Browse Source

Only enable ACRA crash logging in preview and stable release builds

arkon 2 years ago
parent
commit
6e04822f5e

+ 3 - 1
app/src/main/java/eu/kanade/domain/base/BasePreferences.kt

@@ -5,6 +5,8 @@ import eu.kanade.tachiyomi.core.preference.PreferenceStore
 import eu.kanade.tachiyomi.core.preference.getEnum
 import eu.kanade.tachiyomi.data.preference.PreferenceValues
 import eu.kanade.tachiyomi.util.system.DeviceUtil
+import eu.kanade.tachiyomi.util.system.isPreviewBuildType
+import eu.kanade.tachiyomi.util.system.isReleaseBuildType
 
 class BasePreferences(
     val context: Context,
@@ -24,5 +26,5 @@ class BasePreferences(
         if (DeviceUtil.isMiui) PreferenceValues.ExtensionInstaller.LEGACY else PreferenceValues.ExtensionInstaller.PACKAGEINSTALLER,
     )
 
-    fun acraEnabled() = preferenceStore.getBoolean("acra.enable", true)
+    fun acraEnabled() = preferenceStore.getBoolean("acra.enable", isPreviewBuildType || isReleaseBuildType)
 }

+ 3 - 2
app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt

@@ -51,8 +51,9 @@ import eu.kanade.tachiyomi.util.CrashLogUtil
 import eu.kanade.tachiyomi.util.lang.launchNonCancellable
 import eu.kanade.tachiyomi.util.lang.withUIContext
 import eu.kanade.tachiyomi.util.system.DeviceUtil
-import eu.kanade.tachiyomi.util.system.isDevFlavor
 import eu.kanade.tachiyomi.util.system.isPackageInstalled
+import eu.kanade.tachiyomi.util.system.isPreviewBuildType
+import eu.kanade.tachiyomi.util.system.isReleaseBuildType
 import eu.kanade.tachiyomi.util.system.logcat
 import eu.kanade.tachiyomi.util.system.powerManager
 import eu.kanade.tachiyomi.util.system.setDefaultSettings
@@ -83,7 +84,7 @@ class SettingsAdvancedScreen : SearchableSettings {
                 pref = basePreferences.acraEnabled(),
                 title = stringResource(R.string.pref_enable_acra),
                 subtitle = stringResource(R.string.pref_acra_summary),
-                enabled = !isDevFlavor,
+                enabled = isPreviewBuildType || isReleaseBuildType,
             ),
             Preference.PreferenceItem.TextPreference(
                 title = stringResource(R.string.pref_dump_crash_logs),

+ 2 - 2
app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt

@@ -17,7 +17,7 @@ import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
 import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
 import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
 import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
-import eu.kanade.tachiyomi.util.system.isReleaseFlavor
+import eu.kanade.tachiyomi.util.system.isReleaseBuildType
 import uy.kohesive.injekt.Injekt
 import uy.kohesive.injekt.api.get
 
@@ -294,7 +294,7 @@ class SettingsReaderScreen : SearchableSettings {
                     pref = readerPreferences.longStripSplitWebtoon(),
                     title = stringResource(R.string.pref_long_strip_split),
                     subtitle = stringResource(R.string.split_tall_images_summary),
-                    enabled = !isReleaseFlavor, // TODO: Show in release build when the feature is stable
+                    enabled = !isReleaseBuildType, // TODO: Show in release build when the feature is stable
                 ),
             ),
         )

+ 3 - 2
app/src/main/java/eu/kanade/tachiyomi/App.kt

@@ -43,7 +43,8 @@ import eu.kanade.tachiyomi.network.NetworkPreferences
 import eu.kanade.tachiyomi.ui.base.delegate.SecureActivityDelegate
 import eu.kanade.tachiyomi.util.system.WebViewUtil
 import eu.kanade.tachiyomi.util.system.animatorDurationScale
-import eu.kanade.tachiyomi.util.system.isDevFlavor
+import eu.kanade.tachiyomi.util.system.isPreviewBuildType
+import eu.kanade.tachiyomi.util.system.isReleaseBuildType
 import eu.kanade.tachiyomi.util.system.logcat
 import eu.kanade.tachiyomi.util.system.notification
 import kotlinx.coroutines.flow.distinctUntilChanged
@@ -199,7 +200,7 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
     }
 
     private fun setupAcra() {
-        if (isDevFlavor.not()) {
+        if (isPreviewBuildType || isReleaseBuildType) {
             initAcra {
                 buildConfigClass = BuildConfig::class.java
                 excludeMatchingSharedPreferencesKeys = listOf(".*username.*", ".*password.*", ".*token.*")

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt

@@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.ui.reader.setting
 import eu.kanade.tachiyomi.core.preference.PreferenceStore
 import eu.kanade.tachiyomi.core.preference.getEnum
 import eu.kanade.tachiyomi.data.preference.PreferenceValues
-import eu.kanade.tachiyomi.util.system.isReleaseFlavor
+import eu.kanade.tachiyomi.util.system.isReleaseBuildType
 
 class ReaderPreferences(
     private val preferenceStore: PreferenceStore,
@@ -32,7 +32,7 @@ class ReaderPreferences(
     fun defaultOrientationType() = preferenceStore.getInt("pref_default_orientation_type_key", OrientationType.FREE.flagValue)
 
     // TODO: Enable in release build when the feature is stable
-    fun longStripSplitWebtoon() = preferenceStore.getBoolean("pref_long_strip_split_webtoon", !isReleaseFlavor)
+    fun longStripSplitWebtoon() = preferenceStore.getBoolean("pref_long_strip_split_webtoon", !isReleaseBuildType)
 
     fun imageScaleType() = preferenceStore.getInt("pref_image_scale_type_key", 1)
 

+ 4 - 1
app/src/main/java/eu/kanade/tachiyomi/util/system/BuildConfig.kt

@@ -5,5 +5,8 @@ import eu.kanade.tachiyomi.BuildConfig
 val isDevFlavor: Boolean
     get() = BuildConfig.FLAVOR == "dev"
 
-val isReleaseFlavor: Boolean
+val isPreviewBuildType: Boolean
+    get() = BuildConfig.BUILD_TYPE == "preview"
+
+val isReleaseBuildType: Boolean
     get() = BuildConfig.BUILD_TYPE == "release"