From 2f78af7f08fba82d7157e91f02adb4a879dd3179 Mon Sep 17 00:00:00 2001 From: Sculas Date: Wed, 14 Sep 2022 23:16:48 +0200 Subject: [PATCH] refactor: more cleanup --- .../revanced/manager/flutter/MainActivity.kt | 112 +++++++----------- 1 file changed, 41 insertions(+), 71 deletions(-) diff --git a/android/app/src/main/kotlin/app/revanced/manager/flutter/MainActivity.kt b/android/app/src/main/kotlin/app/revanced/manager/flutter/MainActivity.kt index 87b007cb1a..f7c6cc7230 100644 --- a/android/app/src/main/kotlin/app/revanced/manager/flutter/MainActivity.kt +++ b/android/app/src/main/kotlin/app/revanced/manager/flutter/MainActivity.kt @@ -11,6 +11,7 @@ import app.revanced.manager.flutter.utils.zip.structures.ZipEntry import app.revanced.patcher.Patcher import app.revanced.patcher.PatcherOptions import app.revanced.patcher.extensions.PatchExtensions.patchName +import app.revanced.patcher.logging.Logger import app.revanced.patcher.util.patch.impl.DexPatchBundle import dalvik.system.DexClassLoader import io.flutter.embedding.android.FlutterActivity @@ -141,77 +142,7 @@ class MainActivity : FlutterActivity() { resourcePatching, Aapt.binary(applicationContext).absolutePath, cacheDirPath, - logger = - object : - app.revanced.patcher.logging.Logger { - override fun error(msg: String) { - handler.post { - installerChannel - .invokeMethod( - "update", - mapOf( - "progress" to - -1.0, - "header" to - "", - "log" to - msg - ) - ) - } - } - - override fun warn(msg: String) { - handler.post { - installerChannel - .invokeMethod( - "update", - mapOf( - "progress" to - -1.0, - "header" to - "", - "log" to - msg - ) - ) - } - } - - override fun info(msg: String) { - handler.post { - installerChannel - .invokeMethod( - "update", - mapOf( - "progress" to - -1.0, - "header" to - "", - "log" to - msg - ) - ) - } - } - - override fun trace(msg: String) { - handler.post { - installerChannel - .invokeMethod( - "update", - mapOf( - "progress" to - -1.0, - "header" to - "", - "log" to - msg - ) - ) - } - } - } + logger = ManagerLogger() ) ) @@ -326,4 +257,43 @@ class MainActivity : FlutterActivity() { } .start() } + + inner class ManagerLogger : Logger { + override fun error(msg: String) { + handler.post { + installerChannel + .invokeMethod( + "update", + mapOf("progress" to -1.0, "header" to "", "log" to msg) + ) + } + } + + override fun warn(msg: String) { + handler.post { + installerChannel.invokeMethod( + "update", + mapOf("progress" to -1.0, "header" to "", "log" to msg) + ) + } + } + + override fun info(msg: String) { + handler.post { + installerChannel.invokeMethod( + "update", + mapOf("progress" to -1.0, "header" to "", "log" to msg) + ) + } + } + + override fun trace(msg: String) { + handler.post { + installerChannel.invokeMethod( + "update", + mapOf("progress" to -1.0, "header" to "", "log" to msg) + ) + } + } + } }