Add debug overlay
Disable crash workaround, not worth it
This commit is contained in:
parent
bd27cb74a7
commit
81b20a23bf
@ -33,18 +33,6 @@ ext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix for: https://stackoverflow.com/questions/51185566/application-running-on-avd-for-api-28-but-not-api-24
|
|
||||||
configurations.all {
|
|
||||||
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
|
|
||||||
def requested = details.requested
|
|
||||||
if (requested.group == "com.android.support") {
|
|
||||||
if (!requested.name.startsWith("multidex")) {
|
|
||||||
details.useVersion "26.+"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
buildToolsVersion '28.0.3'
|
buildToolsVersion '28.0.3'
|
||||||
@ -77,10 +65,16 @@ android {
|
|||||||
applicationIdSuffix ".debug"
|
applicationIdSuffix ".debug"
|
||||||
ext.enableCrashlytics = false
|
ext.enableCrashlytics = false
|
||||||
}
|
}
|
||||||
|
releaseTest {
|
||||||
|
applicationIdSuffix ".rt"
|
||||||
|
//minifyEnabled true
|
||||||
|
zipAlignEnabled true
|
||||||
|
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
release {
|
release {
|
||||||
//minifyEnabled true
|
//minifyEnabled true
|
||||||
zipAlignEnabled true
|
zipAlignEnabled true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,6 +283,12 @@ dependencies {
|
|||||||
def typed_time_version = '1.0.2'
|
def typed_time_version = '1.0.2'
|
||||||
implementation "com.github.kizitonwose.time:time:$typed_time_version"
|
implementation "com.github.kizitonwose.time:time:$typed_time_version"
|
||||||
implementation "com.github.kizitonwose.time:time-android:$typed_time_version"
|
implementation "com.github.kizitonwose.time:time-android:$typed_time_version"
|
||||||
|
|
||||||
|
// Debug utils (EH)
|
||||||
|
debugImplementation 'com.ms-square:debugoverlay:1.1.3'
|
||||||
|
releaseTestImplementation 'com.ms-square:debugoverlay:1.1.3'
|
||||||
|
releaseImplementation 'com.ms-square:debugoverlay-no-op:1.1.3'
|
||||||
|
testImplementation 'com.ms-square:debugoverlay-no-op:1.1.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
import android.graphics.Color
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.support.multidex.MultiDex
|
import android.support.multidex.MultiDex
|
||||||
import com.elvishew.xlog.LogConfiguration
|
import com.elvishew.xlog.LogConfiguration
|
||||||
@ -16,14 +17,15 @@ import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator
|
|||||||
import com.evernote.android.job.JobManager
|
import com.evernote.android.job.JobManager
|
||||||
import com.github.ajalt.reprint.core.Reprint
|
import com.github.ajalt.reprint.core.Reprint
|
||||||
import com.kizitonwose.time.days
|
import com.kizitonwose.time.days
|
||||||
|
import com.ms_square.debugoverlay.DebugOverlay
|
||||||
|
import com.ms_square.debugoverlay.modules.FpsModule
|
||||||
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.data.updater.UpdaterJob
|
import eu.kanade.tachiyomi.data.updater.UpdaterJob
|
||||||
import eu.kanade.tachiyomi.util.LocaleHelper
|
import eu.kanade.tachiyomi.util.LocaleHelper
|
||||||
import exh.log.CrashlyticsPrinter
|
import exh.log.CrashlyticsPrinter
|
||||||
|
import exh.log.EHDebugModeOverlay
|
||||||
import exh.log.EHLogLevel
|
import exh.log.EHLogLevel
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.RealmConfiguration
|
import io.realm.RealmConfiguration
|
||||||
@ -32,7 +34,6 @@ import kotlinx.coroutines.launch
|
|||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.InjektScope
|
import uy.kohesive.injekt.api.InjektScope
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
import uy.kohesive.injekt.registry.default.DefaultRegistrar
|
import uy.kohesive.injekt.registry.default.DefaultRegistrar
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
@ -51,6 +52,9 @@ open class App : Application() {
|
|||||||
setupNotificationChannels()
|
setupNotificationChannels()
|
||||||
GlobalScope.launch { deleteOldMetadataRealm() } // Delete old metadata DB (EH)
|
GlobalScope.launch { deleteOldMetadataRealm() } // Delete old metadata DB (EH)
|
||||||
Reprint.initialize(this) //Setup fingerprint (EH)
|
Reprint.initialize(this) //Setup fingerprint (EH)
|
||||||
|
if(BuildConfig.DEBUG || BuildConfig.BUILD_TYPE == "releaseTest") {
|
||||||
|
setupDebugOverlay()
|
||||||
|
}
|
||||||
|
|
||||||
LocaleHelper.updateConfiguration(this, resources.configuration)
|
LocaleHelper.updateConfiguration(this, resources.configuration)
|
||||||
}
|
}
|
||||||
@ -148,4 +152,15 @@ open class App : Application() {
|
|||||||
|
|
||||||
XLog.d("Application booting...")
|
XLog.d("Application booting...")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EXH
|
||||||
|
private fun setupDebugOverlay() {
|
||||||
|
DebugOverlay.Builder(this)
|
||||||
|
.modules(FpsModule(), EHDebugModeOverlay(this))
|
||||||
|
.bgColor(Color.parseColor("#7F000000"))
|
||||||
|
.notification(false)
|
||||||
|
.allowSystemLayer(false)
|
||||||
|
.build()
|
||||||
|
.install()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
65
app/src/main/java/exh/log/EHDebugModeOverlay.kt
Normal file
65
app/src/main/java/exh/log/EHDebugModeOverlay.kt
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package exh.log
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.text.Html
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.ms_square.debugoverlay.DataObserver
|
||||||
|
import com.ms_square.debugoverlay.OverlayModule
|
||||||
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
|
import eu.kanade.tachiyomi.util.dpToPx
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
|
class EHDebugModeOverlay(private val context: Context) : OverlayModule<String>(null, null) {
|
||||||
|
private var textView: TextView? = null
|
||||||
|
private val prefs: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
|
override fun start() {}
|
||||||
|
override fun stop() {}
|
||||||
|
override fun notifyObservers() {}
|
||||||
|
override fun addObserver(observer: DataObserver<Any>) {
|
||||||
|
observer.onDataAvailable(buildInfo())
|
||||||
|
}
|
||||||
|
override fun removeObserver(observer: DataObserver<Any>) {}
|
||||||
|
override fun onDataAvailable(data: String?) {
|
||||||
|
textView?.text = Html.fromHtml(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createView(root: ViewGroup, textColor: Int, textSize: Float, textAlpha: Float): View {
|
||||||
|
val view = LinearLayout(root.context)
|
||||||
|
view.layoutParams = ViewGroup.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
|
)
|
||||||
|
view.setPadding(4.dpToPx, 0, 4.dpToPx, 4.dpToPx)
|
||||||
|
val textView = TextView(view.context)
|
||||||
|
textView.setTextColor(textColor)
|
||||||
|
textView.textSize = textSize
|
||||||
|
textView.alpha = textAlpha
|
||||||
|
textView.text = Html.fromHtml(buildInfo())
|
||||||
|
textView.layoutParams = LinearLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
|
)
|
||||||
|
view.addView(textView)
|
||||||
|
this.textView = textView
|
||||||
|
return view
|
||||||
|
}
|
||||||
|
|
||||||
|
fun buildInfo() = """
|
||||||
|
<font color='green'>===[ ${context.getString(R.string.app_name)} ]===</font><br>
|
||||||
|
<b>Build type:</b> ${BuildConfig.BUILD_TYPE}<br>
|
||||||
|
<b>Debug mode:</b> ${BuildConfig.DEBUG}<br>
|
||||||
|
<b>Version code:</b> ${BuildConfig.VERSION_CODE}<br>
|
||||||
|
<b>Commit SHA:</b> ${BuildConfig.COMMIT_SHA}<br>
|
||||||
|
<b>Log level:</b> ${EHLogLevel.currentLogLevel.name.toLowerCase()}<br>
|
||||||
|
<b>Source blacklist:</b> ${prefs.eh_enableSourceBlacklist().getOrDefault().asEnabledString()}<br>
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
private fun Boolean.asEnabledString() = if(this) "enabled" else "disabled"
|
||||||
|
}
|
@ -12,6 +12,8 @@ enum class EHLogLevel(val description: String) {
|
|||||||
companion object {
|
companion object {
|
||||||
private var curLogLevel: Int? = null
|
private var curLogLevel: Int? = null
|
||||||
|
|
||||||
|
val currentLogLevel get() = EHLogLevel.values()[curLogLevel!!]
|
||||||
|
|
||||||
fun init(context: Context) {
|
fun init(context: Context) {
|
||||||
curLogLevel = PreferencesHelper(context)
|
curLogLevel = PreferencesHelper(context)
|
||||||
.eh_logLevel().getOrDefault()
|
.eh_logLevel().getOrDefault()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user