From 0a6aa1bde4bb763e48bdb19c938bdf051a4c7eb7 Mon Sep 17 00:00:00 2001 From: huangyz0918 Date: Wed, 14 Aug 2019 16:15:32 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20reset=20setting?= =?UTF-8?q?s=20option.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/ui/settings/PreferenceKeys.java | 1 + .../views/ui/settings/SettingsActivity.java | 29 +++++++++++-- .../res/drawable/ic_refresh_black_24dp.xml | 9 ++++ .../src/main/res/values/strings.xml | 4 ++ .../src/main/res/xml/preferences_menu.xml | 43 +++++++++++++------ 5 files changed, 69 insertions(+), 17 deletions(-) create mode 100644 skunkworks_crow/src/main/res/drawable/ic_refresh_black_24dp.xml diff --git a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/PreferenceKeys.java b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/PreferenceKeys.java index e411cd41..105c8df9 100644 --- a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/PreferenceKeys.java +++ b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/PreferenceKeys.java @@ -10,6 +10,7 @@ public class PreferenceKeys { public static final String KEY_HOTSPOT_PASSWORD = "hotspot_password"; public static final String KEY_HOTSPOT_PWD_REQUIRE = "hotspot_pwd_require"; public static final String KEY_ODK_DESTINATION_DIR = "odk_destination_dir"; + public static final String KEY_RESET_SETTINGS = "reset_settings"; private PreferenceKeys() { diff --git a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java index 1a358e50..2127df4f 100644 --- a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java +++ b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java @@ -1,5 +1,6 @@ package org.odk.share.views.ui.settings; +import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; @@ -15,13 +16,13 @@ import android.view.WindowManager; import android.widget.Toast; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.widget.Toolbar; + import com.google.android.material.textfield.TextInputLayout; import org.odk.share.R; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.widget.Toolbar; - /** * Created by laksh on 5/27/2018. @@ -31,6 +32,7 @@ public class SettingsActivity extends PreferenceActivity { EditTextPreference hotspotNamePreference; Preference hotspotPasswordPreference; + Preference resetPreference; CheckBoxPreference passwordRequirePreference; EditTextPreference odkDestinationDirPreference; private SharedPreferences prefs; @@ -56,6 +58,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } private void addPreferences() { + resetPreference = findPreference(PreferenceKeys.KEY_RESET_SETTINGS); hotspotNamePreference = (EditTextPreference) findPreference(PreferenceKeys.KEY_HOTSPOT_NAME); hotspotPasswordPreference = findPreference(PreferenceKeys.KEY_HOTSPOT_PASSWORD); passwordRequirePreference = (CheckBoxPreference) findPreference(PreferenceKeys.KEY_HOTSPOT_PWD_REQUIRE); @@ -77,6 +80,7 @@ private void addPreferences() { passwordRequirePreference.setOnPreferenceChangeListener(preferenceChangeListener()); odkDestinationDirPreference.setOnPreferenceChangeListener(preferenceChangeListener()); + resetPreference.setOnPreferenceClickListener(preferenceClickListener()); hotspotPasswordPreference.setOnPreferenceClickListener(preferenceClickListener()); } @@ -86,6 +90,9 @@ private Preference.OnPreferenceClickListener preferenceClickListener() { case PreferenceKeys.KEY_HOTSPOT_PASSWORD: showPasswordDialog(); break; + case PreferenceKeys.KEY_RESET_SETTINGS: + resetSettings(); + break; } return false; }; @@ -162,4 +169,20 @@ private void showPasswordDialog() { alertDialog.setCancelable(true); alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } + + private void resetSettings() { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(getString(R.string.title_reset_settings)) + .setMessage(getString(R.string.message_reset_settings)) + .setPositiveButton(getString(R.string.ok), (DialogInterface dialog, int which) -> { + SharedPreferences.Editor editor = prefs.edit(); + editor.clear(); + editor.apply(); + Toast.makeText(this, getString(R.string.success_reset_settings), Toast.LENGTH_LONG).show(); + finish(); + }) + .setNegativeButton(getString(R.string.cancel), (DialogInterface dialog, int which) -> { + dialog.dismiss(); + }).create().show(); + } } diff --git a/skunkworks_crow/src/main/res/drawable/ic_refresh_black_24dp.xml b/skunkworks_crow/src/main/res/drawable/ic_refresh_black_24dp.xml new file mode 100644 index 00000000..8229a9a6 --- /dev/null +++ b/skunkworks_crow/src/main/res/drawable/ic_refresh_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/skunkworks_crow/src/main/res/values/strings.xml b/skunkworks_crow/src/main/res/values/strings.xml index 07eab49a..aff3d463 100644 --- a/skunkworks_crow/src/main/res/values/strings.xml +++ b/skunkworks_crow/src/main/res/values/strings.xml @@ -131,6 +131,10 @@ The destination should not be empty Location Permission Needed Enable location from the settings. + Click to reset all preferences + Reset Settings + Are you sure to reset all the settings? + Reset success, open settings to see changes Refresh Bluetooth diff --git a/skunkworks_crow/src/main/res/xml/preferences_menu.xml b/skunkworks_crow/src/main/res/xml/preferences_menu.xml index 9d0d1dcb..cc42c943 100644 --- a/skunkworks_crow/src/main/res/xml/preferences_menu.xml +++ b/skunkworks_crow/src/main/res/xml/preferences_menu.xml @@ -1,36 +1,51 @@ - + + + + + + + + + android:summary="@string/default_hotspot_ssid" + android:title="@string/title_hotspot_ssid" /> + android:icon="@drawable/ic_vpn_key_black_24dp" + android:key="hotspot_password" + android:summary="********" + android:title="@string/title_hotspot_password" /> + android:title="@string/set_password" /> + android:summary="@string/default_odk_destination_dir" + android:title="@string/title_odk_destination_dir" /> From 24a842bb21dacebfa1dc1351e4f42eecb2595a43 Mon Sep 17 00:00:00 2001 From: huangyz0918 Date: Thu, 15 Aug 2019 08:38:34 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=F0=9F=9A=91=20quickfix:=20remove=20gener?= =?UTF-8?q?al=20items.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skunkworks_crow/src/main/res/xml/preferences_menu.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/skunkworks_crow/src/main/res/xml/preferences_menu.xml b/skunkworks_crow/src/main/res/xml/preferences_menu.xml index cc42c943..a1c66259 100644 --- a/skunkworks_crow/src/main/res/xml/preferences_menu.xml +++ b/skunkworks_crow/src/main/res/xml/preferences_menu.xml @@ -40,12 +40,5 @@ android:summary="@string/password_hotspot" android:title="@string/set_password" /> - - From d7320ba01bf320ec79f27e57befab47fd3ea3743 Mon Sep 17 00:00:00 2001 From: huangyz0918 Date: Sun, 18 Aug 2019 08:37:45 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20options=20for?= =?UTF-8?q?=20resetting.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/odk/share/utilities/FileUtils.java | 27 ++++++ .../views/ui/settings/SettingsActivity.java | 85 +++++++++++++++++-- .../src/main/res/layout/pref_reset_dialog.xml | 30 +++++++ .../src/main/res/values/strings.xml | 14 ++- .../src/main/res/xml/preferences_menu.xml | 1 - 5 files changed, 143 insertions(+), 14 deletions(-) create mode 100644 skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml diff --git a/skunkworks_crow/src/main/java/org/odk/share/utilities/FileUtils.java b/skunkworks_crow/src/main/java/org/odk/share/utilities/FileUtils.java index c18c23d9..6b0eb452 100644 --- a/skunkworks_crow/src/main/java/org/odk/share/utilities/FileUtils.java +++ b/skunkworks_crow/src/main/java/org/odk/share/utilities/FileUtils.java @@ -1,5 +1,6 @@ package org.odk.share.utilities; +import java.io.File; import java.util.Locale; public final class FileUtils { @@ -15,4 +16,30 @@ public static String getFileExtension(String fileName) { } return fileName.substring(dotIndex + 1).toLowerCase(Locale.ROOT); } + + /** + * Delete all contents under the path, would not remove the folder. + */ + public static boolean deleteFolderContents(String path) { + boolean result = true; + File file = new File(path); + if (file.exists()) { + File[] files = file.listFiles(); + if (files != null) { + for (File f : files) { + result = deleteRecursive(f); + } + } + } + return result; + } + + private static boolean deleteRecursive(File fileOrDirectory) { + if (fileOrDirectory.isDirectory()) { + for (File child : fileOrDirectory.listFiles()) { + deleteRecursive(child); + } + } + return fileOrDirectory.delete(); + } } diff --git a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java index 2127df4f..7c0bf841 100644 --- a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java +++ b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java @@ -1,5 +1,6 @@ package org.odk.share.views.ui.settings; +import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Build; @@ -14,6 +15,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; +import android.widget.CheckBox; import android.widget.Toast; import androidx.appcompat.app.AlertDialog; @@ -22,6 +24,8 @@ import com.google.android.material.textfield.TextInputLayout; import org.odk.share.R; +import org.odk.share.application.Share; +import org.odk.share.utilities.FileUtils; /** @@ -36,6 +40,7 @@ public class SettingsActivity extends PreferenceActivity { CheckBoxPreference passwordRequirePreference; EditTextPreference odkDestinationDirPreference; private SharedPreferences prefs; + private ProgressDialog progressDialog; @Override protected void onCreate(Bundle savedInstanceState) { @@ -91,7 +96,7 @@ private Preference.OnPreferenceClickListener preferenceClickListener() { showPasswordDialog(); break; case PreferenceKeys.KEY_RESET_SETTINGS: - resetSettings(); + resetApplication(); break; } return false; @@ -170,19 +175,81 @@ private void showPasswordDialog() { alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } - private void resetSettings() { + /** + * Reset the application settings and the application data. + */ + private void resetApplication() { + View checkBoxView = View.inflate(this, R.layout.pref_reset_dialog, null); + CheckBox cbResetPref = checkBoxView.findViewById(R.id.cb_reset_pref); + CheckBox cbResetData = checkBoxView.findViewById(R.id.cb_clear_db); + AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(getString(R.string.title_reset_settings)) + AlertDialog resetDialog = builder.setTitle(getString(R.string.title_reset_settings)) .setMessage(getString(R.string.message_reset_settings)) + .setView(checkBoxView) + .setCancelable(false) .setPositiveButton(getString(R.string.ok), (DialogInterface dialog, int which) -> { - SharedPreferences.Editor editor = prefs.edit(); - editor.clear(); - editor.apply(); - Toast.makeText(this, getString(R.string.success_reset_settings), Toast.LENGTH_LONG).show(); - finish(); + progressDialog = new ProgressDialog(this); + progressDialog.setTitle(getString(R.string.resetting)); + progressDialog.setMessage(getString(R.string.resetting_msg)); + progressDialog.setIndeterminate(true); + progressDialog.setCancelable(false); + progressDialog.show(); + + dialog.dismiss(); + if (!cbResetData.isChecked() && !cbResetPref.isChecked()) { + progressDialog.dismiss(); + Toast.makeText(this, getString(R.string.reset_select_nothing), Toast.LENGTH_LONG).show(); + } else { + startRest(cbResetPref, cbResetData); + } }) .setNegativeButton(getString(R.string.cancel), (DialogInterface dialog, int which) -> { dialog.dismiss(); - }).create().show(); + }) + .create(); + resetDialog.show(); + } + + private void startRest(CheckBox cbResetPref, CheckBox cbResetData) { + StringBuilder stringBuilder = new StringBuilder(); + if (cbResetData.isChecked()) { + stringBuilder.append(getString(R.string.reset_result_data, resetData() ? "Success" : "Failed")); + } + + if (cbResetPref.isChecked()) { + stringBuilder.append(getString(R.string.reset_result_pref, resetPreference() ? "Success" : "Failed")); + } + + progressDialog.dismiss(); + new AlertDialog.Builder(this) + .setTitle(getString(R.string.reset_result)) + .setMessage(stringBuilder.toString()) + .setCancelable(false) + .setPositiveButton(getString(R.string.ok), (DialogInterface dialog, int which) -> { + dialog.dismiss(); + finish(); + }) + .create() + .show(); + } + + /** + * Reset the preference by resetting the {@link SharedPreferences}. + */ + private boolean resetPreference() { + SharedPreferences.Editor editor = prefs.edit(); + editor.clear(); + return editor.commit(); + } + + /** + * Removing the cache and database table by deleting the share + * folder and create a new one. + */ + private boolean resetData() { + boolean result = FileUtils.deleteFolderContents(Share.ODK_ROOT); + Share.createODKDirs(this); + return result; } } diff --git a/skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml b/skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml new file mode 100644 index 00000000..b8f5b8c3 --- /dev/null +++ b/skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/skunkworks_crow/src/main/res/values/strings.xml b/skunkworks_crow/src/main/res/values/strings.xml index aff3d463..bc54b64f 100644 --- a/skunkworks_crow/src/main/res/values/strings.xml +++ b/skunkworks_crow/src/main/res/values/strings.xml @@ -131,10 +131,16 @@ The destination should not be empty Location Permission Needed Enable location from the settings. - Click to reset all preferences - Reset Settings - Are you sure to reset all the settings? - Reset success, open settings to see changes + Reset Application + Please select items to reset + Reset Database + Rest Preferences + Please select items to reset + Resetting + Resetting application, please wait… + Reset Result + Reset Preference: %s + Reset Database: %s \n Refresh Bluetooth diff --git a/skunkworks_crow/src/main/res/xml/preferences_menu.xml b/skunkworks_crow/src/main/res/xml/preferences_menu.xml index a1c66259..ff92fbb8 100644 --- a/skunkworks_crow/src/main/res/xml/preferences_menu.xml +++ b/skunkworks_crow/src/main/res/xml/preferences_menu.xml @@ -12,7 +12,6 @@ From 888d822d1c8fbb5bd376a915047495a5a6f892b8 Mon Sep 17 00:00:00 2001 From: huangyz0918 Date: Sun, 18 Aug 2019 09:19:31 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=F0=9F=9A=91=20quickfix:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/views/ui/settings/SettingsActivity.java | 14 +++++++++----- skunkworks_crow/src/main/res/values/strings.xml | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java index 7c0bf841..0ed555ee 100644 --- a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java +++ b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java @@ -176,7 +176,7 @@ private void showPasswordDialog() { } /** - * Reset the application settings and the application data. + * Reset the application settings and the database. */ private void resetApplication() { View checkBoxView = View.inflate(this, R.layout.pref_reset_dialog, null); @@ -185,7 +185,6 @@ private void resetApplication() { AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog resetDialog = builder.setTitle(getString(R.string.title_reset_settings)) - .setMessage(getString(R.string.message_reset_settings)) .setView(checkBoxView) .setCancelable(false) .setPositiveButton(getString(R.string.ok), (DialogInterface dialog, int which) -> { @@ -195,8 +194,8 @@ private void resetApplication() { progressDialog.setIndeterminate(true); progressDialog.setCancelable(false); progressDialog.show(); - dialog.dismiss(); + if (!cbResetData.isChecked() && !cbResetPref.isChecked()) { progressDialog.dismiss(); Toast.makeText(this, getString(R.string.reset_select_nothing), Toast.LENGTH_LONG).show(); @@ -211,14 +210,19 @@ private void resetApplication() { resetDialog.show(); } + /** + * Start resetting the application and presenting the reset result in an {@link AlertDialog}. + */ private void startRest(CheckBox cbResetPref, CheckBox cbResetData) { StringBuilder stringBuilder = new StringBuilder(); if (cbResetData.isChecked()) { - stringBuilder.append(getString(R.string.reset_result_data, resetData() ? "Success" : "Failed")); + stringBuilder.append(getString(R.string.reset_result_data, + resetData() ? getString(R.string.reset_success) : getString(R.string.reset_failed))); } if (cbResetPref.isChecked()) { - stringBuilder.append(getString(R.string.reset_result_pref, resetPreference() ? "Success" : "Failed")); + stringBuilder.append(getString(R.string.reset_result_pref, + resetPreference() ? getString(R.string.reset_success) : getString(R.string.reset_failed))); } progressDialog.dismiss(); diff --git a/skunkworks_crow/src/main/res/values/strings.xml b/skunkworks_crow/src/main/res/values/strings.xml index bc54b64f..79ae14cc 100644 --- a/skunkworks_crow/src/main/res/values/strings.xml +++ b/skunkworks_crow/src/main/res/values/strings.xml @@ -132,7 +132,6 @@ Location Permission Needed Enable location from the settings. Reset Application - Please select items to reset Reset Database Rest Preferences Please select items to reset @@ -141,6 +140,8 @@ Reset Result Reset Preference: %s Reset Database: %s \n + Success + Failed Refresh Bluetooth From 14fb94dee23d11c31439d8c0e01760babb72986d Mon Sep 17 00:00:00 2001 From: huangyz0918 Date: Sun, 18 Aug 2019 12:38:33 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=F0=9F=9A=91=20quickfix:=20fix=20the=20st?= =?UTF-8?q?rings.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/ui/settings/SettingsActivity.java | 4 +- .../src/main/res/layout/pref_reset_dialog.xml | 76 ++++++++++++++----- .../src/main/res/values/strings.xml | 12 +-- 3 files changed, 65 insertions(+), 27 deletions(-) diff --git a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java index 0ed555ee..176d14ca 100644 --- a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java +++ b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java @@ -200,7 +200,7 @@ private void resetApplication() { progressDialog.dismiss(); Toast.makeText(this, getString(R.string.reset_select_nothing), Toast.LENGTH_LONG).show(); } else { - startRest(cbResetPref, cbResetData); + startReset(cbResetPref, cbResetData); } }) .setNegativeButton(getString(R.string.cancel), (DialogInterface dialog, int which) -> { @@ -213,7 +213,7 @@ private void resetApplication() { /** * Start resetting the application and presenting the reset result in an {@link AlertDialog}. */ - private void startRest(CheckBox cbResetPref, CheckBox cbResetData) { + private void startReset(CheckBox cbResetPref, CheckBox cbResetData) { StringBuilder stringBuilder = new StringBuilder(); if (cbResetData.isChecked()) { stringBuilder.append(getString(R.string.reset_result_data, diff --git a/skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml b/skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml index b8f5b8c3..d584eb8a 100644 --- a/skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml +++ b/skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml @@ -6,25 +6,61 @@ android:orientation="vertical" android:padding="4dp"> - - - - + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/skunkworks_crow/src/main/res/values/strings.xml b/skunkworks_crow/src/main/res/values/strings.xml index 79ae14cc..14fa000c 100644 --- a/skunkworks_crow/src/main/res/values/strings.xml +++ b/skunkworks_crow/src/main/res/values/strings.xml @@ -132,14 +132,16 @@ Location Permission Needed Enable location from the settings. Reset Application - Reset Database - Rest Preferences + Reset Saved Forms + reset forms sent for review and forms received for review. + Reset All Settings + reset internal settings and saved settings. Please select items to reset Resetting Resetting application, please wait… - Reset Result - Reset Preference: %s - Reset Database: %s \n + Reset Results + Reset All Settings: %s + Reset Saved Forms: %s \n Success Failed From a7c3882cc654a2fb3a8ef5e579daad4f6c9f6f1c Mon Sep 17 00:00:00 2001 From: huangyz0918 Date: Sun, 18 Aug 2019 15:24:21 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=F0=9F=9A=91=20quickfix:=20fix=20the=20st?= =?UTF-8?q?rings.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skunkworks_crow/src/main/res/values/strings.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/skunkworks_crow/src/main/res/values/strings.xml b/skunkworks_crow/src/main/res/values/strings.xml index 14fa000c..ca627b9d 100644 --- a/skunkworks_crow/src/main/res/values/strings.xml +++ b/skunkworks_crow/src/main/res/values/strings.xml @@ -132,16 +132,16 @@ Location Permission Needed Enable location from the settings. Reset Application - Reset Saved Forms + Reset Saved Forms reset forms sent for review and forms received for review. - Reset All Settings - reset internal settings and saved settings. + Reset All Settings + reset internal settings and saved settings. Please select items to reset Resetting Resetting application, please wait… Reset Results - Reset All Settings: %s - Reset Saved Forms: %s \n + All Settings: %s + Saved Forms: %s \n Success Failed From 794dd7c13ce6b7229ea8ab0e90dfe83926a461fb Mon Sep 17 00:00:00 2001 From: huangyz0918 Date: Mon, 19 Aug 2019 18:30:55 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=F0=9F=9A=91=20quickfix:=20fixed=20the=20?= =?UTF-8?q?missed=20conflict=20tag.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skunkworks_crow/src/main/res/xml/preferences_menu.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/skunkworks_crow/src/main/res/xml/preferences_menu.xml b/skunkworks_crow/src/main/res/xml/preferences_menu.xml index 0717004e..6c9349ce 100644 --- a/skunkworks_crow/src/main/res/xml/preferences_menu.xml +++ b/skunkworks_crow/src/main/res/xml/preferences_menu.xml @@ -62,7 +62,5 @@ android:key="bluetooth_secure_mode" android:summary="@string/summary_security_bluetooth" android:title="@string/secure_mode" /> - >>>>>>> upstream/master - From 1088a50a14d2fe6a68a03c36934d16bd2130cace Mon Sep 17 00:00:00 2001 From: huangyz0918 Date: Mon, 19 Aug 2019 19:02:49 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E2=9C=A8=20feat:=20restart=20application?= =?UTF-8?q?=20after=20resetting.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/views/ui/settings/SettingsActivity.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java index f95c7956..4b1fe333 100644 --- a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java +++ b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java @@ -1,8 +1,12 @@ package org.odk.share.views.ui.settings; +import android.app.AlarmManager; +import android.app.PendingIntent; import android.app.ProgressDialog; import android.bluetooth.BluetoothAdapter; +import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; @@ -29,6 +33,7 @@ import org.odk.share.R; import org.odk.share.application.Share; import org.odk.share.utilities.FileUtils; +import org.odk.share.views.ui.main.MainActivity; /** @@ -267,7 +272,12 @@ private void startReset(CheckBox cbResetPref, CheckBox cbResetData) { .setCancelable(false) .setPositiveButton(getString(R.string.ok), (DialogInterface dialog, int which) -> { dialog.dismiss(); - finish(); + Intent mainIntent = new Intent(this, MainActivity.class); + int mPendingIntentId = 0x130; + PendingIntent mPendingIntent = PendingIntent.getActivity(this, mPendingIntentId, mainIntent, PendingIntent.FLAG_CANCEL_CURRENT); + AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); + mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); + System.exit(0); }) .create() .show(); From 1770d674ffd8901d0287520d9bcfee753b598e11 Mon Sep 17 00:00:00 2001 From: huangyz0918 Date: Mon, 19 Aug 2019 19:06:41 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E2=9C=A8=20feat:=20restart=20application?= =?UTF-8?q?=20after=20resetting.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/odk/share/views/ui/settings/SettingsActivity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java index 4b1fe333..5b8e7936 100644 --- a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java +++ b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java @@ -272,11 +272,13 @@ private void startReset(CheckBox cbResetPref, CheckBox cbResetData) { .setCancelable(false) .setPositiveButton(getString(R.string.ok), (DialogInterface dialog, int which) -> { dialog.dismiss(); + // restart application after that. Intent mainIntent = new Intent(this, MainActivity.class); - int mPendingIntentId = 0x130; - PendingIntent mPendingIntent = PendingIntent.getActivity(this, mPendingIntentId, mainIntent, PendingIntent.FLAG_CANCEL_CURRENT); + int pendingIntentId = 0x130; + PendingIntent pendingIntent = PendingIntent.getActivity(this, pendingIntentId, + mainIntent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); - mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent); + mgr.set(AlarmManager.RTC, System.currentTimeMillis(), pendingIntent); System.exit(0); }) .create() From 3e282e236464b56d349ba843cd43328c578cf34c Mon Sep 17 00:00:00 2001 From: huangyz0918 Date: Mon, 19 Aug 2019 22:22:03 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E2=8F=AA=20revert:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/views/ui/settings/SettingsActivity.java | 14 +------------- .../src/main/res/layout/pref_reset_dialog.xml | 1 + 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java index 5b8e7936..f95c7956 100644 --- a/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java +++ b/skunkworks_crow/src/main/java/org/odk/share/views/ui/settings/SettingsActivity.java @@ -1,12 +1,8 @@ package org.odk.share.views.ui.settings; -import android.app.AlarmManager; -import android.app.PendingIntent; import android.app.ProgressDialog; import android.bluetooth.BluetoothAdapter; -import android.content.Context; import android.content.DialogInterface; -import android.content.Intent; import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; @@ -33,7 +29,6 @@ import org.odk.share.R; import org.odk.share.application.Share; import org.odk.share.utilities.FileUtils; -import org.odk.share.views.ui.main.MainActivity; /** @@ -272,14 +267,7 @@ private void startReset(CheckBox cbResetPref, CheckBox cbResetData) { .setCancelable(false) .setPositiveButton(getString(R.string.ok), (DialogInterface dialog, int which) -> { dialog.dismiss(); - // restart application after that. - Intent mainIntent = new Intent(this, MainActivity.class); - int pendingIntentId = 0x130; - PendingIntent pendingIntent = PendingIntent.getActivity(this, pendingIntentId, - mainIntent, PendingIntent.FLAG_CANCEL_CURRENT); - AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); - mgr.set(AlarmManager.RTC, System.currentTimeMillis(), pendingIntent); - System.exit(0); + finish(); }) .create() .show(); diff --git a/skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml b/skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml index d584eb8a..bb06190c 100644 --- a/skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml +++ b/skunkworks_crow/src/main/res/layout/pref_reset_dialog.xml @@ -7,6 +7,7 @@ android:padding="4dp">