Merge "Add ripple effect to bottom nav and options" into ub-launcher3-qt-dev
diff --git a/res/drawable/option_border.xml b/res/drawable/option_border.xml
index 7221f95..00c8613 100644
--- a/res/drawable/option_border.xml
+++ b/res/drawable/option_border.xml
@@ -13,8 +13,18 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="rectangle">
- <stroke android:color="@color/option_border_color" android:width="@dimen/option_border_width" />
- <corners android:radius="4dp" />
-</shape>
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?android:attr/colorControlHighlight">
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <solid android:color="@android:color/white"/>
+ <corners android:radius="4dp" />
+ </shape>
+ </item>
+ <item>
+ <shape android:shape="rectangle">
+ <stroke android:color="@color/option_border_color" android:width="@dimen/option_border_width" />
+ <corners android:radius="4dp" />
+ </shape>
+ </item>
+</ripple>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index dd44a91..a907769 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -42,6 +42,7 @@
<item name="itemTextColor">@color/bottom_nav_item_color</item>
<item name="itemTextAppearanceActive">@style/BottomNavTextAppearance</item>
<item name="itemTextAppearanceInactive">@style/BottomNavTextAppearance</item>
+ <item name="itemBackground">?android:attr/selectableItemBackgroundBorderless</item>
<item name="android:background">?android:colorPrimary</item>
</style>
diff --git a/src/com/android/customization/widget/OptionSelectorController.java b/src/com/android/customization/widget/OptionSelectorController.java
index 82baaf9..fe04d20 100644
--- a/src/com/android/customization/widget/OptionSelectorController.java
+++ b/src/com/android/customization/widget/OptionSelectorController.java
@@ -76,11 +76,23 @@
if (!mOptions.contains(option)) {
throw new IllegalArgumentException("Invalid option");
}
+ updateActivatedStatus(mSelectedOption, false);
+ updateActivatedStatus(option, true);
mSelectedOption = option;
- mAdapter.notifyDataSetChanged();
notifyListeners();
}
+ private void updateActivatedStatus(CustomizationOption option, boolean isActivated) {
+ int index = mOptions.indexOf(option);
+ if (index < 0) {
+ return;
+ }
+ RecyclerView.ViewHolder holder = mContainer.findViewHolderForAdapterPosition(index);
+ if (holder != null && holder.itemView != null) {
+ holder.itemView.setActivated(isActivated);
+ }
+ }
+
/**
* Initializes the UI for the options passed in the constructor of this class.
*/