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