diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a3c70b47e..6d93681ba 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -437,10 +437,9 @@ android:excludeFromRecents="true"/> directory_listing = new ArrayAdapter(DataManagementActivity.this, android.R.layout.simple_list_item_1, export_path.list()); + + builder.setSingleChoiceItems(directory_listing, 0, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + } + }); + + AlertDialog dialog = builder.create(); + dialog.show(); + + } + }); + int oldDBVisibility = hasOldActivityDatabase() ? View.VISIBLE : View.GONE; TextView deleteOldActivityTitle = findViewById(R.id.mergeOldActivityDataTitle); @@ -140,6 +174,9 @@ public class DbManagementActivity extends AbstractGBActivity { sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); } + private void showDirectoryContent() { + } + //would rather re-use method of SettingsActivity... but lifecycle... private String getAutoExportLocationSummary() { String autoExportLocation = GBApplication.getPrefs().getString(GBPrefs.AUTO_EXPORT_LOCATION, null); @@ -213,7 +250,7 @@ public class DbManagementActivity extends AbstractGBActivity { File myFile = new File(myPath, "Export_preference"); ImportExportSharedPreferences.importFromFile(sharedPrefs, myFile); } catch (Exception ex) { - GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_error_importing_db, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex); + GB.toast(DataManagementActivity.this, getString(R.string.dbmanagementactivity_error_importing_db, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex); } try (DBHandler lockHandler = GBApplication.acquireDB()) { @@ -236,15 +273,30 @@ public class DbManagementActivity extends AbstractGBActivity { } private void exportDB() { - try (DBHandler dbHandler = GBApplication.acquireDB()) { - exportShared(); - DBHelper helper = new DBHelper(this); - File dir = FileUtils.getExternalFilesDir(); - File destFile = helper.exportDB(dbHandler, dir); - GB.toast(this, getString(R.string.dbmanagementactivity_exported_to, destFile.getAbsolutePath()), Toast.LENGTH_LONG, GB.INFO); - } catch (Exception ex) { - GB.toast(this, getString(R.string.dbmanagementactivity_error_exporting_db, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex); - } + new AlertDialog.Builder(this) + .setCancelable(true) + .setTitle(R.string.dbmanagementactivity_export_data_title) + .setMessage(R.string.dbmanagementactivity_export_confirmation) + .setPositiveButton(R.string.activity_DB_ExportButton, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + try (DBHandler dbHandler = GBApplication.acquireDB()) { + exportShared(); + DBHelper helper = new DBHelper(DataManagementActivity.this); + File dir = FileUtils.getExternalFilesDir(); + File destFile = helper.exportDB(dbHandler, dir); + GB.toast(DataManagementActivity.this, getString(R.string.dbmanagementactivity_exported_to, destFile.getAbsolutePath()), Toast.LENGTH_LONG, GB.INFO); + } catch (Exception ex) { + GB.toast(DataManagementActivity.this, getString(R.string.dbmanagementactivity_error_exporting_db, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex); + } + } + }) + .setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + } + }) + .show(); } private void importDB() { @@ -256,15 +308,15 @@ public class DbManagementActivity extends AbstractGBActivity { @Override public void onClick(DialogInterface dialog, int which) { try (DBHandler dbHandler = GBApplication.acquireDB()) { - DBHelper helper = new DBHelper(DbManagementActivity.this); + DBHelper helper = new DBHelper(DataManagementActivity.this); File dir = FileUtils.getExternalFilesDir(); SQLiteOpenHelper sqLiteOpenHelper = dbHandler.getHelper(); File sourceFile = new File(dir, sqLiteOpenHelper.getDatabaseName()); helper.importDB(dbHandler, sourceFile); helper.validateDB(sqLiteOpenHelper); - GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_import_successful), Toast.LENGTH_LONG, GB.INFO); + GB.toast(DataManagementActivity.this, getString(R.string.dbmanagementactivity_import_successful), Toast.LENGTH_LONG, GB.INFO); } catch (Exception ex) { - GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_error_importing_db, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex); + GB.toast(DataManagementActivity.this, getString(R.string.dbmanagementactivity_error_importing_db, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex); } importShared(); } @@ -285,10 +337,10 @@ public class DbManagementActivity extends AbstractGBActivity { .setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if (GBApplication.deleteActivityDatabase(DbManagementActivity.this)) { - GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_database_successfully_deleted), Toast.LENGTH_SHORT, GB.INFO); + if (GBApplication.deleteActivityDatabase(DataManagementActivity.this)) { + GB.toast(DataManagementActivity.this, getString(R.string.dbmanagementactivity_database_successfully_deleted), Toast.LENGTH_SHORT, GB.INFO); } else { - GB.toast(DbManagementActivity.this, getString(R.string.dbmanagementactivity_db_deletion_failed), Toast.LENGTH_SHORT, GB.INFO); + GB.toast(DataManagementActivity.this, getString(R.string.dbmanagementactivity_db_deletion_failed), Toast.LENGTH_SHORT, GB.INFO); } } }) @@ -307,10 +359,10 @@ public class DbManagementActivity extends AbstractGBActivity { 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); + if (GBApplication.deleteOldActivityDatabase(DataManagementActivity.this)) { + GB.toast(DataManagementActivity.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); + GB.toast(DataManagementActivity.this, getString(R.string.dbmanagementactivity_old_activity_db_deletion_failed), Toast.LENGTH_SHORT, GB.INFO); } } }); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java index 0bd8199e9..6094e5974 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java @@ -418,7 +418,7 @@ public class SettingsActivity extends AbstractSettingsActivity { /* Either returns the file path of the selected document, or the display name, or an empty string */ - private String getAutoExportLocationSummary() { + public String getAutoExportLocationSummary() { String autoExportLocation = GBApplication.getPrefs().getString(GBPrefs.AUTO_EXPORT_LOCATION, null); if (autoExportLocation == null) { return ""; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetConfigurationActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetConfigurationActivity.java index 942dc9154..16d54f384 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetConfigurationActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/WidgetConfigurationActivity.java @@ -19,6 +19,7 @@ import java.util.List; import java.util.Map; import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.Widget; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; @@ -58,7 +59,7 @@ public class WidgetConfigurationActivity extends Activity { } AlertDialog.Builder builder = new AlertDialog.Builder(WidgetConfigurationActivity.this); - builder.setTitle("Select device"); + builder.setTitle(R.string.widget_settings_select_device_title); allDevices = getAllDevices(getApplicationContext()); diff --git a/app/src/main/res/layout/activity_db_management.xml b/app/src/main/res/layout/activity_data_management.xml similarity index 70% rename from app/src/main/res/layout/activity_db_management.xml rename to app/src/main/res/layout/activity_data_management.xml index 67ffddee2..260360b44 100644 --- a/app/src/main/res/layout/activity_db_management.xml +++ b/app/src/main/res/layout/activity_data_management.xml @@ -10,30 +10,27 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:paddingRight="@dimen/activity_horizontal_margin" + android:paddingBottom="@dimen/activity_vertical_margin"> + - + android:textColor="@color/accent"/> -