forked from upstream-mirrors/OpenTracks
Do not store show welcome dialog and check unit dialog flags
in the user settings. These two dialogs should only be shown for a new install.
This commit is contained in:
@@ -47,9 +47,7 @@ limitations under the License.
|
||||
<string name="send_to_fusion_tables_key">sendToFusionTables</string>
|
||||
<string name="send_to_maps_key">sendToMaps</string>
|
||||
<string name="sensor_type_key">sensorType</string>
|
||||
<string name="show_check_units_dialog_key">showCheckUnitsDialog</string>
|
||||
<string name="show_confirm_sharing_dialog_key">showConfrimSharingDialog</string>
|
||||
<string name="show_welcome_dialog_key">showWelcomeDialog</string>
|
||||
<string name="split_frequency_key">splitFrequency</string>
|
||||
<string name="stats_show_coordinate_key">statsShowCoordinate</string>
|
||||
<string name="stats_show_elevation_key">statsShowElevation</string>
|
||||
|
||||
@@ -278,23 +278,21 @@ public class TrackListActivity extends FragmentActivity implements DeleteOneTrac
|
||||
* Shows start up dialogs.
|
||||
*/
|
||||
public void showStartupDialogs() {
|
||||
if (!EulaUtils.getEulaValue(this)) {
|
||||
if (!EulaUtils.getAcceptEula(this)) {
|
||||
Fragment fragment = getSupportFragmentManager()
|
||||
.findFragmentByTag(EulaDialogFragment.EULA_DIALOG_TAG);
|
||||
if (fragment == null) {
|
||||
EulaDialogFragment.newInstance(false)
|
||||
.show(getSupportFragmentManager(), EulaDialogFragment.EULA_DIALOG_TAG);
|
||||
}
|
||||
} else if (PreferencesUtils.getBoolean(
|
||||
this, R.string.show_welcome_dialog_key, PreferencesUtils.SHOW_WELCOME_DIALOG_DEFAULT)) {
|
||||
} else if (EulaUtils.getShowWelcome(this)) {
|
||||
Fragment fragment = getSupportFragmentManager()
|
||||
.findFragmentByTag(WelcomeDialogFragment.WELCOME_DIALOG_TAG);
|
||||
if (fragment == null) {
|
||||
new WelcomeDialogFragment().show(
|
||||
getSupportFragmentManager(), WelcomeDialogFragment.WELCOME_DIALOG_TAG);
|
||||
}
|
||||
} else if (PreferencesUtils.getBoolean(this, R.string.show_check_units_dialog_key,
|
||||
PreferencesUtils.SHOW_CHECK_UNITS_DIALOG_DEFAULT)) {
|
||||
} else if (EulaUtils.getShowCheckUnits(this)) {
|
||||
Fragment fragment = getSupportFragmentManager()
|
||||
.findFragmentByTag(CheckUnitsDialogFragment.CHECK_UNITS_DIALOG_TAG);
|
||||
if (fragment == null) {
|
||||
|
||||
+2
-1
@@ -17,6 +17,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;
|
||||
|
||||
@@ -69,7 +70,7 @@ public class CheckUnitsDialogFragment extends DialogFragment {
|
||||
* Tasks to perform when done.
|
||||
*/
|
||||
private void onDone() {
|
||||
PreferencesUtils.setBoolean(getActivity(), R.string.show_check_units_dialog_key, false);
|
||||
EulaUtils.setShowCheckUnits(getActivity());
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class EulaDialogFragment extends DialogFragment {
|
||||
.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
EulaUtils.setEulaValue(getActivity());
|
||||
EulaUtils.setAcceptEula(getActivity());
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.google.android.apps.mytracks.fragments;
|
||||
|
||||
import com.google.android.apps.mytracks.TrackListActivity;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.apps.mytracks.util.EulaUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
@@ -55,7 +55,7 @@ public class WelcomeDialogFragment extends DialogFragment {
|
||||
}
|
||||
|
||||
private void onDone() {
|
||||
PreferencesUtils.setBoolean(getActivity(), R.string.show_welcome_dialog_key, false);
|
||||
EulaUtils.setShowWelcome(getActivity());
|
||||
TrackListActivity trackListActivity = (TrackListActivity) getActivity();
|
||||
trackListActivity.showStartupDialogs();
|
||||
}
|
||||
|
||||
@@ -29,21 +29,47 @@ public class EulaUtils {
|
||||
private static final String EULA_PREFERENCE_FILE = "eula";
|
||||
|
||||
// Accepting Google mobile terms of service
|
||||
private static final String EULA_PREFERENCE_KEY = "eula.google_mobile_tos_accepted";
|
||||
|
||||
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() {}
|
||||
|
||||
public static boolean getEulaValue(Context context) {
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences(
|
||||
EULA_PREFERENCE_FILE, Context.MODE_PRIVATE);
|
||||
return sharedPreferences.getBoolean(EULA_PREFERENCE_KEY, false);
|
||||
public static boolean getAcceptEula(Context context) {
|
||||
return getValue(context, ACCEPT_EULA_PREFERENCE_KEY, false);
|
||||
}
|
||||
|
||||
public static void setEulaValue(Context context) {
|
||||
public static void setAcceptEula(Context context) {
|
||||
setValue(context, ACCEPT_EULA_PREFERENCE_KEY, true);
|
||||
}
|
||||
|
||||
public static boolean getShowWelcome(Context context) {
|
||||
return getValue(context, SHOW_WELCOME_PREFERENCE_KEY, true);
|
||||
}
|
||||
|
||||
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);
|
||||
return sharedPreferences.getBoolean(key, defaultValue);
|
||||
}
|
||||
|
||||
private static void setValue(Context context, String key, boolean value) {
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences(
|
||||
EULA_PREFERENCE_FILE, Context.MODE_PRIVATE);
|
||||
Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean(EULA_PREFERENCE_KEY, true);
|
||||
editor.putBoolean(key, value);
|
||||
ApiAdapterFactory.getApiAdapter().applyPreferenceChanges(editor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +73,7 @@ public class PreferencesUtils {
|
||||
public static final boolean SEND_TO_DOCS_DEFAULT = true;
|
||||
public static final boolean SEND_TO_FUSION_TABLES_DEFAULT = true;
|
||||
public static final boolean SEND_TO_MAPS_DEFAULT = true;
|
||||
public static final boolean SHOW_CHECK_UNITS_DIALOG_DEFAULT = true;
|
||||
public static final boolean SHOW_CONFIRM_SHARING_DIALOG_DEFAULT = true;
|
||||
public static final boolean SHOW_WELCOME_DIALOG_DEFAULT = true;
|
||||
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
|
||||
|
||||
public static final boolean STATS_SHOW_COORDINATE_DEFAULT = false;
|
||||
|
||||
Reference in New Issue
Block a user