Fix focusing with To field

This commit is contained in:
mar-v-in 2014-08-02 00:51:56 +02:00
parent 9d101b4fe5
commit e17c1a0cd4
3 changed files with 20 additions and 3 deletions

View File

@ -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<Uri, Bitmap> thumbnailCache = new HashMap<Uri, Bitmap>();
@ -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);

View File

@ -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.<EncryptionKey>emptyList()));

View File

@ -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"