android:layout_height="wrap_content"
android:layout_marginTop="@dimen/apps_search_bar_height"
android:orientation="horizontal"
+ android:descendantFocusability="afterDescendants"
+ android:focusable="true"
android:visibility="invisible" >
</LinearLayout>
private int mContainerInset;
private int mPredictionBarHeight;
private int mLastRecyclerViewScrollPos = -1;
+ private boolean mFocusPredictionBarOnFirstBind;
private CheckLongPressHelper mPredictionIconCheckForLongPress;
private View mPredictionIconUnderTouch;
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (v == mContentView && hasFocus) {
- mAppsRecyclerView.requestFocus();
+ if (!mApps.getPredictedApps().isEmpty()) {
+ // If the prediction bar is going to be bound, then defer focusing until
+ // it is first bound
+ if (mPredictionBarView.getChildCount() == 0) {
+ mFocusPredictionBarOnFirstBind = true;
+ } else {
+ mPredictionBarView.requestFocus();
+ }
+ } else {
+ mAppsRecyclerView.requestFocus();
+ }
}
}
});
icon.setVisibility(View.INVISIBLE);
}
}
+
+ if (mFocusPredictionBarOnFirstBind) {
+ mFocusPredictionBarOnFirstBind = false;
+ mPredictionBarView.requestFocus();
+ }
}
@Override
// with the hotseat.
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && !profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrix(iconLayout, hotseatLayout, true /* horizontal */,
- hotseat.getAllAppsButtonRank(), false /* all apps icon is ignored */);
+ hotseat.getAllAppsButtonRank(),
+ !hotseat.hasIcons() /* ignore all apps icon, unless there are no other icons */);
countY = countY + 1;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT &&
profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrix(iconLayout, hotseatLayout, false /* horizontal */,
- hotseat.getAllAppsButtonRank(), false /* all apps icon is ignored */);
+ hotseat.getAllAppsButtonRank(),
+ !hotseat.hasIcons() /* ignore all apps icon, unless there are no other icons */);
countX = countX + 1;
} else if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL) {
workspace.removeWorkspaceItem(v);
}
/**
+ * Returns whether there are other icons than the all apps button in the hotseat.
+ */
+ public boolean hasIcons() {
+ return mContent.getShortcutsAndWidgets().getChildCount() > 1;
+ }
+
+ /**
* Registers the specified listener on the cell layout of the hotseat.
*/
@Override
return rank == mAllAppsButtonRank;
}
- /** This returns the coordinates of an app in a given cell, relative to the DragLayer */
- Rect getCellCoordinates(int cellX, int cellY) {
- Rect coords = new Rect();
- mContent.cellToRect(cellX, cellY, 1, 1, coords);
- int[] hotseatInParent = new int[2];
- Utilities.getDescendantCoordRelativeToParent(this, mLauncher.getDragLayer(),
- hotseatInParent, false);
- coords.offset(hotseatInParent[0], hotseatInParent[1]);
-
- // Center the icon
- int cWidth = mContent.getShortcutsAndWidgets().getCellContentWidth();
- int cHeight = mContent.getShortcutsAndWidgets().getCellContentHeight();
- int cellPaddingX = (int) Math.max(0, ((coords.width() - cWidth) / 2f));
- int cellPaddingY = (int) Math.max(0, ((coords.height() - cHeight) / 2f));
- coords.offset(cellPaddingX, cellPaddingY);
-
- return coords;
- }
-
@Override
protected void onFinishInflate() {
super.onFinishInflate();