merge heads

This commit is contained in:
Jimmy Shih
2012-02-06 10:19:43 -08:00
6 changed files with 105 additions and 57 deletions
+9 -14
View File
@@ -1757,14 +1757,11 @@ limitations under the License.
Screenshot: settings.png"> Screenshot: settings.png">
Reset Reset
</string> </string>
<string name="settings_reset_dialog_message" <string name="settings_reset_confirm_message"
translation_description="In the 'Settings' page, after pressing the 'Reset' option, translation_description="In the 'Settings' page, after pressing the 'Reset' option, the
the confirmation dialog asking the user to confirm reverting all settings to defaults. But confirmation dialog message informing the user that all settings will be reverted.">
the saved tracks will be preserved.
Screenshot: settings_reset_dialog_message.png">
All your settings will be erased and reverted to the default values. Saved tracks will be All your settings will be erased and reverted to the default values. Saved tracks will be
preserved. Are you sure? preserved.
</string> </string>
<string name="settings_reset_done" <string name="settings_reset_done"
translation_description="In the 'Settings' page, after pressing the 'Reset' option, translation_description="In the 'Settings' page, after pressing the 'Reset' option,
@@ -1944,13 +1941,11 @@ limitations under the License.
</string> </string>
<string name="settings_sharing_allow_access_confirm_message" <string name="settings_sharing_allow_access_confirm_message"
translation_description="In the 'Sharing' settings, after checking the 'Allow access' checkbox, translation_description="In the 'Sharing' settings, after checking the 'Allow access' checkbox,
the confirmation dialog asking the user if he wants to allow other apps, including apps the confirmation dialog message informing the user that other apps, including apps
installed in the future, to control and access My Tracks data. In addition, no further installed in the future, will be able to control and access My Tracks data. In addition, no
notification of third party app access will be shown. further notification of third party app access will be shown.">
Other apps, including future apps, will be able to control and access My Tracks data. There will
Screenshot: settings_sharing_allow_access_confirm_message.png"> be no further notification.
Are you sure you want to allow other apps, including future apps, to control and access My
Tracks data? There will be no further notification.
</string> </string>
<string name="settings_sharing_allow_access_summary_off" <string name="settings_sharing_allow_access_summary_off"
translation_description="In the 'Sharing' settings, the summary for the 'Allow access' checkbox translation_description="In the 'Sharing' settings, the summary for the 'Allow access' checkbox
@@ -29,7 +29,7 @@ import com.google.android.apps.mytracks.services.ITrackRecordingService;
import com.google.android.apps.mytracks.services.ServiceUtils; import com.google.android.apps.mytracks.services.ServiceUtils;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection; import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
import com.google.android.apps.mytracks.util.ApiAdapterFactory; import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.EulaUtil; import com.google.android.apps.mytracks.util.EulaUtils;
import com.google.android.apps.mytracks.util.SystemUtils; import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.apps.mytracks.util.UriUtils; import com.google.android.apps.mytracks.util.UriUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -196,7 +196,7 @@ public class MyTracks extends TabActivity implements OnTouchListener {
tabHost.addView(layout); tabHost.addView(layout);
layout.setOnTouchListener(this); layout.setOnTouchListener(this);
if (!EulaUtil.getEulaValue(this)) { if (!EulaUtils.getEulaValue(this)) {
showDialog(DIALOG_EULA_ID); showDialog(DIALOG_EULA_ID);
} }
} }
@@ -280,11 +280,11 @@ public class MyTracks extends TabActivity implements OnTouchListener {
case DIALOG_EULA_ID: case DIALOG_EULA_ID:
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.eula_title); builder.setTitle(R.string.eula_title);
builder.setMessage(EulaUtil.getEulaMessage(this)); builder.setMessage(EulaUtils.getEulaMessage(this));
builder.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
EulaUtil.setEulaValue(MyTracks.this); EulaUtils.setEulaValue(MyTracks.this);
Intent startIntent = new Intent(MyTracks.this, WelcomeActivity.class); Intent startIntent = new Intent(MyTracks.this, WelcomeActivity.class);
startActivityForResult(startIntent, Constants.WELCOME); startActivityForResult(startIntent, Constants.WELCOME);
} }
@@ -22,10 +22,11 @@ import com.google.android.apps.mytracks.io.backup.BackupPreferencesListener;
import com.google.android.apps.mytracks.services.sensors.ant.AntUtils; import com.google.android.apps.mytracks.services.sensors.ant.AntUtils;
import com.google.android.apps.mytracks.util.ApiAdapterFactory; import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.BluetoothDeviceUtils; import com.google.android.apps.mytracks.util.BluetoothDeviceUtils;
import com.google.android.apps.mytracks.util.DialogUtils;
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;
import android.app.AlertDialog; import android.app.Dialog;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
@@ -61,6 +62,9 @@ import java.util.Set;
*/ */
public class SettingsActivity extends PreferenceActivity { public class SettingsActivity extends PreferenceActivity {
private static final int DIALOG_CONFIRM_RESET = 0;
private static final int DIALOG_CONFIRM_ACCESS = 1;
// Value when the task frequency is off. // Value when the task frequency is off.
private static final String TASK_FREQUENCY_OFF = "0"; private static final String TASK_FREQUENCY_OFF = "0";
@@ -146,31 +150,19 @@ public class SettingsActivity extends PreferenceActivity {
resetPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() { resetPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference arg0) { public boolean onPreferenceClick(Preference arg0) {
onResetPreferencesClick(); showDialog(DIALOG_CONFIRM_RESET);
return true; return true;
} }
}); });
// Add a confirmation dialog for the 'Allow access' preference. // Add a confirmation dialog for the 'Allow access' preference.
final CheckBoxPreference allowAccessPreference = (CheckBoxPreference) findPreference( CheckBoxPreference allowAccessPreference = (CheckBoxPreference) findPreference(
getString(R.string.allow_access_key)); getString(R.string.allow_access_key));
allowAccessPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { allowAccessPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if ((Boolean) newValue) { if ((Boolean) newValue) {
AlertDialog dialog = new AlertDialog.Builder(SettingsActivity.this) showDialog(DIALOG_CONFIRM_ACCESS);
.setCancelable(true)
.setTitle(getString(R.string.settings_sharing_allow_access))
.setMessage(getString(R.string.settings_sharing_allow_access_confirm_message))
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int button) {
allowAccessPreference.setChecked(true);
}
})
.setNegativeButton(android.R.string.cancel, null)
.create();
dialog.show();
return false; return false;
} else { } else {
return true; return true;
@@ -178,7 +170,33 @@ public class SettingsActivity extends PreferenceActivity {
} }
}); });
} }
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_CONFIRM_RESET:
return DialogUtils.createConfirmationDialog(
this, R.string.settings_reset_confirm_message, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int button) {
onResetPreferencesConfirmed();
}
});
case DIALOG_CONFIRM_ACCESS:
return DialogUtils.createConfirmationDialog(
this, R.string.settings_sharing_allow_access_confirm_message, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int button) {
CheckBoxPreference pref = (CheckBoxPreference) findPreference(
getString(R.string.allow_access_key));
pref.setChecked(true);
}
});
default:
return null;
}
}
/** /**
* Sets the display options for the 'Time between points' option. * Sets the display options for the 'Time between points' option.
*/ */
@@ -580,24 +598,6 @@ public class SettingsActivity extends PreferenceActivity {
devicesPreference.setEntries(entriesArray); devicesPreference.setEntries(entriesArray);
} }
/** Callback for when user asks to reset all settings. */
private void onResetPreferencesClick() {
AlertDialog dialog = new AlertDialog.Builder(this)
.setCancelable(true)
.setTitle(R.string.settings_reset)
.setMessage(R.string.settings_reset_dialog_message)
.setPositiveButton(android.R.string.ok,
new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int button) {
onResetPreferencesConfirmed();
}
})
.setNegativeButton(android.R.string.cancel, null)
.create();
dialog.show();
}
/** Callback for when user confirms resetting all settings. */ /** Callback for when user confirms resetting all settings. */
private void onResetPreferencesConfirmed() { private void onResetPreferencesConfirmed() {
// Change preferences in a separate thread. // Change preferences in a separate thread.
@@ -15,7 +15,7 @@
*/ */
package com.google.android.apps.mytracks; package com.google.android.apps.mytracks;
import com.google.android.apps.mytracks.util.EulaUtil; import com.google.android.apps.mytracks.util.EulaUtils;
import com.google.android.apps.mytracks.util.SystemUtils; import com.google.android.apps.mytracks.util.SystemUtils;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
@@ -78,7 +78,7 @@ public class WelcomeActivity extends Activity {
case DIALOG_EULA_ID: case DIALOG_EULA_ID:
builder = new AlertDialog.Builder(this); builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.eula_title); builder.setTitle(R.string.eula_title);
builder.setMessage(EulaUtil.getEulaMessage(this)); builder.setMessage(EulaUtils.getEulaMessage(this));
builder.setPositiveButton(R.string.generic_ok, null); builder.setPositiveButton(R.string.generic_ok, null);
builder.setCancelable(true); builder.setCancelable(true);
return builder.create(); return builder.create();
@@ -0,0 +1,53 @@
/*
* 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.util;
import com.google.android.maps.mytracks.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface.OnClickListener;
/**
* Utilities for creating dialogs.
*
* @author Jimmy Shih
*/
public class DialogUtils {
private DialogUtils() {}
/**
* Creates a confirmation dialog.
*
* @param context the context
* @param messageId the id of the confirmation message
* @param onClickListener the listener to invoke when the users clicks OK
*/
public static Dialog createConfirmationDialog(
Context context, int messageId, OnClickListener onClickListener) {
return new AlertDialog.Builder(context)
.setCancelable(true)
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(messageId)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, onClickListener)
.setTitle(R.string.generic_confirm_title)
.create();
}
}
@@ -26,7 +26,7 @@ import java.util.Calendar;
/** /**
* Utilities for EULA. * Utilities for EULA.
*/ */
public class EulaUtil { public class EulaUtils {
private static final String EULA_PREFERENCE_FILE = "eula"; private static final String EULA_PREFERENCE_FILE = "eula";
// Accepting Google mobile terms of service // Accepting Google mobile terms of service
@@ -34,7 +34,7 @@ public class EulaUtil {
private static final String HOST_NAME = "m.google.com"; private static final String HOST_NAME = "m.google.com";
private EulaUtil() {} private EulaUtils() {}
public static boolean getEulaValue(Context context) { public static boolean getEulaValue(Context context) {
SharedPreferences preferences = context.getSharedPreferences( SharedPreferences preferences = context.getSharedPreferences(