diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DbManagementActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DbManagementActivity.java index 693577f8..509bc093 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DbManagementActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DbManagementActivity.java @@ -111,8 +111,9 @@ public class DbManagementActivity extends GBActivity { try { return FileUtils.getExternalFilesDir().getAbsolutePath(); } catch (Exception ex) { + LOG.warn("Unable to get external files dir", ex); } - return "Cannot access export path. Please contact the developers."; + return getString(R.string.dbmanagementactivvity_cannot_access_export_path); } private void exportDB() { @@ -120,18 +121,18 @@ public class DbManagementActivity extends GBActivity { DBHelper helper = new DBHelper(this); File dir = FileUtils.getExternalFilesDir(); File destFile = helper.exportDB(dbHandler, dir); - GB.toast(this, "Exported to: " + destFile.getAbsolutePath(), Toast.LENGTH_LONG, GB.INFO); + GB.toast(this, getString(R.string.dbmanagementactivity_exported_to, destFile.getAbsolutePath()), Toast.LENGTH_LONG, GB.INFO); } catch (Exception ex) { - GB.toast(this, "Error exporting DB: " + ex.getMessage(), Toast.LENGTH_LONG, GB.ERROR, ex); + GB.toast(this, getString(R.string.dbmanagementactivity_error_exporting_db, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex); } } private void importDB() { new AlertDialog.Builder(this) .setCancelable(true) - .setTitle("Import Activity Data?") - .setMessage("Really overwrite the current activity database? All your activity data (if any) will be lost.") - .setPositiveButton("Overwrite", new DialogInterface.OnClickListener() { + .setTitle(R.string.dbmanagementactivity_import_data_title) + .setMessage(R.string.dbmanagementactivity_overwrite_database_confirmation) + .setPositiveButton(R.string.dbmanagementactivity_overwrite, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try (DBHandler dbHandler = GBApplication.acquireDB()) { @@ -141,13 +142,13 @@ public class DbManagementActivity extends GBActivity { File sourceFile = new File(dir, sqLiteOpenHelper.getDatabaseName()); helper.importDB(dbHandler, sourceFile); helper.validateDB(sqLiteOpenHelper); - GB.toast(DbManagementActivity.this, "Import successful.", Toast.LENGTH_LONG, GB.INFO); + GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_import_successful), Toast.LENGTH_LONG, GB.INFO); } catch (Exception ex) { - GB.toast(DbManagementActivity.this, "Error importing DB: " + ex.getMessage(), Toast.LENGTH_LONG, GB.ERROR, ex); + GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_error_importing_db, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex); } } }) - .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + .setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } @@ -159,18 +160,18 @@ public class DbManagementActivity extends GBActivity { final DBHelper helper = new DBHelper(getBaseContext()); final ActivityDatabaseHandler oldHandler = helper.getOldActivityDatabaseHandler(); if (oldHandler == null) { - GB.toast(this, "No old activity database found, nothing to import.", Toast.LENGTH_LONG, GB.ERROR); + GB.toast(this, getString(R.string.dbmanagementactivity_no_old_activitydatabase_found), Toast.LENGTH_LONG, GB.ERROR); return; } selectDeviceForMergingActivityDatabaseInto(new DeviceSelectionCallback() { @Override public void invoke(final GBDevice device) { if (device == null) { - GB.toast(DbManagementActivity.this, "No connected device to associate old activity data with.", Toast.LENGTH_LONG, GB.ERROR); + GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_no_connected_device), Toast.LENGTH_LONG, GB.ERROR); return; } try (DBHandler targetHandler = GBApplication.acquireDB()) { - final ProgressDialog progress = ProgressDialog.show(DbManagementActivity.this, "Merging Activity Data", "Please wait while merging your activity data...", true, false); + final ProgressDialog progress = ProgressDialog.show(DbManagementActivity.this, getString(R.string.dbmanagementactivity_merging_activity_data_title), getString(R.string.dbmanagementactivity_please_wait_while_merging), true, false); new AsyncTask() { @Override protected Object doInBackground(Object[] params) { @@ -182,7 +183,7 @@ public class DbManagementActivity extends GBActivity { } }.execute((Object[]) null); } catch (Exception ex) { - GB.toast(DbManagementActivity.this, "Error importing old activity data into new database.", Toast.LENGTH_LONG, GB.ERROR, ex); + GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_error_importing_old_activity_data), Toast.LENGTH_LONG, GB.ERROR, ex); } } }); @@ -199,7 +200,7 @@ public class DbManagementActivity extends GBActivity { new AlertDialog.Builder(this) .setCancelable(true) - .setTitle("Associate old Data with Device") + .setTitle(R.string.dbmanagementactivity_associate_old_data_with_device) .setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -207,7 +208,7 @@ public class DbManagementActivity extends GBActivity { callback.invoke(device); } }) - .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + .setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // ignore, just return @@ -219,19 +220,19 @@ public class DbManagementActivity extends GBActivity { private void deleteActivityDatabase() { new AlertDialog.Builder(this) .setCancelable(true) - .setTitle("Delete Activity Data?") - .setMessage("Really delete the entire activity database? All your activity data will be lost.") - .setPositiveButton("Delete", new DialogInterface.OnClickListener() { + .setTitle(R.string.dbmanagementactivity_delete_activity_data_title) + .setMessage(R.string.dbmanagementactivity_really_delete_entire_db) + .setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (GBApplication.deleteActivityDatabase(DbManagementActivity.this)) { - GB.toast(DbManagementActivity.this, "Activity database successfully deleted.", Toast.LENGTH_SHORT, GB.INFO); + GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_database_successfully_deleted), Toast.LENGTH_SHORT, GB.INFO); } else { - GB.toast(DbManagementActivity.this, "Activity database deletion failed.", Toast.LENGTH_SHORT, GB.INFO); + GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_db_deletion_failed), Toast.LENGTH_SHORT, GB.INFO); } } }) - .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + .setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } @@ -240,26 +241,25 @@ public class DbManagementActivity extends GBActivity { } private void deleteOldActivityDbFile() { - new AlertDialog.Builder(this) - .setCancelable(true) - .setTitle("Delete old Activity Database?") - .setMessage("Really delete the old activity database? Activity data that were not imported will be lost.") - .setPositiveButton("Delete", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - if (GBApplication.deleteOldActivityDatabase(DbManagementActivity.this)) { - GB.toast(DbManagementActivity.this, "Old Activity database successfully deleted.", Toast.LENGTH_SHORT, GB.INFO); - } else { - GB.toast(DbManagementActivity.this, "Old Activity database deletion failed.", Toast.LENGTH_SHORT, GB.INFO); - } - } - }) - .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - } - }) - .show(); + new AlertDialog.Builder(this).setCancelable(true); + new AlertDialog.Builder(this).setTitle(R.string.dbmanagementactivity_delete_old_activity_db); + new AlertDialog.Builder(this).setMessage(R.string.dbmanagementactivity_delete_old_activitydb_confirmation); + new AlertDialog.Builder(this).setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (GBApplication.deleteOldActivityDatabase(DbManagementActivity.this)) { + GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_old_activity_db_successfully_deleted), Toast.LENGTH_SHORT, GB.INFO); + } else { + GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_old_activity_db_deletion_failed), Toast.LENGTH_SHORT, GB.INFO); + } + } + }); + new AlertDialog.Builder(this).setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + } + }); + new AlertDialog.Builder(this).show(); } @Override diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c2f1c432..5f1dd3f1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -298,8 +298,32 @@ Store raw record in the database If checked the data is stored \"as is\" and is available for later interpretation. NB: the database will be bigger in this case! Database Management - Database management - The database operations use the following path on your device. \nThis path is accessible to other android applications and your computer. \nExpect to find your exported database (or place the database you want to import) there: + Database Management + The database operations use the following path on your device. \nThis path is accessible to other Android applications and your computer. \nExpect to find your exported database (or place the database you want to import) there: The activity data recorded with Gadgetbridge versions prior to 0.12 must be converted to a new format. \nYou can do this using the button below. Be aware that you must be connected to the device you want to associate the old activity data with! \nIf you already imported your data and are happy with the result, you may delete the old database. - Legacy database import / delete + Legacy Database Import / Delete + Cannot access export path. Please contact the developers. + Exported to: %1$s + "Error exporting DB: %1$s" + Import Data? + Really overwrite the current database? All your current activity data (if any) will be lost. + Import successful. + "Error importing DB: %1$s" + No old activity database found, nothing to import. + No connected device to associate old activity data with. + Merging Activity Data + Please wait while merging your activity data… + Error importing old activity data into new database. + Associate old Data with Device + Delete Activity Data? + Really delete the entire database? All your activity data and information about your devices will be lost. + Data successfully deleted. + Database deletion failed. + Delete old Activity Database? + Really delete the old activity database? Activity data that was not imported will be lost. + Old activity data successfully deleted. + Old Activity database deletion failed. + Overwrite + Cancel + Delete