summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-05-20 15:03:13 -0700
committerWinson Chung <winsonc@google.com>2015-05-21 00:37:50 +0000
commitc393b0765df8d2d34b3b996b71700a705b7d0106 (patch)
treea082b4b71c6eadb86009a11c6c27c88bc572a783 /src/com/android/launcher3
parentdb092a331ceb9b6cc72fd9b1a593cd77068bb66a (diff)
downloadandroid_packages_apps_Trebuchet-c393b0765df8d2d34b3b996b71700a705b7d0106.tar.gz
android_packages_apps_Trebuchet-c393b0765df8d2d34b3b996b71700a705b7d0106.tar.bz2
android_packages_apps_Trebuchet-c393b0765df8d2d34b3b996b71700a705b7d0106.zip
Fixing issue where the prediction bar apps are not focused.
- Also fixes issue where all apps is not accessible by keyboard when there are no other apps in the hotseat. Bug: 21334471
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r--src/com/android/launcher3/AppsContainerView.java18
-rw-r--r--src/com/android/launcher3/FocusHelper.java6
-rw-r--r--src/com/android/launcher3/Hotseat.java26
3 files changed, 28 insertions, 22 deletions
diff --git a/src/com/android/launcher3/AppsContainerView.java b/src/com/android/launcher3/AppsContainerView.java
index 5ccb6c620..76f3c8861 100644
--- a/src/com/android/launcher3/AppsContainerView.java
+++ b/src/com/android/launcher3/AppsContainerView.java
@@ -183,6 +183,7 @@ public class AppsContainerView extends BaseContainerView implements DragSource,
private int mContainerInset;
private int mPredictionBarHeight;
private int mLastRecyclerViewScrollPos = -1;
+ private boolean mFocusPredictionBarOnFirstBind;
private CheckLongPressHelper mPredictionIconCheckForLongPress;
private View mPredictionIconUnderTouch;
@@ -298,7 +299,17 @@ public class AppsContainerView extends BaseContainerView implements DragSource,
@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();
+ }
}
}
});
@@ -387,6 +398,11 @@ public class AppsContainerView extends BaseContainerView implements DragSource,
icon.setVisibility(View.INVISIBLE);
}
}
+
+ if (mFocusPredictionBarOnFirstBind) {
+ mFocusPredictionBarOnFirstBind = false;
+ mPredictionBarView.requestFocus();
+ }
}
@Override
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index c77d41657..678ed0f82 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -314,12 +314,14 @@ public class FocusHelper {
// 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);
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index b614bc628..b8337b6a4 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -65,6 +65,13 @@ public class Hotseat extends FrameLayout {
}
/**
+ * 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
@@ -98,25 +105,6 @@ public class Hotseat extends FrameLayout {
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();