From c3ff894027fdb689fa04d3dcd663fed8e6d796c0 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Wed, 30 Nov 2022 20:53:11 +0100 Subject: [PATCH 1/2] Initial integration. --- androidApp/build.gradle.kts | 4 +++ .../android/HomeActivity.kt | 27 ++++++++++++++ .../apps/readerforselfossv2/android/MyApp.kt | 35 +++++++++++++++++++ .../android/fragments/ArticleFragment.kt | 35 ++++++++++++------- .../android/model/AndroidIModelUtils.kt | 4 ++- .../android/settings/SettingsActivity.kt | 5 +++ .../src/main/res/values-ca-rES/strings.xml | 3 ++ .../src/main/res/values-de-rDE/strings.xml | 3 ++ .../src/main/res/values-es-rES/strings.xml | 3 ++ .../src/main/res/values-fa-rIR/strings.xml | 3 ++ .../src/main/res/values-fr-rFR/strings.xml | 3 ++ .../src/main/res/values-gl-rES/strings.xml | 3 ++ .../src/main/res/values-in-rID/strings.xml | 3 ++ .../src/main/res/values-it-rIT/strings.xml | 3 ++ .../src/main/res/values-ko-rKR/strings.xml | 3 ++ .../src/main/res/values-night/strings.xml | 3 ++ .../src/main/res/values-nl-rNL/strings.xml | 3 ++ .../src/main/res/values-pt-rBR/strings.xml | 3 ++ .../src/main/res/values-pt-rPT/strings.xml | 3 ++ .../src/main/res/values-si-rLK/strings.xml | 3 ++ .../src/main/res/values-tr-rTR/strings.xml | 3 ++ .../src/main/res/values-zh-rCN/strings.xml | 3 ++ .../src/main/res/values-zh-rTW/strings.xml | 3 ++ androidApp/src/main/res/values/strings.xml | 3 ++ 24 files changed, 151 insertions(+), 13 deletions(-) diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index cccbb10..a97cdb3 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -1,6 +1,7 @@ import java.io.ByteArrayOutputStream val ignoreGitVersion: String by project +val acraVersion = "5.9.7" plugins { id("com.android.application") @@ -187,6 +188,9 @@ dependencies { testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") + implementation("ch.acra:acra-http:$acraVersion") + implementation("ch.acra:acra-toast:$acraVersion") + // Matomo implementation("com.github.matomo-org:matomo-sdk-android:4.1.4") } diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt index 814b335..c1f513d 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt @@ -59,11 +59,15 @@ import com.mikepenz.materialdrawer.util.updateBadge import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import org.acra.ACRA +import org.acra.ktx.sendSilentlyWithAcra +import org.acra.ktx.sendWithAcra import org.kodein.di.DIAware import org.kodein.di.android.closestDI import org.kodein.di.instance import org.matomo.sdk.Tracker import org.matomo.sdk.extra.TrackHelper +import java.security.MessageDigest import java.util.concurrent.TimeUnit @@ -306,6 +310,8 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar handleBottomBarActions() + handleGDPRDialog(appSettingsService.settings.getBoolean("GDPR_shown", false)) + handleRecurringTask() CoroutineScope(Dispatchers.Main).launch { @@ -315,6 +321,26 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar getElementsAccordingToTab() } + + private fun handleGDPRDialog(GDPRShown: Boolean) { + val messageDigest: MessageDigest = MessageDigest.getInstance("SHA-256") + messageDigest.update(appSettingsService.getBaseUrl().toByteArray()) + ACRA.errorReporter.putCustomData("unique_id", String(messageDigest.digest())) + if (!GDPRShown) { + val alertDialog = AlertDialog.Builder(this).create() + alertDialog.setTitle(getString(R.string.gdpr_dialog_title)) + alertDialog.setMessage(getString(R.string.gdpr_dialog_message)) + alertDialog.setButton( + AlertDialog.BUTTON_NEUTRAL, + "OK" + ) { dialog, _ -> + appSettingsService.settings.putBoolean("GDPR_shown", true) + dialog.dismiss() + } + alertDialog.show() + } + } + private fun initDrawer() { DrawerImageLoader.init(object : AbstractDrawerImageLoader() { override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) { @@ -487,6 +513,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar val gdColor = try { Color.parseColor(it.color) } catch (e: IllegalArgumentException) { + e.sendSilentlyWithAcra() resources.getColor(R.color.colorPrimary) } gd.setColor(gdColor) 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 4a4f150..6ccb491 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,12 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch +import org.acra.ReportField +import org.acra.config.httpSender +import org.acra.config.toast +import org.acra.data.StringFormat +import org.acra.ktx.initAcra +import org.acra.sender.HttpSender import org.kodein.di.* import org.matomo.sdk.Matomo import org.matomo.sdk.Tracker @@ -85,6 +91,35 @@ class MyApp : MultiDexApplication(), DIAware { } } + override fun attachBaseContext(base: Context?) { + super.attachBaseContext(base) + + initAcra { + //core configuration: + buildConfigClass = BuildConfig::class.java + reportFormat = StringFormat.JSON + + reportContent = listOf( + ReportField.REPORT_ID, ReportField.INSTALLATION_ID, + ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, + ReportField.BUILD, ReportField.ANDROID_VERSION, ReportField.BRAND, ReportField.PHONE_MODEL, + ReportField.AVAILABLE_MEM_SIZE, ReportField.TOTAL_MEM_SIZE, + ReportField.STACK_TRACE, ReportField.APPLICATION_LOG, ReportField.LOGCAT, + ReportField.INITIAL_CONFIGURATION, ReportField.CRASH_CONFIGURATION, ReportField.IS_SILENT, + ReportField.USER_APP_START_DATE, ReportField.USER_COMMENT, ReportField.USER_CRASH_DATE, ReportField.USER_EMAIL, ReportField.CUSTOM_DATA) + toast { + //required + text = getString(R.string.crash_toast_text) + length = Toast.LENGTH_LONG + } + httpSender { + uri = "https://your.server.com/report" + httpMethod = HttpSender.Method.POST + compress = false + } + } + } + private fun handleNotificationChannels() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt index b90f18a..555c384 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt @@ -44,6 +44,8 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import org.acra.ktx.sendSilentlyWithAcra +import org.acra.ktx.sendWithAcra import org.kodein.di.DI import org.kodein.di.DIAware import org.kodein.di.android.x.closestDI @@ -112,6 +114,7 @@ class ArticleFragment : Fragment(), DIAware { typeface = try { ResourcesCompat.getFont(requireContext(), resId)!! } catch (e: java.lang.Exception) { + e.sendSilentlyWithAcra() // Just to be sure null } @@ -217,6 +220,7 @@ class ArticleFragment : Fragment(), DIAware { ) } catch (e: InflateException) { + e.sendSilentlyWithAcra() AlertDialog.Builder(requireContext()) .setMessage(requireContext().getString(R.string.webview_dialog_issue_message)) .setTitle(requireContext().getString(R.string.webview_dialog_issue_title)) @@ -264,15 +268,18 @@ class ArticleFragment : Fragment(), DIAware { URL(response.data!!.url) url = response.data!!.url } catch (e: MalformedURLException) { - // Mercury returned a relative url. We do nothing. + // Mercury returned a relative url + e.sendSilentlyWithAcra() } } catch (e: Exception) { + e.sendSilentlyWithAcra() } try { contentText = response.data!!.content.orEmpty() htmlToWebview() } catch (e: Exception) { + e.sendSilentlyWithAcra() } try { @@ -288,13 +295,13 @@ class ArticleFragment : Fragment(), DIAware { .apply(RequestOptions.fitCenterTransform()) .into(binding.imageView) } catch (e: Exception) { + e.sendSilentlyWithAcra() } } else { binding.imageView.visibility = View.GONE } } catch (e: Exception) { - if (context != null) { - } + e.sendSilentlyWithAcra() } try { @@ -302,20 +309,17 @@ class ArticleFragment : Fragment(), DIAware { binding.progressBar.visibility = View.GONE } catch (e: Exception) { - if (context != null) { - } + e.sendSilentlyWithAcra() } } else { try { openInBrowserAfterFailing() } catch (e: Exception) { - if (context != null) { - } + e.sendSilentlyWithAcra() } } } catch (e: Exception) { - if (context != null) { - } + e.sendSilentlyWithAcra() } } else { openInBrowserAfterFailing() @@ -359,19 +363,25 @@ class ArticleFragment : Fragment(), DIAware { try { val image = Glide.with(view).asBitmap().apply(glideOptions).load(url).submit().get() return WebResourceResponse("image/jpg", "UTF-8", getBitmapInputStream(image, Bitmap.CompressFormat.JPEG)) - }catch ( e : ExecutionException) {} + } catch ( e : ExecutionException) { + e.sendSilentlyWithAcra() + } } else if (url.lowercase(Locale.US).contains(".png")) { try { val image = Glide.with(view).asBitmap().apply(glideOptions).load(url).submit().get() return WebResourceResponse("image/jpg", "UTF-8", getBitmapInputStream(image, Bitmap.CompressFormat.PNG)) - }catch ( e : ExecutionException) {} + } catch ( e : ExecutionException) { + e.sendSilentlyWithAcra() + } } else if (url.lowercase(Locale.US).contains(".webp")) { try { val image = Glide.with(view).asBitmap().apply(glideOptions).load(url).submit().get() return WebResourceResponse("image/jpg", "UTF-8", getBitmapInputStream(image, Bitmap.CompressFormat.WEBP)) - }catch ( e : ExecutionException) {} + } catch ( e : ExecutionException) { + e.sendSilentlyWithAcra() + } } return super.shouldInterceptRequest(view, url) @@ -395,6 +405,7 @@ class ArticleFragment : Fragment(), DIAware { val itemUrl = URL(url) baseUrl = itemUrl.protocol + "://" + itemUrl.host } catch (e: MalformedURLException) { + e.sendSilentlyWithAcra() } val fontName = when (font) { diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/model/AndroidIModelUtils.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/model/AndroidIModelUtils.kt index 4822eca..618dda2 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/model/AndroidIModelUtils.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/model/AndroidIModelUtils.kt @@ -7,6 +7,7 @@ import bou.amine.apps.readerforselfossv2.utils.getImages import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.request.RequestOptions +import org.acra.ktx.sendSilentlyWithAcra fun SelfossModel.Item.preloadImages(context: Context) : Boolean { val imageUrls = this.getImages() @@ -23,6 +24,7 @@ fun SelfossModel.Item.preloadImages(context: Context) : Boolean { } } } catch (e : Error) { + e.sendSilentlyWithAcra() return false } @@ -35,7 +37,7 @@ fun String.toTextDrawableString(): String { try { textDrawable.append(s[0]) } catch (e: StringIndexOutOfBoundsException) { - // We do nothing + e.sendSilentlyWithAcra() } } return textDrawable.toString() 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 8f3f14b..472ebe1 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 @@ -17,6 +17,8 @@ import androidx.preference.PreferenceFragmentCompat import bou.amine.apps.readerforselfossv2.android.R import bou.amine.apps.readerforselfossv2.android.databinding.ActivitySettingsBinding import bou.amine.apps.readerforselfossv2.service.AppSettingsService +import org.acra.ktx.sendSilentlyWithAcra +import org.acra.ktx.sendWithAcra import org.kodein.di.DIAware import org.kodein.di.android.closestDI import org.kodein.di.instance @@ -117,6 +119,7 @@ class SettingsActivity : AppCompatActivity(), val input: Int = (dest.toString() + source.toString()).toInt() if (input in 1..200) return@InputFilter null } catch (nfe: NumberFormatException) { + nfe.sendSilentlyWithAcra() Toast.makeText(activity, R.string.items_number_should_be_number, Toast.LENGTH_LONG).show() } "" @@ -140,6 +143,7 @@ class SettingsActivity : AppCompatActivity(), try { editText.textSize = editable.toString().toInt().toFloat() } catch (e: NumberFormatException) { + e.sendSilentlyWithAcra() } } } } @@ -149,6 +153,7 @@ class SettingsActivity : AppCompatActivity(), val input = (dest.toString() + source.toString()).toInt() if (input > 0) return@InputFilter null } catch (nfe: NumberFormatException) { + nfe.sendSilentlyWithAcra() } "" } diff --git a/androidApp/src/main/res/values-ca-rES/strings.xml b/androidApp/src/main/res/values-ca-rES/strings.xml index 350228f..b09caad 100644 --- a/androidApp/src/main/res/values-ca-rES/strings.xml +++ b/androidApp/src/main/res/values-ca-rES/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-de-rDE/strings.xml b/androidApp/src/main/res/values-de-rDE/strings.xml index b4c18d4..1f46319 100644 --- a/androidApp/src/main/res/values-de-rDE/strings.xml +++ b/androidApp/src/main/res/values-de-rDE/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-es-rES/strings.xml b/androidApp/src/main/res/values-es-rES/strings.xml index cead2ba..c8f6c2d 100644 --- a/androidApp/src/main/res/values-es-rES/strings.xml +++ b/androidApp/src/main/res/values-es-rES/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-fa-rIR/strings.xml b/androidApp/src/main/res/values-fa-rIR/strings.xml index 1b7bd0b..5db2616 100644 --- a/androidApp/src/main/res/values-fa-rIR/strings.xml +++ b/androidApp/src/main/res/values-fa-rIR/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-fr-rFR/strings.xml b/androidApp/src/main/res/values-fr-rFR/strings.xml index cabbdea..ebf715c 100644 --- a/androidApp/src/main/res/values-fr-rFR/strings.xml +++ b/androidApp/src/main/res/values-fr-rFR/strings.xml @@ -134,4 +134,7 @@ Thème clair Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-gl-rES/strings.xml b/androidApp/src/main/res/values-gl-rES/strings.xml index f4de4ce..af411c2 100644 --- a/androidApp/src/main/res/values-gl-rES/strings.xml +++ b/androidApp/src/main/res/values-gl-rES/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-in-rID/strings.xml b/androidApp/src/main/res/values-in-rID/strings.xml index 2037014..2901507 100644 --- a/androidApp/src/main/res/values-in-rID/strings.xml +++ b/androidApp/src/main/res/values-in-rID/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-it-rIT/strings.xml b/androidApp/src/main/res/values-it-rIT/strings.xml index 7fcd6cf..17166c9 100644 --- a/androidApp/src/main/res/values-it-rIT/strings.xml +++ b/androidApp/src/main/res/values-it-rIT/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-ko-rKR/strings.xml b/androidApp/src/main/res/values-ko-rKR/strings.xml index d31e480..79bc52a 100644 --- a/androidApp/src/main/res/values-ko-rKR/strings.xml +++ b/androidApp/src/main/res/values-ko-rKR/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-night/strings.xml b/androidApp/src/main/res/values-night/strings.xml index 0f00e58..6b3a563 100644 --- a/androidApp/src/main/res/values-night/strings.xml +++ b/androidApp/src/main/res/values-night/strings.xml @@ -1,4 +1,7 @@ Enable analytics + 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. \ 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 350037a..52fc7d4 100644 --- a/androidApp/src/main/res/values-nl-rNL/strings.xml +++ b/androidApp/src/main/res/values-nl-rNL/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-pt-rBR/strings.xml b/androidApp/src/main/res/values-pt-rBR/strings.xml index 142f733..3e61947 100644 --- a/androidApp/src/main/res/values-pt-rBR/strings.xml +++ b/androidApp/src/main/res/values-pt-rBR/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-pt-rPT/strings.xml b/androidApp/src/main/res/values-pt-rPT/strings.xml index 5554e77..c1e9315 100644 --- a/androidApp/src/main/res/values-pt-rPT/strings.xml +++ b/androidApp/src/main/res/values-pt-rPT/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-si-rLK/strings.xml b/androidApp/src/main/res/values-si-rLK/strings.xml index 699bed0..06b89d9 100644 --- a/androidApp/src/main/res/values-si-rLK/strings.xml +++ b/androidApp/src/main/res/values-si-rLK/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-tr-rTR/strings.xml b/androidApp/src/main/res/values-tr-rTR/strings.xml index b7e5deb..312e4ec 100644 --- a/androidApp/src/main/res/values-tr-rTR/strings.xml +++ b/androidApp/src/main/res/values-tr-rTR/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-zh-rCN/strings.xml b/androidApp/src/main/res/values-zh-rCN/strings.xml index 62845fb..4e839bb 100644 --- a/androidApp/src/main/res/values-zh-rCN/strings.xml +++ b/androidApp/src/main/res/values-zh-rCN/strings.xml @@ -134,4 +134,7 @@ 浅色模式 Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values-zh-rTW/strings.xml b/androidApp/src/main/res/values-zh-rTW/strings.xml index 322e112..b07d077 100644 --- a/androidApp/src/main/res/values-zh-rTW/strings.xml +++ b/androidApp/src/main/res/values-zh-rTW/strings.xml @@ -134,4 +134,7 @@ Light mode Error loading sources… Enable analytics + 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. diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index e0f0311..9cf2606 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -137,4 +137,7 @@ Follow the system setting Light mode Enable analytics + 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. -- 2.34.1 From e68da7764f14c112334d06366d36028a2965d0d7 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Wed, 30 Nov 2022 21:06:17 +0100 Subject: [PATCH 2/2] Settings for acra and analytics. Closes #98. --- .../apps/readerforselfossv2/android/MyApp.kt | 47 ++++++++++--------- .../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 | 3 +- .../src/main/res/values-de-rDE/strings.xml | 3 +- .../src/main/res/values-es-rES/strings.xml | 3 +- .../src/main/res/values-fa-rIR/strings.xml | 3 +- .../src/main/res/values-fr-rFR/strings.xml | 3 +- .../src/main/res/values-gl-rES/strings.xml | 3 +- .../src/main/res/values-in-rID/strings.xml | 3 +- .../src/main/res/values-it-rIT/strings.xml | 3 +- .../src/main/res/values-ko-rKR/strings.xml | 3 +- .../src/main/res/values-night/strings.xml | 3 +- .../src/main/res/values-nl-rNL/strings.xml | 3 +- .../src/main/res/values-pt-rBR/strings.xml | 3 +- .../src/main/res/values-pt-rPT/strings.xml | 3 +- .../src/main/res/values-si-rLK/strings.xml | 3 +- .../src/main/res/values-tr-rTR/strings.xml | 3 +- .../src/main/res/values-zh-rCN/strings.xml | 3 +- .../src/main/res/values-zh-rTW/strings.xml | 3 +- androidApp/src/main/res/values/strings.xml | 3 +- .../src/main/res/xml/pref_experimental.xml | 6 --- androidApp/src/main/res/xml/pref_main.xml | 23 ++++++++- 24 files changed, 98 insertions(+), 49 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..1a5c52e 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,7 @@ class MyApp : MultiDexApplication(), DIAware { super.attachBaseContext(base) initAcra { - //core configuration: - buildConfigClass = BuildConfig::class.java reportFormat = StringFormat.JSON - reportContent = listOf( ReportField.REPORT_ID, ReportField.INSTALLATION_ID, ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, @@ -110,12 +110,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..dc17955 100644 --- a/androidApp/src/main/res/values-ca-rES/strings.xml +++ b/androidApp/src/main/res/values-ca-rES/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..c9d6640 100644 --- a/androidApp/src/main/res/values-de-rDE/strings.xml +++ b/androidApp/src/main/res/values-de-rDE/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..fd68002 100644 --- a/androidApp/src/main/res/values-es-rES/strings.xml +++ b/androidApp/src/main/res/values-es-rES/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..568519a 100644 --- a/androidApp/src/main/res/values-fa-rIR/strings.xml +++ b/androidApp/src/main/res/values-fa-rIR/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..777ba1d 100644 --- a/androidApp/src/main/res/values-fr-rFR/strings.xml +++ b/androidApp/src/main/res/values-fr-rFR/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..300cb75 100644 --- a/androidApp/src/main/res/values-gl-rES/strings.xml +++ b/androidApp/src/main/res/values-gl-rES/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..5496c77 100644 --- a/androidApp/src/main/res/values-in-rID/strings.xml +++ b/androidApp/src/main/res/values-in-rID/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..dca5595 100644 --- a/androidApp/src/main/res/values-it-rIT/strings.xml +++ b/androidApp/src/main/res/values-it-rIT/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..88f5aa8 100644 --- a/androidApp/src/main/res/values-ko-rKR/strings.xml +++ b/androidApp/src/main/res/values-ko-rKR/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..a0a75f3 100644 --- a/androidApp/src/main/res/values-night/strings.xml +++ b/androidApp/src/main/res/values-night/strings.xml @@ -2,6 +2,7 @@ Enable analytics 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..04e928d 100644 --- a/androidApp/src/main/res/values-nl-rNL/strings.xml +++ b/androidApp/src/main/res/values-nl-rNL/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..df02f11 100644 --- a/androidApp/src/main/res/values-pt-rBR/strings.xml +++ b/androidApp/src/main/res/values-pt-rBR/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..f566de5 100644 --- a/androidApp/src/main/res/values-pt-rPT/strings.xml +++ b/androidApp/src/main/res/values-pt-rPT/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..48bc1a1 100644 --- a/androidApp/src/main/res/values-si-rLK/strings.xml +++ b/androidApp/src/main/res/values-si-rLK/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..3ed200d 100644 --- a/androidApp/src/main/res/values-tr-rTR/strings.xml +++ b/androidApp/src/main/res/values-tr-rTR/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..6ddf691 100644 --- a/androidApp/src/main/res/values-zh-rCN/strings.xml +++ b/androidApp/src/main/res/values-zh-rCN/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..ef9357b 100644 --- a/androidApp/src/main/res/values-zh-rTW/strings.xml +++ b/androidApp/src/main/res/values-zh-rTW/strings.xml @@ -135,6 +135,7 @@ Error loading sources… Enable analytics 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..fcb6613 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -138,6 +138,7 @@ Light mode Enable analytics 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 -- 2.34.1