feat: add option to delete Devtools.js
This commit is contained in:
parent
b62f7b4daa
commit
05d6f5004d
2 changed files with 35 additions and 0 deletions
|
|
@ -187,6 +187,24 @@ object LogBoxActions {
|
|||
}
|
||||
}
|
||||
|
||||
fun deleteDevtools(context: Context) {
|
||||
try {
|
||||
val devtoolsFile = File(LogBoxUtils.getPyoncordDirectory(context), "preloads/reactDevtools.js")
|
||||
if (devtoolsFile.exists()) {
|
||||
if (devtoolsFile.delete()) {
|
||||
Toast.makeText(context, "Devtools deleted", Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Toast.makeText(context, "Failed to delete Devtools", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(context, "Devtools not found", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("Error deleting Devtools: ${e.message}")
|
||||
showError(context, "Failed to delete Devtools", e.message)
|
||||
}
|
||||
}
|
||||
|
||||
fun showError(context: Context, title: String, message: String?) {
|
||||
LogBoxMenu.showErrorDialog(context, title, message)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,23 @@ object OptionsMenu {
|
|||
)
|
||||
})
|
||||
|
||||
container.addView(LogBoxComponents.createM3Button(context, "Delete Devtools", colors) {
|
||||
dialog.dismiss()
|
||||
RecoveryMenu::class.java.getDeclaredMethod(
|
||||
"showConfirmAction",
|
||||
Context::class.java,
|
||||
String::class.java,
|
||||
String::class.java,
|
||||
Runnable::class.java
|
||||
).apply { isAccessible = true }.invoke(
|
||||
null,
|
||||
context,
|
||||
"Delete Devtools",
|
||||
"This will delete the reactDevtools.js preload file if it exists.",
|
||||
Runnable { LogBoxActions.deleteDevtools(context) }
|
||||
)
|
||||
})
|
||||
|
||||
container.addView(LogBoxComponents.createM3Button(context, "Back", colors) {
|
||||
dialog.dismiss()
|
||||
RecoveryMenu.showRecoveryMenu(context)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue