Make update items/photos highlight when they're clickable
- Highlighting used to work not because "stream_item_content" had the proper
background but because it was the default behavior for ListView items.
- Implement StreamItemAdapter.isEnabled() and make all list items disabled,
so they don't highlight when not necessary. i.e. when items don't have a
click listener set.
- Instead set a click listener to the "stream_item_content" view.
- And change the background to "?android:attr/selectableItemBackground",
which is the default background for list items.
- Also make photo views highlightable when they're clickable.
Bug 5180619
Change-Id: I06bff9d1a0e5385fa66edd4577ddefb43587621c
diff --git a/res/layout/stream_item_container.xml b/res/layout/stream_item_container.xml
index 1f96aad..a88dd9a 100644
--- a/res/layout/stream_item_container.xml
+++ b/res/layout/stream_item_container.xml
@@ -27,7 +27,7 @@
android:paddingBottom="@dimen/detail_update_section_item_last_row_extra_vertical_padding"
android:paddingLeft="@dimen/detail_update_section_item_horizontal_padding"
android:paddingRight="@dimen/detail_update_section_item_horizontal_padding"
- android:background="@drawable/list_selector"
+ android:background="?android:attr/selectableItemBackground"
/>
<View
diff --git a/res/layout/stream_item_photo.xml b/res/layout/stream_item_photo.xml
new file mode 100644
index 0000000..1fc3d0b
--- /dev/null
+++ b/res/layout/stream_item_photo.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android">
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+ <View
+ android:id="@+id/push_layer"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="?android:attr/selectableItemBackground"/>
+</FrameLayout>
diff --git a/res/layout/stream_item_row_image_and_text.xml b/res/layout/stream_item_row_image_and_text.xml
index b6f6599..8c67ce1 100644
--- a/res/layout/stream_item_row_image_and_text.xml
+++ b/res/layout/stream_item_row_image_and_text.xml
@@ -27,8 +27,9 @@
android:layout_weight="1"
ex:ratio="1"
ex:direction="widthToHeight">
- <ImageView
+ <include
android:id="@+id/stream_item_first_image"
+ layout="@layout/stream_item_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</view>
diff --git a/res/layout/stream_item_row_two_images.xml b/res/layout/stream_item_row_two_images.xml
index 6e34b25..f127129 100644
--- a/res/layout/stream_item_row_two_images.xml
+++ b/res/layout/stream_item_row_two_images.xml
@@ -27,8 +27,9 @@
android:layout_weight="1"
ex:ratio="1"
ex:direction="widthToHeight">
- <ImageView
+ <include
android:id="@+id/stream_item_first_image"
+ layout="@layout/stream_item_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</view>
@@ -40,8 +41,9 @@
android:layout_weight="1"
ex:ratio="1"
ex:direction="widthToHeight">
- <ImageView
+ <include
android:id="@+id/stream_item_second_image"
+ layout="@layout/stream_item_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</view>