diff options
author | Winson Chung <winsonc@google.com> | 2015-07-30 23:57:08 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-30 23:57:08 +0000 |
commit | 3ea54fdb490b973e2754cb438c7341e35df3b4cc (patch) | |
tree | b00848fda62b43f04e1ce2c09561b745d65a25a5 /src/com/android/launcher3 | |
parent | 1014e7de0e6c62587b507342f8b477ea84fa635d (diff) | |
parent | deaf4d169b6e08ae2c41ae67ea97147164089b16 (diff) | |
download | android_packages_apps_Trebuchet-3ea54fdb490b973e2754cb438c7341e35df3b4cc.tar.gz android_packages_apps_Trebuchet-3ea54fdb490b973e2754cb438c7341e35df3b4cc.tar.bz2 android_packages_apps_Trebuchet-3ea54fdb490b973e2754cb438c7341e35df3b4cc.zip |
Merge "Fixing issue with accessibility falsely reporting app count when there are no search results." into ub-launcher3-burnaby
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); |