mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 02:34:39 +00:00
parent
2040462c49
commit
20aa3c6e2d
8 changed files with 42 additions and 98 deletions
|
@ -17,6 +17,10 @@ if (gradle.startParameter.taskRequests.toString().contains("Standard")) {
|
|||
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 {
|
||||
val byteOut = ByteArrayOutputStream()
|
||||
project.exec {
|
||||
|
@ -42,11 +46,9 @@ android {
|
|||
multiDexEnabled = true
|
||||
|
||||
buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
|
||||
buildConfigField("String", "BETA_COMMIT_COUNT", "\"${getCommitCountSinceLastRelease()}\"")
|
||||
buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
|
||||
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime()}\"")
|
||||
buildConfigField("Boolean", "INCLUDE_UPDATER", "false")
|
||||
buildConfigField("boolean", "BETA", "false")
|
||||
|
||||
ndk {
|
||||
abiFilters += supportedAbis
|
||||
|
@ -79,7 +81,6 @@ android {
|
|||
buildTypes {
|
||||
getByName("debug") {
|
||||
applicationIdSuffix = ".debugJ2K"
|
||||
versionNameSuffix = "-d${getCommitCount()}"
|
||||
}
|
||||
getByName("release") {
|
||||
applicationIdSuffix = ".j2k"
|
||||
|
@ -87,12 +88,6 @@ android {
|
|||
isMinifyEnabled = true
|
||||
proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
|
||||
}
|
||||
create("beta") {
|
||||
initWith(getByName("release"))
|
||||
buildConfigField("boolean", "BETA", "true")
|
||||
|
||||
versionNameSuffix = "-b${getCommitCountSinceLastRelease()}"
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
|
@ -183,7 +178,6 @@ dependencies {
|
|||
val chuckerVersion = "3.5.2"
|
||||
debugImplementation("com.github.ChuckerTeam.Chucker:library:$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))
|
||||
|
||||
|
|
|
@ -225,6 +225,8 @@ object PreferenceKeys {
|
|||
|
||||
const val sideNavMode = "side_nav_mode"
|
||||
|
||||
const val checkForBetas = "check_for_betas"
|
||||
|
||||
const val shouldAutoUpdate = "should_auto_update"
|
||||
|
||||
const val autoUpdateExtensions = "auto_update_extensions"
|
||||
|
|
|
@ -8,7 +8,6 @@ import androidx.preference.PreferenceManager
|
|||
import com.fredporciuncula.flow.preferences.FlowSharedPreferences
|
||||
import com.fredporciuncula.flow.preferences.Preference
|
||||
import com.google.android.material.color.DynamicColors
|
||||
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
|
||||
|
@ -374,7 +373,7 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun lastAppCheck() = flowPrefs.getLong("last_app_check", 0)
|
||||
|
||||
fun checkForBetas() = flowPrefs.getBoolean("check_for_betas", BuildConfig.BETA)
|
||||
fun checkForBetas() = prefs.getBoolean(Keys.checkForBetas, false)
|
||||
|
||||
fun unreadBadgeType() = flowPrefs.getInt("unread_badge_type", 2)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class AppUpdateChecker {
|
|||
}
|
||||
|
||||
return withIOContext {
|
||||
val result = if (preferences.checkForBetas().get()) {
|
||||
val result = if (preferences.checkForBetas()) {
|
||||
networkService.client
|
||||
.newCall(GET("https://api.github.com/repos/$GITHUB_REPO/releases"))
|
||||
.await()
|
||||
|
@ -72,25 +72,17 @@ class AppUpdateChecker {
|
|||
|
||||
private fun isNewVersion(versionTag: String): Boolean {
|
||||
// Removes prefixes like "r" or "v"
|
||||
val newVersion = versionTag.replace("[^\\d.-]".toRegex(), "")
|
||||
val oldVersion = BuildConfig.VERSION_NAME.replace("[^\\d.-]".toRegex(), "")
|
||||
val newPreReleaseVer = newVersion.split("-")
|
||||
val oldPreReleaseVer = oldVersion.split("-")
|
||||
val newSemVer = newPreReleaseVer.first().split(".").map { it.toInt() }
|
||||
val oldSemVer = oldPreReleaseVer.first().split(".").map { it.toInt() }
|
||||
val newVersion = versionTag.replace("-", ".").replace("[^\\d.]".toRegex(), "")
|
||||
val oldVersion = BuildConfig.VERSION_NAME.replace("-", ".").replace("[^\\d.]".toRegex(), "")
|
||||
val newSemVer = newVersion.split(".").map { it.toInt() }
|
||||
val oldSemVer = oldVersion.split(".").map { it.toInt() }
|
||||
|
||||
oldSemVer.mapIndexed { index, i ->
|
||||
if (newSemVer.getOrElse(index) { i } > i) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
// 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)
|
||||
}
|
||||
return newSemVer.size > oldSemVer.size
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ import android.content.res.ColorStateList
|
|||
import android.graphics.Color
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.text.buildSpannedString
|
||||
import androidx.core.text.color
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||
|
@ -16,7 +14,6 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||
import eu.kanade.tachiyomi.data.preference.toggle
|
||||
import eu.kanade.tachiyomi.databinding.TachiOverflowLayoutBinding
|
||||
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.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
|
@ -82,17 +79,7 @@ class OverflowDialog(activity: MainActivity) : Dialog(activity, R.style.Overflow
|
|||
dismiss()
|
||||
}
|
||||
|
||||
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.text = context.getString(R.string.about).withSubtitle(binding.aboutItem.context, "v${BuildConfig.VERSION_NAME}")
|
||||
|
||||
binding.aboutItem.setOnClickListener {
|
||||
activity.showAbout()
|
||||
|
|
|
@ -58,6 +58,7 @@ import uy.kohesive.injekt.Injekt
|
|||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
|
||||
class SettingsAdvancedController : SettingsController() {
|
||||
|
||||
|
@ -128,15 +129,27 @@ class SettingsAdvancedController : SettingsController() {
|
|||
switchPreference {
|
||||
titleRes = R.string.check_for_beta_releases
|
||||
summaryRes = R.string.try_new_features
|
||||
bindTo(preferences.checkForBetas())
|
||||
key = Keys.checkForBetas
|
||||
|
||||
onChange {
|
||||
it as Boolean
|
||||
if ((!it && BuildConfig.BETA) || (it && !BuildConfig.BETA)) {
|
||||
if (!it && BuildConfig.VERSION_NAME.contains("-b")) {
|
||||
activity!!.materialAlertDialog()
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(if (it) R.string.warning_enroll_into_beta else R.string.warning_unenroll_from_beta)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ -> isChecked = it }
|
||||
.setMessage(R.string.warning_unenroll_from_beta)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
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)
|
||||
.show()
|
||||
false
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.kanade.tachiyomi.util.lang
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.text.SpannableStringBuilder
|
||||
|
@ -8,15 +9,15 @@ import android.text.Spanned
|
|||
import android.text.SpannedString
|
||||
import android.text.style.BackgroundColorSpan
|
||||
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 androidx.annotation.ColorInt
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.text.bold
|
||||
import androidx.core.text.buildSpannedString
|
||||
import androidx.core.text.color
|
||||
import androidx.core.text.inSpans
|
||||
import androidx.core.text.scale
|
||||
import androidx.core.text.superscript
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import net.greypanther.natsort.CaseInsensitiveSimpleNaturalComparator
|
||||
|
@ -154,9 +155,6 @@ fun String.indexesOf(substr: String, ignoreCase: Boolean = true): List<Int> {
|
|||
fun String.withSubtitle(context: Context, @StringRes subtitleRes: Int) =
|
||||
withSubtitle(context, context.getString(subtitleRes))
|
||||
|
||||
fun String.withSubtitle(subtitle: Spanned): Spanned =
|
||||
SpannableStringBuilder(this + "\n").append(subtitle)
|
||||
|
||||
fun String.withSubtitle(context: Context, subtitle: String): Spanned {
|
||||
val spannable = SpannableStringBuilder(this + "\n" + subtitle)
|
||||
spannable.setSpan(
|
||||
|
@ -168,16 +166,14 @@ fun String.withSubtitle(context: Context, subtitle: String): Spanned {
|
|||
return spannable
|
||||
}
|
||||
|
||||
fun String.addBetaTag(context: Context, useSuperScript: Boolean = true): Spanned {
|
||||
fun String.addBetaTag(context: Context): Spanned {
|
||||
val betaText = context.getString(R.string.beta)
|
||||
val colorS = context.getResourceColor(R.attr.colorSecondary)
|
||||
return buildSpannedString {
|
||||
append(this@addBetaTag)
|
||||
val buttonSpan: SpannableStringBuilder.() -> Unit = {
|
||||
bold { scale(0.75f) { color(colorS) { append(betaText) } } }
|
||||
}
|
||||
if (useSuperScript) superscript(buttonSpan) else buttonSpan()
|
||||
}
|
||||
val betaSpan = SpannableStringBuilder(this + betaText)
|
||||
betaSpan.setSpan(SuperscriptSpan(), length, length + betaText.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
betaSpan.setSpan(RelativeSizeSpan(0.75f), length, length + betaText.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
betaSpan.setSpan(StyleSpan(Typeface.BOLD), length, length + betaText.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
betaSpan.setSpan(ForegroundColorSpan(context.getResourceColor(R.attr.colorSecondary)), length, length + betaText.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
return betaSpan
|
||||
}
|
||||
|
||||
fun String.toNormalized(): String = replace("’", "'")
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
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