text selection is kept when user toggles between visible and non visible password
authorjmiazga <jmiazga@definitypartners.com>
Fri, 4 Jan 2013 14:40:13 +0000 (09:40 -0500)
committerjmiazga <jmiazga@definitypartners.com>
Fri, 4 Jan 2013 14:40:13 +0000 (09:40 -0500)
src/com/owncloud/android/ui/activity/AuthenticatorActivity.java

index 7321f6a..bd36ed1 100644 (file)
@@ -55,6 +55,7 @@ import android.view.View.OnClickListener;
 import android.view.View.OnFocusChangeListener;\r
 import android.view.Window;\r
 import android.widget.Button;\r
+import android.widget.EditText;\r
 import android.widget.ImageView;\r
 import android.widget.TextView;\r
 import com.owncloud.android.R;\r
@@ -485,7 +486,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         if (v.getId() == R.id.refreshButton) {\r
             onFocusChange(findViewById(R.id.host_URL), false);\r
         } else if (v.getId() == R.id.viewPassword) {\r
-            TextView view = (TextView) findViewById(R.id.account_password);\r
+            EditText view = (EditText) findViewById(R.id.account_password);\r
+            int selectionStart = view.getSelectionStart();\r
+            int selectionEnd = view.getSelectionEnd();\r
             int input_type = view.getInputType();\r
             if ((input_type & InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) {\r
                 input_type = InputType.TYPE_CLASS_TEXT\r
@@ -495,6 +498,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
                         | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;\r
             }\r
             view.setInputType(input_type);\r
+            view.setSelection(selectionStart, selectionEnd);\r
         }\r
     }\r
 \r