mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Add Beta flavor builds
Use Beta tag instead of version check in advanced settings Simplify beta check logic in advanced settings new version app check fixes for beta
This commit is contained in:
parent
4b24dfc9f9
commit
2040462c49
8 changed files with 98 additions and 42 deletions
|
@ -17,10 +17,6 @@ if (gradle.startParameter.taskRequests.toString().contains("Standard")) {
|
||||||
apply<com.google.gms.googleservices.GoogleServicesPlugin>()
|
apply<com.google.gms.googleservices.GoogleServicesPlugin>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBuildTime() = DateTimeFormatter.ISO_DATE_TIME.format(LocalDateTime.now(ZoneOffset.UTC))
|
|
||||||
fun getCommitCount() = runCommand("git rev-list --count HEAD")
|
|
||||||
fun getGitSha() = runCommand("git rev-parse --short HEAD")
|
|
||||||
|
|
||||||
fun runCommand(command: String): String {
|
fun runCommand(command: String): String {
|
||||||
val byteOut = ByteArrayOutputStream()
|
val byteOut = ByteArrayOutputStream()
|
||||||
project.exec {
|
project.exec {
|
||||||
|
@ -46,9 +42,11 @@ android {
|
||||||
multiDexEnabled = true
|
multiDexEnabled = true
|
||||||
|
|
||||||
buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
|
buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
|
||||||
|
buildConfigField("String", "BETA_COMMIT_COUNT", "\"${getCommitCountSinceLastRelease()}\"")
|
||||||
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", "BETA", "false")
|
||||||
|
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters += supportedAbis
|
abiFilters += supportedAbis
|
||||||
|
@ -81,6 +79,7 @@ android {
|
||||||
buildTypes {
|
buildTypes {
|
||||||
getByName("debug") {
|
getByName("debug") {
|
||||||
applicationIdSuffix = ".debugJ2K"
|
applicationIdSuffix = ".debugJ2K"
|
||||||
|
versionNameSuffix = "-d${getCommitCount()}"
|
||||||
}
|
}
|
||||||
getByName("release") {
|
getByName("release") {
|
||||||
applicationIdSuffix = ".j2k"
|
applicationIdSuffix = ".j2k"
|
||||||
|
@ -88,6 +87,12 @@ android {
|
||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
|
proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
|
||||||
}
|
}
|
||||||
|
create("beta") {
|
||||||
|
initWith(getByName("release"))
|
||||||
|
buildConfigField("boolean", "BETA", "true")
|
||||||
|
|
||||||
|
versionNameSuffix = "-b${getCommitCountSinceLastRelease()}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
|
@ -178,6 +183,7 @@ dependencies {
|
||||||
val chuckerVersion = "3.5.2"
|
val chuckerVersion = "3.5.2"
|
||||||
debugImplementation("com.github.ChuckerTeam.Chucker:library:$chuckerVersion")
|
debugImplementation("com.github.ChuckerTeam.Chucker:library:$chuckerVersion")
|
||||||
releaseImplementation("com.github.ChuckerTeam.Chucker:library-no-op:$chuckerVersion")
|
releaseImplementation("com.github.ChuckerTeam.Chucker:library-no-op:$chuckerVersion")
|
||||||
|
add("betaImplementation", "com.github.ChuckerTeam.Chucker:library-no-op:$chuckerVersion")
|
||||||
|
|
||||||
implementation(kotlin("reflect", version = AndroidVersions.kotlin))
|
implementation(kotlin("reflect", version = AndroidVersions.kotlin))
|
||||||
|
|
||||||
|
|
|
@ -225,8 +225,6 @@ object PreferenceKeys {
|
||||||
|
|
||||||
const val sideNavMode = "side_nav_mode"
|
const val sideNavMode = "side_nav_mode"
|
||||||
|
|
||||||
const val checkForBetas = "check_for_betas"
|
|
||||||
|
|
||||||
const val shouldAutoUpdate = "should_auto_update"
|
const val shouldAutoUpdate = "should_auto_update"
|
||||||
|
|
||||||
const val autoUpdateExtensions = "auto_update_extensions"
|
const val autoUpdateExtensions = "auto_update_extensions"
|
||||||
|
|
|
@ -8,6 +8,7 @@ import androidx.preference.PreferenceManager
|
||||||
import com.fredporciuncula.flow.preferences.FlowSharedPreferences
|
import com.fredporciuncula.flow.preferences.FlowSharedPreferences
|
||||||
import com.fredporciuncula.flow.preferences.Preference
|
import com.fredporciuncula.flow.preferences.Preference
|
||||||
import com.google.android.material.color.DynamicColors
|
import com.google.android.material.color.DynamicColors
|
||||||
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.track.TrackService
|
import eu.kanade.tachiyomi.data.track.TrackService
|
||||||
|
@ -373,7 +374,7 @@ class PreferencesHelper(val context: Context) {
|
||||||
|
|
||||||
fun lastAppCheck() = flowPrefs.getLong("last_app_check", 0)
|
fun lastAppCheck() = flowPrefs.getLong("last_app_check", 0)
|
||||||
|
|
||||||
fun checkForBetas() = prefs.getBoolean(Keys.checkForBetas, false)
|
fun checkForBetas() = flowPrefs.getBoolean("check_for_betas", BuildConfig.BETA)
|
||||||
|
|
||||||
fun unreadBadgeType() = flowPrefs.getInt("unread_badge_type", 2)
|
fun unreadBadgeType() = flowPrefs.getInt("unread_badge_type", 2)
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class AppUpdateChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
return withIOContext {
|
return withIOContext {
|
||||||
val result = if (preferences.checkForBetas()) {
|
val result = if (preferences.checkForBetas().get()) {
|
||||||
networkService.client
|
networkService.client
|
||||||
.newCall(GET("https://api.github.com/repos/$GITHUB_REPO/releases"))
|
.newCall(GET("https://api.github.com/repos/$GITHUB_REPO/releases"))
|
||||||
.await()
|
.await()
|
||||||
|
@ -72,17 +72,25 @@ class AppUpdateChecker {
|
||||||
|
|
||||||
private fun isNewVersion(versionTag: String): Boolean {
|
private fun isNewVersion(versionTag: String): Boolean {
|
||||||
// Removes prefixes like "r" or "v"
|
// Removes prefixes like "r" or "v"
|
||||||
val newVersion = versionTag.replace("-", ".").replace("[^\\d.]".toRegex(), "")
|
val newVersion = versionTag.replace("[^\\d.-]".toRegex(), "")
|
||||||
val oldVersion = BuildConfig.VERSION_NAME.replace("-", ".").replace("[^\\d.]".toRegex(), "")
|
val oldVersion = BuildConfig.VERSION_NAME.replace("[^\\d.-]".toRegex(), "")
|
||||||
val newSemVer = newVersion.split(".").map { it.toInt() }
|
val newPreReleaseVer = newVersion.split("-")
|
||||||
val oldSemVer = oldVersion.split(".").map { it.toInt() }
|
val oldPreReleaseVer = oldVersion.split("-")
|
||||||
|
val newSemVer = newPreReleaseVer.first().split(".").map { it.toInt() }
|
||||||
|
val oldSemVer = oldPreReleaseVer.first().split(".").map { it.toInt() }
|
||||||
|
|
||||||
oldSemVer.mapIndexed { index, i ->
|
oldSemVer.mapIndexed { index, i ->
|
||||||
if (newSemVer.getOrElse(index) { i } > i) {
|
if (newSemVer.getOrElse(index) { i } > i) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newSemVer.size > oldSemVer.size
|
// For cases of extreme patch versions (new: 1.2.3.1 vs old: 1.2.3, return true)
|
||||||
|
return if (newSemVer.size > oldSemVer.size) {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
// For production versions from beta (new: 1.2.3 vs old: 1.2.3-b1, return true)
|
||||||
|
(newPreReleaseVer.getOrNull(1) != null) != (oldPreReleaseVer.getOrNull(1) != null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import android.content.res.ColorStateList
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
|
import androidx.core.text.buildSpannedString
|
||||||
|
import androidx.core.text.color
|
||||||
import androidx.core.view.WindowInsetsControllerCompat
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||||
|
@ -14,6 +16,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.toggle
|
import eu.kanade.tachiyomi.data.preference.toggle
|
||||||
import eu.kanade.tachiyomi.databinding.TachiOverflowLayoutBinding
|
import eu.kanade.tachiyomi.databinding.TachiOverflowLayoutBinding
|
||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
|
import eu.kanade.tachiyomi.util.lang.addBetaTag
|
||||||
import eu.kanade.tachiyomi.util.lang.withSubtitle
|
import eu.kanade.tachiyomi.util.lang.withSubtitle
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
|
@ -79,7 +82,17 @@ class OverflowDialog(activity: MainActivity) : Dialog(activity, R.style.Overflow
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.aboutItem.text = context.getString(R.string.about).withSubtitle(binding.aboutItem.context, "v${BuildConfig.VERSION_NAME}")
|
val vName = "v${BuildConfig.VERSION_NAME}".substringBefore("-")
|
||||||
|
val newVName = buildSpannedString {
|
||||||
|
color(context.getResourceColor(android.R.attr.textColorSecondary)) {
|
||||||
|
append(vName)
|
||||||
|
}
|
||||||
|
if (BuildConfig.BETA) {
|
||||||
|
append("".addBetaTag(context, false))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.aboutItem.text = context.getString(R.string.about).withSubtitle(newVName)
|
||||||
|
|
||||||
binding.aboutItem.setOnClickListener {
|
binding.aboutItem.setOnClickListener {
|
||||||
activity.showAbout()
|
activity.showAbout()
|
||||||
|
|
|
@ -58,7 +58,6 @@ import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
|
||||||
|
|
||||||
class SettingsAdvancedController : SettingsController() {
|
class SettingsAdvancedController : SettingsController() {
|
||||||
|
|
||||||
|
@ -129,27 +128,15 @@ class SettingsAdvancedController : SettingsController() {
|
||||||
switchPreference {
|
switchPreference {
|
||||||
titleRes = R.string.check_for_beta_releases
|
titleRes = R.string.check_for_beta_releases
|
||||||
summaryRes = R.string.try_new_features
|
summaryRes = R.string.try_new_features
|
||||||
key = Keys.checkForBetas
|
bindTo(preferences.checkForBetas())
|
||||||
|
|
||||||
onChange {
|
onChange {
|
||||||
it as Boolean
|
it as Boolean
|
||||||
if (!it && BuildConfig.VERSION_NAME.contains("-b")) {
|
if ((!it && BuildConfig.BETA) || (it && !BuildConfig.BETA)) {
|
||||||
activity!!.materialAlertDialog()
|
activity!!.materialAlertDialog()
|
||||||
.setTitle(R.string.warning)
|
.setTitle(R.string.warning)
|
||||||
.setMessage(R.string.warning_unenroll_from_beta)
|
.setMessage(if (it) R.string.warning_enroll_into_beta else R.string.warning_unenroll_from_beta)
|
||||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
.setPositiveButton(android.R.string.ok) { _, _ -> isChecked = it }
|
||||||
isChecked = false
|
|
||||||
}
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.show()
|
|
||||||
false
|
|
||||||
} else if (it && !BuildConfig.VERSION_NAME.contains("-b")) {
|
|
||||||
activity!!.materialAlertDialog()
|
|
||||||
.setTitle(R.string.warning)
|
|
||||||
.setMessage(R.string.warning_enroll_into_beta)
|
|
||||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
|
||||||
isChecked = true
|
|
||||||
}
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.show()
|
.show()
|
||||||
false
|
false
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.util.lang
|
package eu.kanade.tachiyomi.util.lang
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
|
||||||
import android.text.Spannable
|
import android.text.Spannable
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.SpannableStringBuilder
|
import android.text.SpannableStringBuilder
|
||||||
|
@ -9,15 +8,15 @@ import android.text.Spanned
|
||||||
import android.text.SpannedString
|
import android.text.SpannedString
|
||||||
import android.text.style.BackgroundColorSpan
|
import android.text.style.BackgroundColorSpan
|
||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
import android.text.style.RelativeSizeSpan
|
|
||||||
import android.text.style.StyleSpan
|
|
||||||
import android.text.style.SuperscriptSpan
|
|
||||||
import android.text.style.TextAppearanceSpan
|
import android.text.style.TextAppearanceSpan
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.core.text.bold
|
||||||
import androidx.core.text.buildSpannedString
|
import androidx.core.text.buildSpannedString
|
||||||
import androidx.core.text.color
|
import androidx.core.text.color
|
||||||
import androidx.core.text.inSpans
|
import androidx.core.text.inSpans
|
||||||
|
import androidx.core.text.scale
|
||||||
|
import androidx.core.text.superscript
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import net.greypanther.natsort.CaseInsensitiveSimpleNaturalComparator
|
import net.greypanther.natsort.CaseInsensitiveSimpleNaturalComparator
|
||||||
|
@ -155,6 +154,9 @@ fun String.indexesOf(substr: String, ignoreCase: Boolean = true): List<Int> {
|
||||||
fun String.withSubtitle(context: Context, @StringRes subtitleRes: Int) =
|
fun String.withSubtitle(context: Context, @StringRes subtitleRes: Int) =
|
||||||
withSubtitle(context, context.getString(subtitleRes))
|
withSubtitle(context, context.getString(subtitleRes))
|
||||||
|
|
||||||
|
fun String.withSubtitle(subtitle: Spanned): Spanned =
|
||||||
|
SpannableStringBuilder(this + "\n").append(subtitle)
|
||||||
|
|
||||||
fun String.withSubtitle(context: Context, subtitle: String): Spanned {
|
fun String.withSubtitle(context: Context, subtitle: String): Spanned {
|
||||||
val spannable = SpannableStringBuilder(this + "\n" + subtitle)
|
val spannable = SpannableStringBuilder(this + "\n" + subtitle)
|
||||||
spannable.setSpan(
|
spannable.setSpan(
|
||||||
|
@ -166,14 +168,16 @@ fun String.withSubtitle(context: Context, subtitle: String): Spanned {
|
||||||
return spannable
|
return spannable
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.addBetaTag(context: Context): Spanned {
|
fun String.addBetaTag(context: Context, useSuperScript: Boolean = true): Spanned {
|
||||||
val betaText = context.getString(R.string.beta)
|
val betaText = context.getString(R.string.beta)
|
||||||
val betaSpan = SpannableStringBuilder(this + betaText)
|
val colorS = context.getResourceColor(R.attr.colorSecondary)
|
||||||
betaSpan.setSpan(SuperscriptSpan(), length, length + betaText.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
return buildSpannedString {
|
||||||
betaSpan.setSpan(RelativeSizeSpan(0.75f), length, length + betaText.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
append(this@addBetaTag)
|
||||||
betaSpan.setSpan(StyleSpan(Typeface.BOLD), length, length + betaText.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
val buttonSpan: SpannableStringBuilder.() -> Unit = {
|
||||||
betaSpan.setSpan(ForegroundColorSpan(context.getResourceColor(R.attr.colorSecondary)), length, length + betaText.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
bold { scale(0.75f) { color(colorS) { append(betaText) } } }
|
||||||
return betaSpan
|
}
|
||||||
|
if (useSuperScript) superscript(buttonSpan) else buttonSpan()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.toNormalized(): String = replace("’", "'")
|
fun String.toNormalized(): String = replace("’", "'")
|
||||||
|
|
39
buildSrc/src/main/kotlin/Commands.kt
Normal file
39
buildSrc/src/main/kotlin/Commands.kt
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.TimeZone
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
// Git is needed in your system PATH for these commands to work.
|
||||||
|
// If it's not installed, you can return a random value as a workaround
|
||||||
|
fun Project.getCommitCount(): String {
|
||||||
|
return runCommand("git rev-list --count HEAD")
|
||||||
|
// return "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.getCommitCountSinceLastRelease(): String {
|
||||||
|
val lastTag = runCommand("git describe --tags --abbrev=0")
|
||||||
|
return runCommand("git rev-list --count $lastTag..HEAD").toIntOrNull()?.toString() ?: "1"
|
||||||
|
// return "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun Project.getGitSha(): String {
|
||||||
|
return runCommand("git rev-parse --short HEAD")
|
||||||
|
// return "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.getBuildTime(): String {
|
||||||
|
val df = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
|
||||||
|
df.timeZone = TimeZone.getTimeZone("UTC")
|
||||||
|
return df.format(Date())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.runCommand(command: String): String {
|
||||||
|
val byteOut = ByteArrayOutputStream()
|
||||||
|
project.exec {
|
||||||
|
commandLine = command.split(" ")
|
||||||
|
standardOutput = byteOut
|
||||||
|
}
|
||||||
|
return String(byteOut.toByteArray()).trim()
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue