From 503fe854eb175674a0a926226805a7a1555de49c Mon Sep 17 00:00:00 2001 From: vanous Date: Mon, 2 Sep 2019 23:06:39 +0200 Subject: [PATCH] Add test button, @stringify strings, add headers --- .../activities/DbManagementActivity.java | 30 +++++++ .../res/layout/activity_db_management.xml | 78 ++++++++++++++++--- app/src/main/res/values/strings.xml | 12 ++- 3 files changed, 108 insertions(+), 12 deletions(-) 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 66b022626..3a0765db2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DbManagementActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DbManagementActivity.java @@ -19,6 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.activities; import android.app.AlertDialog; import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; import android.database.sqlite.SQLiteOpenHelper; import android.os.Bundle; @@ -42,10 +43,13 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; +import nodomain.freeyourgadget.gadgetbridge.database.PeriodicExporter; import nodomain.freeyourgadget.gadgetbridge.entities.Device; import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; import nodomain.freeyourgadget.gadgetbridge.util.GB; +import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs; import nodomain.freeyourgadget.gadgetbridge.util.ImportExportSharedPreferences; +import nodomain.freeyourgadget.gadgetbridge.util.Prefs; public class DbManagementActivity extends AbstractGBActivity { @@ -97,6 +101,32 @@ public class DbManagementActivity extends AbstractGBActivity { } }); + Prefs prefs = GBApplication.getPrefs(); + boolean autoExportEnabled = prefs.getBoolean(GBPrefs.AUTO_EXPORT_ENABLED, false); + Integer autoExportInterval = prefs.getInt(GBPrefs.AUTO_EXPORT_INTERVAL, 0); + String autoExportLocation = prefs.getString(GBPrefs.AUTO_EXPORT_LOCATION, ""); + + int testExportVisibility = (autoExportInterval > 0 && autoExportEnabled) ? View.VISIBLE : View.GONE; + + TextView autoExportLocation_label = findViewById(R.id.autoExportLocation_label); + autoExportLocation_label.setVisibility(testExportVisibility); + + TextView autoExportLocation_intro = findViewById(R.id.autoExportLocation_intro); + autoExportLocation_intro.setVisibility(testExportVisibility); + + TextView autoExportLocationview = findViewById(R.id.autoExportLocationview); + autoExportLocationview.setVisibility(testExportVisibility); + autoExportLocationview.setText(autoExportLocation); + + Button testExportDBButton = findViewById(R.id.testExportDBButton); + testExportDBButton.setVisibility(testExportVisibility); + testExportDBButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + sendBroadcast(new Intent(getApplicationContext(), PeriodicExporter.class)); + } + }); + sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); } diff --git a/app/src/main/res/layout/activity_db_management.xml b/app/src/main/res/layout/activity_db_management.xml index c61aa993f..912a642c9 100644 --- a/app/src/main/res/layout/activity_db_management.xml +++ b/app/src/main/res/layout/activity_db_management.xml @@ -1,4 +1,5 @@ - + +