From 6e04822f5e2f0985a98a86c814099b0cf85cb7f8 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 22 Oct 2022 15:47:09 -0400 Subject: [PATCH] Only enable ACRA crash logging in preview and stable release builds --- app/src/main/java/eu/kanade/domain/base/BasePreferences.kt | 4 +++- .../more/settings/screen/SettingsAdvancedScreen.kt | 5 +++-- .../more/settings/screen/SettingsReaderScreen.kt | 4 ++-- app/src/main/java/eu/kanade/tachiyomi/App.kt | 5 +++-- .../kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt | 4 ++-- .../main/java/eu/kanade/tachiyomi/util/system/BuildConfig.kt | 5 ++++- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt b/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt index 3219619859..892bb24b3b 100644 --- a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt +++ b/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) } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt index bc91b9da90..79e06afd84 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt +++ b/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), diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt index 1a4d4fbd57..fd835cdb51 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsReaderScreen.kt +++ b/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 ), ), ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index da938cd13e..48370b20ef 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/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.*") diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt index 434f68a25d..c9b577c177 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderPreferences.kt +++ b/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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/BuildConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/BuildConfig.kt index ba720b32a4..933f44d904 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/BuildConfig.kt +++ b/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"