android: Extend GUI so the server port can be entered
authorTobias Brunner <tobias@strongswan.org>
Tue, 16 Jun 2015 14:42:40 +0000 (16:42 +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 15fe424..089f065 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_port_label" />
+
+            <EditText
+                android:id="@+id/port"
+                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>
 
index 4dfffb7..6cdb5b3 100644 (file)
@@ -65,6 +65,7 @@
     <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_port_label">Server Port:</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>
index a46e8da..87c6a27 100644 (file)
@@ -65,6 +65,7 @@
     <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_port_label">Server port:</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>
index 7fbe231..4164f61 100644 (file)
@@ -62,6 +62,7 @@
     <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_port_label">Server port:</string>
     <string name="profile_use_default_hint">(use default)</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">Пожалуйста введите адрес шлюза</string>
index 19587b2..7e3a735 100644 (file)
@@ -63,6 +63,7 @@
     <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_port_label">Server port:</string>
     <string name="profile_use_default_hint">(use default)</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">Введіть адресу шлюза тут</string>
index 3e9d733..3c06761 100644 (file)
@@ -65,6 +65,7 @@
     <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_port_label">Server port:</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>
index 8d8e07f..ff1625c 100644 (file)
@@ -84,6 +84,7 @@ public class VpnProfileDetailActivity extends Activity
        private CheckBox mShowAdvanced;
        private ViewGroup mAdvancedSettings;
        private EditText mMTU;
+       private EditText mPort;
 
        @Override
        public void onCreate(Bundle savedInstanceState)
@@ -117,6 +118,7 @@ public class VpnProfileDetailActivity extends Activity
                mAdvancedSettings = (ViewGroup)findViewById(R.id.advanced_settings);
 
                mMTU = (EditText)findViewById(R.id.mtu);
+               mPort = (EditText)findViewById(R.id.port);
 
                mSelectVpnType.setOnItemSelectedListener(new OnItemSelectedListener() {
                        @Override
@@ -342,7 +344,7 @@ public class VpnProfileDetailActivity extends Activity
                boolean show = mShowAdvanced.isChecked();
                if (!show && mProfile != null)
                {
-                       show = mProfile.getMTU() != null;
+                       show = mProfile.getMTU() != null || mProfile.getPort() != null;
                }
                mShowAdvanced.setVisibility(!show ? View.VISIBLE : View.GONE);
                mAdvancedSettings.setVisibility(show ? View.VISIBLE : View.GONE);
@@ -408,6 +410,12 @@ public class VpnProfileDetailActivity extends Activity
                        mMTU.setError(String.format(getString(R.string.alert_text_out_of_range), MTU_MIN, MTU_MAX));
                        valid = false;
                }
+               Integer port = getInteger(mPort);
+               if (port != null && (port < 1 || port > 65535))
+               {
+                       mPort.setError(String.format(getString(R.string.alert_text_out_of_range), 1, 65535));
+                       valid = false;
+               }
                return valid;
        }
 
@@ -436,6 +444,7 @@ public class VpnProfileDetailActivity extends Activity
                String certAlias = mCheckAuto.isChecked() ? null : mCertEntry.getAlias();
                mProfile.setCertificateAlias(certAlias);
                mProfile.setMTU(getInteger(mMTU));
+               mProfile.setPort(getInteger(mPort));
        }
 
        /**
@@ -459,6 +468,7 @@ public class VpnProfileDetailActivity extends Activity
                                mUsername.setText(mProfile.getUsername());
                                mPassword.setText(mProfile.getPassword());
                                mMTU.setText(mProfile.getMTU() != null ? mProfile.getMTU().toString() : null);
+                               mPort.setText(mProfile.getPort() != null ? mProfile.getPort().toString() : null);
                                useralias = mProfile.getUserCertificateAlias();
                                alias = mProfile.getCertificateAlias();
                                getActionBar().setTitle(mProfile.getName());