From 9a5caf1b3c08bb34ebcb59baebeb865c93889310 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Wed, 30 Nov 2022 21:06:17 +0100 Subject: [PATCH] Settings for acra and analytics. Closes #98. --- .../apps/readerforselfossv2/android/MyApp.kt | 49 ++++++++++--------- .../android/settings/SettingsActivity.kt | 5 ++ .../drawable/ic_baseline_bug_report_24.xml | 5 ++ .../res/drawable/ic_baseline_insights_24.xml | 7 +++ .../src/main/res/values-ca-rES/strings.xml | 1 + .../src/main/res/values-de-rDE/strings.xml | 1 + .../src/main/res/values-es-rES/strings.xml | 1 + .../src/main/res/values-fa-rIR/strings.xml | 1 + .../src/main/res/values-fr-rFR/strings.xml | 1 + .../src/main/res/values-gl-rES/strings.xml | 1 + .../src/main/res/values-in-rID/strings.xml | 1 + .../src/main/res/values-it-rIT/strings.xml | 1 + .../src/main/res/values-ko-rKR/strings.xml | 1 + .../src/main/res/values-night/strings.xml | 1 + .../src/main/res/values-nl-rNL/strings.xml | 1 + .../src/main/res/values-pt-rBR/strings.xml | 1 + .../src/main/res/values-pt-rPT/strings.xml | 1 + .../src/main/res/values-si-rLK/strings.xml | 1 + .../src/main/res/values-tr-rTR/strings.xml | 1 + .../src/main/res/values-zh-rCN/strings.xml | 1 + .../src/main/res/values-zh-rTW/strings.xml | 1 + androidApp/src/main/res/values/strings.xml | 1 + .../src/main/res/xml/pref_experimental.xml | 6 --- androidApp/src/main/res/xml/pref_main.xml | 23 ++++++++- 24 files changed, 82 insertions(+), 31 deletions(-) create mode 100644 androidApp/src/main/res/drawable/ic_baseline_bug_report_24.xml create mode 100644 androidApp/src/main/res/drawable/ic_baseline_insights_24.xml diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt index 6ccb491..af743ac 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/MyApp.kt @@ -29,6 +29,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch +import org.acra.ACRA import org.acra.ReportField import org.acra.config.httpSender import org.acra.config.toast @@ -65,28 +66,30 @@ class MyApp : MultiDexApplication(), DIAware { super.onCreate() Napier.base(DebugAntilog()) - initDrawerImageLoader() + if (!ACRA.isACRASenderServiceProcess()) { + initDrawerImageLoader() - tryToHandleBug() + tryToHandleBug() - handleNotificationChannels() + handleNotificationChannels() - ProcessLifecycleOwner.get().lifecycle.addObserver(AppLifeCycleObserver(connectivityStatus, repository)) + ProcessLifecycleOwner.get().lifecycle.addObserver(AppLifeCycleObserver(connectivityStatus, repository)) - CoroutineScope(Dispatchers.Main).launch { - viewModel.networkAvailableProvider.collect { networkAvailable -> - val toastMessage = if (networkAvailable) { - repository.handleDBActions() - R.string.network_connectivity_retrieved - } else { - R.string.network_connectivity_lost + CoroutineScope(Dispatchers.Main).launch { + viewModel.networkAvailableProvider.collect { networkAvailable -> + val toastMessage = if (networkAvailable) { + repository.handleDBActions() + R.string.network_connectivity_retrieved + } else { + R.string.network_connectivity_lost + } + + Toast.makeText( + applicationContext, + toastMessage, + Toast.LENGTH_SHORT + ).show() } - - Toast.makeText( - applicationContext, - toastMessage, - Toast.LENGTH_SHORT - ).show() } } } @@ -95,10 +98,9 @@ class MyApp : MultiDexApplication(), DIAware { super.attachBaseContext(base) initAcra { - //core configuration: - buildConfigClass = BuildConfig::class.java reportFormat = StringFormat.JSON - + reportSendSuccessToast = "YES" + reportSendFailureToast = "NO !" reportContent = listOf( ReportField.REPORT_ID, ReportField.INSTALLATION_ID, ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, @@ -110,12 +112,13 @@ class MyApp : MultiDexApplication(), DIAware { toast { //required text = getString(R.string.crash_toast_text) - length = Toast.LENGTH_LONG + length = Toast.LENGTH_SHORT } httpSender { - uri = "https://your.server.com/report" + uri = "https://bugs.amine-louveau.fr/report" /*best guess, you may need to adjust this*/ + basicAuthLogin = "LMTlLZuazADohTCm" + basicAuthPassword = "he6ghHp83F0PYPfh" httpMethod = HttpSender.Method.POST - compress = false } } } diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt index 472ebe1..e3bbe13 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/settings/SettingsActivity.kt @@ -103,6 +103,11 @@ class SettingsActivity : AppCompatActivity(), class MainPreferenceFragment : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { setPreferencesFromResource(R.xml.pref_main, rootKey) + + preferenceManager.findPreference("currentMode")?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> + AppCompatDelegate.setDefaultNightMode(newValue.toString().toInt()) // ListPreference Only takes string-arrays ¯\_(ツ)_/¯ + true + } } } diff --git a/androidApp/src/main/res/drawable/ic_baseline_bug_report_24.xml b/androidApp/src/main/res/drawable/ic_baseline_bug_report_24.xml new file mode 100644 index 0000000..031730c --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_bug_report_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/androidApp/src/main/res/drawable/ic_baseline_insights_24.xml b/androidApp/src/main/res/drawable/ic_baseline_insights_24.xml new file mode 100644 index 0000000..99440b9 --- /dev/null +++ b/androidApp/src/main/res/drawable/ic_baseline_insights_24.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/androidApp/src/main/res/values-ca-rES/strings.xml b/androidApp/src/main/res/values-ca-rES/strings.xml index b09caad..31ddde3 100644 --- a/androidApp/src/main/res/values-ca-rES/strings.xml +++ b/androidApp/src/main/res/values-ca-rES/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-de-rDE/strings.xml b/androidApp/src/main/res/values-de-rDE/strings.xml index 1f46319..92335dc 100644 --- a/androidApp/src/main/res/values-de-rDE/strings.xml +++ b/androidApp/src/main/res/values-de-rDE/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-es-rES/strings.xml b/androidApp/src/main/res/values-es-rES/strings.xml index c8f6c2d..ebff045 100644 --- a/androidApp/src/main/res/values-es-rES/strings.xml +++ b/androidApp/src/main/res/values-es-rES/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-fa-rIR/strings.xml b/androidApp/src/main/res/values-fa-rIR/strings.xml index 5db2616..7938f45 100644 --- a/androidApp/src/main/res/values-fa-rIR/strings.xml +++ b/androidApp/src/main/res/values-fa-rIR/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-fr-rFR/strings.xml b/androidApp/src/main/res/values-fr-rFR/strings.xml index ebf715c..bf16dc7 100644 --- a/androidApp/src/main/res/values-fr-rFR/strings.xml +++ b/androidApp/src/main/res/values-fr-rFR/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-gl-rES/strings.xml b/androidApp/src/main/res/values-gl-rES/strings.xml index af411c2..194abb9 100644 --- a/androidApp/src/main/res/values-gl-rES/strings.xml +++ b/androidApp/src/main/res/values-gl-rES/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-in-rID/strings.xml b/androidApp/src/main/res/values-in-rID/strings.xml index 2901507..2e2299f 100644 --- a/androidApp/src/main/res/values-in-rID/strings.xml +++ b/androidApp/src/main/res/values-in-rID/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-it-rIT/strings.xml b/androidApp/src/main/res/values-it-rIT/strings.xml index 17166c9..7fcc627 100644 --- a/androidApp/src/main/res/values-it-rIT/strings.xml +++ b/androidApp/src/main/res/values-it-rIT/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-ko-rKR/strings.xml b/androidApp/src/main/res/values-ko-rKR/strings.xml index 79bc52a..e56a91f 100644 --- a/androidApp/src/main/res/values-ko-rKR/strings.xml +++ b/androidApp/src/main/res/values-ko-rKR/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-night/strings.xml b/androidApp/src/main/res/values-night/strings.xml index 6b3a563..ac99954 100644 --- a/androidApp/src/main/res/values-night/strings.xml +++ b/androidApp/src/main/res/values-night/strings.xml @@ -4,4 +4,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " \ No newline at end of file diff --git a/androidApp/src/main/res/values-nl-rNL/strings.xml b/androidApp/src/main/res/values-nl-rNL/strings.xml index 52fc7d4..cfc1138 100644 --- a/androidApp/src/main/res/values-nl-rNL/strings.xml +++ b/androidApp/src/main/res/values-nl-rNL/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-pt-rBR/strings.xml b/androidApp/src/main/res/values-pt-rBR/strings.xml index 3e61947..8cd902f 100644 --- a/androidApp/src/main/res/values-pt-rBR/strings.xml +++ b/androidApp/src/main/res/values-pt-rBR/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-pt-rPT/strings.xml b/androidApp/src/main/res/values-pt-rPT/strings.xml index c1e9315..3260238 100644 --- a/androidApp/src/main/res/values-pt-rPT/strings.xml +++ b/androidApp/src/main/res/values-pt-rPT/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-si-rLK/strings.xml b/androidApp/src/main/res/values-si-rLK/strings.xml index 06b89d9..03d439f 100644 --- a/androidApp/src/main/res/values-si-rLK/strings.xml +++ b/androidApp/src/main/res/values-si-rLK/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-tr-rTR/strings.xml b/androidApp/src/main/res/values-tr-rTR/strings.xml index 312e4ec..f98a8b4 100644 --- a/androidApp/src/main/res/values-tr-rTR/strings.xml +++ b/androidApp/src/main/res/values-tr-rTR/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-zh-rCN/strings.xml b/androidApp/src/main/res/values-zh-rCN/strings.xml index 4e839bb..a13def9 100644 --- a/androidApp/src/main/res/values-zh-rCN/strings.xml +++ b/androidApp/src/main/res/values-zh-rCN/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values-zh-rTW/strings.xml b/androidApp/src/main/res/values-zh-rTW/strings.xml index b07d077..ab6462f 100644 --- a/androidApp/src/main/res/values-zh-rTW/strings.xml +++ b/androidApp/src/main/res/values-zh-rTW/strings.xml @@ -137,4 +137,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index 9cf2606..eb086e6 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -140,4 +140,5 @@ The app does not share any personal data about you. Debug). Keep in mind that crash reports are essential for the app development.]]> A crash occured. Sending the details to the developper. + "Disable automatic bug reporting. " diff --git a/androidApp/src/main/res/xml/pref_experimental.xml b/androidApp/src/main/res/xml/pref_experimental.xml index 990de19..7fd7caa 100644 --- a/androidApp/src/main/res/xml/pref_experimental.xml +++ b/androidApp/src/main/res/xml/pref_experimental.xml @@ -1,12 +1,6 @@ - - - + + + + + + \ No newline at end of file