merge heads

This commit is contained in:
Jimmy Shih
2012-04-06 18:25:57 -07:00
16 changed files with 84 additions and 105 deletions
@@ -8,11 +8,13 @@ import com.google.android.maps.mytracks.R;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle; import android.os.Bundle;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.MenuItem;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
@@ -60,8 +62,7 @@ public class AggregatedStatsActivity extends Activity implements
this.tracksProvider = MyTracksProviderUtils.Factory.get(this); this.tracksProvider = MyTracksProviderUtils.Factory.get(this);
// Show the action bar (or nothing at all). ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
ApiAdapterFactory.getApiAdapter().showActionBar(this);
setContentView(R.layout.stats); setContentView(R.layout.stats);
@@ -87,6 +88,16 @@ public class AggregatedStatsActivity extends Activity implements
loadAggregatedStats(); loadAggregatedStats();
} }
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() != android.R.id.home) {
return false;
}
startActivity(new Intent(this, TrackListActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
return true;
}
/** /**
* 1. Reads tracks from the db * 1. Reads tracks from the db
* 2. Merges the trip stats from the tracks * 2. Merges the trip stats from the tracks
@@ -28,7 +28,6 @@ import com.google.android.apps.mytracks.content.TrackDataListener;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.stats.DoubleBuffer; import com.google.android.apps.mytracks.stats.DoubleBuffer;
import com.google.android.apps.mytracks.stats.TripStatisticsBuilder; import com.google.android.apps.mytracks.stats.TripStatisticsBuilder;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.LocationUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.apps.mytracks.util.UnitConversions; import com.google.android.apps.mytracks.util.UnitConversions;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -118,9 +117,6 @@ public class ChartActivity extends Activity implements TrackDataListener {
// The volume we want to control is the Text-To-Speech volume // The volume we want to control is the Text-To-Speech volume
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM); setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
// Show the action bar (or nothing at all).
ApiAdapterFactory.getApiAdapter().showActionBar(this);
setContentView(R.layout.mytracks_charts); setContentView(R.layout.mytracks_charts);
ViewGroup layout = (ViewGroup) findViewById(R.id.elevation_chart); ViewGroup layout = (ViewGroup) findViewById(R.id.elevation_chart);
chartView = new ChartView(this); chartView = new ChartView(this);
@@ -141,8 +141,7 @@ public class ImportActivity extends Activity {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (!importAll && trackId != -1L) { if (!importAll && trackId != -1L) {
Intent intent = new Intent(ImportActivity.this, TrackDetailActivity.class) Intent intent = new Intent(ImportActivity.this, TrackDetailActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(TrackDetailActivity.TRACK_ID, trackId); .putExtra(TrackDetailActivity.TRACK_ID, trackId);
startActivity(intent); startActivity(intent);
} }
@@ -24,7 +24,6 @@ import com.google.android.apps.mytracks.content.TrackDataHub.ListenerDataType;
import com.google.android.apps.mytracks.content.TrackDataListener; import com.google.android.apps.mytracks.content.TrackDataListener;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.stats.TripStatistics; import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.GeoRect; import com.google.android.apps.mytracks.util.GeoRect;
import com.google.android.apps.mytracks.util.LocationUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
@@ -142,9 +141,6 @@ public class MapActivity extends com.google.android.maps.MapActivity
// The volume we want to control is the Text-To-Speech volume // The volume we want to control is the Text-To-Speech volume
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM); setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
// Show the action bar (or nothing at all).
ApiAdapterFactory.getApiAdapter().showActionBar(this);
// Inflate the layout: // Inflate the layout:
setContentView(R.layout.mytracks_layout); setContentView(R.layout.mytracks_layout);
@@ -248,11 +248,10 @@ public class SearchActivity extends ListActivity {
private Intent createViewDataIntent(Map<String, Object> clickedData) { private Intent createViewDataIntent(Map<String, Object> clickedData) {
Intent intent = new Intent(this, TrackDetailActivity.class) Intent intent = new Intent(this, TrackDetailActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(TrackDetailActivity.TRACK_ID, (Long) clickedData.get(TRACK_ID_FIELD));
if (clickedData.containsKey(WAYPOINT_ID_FIELD)) { if (clickedData.containsKey(WAYPOINT_ID_FIELD)) {
intent.putExtra(TrackDetailActivity.WAYPOINT_ID, (Long) clickedData.get(WAYPOINT_ID_FIELD)); intent.putExtra(TrackDetailActivity.WAYPOINT_ID, (Long) clickedData.get(WAYPOINT_ID_FIELD));
} else {
intent.putExtra(TrackDetailActivity.TRACK_ID, (Long) clickedData.get(TRACK_ID_FIELD));
} }
return intent; return intent;
} }
@@ -628,7 +628,7 @@ public class SettingsActivity extends PreferenceActivity {
// Restart the settings activity so all changes are loaded. // Restart the settings activity so all changes are loaded.
Intent intent = getIntent(); Intent intent = getIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent); startActivity(intent);
} }
}); });
@@ -23,7 +23,6 @@ import com.google.android.apps.mytracks.content.TrackDataHub.ListenerDataType;
import com.google.android.apps.mytracks.content.TrackDataListener; import com.google.android.apps.mytracks.content.TrackDataListener;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.services.ServiceUtils; import com.google.android.apps.mytracks.services.ServiceUtils;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.UnitConversions; import com.google.android.apps.mytracks.util.UnitConversions;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -107,9 +106,6 @@ public class StatsActivity extends Activity implements TrackDataListener {
// The volume we want to control is the Text-To-Speech volume // The volume we want to control is the Text-To-Speech volume
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM); setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
// Show the action bar (or nothing at all).
ApiAdapterFactory.getApiAdapter().showActionBar(this);
setContentView(R.layout.stats); setContentView(R.layout.stats);
ScrollView sv = ((ScrollView) findViewById(R.id.scrolly)); ScrollView sv = ((ScrollView) findViewById(R.id.scrolly));
@@ -21,7 +21,6 @@ import static com.google.android.apps.mytracks.Constants.STATS_TAB_TAG;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.TrackDataHub; import com.google.android.apps.mytracks.content.TrackDataHub;
import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.content.WaypointCreationRequest; import com.google.android.apps.mytracks.content.WaypointCreationRequest;
import com.google.android.apps.mytracks.io.file.SaveActivity; import com.google.android.apps.mytracks.io.file.SaveActivity;
import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat; import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat;
@@ -78,7 +77,8 @@ public class TrackDetailActivity extends TabActivity implements OnTouchListener
private TrackDataHub trackDataHub; private TrackDataHub trackDataHub;
private TrackRecordingServiceConnection trackRecordingServiceConnection; private TrackRecordingServiceConnection trackRecordingServiceConnection;
private NavControls navControls; private NavControls navControls;
private long trackId;
private MenuItem stopRecordingMenuItem; private MenuItem stopRecordingMenuItem;
private MenuItem insertMarkerMenuItem; private MenuItem insertMarkerMenuItem;
private MenuItem playMenuItem; private MenuItem playMenuItem;
@@ -104,10 +104,7 @@ public class TrackDetailActivity extends TabActivity implements OnTouchListener
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) { public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
// Note that key can be null // Note that key can be null
if (getString(R.string.recording_track_key).equals(key)) { if (getString(R.string.recording_track_key).equals(key)) {
if (isRecording()) { updateMenu();
trackRecordingServiceConnection.startAndBind();
}
updateMenu();
} }
} }
}; };
@@ -116,16 +113,14 @@ public class TrackDetailActivity extends TabActivity implements OnTouchListener
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE); sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
trackDataHub = ((MyTracksApplication) getApplication()).getTrackDataHub(); trackDataHub = ((MyTracksApplication) getApplication()).getTrackDataHub();
trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, null); trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, null);
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
// Show the action bar (or nothing at all).
ApiAdapterFactory.getApiAdapter().showActionBar(this);
final Resources res = getResources(); final Resources res = getResources();
final TabHost tabHost = getTabHost(); final TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec(MAP_TAB_TAG) tabHost.addTab(tabHost.newTabSpec(MAP_TAB_TAG)
@@ -150,43 +145,33 @@ public class TrackDetailActivity extends TabActivity implements OnTouchListener
navControls.show(); navControls.show();
tabHost.addView(layout); tabHost.addView(layout);
layout.setOnTouchListener(this); layout.setOnTouchListener(this);
// Get the trackid
Intent intent = getIntent();
trackId = intent.getLongExtra(TRACK_ID, -1L);
if (trackId == -1L) {
startTrackListActivity();
finish();
}
trackDataHub.loadTrack(trackId);
// Get the waypointId
long waypointId = intent.getLongExtra(WAYPOINT_ID, -1L);
if (waypointId != -1L) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
getTabHost().setCurrentTab(0);
mapActivity.showWaypoint(trackId, waypointId);
} else {
Log.e(TAG, "MapActivity is null");
}
}
} }
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
trackDataHub.start(); trackDataHub.start();
if (isRecording()) {
trackRecordingServiceConnection.startAndBind();
}
Intent intent = getIntent();
long trackId = intent.getLongExtra(TRACK_ID, -1L);
if (trackId != -1L) {
trackDataHub.loadTrack(trackId);
return;
}
long waypointId = intent.getLongExtra(WAYPOINT_ID, -1L);
if (waypointId != -1L) {
Waypoint waypoint = MyTracksProviderUtils.Factory.get(this).getWaypoint(waypointId);
if (waypoint != null) {
trackId = waypoint.getTrackId();
trackDataHub.loadTrack(trackId);
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
getTabHost().setCurrentTab(0);
mapActivity.showWaypoint(trackId, waypointId);
} else {
Log.e(TAG, "MapActivity is null");
}
return;
}
}
// No track id or waypoint id, return to the track list activity.
startTrackListActivity();
} }
@Override @Override
@@ -272,8 +257,10 @@ public class TrackDetailActivity extends TabActivity implements OnTouchListener
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
MapActivity mapActivity; MapActivity mapActivity;
Intent intent; Intent intent;
long trackId = trackDataHub.getSelectedTrackId();
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home:
startTrackListActivity();
return true;
case R.id.menu_stop_recording: case R.id.menu_stop_recording:
updateMenuItems(false); updateMenuItems(false);
stopRecording(); stopRecording();
@@ -299,16 +286,16 @@ public class TrackDetailActivity extends TabActivity implements OnTouchListener
startActivity(intent); startActivity(intent);
return true; return true;
case R.id.menu_share_gpx: case R.id.menu_share_gpx:
startSaveActivity(trackId, TrackFileFormat.GPX, true); startSaveActivity(TrackFileFormat.GPX, true);
return true; return true;
case R.id.menu_share_kml: case R.id.menu_share_kml:
startSaveActivity(trackId, TrackFileFormat.KML, true); startSaveActivity(TrackFileFormat.KML, true);
return true; return true;
case R.id.menu_share_csv: case R.id.menu_share_csv:
startSaveActivity(trackId, TrackFileFormat.CSV, true); startSaveActivity(TrackFileFormat.CSV, true);
return true; return true;
case R.id.menu_share_tcx: case R.id.menu_share_tcx:
startSaveActivity(trackId, TrackFileFormat.TCX, true); startSaveActivity(TrackFileFormat.TCX, true);
return true; return true;
case R.id.menu_markers: case R.id.menu_markers:
intent = new Intent(this, WaypointsList.class) intent = new Intent(this, WaypointsList.class)
@@ -321,16 +308,16 @@ public class TrackDetailActivity extends TabActivity implements OnTouchListener
startActivity(intent); startActivity(intent);
return true; return true;
case R.id.menu_save_gpx: case R.id.menu_save_gpx:
startSaveActivity(trackId, TrackFileFormat.GPX, false); startSaveActivity(TrackFileFormat.GPX, false);
return true; return true;
case R.id.menu_save_kml: case R.id.menu_save_kml:
startSaveActivity(trackId, TrackFileFormat.KML, false); startSaveActivity(TrackFileFormat.KML, false);
return true; return true;
case R.id.menu_save_csv: case R.id.menu_save_csv:
startSaveActivity(trackId, TrackFileFormat.CSV, false); startSaveActivity(TrackFileFormat.CSV, false);
return true; return true;
case R.id.menu_save_tcx: case R.id.menu_save_tcx:
startSaveActivity(trackId, TrackFileFormat.TCX, false); startSaveActivity(TrackFileFormat.TCX, false);
return true; return true;
case R.id.menu_edit: case R.id.menu_edit:
startActivity(new Intent(this, TrackEditActivity.class) startActivity(new Intent(this, TrackEditActivity.class)
@@ -431,7 +418,8 @@ public class TrackDetailActivity extends TabActivity implements OnTouchListener
* Updates the menu. * Updates the menu.
*/ */
private void updateMenu() { private void updateMenu() {
updateMenuItems(isRecording()); updateMenuItems(
trackId == sharedPreferences.getLong(getString(R.string.recording_track_key), -1L));
} }
/** /**
@@ -475,25 +463,20 @@ public class TrackDetailActivity extends TabActivity implements OnTouchListener
} }
/** /**
* Starts the {@link TrackListActivity} and ends this activity. * Starts the {@link TrackListActivity}.
*/ */
private void startTrackListActivity() { private void startTrackListActivity() {
Intent intent = new Intent(this, TrackListActivity.class) startActivity(new Intent(this, TrackListActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
} }
/** /**
* Starts the {@link SaveActivity} to save a track. * Starts the {@link SaveActivity} to save a track.
* *
* @param trackId the track id
* @param trackFileFormat the track file format * @param trackFileFormat the track file format
* @param shareTrack true to share the track after saving * @param shareTrack true to share the track after saving
*/ */
private void startSaveActivity( private void startSaveActivity(TrackFileFormat trackFileFormat, boolean shareTrack) {
long trackId, TrackFileFormat trackFileFormat, boolean shareTrack) {
Intent intent = new Intent(this, SaveActivity.class) Intent intent = new Intent(this, SaveActivity.class)
.putExtra(SaveActivity.EXTRA_TRACK_ID, trackId) .putExtra(SaveActivity.EXTRA_TRACK_ID, trackId)
.putExtra(SaveActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) trackFileFormat) .putExtra(SaveActivity.EXTRA_TRACK_FILE_FORMAT, (Parcelable) trackFileFormat)
@@ -41,6 +41,7 @@ import android.os.Bundle;
import android.os.Parcelable; import android.os.Parcelable;
import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.LoaderManager.LoaderCallbacks; import android.support.v4.app.LoaderManager.LoaderCallbacks;
@@ -169,6 +170,7 @@ public class TrackListActivity extends FragmentActivity {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(TrackListActivity.this, TrackDetailActivity.class) Intent intent = new Intent(TrackListActivity.this, TrackDetailActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(TrackDetailActivity.TRACK_ID, id); .putExtra(TrackDetailActivity.TRACK_ID, id);
startActivity(intent); startActivity(intent);
} }
@@ -238,15 +240,10 @@ public class TrackListActivity extends FragmentActivity {
}); });
if (!EulaUtils.getEulaValue(this)) { if (!EulaUtils.getEulaValue(this)) {
new EulaDialogFragment().show(getSupportFragmentManager(), EULA_DIALOG_TAG); Fragment fragment = getSupportFragmentManager().findFragmentByTag(EULA_DIALOG_TAG);
} if (fragment == null) {
} new EulaDialogFragment().show(getSupportFragmentManager(), EULA_DIALOG_TAG);
}
@Override
protected void onStart() {
super.onStart();
if (isRecording()) {
trackRecordingServiceConnection.startAndBind();
} }
} }
@@ -92,9 +92,8 @@ public class RestoreActivity extends Activity {
public void onAsyncTaskCompleted(boolean success, int messageId) { public void onAsyncTaskCompleted(boolean success, int messageId) {
removeDialog(DIALOG_PROGRESS_ID); removeDialog(DIALOG_PROGRESS_ID);
Toast.makeText(this, messageId, success ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show(); Toast.makeText(this, messageId, success ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show();
startActivity( startActivity(new Intent(this, TrackListActivity.class)
new Intent(this, TrackListActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
finish();
} }
/** /**
@@ -206,8 +206,7 @@ public class SaveActivity extends Activity {
startActivity(Intent.createChooser(intent, getString(R.string.share_track_picker_title))); startActivity(Intent.createChooser(intent, getString(R.string.share_track_picker_title)));
} else if (playTrack) { } else if (playTrack) {
Intent intent = new Intent() Intent intent = new Intent()
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(PlayTrackUtils.TOUR_FEATURE_ID, KmlTrackWriter.TOUR_FEATURE_ID) .putExtra(PlayTrackUtils.TOUR_FEATURE_ID, KmlTrackWriter.TOUR_FEATURE_ID)
.setClassName(PlayTrackUtils.GOOGLE_EARTH_PACKAGE, PlayTrackUtils.GOOGLE_EARTH_CLASS) .setClassName(PlayTrackUtils.GOOGLE_EARTH_PACKAGE, PlayTrackUtils.GOOGLE_EARTH_CLASS)
.setDataAndType(Uri.fromFile(new File(filePath)), PlayTrackUtils.KML_MIME_TYPE); .setDataAndType(Uri.fromFile(new File(filePath)), PlayTrackUtils.KML_MIME_TYPE);
@@ -485,6 +485,7 @@ public class TrackRecordingService extends Service {
R.drawable.arrow_320, null /* tickerText */, R.drawable.arrow_320, null /* tickerText */,
System.currentTimeMillis()); System.currentTimeMillis());
Intent intent = new Intent(this, TrackDetailActivity.class) Intent intent = new Intent(this, TrackDetailActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(TrackDetailActivity.TRACK_ID, recordingTrackId); .putExtra(TrackDetailActivity.TRACK_ID, recordingTrackId);
PendingIntent contentIntent = PendingIntent.getActivity( PendingIntent contentIntent = PendingIntent.getActivity(
this, 0 /* requestCode */, intent, 0 /* flags */); this, 0 /* requestCode */, intent, 0 /* flags */);
@@ -17,11 +17,11 @@
package com.google.android.apps.mytracks.util; package com.google.android.apps.mytracks.util;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity; import android.app.Activity;
import android.app.SearchManager; import android.app.SearchManager;
import android.content.Context; import android.content.Context;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.Window;
import android.widget.SearchView; import android.widget.SearchView;
/** /**
@@ -33,8 +33,10 @@ import android.widget.SearchView;
public class Api11Adapter extends Api10Adapter { public class Api11Adapter extends Api10Adapter {
@Override @Override
public void showActionBar(Activity activity) { public void configureActionBarHomeAsUp(Activity activity) {
activity.requestWindowFeature(Window.FEATURE_ACTION_BAR); ActionBar actionBar = activity.getActionBar();
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
@@ -104,7 +104,7 @@ public class Api7Adapter implements ApiAdapter {
} }
@Override @Override
public void showActionBar(Activity activity) { public void configureActionBarHomeAsUp(Activity activity) {
// Action bar not available, just hide the title and let actions be shown // Action bar not available, just hide the title and let actions be shown
// via the regular menu. // via the regular menu.
activity.requestWindowFeature(Window.FEATURE_NO_TITLE); activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
@@ -101,15 +101,15 @@ public interface ApiAdapter {
*/ */
public BluetoothSocket getBluetoothSocket(BluetoothDevice bluetoothDevice) throws IOException; public BluetoothSocket getBluetoothSocket(BluetoothDevice bluetoothDevice) throws IOException;
/** /**
* Shows the action bar, if the current system supports it. * Configures the action bar with the Home button as an Up button. If the
* If it's not supported, the title bar will be kept hidden. * system doesn't support action bar, hide the title bar.
* * <p>
* Due to changes in API level 11. * Due to changes in API level 11.
* *
* @param activity the current activity * @param activity the current activity
*/ */
public void showActionBar(Activity activity); public void configureActionBarHomeAsUp(Activity activity);
/** /**
* Configures the search widget. * Configures the search widget.
@@ -145,7 +145,8 @@ public class TrackWidgetProvider
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.track_widget); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.track_widget);
// Make all of the stats open the mytracks activity. // Make all of the stats open the mytracks activity.
Intent intent = new Intent(context, TrackDetailActivity.class); Intent intent = new Intent(context, TrackDetailActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
if (track != null) { if (track != null) {
intent.putExtra(TrackDetailActivity.TRACK_ID, track.getId()); intent.putExtra(TrackDetailActivity.TRACK_ID, track.getId());
} }