From 7e61900cf5cbe3f074d4408c5c2d2f4adc7ecffd Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Sat, 9 Oct 2021 21:28:43 +0700 Subject: [PATCH] Add new build type for weekly preview (#6067) This adds new build type for minified non-debuggable preview builds. "debugFull" is removed and "debug" will be unminified. **It means preview build action needs to be updated to build "standardPreview"** --- app/build.gradle.kts | 21 ++++++------ .../data/updater/AppUpdateChecker.kt | 4 +-- .../tachiyomi/ui/more/AboutController.kt | 34 ++++++++++++------- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d7ee9458f..525e3af84 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -36,6 +36,7 @@ android { buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"") buildConfigField("String", "BUILD_TIME", "\"${getBuildTime()}\"") buildConfigField("boolean", "INCLUDE_UPDATER", "false") + buildConfigField("boolean", "PREVIEW", "false") // Please disable ACRA or use your own instance in forked versions of the project buildConfigField("String", "ACRA_URI", "\"https://tachiyomi.kanade.eu/crash_report\"") @@ -58,25 +59,25 @@ android { named("debug") { versionNameSuffix = "-${getCommitCount()}" applicationIdSuffix = ".debug" - - isShrinkResources = true - isMinifyEnabled = true - proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro") - } - create("debugFull") { // Debug without R8 - initWith(getByName("debug")) - isShrinkResources = false - isMinifyEnabled = false } named("release") { isShrinkResources = true isMinifyEnabled = true proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro") } + create("preview") { + initWith(getByName("release")) + buildConfigField("boolean", "PREVIEW", "true") + + val debugType = getByName("debug") + signingConfig = debugType.signingConfig + versionNameSuffix = debugType.versionNameSuffix + applicationIdSuffix = debugType.applicationIdSuffix + } } sourceSets { - getByName("debugFull").res.srcDirs("src/debug/res") + getByName("preview").res.srcDirs("src/debug/res") } flavorDimensions.add("default") diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt index f7198ae18..7aac67ab6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/AppUpdateChecker.kt @@ -16,7 +16,7 @@ class AppUpdateChecker { private val preferences: PreferencesHelper by injectLazy() private val repo: String by lazy { - if (BuildConfig.DEBUG) { + if (BuildConfig.PREVIEW) { "tachiyomiorg/tachiyomi-preview" } else { "tachiyomiorg/tachiyomi" @@ -46,7 +46,7 @@ class AppUpdateChecker { // Removes prefixes like "r" or "v" val newVersion = versionTag.replace("[^\\d.]".toRegex(), "") - return if (BuildConfig.DEBUG) { + return if (BuildConfig.PREVIEW) { // Preview builds: based on releases in "tachiyomiorg/tachiyomi-preview" repo // tagged as something like "r1234" newVersion.toInt() > BuildConfig.COMMIT_COUNT.toInt() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt index 79aa60bb9..eac9be7a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt @@ -40,10 +40,16 @@ class AboutController : SettingsController(), NoAppBarElevationController { preference { key = "pref_about_version" titleRes = R.string.version - summary = if (BuildConfig.DEBUG) { - "Preview r${BuildConfig.COMMIT_COUNT} (${BuildConfig.COMMIT_SHA}, ${getFormattedBuildTime()})" - } else { - "Stable ${BuildConfig.VERSION_NAME} (${getFormattedBuildTime()})" + summary = when { + BuildConfig.DEBUG -> { + "Debug ${BuildConfig.COMMIT_SHA} (${getFormattedBuildTime()})" + } + BuildConfig.PREVIEW -> { + "Preview r${BuildConfig.COMMIT_COUNT} (${BuildConfig.COMMIT_SHA}, ${getFormattedBuildTime()})" + } + else -> { + "Stable ${BuildConfig.VERSION_NAME} (${getFormattedBuildTime()})" + } } onClick { @@ -61,17 +67,19 @@ class AboutController : SettingsController(), NoAppBarElevationController { onClick { checkVersion() } } } - preference { - key = "pref_about_whats_new" - titleRes = R.string.whats_new + if (!BuildConfig.DEBUG) { + preference { + key = "pref_about_whats_new" + titleRes = R.string.whats_new - onClick { - val url = if (BuildConfig.DEBUG) { - "https://github.com/tachiyomiorg/tachiyomi-preview/releases/tag/r${BuildConfig.COMMIT_COUNT}" - } else { - "https://github.com/tachiyomiorg/tachiyomi/releases/tag/v${BuildConfig.VERSION_NAME}" + onClick { + val url = if (BuildConfig.PREVIEW) { + "https://github.com/tachiyomiorg/tachiyomi-preview/releases/tag/r${BuildConfig.COMMIT_COUNT}" + } else { + "https://github.com/tachiyomiorg/tachiyomi/releases/tag/v${BuildConfig.VERSION_NAME}" + } + openInBrowser(url) } - openInBrowser(url) } } preference {