]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Extend GUI so the MTU can be entered
authorTobias Brunner <tobias@strongswan.org>
Mon, 15 Jun 2015 14:59:12 +0000 (16:59 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 22 Jun 2015 15:39:55 +0000 (17:39 +0200)
This also adds a new area for advanced settings that is only displayed
if the user requests it (or if advanced settings already have been set).

The min. MTU for IPv6 is 1280, anything lower lets the TUN device
creation fail if an IPv6 address has been assigned.  If lower MTUs are
necessary we might be able to catch that later when setting the MTU and
just use at least 1280 if an IPv6 address was assigned, but let's keep
it simple for now.

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 91cd345ffc74a7ea9a67d6e286925a3c700f4c29..15fe42401b3f602c03c76b84a90aac354e498d74 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-    Copyright (C) 2012 Tobias Brunner
+    Copyright (C) 2012-2015 Tobias Brunner
     Copyright (C) 2012 Giuliano Grassi
     Copyright (C) 2012 Ralf Sager
     Hochschule fuer Technik Rapperswil
             android:id="@+id/select_certificate"
             layout="@layout/two_line_button" />
 
+        <CheckBox
+            android:id="@+id/show_advanced"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/profile_show_advanced_label" />
+
+        <LinearLayout
+            android:id="@+id/advanced_settings"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical" >
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="10dp"
+                android:text="@string/profile_mtu_label" />
+
+            <EditText
+                android:id="@+id/mtu"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:singleLine="true"
+                android:inputType="number|textNoSuggestions"
+                android:hint="@string/profile_use_default_hint" />
+
+        </LinearLayout>
     </LinearLayout>
 
 </ScrollView>
\ No newline at end of file
index 491fe8a8a0e6f139c470e0accfcdfab016fd95df..4dfffb7098ebdf3f7c795090e5f459ef9c33e9f2 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-    Copyright (C) 2012-2013 Tobias Brunner
+    Copyright (C) 2012-2015 Tobias Brunner
     Copyright (C) 2012 Giuliano Grassi
     Copyright (C) 2012 Ralf Sager
     Hochschule fuer Technik Rapperswil
     <string name="profile_ca_auto_label">Automatisch wählen</string>
     <string name="profile_ca_select_certificate_label">CA-Zertifikat auswählen</string>
     <string name="profile_ca_select_certificate">Wählen Sie ein bestimmtes CA-Zertifikat</string>
+    <string name="profile_show_advanced_label">Erweiterte Einstellungen anzeigen</string>
+    <string name="profile_mtu_label">MTU:</string>
+    <string name="profile_use_default_hint">(Standardwert verwenden)</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>
     <string name="alert_text_nocertfound_title">Kein CA-Zertifikat ausgewählt</string>
     <string name="alert_text_nocertfound">Bitte wählen Sie eines aus oder aktivieren Sie <i>Automatisch wählen</i></string>
+    <string name="alert_text_out_of_range">Bitte geben Sie eine Nummer von %1$d - %2$d ein</string>
     <string name="tnc_notice_title">EAP-TNC kann Ihre Privatsphäre beeinträchtigen</string>
     <string name="tnc_notice_subtitle">Gerätedaten werden an den Gateway-Betreiber gesendet</string>
     <string name="tnc_notice_details">&lt;p>Trusted Network Connect (TNC) erlaubt Gateway-Betreibern den Gesundheitszustand von Endgeräten zu prüfen.&lt;/p>&lt;p>Dazu kann der Betreiber Daten verlangen, wie etwa eine eindeutige Identifikationsnummer, eine Liste der installierten Pakete, Systemeinstellungen oder kryptografische Prüfsummen von Dateien.&lt;/p>&lt;b>Solche Daten werden nur übermittelt nachdem die Identität des Gateways geprüft wurde.&lt;/b></string>
index d0cfa48f197111482f5f6ffe94cbd8762c72bc1c..a46e8da2aadde7a9fd093069fb4c163dba536d2c 100644 (file)
     <string name="profile_ca_auto_label">Wybierz automatycznie</string>
     <string name="profile_ca_select_certificate_label">Wybierz certyfikat CA</string>
     <string name="profile_ca_select_certificate">Wybierz określony certyfikat CA</string>
+    <string name="profile_show_advanced_label">Show advanced settings</string>
+    <string name="profile_mtu_label">MTU:</string>
+    <string name="profile_use_default_hint">(use default)</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>
     <string name="alert_text_nocertfound_title">Nie wybrano żadnego certyfikatu CA</string>
     <string name="alert_text_nocertfound">Wybierz lub uaktywnij jeden <i>Wybierz automatycznie</i></string>
+    <string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the gateway operator</string>
     <string name="tnc_notice_details">&lt;p>Trusted Network Connect (TNC) allows gateway operators to assess the health of a client device.&lt;/p>&lt;p>For that purpose the gateway operator may request data such as a unique identifier, a list of installed packages, system settings, or cryptographic checksums of files.&lt;/p>&lt;b>Any data will be sent only after verifying the gateway\'s identity.&lt;/b></string>
index eb69183db5696bd0306a81d7636072a1cc823989..7fbe231d3269f59eea4d1e4336ae3752a5c50d27 100644 (file)
     <string name="profile_ca_auto_label">Выбрать автоматически</string>
     <string name="profile_ca_select_certificate_label">Выбрать сертификат CA</string>
     <string name="profile_ca_select_certificate">Выбрать CA сертификат</string>
+    <string name="profile_show_advanced_label">Show advanced settings</string>
+    <string name="profile_mtu_label">MTU:</string>
+    <string name="profile_use_default_hint">(use default)</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">Пожалуйста введите адрес шлюза</string>
     <string name="alert_text_no_input_username">Пожалуйста введите имя пользователя</string>
     <string name="alert_text_nocertfound_title">Не выбран сертификат CA</string>
     <string name="alert_text_nocertfound">Пожалуйста выберите один <i>Выбрать автоматически</i></string>
+    <string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the gateway operator</string>
     <string name="tnc_notice_details">&lt;p>Trusted Network Connect (TNC) allows gateway operators to assess the health of a client device.&lt;/p>&lt;p>For that purpose the gateway operator may request data such as a unique identifier, a list of installed packages, system settings, or cryptographic checksums of files.&lt;/p>&lt;b>Any data will be sent only after verifying the gateway\'s identity.&lt;/b></string>
index e23b9b9b27149a4db6e6c3d47f08738a12d7ab22..19587b2194da364006c85b2b8f2825f9fee093be 100644 (file)
     <string name="profile_ca_auto_label">Вибрати автоматично</string>
     <string name="profile_ca_select_certificate_label">Вибрати сертифікат CA</string>
     <string name="profile_ca_select_certificate">Вибрати спеціальний сертифікат CA</string>
+    <string name="profile_show_advanced_label">Show advanced settings</string>
+    <string name="profile_mtu_label">MTU:</string>
+    <string name="profile_use_default_hint">(use default)</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">Введіть адресу шлюза тут</string>
     <string name="alert_text_no_input_username">Введіть ім\'я користувача тут</string>
     <string name="alert_text_nocertfound_title">Не вибрано сертифікат CA</string>
     <string name="alert_text_nocertfound">Будь ласка виберіть один <i>Вибрати автоматично</i></string>
+    <string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the gateway operator</string>
     <string name="tnc_notice_details">&lt;p>Trusted Network Connect (TNC) allows gateway operators to assess the health of a client device.&lt;/p>&lt;p>For that purpose the gateway operator may request data such as a unique identifier, a list of installed packages, system settings, or cryptographic checksums of files.&lt;/p>&lt;b>Any data will be sent only after verifying the gateway\'s identity.&lt;/b></string>
index 933a80aff1efaf192bce28b6a4d0c01c2e7de246..3e9d7337c6c80b58082ea4e902397574dcd49c51 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-    Copyright (C) 2012-2013 Tobias Brunner
+    Copyright (C) 2012-2015 Tobias Brunner
     Copyright (C) 2012 Giuliano Grassi
     Copyright (C) 2012 Ralf Sager
     Hochschule fuer Technik Rapperswil
     <string name="profile_ca_auto_label">Select automatically</string>
     <string name="profile_ca_select_certificate_label">Select CA certificate</string>
     <string name="profile_ca_select_certificate">Select a specific CA certificate</string>
+    <string name="profile_show_advanced_label">Show advanced settings</string>
+    <string name="profile_mtu_label">MTU:</string>
+    <string name="profile_use_default_hint">(use default)</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>
     <string name="alert_text_nocertfound_title">No CA certificate selected</string>
     <string name="alert_text_nocertfound">Please select one or activate <i>Select automatically</i></string>
+    <string name="alert_text_out_of_range">Please enter a number in the range from %1$d - %2$d</string>
     <string name="tnc_notice_title">EAP-TNC may affect your privacy</string>
     <string name="tnc_notice_subtitle">Device data is sent to the gateway operator</string>
     <string name="tnc_notice_details">&lt;p>Trusted Network Connect (TNC) allows gateway operators to assess the health of a client device.&lt;/p>&lt;p>For that purpose the gateway operator may request data such as a unique identifier, a list of installed packages, system settings, or cryptographic checksums of files.&lt;/p>&lt;b>Any data will be sent only after verifying the gateway\'s identity.&lt;/b></string>
index 41cd6e98c29d058f5f33d1048e9a8a688f9a0ba4..8d8e07f9daaa33558628f3e7e9f5eb4cf1d433ea 100644 (file)
@@ -60,6 +60,8 @@ import android.widget.TextView;
 public class VpnProfileDetailActivity extends Activity
 {
        private static final int SELECT_TRUSTED_CERTIFICATE = 0;
+       private static final int MTU_MIN = 1280;
+       private static final int MTU_MAX = 1500;
 
        private VpnProfileDataSource mDataSource;
        private Long mId;
@@ -79,6 +81,9 @@ public class VpnProfileDetailActivity extends Activity
        private CheckBox mCheckAuto;
        private RelativeLayout mSelectCert;
        private RelativeLayout mTncNotice;
+       private CheckBox mShowAdvanced;
+       private ViewGroup mAdvancedSettings;
+       private EditText mMTU;
 
        @Override
        public void onCreate(Bundle savedInstanceState)
@@ -108,6 +113,11 @@ public class VpnProfileDetailActivity extends Activity
                mCheckAuto = (CheckBox)findViewById(R.id.ca_auto);
                mSelectCert = (RelativeLayout)findViewById(R.id.select_certificate);
 
+               mShowAdvanced = (CheckBox)findViewById(R.id.show_advanced);
+               mAdvancedSettings = (ViewGroup)findViewById(R.id.advanced_settings);
+
+               mMTU = (EditText)findViewById(R.id.mtu);
+
                mSelectVpnType.setOnItemSelectedListener(new OnItemSelectedListener() {
                        @Override
                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
@@ -154,6 +164,14 @@ public class VpnProfileDetailActivity extends Activity
                        }
                });
 
+               mShowAdvanced.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+                       @Override
+                       public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
+                       {
+                               updateAdvancedSettings();
+                       }
+               });
+
                mId = savedInstanceState == null ? null : savedInstanceState.getLong(VpnProfileDataSource.KEY_ID);
                if (mId == null)
                {
@@ -165,6 +183,7 @@ public class VpnProfileDetailActivity extends Activity
 
                updateCredentialView();
                updateCertificateSelector();
+               updateAdvancedSettings();
        }
 
        @Override
@@ -314,6 +333,21 @@ public class VpnProfileDetailActivity extends Activity
                }
        }
 
+       /**
+        * Update the advanced settings UI depending on whether any advanced
+        * settings have already been made.
+        */
+       private void updateAdvancedSettings()
+       {
+               boolean show = mShowAdvanced.isChecked();
+               if (!show && mProfile != null)
+               {
+                       show = mProfile.getMTU() != null;
+               }
+               mShowAdvanced.setVisibility(!show ? View.VISIBLE : View.GONE);
+               mAdvancedSettings.setVisibility(show ? View.VISIBLE : View.GONE);
+       }
+
        /**
         * Save or update the profile depending on whether we actually have a
         * profile object or not (this was created in updateProfileData)
@@ -368,6 +402,12 @@ public class VpnProfileDetailActivity extends Activity
                        showCertificateAlert();
                        valid = false;
                }
+               Integer mtu = getInteger(mMTU);
+               if (mtu != null && (mtu < MTU_MIN || mtu > MTU_MAX))
+               {
+                       mMTU.setError(String.format(getString(R.string.alert_text_out_of_range), MTU_MIN, MTU_MAX));
+                       valid = false;
+               }
                return valid;
        }
 
@@ -395,6 +435,7 @@ public class VpnProfileDetailActivity extends Activity
                }
                String certAlias = mCheckAuto.isChecked() ? null : mCertEntry.getAlias();
                mProfile.setCertificateAlias(certAlias);
+               mProfile.setMTU(getInteger(mMTU));
        }
 
        /**
@@ -417,6 +458,7 @@ public class VpnProfileDetailActivity extends Activity
                                mVpnType = mProfile.getVpnType();
                                mUsername.setText(mProfile.getUsername());
                                mPassword.setText(mProfile.getPassword());
+                               mMTU.setText(mProfile.getMTU() != null ? mProfile.getMTU().toString() : null);
                                useralias = mProfile.getUserCertificateAlias();
                                alias = mProfile.getCertificateAlias();
                                getActionBar().setTitle(mProfile.getName());
@@ -458,6 +500,17 @@ public class VpnProfileDetailActivity extends Activity
                }
        }
 
+       /**
+        * Get the integer value in the given text box or null if empty
+        *
+        * @param view text box (numeric entry assumed)
+        */
+       private Integer getInteger(EditText view)
+       {
+               String value = view.getText().toString().trim();
+               return value.isEmpty() ? null : Integer.valueOf(value);
+       }
+
        private class SelectUserCertOnClickListener implements OnClickListener, KeyChainAliasCallback
        {
                @Override