android: Move profile name field to the bottom and use server address as hint
authorTobias Brunner <tobias@strongswan.org>
Fri, 29 Apr 2016 13:37:35 +0000 (15:37 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 2 May 2016 16:39:17 +0000 (18:39 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileDetailActivity.java
src/frontends/android/app/src/main/res/layout/profile_detail_view.xml

index bcc226b..9271191 100644 (file)
@@ -29,7 +29,10 @@ import android.security.KeyChainException;
 import android.support.v7.app.AlertDialog;
 import android.support.v7.app.AppCompatActivity;
 import android.support.v7.app.AppCompatDialogFragment;
+import android.text.Editable;
 import android.text.Html;
+import android.text.TextUtils;
+import android.text.TextWatcher;
 import android.util.Log;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -124,6 +127,26 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                mBlockIPv4 = (CheckBox)findViewById(R.id.split_tunneling_v4);
                mBlockIPv6 = (CheckBox)findViewById(R.id.split_tunneling_v6);
 
+               mGateway.addTextChangedListener(new TextWatcher() {
+                       @Override
+                       public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
+
+                       @Override
+                       public void onTextChanged(CharSequence s, int start, int before, int count) {}
+
+                       @Override
+                       public void afterTextChanged(Editable s) {
+                               if (TextUtils.isEmpty(mGateway.getText()))
+                               {
+                                       mName.setHint(R.string.profile_name_hint);
+                               }
+                               else
+                               {
+                                       mName.setHint("(" + mGateway.getText() + ")");
+                               }
+                       }
+               });
+
                mSelectVpnType.setOnItemSelectedListener(new OnItemSelectedListener() {
                        @Override
                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
index 57d5606..ee4f256 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-    Copyright (C) 2012-2015 Tobias Brunner
+    Copyright (C) 2012-2016 Tobias Brunner
     Copyright (C) 2012 Giuliano Grassi
     Copyright (C) 2012 Ralf Sager
-    Hochschule fuer Technik Rapperswil
+    HSR Hochschule fuer Technik Rapperswil
 
     This program is free software; you can redistribute it and/or modify it
     under the terms of the GNU General Public License as published by the
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="10dp"
-            android:text="@string/profile_name_label" />
-
-        <EditText
-            android:id="@+id/name"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:inputType="textNoSuggestions"
-            android:hint="@string/profile_name_hint" />
-
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="10dp"
             android:text="@string/profile_gateway_label" />
 
         <EditText
             android:id="@+id/select_certificate"
             layout="@layout/two_line_button" />
 
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="10dp"
+            android:text="@string/profile_name_label" />
+
+        <EditText
+            android:id="@+id/name"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:singleLine="true"
+            android:inputType="textNoSuggestions"
+            android:hint="@string/profile_use_server_hint" />
+
         <CheckBox
             android:id="@+id/show_advanced"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layout_marginTop="10dp"
             android:text="@string/profile_show_advanced_label" />
 
         <LinearLayout
                 android:text="@string/profile_split_tunnelingv6_title" />
 
         </LinearLayout>
+
     </LinearLayout>
 
 </ScrollView>
\ No newline at end of file