Update Back and reset settings, remove are you sure on the dialog title

This commit is contained in:
Jimmy Shih
2013-08-21 11:32:12 -07:00
parent b76d7fbb9c
commit 8f7bc30b10
12 changed files with 150 additions and 94 deletions
+70 -34
View File
@@ -774,10 +774,10 @@ limitations under the License.
translation_description="The text on a button to say cancel.">
Cancel
</string>
<string name="generic_confirm_title"
translation_description="The title on a confirmation dialog asking the user if he is sure?">
Are you sure?
</string>
<string name="generic_delete_selected_confirm_title"
translation_description="When deleting selected items, the title of the confirmation dialog.">
Delete selected?
</string>
<string name="generic_description"
translation_description="The text label for entering a description.">
Description
@@ -1001,6 +1001,10 @@ limitations under the License.
translation_description="When deleting one marker, the confirmation message.">
The marker will be permanently deleted from the device.
</string>
<string name="marker_delete_one_confirm_title"
translation_description="When deleting one marker, the title of the confirmation dialog.">
Delete marker?
</string>
<string name="marker_delete_multiple_confirm_message"
translation_description="When deleting multiple markers, the confirmation message.">
All markers for this track will be permanently deleted from the device.
@@ -1484,29 +1488,39 @@ limitations under the License.
Backup &amp; reset
</string>
<!-- Settings Backup Now -->
<string name="settings_backup_now"
<!-- Settings Backup -->
<string name="settings_backup"
translation_description="In the 'Backup and reset' settings, the option to backup to the
external storage now.
external storage.
Character limit: ~26 (1 line)">
Backup now
Backup
</string>
<string name="settings_backup_confirm_message"
translation_description="In the 'Backup and reset' settings, after pressing the 'Backup' option,
the confirmation message.
%1$s the directory. E.g., '/MyTracks/backups'.">
This will write a full copy of all your tracks and settings to &#8216;%1$s&#8217; on the
external storage.
</string>
<string name="settings_backup_confirm_title"
translation_description="In the 'Backup and reset' settings, after pressing the 'Backup' option,
the title of the confirmation dialog.
Character limit: ~26 (1 line)">
Backup now?
</string>
<string name="settings_backup_now_error"
translation_description="When backing up to the external storage, the error message.">
Unable to backup.
</string>
<string name="settings_backup_now_progress_message"
translation_description="In the 'Backup and reset' settings, after pressing the 'Backup now'
option, the progress message telling the user that it is writing all tracks and settings to
the external storage.">
translation_description="In the 'Backup and reset' settings, after pressing the 'Backup' option,
the progress message telling the user that it is writing all tracks and settings to the
external storage.">
Writing all tracks and settings&#8230;
</string>
<string name="settings_backup_now_summary"
translation_description="In the 'Backup and reset' settings, the summary for the 'Backup now'
option explaining that all tracks and settings will be written to the external storage.">
Write a full copy of all your tracks and settings to the external storage
</string>
<string name="settings_backup_now_success"
translation_description="When backing up to the external storage, the success message">
Finished backup.
@@ -1518,22 +1532,26 @@ limitations under the License.
external storage.
Character limit: ~26 (1 line)">
Restore now
Restore
</string>
<string name="settings_backup_restore_confirm_message"
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
option, the message in the alert dialog asking the user to confirm that he wants to restore
from a backup.">
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore'
option, the confirmation message.">
Restoring a backup from external storage will delete all your tracks and settings, and update
them with the backup copy. Google Drive sync will be turned off. No tracks will be deleted on
Google Drive and on external storage.
</string>
<string name="settings_backup_restore_confirm_title"
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore'
option, the title of the confirmation dialog.">
Restore now?
</string>
<string name="settings_backup_restore_error"
translation_description="When restoring from backup, the error message.">
Unable to restore from backup.
</string>
<string name="settings_backup_restore_no_backups"
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore'
option, the message in the alert dialog informing the user that there is no backups to restore
from.
@@ -1541,21 +1559,16 @@ limitations under the License.
No backups found in %1$s.
</string>
<string name="settings_backup_restore_progress_message"
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore'
option, the progress message informing that My Tracks is reading all tracks and settings from
the backup on the external storage.">
Reading all tracks and settings&#8230;
</string>
<string name="settings_backup_restore_select_title"
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore now'
translation_description="In the 'Backup and reset' settings, after pressing the 'Restore'
option, the title in the picker dialog asking the user to select a backup.">
Select a backup to restore
</string>
<string name="settings_backup_restore_summary"
translation_description="In the 'Backup and reset' settings, the summary for the 'Restore now'
option explaining that it restores all tracks and settings from the external storage.">
Restore all tracks and settings from the external storage
</string>
<string name="settings_backup_restore_success"
translation_description="When restoring from backup, the success message.">
Finished restoring from backup.
@@ -1595,6 +1608,11 @@ limitations under the License.
This will remove any association between your tracks and %1$s Google Drive. Google Drive sync
will be turned off. No tracks will be deleted on %1$s Google Drive.
</string>
<string name="settings_google_account_confirm_title"
translation_description="In the 'Accounts and sync' settings, after pressing 'Switch account',
the title of the confirmation dialog.">
Switch account?
</string>
<string name="settings_google_account_title"
translation_description="In the 'Accounts and sync' settings, the option to switch Google
account.
@@ -1818,17 +1836,17 @@ limitations under the License.
All settings will be reverted to the default values. This will not delete any tracks on the
device or on Google Drive.
</string>
<string name="settings_reset_confirm_title"
translation_description="In the 'Backup and reset' settings, after pressing the 'Reset' option,
the title of the confirmation dialog.">
Reset now?
</string>
<string name="settings_reset_done"
translation_description="In the 'Backup and reset' settings, after pressing the 'Reset' option,
the confirmation dialog informing the user that all settings have been reverted to the default
values.">
All settings have been reverted to the default values.
</string>
<string name="settings_reset_summary"
translation_description="In the 'Backup and reset' settings, the summary for the 'Reset' option
explaining it will revert all settings to the default values.">
Revert all your settings to the default values
</string>
<!-- Settings Sensor -->
<string name="settings_sensor"
@@ -1964,6 +1982,11 @@ limitations under the License.
Other apps, including future apps, will be able to control and access My Tracks data. There will
be no further notification.
</string>
<string name="settings_sharing_allow_access_confirm_title"
translation_description="In the 'Sharing' settings, after checking the 'Allow access' checkbox,
the title of the confirmation dialog.">
Allow access?
</string>
<string name="settings_sharing_allow_access_summary_off"
translation_description="In the 'Sharing' settings, the summary for the 'Allow access' checkbox
option when it is unchecked explaining that other apps cannot read, write, start/stop
@@ -2203,11 +2226,19 @@ limitations under the License.
All tracks and markers will be permanently deleted from the device. Google Drive sync will be
turned off. No tracks will be deleted on Google Drive and on external storage.
</string>
<string name="track_delete_all_confirm_title"
translation_description="When deleting all the tracks, the title of the confirmation dialog.">
Delete all?
</string>
<string name="track_delete_one_confirm_message"
translation_description="When deleting one track, the confirmation message.">
The track and its markers will be permanently deleted from the device. If Google Drive sync is
enabled, this will also delete the track on Google Drive.
</string>
<string name="track_delete_one_confirm_title"
translation_description="When deleting one track, the title of the confirmation dialog.">
Delete track?
</string>
<string name="track_delete_multiple_confirm_message"
translation_description="When deleting multiple tracks, the confirmation message.">
The selected tracks and their markers will be permanently deleted from the device. If Google
@@ -2244,7 +2275,12 @@ limitations under the License.
</string>
<string name="track_detail_play_confirm_message"
translation_description="The confirmation message when playing a track in Google Earth.">
Play in Google Earth will save your track to external storage.
This will save your track to external storage.
</string>
<string name="track_detail_play_confirm_title"
translation_description="When playing a track in Google Earth, the title of the confirmation
dialog.">
Play in Google Earth?
</string>
<string name="track_detail_stats_tab"
translation_description="In the track detail page, the title of the tab showing the stats.">
+1 -1
View File
@@ -19,7 +19,7 @@ limitations under the License.
<Preference
android:key="@string/settings_backup_key"
android:persistent="false"
android:title="@string/settings_backup_now" />
android:title="@string/settings_backup" />
<Preference
android:key="@string/settings_restore_key"
android:persistent="false"
@@ -82,15 +82,19 @@ public class ConfirmDeleteDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final long[] trackIds = getArguments().getLongArray(KEY_TRACK_IDS);
int titleId;
int messageId;
if (trackIds.length == 1 && trackIds[0] == -1L) {
titleId = R.string.track_delete_all_confirm_title;
messageId = R.string.track_delete_all_confirm_message;
} else {
titleId = trackIds.length > 1 ? R.string.generic_delete_selected_confirm_title
: R.string.track_delete_one_confirm_title;
messageId = trackIds.length > 1 ? R.string.track_delete_multiple_confirm_message
: R.string.track_delete_one_confirm_message;
}
return DialogUtils.createConfirmationDialog(
getActivity(), messageId, new DialogInterface.OnClickListener() {
getActivity(), titleId, getString(messageId), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
caller.onConfirmDeleteDone(trackIds);
@@ -16,11 +16,11 @@
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -92,8 +92,8 @@ public class ConfirmPlayDialogFragment extends DialogFragment {
textView.setText(R.string.track_detail_play_confirm_message);
checkBox = (CheckBox) view.findViewById(R.id.confirm_dialog_check_box);
return new AlertDialog.Builder(fragmentActivity).setNegativeButton(R.string.generic_no, null)
.setPositiveButton(R.string.generic_yes, new DialogInterface.OnClickListener() {
return DialogUtils.createConfirmationDialog(fragmentActivity,
R.string.track_detail_play_confirm_title, view, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
long[] trackIds = getArguments().getLongArray(KEY_TRACK_IDS);
@@ -101,6 +101,6 @@ public class ConfirmPlayDialogFragment extends DialogFragment {
fragmentActivity, R.string.confirm_play_earth_key, !checkBox.isChecked());
caller.onConfirmPlayDone(trackIds);
}
}).setTitle(R.string.generic_confirm_title).setView(view).create();
});
}
}
@@ -77,10 +77,12 @@ public class DeleteMarkerDialogFragment extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
final FragmentActivity fragmentActivity = getActivity();
final long[] markerIds = getArguments().getLongArray(KEY_MARKER_IDS);
int titleId = markerIds.length > 1 ? R.string.generic_delete_selected_confirm_title
: R.string.marker_delete_one_confirm_title;
int messageId = markerIds.length > 1 ? R.string.marker_delete_multiple_confirm_message
: R.string.marker_delete_one_confirm_message;
return DialogUtils.createConfirmationDialog(
fragmentActivity, messageId, new DialogInterface.OnClickListener() {
fragmentActivity, titleId, getString(messageId), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new Thread(new Runnable() {
@@ -21,6 +21,7 @@ import com.google.android.apps.mytracks.io.backup.BackupActivity;
import com.google.android.apps.mytracks.io.backup.RestoreChooserActivity;
import com.google.android.apps.mytracks.io.sync.SyncUtils;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.FileUtils;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
@@ -45,8 +46,9 @@ import android.widget.Toast;
public class BackupResetSettingsActivity extends AbstractSettingsActivity {
private static final String TAG = BackupResetSettingsActivity.class.getSimpleName();
private static final int DIALOG_CONFIRM_RESTORE_ID = 0;
private static final int DIALOG_CONFIRM_RESET_ID = 1;
private static final int DIALOG_CONFIRM_BACKUP_ID = 0;
private static final int DIALOG_CONFIRM_RESTORE_ID = 1;
private static final int DIALOG_CONFIRM_RESET_ID = 2;
private SharedPreferences sharedPreferences;
private Preference backupPreference;
@@ -88,10 +90,8 @@ public class BackupResetSettingsActivity extends AbstractSettingsActivity {
backupPreference = findPreference(getString(R.string.settings_backup_key));
backupPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = IntentUtils.newIntent(
BackupResetSettingsActivity.this, BackupActivity.class);
startActivity(intent);
public boolean onPreferenceClick(Preference preference) {
showDialog(DIALOG_CONFIRM_BACKUP_ID);
return true;
}
});
@@ -116,11 +116,26 @@ public class BackupResetSettingsActivity extends AbstractSettingsActivity {
@Override
protected Dialog onCreateDialog(int id) {
String message;
Dialog dialog;
switch (id) {
case DIALOG_CONFIRM_BACKUP_ID:
message = getString(R.string.settings_backup_confirm_message,
FileUtils.getDirectoryDisplayName(FileUtils.BACKUPS_DIR));
dialog = DialogUtils.createConfirmationDialog(this, R.string.settings_backup_confirm_title,
message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int which) {
Intent intent = IntentUtils.newIntent(
BackupResetSettingsActivity.this, BackupActivity.class);
startActivity(intent);
}
});
break;
case DIALOG_CONFIRM_RESTORE_ID:
message = getString(R.string.settings_backup_restore_confirm_message);
dialog = DialogUtils.createConfirmationDialog(this,
R.string.settings_backup_restore_confirm_message,
R.string.settings_backup_restore_confirm_title, message,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int which) {
@@ -131,8 +146,9 @@ public class BackupResetSettingsActivity extends AbstractSettingsActivity {
});
break;
case DIALOG_CONFIRM_RESET_ID:
dialog = DialogUtils.createConfirmationDialog(
this, R.string.settings_reset_confirm_message, new DialogInterface.OnClickListener() {
message = getString(R.string.settings_reset_confirm_message);
dialog = DialogUtils.createConfirmationDialog(this, R.string.settings_reset_confirm_title,
message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int button) {
onResetPreferencesConfirmed();
@@ -164,17 +180,13 @@ public class BackupResetSettingsActivity extends AbstractSettingsActivity {
*/
private void updateUi() {
boolean isRecording = recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
String summary = isRecording ? getString(R.string.settings_not_while_recording) : "";
backupPreference.setEnabled(!isRecording);
backupPreference.setSummary(
isRecording ? R.string.settings_not_while_recording : R.string.settings_backup_now_summary);
backupPreference.setSummary(summary);
restoreNowPreference.setEnabled(!isRecording);
restoreNowPreference.setSummary(isRecording ? R.string.settings_not_while_recording
: R.string.settings_backup_restore_summary);
restoreNowPreference.setSummary(summary);
resetPreference.setEnabled(!isRecording);
resetPreference.setSummary(
isRecording ? R.string.settings_not_while_recording : R.string.settings_reset_summary);
resetPreference.setSummary(summary);
}
/**
@@ -140,12 +140,13 @@ public class GoogleSettingsActivity extends AbstractSettingsActivity {
Dialog dialog;
switch (id) {
case DIALOG_CONFIRM_SWITCH_ACCOUNT:
dialog = DialogUtils.createConfirmationDialog(
this, R.string.settings_google_account_confirm_message, null);
dialog = DialogUtils.createConfirmationDialog(this,
R.string.settings_google_account_confirm_title,
getString(R.string.settings_google_account_confirm_message), null);
break;
case DIALOG_CONFIRM_DRIVE_SYNC_ON:
dialog = DialogUtils.createConfirmationDialog(this, R.string.sync_drive_title,
R.string.sync_drive_confirm_message, null, new DialogInterface.OnClickListener() {
getString(R.string.sync_drive_confirm_message), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int button) {
final String googleAccount = PreferencesUtils.getString(GoogleSettingsActivity.this,
@@ -179,7 +180,7 @@ public class GoogleSettingsActivity extends AbstractSettingsActivity {
});
thread.start();
}
}, null);
});
break;
default:
dialog = null;
@@ -64,7 +64,8 @@ public class SharingSettingsActivity extends AbstractSettingsActivity {
return null;
}
return DialogUtils.createConfirmationDialog(this,
R.string.settings_sharing_allow_access_confirm_message,
R.string.settings_sharing_allow_access_confirm_title,
getString(R.string.settings_sharing_allow_access_confirm_message),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int button) {
@@ -38,40 +38,26 @@ public class DialogUtils {
* Creates a confirmation dialog.
*
* @param context the context
* @param messageId the message id
* @param titleId the title
* @param message the message
* @param okListener the listener when OK is clicked
*/
public static Dialog createConfirmationDialog(
Context context, int messageId, DialogInterface.OnClickListener okListener) {
return createConfirmationDialog(
context, R.string.generic_confirm_title, messageId, null, okListener, null);
Context context, int titleId, String message, DialogInterface.OnClickListener okListener) {
return createConfirmationDialog(context, titleId, message, null, okListener);
}
/**
* Creates a confirmation dialog.
*
* @param context the context
* @param titleId the titleId
* @param messageId the messageId
* @param titleId the title
* @param view the view
* @param okListener the listener when OK is clicked
* @param cancelListener the listener when cancel is clicked
*/
public static Dialog createConfirmationDialog(Context context, int titleId, int messageId,
View view, DialogInterface.OnClickListener okListener,
DialogInterface.OnClickListener cancelListener) {
AlertDialog.Builder builder = new AlertDialog.Builder(context).setCancelable(true)
.setIcon(android.R.drawable.ic_dialog_alert)
.setNegativeButton(R.string.generic_no, cancelListener)
.setPositiveButton(R.string.generic_yes, okListener).setTitle(titleId);
if (messageId != -1) {
builder.setMessage(messageId);
}
if (view != null) {
builder.setView(view);
}
return builder.create();
public static Dialog createConfirmationDialog(
Context context, int titleId, View view, DialogInterface.OnClickListener okListener) {
return createConfirmationDialog(context, titleId, null, view, okListener);
}
/**
@@ -99,6 +85,21 @@ public class DialogUtils {
return createProgressDialog(false, context, messageId, onCancelListener, formatArgs);
}
private static Dialog createConfirmationDialog(Context context, int titleId, String message,
View view, DialogInterface.OnClickListener okListener) {
AlertDialog.Builder builder = new AlertDialog.Builder(context).setCancelable(true)
.setIcon(android.R.drawable.ic_dialog_alert).setNegativeButton(R.string.generic_no, null)
.setPositiveButton(R.string.generic_yes, okListener).setTitle(titleId);
if (message != null) {
builder.setMessage(message);
}
if (view != null) {
builder.setView(view);
}
return builder.create();
}
/**
* Creates a progress dialog.
*
@@ -843,7 +843,7 @@ public class EndToEndTestUtils {
findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_reset));
Assert.assertTrue(SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset)));
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset_summary));
SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset));
getButtonOnScreen(activityMytracks.getString(R.string.generic_yes), true, true);
Assert.assertTrue(SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset_done)));
instrumentation.waitForIdleSync();
@@ -99,7 +99,7 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
// Reset all settings.
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_reset));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset_summary));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_reset));
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_yes), true,
true);
EndToEndTestUtils.SOLO.waitForText(activityMyTracks.getString(R.string.settings_reset_done), 1,
@@ -283,7 +283,7 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
// Write to SD card.
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_reset));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_now));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup));
assertTrue(EndToEndTestUtils.SOLO.waitForText(
activityMyTracks.getString(R.string.settings_backup_now_success), 0,
EndToEndTestUtils.SUPER_LONG_WAIT_TIME));
@@ -298,7 +298,7 @@ public class SettingTest extends ActivityInstrumentationTestCase2<TrackListActiv
// Read from SD card.
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_reset));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup_now));
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_backup));
EndToEndTestUtils.SOLO
.clickOnText(activityMyTracks.getString(R.string.settings_backup_restore));
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_yes), true,
@@ -187,11 +187,10 @@ public class SyncTestUtils {
if (EndToEndTestUtils.SOLO.waitForText(accountName, 1, EndToEndTestUtils.SHORT_WAIT_TIME)) {
EndToEndTestUtils.SOLO.clickOnText(accountName);
EndToEndTestUtils.instrumentation.waitForIdleSync();
if (EndToEndTestUtils.SOLO.waitForText(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_confirm_title), 1,
EndToEndTestUtils.SHORT_WAIT_TIME)) {
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.activityMytracks
.getString(R.string.generic_yes));
if (EndToEndTestUtils.SOLO.waitForText(EndToEndTestUtils.activityMytracks.getString(
R.string.settings_google_account_confirm_title), 1, EndToEndTestUtils.SHORT_WAIT_TIME)) {
EndToEndTestUtils.SOLO.clickOnText(
EndToEndTestUtils.activityMytracks.getString(R.string.generic_yes));
}
} else {
Assert.fail();