mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Implemented NameEditText
This commit is contained in:
parent
e2c502a511
commit
c55353e2b8
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* 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 Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
|
||||
/**
|
||||
* Hack to re-enable keyboard auto correction in AutoCompleteTextView.
|
||||
* From http://stackoverflow.com/a/22512858
|
||||
*/
|
||||
public class AutoCorrectAutoCompleteTextView extends AutoCompleteTextView {
|
||||
|
||||
public AutoCorrectAutoCompleteTextView(Context context) {
|
||||
super(context);
|
||||
removeFlag();
|
||||
}
|
||||
|
||||
public AutoCorrectAutoCompleteTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
removeFlag();
|
||||
}
|
||||
|
||||
public AutoCorrectAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
removeFlag();
|
||||
}
|
||||
|
||||
private void removeFlag() {
|
||||
int inputType = getInputType();
|
||||
inputType &= ~EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE;
|
||||
setRawInputType(inputType);
|
||||
}
|
||||
}
|
@ -31,22 +31,26 @@ public class NameEditText extends AutoCompleteTextView {
|
||||
public NameEditText(Context context) {
|
||||
super(context);
|
||||
removeFlag();
|
||||
makeAdapter();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@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() {
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user