Hack to fix #805

This commit is contained in:
Dominik Schürmann 2014-09-22 00:10:55 +02:00
parent fc4cdaa24b
commit d63fabace7
4 changed files with 71 additions and 18 deletions

View File

@ -22,10 +22,12 @@ import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.TextKeyListener;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
@ -68,10 +70,10 @@ 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.name);
mEmailEdit = (AutoCompleteTextView) view.findViewById(R.id.email);
mPassphraseEdit = (EditText) view.findViewById(R.id.passphrase);
mPassphraseEditAgain = (EditText) view.findViewById(R.id.passphrase_again);
mNameEdit = (AutoCompleteTextView) view.findViewById(R.id.create_key_name);
mEmailEdit = (AutoCompleteTextView) view.findViewById(R.id.create_key_email);
mPassphraseEdit = (EditText) view.findViewById(R.id.create_key_passphrase);
mPassphraseEditAgain = (EditText) view.findViewById(R.id.create_key_passphrase_again);
mCreateButton = view.findViewById(R.id.create_key_button);
// initial values

View File

@ -0,0 +1,51 @@
/*
* 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);
}
}

View File

@ -8,21 +8,21 @@
android:paddingTop="8dp"
android:paddingBottom="8dp">
<AutoCompleteTextView
<org.sufficientlysecure.keychain.ui.widget.AutoCorrectAutoCompleteTextView
android:id="@+id/add_user_id_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/label_email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:inputType="textAutoCorrect|textEmailAddress"
android:textAppearance="?android:attr/textAppearanceMedium" />
<AutoCompleteTextView
<org.sufficientlysecure.keychain.ui.widget.AutoCorrectAutoCompleteTextView
android:id="@+id/add_user_id_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:inputType="textAutoCorrect|textPersonName|textCapWords"
android:hint="@string/create_key_hint_full_name"
android:textAppearance="?android:attr/textAppearanceSmall" />

View File

@ -31,26 +31,26 @@
android:layout_marginTop="8dp"
android:text="@string/label_user_id" />
<AutoCompleteTextView
<org.sufficientlysecure.keychain.ui.widget.AutoCorrectAutoCompleteTextView
android:id="@+id/create_key_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:inputType="textAutoCorrect|textPersonName|textCapWords"
android:hint="@string/create_key_hint_full_name"
android:ems="10"
android:id="@+id/name" />
android:ems="10" />
<AutoCompleteTextView
android:id="@+id/email"
<org.sufficientlysecure.keychain.ui.widget.AutoCorrectAutoCompleteTextView
android:id="@+id/create_key_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:imeOptions="actionNext"
android:inputType="textAutoCorrect|textEmailAddress"
android:hint="@string/label_email"
android:ems="10"
android:inputType="textEmailAddress" />
android:ems="10" />
<TextView
style="@style/SectionHeader"
@ -59,7 +59,7 @@
android:text="@string/label_passphrase" />
<EditText
android:id="@+id/passphrase"
android:id="@+id/create_key_passphrase"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
@ -71,7 +71,7 @@
android:layout_gravity="center_horizontal" />
<EditText
android:id="@+id/passphrase_again"
android:id="@+id/create_key_passphrase_again"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"