Launcher-side changes to support prediction bar.

Change-Id: Ib9974ad8888ad87137c774f9f531fae9d56b899a
This commit is contained in:
Winson Chung
2015-04-29 11:03:24 -07:00
parent d47d90224a
commit cd99cd3ed6
7 changed files with 73 additions and 49 deletions
+62 -17
View File
@@ -522,13 +522,19 @@ public class Launcher extends Activity
mLauncherCallbacks.setLauncherAppsCallback(new Launcher.LauncherAppsCallbacks() {
@Override
public void onAllAppsBoundsChanged(Rect bounds) {
if (LOGD) {
Log.d(TAG, "onAllAppsBoundsChanged(Rect): " + bounds);
}
mAppsView.setFixedBounds(Launcher.this, bounds);
}
@Override
public void dismissAllApps() {
showWorkspace(WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, true, null,
false /* notifyLauncherCallbacks */);
// Dismiss All Apps if we aren't already paused/invisible
if (!mPaused) {
showWorkspace(WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, true,
null /* onCompleteRunnable */, false /* notifyLauncherCallbacks */);
}
}
});
return true;
@@ -1012,6 +1018,13 @@ public class Launcher extends Activity
}
mOnResumeState = State.NONE;
// Restore the apps state if we are in all apps
if (mState == State.APPS) {
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onAllAppsShown();
}
}
// Background was set to gradient in onPause(), restore to black if in all apps.
setWorkspaceBackground(mState == State.WORKSPACE);
@@ -1072,7 +1085,7 @@ public class Launcher extends Activity
mWorkspace.getCustomContentCallbacks().onShow(true);
}
}
mWorkspace.updateInteractionForState();
updateInteraction(Workspace.State.NORMAL, mWorkspace.getState());
mWorkspace.onResume();
if (!isWorkspaceLoading()) {
@@ -2101,8 +2114,6 @@ public class Launcher extends Activity
public void startSearch(String initialQuery, boolean selectInitialQuery,
Bundle appSearchData, boolean globalSearch) {
showWorkspace(true);
if (initialQuery == null) {
// Use any text typed in the launcher as the initial query
initialQuery = getTypedText();
@@ -2121,6 +2132,9 @@ public class Launcher extends Activity
if (clearTextImmediately) {
clearTypedText();
}
// We need to show the workspace after starting the search
showWorkspace(true);
}
/**
@@ -2866,6 +2880,21 @@ public class Launcher extends Activity
}
}
/** Updates the interaction state. */
public void updateInteraction(Workspace.State fromState, Workspace.State toState) {
// Only update the interacting state if we are transitioning to/from a view without an
// overlay
boolean fromStateWithoutOverlay = fromState != Workspace.State.NORMAL &&
fromState != Workspace.State.NORMAL_HIDDEN;
boolean toStateWithoutOverlay = toState != Workspace.State.NORMAL &&
toState != Workspace.State.NORMAL_HIDDEN;
if (toStateWithoutOverlay) {
onInteractionBegin();
} else if (fromStateWithoutOverlay) {
onInteractionEnd();
}
}
void startApplicationDetailsActivity(ComponentName componentName, UserHandleCompat user) {
try {
LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(this);
@@ -3170,7 +3199,6 @@ public class Launcher extends Activity
if (v instanceof Workspace) {
if (!mWorkspace.isInOverviewMode()) {
if (!mWorkspace.isTouchActive()) {
showOverviewMode(true);
mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
@@ -3342,8 +3370,12 @@ public class Launcher extends Activity
// Send an accessibility event to announce the context change
getWindow().getDecorView()
.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
onWorkspaceShown(animated);
if (notifyLauncherCallbacks) {
// Dismiss all apps when the workspace is shown
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onAllAppsHidden();
}
}
}
}
@@ -3353,10 +3385,6 @@ public class Launcher extends Activity
WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE, animated,
null /* onCompleteRunnable */);
mState = State.WORKSPACE;
onWorkspaceShown(animated);
}
public void onWorkspaceShown(boolean animated) {
}
/**
@@ -3416,6 +3444,18 @@ public class Launcher extends Activity
.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
/**
* Updates the workspace and interaction state on state change, and return the animation to this
* new state.
*/
public Animator startWorkspaceStateChangeAnimation(Workspace.State toState, int toPage,
boolean animated, HashMap<View, Integer> layerViews) {
Workspace.State fromState = mWorkspace.getState();
Animator anim = mWorkspace.setStateWithAnimation(toState, toPage, animated, layerViews);
updateInteraction(fromState, toState);
return anim;
}
public void enterSpringLoadedDragMode() {
Log.d(TAG, String.format("enterSpringLoadedDragMode [mState=%s",
mState.name()));
@@ -3434,6 +3474,14 @@ public class Launcher extends Activity
final Runnable onCompleteRunnable) {
if (mState != State.APPS_SPRING_LOADED && mState != State.WIDGETS_SPRING_LOADED) return;
if (successfulDrop) {
// We need to trigger all apps hidden to notify search to update itself before the
// delayed call to showWorkspace below
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onAllAppsHidden();
}
}
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
@@ -3454,13 +3502,10 @@ public class Launcher extends Activity
void exitSpringLoadedDragMode() {
if (mState == State.APPS_SPRING_LOADED) {
mStateTransitionAnimation.startAnimationToAllApps(true /* animated */);
mState = State.APPS;
showAppsView(true, false);
} else if (mState == State.WIDGETS_SPRING_LOADED) {
mStateTransitionAnimation.startAnimationToWidgets(true /* animated */);
mState = State.WIDGETS;
showWidgetsView(true, false);
}
// Otherwise, we are not in spring loaded mode, so don't do anything.
}
void lockAllApps() {