fix: rearrange some stuff
This commit is contained in:
parent
143eed8cb2
commit
4ccf6fa1c8
3 changed files with 28 additions and 41 deletions
|
@ -38,8 +38,8 @@ import logcat.AndroidLogcatLogger
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
import logcat.LogcatLogger
|
import logcat.LogcatLogger
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.addSingletonFactory
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.lang.IllegalStateException
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
@ -64,13 +64,19 @@ class App : MultiDexApplication() {
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
|
||||||
PrefManager.init(this)
|
PrefManager.init(this)
|
||||||
|
|
||||||
|
val crashlytics =
|
||||||
|
ani.dantotsu.connections.crashlytics.CrashlyticsFactory.createCrashlytics()
|
||||||
|
Injekt.addSingletonFactory<CrashlyticsInterface> { crashlytics }
|
||||||
|
crashlytics.initialize(this)
|
||||||
|
Logger.init(this)
|
||||||
|
Thread.setDefaultUncaughtExceptionHandler(FinalExceptionHandler())
|
||||||
|
Logger.log(Log.WARN, "App: Logging started")
|
||||||
|
|
||||||
Injekt.importModule(AppModule(this))
|
Injekt.importModule(AppModule(this))
|
||||||
Injekt.importModule(PreferenceModule(this))
|
Injekt.importModule(PreferenceModule(this))
|
||||||
|
|
||||||
val crashlytics = Injekt.get<CrashlyticsInterface>()
|
|
||||||
crashlytics.initialize(this)
|
|
||||||
|
|
||||||
val useMaterialYou: Boolean = PrefManager.getVal(PrefName.UseMaterialYou)
|
val useMaterialYou: Boolean = PrefManager.getVal(PrefName.UseMaterialYou)
|
||||||
if (useMaterialYou) {
|
if (useMaterialYou) {
|
||||||
|
@ -92,10 +98,6 @@ class App : MultiDexApplication() {
|
||||||
}
|
}
|
||||||
crashlytics.setCustomKey("device Info", SettingsActivity.getDeviceInfo())
|
crashlytics.setCustomKey("device Info", SettingsActivity.getDeviceInfo())
|
||||||
|
|
||||||
Logger.init(this)
|
|
||||||
Thread.setDefaultUncaughtExceptionHandler(FinalExceptionHandler())
|
|
||||||
Logger.log(Log.WARN, "App: Logging started")
|
|
||||||
|
|
||||||
initializeNetwork()
|
initializeNetwork()
|
||||||
|
|
||||||
setupNotificationChannels()
|
setupNotificationChannels()
|
||||||
|
@ -154,6 +156,7 @@ class App : MultiDexApplication() {
|
||||||
override fun onActivityCreated(p0: Activity, p1: Bundle?) {
|
override fun onActivityCreated(p0: Activity, p1: Bundle?) {
|
||||||
lastActivity = p0.javaClass.simpleName
|
lastActivity = p0.javaClass.simpleName
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityStarted(p0: Activity) {
|
override fun onActivityStarted(p0: Activity) {
|
||||||
currentActivity = p0
|
currentActivity = p0
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,10 +60,6 @@ class AppModule(val app: Application) : InjektModule {
|
||||||
|
|
||||||
addSingletonFactory { StandaloneDatabaseProvider(app) }
|
addSingletonFactory { StandaloneDatabaseProvider(app) }
|
||||||
|
|
||||||
addSingletonFactory<CrashlyticsInterface> {
|
|
||||||
ani.dantotsu.connections.crashlytics.CrashlyticsFactory.createCrashlytics()
|
|
||||||
}
|
|
||||||
|
|
||||||
addSingletonFactory { MangaCache() }
|
addSingletonFactory { MangaCache() }
|
||||||
|
|
||||||
ContextCompat.getMainExecutor(app).execute {
|
ContextCompat.getMainExecutor(app).execute {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.pm.PackageInfo
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.core.content.pm.PackageInfoCompat
|
import androidx.core.content.pm.PackageInfoCompat
|
||||||
|
import ani.dantotsu.connections.crashlytics.CrashlyticsInterface
|
||||||
import ani.dantotsu.media.MediaType
|
import ani.dantotsu.media.MediaType
|
||||||
import ani.dantotsu.parsers.NovelInterface
|
import ani.dantotsu.parsers.NovelInterface
|
||||||
import ani.dantotsu.parsers.novel.NovelExtension
|
import ani.dantotsu.parsers.novel.NovelExtension
|
||||||
|
@ -26,6 +27,8 @@ import eu.kanade.tachiyomi.util.lang.Hash
|
||||||
import eu.kanade.tachiyomi.util.system.getApplicationIcon
|
import eu.kanade.tachiyomi.util.system.getApplicationIcon
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
|
@ -255,22 +258,6 @@ internal object ExtensionLoader {
|
||||||
|
|
||||||
val signatureHash = getSignatureHash(pkgInfo)
|
val signatureHash = getSignatureHash(pkgInfo)
|
||||||
|
|
||||||
if (signatureHash == null) {
|
|
||||||
Logger.log("Package $pkgName isn't signed")
|
|
||||||
return AnimeLoadResult.Error
|
|
||||||
} else if (signatureHash !in trustedSignaturesAnime) {
|
|
||||||
val extension = AnimeExtension.Untrusted(
|
|
||||||
extName,
|
|
||||||
pkgName,
|
|
||||||
versionName,
|
|
||||||
versionCode,
|
|
||||||
libVersion,
|
|
||||||
signatureHash
|
|
||||||
)
|
|
||||||
Logger.log("Extension $pkgName isn't trusted")
|
|
||||||
return AnimeLoadResult.Untrusted(extension)
|
|
||||||
}
|
|
||||||
|
|
||||||
val isNsfw = appInfo.metaData.getInt("$ANIME_PACKAGE$XX_METADATA_NSFW") == 1
|
val isNsfw = appInfo.metaData.getInt("$ANIME_PACKAGE$XX_METADATA_NSFW") == 1
|
||||||
if (!loadNsfwSource && isNsfw) {
|
if (!loadNsfwSource && isNsfw) {
|
||||||
Logger.log("NSFW extension $pkgName not allowed")
|
Logger.log("NSFW extension $pkgName not allowed")
|
||||||
|
@ -281,7 +268,13 @@ internal object ExtensionLoader {
|
||||||
val hasChangelog =
|
val hasChangelog =
|
||||||
appInfo.metaData.getInt("$ANIME_PACKAGE$XX_METADATA_HAS_CHANGELOG", 0) == 1
|
appInfo.metaData.getInt("$ANIME_PACKAGE$XX_METADATA_HAS_CHANGELOG", 0) == 1
|
||||||
|
|
||||||
val classLoader = PathClassLoader(appInfo.sourceDir, null, context.classLoader)
|
val classLoader = try{
|
||||||
|
PathClassLoader(appInfo.sourceDir, null, context.classLoader)
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
Logger.log("Extension load error: $extName")
|
||||||
|
Injekt.get<CrashlyticsInterface>().logException(e)
|
||||||
|
return AnimeLoadResult.Error
|
||||||
|
}
|
||||||
|
|
||||||
val sources = appInfo.metaData.getString("$ANIME_PACKAGE$XX_METADATA_SOURCE_CLASS")!!
|
val sources = appInfo.metaData.getString("$ANIME_PACKAGE$XX_METADATA_SOURCE_CLASS")!!
|
||||||
.split(";")
|
.split(";")
|
||||||
|
@ -371,17 +364,6 @@ internal object ExtensionLoader {
|
||||||
|
|
||||||
val signatureHash = getSignatureHash(pkgInfo)
|
val signatureHash = getSignatureHash(pkgInfo)
|
||||||
|
|
||||||
/* temporarily disabling signature check TODO: remove?
|
|
||||||
if (signatureHash == null) {
|
|
||||||
Logger.log("Package $pkgName isn't signed")
|
|
||||||
return MangaLoadResult.Error
|
|
||||||
} else if (signatureHash !in trustedSignatures) {
|
|
||||||
val extension = MangaExtension.Untrusted(extName, pkgName, versionName, versionCode, libVersion, signatureHash)
|
|
||||||
Logger.log("Extension $pkgName isn't trusted")
|
|
||||||
return MangaLoadResult.Untrusted(extension)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
val isNsfw = appInfo.metaData.getInt("$MANGA_PACKAGE$XX_METADATA_NSFW") == 1
|
val isNsfw = appInfo.metaData.getInt("$MANGA_PACKAGE$XX_METADATA_NSFW") == 1
|
||||||
if (!loadNsfwSource && isNsfw) {
|
if (!loadNsfwSource && isNsfw) {
|
||||||
Logger.log("NSFW extension $pkgName not allowed")
|
Logger.log("NSFW extension $pkgName not allowed")
|
||||||
|
@ -392,7 +374,13 @@ internal object ExtensionLoader {
|
||||||
val hasChangelog =
|
val hasChangelog =
|
||||||
appInfo.metaData.getInt("$MANGA_PACKAGE$XX_METADATA_HAS_CHANGELOG", 0) == 1
|
appInfo.metaData.getInt("$MANGA_PACKAGE$XX_METADATA_HAS_CHANGELOG", 0) == 1
|
||||||
|
|
||||||
val classLoader = PathClassLoader(appInfo.sourceDir, null, context.classLoader)
|
val classLoader = try{
|
||||||
|
PathClassLoader(appInfo.sourceDir, null, context.classLoader)
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
Logger.log("Extension load error: $extName")
|
||||||
|
Injekt.get<CrashlyticsInterface>().logException(e)
|
||||||
|
return MangaLoadResult.Error
|
||||||
|
}
|
||||||
|
|
||||||
val sources = appInfo.metaData.getString("$MANGA_PACKAGE$XX_METADATA_SOURCE_CLASS")!!
|
val sources = appInfo.metaData.getString("$MANGA_PACKAGE$XX_METADATA_SOURCE_CLASS")!!
|
||||||
.split(";")
|
.split(";")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue