Do not show the check units dialog on startup.

Use imperial for US. Use metrics for others.
This commit is contained in:
Jimmy Shih
2012-11-07 12:54:28 -08:00
parent 85bbb950d2
commit 0ebc8d255d
3 changed files with 11 additions and 21 deletions
@@ -22,7 +22,6 @@ 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;
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller;
@@ -163,7 +162,8 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
runOnUiThread(new Runnable() {
@Override
public void run() {
boolean isRecording = recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
boolean isRecording = recordingTrackId
!= PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
updateMenuItems(isRecording);
resourceCursorAdapter.notifyDataSetChanged();
trackController.update(isRecording, recordingTrackPaused);
@@ -428,7 +428,7 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
// Update track data hub
handleStartGps();
// Update UI
boolean isRecording = recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
updateMenuItems(isRecording);
@@ -449,7 +449,7 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
// Update track data hub
trackDataHub.unregisterTrackDataListener(trackDataListener);
// Update UI
trackController.stop();
}
@@ -595,13 +595,6 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
new WelcomeDialogFragment().show(
getSupportFragmentManager(), WelcomeDialogFragment.WELCOME_DIALOG_TAG);
}
} else if (EulaUtils.getShowCheckUnits(this)) {
Fragment fragment = getSupportFragmentManager()
.findFragmentByTag(CheckUnitsDialogFragment.CHECK_UNITS_DIALOG_TAG);
if (fragment == null) {
new CheckUnitsDialogFragment().show(
getSupportFragmentManager(), CheckUnitsDialogFragment.CHECK_UNITS_DIALOG_TAG);
}
} else {
/*
* Before the welcome sequence, the empty view is not visible so that it
@@ -18,6 +18,7 @@ package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.TrackListActivity;
import com.google.android.apps.mytracks.util.EulaUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.app.AlertDialog;
@@ -27,6 +28,8 @@ import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import java.util.Locale;
/**
* A DialogFragment to show EULA.
*
@@ -84,6 +87,9 @@ public class EulaDialogFragment extends DialogFragment {
@Override
public void onClick(DialogInterface dialog, int which) {
EulaUtils.setAcceptEula(activity);
Locale locale = Locale.getDefault();
PreferencesUtils.setBoolean(
activity, R.string.metric_units_key, !Locale.US.equals(Locale.getDefault()));
TrackListActivity trackListActivity = (TrackListActivity) activity;
trackListActivity.showStartupDialogs();
}
@@ -31,7 +31,6 @@ public class EulaUtils {
// Accepting Google mobile terms of service
private static final String ACCEPT_EULA_PREFERENCE_KEY = "eula.google_mobile_tos_accepted";
private static final String SHOW_WELCOME_PREFERENCE_KEY = "showWelcome";
private static final String SHOW_CHECK_UNITS_PREFERENCE_KEY = "showCheckUnits";
private EulaUtils() {}
@@ -50,15 +49,7 @@ public class EulaUtils {
public static void setShowWelcome(Context context) {
setValue(context, SHOW_WELCOME_PREFERENCE_KEY, false);
}
public static boolean getShowCheckUnits(Context context) {
return getValue(context, SHOW_CHECK_UNITS_PREFERENCE_KEY, true);
}
public static void setShowCheckUnits(Context context) {
setValue(context, SHOW_CHECK_UNITS_PREFERENCE_KEY, false);
}
private static boolean getValue(Context context, String key, boolean defaultValue) {
SharedPreferences sharedPreferences = context.getSharedPreferences(
EULA_PREFERENCE_FILE, Context.MODE_PRIVATE);