From 63da3b9fe737152e5f19f7ad5e7c4d3efc18a588 Mon Sep 17 00:00:00 2001 From: Amine Date: Mon, 30 Dec 2024 15:07:18 +0100 Subject: [PATCH] chore: filter some bugs. --- androidApp/build.gradle.kts | 2 +- .../android/LoginActivityTest.kt | 2 +- .../android/adapters/ItemCardAdapter.kt | 2 +- .../android/adapters/ItemListAdapter.kt | 4 +-- .../android/fragments/ArticleFragment.kt | 2 +- .../android/fragments/FilterSheetFragment.kt | 4 +-- .../android/model/AndroidIModelUtils.kt | 4 +-- .../android/settings/SettingsActivity.kt | 4 +-- .../android/{ => utils/acra}/ACRAUtils.kt | 4 +-- .../utils/acra/AcraReportingAdministrator.kt | 29 +++++++++++++++++++ 10 files changed, 43 insertions(+), 14 deletions(-) rename androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/{ => utils/acra}/ACRAUtils.kt (77%) create mode 100644 androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/acra/AcraReportingAdministrator.kt diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index dc12389..49bc9b3 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -203,7 +203,7 @@ dependencies { implementation("ch.acra:acra-http:$acraVersion") implementation("ch.acra:acra-toast:$acraVersion") - + implementation("com.google.auto.service:auto-service:1.1.1") } tasks.withType { diff --git a/androidApp/src/androidTest/kotlin/bou/amine/apps/readerforselfossv2/android/LoginActivityTest.kt b/androidApp/src/androidTest/kotlin/bou/amine/apps/readerforselfossv2/android/LoginActivityTest.kt index 06c554d..43d8343 100644 --- a/androidApp/src/androidTest/kotlin/bou/amine/apps/readerforselfossv2/android/LoginActivityTest.kt +++ b/androidApp/src/androidTest/kotlin/bou/amine/apps/readerforselfossv2/android/LoginActivityTest.kt @@ -62,7 +62,7 @@ class LoginActivityTest { @Test fun urlError() { - performLogin("172.17.0.1:8888") + performLogin("10.0.2.2:8888") onView(withId(R.id.urlView)).perform(click()) onView(withId(R.id.urlView)).check(matches(withError(R.string.wrong_infos))) } diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt index ec54db8..3f2de89 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemCardAdapter.kt @@ -8,8 +8,8 @@ import android.widget.ImageView.ScaleType import androidx.recyclerview.widget.RecyclerView import bou.amine.apps.readerforselfossv2.android.R import bou.amine.apps.readerforselfossv2.android.databinding.CardItemBinding -import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName import bou.amine.apps.readerforselfossv2.android.utils.LinkOnTouchListener +import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName import bou.amine.apps.readerforselfossv2.android.utils.glide.bitmapCenterCrop import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable import bou.amine.apps.readerforselfossv2.android.utils.openItemUrlInBrowserAsNewTask diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt index ac43bd6..f6a48b5 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/ItemListAdapter.kt @@ -6,8 +6,8 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import bou.amine.apps.readerforselfossv2.android.R import bou.amine.apps.readerforselfossv2.android.databinding.ListItemBinding -import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName import bou.amine.apps.readerforselfossv2.android.utils.LinkOnTouchListener +import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable import bou.amine.apps.readerforselfossv2.model.SelfossModel import bou.amine.apps.readerforselfossv2.repository.Repository @@ -73,4 +73,4 @@ class ItemListAdapter( } inner class ViewHolder(val binding: ListItemBinding) : RecyclerView.ViewHolder(binding.root) -} +} \ No newline at end of file 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 749ca41..a624f97 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 @@ -29,7 +29,7 @@ import bou.amine.apps.readerforselfossv2.android.databinding.FragmentArticleBind import bou.amine.apps.readerforselfossv2.android.model.ParecelableItem import bou.amine.apps.readerforselfossv2.android.model.toModel import bou.amine.apps.readerforselfossv2.android.model.toParcelable -import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName +import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName import bou.amine.apps.readerforselfossv2.android.utils.glide.getBitmapInputStream import bou.amine.apps.readerforselfossv2.android.utils.isUrlValid import bou.amine.apps.readerforselfossv2.android.utils.openItemUrlInBrowserAsNewTask diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt index cca1876..34eec9a 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/FilterSheetFragment.kt @@ -15,7 +15,7 @@ import android.view.ViewGroup import bou.amine.apps.readerforselfossv2.android.HomeActivity import bou.amine.apps.readerforselfossv2.android.R import bou.amine.apps.readerforselfossv2.android.databinding.FilterFragmentBinding -import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName +import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName import bou.amine.apps.readerforselfossv2.repository.Repository import bou.amine.apps.readerforselfossv2.utils.getColorHexCode import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded @@ -192,4 +192,4 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware { companion object { const val TAG = "FilterModalBottomSheet" } -} +} \ No newline at end of file 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 7db8688..2898e9f 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 @@ -2,7 +2,7 @@ package bou.amine.apps.readerforselfossv2.android.model import android.content.Context import android.webkit.URLUtil -import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName +import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName import bou.amine.apps.readerforselfossv2.model.SelfossModel import bou.amine.apps.readerforselfossv2.utils.getImages import com.bumptech.glide.Glide @@ -40,4 +40,4 @@ fun String.toTextDrawableString(): String { } } return textDrawable.toString() -} +} \ No newline at end of file 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 9c6caa2..0ea06be 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 @@ -14,7 +14,7 @@ import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import bou.amine.apps.readerforselfossv2.android.R import bou.amine.apps.readerforselfossv2.android.databinding.ActivitySettingsBinding -import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName +import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName import bou.amine.apps.readerforselfossv2.android.utils.openUrlInBrowser import bou.amine.apps.readerforselfossv2.service.AppSettingsService import com.mikepenz.aboutlibraries.LibsBuilder @@ -274,4 +274,4 @@ class SettingsActivity : setPreferencesFromResource(R.xml.pref_experimental, rootKey) } } -} +} \ No newline at end of file diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/ACRAUtils.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/acra/ACRAUtils.kt similarity index 77% rename from androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/ACRAUtils.kt rename to androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/acra/ACRAUtils.kt index 14ebf0e..b6e6199 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/ACRAUtils.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/acra/ACRAUtils.kt @@ -1,4 +1,4 @@ -package bou.amine.apps.readerforselfossv2.android +package bou.amine.apps.readerforselfossv2.android.utils.acra import org.acra.ACRA import org.acra.ktx.sendSilentlyWithAcra @@ -6,4 +6,4 @@ import org.acra.ktx.sendSilentlyWithAcra fun Throwable.sendSilentlyWithAcraWithName(name: String) { ACRA.errorReporter.putCustomData("error_source", name) this.sendSilentlyWithAcra() -} +} \ No newline at end of file diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/acra/AcraReportingAdministrator.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/acra/AcraReportingAdministrator.kt new file mode 100644 index 0000000..cfd5079 --- /dev/null +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/acra/AcraReportingAdministrator.kt @@ -0,0 +1,29 @@ +package bou.amine.apps.readerforselfossv2.android.utils.acra + +import android.content.Context +import android.os.DeadSystemException +import com.google.auto.service.AutoService +import org.acra.builder.ReportBuilder +import org.acra.config.CoreConfiguration +import org.acra.config.ReportingAdministrator +import org.acra.data.CrashReportData + + +@AutoService(ReportingAdministrator::class) +class AcraReportingAdministrator : ReportingAdministrator { + override fun shouldStartCollecting( + context: Context, + config: CoreConfiguration, + reportBuilder: ReportBuilder + ): Boolean { + return reportBuilder.exception !is DeadSystemException + } + + override fun shouldSendReport( + context: Context, + config: CoreConfiguration, + crashReportData: CrashReportData + ): Boolean { + return crashReportData.get("BRAND") != "redroid" + } +} \ No newline at end of file