Updater: similar to Mihon
- Preview version now name Beta, use different package & repo - Drop syDebugVersion, use commitCount - Fix Firebase analytics for both Release & Preview build - Create separate variant for Preview build instead of using syDebugVersion - Preview version showing changelog_debug.xml - Release version showing changelog_release.xml
This commit is contained in:
parent
4161b6cac9
commit
1eefa745ea
13 changed files with 169 additions and 86 deletions
7
.github/workflows/build_develop.yml
vendored
7
.github/workflows/build_develop.yml
vendored
|
|
@ -68,13 +68,6 @@ jobs:
|
||||||
changelog="<?xml version=\"1.0\" encoding=\"utf-8\"?><changelog bulletedList=\"true\"><changelogversion versionName=\"${{ github.run_number }}\" changeDate=\"\">$changelog</changelogversion></changelog>"
|
changelog="<?xml version=\"1.0\" encoding=\"utf-8\"?><changelog bulletedList=\"true\"><changelogversion versionName=\"${{ github.run_number }}\" changeDate=\"\">$changelog</changelogversion></changelog>"
|
||||||
echo "CHANGELOG=$changelog" >> $GITHUB_ENV
|
echo "CHANGELOG=$changelog" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Write Version.kt
|
|
||||||
uses: DamianReeves/write-file-action@v1.3
|
|
||||||
with:
|
|
||||||
path: app/src/main/java/exh/Version.kt
|
|
||||||
contents: 'package exh const val syDebugVersion: String = "${{ github.run_number }}"'
|
|
||||||
write-mode: overwrite
|
|
||||||
|
|
||||||
- name: Write changelog_debug.xml
|
- name: Write changelog_debug.xml
|
||||||
uses: DamianReeves/write-file-action@v1.3
|
uses: DamianReeves/write-file-action@v1.3
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
14
.github/workflows/build_preview.yml
vendored
14
.github/workflows/build_preview.yml
vendored
|
|
@ -71,20 +71,6 @@ jobs:
|
||||||
changelog="<?xml version=\"1.0\" encoding=\"utf-8\"?><changelog bulletedList=\"true\"><changelogversion versionName=\"${{ github.run_number }}\" changeDate=\"\">$changelog</changelogversion></changelog>"
|
changelog="<?xml version=\"1.0\" encoding=\"utf-8\"?><changelog bulletedList=\"true\"><changelogversion versionName=\"${{ github.run_number }}\" changeDate=\"\">$changelog</changelogversion></changelog>"
|
||||||
echo "CHANGELOG=$changelog" >> $GITHUB_ENV
|
echo "CHANGELOG=$changelog" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Write Version.kt
|
|
||||||
uses: DamianReeves/write-file-action@v1.3
|
|
||||||
with:
|
|
||||||
path: app/src/main/java/exh/Version.kt
|
|
||||||
contents: 'package exh const val syDebugVersion: String = "${{ github.run_number }}"'
|
|
||||||
write-mode: overwrite
|
|
||||||
|
|
||||||
# - name: Write changelog_debug.xml
|
|
||||||
# uses: DamianReeves/write-file-action@v1.3
|
|
||||||
# with:
|
|
||||||
# path: app/src/main/res/raw/changelog_debug.xml
|
|
||||||
# contents: "${{ env.CHANGELOG }}"
|
|
||||||
# write-mode: overwrite
|
|
||||||
|
|
||||||
- name: Write google-services.json
|
- name: Write google-services.json
|
||||||
uses: DamianReeves/write-file-action@v1.3
|
uses: DamianReeves/write-file-action@v1.3
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ android {
|
||||||
buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
|
buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
|
||||||
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime()}\"")
|
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime()}\"")
|
||||||
buildConfigField("boolean", "INCLUDE_UPDATER", "false")
|
buildConfigField("boolean", "INCLUDE_UPDATER", "false")
|
||||||
|
buildConfigField("boolean", "PREVIEW", "false")
|
||||||
|
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters += SUPPORTED_ABIS
|
abiFilters += SUPPORTED_ABIS
|
||||||
|
|
@ -66,10 +67,20 @@ android {
|
||||||
matchingFallbacks.add("release")
|
matchingFallbacks.add("release")
|
||||||
}
|
}
|
||||||
named("release") {
|
named("release") {
|
||||||
isMinifyEnabled = true
|
|
||||||
isShrinkResources = true
|
isShrinkResources = true
|
||||||
|
isMinifyEnabled = true
|
||||||
setProguardFiles(listOf(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"))
|
setProguardFiles(listOf(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"))
|
||||||
}
|
}
|
||||||
|
create("preview") {
|
||||||
|
initWith(getByName("release"))
|
||||||
|
buildConfigField("boolean", "PREVIEW", "true")
|
||||||
|
|
||||||
|
matchingFallbacks.add("release")
|
||||||
|
versionNameSuffix = "-${getCommitCount()}"
|
||||||
|
applicationIdSuffix = ".beta"
|
||||||
|
signingConfig = signingConfigs.getByName("debug")
|
||||||
|
// signingConfig = signingConfigs.getByName("debug")
|
||||||
|
}
|
||||||
create("benchmark") {
|
create("benchmark") {
|
||||||
initWith(getByName("release"))
|
initWith(getByName("release"))
|
||||||
|
|
||||||
|
|
@ -77,12 +88,13 @@ android {
|
||||||
matchingFallbacks.add("release")
|
matchingFallbacks.add("release")
|
||||||
isDebuggable = false
|
isDebuggable = false
|
||||||
isProfileable = true
|
isProfileable = true
|
||||||
versionNameSuffix = "-benchmark"
|
versionNameSuffix = "-${getCommitCount()}-benchmark"
|
||||||
applicationIdSuffix = ".benchmark"
|
applicationIdSuffix = ".benchmark"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
getByName("preview").res.srcDirs("src/beta/res")
|
||||||
getByName("benchmark").res.srcDirs("src/debug/res")
|
getByName("benchmark").res.srcDirs("src/debug/res")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,7 @@ import eu.kanade.tachiyomi.ui.more.NewUpdateScreen
|
||||||
import eu.kanade.tachiyomi.util.CrashLogUtil
|
import eu.kanade.tachiyomi.util.CrashLogUtil
|
||||||
import eu.kanade.tachiyomi.util.lang.toDateTimestampString
|
import eu.kanade.tachiyomi.util.lang.toDateTimestampString
|
||||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||||
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import exh.syDebugVersion
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
import tachiyomi.core.common.util.lang.withIOContext
|
import tachiyomi.core.common.util.lang.withIOContext
|
||||||
|
|
@ -54,6 +52,7 @@ import java.time.Instant
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
|
|
||||||
|
@Suppress("JavaIoSerializableObjectMustHaveReadResolve")
|
||||||
object AboutScreen : Screen() {
|
object AboutScreen : Screen() {
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -259,9 +258,8 @@ object AboutScreen : Screen() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SY -->
|
BuildConfig.PREVIEW -> {
|
||||||
isPreviewBuildType -> {
|
"Beta r${BuildConfig.COMMIT_COUNT}".let {
|
||||||
"Preview r$syDebugVersion".let {
|
|
||||||
if (withBuildDate) {
|
if (withBuildDate) {
|
||||||
"$it (${BuildConfig.COMMIT_SHA}, ${getFormattedBuildTime()})"
|
"$it (${BuildConfig.COMMIT_SHA}, ${getFormattedBuildTime()})"
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -269,7 +267,6 @@ object AboutScreen : Screen() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SY <--
|
|
||||||
else -> {
|
else -> {
|
||||||
"Stable ${BuildConfig.VERSION_NAME}".let {
|
"Stable ${BuildConfig.VERSION_NAME}".let {
|
||||||
if (withBuildDate) {
|
if (withBuildDate) {
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ import eu.kanade.tachiyomi.util.system.WebViewUtil
|
||||||
import eu.kanade.tachiyomi.util.system.animatorDurationScale
|
import eu.kanade.tachiyomi.util.system.animatorDurationScale
|
||||||
import eu.kanade.tachiyomi.util.system.cancelNotification
|
import eu.kanade.tachiyomi.util.system.cancelNotification
|
||||||
import eu.kanade.tachiyomi.util.system.isDevFlavor
|
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.isReleaseBuildType
|
||||||
import eu.kanade.tachiyomi.util.system.notify
|
import eu.kanade.tachiyomi.util.system.notify
|
||||||
import exh.log.CrashlyticsPrinter
|
import exh.log.CrashlyticsPrinter
|
||||||
|
|
@ -65,7 +66,6 @@ import exh.log.EHLogLevel
|
||||||
import exh.log.EnhancedFilePrinter
|
import exh.log.EnhancedFilePrinter
|
||||||
import exh.log.XLogLogcatLogger
|
import exh.log.XLogLogcatLogger
|
||||||
import exh.log.xLogD
|
import exh.log.xLogD
|
||||||
import exh.syDebugVersion
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
|
@ -102,7 +102,7 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
if (!isDevFlavor) {
|
if (!isDevFlavor) {
|
||||||
Firebase.crashlytics.setCrashlyticsCollectionEnabled(isReleaseBuildType)
|
Firebase.crashlytics.setCrashlyticsCollectionEnabled(isReleaseBuildType || isPreviewBuildType)
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
GlobalExceptionHandler.initialize(applicationContext, CrashActivity::class.java)
|
GlobalExceptionHandler.initialize(applicationContext, CrashActivity::class.java)
|
||||||
|
|
@ -329,7 +329,7 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||||
xLogD(
|
xLogD(
|
||||||
"""
|
"""
|
||||||
App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.FLAVOR}, ${BuildConfig.COMMIT_SHA}, ${BuildConfig.VERSION_CODE})
|
App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.FLAVOR}, ${BuildConfig.COMMIT_SHA}, ${BuildConfig.VERSION_CODE})
|
||||||
Preview build: $syDebugVersion
|
Build version: ${BuildConfig.COMMIT_COUNT}
|
||||||
Android version: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT})
|
Android version: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT})
|
||||||
Android build ID: ${Build.DISPLAY}
|
Android build ID: ${Build.DISPLAY}
|
||||||
Device brand: ${Build.BRAND}
|
Device brand: ${Build.BRAND}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@ package eu.kanade.tachiyomi.data.updater
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.util.system.isInstalledFromFDroid
|
import eu.kanade.tachiyomi.util.system.isInstalledFromFDroid
|
||||||
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
|
||||||
import exh.syDebugVersion
|
|
||||||
import tachiyomi.core.common.util.lang.withIOContext
|
import tachiyomi.core.common.util.lang.withIOContext
|
||||||
import tachiyomi.domain.release.interactor.GetApplicationRelease
|
import tachiyomi.domain.release.interactor.GetApplicationRelease
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
@ -22,17 +20,12 @@ class AppUpdateChecker {
|
||||||
return withIOContext {
|
return withIOContext {
|
||||||
val result = getApplicationRelease.await(
|
val result = getApplicationRelease.await(
|
||||||
GetApplicationRelease.Arguments(
|
GetApplicationRelease.Arguments(
|
||||||
// SY -->
|
isPreview = BuildConfig.PREVIEW,
|
||||||
isPreviewBuildType,
|
isThirdParty = context.isInstalledFromFDroid(),
|
||||||
// SY <--
|
commitCount = BuildConfig.COMMIT_COUNT.toInt(),
|
||||||
context.isInstalledFromFDroid(),
|
versionName = BuildConfig.VERSION_NAME,
|
||||||
BuildConfig.COMMIT_COUNT.toInt(),
|
repository = GITHUB_REPO,
|
||||||
BuildConfig.VERSION_NAME,
|
forceCheck = forceCheck,
|
||||||
GITHUB_REPO,
|
|
||||||
// SY -->
|
|
||||||
syDebugVersion,
|
|
||||||
// SY <--
|
|
||||||
forceCheck,
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -50,12 +43,19 @@ class AppUpdateChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
val GITHUB_REPO: String by lazy {
|
val GITHUB_REPO: String by lazy {
|
||||||
// SY -->
|
if (BuildConfig.PREVIEW) {
|
||||||
if (isPreviewBuildType) {
|
"komikku-app/komikku-preview"
|
||||||
"komikku-app/komikku"
|
|
||||||
} else {
|
} else {
|
||||||
"komikku-app/komikku"
|
"komikku-app/komikku"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val RELEASE_TAG: String by lazy {
|
||||||
|
if (BuildConfig.PREVIEW) {
|
||||||
|
"r${BuildConfig.COMMIT_COUNT}"
|
||||||
|
} else {
|
||||||
|
"v${BuildConfig.VERSION_NAME}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val RELEASE_URL = "https://github.com/$GITHUB_REPO/releases/tag/$RELEASE_TAG"
|
val RELEASE_URL = "https://github.com/$GITHUB_REPO/releases/tag/$RELEASE_TAG"
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,10 @@ import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
||||||
import eu.kanade.tachiyomi.ui.more.NewUpdateScreen
|
import eu.kanade.tachiyomi.ui.more.NewUpdateScreen
|
||||||
import eu.kanade.tachiyomi.ui.more.OnboardingScreen
|
import eu.kanade.tachiyomi.ui.more.OnboardingScreen
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
|
import eu.kanade.tachiyomi.util.system.isDevFlavor
|
||||||
import eu.kanade.tachiyomi.util.system.isNavigationBarNeedsScrim
|
import eu.kanade.tachiyomi.util.system.isNavigationBarNeedsScrim
|
||||||
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
||||||
|
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
|
||||||
import eu.kanade.tachiyomi.util.view.setComposeContent
|
import eu.kanade.tachiyomi.util.view.setComposeContent
|
||||||
import exh.debug.DebugToggles
|
import exh.debug.DebugToggles
|
||||||
import exh.eh.EHentaiUpdateWorker
|
import exh.eh.EHentaiUpdateWorker
|
||||||
|
|
@ -84,7 +86,6 @@ import exh.log.DebugModeOverlay
|
||||||
import exh.source.BlacklistedSources
|
import exh.source.BlacklistedSources
|
||||||
import exh.source.EH_SOURCE_ID
|
import exh.source.EH_SOURCE_ID
|
||||||
import exh.source.EXH_SOURCE_ID
|
import exh.source.EXH_SOURCE_ID
|
||||||
import exh.syDebugVersion
|
|
||||||
import kotlinx.coroutines.channels.awaitClose
|
import kotlinx.coroutines.channels.awaitClose
|
||||||
import kotlinx.coroutines.flow.callbackFlow
|
import kotlinx.coroutines.flow.callbackFlow
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
|
|
@ -520,8 +521,8 @@ class MainActivity : BaseActivity() {
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
private fun addAnalytics() {
|
private fun addAnalytics() {
|
||||||
if (!BuildConfig.DEBUG && isPreviewBuildType) {
|
if (!isDevFlavor && (isReleaseBuildType || isPreviewBuildType)) {
|
||||||
Firebase.analytics.setUserProperty("preview_version", syDebugVersion)
|
Firebase.analytics.setUserProperty("preview_version", BuildConfig.COMMIT_COUNT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import eu.kanade.tachiyomi.util.system.WebViewUtil
|
||||||
import eu.kanade.tachiyomi.util.system.createFileInCacheDir
|
import eu.kanade.tachiyomi.util.system.createFileInCacheDir
|
||||||
import eu.kanade.tachiyomi.util.system.toShareIntent
|
import eu.kanade.tachiyomi.util.system.toShareIntent
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import exh.syDebugVersion
|
|
||||||
import tachiyomi.core.common.util.lang.withNonCancellableContext
|
import tachiyomi.core.common.util.lang.withNonCancellableContext
|
||||||
import tachiyomi.core.common.util.lang.withUIContext
|
import tachiyomi.core.common.util.lang.withUIContext
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
|
|
@ -39,7 +38,7 @@ class CrashLogUtil(
|
||||||
fun getDebugInfo(): String {
|
fun getDebugInfo(): String {
|
||||||
return """
|
return """
|
||||||
App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.FLAVOR}, ${BuildConfig.COMMIT_SHA}, ${BuildConfig.VERSION_CODE}, ${BuildConfig.BUILD_TIME})
|
App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.FLAVOR}, ${BuildConfig.COMMIT_SHA}, ${BuildConfig.VERSION_CODE}, ${BuildConfig.BUILD_TIME})
|
||||||
Preview build: $syDebugVersion
|
Build version: ${BuildConfig.COMMIT_COUNT}
|
||||||
Android version: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT}; build ${Build.DISPLAY})
|
Android version: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT}; build ${Build.DISPLAY})
|
||||||
Device brand: ${Build.BRAND}
|
Device brand: ${Build.BRAND}
|
||||||
Device manufacturer: ${Build.MANUFACTURER}
|
Device manufacturer: ${Build.MANUFACTURER}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
package eu.kanade.tachiyomi.util.system
|
package eu.kanade.tachiyomi.util.system
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import exh.syDebugVersion
|
|
||||||
|
|
||||||
val isDevFlavor: Boolean
|
val isDevFlavor: Boolean
|
||||||
get() = BuildConfig.FLAVOR == "dev"
|
get() = BuildConfig.FLAVOR == "dev"
|
||||||
|
|
||||||
val isPreviewBuildType: Boolean
|
val isPreviewBuildType: Boolean
|
||||||
get() = BuildConfig.BUILD_TYPE == "release" /* SY --> */ && syDebugVersion != "0" /* SY <-- */
|
get() = BuildConfig.BUILD_TYPE == "preview"
|
||||||
|
|
||||||
val isReleaseBuildType: Boolean
|
val isReleaseBuildType: Boolean
|
||||||
get() = BuildConfig.BUILD_TYPE == "release" /* SY --> */ && syDebugVersion == "0" /* SY <-- */
|
get() = BuildConfig.BUILD_TYPE == "release"
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
package exh const val syDebugVersion: String = "0"
|
|
||||||
|
|
@ -32,10 +32,12 @@ class GetApplicationRelease(
|
||||||
lastChecked.set(now.toEpochMilli())
|
lastChecked.set(now.toEpochMilli())
|
||||||
|
|
||||||
// Check if latest version is different from current version
|
// Check if latest version is different from current version
|
||||||
// SY -->
|
val isNewVersion = isNewVersion(
|
||||||
val isNewVersion =
|
isPreview = arguments.isPreview,
|
||||||
isNewVersion(arguments.isPreview, arguments.syDebugVersion, arguments.versionName, release.version)
|
commitCount = arguments.commitCount,
|
||||||
// SY <--
|
versionName = arguments.versionName,
|
||||||
|
versionTag = release.version,
|
||||||
|
)
|
||||||
return when {
|
return when {
|
||||||
isNewVersion && arguments.isThirdParty -> Result.ThirdPartyInstallation
|
isNewVersion && arguments.isThirdParty -> Result.ThirdPartyInstallation
|
||||||
isNewVersion -> Result.NewUpdate(release)
|
isNewVersion -> Result.NewUpdate(release)
|
||||||
|
|
@ -43,28 +45,45 @@ class GetApplicationRelease(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SY -->
|
/**
|
||||||
|
* [isPreview] is if current version is Preview (beta) build
|
||||||
|
*
|
||||||
|
* [versionTag] is the version of new release
|
||||||
|
*
|
||||||
|
* Release (stable) version will compare with current's [versionName] ("v0.1.2")
|
||||||
|
*
|
||||||
|
* Preview (beta) version will compare with current's [commitCount] ("r1234")
|
||||||
|
*/
|
||||||
private fun isNewVersion(
|
private fun isNewVersion(
|
||||||
isPreview: Boolean,
|
isPreview: Boolean,
|
||||||
syDebugVersion: String,
|
commitCount: Int,
|
||||||
versionName: String,
|
versionName: String,
|
||||||
versionTag: String,
|
versionTag: String,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
// Removes prefixes like "r" or "v"
|
// Removes prefixes like "r" or "v"
|
||||||
val newVersion = versionTag.replace("[^\\d.]".toRegex(), "")
|
val newVersion = versionTag.replace("[^\\d.]".toRegex(), "")
|
||||||
return if (isPreview) {
|
return if (isPreview) {
|
||||||
// Preview builds: based on releases in "jobobby04/TachiyomiSYPreview" repo
|
// Preview builds: based on releases in "komikku-app/komikku-preview" repo
|
||||||
// tagged as something like "508"
|
// tagged as something like "r1234"
|
||||||
val currentInt = syDebugVersion.toIntOrNull()
|
// KMK -->
|
||||||
currentInt != null && newVersion.toInt() > currentInt
|
// When has stable update but current app is preview version (same repo) expect new update
|
||||||
|
// TODO: remove this when all users has finished switching from preview to stable
|
||||||
|
if (newVersion.matches("""\d.\d.\d""".toRegex())) return true
|
||||||
|
// KMK <--
|
||||||
|
newVersion.toInt() > commitCount
|
||||||
} else {
|
} else {
|
||||||
// Release builds: based on releases in "komikku-app/komikku" repo
|
// Release builds: based on releases in "komikku-app/komikku" repo
|
||||||
// tagged as something like "0.1.2"
|
// tagged as something like "v0.1.2"
|
||||||
val oldVersion = versionName.replace("[^\\d.]".toRegex(), "")
|
val oldVersion = versionName.replace("[^\\d.]".toRegex(), "")
|
||||||
|
|
||||||
val newSemVer = newVersion.split(".").map { it.toInt() }
|
val newSemVer = newVersion.split(".").map { it.toInt() }
|
||||||
val oldSemVer = oldVersion.split(".").map { it.toInt() }
|
val oldSemVer = oldVersion.split(".").map { it.toInt() }
|
||||||
|
|
||||||
|
// KMK -->
|
||||||
|
// When has stable update with preview version but current app is stable version expect no update
|
||||||
|
// TODO: remove this when all users has finished switching from preview to stable
|
||||||
|
if (newSemVer.size != oldSemVer.size) return false
|
||||||
|
// KMK <--
|
||||||
oldSemVer.mapIndexed { index, i ->
|
oldSemVer.mapIndexed { index, i ->
|
||||||
if (newSemVer[index] > i) {
|
if (newSemVer[index] > i) {
|
||||||
return true
|
return true
|
||||||
|
|
@ -74,17 +93,19 @@ class GetApplicationRelease(
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SY <--
|
|
||||||
|
|
||||||
data class Arguments(
|
data class Arguments(
|
||||||
|
/** If current version is Preview (beta) build */
|
||||||
val isPreview: Boolean,
|
val isPreview: Boolean,
|
||||||
|
/** If current version is from third party */
|
||||||
val isThirdParty: Boolean,
|
val isThirdParty: Boolean,
|
||||||
|
/** Commit count of current version */
|
||||||
val commitCount: Int,
|
val commitCount: Int,
|
||||||
|
/** Current version name, could be version tag (v0.1.2) or commit count (r1234) */
|
||||||
val versionName: String,
|
val versionName: String,
|
||||||
|
/** Repository name */
|
||||||
val repository: String,
|
val repository: String,
|
||||||
// SY -->
|
/** Force check for new update */
|
||||||
val syDebugVersion: String,
|
|
||||||
// SY <--
|
|
||||||
val forceCheck: Boolean = false,
|
val forceCheck: Boolean = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ class GetApplicationReleaseTest {
|
||||||
commitCount = 0,
|
commitCount = 0,
|
||||||
versionName = "v1.0.0",
|
versionName = "v1.0.0",
|
||||||
repository = "test",
|
repository = "test",
|
||||||
syDebugVersion = "0",
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -62,7 +61,7 @@ class GetApplicationReleaseTest {
|
||||||
every { preference.set(any()) }.answers { }
|
every { preference.set(any()) }.answers { }
|
||||||
|
|
||||||
val release = Release(
|
val release = Release(
|
||||||
"200",
|
"r2000",
|
||||||
"info",
|
"info",
|
||||||
"http://example.com/release_link",
|
"http://example.com/release_link",
|
||||||
listOf("http://example.com/assets"),
|
listOf("http://example.com/assets"),
|
||||||
|
|
@ -77,13 +76,10 @@ class GetApplicationReleaseTest {
|
||||||
commitCount = 1000,
|
commitCount = 1000,
|
||||||
versionName = "",
|
versionName = "",
|
||||||
repository = "test",
|
repository = "test",
|
||||||
syDebugVersion = "100",
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
(result as GetApplicationRelease.Result.NewUpdate).release shouldBe GetApplicationRelease.Result.NewUpdate(
|
result shouldBe GetApplicationRelease.Result.NewUpdate(release)
|
||||||
release,
|
|
||||||
).release
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -106,14 +102,11 @@ class GetApplicationReleaseTest {
|
||||||
isThirdParty = false,
|
isThirdParty = false,
|
||||||
commitCount = 0,
|
commitCount = 0,
|
||||||
versionName = "v1.0.0",
|
versionName = "v1.0.0",
|
||||||
syDebugVersion = "0",
|
|
||||||
repository = "test",
|
repository = "test",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
(result as GetApplicationRelease.Result.NewUpdate).release shouldBe GetApplicationRelease.Result.NewUpdate(
|
result shouldBe GetApplicationRelease.Result.NewUpdate(release)
|
||||||
release,
|
|
||||||
).release
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -136,7 +129,6 @@ class GetApplicationReleaseTest {
|
||||||
isThirdParty = false,
|
isThirdParty = false,
|
||||||
commitCount = 0,
|
commitCount = 0,
|
||||||
versionName = "v2.0.0",
|
versionName = "v2.0.0",
|
||||||
syDebugVersion = "0",
|
|
||||||
repository = "test",
|
repository = "test",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -150,7 +142,7 @@ class GetApplicationReleaseTest {
|
||||||
every { preference.set(any()) }.answers { }
|
every { preference.set(any()) }.answers { }
|
||||||
|
|
||||||
val release = Release(
|
val release = Release(
|
||||||
"v1.0.0",
|
"v2.0.0",
|
||||||
"info",
|
"info",
|
||||||
"http://example.com/release_link",
|
"http://example.com/release_link",
|
||||||
listOf("http://example.com/assets"),
|
listOf("http://example.com/assets"),
|
||||||
|
|
@ -163,8 +155,7 @@ class GetApplicationReleaseTest {
|
||||||
isPreview = false,
|
isPreview = false,
|
||||||
isThirdParty = false,
|
isThirdParty = false,
|
||||||
commitCount = 0,
|
commitCount = 0,
|
||||||
versionName = "v2.0.0",
|
versionName = "v1.0.0",
|
||||||
syDebugVersion = "0",
|
|
||||||
repository = "test",
|
repository = "test",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -172,4 +163,88 @@ class GetApplicationReleaseTest {
|
||||||
coVerify(exactly = 0) { releaseService.latest(any()) }
|
coVerify(exactly = 0) { releaseService.latest(any()) }
|
||||||
result shouldBe GetApplicationRelease.Result.NoNewUpdate
|
result shouldBe GetApplicationRelease.Result.NoNewUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KMK -->
|
||||||
|
// TODO: remove below tests when all users finished switching from preview to stable
|
||||||
|
@Test
|
||||||
|
fun `When preview version updating to new stable version with preview tag expect new update`() = runTest {
|
||||||
|
every { preference.get() } returns 0
|
||||||
|
every { preference.set(any()) }.answers { }
|
||||||
|
|
||||||
|
val release = Release(
|
||||||
|
"r1234",
|
||||||
|
"info",
|
||||||
|
"http://example.com/release_link",
|
||||||
|
listOf("http://example.com/assets"),
|
||||||
|
)
|
||||||
|
|
||||||
|
coEvery { releaseService.latest(any()) } returns release
|
||||||
|
|
||||||
|
val result = getApplicationRelease.await(
|
||||||
|
GetApplicationRelease.Arguments(
|
||||||
|
isPreview = true,
|
||||||
|
isThirdParty = false,
|
||||||
|
commitCount = 25,
|
||||||
|
versionName = "",
|
||||||
|
repository = "test",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
result shouldBe GetApplicationRelease.Result.NewUpdate(release)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `When has stable update with preview version but current app is stable version expect no update`() = runTest {
|
||||||
|
every { preference.get() } returns 0
|
||||||
|
every { preference.set(any()) }.answers { }
|
||||||
|
|
||||||
|
val release = Release(
|
||||||
|
"r1234",
|
||||||
|
"info",
|
||||||
|
"http://example.com/release_link",
|
||||||
|
listOf("http://example.com/assets"),
|
||||||
|
)
|
||||||
|
|
||||||
|
coEvery { releaseService.latest(any()) } returns release
|
||||||
|
|
||||||
|
val result = getApplicationRelease.await(
|
||||||
|
GetApplicationRelease.Arguments(
|
||||||
|
isPreview = false,
|
||||||
|
isThirdParty = false,
|
||||||
|
commitCount = 0,
|
||||||
|
versionName = "v1.0.0",
|
||||||
|
repository = "test",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
result shouldBe GetApplicationRelease.Result.NoNewUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `When has stable update but current app is preview version (same repo) expect new update`() = runTest {
|
||||||
|
every { preference.get() } returns 0
|
||||||
|
every { preference.set(any()) }.answers { }
|
||||||
|
|
||||||
|
val release = Release(
|
||||||
|
"v2.0.0",
|
||||||
|
"info",
|
||||||
|
"http://example.com/release_link",
|
||||||
|
listOf("http://example.com/assets"),
|
||||||
|
)
|
||||||
|
|
||||||
|
coEvery { releaseService.latest(any()) } returns release
|
||||||
|
|
||||||
|
val result = getApplicationRelease.await(
|
||||||
|
GetApplicationRelease.Arguments(
|
||||||
|
isPreview = true,
|
||||||
|
isThirdParty = false,
|
||||||
|
commitCount = 25,
|
||||||
|
versionName = "",
|
||||||
|
repository = "test",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
result shouldBe GetApplicationRelease.Result.NewUpdate(release)
|
||||||
|
}
|
||||||
|
// KMK <--
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="changelog_version">Version %1$s</string>
|
<string name="changelog_version">Version %1$s</string>
|
||||||
|
<string name="changelogs">Change Logs</string>
|
||||||
|
|
||||||
<!-- EH Settings -->
|
<!-- EH Settings -->
|
||||||
<string name="ehentai_prefs_account_settings">E-Hentai Website Account Settings</string>
|
<string name="ehentai_prefs_account_settings">E-Hentai Website Account Settings</string>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue