From 24a75a3581eabe9f6b161234556c0f6f8959d2d6 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 9 Oct 2021 20:02:48 -0400 Subject: [PATCH] Fix possible crash when copying --- .../be/mygod/vpnhotspot/net/wifi/WifiApDialogFragment.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApDialogFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApDialogFragment.kt index b62f2903..90f0e61a 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApDialogFragment.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApDialogFragment.kt @@ -351,10 +351,13 @@ class WifiApDialogFragment : AlertDialogFragment { + android.R.id.copy -> try { app.clipboard.setPrimaryClip(ClipData.newPlainText(null, Base64.encodeToString(generateConfig().toByteArray(), BASE64_FLAGS))) true + } catch (e: RuntimeException) { + Toast.makeText(context, e.readableMessage, Toast.LENGTH_LONG).show() + false } android.R.id.paste -> try { app.clipboard.primaryClip?.getItemAt(0)?.text?.apply {