From d615304e83d349b3da741d8262e4c998ea74ae52 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 25 Jul 2018 02:37:36 +0200 Subject: [PATCH] qrcode: minor adjustments Signed-off-by: Jason A. Donenfeld --- .../fragment/ConfigNamingDialogFragment.java | 2 +- .../android/fragment/TunnelListFragment.java | 8 ++++---- .../main/res/layout/tunnel_list_fragment.xml | 20 +++++++++---------- app/src/main/res/values/strings.xml | 4 +++- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java b/app/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java index 1a3ec0d2..d89938e1 100644 --- a/app/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java +++ b/app/src/main/java/com/wireguard/android/fragment/ConfigNamingDialogFragment.java @@ -70,7 +70,7 @@ public class ConfigNamingDialogFragment extends DialogFragment { imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity); - alertDialogBuilder.setTitle(R.string.create_tunnel); + alertDialogBuilder.setTitle(R.string.import_from_qrcode); binding = ConfigNamingDialogFragmentBinding.inflate(getActivity().getLayoutInflater(), null, false); binding.executePendingBindings(); diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java index 23e449b6..e2291f9c 100644 --- a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java +++ b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java @@ -83,10 +83,8 @@ public class TunnelListFragment extends BaseFragment { // Config text is valid, now create the tunnel… final FragmentManager fragmentManager = getFragmentManager(); - if (fragmentManager != null) { - final ConfigNamingDialogFragment fragment = ConfigNamingDialogFragment.newInstance(configText); - fragment.show(fragmentManager, null); - } + if (fragmentManager != null) + ConfigNamingDialogFragment.newInstance(configText).show(fragmentManager, null); } catch (final IllegalArgumentException|IOException exception) { onTunnelImportFinished(Collections.emptyList(), Collections.singletonList(exception)); } @@ -246,6 +244,8 @@ public class TunnelListFragment extends BaseFragment { public void onRequestScanQRCode(@SuppressWarnings("unused") final View view) { final IntentIntegrator intentIntegrator = IntentIntegrator.forSupportFragment(this); intentIntegrator.setOrientationLocked(false); + intentIntegrator.setBeepEnabled(false); + intentIntegrator.setPrompt(getString(R.string.qrcode_hint)); intentIntegrator.initiateScan(Collections.singletonList(IntentIntegrator.QR_CODE)); if (binding != null) diff --git a/app/src/main/res/layout/tunnel_list_fragment.xml b/app/src/main/res/layout/tunnel_list_fragment.xml index 2a7de392..3e31159c 100644 --- a/app/src/main/res/layout/tunnel_list_fragment.xml +++ b/app/src/main/res/layout/tunnel_list_fragment.xml @@ -72,15 +72,6 @@ app:fab_labelsPosition="@integer/label_position" app:layout_behavior="com.wireguard.android.widget.fab.FloatingActionButtonBehavior" > - - + app:fab_title="@string/create_from_qrcode" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1bb43fa0..991ac98d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -30,6 +30,7 @@ Create WireGuard Tunnel Create from scratch Create from file or archive + Create from QR code Create Tunnel Use dark theme Currently using dark night theme @@ -51,6 +52,7 @@ (generated) (optional) (random) + Import Tunnel from QR Code Unable to import tunnel: %s Imported “%s” Interface @@ -69,10 +71,10 @@ Private key Public key Public key + Tip: generate with `qrencode -t ansiutf8 < tunnel.conf`. Bring up previously-enabled tunnels on boot Restore on boot Save - Scan QR Code %d Excluded Application %d Excluded Applications