feat: add Reset Loader Config in Recovery dialog, show Recovery option in Update Failed dialog

This commit is contained in:
PalmDevs 2025-10-13 03:49:58 +07:00
parent 12e35d8d04
commit 614f9ced6f
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA
2 changed files with 33 additions and 14 deletions

View file

@ -62,22 +62,31 @@ class LogBoxModule : Module() {
} }
} }
private fun showRecoveryAlert(context: Context) { companion object {
AlertDialog.Builder(context).setTitle("Revenge Recovery Options") fun showRecoveryAlert(context: Context) {
.setItems(arrayOf("Reload", "Delete bundle.js")) { _, which -> AlertDialog.Builder(context).setTitle("Revenge Recovery Options")
when (which) { .setItems(arrayOf("Reload", "Delete Script", "Reset Loader Config")) { _, which ->
0 -> { when (which) {
reloadApp() 0 -> {
} reloadApp()
}
1 -> { 1 -> {
val bundleFile = val bundleFile = File(
File(packageParam.appInfo.dataDir, "${Constants.CACHE_DIR}/${Constants.MAIN_SCRIPT_FILE}") context.dataDir, "${Constants.CACHE_DIR}/${Constants.MAIN_SCRIPT_FILE}"
if (bundleFile.exists()) bundleFile.delete() )
reloadApp() if (bundleFile.exists()) bundleFile.delete()
reloadApp()
}
2 -> {
UpdaterModule.resetLoaderConfig(context)
reloadApp()
}
} }
} }.show()
}.show() }
} }
} }

View file

@ -2,6 +2,7 @@ package io.github.revenge.xposed.modules
import android.app.Activity import android.app.Activity
import android.app.AlertDialog import android.app.AlertDialog
import android.content.Context
import android.util.AtomicFile import android.util.AtomicFile
import android.widget.Toast import android.widget.Toast
import androidx.core.util.writeBytes import androidx.core.util.writeBytes
@ -155,7 +156,16 @@ object UpdaterModule : Module() {
downloadScript(activity) downloadScript(activity)
Toast.makeText(activity, "Retrying download in background...", Toast.LENGTH_SHORT).show() Toast.makeText(activity, "Retrying download in background...", Toast.LENGTH_SHORT).show()
dialog.dismiss() dialog.dismiss()
}.setNeutralButton("Recovery") { dialog, _ ->
LogBoxModule.showRecoveryAlert(activity)
dialog.dismiss()
}.show() }.show()
} }
} }
fun resetLoaderConfig(context: Context) {
val filesDir = File(context.dataDir, Constants.FILES_DIR)
val config = File(filesDir, CONFIG_FILE)
if (config.exists()) config.delete()
}
} }