chore: move showRecoveryAlert to Utils
This commit is contained in:
parent
c5279ae484
commit
0f0fc1645a
3 changed files with 34 additions and 32 deletions
|
|
@ -1,8 +1,12 @@
|
|||
package io.github.revenge.xposed
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.app.AndroidAppHelper
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import io.github.revenge.xposed.modules.UpdaterModule
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.io.File
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class Utils {
|
||||
|
|
@ -15,6 +19,32 @@ class Utils {
|
|||
application.startActivity(Intent.makeRestartActivityTask(intent!!.component))
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
fun showRecoveryAlert(context: Context) {
|
||||
AlertDialog.Builder(context).setTitle("Revenge Recovery Options")
|
||||
.setItems(arrayOf("Reload", "Delete Script", "Reset Loader Config")) { _, which ->
|
||||
when (which) {
|
||||
0 -> {
|
||||
reloadApp()
|
||||
}
|
||||
|
||||
1 -> {
|
||||
val bundleFile = File(
|
||||
context.dataDir, "${Constants.CACHE_DIR}/${Constants.MAIN_SCRIPT_FILE}"
|
||||
)
|
||||
|
||||
if (bundleFile.exists()) bundleFile.delete()
|
||||
|
||||
reloadApp()
|
||||
}
|
||||
|
||||
2 -> {
|
||||
UpdaterModule.resetLoaderConfig(context)
|
||||
reloadApp()
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
|
||||
object Log {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
package io.github.revenge.xposed.modules
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import io.github.revenge.xposed.Constants
|
||||
import io.github.revenge.xposed.Module
|
||||
import io.github.revenge.xposed.Utils
|
||||
import io.github.revenge.xposed.Utils.Companion.reloadApp
|
||||
import io.github.revenge.xposed.Utils.Log
|
||||
import java.io.File
|
||||
|
||||
class LogBoxModule : Module() {
|
||||
lateinit var packageParam: XC_LoadPackage.LoadPackageParam
|
||||
|
|
@ -51,7 +50,7 @@ class LogBoxModule : Module() {
|
|||
showDevOptionsDialogMethod.hook {
|
||||
before {
|
||||
try {
|
||||
showRecoveryAlert(context)
|
||||
Utils.showRecoveryAlert(context)
|
||||
} catch (ex: Exception) {
|
||||
Log.e("Failed to show dev options dialog: $ex")
|
||||
}
|
||||
|
|
@ -61,32 +60,4 @@ class LogBoxModule : Module() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun showRecoveryAlert(context: Context) {
|
||||
AlertDialog.Builder(context).setTitle("Revenge Recovery Options")
|
||||
.setItems(arrayOf("Reload", "Delete Script", "Reset Loader Config")) { _, which ->
|
||||
when (which) {
|
||||
0 -> {
|
||||
reloadApp()
|
||||
}
|
||||
|
||||
1 -> {
|
||||
val bundleFile = File(
|
||||
context.dataDir, "${Constants.CACHE_DIR}/${Constants.MAIN_SCRIPT_FILE}"
|
||||
)
|
||||
|
||||
if (bundleFile.exists()) bundleFile.delete()
|
||||
|
||||
reloadApp()
|
||||
}
|
||||
|
||||
2 -> {
|
||||
UpdaterModule.resetLoaderConfig(context)
|
||||
reloadApp()
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import androidx.core.util.writeBytes
|
|||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import io.github.revenge.xposed.Constants
|
||||
import io.github.revenge.xposed.Module
|
||||
import io.github.revenge.xposed.Utils
|
||||
import io.github.revenge.xposed.Utils.Companion.JSON
|
||||
import io.github.revenge.xposed.Utils.Companion.reloadApp
|
||||
import io.github.revenge.xposed.Utils.Log
|
||||
|
|
@ -157,7 +158,7 @@ object UpdaterModule : Module() {
|
|||
Toast.makeText(activity, "Retrying download in background...", Toast.LENGTH_SHORT).show()
|
||||
dialog.dismiss()
|
||||
}.setNeutralButton("Recovery") { dialog, _ ->
|
||||
LogBoxModule.showRecoveryAlert(activity)
|
||||
Utils.showRecoveryAlert(activity)
|
||||
dialog.dismiss()
|
||||
}.show()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue