From 9d77052d9c36d18ef421074589b40b0fa37e51af Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 22 Apr 2022 18:34:53 +0200 Subject: [PATCH] Enable verbose logging in dev flavor by default (#6979) --- app/src/main/java/eu/kanade/tachiyomi/App.kt | 3 ++- .../kanade/tachiyomi/data/preference/PreferencesHelper.kt | 4 +++- .../tachiyomi/ui/setting/SettingsAdvancedController.kt | 5 +++-- .../java/eu/kanade/tachiyomi/util/system/BuildConfig.kt | 6 ++++++ 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/eu/kanade/tachiyomi/util/system/BuildConfig.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index b37721ce6..74ced7ff0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -37,6 +37,7 @@ import eu.kanade.tachiyomi.util.preference.asImmediateFlow import eu.kanade.tachiyomi.util.system.AuthenticatorUtil 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.logcat import eu.kanade.tachiyomi.util.system.notification import kotlinx.coroutines.flow.launchIn @@ -176,7 +177,7 @@ open class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory { } protected open fun setupAcra() { - if (BuildConfig.FLAVOR != "dev") { + if (isDevFlavor.not()) { initAcra { buildConfigClass = BuildConfig::class.java excludeMatchingSharedPreferencesKeys = listOf(".*username.*", ".*password.*", ".*token.*") diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index b7d061c7e..8567a0383 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -7,6 +7,7 @@ import androidx.core.content.edit import androidx.core.net.toUri import androidx.preference.PreferenceManager import com.fredporciuncula.flow.preferences.FlowSharedPreferences +import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.track.TrackService @@ -25,6 +26,7 @@ import java.text.SimpleDateFormat import java.util.Locale import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values +import eu.kanade.tachiyomi.util.system.isDevFlavor class PreferencesHelper(val context: Context) { @@ -319,7 +321,7 @@ class PreferencesHelper(val context: Context) { if (DeviceUtil.isMiui) Values.ExtensionInstaller.LEGACY else Values.ExtensionInstaller.PACKAGEINSTALLER, ) - fun verboseLogging() = prefs.getBoolean(Keys.verboseLogging, false) + fun verboseLogging() = prefs.getBoolean(Keys.verboseLogging, isDevFlavor) fun autoClearChapterCache() = prefs.getBoolean(Keys.autoClearChapterCache, false) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index dd873bcfa..b8097f5d6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -44,6 +44,7 @@ import eu.kanade.tachiyomi.util.system.toast import rikka.sui.Sui import uy.kohesive.injekt.injectLazy import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys +import eu.kanade.tachiyomi.util.system.isDevFlavor class SettingsAdvancedController : SettingsController() { @@ -55,7 +56,7 @@ class SettingsAdvancedController : SettingsController() { override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply { titleRes = R.string.pref_category_advanced - if (BuildConfig.FLAVOR != "dev") { + if (isDevFlavor.not()) { switchPreference { key = "acra.enable" titleRes = R.string.pref_enable_acra @@ -78,7 +79,7 @@ class SettingsAdvancedController : SettingsController() { key = Keys.verboseLogging titleRes = R.string.pref_verbose_logging summaryRes = R.string.pref_verbose_logging_summary - defaultValue = false + defaultValue = isDevFlavor onChange { activity?.toast(R.string.requires_app_restart) 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 new file mode 100644 index 000000000..cd74287fa --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/BuildConfig.kt @@ -0,0 +1,6 @@ +package eu.kanade.tachiyomi.util.system + +import eu.kanade.tachiyomi.BuildConfig + +val isDevFlavor: Boolean + get() = BuildConfig.FLAVOR == "dev"