android: Extend GUI so the split tunneling options can be set

This commit is contained in:
Tobias Brunner
2015-07-28 13:27:33 +02:00
parent f3d8da7644
commit 3ee84fa976
7 changed files with 45 additions and 1 deletions
@@ -179,6 +179,24 @@
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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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());