Compare commits

...

13 Commits

Author SHA1 Message Date
Jobobby04 bbaa74d99c Fix build 2024-10-20 01:51:54 -04:00
AntsyLich 310b1ad69b Pass uncaught exception to default handler in GlobalExceptionHandler
Fixes #1347

(cherry picked from commit f3a2f566c8a09ab862758ae69b43da2a2cd8f1db)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/crash/GlobalExceptionHandler.kt
2024-10-20 01:04:23 -04:00
AntsyLich 7f37989c4e Rework Firebase setup
Fixes #1332
Closes #1339

(cherry picked from commit 15e3f28aa36bec3c31f212c572ab57ce960cc862)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/App.kt
2024-10-20 01:03:36 -04:00
AntsyLich 185920b984 Address deprecation, suggestion and spotless
(cherry picked from commit 3bf70b230fc2c3eda58c4d46dec3fb75668e4f69)
2024-10-20 01:02:06 -04:00
AntsyLich 4639077756 Revert "Tweak Preference.collectAsState"
This reverts commit 3bddb5538528c19388e364d21e6a6c16487af759.

Fixes #1341

(cherry picked from commit eb3bea8150ce9bf2320d15c879cbebaa6d51a4c6)
2024-10-20 01:01:58 -04:00
Mend Renovate 0bf1519c25 Update dependency androidx.compose:compose-bom to v2024.10.00 (#1338)
(cherry picked from commit 5612ae0149e9231c9691ee782da8159489a0d057)
2024-10-20 01:01:48 -04:00
Mend Renovate 45a36cef32 Update xml.serialization.version to v0.90.2 (#1331)
* Update xml.serialization.version to v0.90.2

* Fix build

---------

Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
(cherry picked from commit dbf6ad2ca7e0525f597010709e87d094d10e4f8d)

# Conflicts:
#	source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt
2024-10-20 01:01:41 -04:00
AntsyLich dece1bc0cb Change "Invalidate downloads index" to "Reindex downloads"
(cherry picked from commit d2afbfe4ede283076aae40633c79c3f90b4390e7)
2024-10-20 01:01:09 -04:00
Mend Renovate eaffd3f2dc Update dependency androidx.annotation:annotation to v1.9.0 (#1336)
(cherry picked from commit 337806d9e17e92a9134d59324e9857d05abc4db3)
2024-10-20 01:00:58 -04:00
Mend Renovate aabe409ee5 Update dependency androidx.glance:glance-appwidget to v1.1.1 (#1335)
(cherry picked from commit 443f6e0ae53dadce1f66818fac0cd1eeaa5fec27)
2024-10-20 01:00:50 -04:00
Mend Renovate e626cdd030 Update dependency androidx.benchmark:benchmark-macro-junit4 to v1.3.3 (#1334)
(cherry picked from commit 572ee2f02a980a60a1120e7c0c88060fb1a7b3d2)
2024-10-20 01:00:43 -04:00
Mend Renovate b161c333ec Update dependency androidx.activity:activity-compose to v1.9.3 (#1333)
(cherry picked from commit ba1343bed8c00d5ed976111c710c9b5648676a59)
2024-10-20 01:00:36 -04:00
FlaminSarge e587bb7f44 [skip ci] Update i18n readme (#1328)
(cherry picked from commit 9f3d5d13d4fedcca53ebb779a2cfca1e286c79da)
2024-10-20 01:00:26 -04:00
16 changed files with 107 additions and 100 deletions
@@ -1,9 +0,0 @@
package mihon.core.firebase
import android.content.Context
import eu.kanade.tachiyomi.core.security.PrivacyPreferences
import kotlinx.coroutines.CoroutineScope
object Firebase {
fun setup(context: Context, preference: PrivacyPreferences, scope: CoroutineScope) = Unit
}
@@ -0,0 +1,11 @@
package mihon.core.firebase
import android.content.Context
object FirebaseConfig {
fun init(context: Context) = Unit
fun setAnalyticsEnabled(enabled: Boolean) = Unit
fun setCrashlyticsEnabled(enabled: Boolean) = Unit
}
@@ -25,7 +25,7 @@ import androidx.compose.ui.unit.dp
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
import kotlinx.serialization.Serializable
import nl.adaptivity.xmlutil.AndroidXmlReader
import nl.adaptivity.xmlutil.core.AndroidXmlReader
import nl.adaptivity.xmlutil.serialization.XML
import nl.adaptivity.xmlutil.serialization.XmlSerialName
import nl.adaptivity.xmlutil.serialization.XmlValue
+16 -7
View File
@@ -71,7 +71,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import logcat.LogPriority
import logcat.LogcatLogger
import mihon.core.firebase.Firebase
import mihon.core.firebase.FirebaseConfig
import mihon.core.migration.Migrator
import mihon.core.migration.migrations.migrations
import org.conscrypt.Conscrypt
@@ -100,6 +100,7 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
@SuppressLint("LaunchActivityFromNotification")
override fun onCreate() {
super<Application>.onCreate()
FirebaseConfig.init(applicationContext)
GlobalExceptionHandler.initialize(applicationContext, CrashActivity::class.java)
@@ -127,12 +128,12 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
setupExhLogging() // EXH logging
LogcatLogger.install(XLogLogcatLogger()) // SY Redirect Logcat to XLog
Firebase.setup(applicationContext, privacyPreferences, ProcessLifecycleOwner.get().lifecycleScope)
setupNotificationChannels()
ProcessLifecycleOwner.get().lifecycle.addObserver(this)
val scope = ProcessLifecycleOwner.get().lifecycleScope
// Show notification to disable Incognito Mode when it's enabled
basePreferences.incognitoMode().changes()
.onEach { enabled ->
@@ -160,14 +161,22 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
cancelNotification(Notifications.ID_INCOGNITO_MODE)
}
}
.launchIn(ProcessLifecycleOwner.get().lifecycleScope)
.launchIn(scope)
privacyPreferences.analytics()
.changes()
.onEach(FirebaseConfig::setAnalyticsEnabled)
.launchIn(scope)
privacyPreferences.crashlytics()
.changes()
.onEach(FirebaseConfig::setCrashlyticsEnabled)
.launchIn(scope)
setAppCompatDelegateThemeMode(Injekt.get<UiPreferences>().themeMode().get())
// Updates widget update
with(WidgetManager(Injekt.get(), Injekt.get())) {
init(ProcessLifecycleOwner.get().lifecycleScope)
}
WidgetManager(Injekt.get(), Injekt.get()).apply { init(scope) }
/*if (!LogcatLogger.isInstalled && networkPreferences.verboseLogging().get()) {
LogcatLogger.install(AndroidLogcatLogger(LogPriority.VERBOSE))
@@ -2,8 +2,6 @@ package eu.kanade.tachiyomi.crash
import android.content.Context
import android.content.Intent
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
@@ -13,7 +11,6 @@ import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.Json
import logcat.LogPriority
import tachiyomi.core.common.util.system.logcat
import kotlin.system.exitProcess
class GlobalExceptionHandler private constructor(
private val applicationContext: Context,
@@ -33,14 +30,9 @@ class GlobalExceptionHandler private constructor(
}
override fun uncaughtException(thread: Thread, exception: Throwable) {
try {
logcat(priority = LogPriority.ERROR, throwable = exception)
Firebase.crashlytics.recordException(exception)
launchActivity(applicationContext, activityToBeLaunched, exception)
exitProcess(0)
} catch (_: Exception) {
defaultHandler.uncaughtException(thread, exception)
}
logcat(priority = LogPriority.ERROR, throwable = exception)
launchActivity(applicationContext, activityToBeLaunched, exception)
defaultHandler.uncaughtException(thread, exception)
}
private fun launchActivity(
@@ -96,13 +96,13 @@ class DownloadCache(
private val diskCacheFile: File
get() = File(context.cacheDir, "dl_index_cache_v3")
private val rootDownloadsDirLock = Mutex()
private val rootDownloadsDirMutex = Mutex()
private var rootDownloadsDir = RootDirectory(storageManager.getDownloadsDirectory())
init {
// Attempt to read cache file
scope.launch {
rootDownloadsDirLock.withLock {
rootDownloadsDirMutex.withLock {
try {
if (diskCacheFile.exists()) {
val diskCache = diskCacheFile.inputStream().use {
@@ -112,7 +112,7 @@ class DownloadCache(
lastRenew = System.currentTimeMillis()
}
} catch (e: Throwable) {
logcat(LogPriority.ERROR, e) { "Failed to initialize disk cache" }
logcat(LogPriority.ERROR, e) { "Failed to initialize from disk cache" }
diskCacheFile.delete()
}
}
@@ -200,7 +200,7 @@ class DownloadCache(
* @param manga the manga of the chapter.
*/
suspend fun addChapter(chapterDirName: String, mangaUniFile: UniFile, manga: Manga) {
rootDownloadsDirLock.withLock {
rootDownloadsDirMutex.withLock {
// Retrieve the cached source directory or cache a new one
var sourceDir = rootDownloadsDir.sourceDirs[manga.source]
if (sourceDir == null) {
@@ -232,7 +232,7 @@ class DownloadCache(
* @param manga the manga of the chapter.
*/
suspend fun removeChapter(chapter: Chapter, manga: Manga) {
rootDownloadsDirLock.withLock {
rootDownloadsDirMutex.withLock {
val sourceDir = rootDownloadsDir.sourceDirs[manga.source] ?: return
val mangaDir = sourceDir.mangaDirs[
provider.getMangaDirName(
@@ -251,7 +251,7 @@ class DownloadCache(
// SY -->
suspend fun removeFolders(folders: List<String>, manga: Manga) {
rootDownloadsDirLock.withLock {
rootDownloadsDirMutex.withLock {
val sourceDir = rootDownloadsDir.sourceDirs[manga.source] ?: return
val mangaDir = sourceDir.mangaDirs[provider.getMangaDirName(manga.ogTitle)] ?: return
folders.forEach { chapter ->
@@ -271,7 +271,7 @@ class DownloadCache(
* @param manga the manga of the chapter.
*/
suspend fun removeChapters(chapters: List<Chapter>, manga: Manga) {
rootDownloadsDirLock.withLock {
rootDownloadsDirMutex.withLock {
val sourceDir = rootDownloadsDir.sourceDirs[manga.source] ?: return
val mangaDir = sourceDir.mangaDirs[
provider.getMangaDirName(
@@ -296,7 +296,7 @@ class DownloadCache(
* @param manga the manga to remove.
*/
suspend fun removeManga(manga: Manga) {
rootDownloadsDirLock.withLock {
rootDownloadsDirMutex.withLock {
val sourceDir = rootDownloadsDir.sourceDirs[manga.source] ?: return
val mangaDirName = provider.getMangaDirName(/* SY --> */ manga.ogTitle /* SY <-- */)
if (sourceDir.mangaDirs.containsKey(mangaDirName)) {
@@ -308,7 +308,7 @@ class DownloadCache(
}
suspend fun removeSource(source: Source) {
rootDownloadsDirLock.withLock {
rootDownloadsDirMutex.withLock {
rootDownloadsDir.sourceDirs -= source.id
}
@@ -349,10 +349,10 @@ class DownloadCache(
val sourceMap = sources.associate { provider.getSourceDirName(it).lowercase() to it.id }
rootDownloadsDirLock.withLock {
rootDownloadsDir = RootDirectory(storageManager.getDownloadsDirectory())
rootDownloadsDirMutex.withLock {
val updatedRootDir = RootDirectory(storageManager.getDownloadsDirectory())
val sourceDirs = rootDownloadsDir.dir?.listFiles().orEmpty()
updatedRootDir.sourceDirs = updatedRootDir.dir?.listFiles().orEmpty()
.filter { it.isDirectory && !it.name.isNullOrBlank() }
.mapNotNull { dir ->
val sourceId = sourceMap[dir.name!!.lowercase()]
@@ -360,36 +360,35 @@ class DownloadCache(
}
.toMap()
rootDownloadsDir.sourceDirs = sourceDirs
updatedRootDir.sourceDirs.values.map { sourceDir ->
async {
sourceDir.mangaDirs = sourceDir.dir?.listFiles().orEmpty()
.filter { it.isDirectory && !it.name.isNullOrBlank() }
.associate { it.name!! to MangaDirectory(it) }
sourceDirs.values
.map { sourceDir ->
async {
sourceDir.mangaDirs = sourceDir.dir?.listFiles().orEmpty()
.filter { it.isDirectory && !it.name.isNullOrBlank() }
.associate { it.name!! to MangaDirectory(it) }
sourceDir.mangaDirs.values.forEach { mangaDir ->
val chapterDirs = mangaDir.dir?.listFiles().orEmpty()
.mapNotNull {
when {
// Ignore incomplete downloads
it.name?.endsWith(Downloader.TMP_DIR_SUFFIX) == true -> null
// Folder of images
it.isDirectory -> it.name
// CBZ files
it.isFile && it.extension == "cbz" -> it.nameWithoutExtension
// Anything else is irrelevant
else -> null
}
sourceDir.mangaDirs.values.forEach { mangaDir ->
val chapterDirs = mangaDir.dir?.listFiles().orEmpty()
.mapNotNull {
when {
// Ignore incomplete downloads
it.name?.endsWith(Downloader.TMP_DIR_SUFFIX) == true -> null
// Folder of images
it.isDirectory -> it.name
// CBZ files
it.isFile && it.extension == "cbz" -> it.nameWithoutExtension
// Anything else is irrelevant
else -> null
}
.toMutableSet()
}
.toMutableSet()
mangaDir.chapterDirs = chapterDirs
}
mangaDir.chapterDirs = chapterDirs
}
}
}
.awaitAll()
rootDownloadsDir = updatedRootDir
}
_isInitializing.emit(false)
@@ -346,12 +346,13 @@ class MainActivity : BaseActivity() {
@Composable
private fun HandleOnNewIntent(context: Context, navigator: Navigator) {
LaunchedEffect(Unit) {
callbackFlow<Intent> {
callbackFlow {
val componentActivity = context as ComponentActivity
val consumer = Consumer<Intent> { trySend(it) }
componentActivity.addOnNewIntentListener(consumer)
awaitClose { componentActivity.removeOnNewIntentListener(consumer) }
}.collectLatest { handleIntentAction(it, navigator) }
}
.collectLatest { handleIntentAction(it, navigator) }
}
}
@@ -407,6 +408,7 @@ class MainActivity : BaseActivity() {
* When custom animation is used, status and navigation bar color will be set to transparent and will be restored
* after the animation is finished.
*/
@Suppress("Deprecation")
private fun setSplashScreenExitAnimation(splashScreen: SplashScreen?) {
val root = findViewById<View>(android.R.id.content)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S && splashScreen != null) {
@@ -1,20 +0,0 @@
package mihon.core.firebase
import android.content.Context
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import eu.kanade.tachiyomi.core.security.PrivacyPreferences
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
object Firebase {
fun setup(context: Context, preference: PrivacyPreferences, scope: CoroutineScope) {
preference.analytics().changes().onEach { enabled ->
FirebaseAnalytics.getInstance(context).setAnalyticsCollectionEnabled(enabled)
}.launchIn(scope)
preference.crashlytics().changes().onEach { enabled ->
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(enabled)
}.launchIn(scope)
}
}
@@ -0,0 +1,25 @@
package mihon.core.firebase
import android.content.Context
import com.google.firebase.FirebaseApp
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
object FirebaseConfig {
private lateinit var analytics: FirebaseAnalytics
private lateinit var crashlytics: FirebaseCrashlytics
fun init(context: Context) {
analytics = FirebaseAnalytics.getInstance(context)
FirebaseApp.initializeApp(context)
crashlytics = FirebaseCrashlytics.getInstance()
}
fun setAnalyticsEnabled(enabled: Boolean) {
analytics.setAnalyticsCollectionEnabled(enabled)
}
fun setCrashlyticsEnabled(enabled: Boolean) {
crashlytics.isCrashlyticsCollectionEnabled = enabled
}
}
+2 -2
View File
@@ -7,7 +7,7 @@ interpolator_version = "1.0.0"
[libraries]
gradle = { module = "com.android.tools.build:gradle", version.ref = "agp_version" }
annotation = "androidx.annotation:annotation:1.8.2"
annotation = "androidx.annotation:annotation:1.9.0"
appcompat = "androidx.appcompat:appcompat:1.7.0"
biometricktx = "androidx.biometric:biometric-ktx:1.2.0-alpha05"
constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4"
@@ -28,7 +28,7 @@ paging-compose = { module = "androidx.paging:paging-compose", version.ref = "pag
interpolator = { group = "androidx.interpolator", name = "interpolator", version.ref = "interpolator_version" }
benchmark-macro = "androidx.benchmark:benchmark-macro-junit4:1.3.2"
benchmark-macro = "androidx.benchmark:benchmark-macro-junit4:1.3.3"
test-ext = "androidx.test.ext:junit-ktx:1.2.1"
test-espresso-core = "androidx.test.espresso:espresso-core:3.6.1"
test-uiautomator = "androidx.test.uiautomator:uiautomator:2.3.0"
+3 -3
View File
@@ -1,8 +1,8 @@
[versions]
compose-bom = "2024.09.03"
compose-bom = "2024.10.00"
[libraries]
activity = "androidx.activity:activity-compose:1.9.2"
activity = "androidx.activity:activity-compose:1.9.3"
bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
foundation = { module = "androidx.compose.foundation:foundation" }
animation = { module = "androidx.compose.animation:animation" }
@@ -15,4 +15,4 @@ ui-util = { module = "androidx.compose.ui:ui-util" }
material3-core = { module = "androidx.compose.material3:material3" }
material-icons = { module = "androidx.compose.material:material-icons-extended" }
glance = "androidx.glance:glance-appwidget:1.1.0"
glance = "androidx.glance:glance-appwidget:1.1.1"
+1 -1
View File
@@ -1,7 +1,7 @@
[versions]
kotlin_version = "2.0.21"
serialization_version = "1.7.3"
xml_serialization_version = "0.86.3"
xml_serialization_version = "0.90.2"
[libraries]
reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin_version" }
+1 -1
View File
@@ -2,4 +2,4 @@
This module houses the string resources and translations.
Original English strings are manged in `src/commonMain/resources/MR/base/`. Translations are done externally via Weblate. See [our website](https://mihon.app/docs/contribute#translation) for more details.
Original English strings are managed in `src/commonMain/moko-resources/base/`. Translations are done externally via Weblate. See [our website](https://mihon.app/docs/contribute#translation) for more details.
@@ -582,7 +582,7 @@
<string name="pref_reset_user_agent_string">Reset default user agent string</string>
<string name="requires_app_restart">Requires app restart to take effect</string>
<string name="cookies_cleared">Cookies cleared</string>
<string name="pref_invalidate_download_cache">Invalidate downloads index</string>
<string name="pref_invalidate_download_cache">Reindex downloads</string>
<string name="pref_invalidate_download_cache_summary">Force app to recheck downloaded chapters</string>
<string name="download_cache_invalidated">Downloads index invalidated</string>
<string name="pref_clear_database">Clear database</string>
@@ -4,12 +4,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import kotlinx.coroutines.CoroutineScope
import tachiyomi.core.common.preference.Preference
@Composable
fun <T> Preference<T>.collectAsState(scope: CoroutineScope = rememberCoroutineScope()): State<T> {
val flow = remember(this) { stateIn(scope) }
return flow.collectAsState()
fun <T> Preference<T>.collectAsState(): State<T> {
val flow = remember(this) { changes() }
return flow.collectAsState(initial = get())
}
@@ -19,7 +19,7 @@ import kotlinx.serialization.json.decodeFromStream
import logcat.LogPriority
import mihon.core.common.archive.ZipWriter
import mihon.core.common.archive.archiveReader
import nl.adaptivity.xmlutil.AndroidXmlReader
import nl.adaptivity.xmlutil.core.AndroidXmlReader
import nl.adaptivity.xmlutil.serialization.XML
import tachiyomi.core.common.i18n.stringResource
import tachiyomi.core.common.storage.extension