From 9817251ed5f48e56c5c3f068a98e9c2a95f3c92c Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Thu, 4 Sep 2014 11:46:13 +0200 Subject: made muc password dialog hide the password (password field) --- .../conversations/ui/ConversationFragment.java | 2 +- src/eu/siacs/conversations/ui/XmppActivity.java | 37 ++++++++++++++++------ 2 files changed, 29 insertions(+), 10 deletions(-) (limited to 'src/eu/siacs/conversations/ui') diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index 4ebeea19e..a51371edc 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -138,7 +138,7 @@ public class ConversationFragment extends Fragment { if (password==null) { password = ""; } - activity.quickEdit(password, new OnValueEdited() { + activity.quickPasswordEdit(password, new OnValueEdited() { @Override public void onValueEdited(String value) { diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java index 784826588..72902c65b 100644 --- a/src/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/eu/siacs/conversations/ui/XmppActivity.java @@ -33,6 +33,7 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.IBinder; +import android.text.InputType; import android.util.DisplayMetrics; import android.util.Log; import android.view.MenuItem; @@ -56,7 +57,7 @@ public abstract class XmppActivity extends Activity { protected int mPrimaryColor; private DisplayMetrics metrics; - + protected interface OnValueEdited { public void onValueEdited(String value); } @@ -297,16 +298,22 @@ public abstract class XmppActivity extends Activity { builder.create().show(); } - protected void quickEdit(final String previousValue, - final OnValueEdited callback) { + protected void quickEdit(String previousValue, OnValueEdited callback) { + quickEdit(previousValue, callback, false); + } + + protected void quickPasswordEdit(String previousValue, + OnValueEdited callback) { + quickEdit(previousValue, callback, true); + } + + private void quickEdit(final String previousValue, + final OnValueEdited callback, boolean password) { AlertDialog.Builder builder = new AlertDialog.Builder(this); View view = (View) getLayoutInflater() .inflate(R.layout.quickedit, null); final EditText editor = (EditText) view.findViewById(R.id.editor); - editor.setText(previousValue); - builder.setView(view); - builder.setNegativeButton(R.string.cancel, null); - builder.setPositiveButton(R.string.edit, new OnClickListener() { + OnClickListener mClickListener = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -315,7 +322,19 @@ public abstract class XmppActivity extends Activity { callback.onValueEdited(value); } } - }); + }; + if (password) { + editor.setInputType(InputType.TYPE_CLASS_TEXT + | InputType.TYPE_TEXT_VARIATION_PASSWORD); + editor.setHint(R.string.password); + builder.setPositiveButton(R.string.accept, mClickListener); + } else { + builder.setPositiveButton(R.string.edit, mClickListener); + } + editor.requestFocus(); + editor.setText(previousValue); + builder.setView(view); + builder.setNegativeButton(R.string.cancel, null); builder.create().show(); } @@ -403,7 +422,7 @@ public abstract class XmppActivity extends Activity { public int getPrimaryColor() { return this.mPrimaryColor; } - + class BitmapWorkerTask extends AsyncTask { private final WeakReference imageViewReference; private Message message = null; -- cgit v1.2.3