From 62e36ee804262be866946ca467f7abeb2746add4 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sun, 25 Feb 2018 13:00:13 +0100 Subject: #8808 add a link to android's vpn settings for API >= 24 --- .../main/java/se/leap/bitmaskclient/DrawerSettingsAdapter.java | 1 + .../se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java | 10 ++++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 12 insertions(+) diff --git a/app/src/main/java/se/leap/bitmaskclient/DrawerSettingsAdapter.java b/app/src/main/java/se/leap/bitmaskclient/DrawerSettingsAdapter.java index 867f3d48..9b40d36f 100644 --- a/app/src/main/java/se/leap/bitmaskclient/DrawerSettingsAdapter.java +++ b/app/src/main/java/se/leap/bitmaskclient/DrawerSettingsAdapter.java @@ -39,6 +39,7 @@ public class DrawerSettingsAdapter extends BaseAdapter { public static final int LOG = 1; public static final int ABOUT = 2; public static final int BATTERY_SAVER = 3; + public static final int ALWAYS_ON = 4; //view types public final static int VIEW_SIMPLE_TEXT = 0; 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 6e39e9ed..2a7d8def 100644 --- a/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java @@ -22,6 +22,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; @@ -62,6 +63,7 @@ import static se.leap.bitmaskclient.Constants.PROVIDER_KEY; import static se.leap.bitmaskclient.Constants.REQUEST_CODE_SWITCH_PROVIDER; import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; import static se.leap.bitmaskclient.DrawerSettingsAdapter.ABOUT; +import static se.leap.bitmaskclient.DrawerSettingsAdapter.ALWAYS_ON; import static se.leap.bitmaskclient.DrawerSettingsAdapter.BATTERY_SAVER; import static se.leap.bitmaskclient.DrawerSettingsAdapter.DrawerSettingsItem.getSimpleTextInstance; import static se.leap.bitmaskclient.DrawerSettingsAdapter.DrawerSettingsItem.getSwitchInstance; @@ -171,6 +173,9 @@ public class NavigationDrawerFragment extends Fragment { } })); } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + settingsListAdapter.addItem(getSimpleTextInstance(getString(R.string.always_on_vpn), ALWAYS_ON)); + } settingsListAdapter.addItem(getSimpleTextInstance(getString(switch_provider_menu_option), SWITCH_PROVIDER)); settingsListAdapter.addItem(getSimpleTextInstance(getString(log_fragment_title), LOG)); settingsListAdapter.addItem(getSimpleTextInstance(getString(about_fragment_title), ABOUT)); @@ -422,6 +427,11 @@ public class NavigationDrawerFragment extends Fragment { mTitle = getString(about_fragment_title); fragment = new AboutFragment(); break; + case ALWAYS_ON: + Intent intent = new Intent("android.net.vpn.SETTINGS"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + break; default: break; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 71b6d437..03fd4584 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -110,4 +110,5 @@ The VPN certificate is invalid. Please log in to download a new one. Save battery Background data connections will hibernate when your phone is inactive. This feature is still experimental. + Always-on VPN -- cgit v1.2.3