summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Constants.java2
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java80
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/firewall/FirewallManager.java17
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java24
-rw-r--r--app/src/main/res/layout/f_drawer_main.xml41
-rw-r--r--app/src/main/res/values/strings.xml7
6 files changed, 140 insertions, 31 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Constants.java b/app/src/main/java/se/leap/bitmaskclient/Constants.java
index 6a065d84..60edc941 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Constants.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Constants.java
@@ -19,6 +19,8 @@ public interface Constants {
String ALLOW_TETHERING_BLUETOOTH = "tethering_bluetooth";
String ALLOW_TETHERING_WIFI = "tethering_wifi";
String ALLOW_TETHERING_USB = "tethering_usb";
+ String SHOW_EXPERIMENTAL = "show_experimental";
+ String USE_IPv6_FIREWALL = "use_ipv6_firewall";
//////////////////////////////////////////////
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 de24802a..104f1edc 100644
--- a/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/drawer/NavigationDrawerFragment.java
@@ -43,6 +43,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.TextView;
import java.util.Set;
@@ -56,6 +57,7 @@ import se.leap.bitmaskclient.ProviderListActivity;
import se.leap.bitmaskclient.ProviderObservable;
import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.eip.EipCommand;
+import se.leap.bitmaskclient.firewall.FirewallManager;
import se.leap.bitmaskclient.fragments.AboutFragment;
import se.leap.bitmaskclient.fragments.AlwaysOnDialog;
import se.leap.bitmaskclient.fragments.ExcludeAppsFragment;
@@ -82,6 +84,7 @@ import static se.leap.bitmaskclient.utils.PreferenceHelper.getSaveBattery;
import static se.leap.bitmaskclient.utils.PreferenceHelper.getShowAlwaysOnDialog;
import static se.leap.bitmaskclient.utils.PreferenceHelper.getUsePluggableTransports;
import static se.leap.bitmaskclient.utils.PreferenceHelper.saveBattery;
+import static se.leap.bitmaskclient.utils.PreferenceHelper.showExperimentalFeatures;
import static se.leap.bitmaskclient.utils.PreferenceHelper.usePluggableTransports;
/**
@@ -110,6 +113,9 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen
private Toolbar toolbar;
private IconTextEntry account;
private IconSwitchEntry saveBattery;
+ private IconTextEntry tethering;
+ private IconSwitchEntry firewall;
+ private View experimentalFeatureFooter;
private boolean userLearnedDrawer;
private volatile boolean wasPaused;
@@ -237,8 +243,11 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen
initUseBridgesEntry();
initSaveBatteryEntry();
initAlwaysOnVpnEntry();
- initTetheringEntry();
initExcludeAppsEntry();
+ initShowExperimentalHint();
+ initTetheringEntry();
+ initFirewallEntry();
+ initExperimentalFeatureFooter();
initDonateEntry();
initLogEntry();
initAboutEntry();
@@ -323,19 +332,6 @@ 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);
@@ -354,6 +350,62 @@ public class NavigationDrawerFragment extends Fragment implements SharedPreferen
}
}
+ private void initShowExperimentalHint() {
+ TextView textView = drawerLayout.findViewById(R.id.show_experimental_features);
+ textView.setText(showExperimentalFeatures(getContext()) ? R.string.hide_experimental : R.string.show_experimental);
+ textView.setOnClickListener(v -> {
+ boolean shown = showExperimentalFeatures(getContext());
+ if (shown) {
+ tethering.setVisibility(GONE);
+ firewall.setVisibility(GONE);
+ experimentalFeatureFooter.setVisibility(GONE);
+ ((TextView) v).setText(R.string.show_experimental);
+ } else {
+ tethering.setVisibility(VISIBLE);
+ firewall.setVisibility(VISIBLE);
+ experimentalFeatureFooter.setVisibility(VISIBLE);
+ ((TextView) v).setText(R.string.hide_experimental);
+ }
+ PreferenceHelper.setShowExperimentalFeatures(getContext(), !shown);
+ });
+ }
+
+ private void initFirewallEntry() {
+ firewall = drawerView.findViewById(R.id.enableIPv6Firewall);
+ boolean show = showExperimentalFeatures(getContext());
+ firewall.setVisibility(show ? VISIBLE : GONE);
+ firewall.setChecked(PreferenceHelper.useIpv6Firewall(this.getContext()));
+ firewall.setOnCheckedChangeListener((buttonView, isChecked) -> {
+ if (!buttonView.isPressed()) {
+ return;
+ }
+ PreferenceHelper.setUseIPv6Firewall(getContext(), isChecked);
+ FirewallManager firewallManager = new FirewallManager(getContext().getApplicationContext(), false);
+ if (VpnStatus.isVPNActive()) {
+ if (isChecked) {
+ firewallManager.startIPv6Firewall();
+ } else {
+ firewallManager.stopIPv6Firewall();
+ }
+ }
+ });
+ }
+
+ private void initTetheringEntry() {
+ tethering = drawerView.findViewById(R.id.tethering);
+ boolean show = showExperimentalFeatures(getContext());
+ tethering.setVisibility(show ? VISIBLE : GONE);
+ tethering.setOnClickListener((buttonView) -> {
+ showTetheringAlert();
+ });
+ }
+
+ private void initExperimentalFeatureFooter() {
+ experimentalFeatureFooter = drawerView.findViewById(R.id.experimental_features_footer);
+ boolean show = showExperimentalFeatures(getContext());
+ experimentalFeatureFooter.setVisibility(show ? VISIBLE : GONE);
+ }
+
private void initDonateEntry() {
if (ENABLE_DONATION) {
IconTextEntry donate = drawerView.findViewById(R.id.donate);
diff --git a/app/src/main/java/se/leap/bitmaskclient/firewall/FirewallManager.java b/app/src/main/java/se/leap/bitmaskclient/firewall/FirewallManager.java
index 30ecebea..c148497b 100644
--- a/app/src/main/java/se/leap/bitmaskclient/firewall/FirewallManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/firewall/FirewallManager.java
@@ -94,7 +94,9 @@ public class FirewallManager implements FirewallCallback, Observer {
public void start() {
if (!isRunning) {
isRunning = true;
- startIPv6Firewall();
+ if (PreferenceHelper.useIpv6Firewall(context)) {
+ startIPv6Firewall();
+ }
TetheringState tetheringState = TetheringObservable.getInstance().getTetheringState();
if (tetheringState.hasAnyDeviceTetheringEnabled() && tetheringState.hasAnyVpnTetheringAllowed()) {
startTethering();
@@ -105,8 +107,13 @@ public class FirewallManager implements FirewallCallback, Observer {
public void stop() {
isRunning = false;
- stopIPv6Firewall();
- stopTethering();
+ if (PreferenceHelper.useIpv6Firewall(context)) {
+ stopIPv6Firewall();
+ }
+ TetheringState tetheringState = TetheringObservable.getInstance().getTetheringState();
+ if (tetheringState.hasAnyDeviceTetheringEnabled() && tetheringState.hasAnyVpnTetheringAllowed()) {
+ stopTethering();
+ }
}
public void startTethering() {
@@ -119,12 +126,12 @@ public class FirewallManager implements FirewallCallback, Observer {
task.execute();
}
- private void startIPv6Firewall() {
+ public void startIPv6Firewall() {
StartIPv6FirewallTask task = new StartIPv6FirewallTask(this);
task.execute();
}
- private void stopIPv6Firewall() {
+ public void stopIPv6Firewall() {
ShutdownIPv6FirewallTask task = new ShutdownIPv6FirewallTask(this);
task.execute();
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java b/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java
index 073e338c..6f9744bc 100644
--- a/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/utils/PreferenceHelper.java
@@ -16,6 +16,9 @@ import de.blinkt.openvpn.VpnProfile;
import se.leap.bitmaskclient.Provider;
import static android.content.Context.MODE_PRIVATE;
+import static se.leap.bitmaskclient.Constants.ALLOW_TETHERING_BLUETOOTH;
+import static se.leap.bitmaskclient.Constants.ALLOW_TETHERING_USB;
+import static se.leap.bitmaskclient.Constants.ALLOW_TETHERING_WIFI;
import static se.leap.bitmaskclient.Constants.ALWAYS_ON_SHOW_DIALOG;
import static se.leap.bitmaskclient.Constants.DEFAULT_SHARED_PREFS_BATTERY_SAVER;
import static se.leap.bitmaskclient.Constants.EXCLUDED_APPS;
@@ -25,10 +28,9 @@ import static se.leap.bitmaskclient.Constants.PROVIDER_EIP_DEFINITION;
import static se.leap.bitmaskclient.Constants.PROVIDER_PRIVATE_KEY;
import static se.leap.bitmaskclient.Constants.PROVIDER_VPN_CERTIFICATE;
import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
+import static se.leap.bitmaskclient.Constants.SHOW_EXPERIMENTAL;
import static se.leap.bitmaskclient.Constants.SU_PERMISSION;
-import static se.leap.bitmaskclient.Constants.ALLOW_TETHERING_BLUETOOTH;
-import static se.leap.bitmaskclient.Constants.ALLOW_TETHERING_USB;
-import static se.leap.bitmaskclient.Constants.ALLOW_TETHERING_WIFI;
+import static se.leap.bitmaskclient.Constants.USE_IPv6_FIREWALL;
import static se.leap.bitmaskclient.Constants.USE_PLUGGABLE_TRANSPORTS;
/**
@@ -167,6 +169,22 @@ public class PreferenceHelper {
return getBoolean(context, ALLOW_TETHERING_BLUETOOTH, false);
}
+ public static void setShowExperimentalFeatures(Context context, boolean show) {
+ putBoolean(context, SHOW_EXPERIMENTAL, show);
+ }
+
+ public static boolean showExperimentalFeatures(Context context) {
+ return getBoolean(context, SHOW_EXPERIMENTAL, false);
+ }
+
+ public static void setUseIPv6Firewall(Context context, boolean useFirewall) {
+ putBoolean(context, USE_IPv6_FIREWALL, useFirewall);
+ }
+
+ public static boolean useIpv6Firewall(Context context) {
+ return getBoolean(context, USE_IPv6_FIREWALL, false);
+ }
+
public static void saveShowAlwaysOnDialog(Context context, boolean showAlwaysOnDialog) {
putBoolean(context, ALWAYS_ON_SHOW_DIALOG, showAlwaysOnDialog);
}
diff --git a/app/src/main/res/layout/f_drawer_main.xml b/app/src/main/res/layout/f_drawer_main.xml
index 505bd714..191d547f 100644
--- a/app/src/main/res/layout/f_drawer_main.xml
+++ b/app/src/main/res/layout/f_drawer_main.xml
@@ -88,29 +88,56 @@
android:visibility="gone"
/>
-
<se.leap.bitmaskclient.views.IconTextEntry
- android:id="@+id/tethering"
+ android:id="@+id/exclude_apps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- app:text="@string/tethering"
- app:icon="@drawable/ic_access_point_36"
+ app:text="@string/exclude_apps_fragment_title"
+ app:icon="@drawable/ic_shield_remove_grey600_36dp"
android:visibility="gone"
/>
+ <TextView
+ android:id="@+id/show_experimental_features"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/show_experimental"
+ android:textColor="@color/colorPrimaryDark"
+ android:paddingTop="6dp"
+ android:paddingBottom="6dp"
+ android:gravity="center"
+ android:background="@color/black800_high_transparent"
+ />
+
+ <se.leap.bitmaskclient.views.IconSwitchEntry
+ android:id="@+id/enableIPv6Firewall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:text="@string/ipv6Firewall"
+ app:subtitle="@string/require_root"
+ app:icon="@drawable/ic_cancel"
+ android:visibility="gone"
+ tools:visibility="visible"
+ />
+
<se.leap.bitmaskclient.views.IconTextEntry
- android:id="@+id/exclude_apps"
+ android:id="@+id/tethering"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- app:text="@string/exclude_apps_fragment_title"
- app:icon="@drawable/ic_shield_remove_grey600_36dp"
+ app:text="@string/tethering"
+ app:subtitle="@string/require_root"
+ app:icon="@drawable/ic_access_point_36"
android:visibility="gone"
+ tools:visibility="visible"
/>
<View
+ android:id="@+id/experimental_features_footer"
android:layout_width="match_parent"
android:layout_height="20dp"
android:background="@color/black800_high_transparent"
+ android:visibility="gone"
+ tools:visibility="visible"
/>
<se.leap.bitmaskclient.views.IconTextEntry
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f8e6b887..9b6f3125 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -106,8 +106,11 @@
<string name="always_on_vpn">Always-on VPN</string>
<string name="subtitle_always_on_vpn">Open Android System Settings</string>
<string name="tethering">VPN Hotspot</string>
- <string name="subtitle_tethering">Share your VPN</string>
- <string name="tethering_enabled_message">Please make sure that you have enabled tethering in the %s first!</string>
+ <string name="ipv6Firewall">Firewall</string>
+ <string name="require_root">Requires root permissions</string>
+ <string name="show_experimental">Show experimental options</string>
+ <string name="hide_experimental">Hide experimental options</string>
+ <string name="tethering_enabled_message">Please make sure to enable tethering in the %s first!</string>
<string name="tethering_system_settings">system settings</string>
<string name="tethering_message">Share your VPN with other devices via:</string>
<string name="tethering_wifi">Wifi hotspot</string>