From e17c1a0cd4581adce49a9941b2f4fadbdbf5a94d Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Sat, 2 Aug 2014 00:51:56 +0200 Subject: Fix focusing with To field --- .../sufficientlysecure/keychain/ui/EncryptFileFragment.java | 10 +++++++--- .../keychain/ui/widget/EncryptKeyCompletionView.java | 11 +++++++++++ OpenKeychain/src/main/res/layout/encrypt_file_fragment.xml | 2 ++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java index 7650c3954..6bbbac713 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -27,6 +27,7 @@ import android.os.Build; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; @@ -58,6 +59,7 @@ public class EncryptFileFragment extends Fragment implements EncryptActivityInte private View mAddView; private View mShareFile; private View mEncryptFile; + private ListView mSelectedFiles; private SelectedFilesAdapter mAdapter = new SelectedFilesAdapter(); private final Map thumbnailCache = new HashMap(); @@ -100,9 +102,9 @@ public class EncryptFileFragment extends Fragment implements EncryptActivityInte addInputUri(); } }); - ListView listView = (ListView) view.findViewById(R.id.selected_files_list); - listView.addFooterView(mAddView); - listView.setAdapter(mAdapter); + mSelectedFiles = (ListView) view.findViewById(R.id.selected_files_list); + mSelectedFiles.addFooterView(mAddView); + mSelectedFiles.setAdapter(mAdapter); return view; } @@ -139,6 +141,7 @@ public class EncryptFileFragment extends Fragment implements EncryptActivityInte mEncryptInterface.getInputUris().add(inputUri); mEncryptInterface.notifyUpdate(); + mSelectedFiles.requestFocus(); /** * We hide the encrypt to file button if multiple files are selected. @@ -157,6 +160,7 @@ public class EncryptFileFragment extends Fragment implements EncryptActivityInte private void delInputUri(int position) { mEncryptInterface.getInputUris().remove(position); mEncryptInterface.notifyUpdate(); + mSelectedFiles.requestFocus(); if (mEncryptInterface.getInputUris().size() > 1) { mEncryptFile.setVisibility(View.GONE); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java index 329ef2c9b..f1c17bfb5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.content.Context; import android.database.Cursor; import android.graphics.Bitmap; +import android.graphics.Rect; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.LoaderManager; @@ -13,6 +14,7 @@ import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; import android.widget.ImageView; import android.widget.TextView; import com.tokenautocomplete.FilteredArrayAdapter; @@ -109,6 +111,15 @@ public class EncryptKeyCompletionView extends TokenCompleteTextView { } } + @Override + public void onFocusChanged(boolean hasFocus, int direction, Rect previous) { + super.onFocusChanged(hasFocus, direction, previous); + if (hasFocus) { + ((InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE)) + .showSoftInput(this, InputMethodManager.SHOW_IMPLICIT); + } + } + public void swapCursor(Cursor cursor) { if (cursor == null) { setAdapter(new EncryptKeyAdapter(Collections.emptyList())); diff --git a/OpenKeychain/src/main/res/layout/encrypt_file_fragment.xml b/OpenKeychain/src/main/res/layout/encrypt_file_fragment.xml index 3110b059e..b853ac2fb 100644 --- a/OpenKeychain/src/main/res/layout/encrypt_file_fragment.xml +++ b/OpenKeychain/src/main/res/layout/encrypt_file_fragment.xml @@ -14,6 +14,8 @@ android:id="@+id/selected_files_list" android:dividerHeight="4dip" android:divider="@android:color/transparent" + android:focusable="true" + android:focusableInTouchMode="true" android:layout_marginTop="8dp" android:layout_width="match_parent" android:layout_height="0dip" -- cgit v1.2.3