Fixes some issues with single actions on rows
- row content didn’t accurately note if the end items
contained an action or not
- need to set row action as the end item if there’s
only one end item
Test: manual, show the ride slice ensure you can tap
all the rows
Change-Id: I0df117438c29ed958b6b6c7fbaff3a1a86aceb96
diff --git a/slices/view/src/main/java/androidx/app/slice/widget/RowContent.java b/slices/view/src/main/java/androidx/app/slice/widget/RowContent.java
index 735db8e..52c1f02 100644
--- a/slices/view/src/main/java/androidx/app/slice/widget/RowContent.java
+++ b/slices/view/src/main/java/androidx/app/slice/widget/RowContent.java
@@ -25,6 +25,7 @@
import static android.app.slice.SliceItem.FORMAT_SLICE;
import static android.app.slice.SliceItem.FORMAT_TEXT;
import static android.app.slice.SliceItem.FORMAT_TIMESTAMP;
+
import static androidx.app.slice.core.SliceHints.SUBTYPE_RANGE;
import android.support.annotation.Nullable;
@@ -135,6 +136,7 @@
} else if (desiredFormat == null) {
desiredFormat = item.getFormat();
mEndItems.add(item);
+ mEndItemsContainAction |= FORMAT_ACTION.equals(item.getFormat());
} else if (desiredFormat.equals(item.getFormat())) {
mEndItems.add(item);
mEndItemsContainAction |= FORMAT_ACTION.equals(item.getFormat());
diff --git a/slices/view/src/main/java/androidx/app/slice/widget/RowView.java b/slices/view/src/main/java/androidx/app/slice/widget/RowView.java
index 5956317..3a472ad 100644
--- a/slices/view/src/main/java/androidx/app/slice/widget/RowView.java
+++ b/slices/view/src/main/java/androidx/app/slice/widget/RowView.java
@@ -24,6 +24,7 @@
import static android.app.slice.SliceItem.FORMAT_IMAGE;
import static android.app.slice.SliceItem.FORMAT_INT;
import static android.app.slice.SliceItem.FORMAT_TIMESTAMP;
+
import static androidx.app.slice.core.SliceHints.EXTRA_RANGE_VALUE;
import static androidx.app.slice.core.SliceHints.SUBTYPE_MAX;
import static androidx.app.slice.core.SliceHints.SUBTYPE_VALUE;
@@ -241,6 +242,9 @@
} else {
// If the only end item is an action, make the whole row clickable.
if (mRowContent.endItemsContainAction() && itemCount == 1) {
+ if (!SUBTYPE_TOGGLE.equals(endItems.get(0).getSubType())) {
+ mRowAction = endItems.get(0);
+ }
setViewClickable(this, true);
}
}