Skip to content

Commit

Permalink
merge43
Browse files Browse the repository at this point in the history
Last Commit Merged: https://github.com/tachiyomiorg/tachiyomi/commit/d62d94f587b801a1f0eadac2f6e98d36f8d9fa93
This should be the last commit for now. Fixes the preview build problem
  • Loading branch information
LuftVerbot committed Jul 23, 2023
1 parent 1bf27a7 commit f70e209
Show file tree
Hide file tree
Showing 28 changed files with 523 additions and 357 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {

defaultConfig {
applicationId = "xyz.jmir.tachiyomi.mi"
versionCode = 101
versionCode = 102
versionName = "0.14.6"

buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
Expand Down
3 changes: 3 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
-dontobfuscate

-keep,allowoptimization class eu.kanade.**
-keep,allowoptimization class tachiyomi.**

# Keep common dependencies used in extensions
-keep,allowoptimization class androidx.preference.** { public protected *; }
-keep,allowoptimization class android.content.** { *; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ object AboutScreen : Screen() {
}
}

private fun getFormattedBuildTime(): String {
internal fun getFormattedBuildTime(): String {
return try {
val inputDf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'", Locale.US)
inputDf.timeZone = TimeZone.getTimeZone("UTC")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,132 @@
package eu.kanade.presentation.more.settings.screen.debug

import androidx.annotation.StringRes
import android.os.Build
import android.webkit.WebView
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.produceState
import androidx.compose.ui.platform.LocalContext
import androidx.profileinstaller.ProfileVerifier
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow
import eu.kanade.presentation.more.settings.Preference
import eu.kanade.presentation.more.settings.screen.SearchableSettings
import eu.kanade.presentation.more.settings.PreferenceScaffold
import eu.kanade.presentation.more.settings.screen.AboutScreen
import eu.kanade.presentation.util.Screen
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.DeviceUtil
import kotlinx.coroutines.guava.await

object DebugInfoScreen : SearchableSettings {
@ReadOnlyComposable
object DebugInfoScreen : Screen() {
@Composable
@StringRes
override fun getTitleRes() = R.string.pref_debug_info
override fun Content() {
val navigator = LocalNavigator.currentOrThrow
PreferenceScaffold(
titleRes = R.string.pref_debug_info,
onBackPressed = navigator::pop,
itemsProvider = {
listOf(
Preference.PreferenceItem.TextPreference(
title = WorkerInfoScreen.title,
onClick = { navigator.push(WorkerInfoScreen) },
),
getAppInfoGroup(),
getDeviceInfoGroup(),
)
},
)
}

@Composable
override fun getPreferences(): List<Preference> {
val navigator = LocalNavigator.currentOrThrow
private fun getAppInfoGroup(): Preference.PreferenceGroup {
return Preference.PreferenceGroup(
title = "App info",
preferenceItems = listOf(
Preference.PreferenceItem.TextPreference(
title = "Version",
subtitle = AboutScreen.getVersionName(false),
),
Preference.PreferenceItem.TextPreference(
title = "Build time",
subtitle = AboutScreen.getFormattedBuildTime(),
),
getProfileVerifierPreference(),
Preference.PreferenceItem.TextPreference(
title = "WebView version",
subtitle = getWebViewVersion(),
),
),
)
}

@Composable
@ReadOnlyComposable
private fun getWebViewVersion(): String {
val webView = WebView.getCurrentWebViewPackage() ?: return "how did you get here?"
val pm = LocalContext.current.packageManager
val label = webView.applicationInfo.loadLabel(pm)
val version = webView.versionName
return "$label $version"
}

@Composable
private fun getProfileVerifierPreference(): Preference.PreferenceItem.TextPreference {
val status by produceState(initialValue = "-") {
val result = ProfileVerifier.getCompilationStatusAsync().await().profileInstallResultCode
value = when (result) {
ProfileVerifier.CompilationStatus.RESULT_CODE_NO_PROFILE -> "No profile installed"
ProfileVerifier.CompilationStatus.RESULT_CODE_COMPILED_WITH_PROFILE -> "Compiled"
ProfileVerifier.CompilationStatus.RESULT_CODE_COMPILED_WITH_PROFILE_NON_MATCHING -> "Compiled non-matching"
ProfileVerifier.CompilationStatus.RESULT_CODE_ERROR_CACHE_FILE_EXISTS_BUT_CANNOT_BE_READ,
ProfileVerifier.CompilationStatus.RESULT_CODE_ERROR_CANT_WRITE_PROFILE_VERIFICATION_RESULT_CACHE_FILE,
ProfileVerifier.CompilationStatus.RESULT_CODE_ERROR_PACKAGE_NAME_DOES_NOT_EXIST,
-> "Error $result"
ProfileVerifier.CompilationStatus.RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION -> "Not supported"
ProfileVerifier.CompilationStatus.RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION -> "Pending compilation"
else -> "Unknown code $result"
}
}
return Preference.PreferenceItem.TextPreference(
title = "Profile compilation status",
subtitle = status,
)
}

return listOf(
private fun getDeviceInfoGroup(): Preference.PreferenceGroup {
val items = mutableListOf(
Preference.PreferenceItem.TextPreference(
title = WorkerInfoScreen.title,
onClick = { navigator.push(WorkerInfoScreen) },
title = "Model",
subtitle = "${Build.MANUFACTURER} ${Build.MODEL} (${Build.DEVICE})",
),
)
if (DeviceUtil.oneUiVersion != null) {
items += Preference.PreferenceItem.TextPreference(
title = "OneUI version",
subtitle = "${DeviceUtil.oneUiVersion}",
)
} else if (DeviceUtil.miuiMajorVersion != null) {
items += Preference.PreferenceItem.TextPreference(
title = "MIUI version",
subtitle = "${DeviceUtil.miuiMajorVersion}",
)
}

val androidVersion = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Build.VERSION.RELEASE_OR_PREVIEW_DISPLAY
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Build.VERSION.RELEASE_OR_CODENAME
} else {
Build.VERSION.RELEASE
}
items += Preference.PreferenceItem.TextPreference(
title = "Android version",
subtitle = "$androidVersion (${Build.DISPLAY})",
)

return Preference.PreferenceGroup(
title = "Device info",
preferenceItems = items,
)
}
}
8 changes: 8 additions & 0 deletions app/src/main/java/eu/kanade/tachiyomi/Migrations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
import eu.kanade.tachiyomi.util.preference.minusAssign
import eu.kanade.tachiyomi.util.preference.plusAssign
import eu.kanade.tachiyomi.util.system.DeviceUtil
import eu.kanade.tachiyomi.util.system.isReleaseBuildType
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.system.workManager
import tachiyomi.core.preference.PreferenceStore
Expand Down Expand Up @@ -449,6 +450,13 @@ object Migrations {
if (oldVersion < 100) {
BackupCreateJob.setupTask(context)
}
if (oldVersion < 102) {
// This was accidentally visible from the reader settings sheet, but should always
// be disabled in release builds.
if (isReleaseBuildType) {
readerPreferences.longStripSplitWebtoon().set(false)
}
}
return true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,26 @@ class AnimeDownloadProvider(
* @param episodeScanlator scanlator of the episode to query
*/
fun getEpisodeDirName(episodeName: String, episodeScanlator: String?): String {
val newEpisodeName = sanitizeEpisodeName(episodeName)
return DiskUtil.buildValidFilename(
when {
episodeScanlator.isNullOrBlank().not() -> "${episodeScanlator}_$episodeName"
else -> episodeName
episodeScanlator.isNullOrBlank().not() -> "${episodeScanlator}_$newEpisodeName"
else -> newEpisodeName
},
)
}

/**
* Return the new name for the episode (in case it's empty or blank)
*
* @param episodeName the name of the episode
*/
private fun sanitizeEpisodeName(episodeName: String): String {
return episodeName.ifBlank {
"Episode"
}
}

/**
* Returns the episode directory name for an episode.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,26 @@ class MangaDownloadProvider(
* @param chapterScanlator scanlator of the chapter to query
*/
fun getChapterDirName(chapterName: String, chapterScanlator: String?): String {
val newChapterName = sanitizeChapterName(chapterName)
return DiskUtil.buildValidFilename(
when {
chapterScanlator.isNullOrBlank().not() -> "${chapterScanlator}_$chapterName"
else -> chapterName
chapterScanlator.isNullOrBlank().not() -> "${chapterScanlator}_$newChapterName"
else -> newChapterName
},
)
}

/**
* Return the new name for the chapter (in case it's empty or blank)
*
* @param chapterName the name of the chapter
*/
private fun sanitizeChapterName(chapterName: String): String {
return chapterName.ifBlank {
"Chapter"
}
}

fun isChapterDirNameChanged(oldChapter: Chapter, newChapter: Chapter): Boolean {
return oldChapter.name != newChapter.name ||
oldChapter.scanlator?.takeIf { it.isNotBlank() } != newChapter.scanlator?.takeIf { it.isNotBlank() }
Expand Down
Loading

0 comments on commit f70e209

Please sign in to comment.