Make strings translatable in the database management activity
This commit is contained in:
parent
8c1577a478
commit
ec0a0db4f6
|
@ -111,8 +111,9 @@ public class DbManagementActivity extends GBActivity {
|
||||||
try {
|
try {
|
||||||
return FileUtils.getExternalFilesDir().getAbsolutePath();
|
return FileUtils.getExternalFilesDir().getAbsolutePath();
|
||||||
} catch (Exception ex) {
|
} 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() {
|
private void exportDB() {
|
||||||
|
@ -120,18 +121,18 @@ public class DbManagementActivity extends GBActivity {
|
||||||
DBHelper helper = new DBHelper(this);
|
DBHelper helper = new DBHelper(this);
|
||||||
File dir = FileUtils.getExternalFilesDir();
|
File dir = FileUtils.getExternalFilesDir();
|
||||||
File destFile = helper.exportDB(dbHandler, dir);
|
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) {
|
} 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() {
|
private void importDB() {
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setTitle("Import Activity Data?")
|
.setTitle(R.string.dbmanagementactivity_import_data_title)
|
||||||
.setMessage("Really overwrite the current activity database? All your activity data (if any) will be lost.")
|
.setMessage(R.string.dbmanagementactivity_overwrite_database_confirmation)
|
||||||
.setPositiveButton("Overwrite", new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.dbmanagementactivity_overwrite, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
||||||
|
@ -141,13 +142,13 @@ public class DbManagementActivity extends GBActivity {
|
||||||
File sourceFile = new File(dir, sqLiteOpenHelper.getDatabaseName());
|
File sourceFile = new File(dir, sqLiteOpenHelper.getDatabaseName());
|
||||||
helper.importDB(dbHandler, sourceFile);
|
helper.importDB(dbHandler, sourceFile);
|
||||||
helper.validateDB(sqLiteOpenHelper);
|
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) {
|
} 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
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
}
|
}
|
||||||
|
@ -159,18 +160,18 @@ public class DbManagementActivity extends GBActivity {
|
||||||
final DBHelper helper = new DBHelper(getBaseContext());
|
final DBHelper helper = new DBHelper(getBaseContext());
|
||||||
final ActivityDatabaseHandler oldHandler = helper.getOldActivityDatabaseHandler();
|
final ActivityDatabaseHandler oldHandler = helper.getOldActivityDatabaseHandler();
|
||||||
if (oldHandler == null) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
selectDeviceForMergingActivityDatabaseInto(new DeviceSelectionCallback() {
|
selectDeviceForMergingActivityDatabaseInto(new DeviceSelectionCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(final GBDevice device) {
|
public void invoke(final GBDevice device) {
|
||||||
if (device == null) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
try (DBHandler targetHandler = GBApplication.acquireDB()) {
|
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<Object, ProgressDialog, Object>() {
|
new AsyncTask<Object, ProgressDialog, Object>() {
|
||||||
@Override
|
@Override
|
||||||
protected Object doInBackground(Object[] params) {
|
protected Object doInBackground(Object[] params) {
|
||||||
|
@ -182,7 +183,7 @@ public class DbManagementActivity extends GBActivity {
|
||||||
}
|
}
|
||||||
}.execute((Object[]) null);
|
}.execute((Object[]) null);
|
||||||
} catch (Exception ex) {
|
} 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)
|
new AlertDialog.Builder(this)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setTitle("Associate old Data with Device")
|
.setTitle(R.string.dbmanagementactivity_associate_old_data_with_device)
|
||||||
.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -207,7 +208,7 @@ public class DbManagementActivity extends GBActivity {
|
||||||
callback.invoke(device);
|
callback.invoke(device);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// ignore, just return
|
// ignore, just return
|
||||||
|
@ -219,19 +220,19 @@ public class DbManagementActivity extends GBActivity {
|
||||||
private void deleteActivityDatabase() {
|
private void deleteActivityDatabase() {
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setTitle("Delete Activity Data?")
|
.setTitle(R.string.dbmanagementactivity_delete_activity_data_title)
|
||||||
.setMessage("Really delete the entire activity database? All your activity data will be lost.")
|
.setMessage(R.string.dbmanagementactivity_really_delete_entire_db)
|
||||||
.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (GBApplication.deleteActivityDatabase(DbManagementActivity.this)) {
|
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 {
|
} 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
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
}
|
}
|
||||||
|
@ -240,26 +241,25 @@ public class DbManagementActivity extends GBActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteOldActivityDbFile() {
|
private void deleteOldActivityDbFile() {
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this).setCancelable(true);
|
||||||
.setCancelable(true)
|
new AlertDialog.Builder(this).setTitle(R.string.dbmanagementactivity_delete_old_activity_db);
|
||||||
.setTitle("Delete old Activity Database?")
|
new AlertDialog.Builder(this).setMessage(R.string.dbmanagementactivity_delete_old_activitydb_confirmation);
|
||||||
.setMessage("Really delete the old activity database? Activity data that were not imported will be lost.")
|
new AlertDialog.Builder(this).setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() {
|
||||||
.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
if (GBApplication.deleteOldActivityDatabase(DbManagementActivity.this)) {
|
||||||
if (GBApplication.deleteOldActivityDatabase(DbManagementActivity.this)) {
|
GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_old_activity_db_successfully_deleted), Toast.LENGTH_SHORT, GB.INFO);
|
||||||
GB.toast(DbManagementActivity.this, "Old Activity database successfully deleted.", Toast.LENGTH_SHORT, GB.INFO);
|
} else {
|
||||||
} else {
|
GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_old_activity_db_deletion_failed), Toast.LENGTH_SHORT, GB.INFO);
|
||||||
GB.toast(DbManagementActivity.this, "Old Activity database deletion failed.", Toast.LENGTH_SHORT, GB.INFO);
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
})
|
new AlertDialog.Builder(this).setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
|
||||||
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
}
|
||||||
}
|
});
|
||||||
})
|
new AlertDialog.Builder(this).show();
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -298,8 +298,32 @@
|
||||||
<string name="pref_title_pebble_health_store_raw">Store raw record in the database</string>
|
<string name="pref_title_pebble_health_store_raw">Store raw record in the database</string>
|
||||||
<string name="pref_summary_pebble_health_store_raw">If checked the data is stored \"as is\" and is available for later interpretation. NB: the database will be bigger in this case!</string>
|
<string name="pref_summary_pebble_health_store_raw">If checked the data is stored \"as is\" and is available for later interpretation. NB: the database will be bigger in this case!</string>
|
||||||
<string name="action_db_management">Database Management</string>
|
<string name="action_db_management">Database Management</string>
|
||||||
<string name="title_activity_db_management">Database management</string>
|
<string name="title_activity_db_management">Database Management</string>
|
||||||
<string name="activity_db_management_import_export_explanation">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:</string>
|
<string name="activity_db_management_import_export_explanation">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:</string>
|
||||||
<string name="activity_db_management_merge_old_explanation">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.</string>
|
<string name="activity_db_management_merge_old_explanation">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.</string>
|
||||||
<string name="activity_db_management_merge_old_title">Legacy database import / delete</string>
|
<string name="activity_db_management_merge_old_title">Legacy Database Import / Delete</string>
|
||||||
|
<string name="dbmanagementactivvity_cannot_access_export_path">Cannot access export path. Please contact the developers.</string>
|
||||||
|
<string name="dbmanagementactivity_exported_to">Exported to: %1$s</string>
|
||||||
|
<string name="dbmanagementactivity_error_exporting_db">"Error exporting DB: %1$s"</string>
|
||||||
|
<string name="dbmanagementactivity_import_data_title">Import Data?</string>
|
||||||
|
<string name="dbmanagementactivity_overwrite_database_confirmation">Really overwrite the current database? All your current activity data (if any) will be lost.</string>
|
||||||
|
<string name="dbmanagementactivity_import_successful">Import successful.</string>
|
||||||
|
<string name="dbmanagementactivity_error_importing_db">"Error importing DB: %1$s"</string>
|
||||||
|
<string name="dbmanagementactivity_no_old_activitydatabase_found">No old activity database found, nothing to import.</string>
|
||||||
|
<string name="dbmanagementactivity_no_connected_device">No connected device to associate old activity data with.</string>
|
||||||
|
<string name="dbmanagementactivity_merging_activity_data_title">Merging Activity Data</string>
|
||||||
|
<string name="dbmanagementactivity_please_wait_while_merging">Please wait while merging your activity data…</string>
|
||||||
|
<string name="dbmanagementactivity_error_importing_old_activity_data">Error importing old activity data into new database.</string>
|
||||||
|
<string name="dbmanagementactivity_associate_old_data_with_device">Associate old Data with Device</string>
|
||||||
|
<string name="dbmanagementactivity_delete_activity_data_title">Delete Activity Data?</string>
|
||||||
|
<string name="dbmanagementactivity_really_delete_entire_db">Really delete the entire database? All your activity data and information about your devices will be lost.</string>
|
||||||
|
<string name="dbmanagementactivity_database_successfully_deleted">Data successfully deleted.</string>
|
||||||
|
<string name="dbmanagementactivity_db_deletion_failed">Database deletion failed.</string>
|
||||||
|
<string name="dbmanagementactivity_delete_old_activity_db">Delete old Activity Database?</string>
|
||||||
|
<string name="dbmanagementactivity_delete_old_activitydb_confirmation">Really delete the old activity database? Activity data that was not imported will be lost.</string>
|
||||||
|
<string name="dbmanagementactivity_old_activity_db_successfully_deleted">Old activity data successfully deleted.</string>
|
||||||
|
<string name="dbmanagementactivity_old_activity_db_deletion_failed">Old Activity database deletion failed.</string>
|
||||||
|
<string name="dbmanagementactivity_overwrite">Overwrite</string>
|
||||||
|
<string name="Cancel">Cancel</string>
|
||||||
|
<string name="Delete">Delete</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue