Improve the wording where there is no backup.

This commit is contained in:
Jimmy Shih
2013-06-21 17:38:43 -07:00
parent 8bb55ad5db
commit abd8f59a07
4 changed files with 17 additions and 6 deletions
+4 -2
View File
@@ -1527,8 +1527,10 @@ limitations under the License.
<string name="settings_backup_restore_no_backup" <string name="settings_backup_restore_no_backup"
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 now'
option, the message in the alert dialog informing the user that there is no backup to restore option, the message in the alert dialog informing the user that there is no backup to restore
from."> from.
No backup found.
%1$s the directory. E.g., '/MyTracks/backups'.">
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 now'
@@ -59,7 +59,6 @@ class ExternalFileBackup {
BACKUP_FILENAME_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); BACKUP_FILENAME_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
} }
private static final String BACKUPS_SUBDIR = "backups";
private static final int BACKUP_FORMAT_VERSION = 1; private static final int BACKUP_FORMAT_VERSION = 1;
private static final String ZIP_ENTRY_NAME = private static final String ZIP_ENTRY_NAME =
"backup.mytracks.v" + BACKUP_FORMAT_VERSION; "backup.mytracks.v" + BACKUP_FORMAT_VERSION;
@@ -86,7 +85,7 @@ class ExternalFileBackup {
* @param create whether to try creating the directory if it doesn't exist * @param create whether to try creating the directory if it doesn't exist
*/ */
private File getBackupsDirectory(boolean create) { private File getBackupsDirectory(boolean create) {
String directoryPath = FileUtils.getDirectoryPath(BACKUPS_SUBDIR); String directoryPath = FileUtils.getDirectoryPath(FileUtils.BACKUPS_DIR);
final File dir = new File(directoryPath); final File dir = new File(directoryPath);
Log.d(Constants.TAG, "Dir: " + dir.getAbsolutePath()); Log.d(Constants.TAG, "Dir: " + dir.getAbsolutePath());
if (create) { if (create) {
@@ -64,14 +64,14 @@ public class RestoreChooserActivity extends Activity {
} }
if (!externalFileBackup.isBackupsDirectoryAvailable(false)) { if (!externalFileBackup.isBackupsDirectoryAvailable(false)) {
Toast.makeText(this, R.string.settings_backup_restore_no_backup, Toast.LENGTH_LONG).show(); showNoBackupMessage();
finish(); finish();
return; return;
} }
backupDates = externalFileBackup.getAvailableBackups(); backupDates = externalFileBackup.getAvailableBackups();
if (backupDates == null || backupDates.length == 0) { if (backupDates == null || backupDates.length == 0) {
Toast.makeText(this, R.string.settings_backup_restore_no_backup, Toast.LENGTH_LONG).show(); showNoBackupMessage();
finish(); finish();
return; return;
} }
@@ -118,4 +118,13 @@ public class RestoreChooserActivity extends Activity {
.setTitle(R.string.settings_backup_restore_select_title) .setTitle(R.string.settings_backup_restore_select_title)
.create(); .create();
} }
/**
* Shows a no backup message.
*/
private void showNoBackupMessage() {
String message = getString(R.string.settings_backup_restore_no_backup,
FileUtils.getDirectoryDisplayName(FileUtils.BACKUPS_DIR));
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
}
} }
@@ -31,6 +31,7 @@ public class FileUtils {
private FileUtils() {} private FileUtils() {}
public static final String TEMP_DIR = "tmp"; public static final String TEMP_DIR = "tmp";
public static final String BACKUPS_DIR = "backups";
/** /**
* Name of the top-level directory inside the SD card where our files will be * Name of the top-level directory inside the SD card where our files will be