android: Extend GUI so the split tunneling options can be set
authorTobias Brunner <tobias@strongswan.org>
Fri, 24 Jul 2015 09:47:53 +0000 (11:47 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 28 Jul 2015 11:27:33 +0000 (13:27 +0200)
src/frontends/android/res/layout/profile_detail_view.xml
src/frontends/android/res/values-de/strings.xml
src/frontends/android/res/values-pl/strings.xml
src/frontends/android/res/values-ru/strings.xml
src/frontends/android/res/values-ua/strings.xml
src/frontends/android/res/values/strings.xml
src/frontends/android/src/org/strongswan/android/ui/VpnProfileDetailActivity.java

index 089f065..57d5606 100644 (file)
                 android:inputType="number|textNoSuggestions"
                 android:hint="@string/profile_use_default_hint" />
 
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="10dp"
+                android:text="@string/profile_split_tunneling_label" />
+
+            <CheckBox
+                android:id="@+id/split_tunneling_v4"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/profile_split_tunnelingv4_title" />
+
+            <CheckBox
+                android:id="@+id/split_tunneling_v6"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/profile_split_tunnelingv6_title" />
+
         </LinearLayout>
     </LinearLayout>
 
index 6cdb5b3..6cd5ba5 100644 (file)
@@ -67,6 +67,9 @@
     <string name="profile_mtu_label">MTU:</string>
     <string name="profile_port_label">Server Port:</string>
     <string name="profile_use_default_hint">(Standardwert verwenden)</string>
+    <string name="profile_split_tunneling_label">Split-Tunneling:</string>
+    <string name="profile_split_tunnelingv4_title">Blockiere IPv4 Verkehr der nicht für das VPN bestimmt ist</string>
+    <string name="profile_split_tunnelingv6_title">Blockiere IPv6 Verkehr der nicht für das VPN bestimmt ist</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">Bitte geben Sie hier die Gateway-Adresse ein</string>
     <string name="alert_text_no_input_username">Bitte geben Sie hier Ihren Benutzernamen ein</string>
index 87c6a27..fb2aba0 100644 (file)
@@ -67,6 +67,9 @@
     <string name="profile_mtu_label">MTU:</string>
     <string name="profile_port_label">Server port:</string>
     <string name="profile_use_default_hint">(use default)</string>
+    <string name="profile_split_tunneling_label">Split tunneling:</string>
+    <string name="profile_split_tunnelingv4_title">Block IPv4 traffic not destined for the VPN</string>
+    <string name="profile_split_tunnelingv6_title">Block IPv6 traffic not destined for the VPN</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">Wprowadź adres bramki</string>
     <string name="alert_text_no_input_username">Wprowadź swoją nazwę użytkownika</string>
index 4164f61..eabfc08 100644 (file)
@@ -64,6 +64,9 @@
     <string name="profile_mtu_label">MTU:</string>
     <string name="profile_port_label">Server port:</string>
     <string name="profile_use_default_hint">(use default)</string>
+    <string name="profile_split_tunneling_label">Split tunneling:</string>
+    <string name="profile_split_tunnelingv4_title">Block IPv4 traffic not destined for the VPN</string>
+    <string name="profile_split_tunnelingv6_title">Block IPv6 traffic not destined for the VPN</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">Пожалуйста введите адрес шлюза</string>
     <string name="alert_text_no_input_username">Пожалуйста введите имя пользователя</string>
index 7e3a735..d7c2383 100644 (file)
@@ -65,6 +65,9 @@
     <string name="profile_mtu_label">MTU:</string>
     <string name="profile_port_label">Server port:</string>
     <string name="profile_use_default_hint">(use default)</string>
+    <string name="profile_split_tunneling_label">Split tunneling:</string>
+    <string name="profile_split_tunnelingv4_title">Block IPv4 traffic not destined for the VPN</string>
+    <string name="profile_split_tunnelingv6_title">Block IPv6 traffic not destined for the VPN</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">Введіть адресу шлюза тут</string>
     <string name="alert_text_no_input_username">Введіть ім\'я користувача тут</string>
index 3c06761..5c8ebab 100644 (file)
@@ -67,6 +67,9 @@
     <string name="profile_mtu_label">MTU:</string>
     <string name="profile_port_label">Server port:</string>
     <string name="profile_use_default_hint">(use default)</string>
+    <string name="profile_split_tunneling_label">Split tunneling:</string>
+    <string name="profile_split_tunnelingv4_title">Block IPv4 traffic not destined for the VPN</string>
+    <string name="profile_split_tunnelingv6_title">Block IPv6 traffic not destined for the VPN</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">Please enter the gateway address here</string>
     <string name="alert_text_no_input_username">Please enter your username here</string>
index ff1625c..a8b3daa 100644 (file)
@@ -85,6 +85,8 @@ public class VpnProfileDetailActivity extends Activity
        private ViewGroup mAdvancedSettings;
        private EditText mMTU;
        private EditText mPort;
+       private CheckBox mBlockIPv4;
+       private CheckBox mBlockIPv6;
 
        @Override
        public void onCreate(Bundle savedInstanceState)
@@ -119,6 +121,8 @@ public class VpnProfileDetailActivity extends Activity
 
                mMTU = (EditText)findViewById(R.id.mtu);
                mPort = (EditText)findViewById(R.id.port);
+               mBlockIPv4 = (CheckBox)findViewById(R.id.split_tunneling_v4);
+               mBlockIPv6 = (CheckBox)findViewById(R.id.split_tunneling_v6);
 
                mSelectVpnType.setOnItemSelectedListener(new OnItemSelectedListener() {
                        @Override
@@ -344,7 +348,8 @@ public class VpnProfileDetailActivity extends Activity
                boolean show = mShowAdvanced.isChecked();
                if (!show && mProfile != null)
                {
-                       show = mProfile.getMTU() != null || mProfile.getPort() != null;
+                       Integer st = mProfile.getSplitTunneling();
+                       show = mProfile.getMTU() != null || mProfile.getPort() != null || (st != null && st != 0);
                }
                mShowAdvanced.setVisibility(!show ? View.VISIBLE : View.GONE);
                mAdvancedSettings.setVisibility(show ? View.VISIBLE : View.GONE);
@@ -445,6 +450,10 @@ public class VpnProfileDetailActivity extends Activity
                mProfile.setCertificateAlias(certAlias);
                mProfile.setMTU(getInteger(mMTU));
                mProfile.setPort(getInteger(mPort));
+               int st = 0;
+               st |= mBlockIPv4.isChecked() ? VpnProfile.SPLIT_TUNNELING_BLOCK_IPV4 : 0;
+               st |= mBlockIPv6.isChecked() ? VpnProfile.SPLIT_TUNNELING_BLOCK_IPV6 : 0;
+               mProfile.setSplitTunneling(st == 0 ? null : st);
        }
 
        /**
@@ -469,6 +478,8 @@ public class VpnProfileDetailActivity extends Activity
                                mPassword.setText(mProfile.getPassword());
                                mMTU.setText(mProfile.getMTU() != null ? mProfile.getMTU().toString() : null);
                                mPort.setText(mProfile.getPort() != null ? mProfile.getPort().toString() : null);
+                               mBlockIPv4.setChecked(mProfile.getSplitTunneling() != null ? (mProfile.getSplitTunneling() & VpnProfile.SPLIT_TUNNELING_BLOCK_IPV4) != 0 : false);
+                               mBlockIPv6.setChecked(mProfile.getSplitTunneling() != null ? (mProfile.getSplitTunneling() & VpnProfile.SPLIT_TUNNELING_BLOCK_IPV6) != 0 : false);
                                useralias = mProfile.getUserCertificateAlias();
                                alias = mProfile.getCertificateAlias();
                                getActionBar().setTitle(mProfile.getName());