From 218ccc803b86fa8aee2d0c37be36025d7b09f399 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 8 Nov 2016 22:35:57 +0100 Subject: [PATCH 1/4] Ask before resetting DB --- .../info/nightscout/androidaps/MainActivity.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 04177386c8..ced7f2311e 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; @@ -7,6 +8,7 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; +import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; @@ -110,7 +112,17 @@ public class MainActivity extends AppCompatActivity { startActivity(i); break; case R.id.nav_resetdb: - MainApp.getDbHelper().resetDatabases(); + new AlertDialog.Builder(getApplicationContext()) + .setTitle(R.string.nav_resetdb) + .setMessage(R.string.reset_db_confirm) + .setNegativeButton(android.R.string.cancel, null) + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override public void onClick(DialogInterface dialog, int which) { + MainApp.getDbHelper().resetDatabases(); + } + }) + .create() + .show(); break; case R.id.nav_export: ImportExportPrefs.verifyStoragePermissions(this); From 341d7222e5441db488764115513e851c09d0cefd Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 8 Nov 2016 22:36:47 +0100 Subject: [PATCH 2/4] Strings for reset DB --- app/src/main/res/values/strings.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6a72ca3921..13a9816ff1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -8,7 +8,8 @@ Refresh treatments from NS Backup Test alarm - Reset databases + Reset Databases + Do you really want to reset the databases? Exit Use extended boluses for >200% DanaR Bluetooth device From bad7e5d7c495e0a0e3efc9bd6834130c7ae2ed93 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 8 Nov 2016 22:55:08 +0100 Subject: [PATCH 3/4] gradle fix --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 4b0a9e796e..66b3675c8d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -27,7 +27,7 @@ def generateGitBuild = { -> String commitObject = stdout.toString().trim() stringBuilder.append(commitObject) } catch (ignored) { - return "NoGitSystemAvailable"; + stringBuilder.append('NoGitSystemAvailable') } stringBuilder.append('-') stringBuilder.append((new Date()).format('yyyy.MM.dd')) From aaba503cd0384a2c5a86773ea4bc6ef2d0bfad7e Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 8 Nov 2016 22:57:56 +0100 Subject: [PATCH 4/4] Fix crash due to not found theme --- app/src/main/java/info/nightscout/androidaps/MainActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index ced7f2311e..aead928e52 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -112,7 +112,7 @@ public class MainActivity extends AppCompatActivity { startActivity(i); break; case R.id.nav_resetdb: - new AlertDialog.Builder(getApplicationContext()) + new AlertDialog.Builder(this) .setTitle(R.string.nav_resetdb) .setMessage(R.string.reset_db_confirm) .setNegativeButton(android.R.string.cancel, null)