forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
@@ -21,6 +21,11 @@ limitations under the License.
|
||||
android:id="@+id/track_list_search"
|
||||
android:showAsAction="ifRoom|collapseActionView"
|
||||
android:title="@string/menu_search"/>
|
||||
<item
|
||||
android:icon="@drawable/menu_start_gps"
|
||||
android:id="@+id/track_list_start_gps"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/menu_start_gps"/>
|
||||
<item
|
||||
android:icon="@drawable/menu_import"
|
||||
android:id="@+id/track_list_import"
|
||||
|
||||
@@ -1171,6 +1171,18 @@ limitations under the License.
|
||||
Character limit: ~20 (1 line)">
|
||||
Split frequency
|
||||
</string>
|
||||
<string name="menu_start_gps"
|
||||
translation_description="In the menu, to start the GPS receiver on the phone.
|
||||
|
||||
Character limit: ~20 (1 line)">
|
||||
Start GPS
|
||||
</string>
|
||||
<string name="menu_stop_gps"
|
||||
translation_description="In the menu, to stop the GPS receiver on the phone.
|
||||
|
||||
Character limit: ~20 (1 line)">
|
||||
Stop GPS
|
||||
</string>
|
||||
<string name="menu_voice_frequency"
|
||||
translation_description="In the menu, to configure the voice frequency, how frequent to announce
|
||||
status.
|
||||
|
||||
@@ -28,14 +28,20 @@ import android.view.MenuItem;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class AbstractMyTracksActivity extends FragmentActivity {
|
||||
public abstract class AbstractMyTracksActivity extends FragmentActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
|
||||
setContentView(getLayoutResId());
|
||||
ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the layout resource id.
|
||||
*/
|
||||
protected abstract int getLayoutResId();
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
@@ -36,11 +36,15 @@ public class AggregatedStatsActivity extends AbstractMyTracksActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.aggregated_stats);
|
||||
StatsUtils.setTripStatisticsValues(this, getTripStatistics());
|
||||
StatsUtils.setLocationValues(this, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.aggregated_stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the aggregated trip statistics for all the recorded tracks or null if
|
||||
* there is no track.
|
||||
|
||||
@@ -35,7 +35,6 @@ public class HelpActivity extends AbstractMyTracksActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.help);
|
||||
|
||||
TextView mapsPublicUnlisted = (TextView) findViewById(R.id.help_maps_public_unlisted_answer);
|
||||
mapsPublicUnlisted.setText(StringUtils.getHtml(
|
||||
@@ -58,4 +57,9 @@ public class HelpActivity extends AbstractMyTracksActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.help;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ public class MarkerDetailActivity extends AbstractMyTracksActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.marker_detail);
|
||||
|
||||
markerId = getIntent().getLongExtra(EXTRA_MARKER_ID, -1L);
|
||||
if (markerId == -1L) {
|
||||
@@ -64,6 +63,11 @@ public class MarkerDetailActivity extends AbstractMyTracksActivity {
|
||||
statisticsSection = findViewById(R.id.marker_detail_statistics_section);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.marker_detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -62,7 +62,6 @@ public class MarkerEditActivity extends AbstractMyTracksActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.marker_edit);
|
||||
|
||||
trackId = getIntent().getLongExtra(EXTRA_TRACK_ID, -1L);
|
||||
markerId = getIntent().getLongExtra(EXTRA_MARKER_ID, -1L);
|
||||
@@ -91,6 +90,11 @@ public class MarkerEditActivity extends AbstractMyTracksActivity {
|
||||
updateUiByMarkerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.marker_edit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the UI based on the marker id.
|
||||
*/
|
||||
|
||||
@@ -113,7 +113,6 @@ public class MarkerListActivity extends AbstractMyTracksActivity {
|
||||
}
|
||||
|
||||
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
|
||||
setContentView(R.layout.marker_list);
|
||||
|
||||
getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE)
|
||||
.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
||||
@@ -179,6 +178,11 @@ public class MarkerListActivity extends AbstractMyTracksActivity {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.marker_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.marker_list, menu);
|
||||
|
||||
@@ -137,7 +137,6 @@ public class SearchListActivity extends AbstractMyTracksActivity implements Dele
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
|
||||
setContentView(R.layout.search_list);
|
||||
|
||||
trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, null);
|
||||
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
|
||||
@@ -202,6 +201,11 @@ public class SearchListActivity extends AbstractMyTracksActivity implements Dele
|
||||
handleIntent(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.search_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -92,10 +92,14 @@ public class SensorStateActivity extends AbstractMyTracksActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.sensor_state);
|
||||
trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.sensor_state;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -143,7 +143,7 @@ public class TabManager implements TabHost.OnTabChangeListener {
|
||||
}
|
||||
|
||||
lastTabInfo = newTabInfo;
|
||||
fragmentTransaction.commit();
|
||||
fragmentTransaction.commitAllowingStateLoss();
|
||||
fragmentActivity.getSupportFragmentManager().executePendingTransactions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
||||
public static final String EXTRA_MARKER_ID = "marker_id";
|
||||
|
||||
private static final String TAG = TrackDetailActivity.class.getSimpleName();
|
||||
private static final String CURRENT_TAG_KEY = "tab";
|
||||
private static final String CURRENT_TAB_TAG_KEY = "current_tab_tag_key";
|
||||
|
||||
// The following are set in onCreate
|
||||
private TrackRecordingServiceConnection trackRecordingServiceConnection;
|
||||
@@ -192,7 +192,6 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
||||
super.onCreate(savedInstanceState);
|
||||
handleIntent(getIntent());
|
||||
ApiAdapterFactory.getApiAdapter().hideTitle(this);
|
||||
setContentView(R.layout.track_detail);
|
||||
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(
|
||||
Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||
@@ -220,12 +219,17 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
||||
getResources().getDrawable(R.drawable.tab_stats));
|
||||
tabManager.addTab(statsTabSpec, StatsFragment.class, null);
|
||||
if (savedInstanceState != null) {
|
||||
tabHost.setCurrentTabByTag(savedInstanceState.getString(CURRENT_TAG_KEY));
|
||||
tabHost.setCurrentTabByTag(savedInstanceState.getString(CURRENT_TAB_TAG_KEY));
|
||||
}
|
||||
trackController = new TrackController(this, trackRecordingServiceConnection, false, recordListener, stopListener);
|
||||
showMarker();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.track_detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
@@ -249,7 +253,7 @@ public class TrackDetailActivity extends AbstractMyTracksActivity implements Del
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putString(CURRENT_TAG_KEY, tabHost.getCurrentTabTag());
|
||||
outState.putString(CURRENT_TAB_TAG_KEY, tabHost.getCurrentTabTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,7 +57,6 @@ public class TrackEditActivity extends AbstractMyTracksActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
setContentView(R.layout.track_edit);
|
||||
|
||||
trackId = getIntent().getLongExtra(EXTRA_TRACK_ID, -1L);
|
||||
if (trackId == -1L) {
|
||||
@@ -143,6 +142,11 @@ public class TrackEditActivity extends AbstractMyTracksActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.track_edit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the activity type icon.
|
||||
*
|
||||
|
||||
@@ -16,7 +16,12 @@
|
||||
|
||||
package com.google.android.apps.mytracks;
|
||||
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.TrackDataHub;
|
||||
import com.google.android.apps.mytracks.content.TrackDataListener;
|
||||
import com.google.android.apps.mytracks.content.TrackDataType;
|
||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.fragments.CheckUnitsDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.DeleteAllTrackDialogFragment;
|
||||
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment;
|
||||
@@ -44,6 +49,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.database.Cursor;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
@@ -67,6 +73,8 @@ import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* An activity displaying a list of tracks.
|
||||
*
|
||||
@@ -75,7 +83,8 @@ import android.widget.Toast;
|
||||
public class TrackListActivity extends FragmentActivity implements DeleteOneTrackCaller {
|
||||
|
||||
private static final String TAG = TrackListActivity.class.getSimpleName();
|
||||
|
||||
private static final String START_GPS_KEY = "start_gps_key";
|
||||
|
||||
private static final String[] PROJECTION = new String[] { TracksColumns._ID, TracksColumns.NAME,
|
||||
TracksColumns.DESCRIPTION, TracksColumns.CATEGORY, TracksColumns.STARTTIME,
|
||||
TracksColumns.TOTALDISTANCE, TracksColumns.TOTALTIME, TracksColumns.ICON };
|
||||
@@ -181,6 +190,8 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
if (recordingTrackId == PreferencesUtils.RECORDING_TRACK_ID_DEFAULT) {
|
||||
// Not recording -> Recording
|
||||
AnalyticsUtils.sendPageViews(TrackListActivity.this, "/action/record_track");
|
||||
startGps = false;
|
||||
handleStartGps();
|
||||
updateMenuItems(true);
|
||||
startRecording();
|
||||
} else {
|
||||
@@ -211,11 +222,94 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
}
|
||||
};
|
||||
|
||||
private final TrackDataListener trackDataListener = new TrackDataListener() {
|
||||
@Override
|
||||
public void onTrackUpdated(Track track) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelectedTrackChanged(Track track) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSegmentSplit(Location location) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSampledOutTrackPoint(Location location) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSampledInTrackPoint(Location location) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onReportSpeedChanged(boolean reportSpeed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewWaypointsDone() {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewWaypoint(Waypoint waypoint) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewTrackPointsDone() {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMinRecordingDistanceChanged(int minRecordingDistance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMetricUnitsChanged(boolean isMetricUnits) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationStateChanged(LocationState locationState) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadingChanged(double heading) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearWaypoints() {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearTrackPoints() {
|
||||
// Ignore
|
||||
}
|
||||
};
|
||||
|
||||
// The following are set in onCreate
|
||||
private TrackRecordingServiceConnection trackRecordingServiceConnection;
|
||||
private TrackController trackController;
|
||||
private ListView listView;
|
||||
private ResourceCursorAdapter resourceCursorAdapter;
|
||||
private TrackDataHub trackDataHub;
|
||||
|
||||
// Preferences
|
||||
private boolean metricUnits;
|
||||
@@ -224,11 +318,13 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
|
||||
// Menu items
|
||||
private MenuItem searchMenuItem;
|
||||
private MenuItem startGpsMenuItem;
|
||||
private MenuItem importMenuItem;
|
||||
private MenuItem saveAllMenuItem;
|
||||
private MenuItem deleteAllMenuItem;
|
||||
|
||||
private boolean startNewRecording = false; // true to start a new recording
|
||||
private boolean startGps = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -306,10 +402,19 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
resourceCursorAdapter.swapCursor(null);
|
||||
}
|
||||
});
|
||||
|
||||
trackDataHub = TrackDataHub.newInstance(this);
|
||||
if (savedInstanceState != null) {
|
||||
startGps = savedInstanceState.getBoolean(START_GPS_KEY);
|
||||
}
|
||||
showStartupDialogs();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
trackDataHub.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
@@ -322,6 +427,19 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
TrackRecordingServiceConnectionUtils.resumeConnection(this, trackRecordingServiceConnection);
|
||||
trackController.update(
|
||||
recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT, recordingTrackPaused);
|
||||
handleStartGps();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(START_GPS_KEY, startGps);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
trackDataHub.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -344,6 +462,7 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
.setTitle(getString(R.string.menu_save_format, fileTypes[3]));
|
||||
|
||||
searchMenuItem = menu.findItem(R.id.track_list_search);
|
||||
startGpsMenuItem = menu.findItem(R.id.track_list_start_gps);
|
||||
importMenuItem = menu.findItem(R.id.track_list_import);
|
||||
saveAllMenuItem = menu.findItem(R.id.track_list_save_all);
|
||||
deleteAllMenuItem = menu.findItem(R.id.track_list_delete_all);
|
||||
@@ -359,6 +478,11 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
switch (item.getItemId()) {
|
||||
case R.id.track_list_search:
|
||||
return ApiAdapterFactory.getApiAdapter().handleSearchMenuSelection(this);
|
||||
case R.id.track_list_start_gps:
|
||||
startGps = !startGps;
|
||||
handleStartGps();
|
||||
updateMenuItems(recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT);
|
||||
return true;
|
||||
case R.id.track_list_import:
|
||||
AnalyticsUtils.sendPageViews(this, "/action/import");
|
||||
intent = IntentUtils.newIntent(this, ImportActivity.class)
|
||||
@@ -467,6 +591,10 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
* @param isRecording true if recording
|
||||
*/
|
||||
private void updateMenuItems(boolean isRecording) {
|
||||
if (startGpsMenuItem != null) {
|
||||
startGpsMenuItem.setIcon(startGps ? R.drawable.menu_stop_gps : R.drawable.menu_start_gps);
|
||||
startGpsMenuItem.setTitle(startGps ? R.string.menu_stop_gps : R.string.menu_start_gps);
|
||||
}
|
||||
if (importMenuItem != null) {
|
||||
importMenuItem.setVisible(!isRecording);
|
||||
}
|
||||
@@ -534,4 +662,15 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles starting gps.
|
||||
*/
|
||||
private void handleStartGps() {
|
||||
if (startGps) {
|
||||
trackDataHub.registerTrackDataListener(trackDataListener, EnumSet.of(TrackDataType.LOCATION));
|
||||
} else {
|
||||
trackDataHub.unregisterTrackDataListener(trackDataListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -36,17 +37,20 @@ public class AboutDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String ABOUT_DIALOG_TAG = "aboutDialog";
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.about, null);
|
||||
activity = getActivity();
|
||||
View view = activity.getLayoutInflater().inflate(R.layout.about, null);
|
||||
TextView aboutVersion = (TextView) view.findViewById(R.id.about_version);
|
||||
aboutVersion.setText(SystemUtils.getMyTracksVersion(getActivity()));
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
aboutVersion.setText(SystemUtils.getMyTracksVersion(activity));
|
||||
return new AlertDialog.Builder(activity)
|
||||
.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
EulaDialogFragment.newInstance(true).show(
|
||||
getActivity().getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
|
||||
activity.getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.generic_ok, null)
|
||||
|
||||
+20
-16
@@ -26,52 +26,56 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A DialogFragment to check preferred units.
|
||||
*
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class CheckUnitsDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String CHECK_UNITS_DIALOG_TAG = "checkUnitsDialog";
|
||||
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface arg0) {
|
||||
onDone();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = getActivity();
|
||||
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
boolean defaultMetric = !defaultLocale.equals(Locale.US) && !defaultLocale.equals(Locale.UK);
|
||||
PreferencesUtils.setBoolean(getActivity(), R.string.metric_units_key, defaultMetric);
|
||||
PreferencesUtils.setBoolean(activity, R.string.metric_units_key, defaultMetric);
|
||||
final String metric = getString(R.string.settings_stats_units_metric);
|
||||
final String imperial = getString(R.string.settings_stats_units_imperial);
|
||||
final CharSequence[] items = defaultMetric ? new CharSequence[] { metric, imperial }
|
||||
: new CharSequence[] { imperial, metric };
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
return new AlertDialog.Builder(activity).setPositiveButton(
|
||||
R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.metric_units_key, items[position].equals(metric));
|
||||
activity, R.string.metric_units_key, items[position].equals(metric));
|
||||
onDone();
|
||||
}
|
||||
})
|
||||
.setSingleChoiceItems(items, 0, null)
|
||||
.setTitle(R.string.settings_stats_units_title).create();
|
||||
}).setSingleChoiceItems(items, 0, null).setTitle(R.string.settings_stats_units_title)
|
||||
.create();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tasks to perform when done.
|
||||
*/
|
||||
private void onDone() {
|
||||
EulaUtils.setShowCheckUnits(getActivity());
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
EulaUtils.setShowCheckUnits(activity);
|
||||
TrackListActivity trackListActivity = (TrackListActivity) activity;
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
}
|
||||
+14
-11
@@ -16,8 +16,8 @@
|
||||
|
||||
package com.google.android.apps.mytracks.fragments;
|
||||
|
||||
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
|
||||
import com.google.android.apps.mytracks.io.sendtogoogle.ConfirmSharingActivity;
|
||||
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
|
||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.ShareCompat;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -55,6 +56,7 @@ public class ChooseActivityDialogFragment extends DialogFragment {
|
||||
private static final String KEY_TRACK_ID = "trackId";
|
||||
private static final String KEY_TRACK_URL = "trackUrl";
|
||||
|
||||
private FragmentActivity activity;
|
||||
private PackageManager packageManager;
|
||||
|
||||
public static ChooseActivityDialogFragment newInstance(long trackId, String trackUrl) {
|
||||
@@ -69,17 +71,18 @@ public class ChooseActivityDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
packageManager = getActivity().getPackageManager();
|
||||
activity = getActivity();
|
||||
packageManager = activity.getPackageManager();
|
||||
List<DisplayInfo> displayInfos = getDisplayInfos();
|
||||
|
||||
ArrayAdapter<DisplayInfo> arrayAdapter = new ArrayAdapter<DisplayInfo>(getActivity(),
|
||||
ArrayAdapter<DisplayInfo> arrayAdapter = new ArrayAdapter<DisplayInfo>(activity,
|
||||
R.layout.choose_activity_list_item, R.id.choose_activity_list_item_text1, displayInfos) {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view;
|
||||
if (convertView == null) {
|
||||
view = getActivity()
|
||||
.getLayoutInflater().inflate(R.layout.choose_activity_list_item, parent, false);
|
||||
view = activity.getLayoutInflater()
|
||||
.inflate(R.layout.choose_activity_list_item, parent, false);
|
||||
} else {
|
||||
view = convertView;
|
||||
}
|
||||
@@ -98,7 +101,7 @@ public class ChooseActivityDialogFragment extends DialogFragment {
|
||||
return view;
|
||||
}
|
||||
};
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
return new AlertDialog.Builder(activity)
|
||||
.setSingleChoiceItems(arrayAdapter, 0, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
@@ -108,7 +111,7 @@ public class ChooseActivityDialogFragment extends DialogFragment {
|
||||
ActivityInfo activityInfo = displayInfo.resolveInfo.activityInfo;
|
||||
String packageName = activityInfo.applicationInfo.packageName;
|
||||
String className = activityInfo.name;
|
||||
|
||||
|
||||
long trackId = getArguments().getLong(KEY_TRACK_ID);
|
||||
String trackUrl = getArguments().getString(KEY_TRACK_URL);
|
||||
if (trackUrl == null) {
|
||||
@@ -117,15 +120,15 @@ public class ChooseActivityDialogFragment extends DialogFragment {
|
||||
sendRequest.setNewMap(true);
|
||||
sendRequest.setSharingAppPackageName(packageName);
|
||||
sendRequest.setSharingAppClassName(className);
|
||||
Intent intent = IntentUtils.newIntent(getActivity(), ConfirmSharingActivity.class)
|
||||
Intent intent = IntentUtils.newIntent(activity, ConfirmSharingActivity.class)
|
||||
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
|
||||
startActivity(intent);
|
||||
dismiss();
|
||||
} else {
|
||||
Intent intent = IntentUtils.newShareUrlIntent(
|
||||
getActivity(), trackId, trackUrl, packageName, className);
|
||||
activity, trackId, trackUrl, packageName, className);
|
||||
startActivity(intent);
|
||||
getActivity().finish();
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -138,7 +141,7 @@ public class ChooseActivityDialogFragment extends DialogFragment {
|
||||
*/
|
||||
private List<DisplayInfo> getDisplayInfos() {
|
||||
List<DisplayInfo> displayInfos = new ArrayList<DisplayInfo>();
|
||||
Intent intent = ShareCompat.IntentBuilder.from(getActivity())
|
||||
Intent intent = ShareCompat.IntentBuilder.from(activity)
|
||||
.setType(IntentUtils.TEXT_PLAIN_TYPE).getIntent();
|
||||
List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(
|
||||
intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
|
||||
+20
-16
@@ -28,6 +28,7 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
@@ -57,6 +58,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
return chooseUploadServiceDialogFragment;
|
||||
}
|
||||
|
||||
private FragmentActivity activity;
|
||||
private SendRequest sendRequest;
|
||||
|
||||
private CheckBox mapsCheckBox;
|
||||
@@ -68,20 +70,22 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = getActivity();
|
||||
sendRequest = getArguments().getParcelable(KEY_SEND_REQUEST);
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.choose_upload_service, null);
|
||||
|
||||
View view = activity.getLayoutInflater().inflate(R.layout.choose_upload_service, null);
|
||||
|
||||
mapsCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_maps);
|
||||
fusionTablesCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_fusion_tables);
|
||||
docsCheckBox = (CheckBox) view.findViewById(R.id.choose_upload_service_docs);
|
||||
|
||||
mapsCheckBox.setChecked(PreferencesUtils.getBoolean(
|
||||
getActivity(), R.string.send_to_maps_key, PreferencesUtils.SEND_TO_MAPS_DEFAULT));
|
||||
activity, R.string.send_to_maps_key, PreferencesUtils.SEND_TO_MAPS_DEFAULT));
|
||||
fusionTablesCheckBox.setChecked(PreferencesUtils.getBoolean(
|
||||
getActivity(), R.string.send_to_fusion_tables_key,
|
||||
activity, R.string.send_to_fusion_tables_key,
|
||||
PreferencesUtils.SEND_TO_FUSION_TABLES_DEFAULT));
|
||||
docsCheckBox.setChecked(PreferencesUtils.getBoolean(
|
||||
getActivity(), R.string.send_to_docs_key, PreferencesUtils.SEND_TO_DOCS_DEFAULT));
|
||||
activity, R.string.send_to_docs_key, PreferencesUtils.SEND_TO_DOCS_DEFAULT));
|
||||
|
||||
mapsCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(CompoundButton button, boolean checked) {
|
||||
@@ -93,7 +97,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
|
||||
RadioButton newMapRadioButton = (RadioButton) view.findViewById(
|
||||
R.id.choose_upload_service_new_map);
|
||||
boolean defaultMapPublic = PreferencesUtils.getBoolean(getActivity(),
|
||||
boolean defaultMapPublic = PreferencesUtils.getBoolean(activity,
|
||||
R.string.default_map_public_key, PreferencesUtils.DEFAULT_MAP_PUBLIC_DEFAULT);
|
||||
newMapRadioButton.setText(defaultMapPublic ? R.string.send_google_new_public_map
|
||||
: R.string.send_google_new_unlisted_map);
|
||||
@@ -102,31 +106,31 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
R.id.choose_upload_service_existing_map);
|
||||
|
||||
updateMapsOption();
|
||||
if (PreferencesUtils.getBoolean(getActivity(), R.string.pick_existing_map_key,
|
||||
if (PreferencesUtils.getBoolean(activity, R.string.pick_existing_map_key,
|
||||
PreferencesUtils.PICK_EXISTING_MAP_DEFAULT)) {
|
||||
existingMapRadioButton.setChecked(true);
|
||||
} else {
|
||||
newMapRadioButton.setChecked(true);
|
||||
}
|
||||
|
||||
return new AlertDialog.Builder(getActivity()).setNegativeButton(R.string.generic_cancel, null)
|
||||
return new AlertDialog.Builder(activity).setNegativeButton(R.string.generic_cancel, null)
|
||||
.setPositiveButton(R.string.send_google_send_now, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.pick_existing_map_key, existingMapRadioButton.isChecked());
|
||||
activity, R.string.pick_existing_map_key, existingMapRadioButton.isChecked());
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.send_to_maps_key, mapsCheckBox.isChecked());
|
||||
PreferencesUtils.setBoolean(getActivity(), R.string.send_to_fusion_tables_key,
|
||||
activity, R.string.send_to_maps_key, mapsCheckBox.isChecked());
|
||||
PreferencesUtils.setBoolean(activity, R.string.send_to_fusion_tables_key,
|
||||
fusionTablesCheckBox.isChecked());
|
||||
PreferencesUtils.setBoolean(
|
||||
getActivity(), R.string.send_to_docs_key, docsCheckBox.isChecked());
|
||||
activity, R.string.send_to_docs_key, docsCheckBox.isChecked());
|
||||
if (mapsCheckBox.isChecked() || fusionTablesCheckBox.isChecked()
|
||||
|| docsCheckBox.isChecked()) {
|
||||
startNextActivity();
|
||||
} else {
|
||||
Toast.makeText(
|
||||
getActivity(), R.string.send_google_no_service_selected, Toast.LENGTH_LONG)
|
||||
activity, R.string.send_google_no_service_selected, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
@@ -152,7 +156,7 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
sendRequest.setSendDocs(docsCheckBox.isChecked());
|
||||
sendRequest.setNewMap(!existingMapRadioButton.isChecked());
|
||||
sendStats();
|
||||
Intent intent = IntentUtils.newIntent(getActivity(), AccountChooserActivity.class)
|
||||
Intent intent = IntentUtils.newIntent(activity, AccountChooserActivity.class)
|
||||
.putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
|
||||
startActivity(intent);
|
||||
}
|
||||
@@ -162,13 +166,13 @@ public class ChooseUploadServiceDialogFragment extends DialogFragment {
|
||||
*/
|
||||
private void sendStats() {
|
||||
if (sendRequest.isSendMaps()) {
|
||||
AnalyticsUtils.sendPageViews(getActivity(), "/send/maps");
|
||||
AnalyticsUtils.sendPageViews(activity, "/send/maps");
|
||||
}
|
||||
if (sendRequest.isSendFusionTables()) {
|
||||
AnalyticsUtils.sendPageViews(getActivity(), "/send/fusion_tables");
|
||||
AnalyticsUtils.sendPageViews(activity, "/send/fusion_tables");
|
||||
}
|
||||
if (sendRequest.isSendDocs()) {
|
||||
AnalyticsUtils.sendPageViews(getActivity(), "/send/docs");
|
||||
AnalyticsUtils.sendPageViews(activity, "/send/docs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -24,6 +24,7 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFragment to delete all tracks.
|
||||
@@ -34,16 +35,19 @@ public class DeleteAllTrackDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String DELETE_ALL_TRACK_DIALOG_TAG = "deleteAllTrackDialog";
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return DialogUtils.createConfirmationDialog(getActivity(),
|
||||
activity = getActivity();
|
||||
return DialogUtils.createConfirmationDialog(activity,
|
||||
R.string.track_list_delete_all_confirm_message, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MyTracksProviderUtils.Factory.get(getActivity()).deleteAllTracks();
|
||||
MyTracksProviderUtils.Factory.get(activity).deleteAllTracks();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
+9
-5
@@ -28,6 +28,7 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFragment to delete one marker.
|
||||
@@ -50,25 +51,28 @@ public class DeleteOneMarkerDialogFragment extends DialogFragment {
|
||||
return deleteOneMarkerDialogFragment;
|
||||
}
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return DialogUtils.createConfirmationDialog(getActivity(),
|
||||
activity = getActivity();
|
||||
return DialogUtils.createConfirmationDialog(activity,
|
||||
R.string.marker_delete_one_marker_confirm_message, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MyTracksProviderUtils.Factory.get(getActivity()).deleteWaypoint(
|
||||
MyTracksProviderUtils.Factory.get(activity).deleteWaypoint(
|
||||
getArguments().getLong(KEY_MARKER_ID),
|
||||
new DescriptionGeneratorImpl(getActivity()));
|
||||
new DescriptionGeneratorImpl(activity));
|
||||
}
|
||||
}).start();
|
||||
Intent intent = IntentUtils.newIntent(getActivity(), MarkerListActivity.class)
|
||||
Intent intent = IntentUtils.newIntent(activity, MarkerListActivity.class)
|
||||
.putExtra(MarkerListActivity.EXTRA_TRACK_ID, getArguments().getLong(KEY_TRACK_ID));
|
||||
startActivity(intent);
|
||||
// Close the activity since its content can change after delete.
|
||||
getActivity().finish();
|
||||
activity.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+8
-5
@@ -32,6 +32,7 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFragment to delete one track.
|
||||
@@ -52,8 +53,6 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
|
||||
public TrackRecordingServiceConnection getTrackRecordingServiceConnection();
|
||||
}
|
||||
|
||||
private DeleteOneTrackCaller caller;
|
||||
|
||||
public static DeleteOneTrackDialogFragment newInstance(long trackId) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(KEY_TRACK_ID, trackId);
|
||||
@@ -63,6 +62,9 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
|
||||
return deleteOneTrackDialogFragment;
|
||||
}
|
||||
|
||||
private FragmentActivity activity;
|
||||
private DeleteOneTrackCaller caller;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
@@ -75,12 +77,13 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return DialogUtils.createConfirmationDialog(getActivity(),
|
||||
activity = getActivity();
|
||||
return DialogUtils.createConfirmationDialog(activity,
|
||||
R.string.track_detail_delete_confirm_message, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final long trackId = getArguments().getLong(KEY_TRACK_ID);
|
||||
final Context context = getActivity();
|
||||
final Context context = activity;
|
||||
if (trackId == PreferencesUtils.getLong(context, R.string.recording_track_id_key)) {
|
||||
TrackRecordingServiceConnectionUtils.stopRecording(
|
||||
context, caller.getTrackRecordingServiceConnection(), false);
|
||||
@@ -94,7 +97,7 @@ public class DeleteOneTrackDialogFragment extends DialogFragment {
|
||||
Intent intent = IntentUtils.newIntent(context, TrackListActivity.class);
|
||||
startActivity(intent);
|
||||
// Close the activity since its content can change after delete
|
||||
getActivity().finish();
|
||||
activity.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFragment to show EULA.
|
||||
@@ -52,6 +53,8 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
return eulaDialogFragment;
|
||||
}
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface arg0) {
|
||||
if (!getArguments().getBoolean(KEY_HAS_ACCEPTED)) {
|
||||
@@ -61,8 +64,10 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = getActivity();
|
||||
|
||||
boolean hasAccepted = getArguments().getBoolean(KEY_HAS_ACCEPTED);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity)
|
||||
.setMessage(getEulaText())
|
||||
.setTitle(R.string.eula_title);
|
||||
|
||||
@@ -78,8 +83,8 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
EulaUtils.setAcceptEula(getActivity());
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
EulaUtils.setAcceptEula(activity);
|
||||
TrackListActivity trackListActivity = (TrackListActivity) activity;
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
});
|
||||
@@ -91,7 +96,7 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
* Exits the application.
|
||||
*/
|
||||
private void exitApp() {
|
||||
getActivity().finish();
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+9
-4
@@ -24,6 +24,7 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFragment to configure frequency.
|
||||
@@ -50,19 +51,23 @@ public class FrequencyDialogFragment extends DialogFragment {
|
||||
return frequencyDialogFragment;
|
||||
}
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
activity = getActivity();
|
||||
|
||||
final int preferenceId = getArguments().getInt(KEY_PREFERENCE_ID);
|
||||
int defaultValue = getArguments().getInt(KEY_DEFAULT_VALUE);
|
||||
int titleId = getArguments().getInt(KEY_TITLE_ID);
|
||||
int frequencyValue = PreferencesUtils.getInt(getActivity(), preferenceId, defaultValue);
|
||||
int frequencyValue = PreferencesUtils.getInt(activity, preferenceId, defaultValue);
|
||||
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
return new AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int listIndex = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
|
||||
PreferencesUtils.setInt(getActivity(), preferenceId, getFrequencyValue(listIndex));
|
||||
PreferencesUtils.setInt(activity, preferenceId, getFrequencyValue(listIndex));
|
||||
}
|
||||
})
|
||||
.setSingleChoiceItems(getFrequencyDisplayOptions(), getListIndex(frequencyValue), null)
|
||||
@@ -75,7 +80,7 @@ public class FrequencyDialogFragment extends DialogFragment {
|
||||
*/
|
||||
private String[] getFrequencyDisplayOptions() {
|
||||
boolean metricUnits = PreferencesUtils.getBoolean(
|
||||
getActivity(), R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
|
||||
activity, R.string.metric_units_key, PreferencesUtils.METRIC_UNITS_DEFAULT);
|
||||
String[] values = getResources().getStringArray(R.array.frequency_values);
|
||||
String[] options = new String[values.length];
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
|
||||
+6
-2
@@ -27,6 +27,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
@@ -38,9 +39,12 @@ public class InstallEarthDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String INSTALL_EARTH_DIALOG_TAG = "installEarthDialog";
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
activity = getActivity();
|
||||
return new AlertDialog.Builder(activity)
|
||||
.setMessage(R.string.track_detail_install_earth_message)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@@ -51,7 +55,7 @@ public class InstallEarthDialogFragment extends DialogFragment {
|
||||
startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(
|
||||
getActivity(), R.string.track_detail_install_earth_error, Toast.LENGTH_LONG)
|
||||
activity, R.string.track_detail_install_earth_error, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ public class MapFragment extends Fragment
|
||||
|
||||
public static final String MAP_FRAGMENT_TAG = "mapFragment";
|
||||
|
||||
private static final String KEY_CURRENT_LOCATION = "currentLocation";
|
||||
private static final String KEY_KEEP_MY_LOCATION_VISIBLE = "keepMyLocationVisible";
|
||||
private static final String CURRENT_LOCATION_KEY = "current_location_key";
|
||||
private static final String KEEP_MY_LOCATION_VISIBLE_KEY = "keep_my_location_visible_key";
|
||||
|
||||
private TrackDataHub trackDataHub;
|
||||
|
||||
@@ -133,8 +133,8 @@ public class MapFragment extends Fragment
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
if (savedInstanceState != null) {
|
||||
keepMyLocationVisible = savedInstanceState.getBoolean(KEY_KEEP_MY_LOCATION_VISIBLE, false);
|
||||
currentLocation = (Location) savedInstanceState.getParcelable(KEY_CURRENT_LOCATION);
|
||||
keepMyLocationVisible = savedInstanceState.getBoolean(KEEP_MY_LOCATION_VISIBLE_KEY, false);
|
||||
currentLocation = (Location) savedInstanceState.getParcelable(CURRENT_LOCATION_KEY);
|
||||
if (currentLocation != null) {
|
||||
updateCurrentLocation();
|
||||
}
|
||||
@@ -150,9 +150,9 @@ public class MapFragment extends Fragment
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(KEY_KEEP_MY_LOCATION_VISIBLE, keepMyLocationVisible);
|
||||
outState.putBoolean(KEEP_MY_LOCATION_VISIBLE_KEY, keepMyLocationVisible);
|
||||
if (currentLocation != null) {
|
||||
outState.putParcelable(KEY_CURRENT_LOCATION, currentLocation);
|
||||
outState.putParcelable(CURRENT_LOCATION_KEY, currentLocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
/**
|
||||
* A DialogFrament to show the welcome info.
|
||||
@@ -35,6 +36,8 @@ public class WelcomeDialogFragment extends DialogFragment {
|
||||
|
||||
public static final String WELCOME_DIALOG_TAG = "welcomeDialog";
|
||||
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface arg0) {
|
||||
onDone();
|
||||
@@ -42,7 +45,8 @@ public class WelcomeDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
activity = getActivity();
|
||||
return new AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
@@ -55,8 +59,8 @@ public class WelcomeDialogFragment extends DialogFragment {
|
||||
}
|
||||
|
||||
private void onDone() {
|
||||
EulaUtils.setShowWelcome(getActivity());
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
EulaUtils.setShowWelcome(activity);
|
||||
TrackListActivity trackListActivity = (TrackListActivity) activity;
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ public class DialogUtils {
|
||||
int messageId, DialogInterface.OnCancelListener onCancelListener, Object... formatArgs) {
|
||||
ProgressDialog progressDialog = new ProgressDialog(context);
|
||||
progressDialog.setCancelable(true);
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
progressDialog.setIcon(android.R.drawable.ic_dialog_info);
|
||||
progressDialog.setIndeterminate(true);
|
||||
progressDialog.setMessage(context.getString(messageId, formatArgs));
|
||||
|
||||
Reference in New Issue
Block a user