Merge "Fixing issue with accessibility falsely reporting app count when there are no search results." into ub-launcher3-burnaby
This commit is contained in:
commit
3ea54fdb49
1 file changed
+36
-1
@@ -22,12 +22,15 @@ import android.graphics.Paint;
|
|||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Handler;
|
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.GridLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.android.launcher3.AppInfo;
|
import com.android.launcher3.AppInfo;
|
||||||
import com.android.launcher3.BubbleTextView;
|
import com.android.launcher3.BubbleTextView;
|
||||||
@@ -68,6 +71,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.
|
* Helper class to size the grid items.
|
||||||
*/
|
*/
|
||||||
@@ -305,7 +340,7 @@ class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.ViewHol
|
|||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
mApps = apps;
|
mApps = apps;
|
||||||
mGridSizer = new GridSpanSizer();
|
mGridSizer = new GridSpanSizer();
|
||||||
mGridLayoutMgr = new GridLayoutManager(context, 1, GridLayoutManager.VERTICAL, false);
|
mGridLayoutMgr = new AppsGridLayoutManager(context);
|
||||||
mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
|
mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
|
||||||
mItemDecoration = new GridItemDecoration();
|
mItemDecoration = new GridItemDecoration();
|
||||||
mLayoutInflater = LayoutInflater.from(context);
|
mLayoutInflater = LayoutInflater.from(context);
|
||||||
|
|||||||
Reference in new issue
Block a user