diff --git a/MyTracks/AndroidManifest.xml b/MyTracks/AndroidManifest.xml
index 34fbb187e..bca3f3403 100755
--- a/MyTracks/AndroidManifest.xml
+++ b/MyTracks/AndroidManifest.xml
@@ -180,9 +180,6 @@ limitations under the License.
-
@@ -210,6 +207,8 @@ limitations under the License.
+
+
-
-
+
allowAccess
announcementFrequency
antCadenceSensorId
@@ -51,7 +50,7 @@ limitations under the License.
statsShowCoordinate
statsShowElevation
statsShowGrade
- statsShowTotalTime
+ statsShowTotalTime
trackColorModeDynamicVariation
trackColorModeFixedMediumDisplay
trackColorModeFixedMedium
@@ -60,11 +59,12 @@ limitations under the License.
trackColorMode
trackName
-
+
antOptions
backupToSd
resetToDefaults
restoreFromSd
sensorOptions
+ settingsSharing
trackColorModeFixedOptions
\ No newline at end of file
diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml
index 5e5fd1054..278dcec01 100644
--- a/MyTracks/res/values/strings.xml
+++ b/MyTracks/res/values/strings.xml
@@ -2040,10 +2040,6 @@ limitations under the License.
sharing a URL with friends.">
Remove any descriptive text when sharing a URL with friends.
-
- My Tracks settings
-
-
+
@@ -152,6 +152,12 @@ limitations under the License.
+
+
+
@@ -186,30 +192,6 @@ limitations under the License.
-
-
-
-
-
-
-
-
-
diff --git a/MyTracks/res/xml/sharing_settings.xml b/MyTracks/res/xml/sharing_settings.xml
new file mode 100644
index 000000000..04276f123
--- /dev/null
+++ b/MyTracks/res/xml/sharing_settings.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MyTracks/src/com/google/android/apps/mytracks/AbstractMyTracksActivity.java b/MyTracks/src/com/google/android/apps/mytracks/AbstractMyTracksActivity.java
index c409e06c7..b899016bc 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/AbstractMyTracksActivity.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/AbstractMyTracksActivity.java
@@ -34,8 +34,8 @@ public class AbstractMyTracksActivity extends FragmentActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
- ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
- }
+ ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
+ }
@Override
public boolean onOptionsItemSelected(MenuItem item) {
@@ -44,8 +44,8 @@ public class AbstractMyTracksActivity extends FragmentActivity {
}
onHomeSelected();
return true;
- }
-
+ }
+
/**
* Callback when the home menu item is selected.
*/
diff --git a/MyTracks/src/com/google/android/apps/mytracks/TrackDetailActivity.java b/MyTracks/src/com/google/android/apps/mytracks/TrackDetailActivity.java
index ada48c878..5e9b72dc0 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/TrackDetailActivity.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/TrackDetailActivity.java
@@ -34,6 +34,7 @@ import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileForm
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
import com.google.android.apps.mytracks.io.sendtogoogle.UploadServiceChooserActivity;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
+import com.google.android.apps.mytracks.settings.SettingsActivity;
import com.google.android.apps.mytracks.util.AnalyticsUtils;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.IntentUtils;
diff --git a/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java b/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java
index b6ca0fbb7..a3798eedb 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/TrackListActivity.java
@@ -25,6 +25,7 @@ import com.google.android.apps.mytracks.fragments.WelcomeDialogFragment;
import com.google.android.apps.mytracks.io.file.TrackWriterFactory.TrackFileFormat;
import com.google.android.apps.mytracks.services.ITrackRecordingService;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
+import com.google.android.apps.mytracks.settings.SettingsActivity;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.EulaUtils;
import com.google.android.apps.mytracks.util.IntentUtils;
diff --git a/MyTracks/src/com/google/android/apps/mytracks/content/MyTracksProvider.java b/MyTracks/src/com/google/android/apps/mytracks/content/MyTracksProvider.java
index 2f959a575..5b0e01585 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/content/MyTracksProvider.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/content/MyTracksProvider.java
@@ -16,13 +16,13 @@
package com.google.android.apps.mytracks.content;
import com.google.android.apps.mytracks.Constants;
+import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.content.ContentProvider;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
-import android.content.SharedPreferences;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.SQLException;
@@ -190,13 +190,11 @@ public class MyTracksProvider extends ContentProvider {
if (Binder.getCallingPid() == Process.myPid()) {
return true;
} else {
- Context context = getContext();
- SharedPreferences sharedPreferences = context.getSharedPreferences(
- Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
- return sharedPreferences.getBoolean(context.getString(R.string.allow_access_key), false);
+ return PreferencesUtils.getBoolean(
+ getContext(), R.string.allow_access_key, PreferencesUtils.ALLOW_ACCESS_DEFAULT);
}
}
-
+
@Override
public boolean onCreate() {
if (!canAccess()) {
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/maps/SendMapsAsyncTask.java b/MyTracks/src/com/google/android/apps/mytracks/io/maps/SendMapsAsyncTask.java
index 112ea8a90..ed338cb45 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/maps/SendMapsAsyncTask.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/maps/SendMapsAsyncTask.java
@@ -45,7 +45,6 @@ import android.accounts.AccountManager;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.content.Context;
-import android.content.SharedPreferences;
import android.database.Cursor;
import android.location.Location;
import android.util.Log;
@@ -225,15 +224,13 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
mapId = chooseMapId;
return true;
} else {
- SharedPreferences sharedPreferences = context.getSharedPreferences(
- Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
- boolean mapPublic = sharedPreferences.getBoolean(
- context.getString(R.string.default_map_public_key), true);
+ boolean defaultMapPublic = PreferencesUtils.getBoolean(
+ context, R.string.default_map_public_key, PreferencesUtils.DEFAULT_MAP_PUBLIC_DEFAULT);
try {
String description = track.getCategory() + "\n" + track.getDescription() + "\n"
+ context.getString(R.string.send_google_by_my_tracks, "", "");
mapId = SendMapsUtils.createNewMap(
- track.getName(), description, mapPublic, mapsClient, authToken);
+ track.getName(), description, defaultMapPublic, mapsClient, authToken);
} catch (ParseException e) {
Log.d(TAG, "Unable to create a new map", e);
return false;
diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/UploadResultActivity.java b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/UploadResultActivity.java
index 4324db320..bb523282b 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/UploadResultActivity.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/UploadResultActivity.java
@@ -15,21 +15,19 @@
*/
package com.google.android.apps.mytracks.io.sendtogoogle;
-import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.io.fusiontables.SendFusionTablesUtils;
import com.google.android.apps.mytracks.io.maps.SendMapsUtils;
+import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import com.google.common.annotations.VisibleForTesting;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
-import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
@@ -175,13 +173,12 @@ public class UploadResultActivity extends Activity {
/**
* Starts an activity to share the url.
- *
+ *
* @param url the url
*/
private void startShareUrlActivity(String url) {
- SharedPreferences prefs = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
- boolean shareUrlOnly = prefs.getBoolean(getString(R.string.share_url_only_key), false);
-
+ boolean shareUrlOnly = PreferencesUtils.getBoolean(
+ this, R.string.share_url_only_key, PreferencesUtils.SHARE_URL_ONLY_DEFAULT);
Intent intent = new Intent(Intent.ACTION_SEND)
.setType(TEXT_PLAIN_TYPE)
.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_track_subject))
diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java b/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java
index d95e93ffc..4f80146ad 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java
@@ -1075,10 +1075,8 @@ public class TrackRecordingService extends Service {
.setAction(getString(actionResId))
.putExtra(getString(R.string.track_id_broadcast_extra), trackId);
sendBroadcast(broadcastIntent, getString(R.string.permission_notification_value));
-
- SharedPreferences sharedPreferences = getSharedPreferences(
- Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
- if (sharedPreferences.getBoolean(getString(R.string.allow_access_key), false)) {
+ if (PreferencesUtils.getBoolean(
+ this, R.string.allow_access_key, PreferencesUtils.ALLOW_ACCESS_DEFAULT)) {
sendBroadcast(broadcastIntent, getString(R.string.broadcast_notifications_permission));
}
}
@@ -1224,20 +1222,17 @@ public class TrackRecordingService extends Service {
/**
* Returns true if the RPC caller is from the same application or if the
- * "Allow access" setting indicates that another app can invoke this service's
- * RPCs.
+ * "Allow access" setting indicates that another app can invoke this
+ * service's RPCs.
*/
private boolean canAccess() {
-
// As a precondition for access, must check if the service is available.
checkService();
-
if (Process.myPid() == Binder.getCallingPid()) {
return true;
} else {
- SharedPreferences sharedPreferences = service.getSharedPreferences(
- Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
- return sharedPreferences.getBoolean(service.getString(R.string.allow_access_key), false);
+ return PreferencesUtils.getBoolean(
+ service, R.string.allow_access_key, PreferencesUtils.ALLOW_ACCESS_DEFAULT);
}
}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/settings/AbstractSettingsActivity.java b/MyTracks/src/com/google/android/apps/mytracks/settings/AbstractSettingsActivity.java
new file mode 100644
index 000000000..12f315107
--- /dev/null
+++ b/MyTracks/src/com/google/android/apps/mytracks/settings/AbstractSettingsActivity.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.android.apps.mytracks.settings;
+
+import com.google.android.apps.mytracks.Constants;
+import com.google.android.apps.mytracks.io.backup.BackupPreferencesListener;
+import com.google.android.apps.mytracks.util.ApiAdapterFactory;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceManager;
+import android.speech.tts.TextToSpeech;
+import android.view.MenuItem;
+
+/**
+ * An abstract activity for all the settings activities.
+ *
+ * @author Jimmy Shih
+ */
+public class AbstractSettingsActivity extends PreferenceActivity {
+
+ private BackupPreferencesListener backupPreferencesListener;
+
+ @Override
+ protected void onCreate(Bundle bundle) {
+ super.onCreate(bundle);
+ setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
+ ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
+
+ @SuppressWarnings("deprecation")
+ PreferenceManager preferenceManager = getPreferenceManager();
+ preferenceManager.setSharedPreferencesName(Constants.SETTINGS_NAME);
+ preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE);
+
+ // Set up automatic preferences backup
+ backupPreferencesListener = ApiAdapterFactory.getApiAdapter()
+ .getBackupPreferencesListener(this);
+ preferenceManager.getSharedPreferences()
+ .registerOnSharedPreferenceChangeListener(backupPreferencesListener);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() != android.R.id.home) {
+ return super.onOptionsItemSelected(item);
+ }
+ finish();
+ return true;
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ @SuppressWarnings("deprecation")
+ PreferenceManager preferenceManager = getPreferenceManager();
+ preferenceManager.getSharedPreferences()
+ .unregisterOnSharedPreferenceChangeListener(backupPreferencesListener);
+ }
+}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/SettingsActivity.java b/MyTracks/src/com/google/android/apps/mytracks/settings/SettingsActivity.java
similarity index 91%
rename from MyTracks/src/com/google/android/apps/mytracks/SettingsActivity.java
rename to MyTracks/src/com/google/android/apps/mytracks/settings/SettingsActivity.java
index 2c256fbbd..95b24d433 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/SettingsActivity.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/settings/SettingsActivity.java
@@ -13,12 +13,13 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.android.apps.mytracks;
+
+package com.google.android.apps.mytracks.settings;
import static com.google.android.apps.mytracks.Constants.TAG;
+import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.io.backup.BackupActivity;
-import com.google.android.apps.mytracks.io.backup.BackupPreferencesListener;
import com.google.android.apps.mytracks.io.backup.RestoreChooserActivity;
import com.google.android.apps.mytracks.services.sensors.ant.AntUtils;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
@@ -31,6 +32,7 @@ import com.google.android.maps.mytracks.R;
import android.app.Dialog;
import android.bluetooth.BluetoothAdapter;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -42,12 +44,9 @@ import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
-import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
-import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.provider.Settings;
-import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.widget.Toast;
@@ -62,11 +61,10 @@ import java.util.Set;
* @author Leif Hendrik Wilden
* @author Rodrigo Damazio
*/
-public class SettingsActivity extends PreferenceActivity {
+public class SettingsActivity extends AbstractSettingsActivity {
private static final int DIALOG_CONFIRM_RESET_ID = 0;
- private static final int DIALOG_CONFIRM_ACCESS_ID = 1;
- private static final int DIALOG_CONFIRM_RESTORE_ID = 2;
+ private static final int DIALOG_CONFIRM_RESTORE_ID = 1;
// Value when the task frequency is off.
private static final String TASK_FREQUENCY_OFF = "0";
@@ -101,27 +99,11 @@ public class SettingsActivity extends PreferenceActivity {
// Value when the GPS accuracy is for poor GPS signal.
private static final String GPS_ACCURACY_POOR = "5000";
- private BackupPreferencesListener backupListener;
- private SharedPreferences preferences;
-
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
- // The volume we want to control is the Text-To-Speech volume
- setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
-
- // Tell it where to read/write preferences
- PreferenceManager preferenceManager = getPreferenceManager();
- preferenceManager.setSharedPreferencesName(Constants.SETTINGS_NAME);
- preferenceManager.setSharedPreferencesMode(0);
-
- // Set up automatic preferences backup
- backupListener = ApiAdapterFactory.getApiAdapter().getBackupPreferencesListener(this);
- preferences = preferenceManager.getSharedPreferences();
- preferences.registerOnSharedPreferenceChangeListener(backupListener);
-
// Load the preferences to be displayed
addPreferencesFromResource(R.xml.preferences);
@@ -157,18 +139,13 @@ public class SettingsActivity extends PreferenceActivity {
}
});
- // Add a confirmation dialog for the 'Allow access' preference.
- CheckBoxPreference allowAccessPreference = (CheckBoxPreference) findPreference(
- getString(R.string.allow_access_key));
- allowAccessPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ Preference sharingPreference = findPreference(getString(R.string.settings_sharing_key));
+ sharingPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- if ((Boolean) newValue) {
- showDialog(DIALOG_CONFIRM_ACCESS_ID);
- return false;
- } else {
- return true;
- }
+ public boolean onPreferenceClick(Preference preference) {
+ Intent intent = IntentUtils.newIntent(SettingsActivity.this, SharingSettingsActivity.class);
+ startActivity(intent);
+ return true;
}
});
}
@@ -184,17 +161,6 @@ public class SettingsActivity extends PreferenceActivity {
onResetPreferencesConfirmed();
}
});
- case DIALOG_CONFIRM_ACCESS_ID:
- return DialogUtils.createConfirmationDialog(this,
- R.string.settings_sharing_allow_access_confirm_message,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int button) {
- CheckBoxPreference pref = (CheckBoxPreference) findPreference(
- getString(R.string.allow_access_key));
- pref.setChecked(true);
- }
- });
case DIALOG_CONFIRM_RESTORE_ID:
return DialogUtils.createConfirmationDialog(this,
R.string.settings_backup_restore_confirm_message,
@@ -380,14 +346,6 @@ public class SettingsActivity extends PreferenceActivity {
});
}
- @Override
- protected void onDestroy() {
- getPreferenceManager().getSharedPreferences()
- .unregisterOnSharedPreferenceChangeListener(backupListener);
-
- super.onPause();
- }
-
private void updateSensorSettings(String sensorType) {
boolean usesBluetooth =
getString(R.string.sensor_type_value_zephyr).equals(sensorType)
@@ -614,8 +572,10 @@ public class SettingsActivity extends PreferenceActivity {
public void run() {
Log.i(TAG, "Resetting all settings");
+ SharedPreferences sharedPreferences = getSharedPreferences(
+ Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
// Actually wipe preferences (and save synchronously).
- preferences.edit().clear().commit();
+ sharedPreferences.edit().clear().commit();
// Give UI feedback in the UI thread.
runOnUiThread(new Runnable() {
diff --git a/MyTracks/src/com/google/android/apps/mytracks/settings/SharingSettingsActivity.java b/MyTracks/src/com/google/android/apps/mytracks/settings/SharingSettingsActivity.java
new file mode 100644
index 000000000..a322ce262
--- /dev/null
+++ b/MyTracks/src/com/google/android/apps/mytracks/settings/SharingSettingsActivity.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.android.apps.mytracks.settings;
+
+import com.google.android.apps.mytracks.util.DialogUtils;
+import com.google.android.maps.mytracks.R;
+
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+
+/**
+ * An activity for accessing the sharing settings.
+ *
+ * @author Jimmy Shih
+ */
+public class SharingSettingsActivity extends AbstractSettingsActivity {
+
+ private static final int DIALOG_CONFIRM_ALLOW_ACCESS_ID = 0;
+
+ private CheckBoxPreference allowAccessCheckBoxPreference;
+
+ @SuppressWarnings("deprecation")
+ @Override
+ protected void onCreate(Bundle bundle) {
+ super.onCreate(bundle);
+ addPreferencesFromResource(R.xml.sharing_settings);
+
+ allowAccessCheckBoxPreference = (CheckBoxPreference) findPreference(
+ getString(R.string.allow_access_key));
+ allowAccessCheckBoxPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if ((Boolean) newValue) {
+ showDialog(DIALOG_CONFIRM_ALLOW_ACCESS_ID);
+ return false;
+ } else {
+ return true;
+ }
+ }
+ });
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ if (id != DIALOG_CONFIRM_ALLOW_ACCESS_ID) {
+ return null;
+ }
+ return DialogUtils.createConfirmationDialog(this,
+ R.string.settings_sharing_allow_access_confirm_message,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int button) {
+ allowAccessCheckBoxPreference.setChecked(true);
+ }
+ });
+ }
+}
diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java
index 58e49589b..5f54069d5 100644
--- a/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java
+++ b/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java
@@ -29,6 +29,14 @@ import android.content.SharedPreferences.Editor;
*/
public class PreferencesUtils {
+ /*
+ * Preferences defaults, need to match the android:defaultValue in the xml
+ * files.
+ */
+ public static final boolean ALLOW_ACCESS_DEFAULT = false;
+ public static final boolean DEFAULT_MAP_PUBLIC_DEFAULT = true;
+ public static final boolean SHARE_URL_ONLY_DEFAULT = false;
+
private PreferencesUtils() {}
/**