<commit_before>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"
}<commit_msg>Remove extra line in debug overlay<commit_after>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()}
    """.trimIndent()

    private fun Boolean.asEnabledString() = if(this) "enabled" else "disabled"
}
{'fraction_non_alphanumeric': 0.1156113329530329, 'fraction_numerical': 0.0015212017493820118, 'mean_word_length': 3.5266781411359727, 'pattern_counts': {'":': 0, '<': 50, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4145101', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1586, 'n_words': 295}