11package io.github.revenge.xposed.modules.bridge
22
3+ import android.app.Activity
34import android.app.AlertDialog
45import android.content.ClipData
56import android.content.ClipboardManager
@@ -12,42 +13,6 @@ import java.io.File
1213
1314class AdditionalBridgeMethodsModule : Module () {
1415 override fun onContext (context : Context ) = with (context) {
15- BridgeModule .registerMethod(" revenge.alertError" ) {
16- val (error, version) = it
17- val app = getAppInfo()
18- val errorString = " $error "
19-
20- val clipboard = applicationContext.getSystemService(Context .CLIPBOARD_SERVICE ) as ClipboardManager
21- val clip = ClipData .newPlainText(" Stack Trace" , errorString)
22-
23- AlertDialog .Builder (this )
24- .setTitle(" Revenge Error" )
25- .setMessage(
26- """
27- Revenge: $version
28- ${app.name} : ${app.version} (${app.versionCode} )
29- Device: ${Build .MANUFACTURER } ${Build .MODEL }
30-
31-
32- """ .trimIndent() + errorString
33- )
34- .setPositiveButton(" OK" ) { dialog, _ ->
35- dialog.dismiss()
36- }
37- .setNeutralButton(" Copy" ) { dialog, _ ->
38- clipboard.setPrimaryClip(clip)
39- Toast .makeText(applicationContext, " Copied stack trace" , Toast .LENGTH_SHORT ).show()
40- dialog.dismiss()
41- }
42- .show()
43-
44- null
45- }
46-
47- BridgeModule .registerMethod(" revenge.showRecoveryAlert" ) {
48- Utils .showRecoveryAlert(context)
49- }
50-
5116 BridgeModule .registerMethod(" revenge.fs.getConstants" ) {
5217 mapOf (
5318 " data" to dataDir.absolutePath,
@@ -84,6 +49,44 @@ class AdditionalBridgeMethodsModule : Module() {
8449 }
8550 }
8651
52+ override fun onActivity (activity : Activity ) = with (activity) {
53+ BridgeModule .registerMethod(" revenge.alertError" ) {
54+ val (error, version) = it
55+ val app = getAppInfo()
56+ val errorString = " $error "
57+
58+ val clipboard = applicationContext.getSystemService(Context .CLIPBOARD_SERVICE ) as ClipboardManager
59+ val clip = ClipData .newPlainText(" Stack Trace" , errorString)
60+
61+ AlertDialog .Builder (this )
62+ .setTitle(" Revenge Error" )
63+ .setMessage(
64+ """
65+ Revenge: $version
66+ ${app.name} : ${app.version} (${app.versionCode} )
67+ Device: ${Build .MANUFACTURER } ${Build .MODEL }
68+
69+
70+ """ .trimIndent() + errorString
71+ )
72+ .setPositiveButton(" OK" ) { dialog, _ ->
73+ dialog.dismiss()
74+ }
75+ .setNeutralButton(" Copy" ) { dialog, _ ->
76+ clipboard.setPrimaryClip(clip)
77+ Toast .makeText(applicationContext, " Copied stack trace" , Toast .LENGTH_SHORT ).show()
78+ dialog.dismiss()
79+ }
80+ .show()
81+
82+ null
83+ }
84+
85+ BridgeModule .registerMethod(" revenge.showRecoveryAlert" ) {
86+ Utils .showRecoveryAlert(this )
87+ }
88+ }
89+
8790 private fun File.openFileGuarded () {
8891 if (! this .exists()) throw Error (" Path does not exist: $path " )
8992 if (! this .isFile) throw Error (" Path is not a file: $path " )
0 commit comments