aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java26
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java25
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EmailEditText.java21
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/NameEditText.java (renamed from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/AutoCorrectAutoCompleteTextView.java)35
-rw-r--r--OpenKeychain/src/main/res/layout/add_user_id_dialog.xml2
-rw-r--r--OpenKeychain/src/main/res/layout/create_key_input_fragment.xml2
6 files changed, 55 insertions, 56 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java
index ecc609212..05408e21e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java
@@ -24,22 +24,20 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction;
import org.sufficientlysecure.keychain.ui.widget.EmailEditText;
+import org.sufficientlysecure.keychain.ui.widget.NameEditText;
import org.sufficientlysecure.keychain.ui.widget.PassphraseEditText;
-import org.sufficientlysecure.keychain.util.ContactHelper;
public class CreateKeyInputFragment extends Fragment {
public static final String ARG_NAME = "name";
public static final String ARG_EMAIL = "email";
CreateKeyActivity mCreateKeyActivity;
- AutoCompleteTextView mNameEdit;
+ NameEditText mNameEdit;
EmailEditText mEmailEdit;
PassphraseEditText mPassphraseEdit;
EditText mPassphraseEditAgain;
@@ -98,7 +96,7 @@ public class CreateKeyInputFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.create_key_input_fragment, container, false);
- mNameEdit = (AutoCompleteTextView) view.findViewById(R.id.create_key_name);
+ mNameEdit = (NameEditText) view.findViewById(R.id.create_key_name);
mPassphraseEdit = (PassphraseEditText) view.findViewById(R.id.create_key_passphrase);
mEmailEdit = (EmailEditText) view.findViewById(R.id.create_key_email);
mPassphraseEditAgain = (EditText) view.findViewById(R.id.create_key_passphrase_again);
@@ -116,24 +114,6 @@ public class CreateKeyInputFragment extends Fragment {
} else if (name != null) {
mEmailEdit.requestFocus();
}
-
- mEmailEdit.setThreshold(1); // Start working from first character
- mEmailEdit.setAdapter(
- new ArrayAdapter<>
- (getActivity(), android.R.layout.simple_spinner_dropdown_item,
- ContactHelper.getPossibleUserEmails(getActivity())
- )
- );
-
-
- mNameEdit.setThreshold(1); // Start working from first character
- mNameEdit.setAdapter(
- new ArrayAdapter<>
- (getActivity(), android.R.layout.simple_spinner_dropdown_item,
- ContactHelper.getPossibleUserNames(getActivity())
- )
- );
-
mCreateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java
index ee4af8cbe..5dd675fd3 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java
@@ -33,8 +33,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
@@ -44,7 +42,7 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.ui.widget.EmailEditText;
-import org.sufficientlysecure.keychain.util.ContactHelper;
+import org.sufficientlysecure.keychain.ui.widget.NameEditText;
import org.sufficientlysecure.keychain.util.Log;
public class AddUserIdDialogFragment extends DialogFragment implements OnEditorActionListener {
@@ -57,7 +55,7 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
public static final String MESSAGE_DATA_USER_ID = "user_id";
private Messenger mMessenger;
- private AutoCompleteTextView mName;
+ private NameEditText mName;
private EmailEditText mEmail;
private EditText mComment;
@@ -81,11 +79,6 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
mMessenger = getArguments().getParcelable(ARG_MESSENGER);
String predefinedName = getArguments().getString(ARG_NAME);
- ArrayAdapter<String> autoCompleteEmailAdapter = new ArrayAdapter<>
- (getActivity(), android.R.layout.simple_spinner_dropdown_item,
- ContactHelper.getPossibleUserEmails(getActivity())
- );
-
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
alert.setTitle(R.string.edit_key_action_add_identity);
@@ -94,16 +87,12 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
View view = inflater.inflate(R.layout.add_user_id_dialog, null);
alert.setView(view);
- mName = (AutoCompleteTextView) view.findViewById(R.id.add_user_id_name);
+ mName = (NameEditText) view.findViewById(R.id.add_user_id_name);
mEmail = (EmailEditText) view.findViewById(R.id.add_user_id_address);
mComment = (EditText) view.findViewById(R.id.add_user_id_comment);
mName.setText(predefinedName);
-
- mEmail.setThreshold(1); // Start working from first character
- mEmail.setAdapter(autoCompleteEmailAdapter);
-
alert.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
@@ -118,14 +107,6 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
}
});
- mName.setThreshold(1); // Start working from first character
- mName.setAdapter(
- new ArrayAdapter<>
- (getActivity(), android.R.layout.simple_spinner_dropdown_item,
- ContactHelper.getPossibleUserNames(getActivity())
- )
- );
-
alert.setNegativeButton(android.R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EmailEditText.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EmailEditText.java
index 697f5a61e..e7ef788d8 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EmailEditText.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EmailEditText.java
@@ -25,6 +25,7 @@ import android.text.InputType;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.Patterns;
+import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
@@ -41,6 +42,8 @@ public class EmailEditText extends AutoCompleteTextView {
emailEditText = this;
this.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
this.addTextChangedListener(textWatcher);
+ removeFlag();
+ makeAdapter();
}
public EmailEditText(Context context, AttributeSet attrs) {
@@ -48,6 +51,8 @@ public class EmailEditText extends AutoCompleteTextView {
emailEditText = this;
this.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
this.addTextChangedListener(textWatcher);
+ removeFlag();
+ makeAdapter();
}
public EmailEditText(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -55,6 +60,8 @@ public class EmailEditText extends AutoCompleteTextView {
emailEditText = this;
this.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
this.addTextChangedListener(textWatcher);
+ removeFlag();
+ makeAdapter();
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@@ -63,6 +70,8 @@ public class EmailEditText extends AutoCompleteTextView {
emailEditText = this;
this.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
this.addTextChangedListener(textWatcher);
+ removeFlag();
+ makeAdapter();
}
TextWatcher textWatcher = new TextWatcher() {
@@ -94,4 +103,16 @@ public class EmailEditText extends AutoCompleteTextView {
}
}
};
+
+ private void makeAdapter() {
+ this.setThreshold(1); // Start working from first character
+ this.setAdapter(new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item,
+ ContactHelper.getPossibleUserEmails(getContext())));
+ }
+
+ private void removeFlag() {
+ int inputType = getInputType();
+ inputType &= ~EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE;
+ setRawInputType(inputType);
+ }
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/AutoCorrectAutoCompleteTextView.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/NameEditText.java
index ed373a938..895cd45ec 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/AutoCorrectAutoCompleteTextView.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/NameEditText.java
@@ -17,30 +17,40 @@
package org.sufficientlysecure.keychain.ui.widget;
+import android.annotation.TargetApi;
import android.content.Context;
+import android.os.Build;
import android.util.AttributeSet;
import android.view.inputmethod.EditorInfo;
+import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
-/**
- * Hack to re-enable keyboard auto correction in AutoCompleteTextView.
- * From http://stackoverflow.com/a/22512858
- */
-public class AutoCorrectAutoCompleteTextView extends AutoCompleteTextView {
+import org.sufficientlysecure.keychain.util.ContactHelper;
- public AutoCorrectAutoCompleteTextView(Context context) {
+public class NameEditText extends AutoCompleteTextView {
+ public NameEditText(Context context) {
super(context);
removeFlag();
+ makeAdapter();
}
- public AutoCorrectAutoCompleteTextView(Context context, AttributeSet attrs) {
+ public NameEditText(Context context, AttributeSet attrs) {
super(context, attrs);
removeFlag();
+ makeAdapter();
+ }
+
+ public NameEditText(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ removeFlag();
+ makeAdapter();
}
- public AutoCorrectAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ public NameEditText(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
removeFlag();
+ makeAdapter();
}
private void removeFlag() {
@@ -48,4 +58,11 @@ public class AutoCorrectAutoCompleteTextView extends AutoCompleteTextView {
inputType &= ~EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE;
setRawInputType(inputType);
}
+
+ private void makeAdapter() {
+ this.setThreshold(1); // Start working from first character
+ this.setAdapter(new ArrayAdapter<>(
+ getContext(), android.R.layout.simple_spinner_dropdown_item,
+ ContactHelper.getPossibleUserNames(getContext())));
+ }
}
diff --git a/OpenKeychain/src/main/res/layout/add_user_id_dialog.xml b/OpenKeychain/src/main/res/layout/add_user_id_dialog.xml
index c1b97b02c..ffb7493f6 100644
--- a/OpenKeychain/src/main/res/layout/add_user_id_dialog.xml
+++ b/OpenKeychain/src/main/res/layout/add_user_id_dialog.xml
@@ -16,7 +16,7 @@
android:imeOptions="actionNext"
android:textAppearance="?android:attr/textAppearanceMedium" />
- <org.sufficientlysecure.keychain.ui.widget.AutoCorrectAutoCompleteTextView
+ <org.sufficientlysecure.keychain.ui.widget.NameEditText
android:id="@+id/add_user_id_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml b/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml
index 211c04d77..2178fcb1f 100644
--- a/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml
+++ b/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml
@@ -32,7 +32,7 @@
android:layout_marginTop="8dp"
android:text="@string/label_user_id" />
- <org.sufficientlysecure.keychain.ui.widget.AutoCorrectAutoCompleteTextView
+ <org.sufficientlysecure.keychain.ui.widget.NameEditText
android:id="@+id/create_key_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"