diff options
author | Winson Chung <winsonc@google.com> | 2015-07-30 12:53:33 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2015-07-30 12:54:27 -0700 |
commit | deaf4d169b6e08ae2c41ae67ea97147164089b16 (patch) | |
tree | e0c18879136d3e6318f3ed83757630003d3b2cf8 /src/com/android/launcher3 | |
parent | 70d5a07c5db9414742b0fd357d8ceb45c9f924ff (diff) | |
download | android_packages_apps_Trebuchet-deaf4d169b6e08ae2c41ae67ea97147164089b16.tar.gz android_packages_apps_Trebuchet-deaf4d169b6e08ae2c41ae67ea97147164089b16.tar.bz2 android_packages_apps_Trebuchet-deaf4d169b6e08ae2c41ae67ea97147164089b16.zip |
Fixing issue with accessibility falsely reporting app count when there are no search results.
Bug: 22672783
Change-Id: Ie40acc592e59699eac2a4ff2045a7f8ba029d33a
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsGridAdapter.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index 057883cab..e96567c41 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -22,12 +22,15 @@ import android.graphics.Paint; import android.graphics.PointF; import android.graphics.Rect; import android.os.Handler; +import android.support.v4.view.accessibility.AccessibilityRecordCompat; +import android.support.v4.view.accessibility.AccessibilityEventCompat; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; +import android.view.accessibility.AccessibilityEvent; import android.widget.TextView; import com.android.launcher3.AppInfo; import com.android.launcher3.BubbleTextView; @@ -69,6 +72,38 @@ class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.ViewHol } /** + * A subclass of GridLayoutManager that overrides accessibility values during app search. + */ + public class AppsGridLayoutManager extends GridLayoutManager { + + public AppsGridLayoutManager(Context context) { + super(context, 1, GridLayoutManager.VERTICAL, false); + } + + @Override + public void onInitializeAccessibilityEvent(AccessibilityEvent event) { + super.onInitializeAccessibilityEvent(event); + if (mApps.hasNoFilteredResults()) { + // Disregard the no-search-results text as a list item for accessibility + final AccessibilityRecordCompat record = AccessibilityEventCompat + .asRecord(event); + record.setItemCount(0); + } + } + + @Override + public int getRowCountForAccessibility(RecyclerView.Recycler recycler, + RecyclerView.State state) { + if (mApps.hasNoFilteredResults()) { + // Disregard the no-search-results text as a list item for accessibility + return 0; + } else { + return super.getRowCountForAccessibility(recycler, state); + } + } + } + + /** * Helper class to size the grid items. */ public class GridSpanSizer extends GridLayoutManager.SpanSizeLookup { @@ -305,7 +340,7 @@ class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.ViewHol Resources res = context.getResources(); mApps = apps; mGridSizer = new GridSpanSizer(); - mGridLayoutMgr = new GridLayoutManager(context, 1, GridLayoutManager.VERTICAL, false); + mGridLayoutMgr = new AppsGridLayoutManager(context); mGridLayoutMgr.setSpanSizeLookup(mGridSizer); mItemDecoration = new GridItemDecoration(); mLayoutInflater = LayoutInflater.from(context); |