From 6bab1f26d302cb1f10a31397b335f1458ebbbd50 Mon Sep 17 00:00:00 2001 From: Gabe-W-J Date: Wed, 9 Oct 2024 21:30:45 +0200 Subject: [PATCH 1/6] no images found to replace, replaced some/all frontend branding --- app/build.gradle.kts | 4 ++-- app/src/main/AndroidManifest.xml | 2 +- app/src/main/assets/xposed_init | 2 +- .../kotlin/io/github/pyoncord/xposed/FontsModule.kt | 8 ++++---- app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt | 11 ++++++----- app/src/main/res/values/strings.xml | 2 +- settings.gradle.kts | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4fabd7c..d2bc0dd 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -5,11 +5,11 @@ plugins { } android { - namespace = "io.github.pyoncord.xposed" + namespace = "io.github.revenge.xposed" compileSdk = 33 defaultConfig { - applicationId = "io.github.pyoncord.xposed" + applicationId = "io.github.revenge.xposed" minSdk = 24 targetSdk = 33 versionCode = 203 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9e52cff..84c00fd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,7 +13,7 @@ android:value="true" /> + android:value="An Xposed module to inject Revenge, a mod for Discord's mobile apps." /> diff --git a/app/src/main/assets/xposed_init b/app/src/main/assets/xposed_init index 9afddb0..9ad2900 100644 --- a/app/src/main/assets/xposed_init +++ b/app/src/main/assets/xposed_init @@ -1 +1 @@ -io.github.pyoncord.xposed.Main \ No newline at end of file +io.github.revenge.xposed.Main \ No newline at end of file diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/FontsModule.kt b/app/src/main/kotlin/io/github/pyoncord/xposed/FontsModule.kt index 85e574d..3bf82c7 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/FontsModule.kt +++ b/app/src/main/kotlin/io/github/pyoncord/xposed/FontsModule.kt @@ -85,7 +85,7 @@ class FontsModule: PyonModule() { if (!fileName.startsWith(".")) { val fontName = fileName.split('.')[0] if (fontDef.main.keys.none { it == fontName }) { - Log.i("Bunny", "Deleting font file: $fileName") + Log.i("Revenge", "Deleting font file: $fileName") file.delete() } } @@ -97,12 +97,12 @@ class FontsModule: PyonModule() { async { val url = fontDef.main.getValue(name) try { - Log.i("Bunny", "Downloading $name from $url") + Log.i("Revenge", "Downloading $name from $url") val file = File(fontsDir, "$name${FILE_EXTENSIONS.first { url.endsWith(it) }}") if (file.exists()) return@async val client = HttpClient(CIO) { - install(UserAgent) { agent = "BunnyXposed" } + install(UserAgent) { agent = "RevengeXposed" } } val response: HttpResponse = client.get(url) @@ -113,7 +113,7 @@ class FontsModule: PyonModule() { return@async } catch (e: Throwable) { - Log.e("Bunny", "Failed to download fonts ($name from $url)", e) + Log.e("Revenge", "Failed to download fonts ($name from $url)", e) } } }.awaitAll() diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt b/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt index c7718a4..d8610d0 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt +++ b/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt @@ -124,14 +124,14 @@ class Main : IXposedHookLoadPackage { install(HttpTimeout) { requestTimeoutMillis = if (bundle.exists()) 3000 else 10000 } - install(UserAgent) { agent = "BunnyXposed" } + install(UserAgent) { agent = "RevengeXposed" } } val url = if (config.customLoadUrl.enabled) config.customLoadUrl.url else "https://github.com/revenge-mod/Revenge/releases/latest/download/revenge.js" - Log.e("Bunny", "Fetching JS bundle from $url") + Log.e("Revenge", "Fetching JS bundle from $url") val response: HttpResponse = client.get(url) { headers { @@ -153,13 +153,14 @@ class Main : IXposedHookLoadPackage { return@async } catch (e: RedirectResponseException) { if (e.response.status != HttpStatusCode.NotModified) throw e; - Log.e("Bunny", "Server reponded with status code 304 - no changes to file") + Log.e("Revenge", "Server reponded with status code 304 - no changes to file") } catch (e: Throwable) { // activity.runOnUiThread { - // Toast.makeText(activity.applicationContext, "Failed to fetch JS bundle, Bunny may not load!", Toast.LENGTH_SHORT).show() + // Toast.makeText(activity.applicationContext, "Failed to fetch JS bundle, Revenge may not load!", Toast.LENGTH_SHORT).show() // } + // so are we just removing the toast entirely or, cos like commented code without explanation isnt the best - Log.e("Bunny", "Failed to download bundle", e) + Log.e("Revenge", "Failed to download bundle", e) } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a327e5c..401896b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - BunnyXposed + RevengeXposed \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 808d13f..754c616 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,2 +1,2 @@ -rootProject.name = "BunnyXposed" +rootProject.name = "RevengeXposed" include(":app") From 7431c6049995f3eb7a55100389163275185f6638 Mon Sep 17 00:00:00 2001 From: Palm Date: Thu, 10 Oct 2024 15:14:22 +0700 Subject: [PATCH 2/6] fix build --- app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt b/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt index d8610d0..9e0fd8b 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt +++ b/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt @@ -1,4 +1,4 @@ -package io.github.pyoncord.xposed +package io.github.revenge.xposed import android.app.Activity import android.app.AndroidAppHelper @@ -12,7 +12,7 @@ import de.robv.android.xposed.IXposedHookLoadPackage import de.robv.android.xposed.XC_MethodHook import de.robv.android.xposed.XposedBridge import de.robv.android.xposed.callbacks.XC_LoadPackage -import io.github.pyoncord.xposed.BuildConfig +import io.github.revenge.xposed.BuildConfig import io.ktor.client.* import io.ktor.client.call.* import io.ktor.client.request.* @@ -212,4 +212,4 @@ class Main : IXposedHookLoadPackage { }) } } -} \ No newline at end of file +} From b26e30d7c0cc19985582b9a6a1e006ab3f57dda5 Mon Sep 17 00:00:00 2001 From: Palm Date: Thu, 10 Oct 2024 08:19:25 +0000 Subject: [PATCH 3/6] actually fix build and update more references --- .github/workflows/build.yml | 16 ++++++++-------- .../{pyoncord => revenge}/xposed/FontsModule.kt | 4 ++-- .../github/{pyoncord => revenge}/xposed/Main.kt | 6 +++--- .../{pyoncord => revenge}/xposed/PyonModule.kt | 4 ++-- .../xposed/SysColorsModule.kt | 4 ++-- .../{pyoncord => revenge}/xposed/ThemeModule.kt | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) rename app/src/main/kotlin/io/github/{pyoncord => revenge}/xposed/FontsModule.kt (99%) rename app/src/main/kotlin/io/github/{pyoncord => revenge}/xposed/Main.kt (98%) rename app/src/main/kotlin/io/github/{pyoncord => revenge}/xposed/PyonModule.kt (79%) rename app/src/main/kotlin/io/github/{pyoncord => revenge}/xposed/SysColorsModule.kt (95%) rename app/src/main/kotlin/io/github/{pyoncord => revenge}/xposed/ThemeModule.kt (98%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1fc257c..2c82391 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,29 +25,29 @@ jobs: - name: "Setup directories" run: | - mkdir -p /tmp/pyonbuild/apks - mkdir -p /tmp/pyonbuild/tools + mkdir -p /tmp/build/apks + mkdir -p /tmp/build/tools - name: "Move debug APK" - run: mv ./app/build/outputs/apk/debug/app-debug.apk /tmp/pyonbuild/apks + run: mv ./app/build/outputs/apk/debug/app-debug.apk /tmp/build/apks - name: "Download uber-apk-signer" - run: wget -nv "https://github.com/patrickfav/uber-apk-signer/releases/download/v1.2.1/uber-apk-signer-1.2.1.jar" -O /tmp/pyonbuild/tools/uber-apk-signer.jar + run: wget -nv "https://github.com/patrickfav/uber-apk-signer/releases/download/v1.2.1/uber-apk-signer-1.2.1.jar" -O /tmp/build/tools/uber-apk-signer.jar - name: "Sign release APK" - run: java -jar /tmp/pyonbuild/tools/uber-apk-signer.jar --apks ./app/build/outputs/apk/release/app-release-unsigned.apk --out /tmp/pyonbuild/apks/ + run: java -jar /tmp/build/tools/uber-apk-signer.jar --apks ./app/build/outputs/apk/release/app-release-unsigned.apk --out /tmp/build/apks/ - name: "Rename release APK" - run: mv /tmp/pyonbuild/apks/app-release-aligned-debugSigned.apk /tmp/pyonbuild/apks/app-release.apk + run: mv /tmp/build/apks/app-release-aligned-debugSigned.apk /tmp/build/apks/app-release.apk - name: "Upload debug APK" uses: actions/upload-artifact@v3 with: name: app-debug - path: /tmp/pyonbuild/apks/app-debug.apk + path: /tmp/build/apks/app-debug.apk - name: "Upload release APK" uses: actions/upload-artifact@v3 with: name: app-release - path: /tmp/pyonbuild/apks/app-release.apk \ No newline at end of file + path: /tmp/build/apks/app-release.apk \ No newline at end of file diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/FontsModule.kt b/app/src/main/kotlin/io/github/revenge/xposed/FontsModule.kt similarity index 99% rename from app/src/main/kotlin/io/github/pyoncord/xposed/FontsModule.kt rename to app/src/main/kotlin/io/github/revenge/xposed/FontsModule.kt index 3bf82c7..c529974 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/FontsModule.kt +++ b/app/src/main/kotlin/io/github/revenge/xposed/FontsModule.kt @@ -1,7 +1,7 @@ // credits to janisslsm from his PR: https://github.com/vendetta-mod/VendettaXposed/pull/17 // hooks are modified function from RN codebase -package io.github.pyoncord.xposed +package io.github.revenge.xposed import android.content.res.AssetManager import android.os.Build @@ -41,7 +41,7 @@ data class FontDefinition( val main: Map, ) -class FontsModule: PyonModule() { +class FontsModule: Module() { private val EXTENSIONS = arrayOf("", "_bold", "_italic", "_bold_italic") private val FILE_EXTENSIONS = arrayOf(".ttf", ".otf") private val FONTS_ASSET_PATH = "fonts/" diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt b/app/src/main/kotlin/io/github/revenge/xposed/Main.kt similarity index 98% rename from app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt rename to app/src/main/kotlin/io/github/revenge/xposed/Main.kt index 9e0fd8b..8819eff 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt +++ b/app/src/main/kotlin/io/github/revenge/xposed/Main.kt @@ -36,7 +36,7 @@ data class LoaderConfig( ) class Main : IXposedHookLoadPackage { - private val pyonModules: Array = arrayOf( + private val modules: Array = arrayOf( ThemeModule(), SysColorsModule(), FontsModule(), @@ -47,7 +47,7 @@ class Main : IXposedHookLoadPackage { put("loaderName", "BunnyXposed") put("loaderVersion", BuildConfig.VERSION_NAME) - for (module in pyonModules) { + for (module in modules) { module.buildJson(this) } } @@ -73,7 +73,7 @@ class Main : IXposedHookLoadPackage { classLoader.loadClass("com.facebook.react.bridge.CatalystInstanceImpl") }.getOrElse { return@with } - for (module in pyonModules) module.onInit(param) + for (module in modules) module.onInit(param) val loadScriptFromAssets = catalystInstanceImpl.getDeclaredMethod( "loadScriptFromAssets", diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/PyonModule.kt b/app/src/main/kotlin/io/github/revenge/xposed/PyonModule.kt similarity index 79% rename from app/src/main/kotlin/io/github/pyoncord/xposed/PyonModule.kt rename to app/src/main/kotlin/io/github/revenge/xposed/PyonModule.kt index ebcab56..b0416fd 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/PyonModule.kt +++ b/app/src/main/kotlin/io/github/revenge/xposed/PyonModule.kt @@ -1,9 +1,9 @@ -package io.github.pyoncord.xposed +package io.github.revenge.xposed import de.robv.android.xposed.callbacks.XC_LoadPackage import kotlinx.serialization.json.JsonObjectBuilder -abstract class PyonModule { +abstract class Module { open fun buildJson(builder: JsonObjectBuilder) {} open fun onInit(packageParam: XC_LoadPackage.LoadPackageParam) {} } \ No newline at end of file diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/SysColorsModule.kt b/app/src/main/kotlin/io/github/revenge/xposed/SysColorsModule.kt similarity index 95% rename from app/src/main/kotlin/io/github/pyoncord/xposed/SysColorsModule.kt rename to app/src/main/kotlin/io/github/revenge/xposed/SysColorsModule.kt index 140b631..c4e49aa 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/SysColorsModule.kt +++ b/app/src/main/kotlin/io/github/revenge/xposed/SysColorsModule.kt @@ -1,4 +1,4 @@ -package io.github.pyoncord.xposed +package io.github.revenge.xposed import android.app.AndroidAppHelper import android.content.Context @@ -16,7 +16,7 @@ data class SysColors( val accent3: List ) -class SysColorsModule : PyonModule() { +class SysColorsModule : Module() { private lateinit var context: Context fun isSupported() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/ThemeModule.kt b/app/src/main/kotlin/io/github/revenge/xposed/ThemeModule.kt similarity index 98% rename from app/src/main/kotlin/io/github/pyoncord/xposed/ThemeModule.kt rename to app/src/main/kotlin/io/github/revenge/xposed/ThemeModule.kt index 7b1cb6c..e8da0f8 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/ThemeModule.kt +++ b/app/src/main/kotlin/io/github/revenge/xposed/ThemeModule.kt @@ -1,4 +1,4 @@ -package io.github.pyoncord.xposed +package io.github.revenge.xposed import android.content.Context import android.graphics.Color @@ -35,7 +35,7 @@ data class Theme( val data: ThemeData ) -class ThemeModule : PyonModule() { +class ThemeModule : Module() { private lateinit var param: XC_LoadPackage.LoadPackageParam private var theme: Theme? = null From 59d85ef774465689bae0f118aa5d904bbcd4d903 Mon Sep 17 00:00:00 2001 From: pylixonly <82711525+pylixonly@users.noreply.github.com> Date: Fri, 11 Oct 2024 23:48:21 +0800 Subject: [PATCH 4/6] fix: undelay module initialization --- .idea/compiler.xml | 2 +- .idea/deploymentTargetSelector.xml | 18 ++++++++++ .idea/gradle.xml | 5 ++- .idea/migrations.xml | 10 ++++++ .idea/misc.xml | 2 +- .idea/vcs.xml | 2 +- app/build.gradle.kts | 4 +-- .../io/github/pyoncord/xposed/FontsModule.kt | 11 ++---- .../kotlin/io/github/pyoncord/xposed/Main.kt | 34 ++++++++++++++----- .../github/pyoncord/xposed/SysColorsModule.kt | 4 +-- .../io/github/pyoncord/xposed/ThemeModule.kt | 12 +++---- 11 files changed, 71 insertions(+), 33 deletions(-) create mode 100644 .idea/deploymentTargetSelector.xml create mode 100644 .idea/migrations.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml index e58d3e4..b589d56 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..19ce6a7 --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,18 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index cbbe561..0897082 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,16 +4,15 @@ diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 9924903..0ad17cb 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4fabd7c..b80296a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -12,8 +12,8 @@ android { applicationId = "io.github.pyoncord.xposed" minSdk = 24 targetSdk = 33 - versionCode = 203 - versionName = "0.2.3" + versionCode = 204 + versionName = "0.2.4" } buildTypes { diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/FontsModule.kt b/app/src/main/kotlin/io/github/pyoncord/xposed/FontsModule.kt index 85e574d..ac98f30 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/FontsModule.kt +++ b/app/src/main/kotlin/io/github/pyoncord/xposed/FontsModule.kt @@ -5,15 +5,12 @@ package io.github.pyoncord.xposed import android.content.res.AssetManager import android.os.Build -import android.graphics.Color import android.graphics.Typeface import android.graphics.Typeface.CustomFallbackBuilder import android.graphics.fonts.Font import android.graphics.fonts.FontFamily import android.util.Log -import android.webkit.URLUtil import de.robv.android.xposed.XC_MethodReplacement -import de.robv.android.xposed.XposedBridge import de.robv.android.xposed.XposedHelpers import de.robv.android.xposed.callbacks.XC_LoadPackage import kotlinx.serialization.Serializable @@ -21,8 +18,6 @@ import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.* import java.io.IOException import java.io.File -import java.net.HttpURLConnection -import java.net.URL import kotlinx.coroutines.* import io.ktor.client.* @@ -67,7 +62,7 @@ class FontsModule: PyonModule() { val assetManager: AssetManager = param.args[2] as AssetManager return createAssetTypeface(fontFamilyName, style, assetManager) } - }); + }) val fontDefFile = File(appInfo.dataDir, "files/pyoncord/fonts.json") if (!fontDefFile.exists()) return@with @@ -144,7 +139,7 @@ class FontsModule: PyonModule() { // ignore } - for (fontRootPath in arrayOf(fontsAbsPath, FONTS_ASSET_PATH).filter { it != null }) { + for (fontRootPath in arrayOf(fontsAbsPath, FONTS_ASSET_PATH).filterNotNull()) { for (fileExtension in FILE_EXTENSIONS) { val fileName = java.lang.StringBuilder() .append(fontRootPath) @@ -220,7 +215,7 @@ class FontsModule: PyonModule() { // Lastly, after all those checks above, this is the original RN logic for // getting the typeface. - for (fontRootPath in arrayOf(fontsAbsPath, FONTS_ASSET_PATH).filter { it != null }) { + for (fontRootPath in arrayOf(fontsAbsPath, FONTS_ASSET_PATH).filterNotNull()) { for (fileExtension in FILE_EXTENSIONS) { val fileName = java.lang.StringBuilder() .append(fontRootPath) diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt b/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt index 0e9ae32..d8e1bea 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt +++ b/app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt @@ -1,8 +1,6 @@ package io.github.pyoncord.xposed -import android.app.Activity -import android.app.AndroidAppHelper -import android.content.Context +import android.app.Activity import android.content.res.AssetManager import android.content.res.Resources import android.util.Log @@ -12,7 +10,6 @@ import de.robv.android.xposed.IXposedHookLoadPackage import de.robv.android.xposed.XC_MethodHook import de.robv.android.xposed.XposedBridge import de.robv.android.xposed.callbacks.XC_LoadPackage -import io.github.pyoncord.xposed.BuildConfig import io.ktor.client.* import io.ktor.client.call.* import io.ktor.client.request.* @@ -60,14 +57,27 @@ class Main : IXposedHookLoadPackage { lpparam.classLoader.loadClass("com.discord.react_activities.ReactActivity") }.getOrElse { return } // Package is not our the target app, return + var activity: Activity? = null; + val onActivityCreateCallback = mutableSetOf<(activity: Activity) -> Unit>() + XposedBridge.hookMethod(reactActivity.getDeclaredMethod("onCreate", Bundle::class.java), object : XC_MethodHook() { override fun beforeHookedMethod(param: MethodHookParam) { - init(lpparam, param.thisObject as Activity) + activity = param.thisObject as Activity; + onActivityCreateCallback.forEach { cb -> cb(activity!!) } + onActivityCreateCallback.clear() } }) + + init(lpparam) { cb -> + if (activity != null) cb(activity!!) + else onActivityCreateCallback.add(cb) + } } - fun init(param: XC_LoadPackage.LoadPackageParam, activity: Activity) = with (param) { + private fun init( + param: XC_LoadPackage.LoadPackageParam, + onActivityCreate: ((activity: Activity) -> Unit) -> Unit + ) = with (param) { val catalystInstanceImpl = classLoader.loadClass("com.facebook.react.bridge.CatalystInstanceImpl") for (module in pyonModules) module.onInit(param) @@ -150,10 +160,16 @@ class Main : IXposedHookLoadPackage { return@async } catch (e: RedirectResponseException) { if (e.response.status != HttpStatusCode.NotModified) throw e; - Log.e("Bunny", "Server reponded with status code 304 - no changes to file") + Log.e("Bunny", "Server responded with status code 304 - no changes to file") } catch (e: Throwable) { - activity.runOnUiThread { - Toast.makeText(activity.applicationContext, "Failed to fetch JS bundle, Bunny may not load!", Toast.LENGTH_SHORT).show() + onActivityCreate { activity -> + activity.runOnUiThread { + Toast.makeText( + activity.applicationContext, + "Failed to fetch JS bundle, Bunny may not load!", + Toast.LENGTH_SHORT + ).show() + } } Log.e("Bunny", "Failed to download bundle", e) diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/SysColorsModule.kt b/app/src/main/kotlin/io/github/pyoncord/xposed/SysColorsModule.kt index 140b631..123526e 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/SysColorsModule.kt +++ b/app/src/main/kotlin/io/github/pyoncord/xposed/SysColorsModule.kt @@ -18,7 +18,7 @@ data class SysColors( class SysColorsModule : PyonModule() { private lateinit var context: Context - fun isSupported() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S + private fun isSupported() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S override fun buildJson(builder: JsonObjectBuilder) { context = AndroidAppHelper.currentApplication() @@ -43,7 +43,7 @@ class SysColorsModule : PyonModule() { } } - fun convertToColor(id: Int): String { + private fun convertToColor(id: Int): String { val clr = if (isSupported()) ContextCompat.getColor(context, id) else 0 return String.format("#%06X", 0xFFFFFF and clr) } diff --git a/app/src/main/kotlin/io/github/pyoncord/xposed/ThemeModule.kt b/app/src/main/kotlin/io/github/pyoncord/xposed/ThemeModule.kt index 7b1cb6c..67edd7d 100644 --- a/app/src/main/kotlin/io/github/pyoncord/xposed/ThemeModule.kt +++ b/app/src/main/kotlin/io/github/pyoncord/xposed/ThemeModule.kt @@ -58,14 +58,14 @@ class ThemeModule : PyonModule() { hookTheme() } - fun File.isValidish(): Boolean { + private fun File.isValidish(): Boolean { if (!this.exists()) return false val text = this.readText() - return !text.isBlank() && text != "{}" && text != "null" + return text.isNotBlank() && text != "{}" && text != "null" } - fun getTheme(): Theme? { + private fun getTheme(): Theme? { val filesDir = File(param.appInfo.dataDir, "files").apply { mkdirs() } val pyonDir = File(filesDir, "pyoncord").apply { mkdirs() } val themeFile = File(pyonDir, "current-theme.json") @@ -139,12 +139,12 @@ class ThemeModule : PyonModule() { } // Convert 0xRRGGBBAA to 0XAARRGGBB - fun hexStringToColorInt(hexString: String): Int { + private fun hexStringToColorInt(hexString: String): Int { val parsed = Color.parseColor(hexString) - return parsed.takeIf { hexString.length == 7 } ?: parsed and 0xFFFFFF or (parsed ushr 24) + return parsed.takeIf { hexString.length == 7 } ?: (parsed and 0xFFFFFF or (parsed ushr 24)) } - fun hookThemeMethod(themeClass: Class<*>, methodName: String, themeValue: Int) { + private fun hookThemeMethod(themeClass: Class<*>, methodName: String, themeValue: Int) { try { themeClass.getDeclaredMethod(methodName).let { method -> // Log.i("Hooking $methodName -> ${themeValue.toString(16)}") From 7c51fb86181ba4eaa988cec6e4d840a4e0259d69 Mon Sep 17 00:00:00 2001 From: Palm Date: Sun, 20 Oct 2024 18:01:08 +0700 Subject: [PATCH 5/6] feat: download minified builds --- app/src/main/kotlin/io/github/revenge/xposed/Main.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/io/github/revenge/xposed/Main.kt b/app/src/main/kotlin/io/github/revenge/xposed/Main.kt index 7a212a0..bff07e0 100644 --- a/app/src/main/kotlin/io/github/revenge/xposed/Main.kt +++ b/app/src/main/kotlin/io/github/revenge/xposed/Main.kt @@ -137,7 +137,7 @@ class Main : IXposedHookLoadPackage { val url = if (config.customLoadUrl.enabled) config.customLoadUrl.url - else "https://github.com/revenge-mod/Revenge/releases/latest/download/revenge.js" + else "https://github.com/revenge-mod/Revenge/releases/latest/download/revenge.min.js" Log.e("Revenge", "Fetching JS bundle from $url") From c31d3c9755b98a003f842f58b939a32c3d929e5f Mon Sep 17 00:00:00 2001 From: Palm Date: Sun, 20 Oct 2024 18:05:10 +0700 Subject: [PATCH 6/6] fix: update to correct repo link --- app/src/main/kotlin/io/github/revenge/xposed/Main.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/io/github/revenge/xposed/Main.kt b/app/src/main/kotlin/io/github/revenge/xposed/Main.kt index bff07e0..46360af 100644 --- a/app/src/main/kotlin/io/github/revenge/xposed/Main.kt +++ b/app/src/main/kotlin/io/github/revenge/xposed/Main.kt @@ -137,7 +137,7 @@ class Main : IXposedHookLoadPackage { val url = if (config.customLoadUrl.enabled) config.customLoadUrl.url - else "https://github.com/revenge-mod/Revenge/releases/latest/download/revenge.min.js" + else "https://github.com/revenge-mod/revenge-bundle/releases/latest/download/revenge.min.js" Log.e("Revenge", "Fetching JS bundle from $url")