diff options
author | cyBerta <cyberta@riseup.net> | 2020-01-02 23:06:36 +0100 |
---|---|---|
committer | cyberta <cyberta@riseup.net> | 2020-01-24 10:36:03 -0600 |
commit | 921ee995ef0f0e7f2076ac3538fed289bcb82ba9 (patch) | |
tree | 349b3a3472f0e5436e3abb29d8955be1c8c51c7f /app/src/main/java/se/leap/bitmaskclient/drawer | |
parent | 87bdccc31f5fcd10e697d30225105ca40114582c (diff) |
implement basic UI for VPN tethering
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/drawer')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java b/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java index 3144d62c..85c982df 100644 --- a/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java @@ -60,6 +60,7 @@ import se.leap.bitmaskclient.fragments.AboutFragment; import se.leap.bitmaskclient.fragments.AlwaysOnDialog; import se.leap.bitmaskclient.fragments.ExcludeAppsFragment; import se.leap.bitmaskclient.fragments.LogFragment; +import se.leap.bitmaskclient.fragments.TetheringDialog; import se.leap.bitmaskclient.utils.PreferenceHelper; import se.leap.bitmaskclient.views.IconSwitchEntry; import se.leap.bitmaskclient.views.IconTextEntry; @@ -236,6 +237,7 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen initUseBridgesEntry(); initSaveBatteryEntry(); initAlwaysOnVpnEntry(); + initTetheringEntry(); initExcludeAppsEntry(); initDonateEntry(); initLogEntry(); @@ -321,6 +323,19 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen } } + private void initTetheringEntry() { + IconTextEntry tethering = drawerView.findViewById(R.id.tethering); + if (PreferenceHelper.hasSuPermission(getContext())) { + tethering.setVisibility(VISIBLE); + tethering.setOnClickListener((buttonView) -> { + showTetheringAlert(); + }); + } else { + tethering.setVisibility(GONE); + } + + } + private void initExcludeAppsEntry() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { IconTextEntry excludeApps = drawerView.findViewById(R.id.exclude_apps); @@ -442,13 +457,26 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen saveBattery(getContext(), true); }) .setNegativeButton(activity.getString(android.R.string.no), (dialog, which) -> saveBattery.setCheckedQuietly(false)) - .setOnDismissListener(dialog -> showEnableExperimentalFeature = false) + .setOnDismissListener(dialog -> showSaveBattery = false) .setOnCancelListener(dialog -> saveBattery.setCheckedQuietly(false)).show(); } catch (IllegalStateException e) { e.printStackTrace(); } } + public void showTetheringAlert() { + try { + + FragmentTransaction fragmentTransaction = new FragmentManagerEnhanced( + getActivity().getSupportFragmentManager()).removePreviousFragment( + TetheringDialog.TAG); + DialogFragment newFragment = new TetheringDialog(); + newFragment.show(fragmentTransaction, TetheringDialog.TAG); + } catch (IllegalStateException | NullPointerException e) { + e.printStackTrace(); + } + } + public void showAlwaysOnDialog() { try { |