android: Move profile name field to the bottom and use server address as hint
[strongswan.git] / src / frontends / android / app / src / main / java / org / strongswan / android / ui / VpnProfileDetailActivity.java
index 24690de..9271191 100644 (file)
@@ -17,9 +17,7 @@
 
 package org.strongswan.android.ui;
 
-import android.app.AlertDialog;
 import android.app.Dialog;
-import android.app.DialogFragment;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
@@ -28,8 +26,13 @@ import android.os.Bundle;
 import android.security.KeyChain;
 import android.security.KeyChainAliasCallback;
 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)
@@ -146,7 +169,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
                        @Override
                        public void onClick(View v)
                        {
-                               new TncNoticeDialog().show(VpnProfileDetailActivity.this.getFragmentManager(), "TncNotice");
+                               new TncNoticeDialog().show(VpnProfileDetailActivity.this.getSupportFragmentManager(), "TncNotice");
                        }
                });
 
@@ -633,7 +656,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
        /**
         * Dialog with notification message if EAP-TNC is used.
         */
-       public static class TncNoticeDialog extends DialogFragment
+       public static class TncNoticeDialog extends AppCompatDialogFragment
        {
                @Override
                public Dialog onCreateDialog(Bundle savedInstanceState)