Revert unwanted changes

This commit is contained in:
koalasat
2025-08-09 13:45:16 +02:00
parent 58e4d31412
commit 541508c0b6

View File

@ -109,7 +109,6 @@ class WebAppInterface(private val context: MainActivity, private val webView: We
@JavascriptInterface
fun copyToClipboard(message: String) {
try {
// Copy to clipboard
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
val clip = android.content.ClipData.newPlainText("RoboSats Data", message)
@ -119,7 +118,7 @@ class WebAppInterface(private val context: MainActivity, private val webView: We
Toast.makeText(context, "Copied to clipboard", Toast.LENGTH_SHORT).show()
// Log the action (don't log the content for privacy)
Log.d(TAG, "Text copied to clipboard (${message.length} chars)")
Log.d(TAG, "Text copied to clipboard")
} catch (e: Exception) {
Log.e(TAG, "Error copying to clipboard", e)
Toast.makeText(context, "Failed to copy to clipboard", Toast.LENGTH_SHORT).show()
@ -384,6 +383,29 @@ class WebAppInterface(private val context: MainActivity, private val webView: We
resolvePromise(uuid, key)
}
@JavascriptInterface
fun restart() {
try {
Log.d(TAG, "Restarting app...")
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
intent?.let {
it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
context.startActivity(it)
context.finish()
} ?: run {
Log.e(TAG, "Could not get launch intent for app restart")
Toast.makeText(context, "Failed to restart app", Toast.LENGTH_SHORT).show()
}
} catch (e: Exception) {
Log.e(TAG, "Error restarting app", e)
Toast.makeText(context, "Failed to restart app", Toast.LENGTH_SHORT).show()
}
}
private fun onWsMessage(path: String?, message: String?) {
val encodedMessage = encodeForJavaScript(message)
safeEvaluateJavascript("javascript:window.AndroidRobosats.onWSMessage('$path', '$encodedMessage')")