mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Add debug overlay
Disable crash workaround, not worth it
This commit is contained in:
		@@ -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 {
 | 
			
		||||
    compileSdkVersion 28
 | 
			
		||||
    buildToolsVersion '28.0.3'
 | 
			
		||||
@@ -77,10 +65,16 @@ android {
 | 
			
		||||
            applicationIdSuffix ".debug"
 | 
			
		||||
            ext.enableCrashlytics = false
 | 
			
		||||
        }
 | 
			
		||||
        releaseTest {
 | 
			
		||||
            applicationIdSuffix ".rt"
 | 
			
		||||
            //minifyEnabled true
 | 
			
		||||
            zipAlignEnabled true
 | 
			
		||||
//            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
 | 
			
		||||
        }
 | 
			
		||||
        release {
 | 
			
		||||
            //minifyEnabled 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'
 | 
			
		||||
    implementation "com.github.kizitonwose.time:time:$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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ package eu.kanade.tachiyomi
 | 
			
		||||
import android.app.Application
 | 
			
		||||
import android.content.Context
 | 
			
		||||
import android.content.res.Configuration
 | 
			
		||||
import android.graphics.Color
 | 
			
		||||
import android.os.Environment
 | 
			
		||||
import android.support.multidex.MultiDex
 | 
			
		||||
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.github.ajalt.reprint.core.Reprint
 | 
			
		||||
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.library.LibraryUpdateJob
 | 
			
		||||
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.util.LocaleHelper
 | 
			
		||||
import exh.log.CrashlyticsPrinter
 | 
			
		||||
import exh.log.EHDebugModeOverlay
 | 
			
		||||
import exh.log.EHLogLevel
 | 
			
		||||
import io.realm.Realm
 | 
			
		||||
import io.realm.RealmConfiguration
 | 
			
		||||
@@ -32,7 +34,6 @@ import kotlinx.coroutines.launch
 | 
			
		||||
import timber.log.Timber
 | 
			
		||||
import uy.kohesive.injekt.Injekt
 | 
			
		||||
import uy.kohesive.injekt.api.InjektScope
 | 
			
		||||
import uy.kohesive.injekt.api.get
 | 
			
		||||
import uy.kohesive.injekt.registry.default.DefaultRegistrar
 | 
			
		||||
import java.io.File
 | 
			
		||||
import kotlin.concurrent.thread
 | 
			
		||||
@@ -51,6 +52,9 @@ open class App : Application() {
 | 
			
		||||
        setupNotificationChannels()
 | 
			
		||||
        GlobalScope.launch { deleteOldMetadataRealm() } // Delete old metadata DB (EH)
 | 
			
		||||
        Reprint.initialize(this) //Setup fingerprint (EH)
 | 
			
		||||
        if(BuildConfig.DEBUG || BuildConfig.BUILD_TYPE == "releaseTest") {
 | 
			
		||||
            setupDebugOverlay()
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        LocaleHelper.updateConfiguration(this, resources.configuration)
 | 
			
		||||
    }
 | 
			
		||||
@@ -148,4 +152,15 @@ open class App : Application() {
 | 
			
		||||
 | 
			
		||||
        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 {
 | 
			
		||||
        private var curLogLevel: Int? = null
 | 
			
		||||
 | 
			
		||||
        val currentLogLevel get() = EHLogLevel.values()[curLogLevel!!]
 | 
			
		||||
 | 
			
		||||
        fun init(context: Context) {
 | 
			
		||||
            curLogLevel = PreferencesHelper(context)
 | 
			
		||||
                    .eh_logLevel().getOrDefault()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user