|
|
|
@ -1,9 +1,12 @@
|
|
|
|
package org.koitharu.kotatsu
|
|
|
|
package org.koitharu.kotatsu
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.content.Context
|
|
|
|
|
|
|
|
import android.content.SharedPreferences
|
|
|
|
import android.os.Build
|
|
|
|
import android.os.Build
|
|
|
|
import android.os.StrictMode
|
|
|
|
import android.os.StrictMode
|
|
|
|
|
|
|
|
import androidx.core.content.edit
|
|
|
|
import androidx.fragment.app.strictmode.FragmentStrictMode
|
|
|
|
import androidx.fragment.app.strictmode.FragmentStrictMode
|
|
|
|
|
|
|
|
import leakcanary.LeakCanary
|
|
|
|
import org.koitharu.kotatsu.core.BaseApp
|
|
|
|
import org.koitharu.kotatsu.core.BaseApp
|
|
|
|
import org.koitharu.kotatsu.local.data.LocalMangaRepository
|
|
|
|
import org.koitharu.kotatsu.local.data.LocalMangaRepository
|
|
|
|
import org.koitharu.kotatsu.local.data.PagesCache
|
|
|
|
import org.koitharu.kotatsu.local.data.PagesCache
|
|
|
|
@ -13,9 +16,23 @@ import org.koitharu.kotatsu.reader.ui.ReaderViewModel
|
|
|
|
|
|
|
|
|
|
|
|
class KotatsuApp : BaseApp() {
|
|
|
|
class KotatsuApp : BaseApp() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isLeakCanaryEnabled: Boolean
|
|
|
|
|
|
|
|
get() = getDebugPreferences(this).getBoolean(KEY_LEAK_CANARY, true)
|
|
|
|
|
|
|
|
set(value) {
|
|
|
|
|
|
|
|
getDebugPreferences(this).edit { putBoolean(KEY_LEAK_CANARY, value) }
|
|
|
|
|
|
|
|
configureLeakCanary()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun attachBaseContext(base: Context) {
|
|
|
|
override fun attachBaseContext(base: Context) {
|
|
|
|
super.attachBaseContext(base)
|
|
|
|
super.attachBaseContext(base)
|
|
|
|
enableStrictMode()
|
|
|
|
enableStrictMode()
|
|
|
|
|
|
|
|
configureLeakCanary()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun configureLeakCanary() {
|
|
|
|
|
|
|
|
LeakCanary.config = LeakCanary.config.copy(
|
|
|
|
|
|
|
|
dumpHeap = isLeakCanaryEnabled,
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun enableStrictMode() {
|
|
|
|
private fun enableStrictMode() {
|
|
|
|
@ -55,7 +72,7 @@ class KotatsuApp : BaseApp() {
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && notifier != null) {
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && notifier != null) {
|
|
|
|
penaltyListener(notifier.executor, notifier)
|
|
|
|
penaltyListener(notifier.executor, notifier)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.build()
|
|
|
|
}.build(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
FragmentStrictMode.defaultPolicy = FragmentStrictMode.Policy.Builder().apply {
|
|
|
|
FragmentStrictMode.defaultPolicy = FragmentStrictMode.Policy.Builder().apply {
|
|
|
|
detectWrongFragmentContainer()
|
|
|
|
detectWrongFragmentContainer()
|
|
|
|
@ -70,4 +87,13 @@ class KotatsuApp : BaseApp() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.build()
|
|
|
|
}.build()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private companion object {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const val PREFS_DEBUG = "_debug"
|
|
|
|
|
|
|
|
const val KEY_LEAK_CANARY = "leak_canary"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun getDebugPreferences(context: Context): SharedPreferences =
|
|
|
|
|
|
|
|
context.getSharedPreferences(PREFS_DEBUG, MODE_PRIVATE)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|