@@ -13,6 +13,7 @@ import io.github.revenge.xposed.Utils
1313import io.github.revenge.xposed.Utils.Companion.JSON
1414import io.github.revenge.xposed.Utils.Companion.reloadApp
1515import io.github.revenge.xposed.Utils.Log
16+ import io.github.revenge.xposed.modules.bridge.BridgeModule
1617import io.ktor.client.*
1718import io.ktor.client.call.*
1819import io.ktor.client.engine.cio.*
@@ -42,6 +43,8 @@ data class LoaderConfig(
4243 */
4344object UpdaterModule : Module() {
4445 private lateinit var config: LoaderConfig
46+ val isCustomUrlEnabled: Boolean
47+ get() = config.customLoadUrl.enabled
4548 private val scope = CoroutineScope (SupervisorJob () + Dispatchers .IO )
4649 private var lastActivity: WeakReference <Activity >? = null
4750
@@ -71,9 +74,15 @@ object UpdaterModule : Module() {
7174 JSON .decodeFromString<LoaderConfig >(configFile.readText())
7275 } else LoaderConfig ()
7376 }.getOrDefault(LoaderConfig ())
77+
78+ BridgeModule .registerMethod(" revenge.updater.clear" ) {
79+ if (bundle.exists()) bundle.delete()
80+ if (etag.exists()) etag.delete()
81+ null
82+ }
7483 }
7584
76- fun downloadScript (activity : Activity ? = null): Job = scope.launch {
85+ fun downloadScript (activity : Activity ? = null, showUpdateDialog : Boolean = true ): Job = scope.launch {
7786 try {
7887 HttpClient (CIO ) {
7988 expectSuccess = false
@@ -108,15 +117,22 @@ object UpdaterModule : Module() {
108117
109118 Log .i(" Bundle updated (${bytes.size} bytes)" )
110119
111- // This is a retry, so we show a dialog
112- if (activity != null ) {
113- withContext(Dispatchers .Main ) {
114- AlertDialog .Builder (activity).setTitle(" Revenge Update Successful" )
120+ if (showUpdateDialog) {
121+ val activity = activity ? : lastActivity?.get()
122+
123+ activity?.runOnUiThread {
124+ AlertDialog .Builder (activity)
125+ .setTitle(" Revenge Update Downloaded" )
115126 .setMessage(" A reload is required for changes to take effect." )
116127 .setPositiveButton(" Reload" ) { dialog, _ ->
117128 reloadApp()
118129 dialog.dismiss()
119- }.setCancelable(false ).show()
130+ }
131+ .setNegativeButton(" Later" ) { dialog, _ ->
132+ dialog.dismiss()
133+ }
134+ .setCancelable(false )
135+ .show()
120136 }
121137 }
122138 }
0 commit comments