From 5730e5c56cd5a17a2f75bbd5fcfc752d69a8c062 Mon Sep 17 00:00:00 2001 From: Alexandre Elias Date: Mon, 10 Jan 2022 19:41:20 -0800 Subject: [PATCH] Expose public API to control mIsChildViewEnabled This is needed to replace an @UnsupportedApiUsage of the field in appcompat/widget/DropDownListView.java Bug: 177008210 Test: AbsListViewTest.testSelectedChildViewEnabled Change-Id: Ia0bfe3f70f62db8185e1d9784d921e2e1f291006 --- core/api/current.txt | 2 ++ core/java/android/widget/AbsListView.java | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/core/api/current.txt b/core/api/current.txt index 05e9a9a889501..1beb0b206bf64 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -54943,6 +54943,7 @@ package android.widget { method protected boolean isInFilterMode(); method public boolean isItemChecked(int); method public boolean isScrollingCacheEnabled(); + method public boolean isSelectedChildViewEnabled(); method public boolean isSmoothScrollbarEnabled(); method public boolean isStackFromBottom(); method public boolean isTextFilterEnabled(); @@ -54978,6 +54979,7 @@ package android.widget { method public void setRemoteViewsAdapter(android.content.Intent); method public void setScrollIndicators(android.view.View, android.view.View); method public void setScrollingCacheEnabled(boolean); + method public void setSelectedChildViewEnabled(boolean); method public void setSelectionFromTop(int, int); method public void setSelector(@DrawableRes int); method public void setSelector(android.graphics.drawable.Drawable); diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 414a7f1f0e1cc..1d8e9a36fb3f1 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -2656,6 +2656,27 @@ public abstract class AbsListView extends AdapterView implements Te } } + /** + * Returns whether the selected child view (from the adapter's getView) is enabled. + * + * @return true if enabled + */ + public boolean isSelectedChildViewEnabled() { + return mIsChildViewEnabled; + } + + /** + * Set whether the selected child view (from the adapter's getView) is enabled. + * + * When refreshDrawableState is called, AbsListView will control the "enabled" state + * of the selector based on this. + * + * @param selectedChildViewEnabled true if enabled + */ + public void setSelectedChildViewEnabled(boolean selectedChildViewEnabled) { + mIsChildViewEnabled = selectedChildViewEnabled; + } + @Override protected void dispatchDraw(Canvas canvas) { int saveCount = 0;