Allow hardware select, focus fixes

pull/160/head
M66B 6 years ago
parent c01293a53c
commit 7286b3ac25

@ -61,6 +61,7 @@ import android.text.style.ImageSpan;
import android.text.style.QuoteSpan; import android.text.style.QuoteSpan;
import android.text.style.URLSpan; import android.text.style.URLSpan;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -218,8 +219,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
)); ));
public class ViewHolder extends RecyclerView.ViewHolder implements public class ViewHolder extends RecyclerView.ViewHolder implements
View.OnClickListener, View.OnClickListener, View.OnLongClickListener, View.OnKeyListener,
BottomNavigationView.OnNavigationItemSelectedListener, View.OnLongClickListener { BottomNavigationView.OnNavigationItemSelectedListener {
private View view; private View view;
private View vwColor; private View vwColor;
private ImageView ivExpander; private ImageView ivExpander;
@ -471,6 +472,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
view.setTouchDelegate(new TouchDelegate(rect, touch)); view.setTouchDelegate(new TouchDelegate(rect, touch));
} }
}); });
view.setOnKeyListener(this);
ivSnoozed.setOnClickListener(this); ivSnoozed.setOnClickListener(this);
ivFlagged.setOnClickListener(this); ivFlagged.setOnClickListener(this);
@ -499,11 +501,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
private void unwire() { private void unwire() {
if (viewType == ViewType.THREAD) { final View touch = (viewType == ViewType.THREAD ? ivExpander : vwColor);
vwColor.setOnClickListener(null); touch.setOnClickListener(null);
ivExpander.setOnClickListener(null); view.setOnKeyListener(null);
} else
view.setOnClickListener(null);
ivSnoozed.setOnClickListener(null); ivSnoozed.setOnClickListener(null);
ivFlagged.setOnClickListener(null); ivFlagged.setOnClickListener(null);
@ -1540,6 +1540,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return false; return false;
} }
@Override
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
if (keyEvent.getAction() == KeyEvent.ACTION_DOWN &&
(keyCode == KeyEvent.KEYCODE_ENTER ||
keyCode == KeyEvent.KEYCODE_DPAD_CENTER ||
keyCode == KeyEvent.KEYCODE_BUTTON_A)) {
onClick(view);
return true;
} else
return false;
}
private void onShowSnoozed(TupleMessageEx message) { private void onShowSnoozed(TupleMessageEx message) {
if (message.ui_snoozed != null) { if (message.ui_snoozed != null) {
DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT); DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT);

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--item android:drawable="@color/colorPrimary" android:state_focused="true" /-->
<item android:drawable="@color/darkColorItemSelected" android:state_activated="true" /> <item android:drawable="@color/darkColorItemSelected" android:state_activated="true" />
<item android:drawable="@android:color/transparent" /> <item android:drawable="@android:color/transparent" />
</selector> </selector>

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--item android:drawable="@color/colorPrimary" android:state_focused="true" /-->
<item android:drawable="@color/lightColorItemSelected" android:state_activated="true" /> <item android:drawable="@color/lightColorItemSelected" android:state_activated="true" />
<item android:drawable="@android:color/transparent" /> <item android:drawable="@android:color/transparent" />
</selector> </selector>

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/clItem"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">

@ -1,13 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/clItem"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/activatableItemBackground"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:paddingEnd="3dp"> android:paddingEnd="3dp">
<View <View

@ -1,12 +1,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/clItem"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/activatableItemBackground"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:paddingEnd="3dp"> android:paddingEnd="3dp">
<View <View

@ -8,7 +8,10 @@
android:id="@+id/clItem" android:id="@+id/clItem"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/activatableItemBackground"> android:background="?attr/activatableItemBackground"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true">
<include <include
android:id="@+id/inHeader" android:id="@+id/inHeader"

@ -8,7 +8,10 @@
android:id="@+id/clItem" android:id="@+id/clItem"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/activatableItemBackground"> android:background="?attr/activatableItemBackground"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true">
<include <include
android:id="@+id/inHeader" android:id="@+id/inHeader"

Loading…
Cancel
Save