mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 19:38:21 +00:00
Launcher-side changes to support prediction bar.
Change-Id: Ib9974ad8888ad87137c774f9f531fae9d56b899a
This commit is contained in:
@@ -269,19 +269,8 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett
|
||||
|
||||
// Start the drag
|
||||
mLauncher.getWorkspace().beginDragShared(v, mLastTouchPos, this, false);
|
||||
|
||||
// We delay entering spring-loaded mode slightly to make sure the UI
|
||||
// thready is free of any work.
|
||||
postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// We don't enter spring-loaded mode if the drag has been cancelled
|
||||
if (mLauncher.getDragController().isDragging()) {
|
||||
// Go into spring loaded mode (must happen before we startDrag())
|
||||
mLauncher.enterSpringLoadedDragMode();
|
||||
}
|
||||
}
|
||||
}, 150);
|
||||
// Enter spring loaded mode
|
||||
mLauncher.enterSpringLoadedDragMode();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -51,6 +51,7 @@ public interface LauncherCallbacks {
|
||||
public void finishBindingItems(final boolean upgradePath);
|
||||
public void onClickAllAppsButton(View v);
|
||||
public void onAllAppsShown();
|
||||
public void onAllAppsHidden();
|
||||
public void bindAllApplications(ArrayList<AppInfo> apps);
|
||||
public void onClickFolderIcon(View v);
|
||||
public void onClickAppShortcut(View v);
|
||||
|
||||
@@ -127,6 +127,10 @@ public class LauncherExtension extends Launcher {
|
||||
public void onAllAppsShown() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAllAppsHidden() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindAllApplications(ArrayList<AppInfo> apps) {
|
||||
}
|
||||
|
||||
@@ -249,8 +249,8 @@ public class LauncherStateTransitionAnimation {
|
||||
|
||||
// Create the workspace animation.
|
||||
// NOTE: this call apparently also sets the state for the workspace if !animated
|
||||
Animator workspaceAnim = mLauncher.getWorkspace().setStateWithAnimation(
|
||||
toWorkspaceState, -1, animated, layerViews);
|
||||
Animator workspaceAnim = mLauncher.startWorkspaceStateChangeAnimation(toWorkspaceState, -1,
|
||||
animated, layerViews);
|
||||
|
||||
if (animated && initialized) {
|
||||
mStateAnimation = LauncherAnimUtils.createAnimatorSet();
|
||||
@@ -546,8 +546,8 @@ public class LauncherStateTransitionAnimation {
|
||||
|
||||
// Create the workspace animation.
|
||||
// NOTE: this call apparently also sets the state for the workspace if !animated
|
||||
Animator workspaceAnim = mLauncher.getWorkspace().setStateWithAnimation(
|
||||
toWorkspaceState, toWorkspacePage, animated, layerViews);
|
||||
Animator workspaceAnim = mLauncher.startWorkspaceStateChangeAnimation(toWorkspaceState,
|
||||
toWorkspacePage, animated, layerViews);
|
||||
|
||||
if (animated && initialized) {
|
||||
mStateAnimation = LauncherAnimUtils.createAnimatorSet();
|
||||
|
||||
@@ -180,9 +180,6 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
|
||||
prepareStartAnimation(mDropTargetBar);
|
||||
mShowDropTargetBarAnim.start();
|
||||
hideSearchBar(true);
|
||||
if (mQSBSearchBar != null) {
|
||||
mQSBSearchBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,9 +190,6 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
|
||||
prepareStartAnimation(mDropTargetBar);
|
||||
mShowDropTargetBarAnim.reverse();
|
||||
showSearchBar(true);
|
||||
if (mQSBSearchBar != null) {
|
||||
mQSBSearchBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -2040,14 +2040,6 @@ public class Workspace extends SmoothPagedView
|
||||
return -offsetFromTopEdge + mInsets.top + offsetToCenterInOverview;
|
||||
}
|
||||
|
||||
public void updateInteractionForState() {
|
||||
if (mState != State.NORMAL) {
|
||||
mLauncher.onInteractionBegin();
|
||||
} else {
|
||||
mLauncher.onInteractionEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current workspace {@link State}, returning an animation transitioning the workspace
|
||||
* to that new state.
|
||||
@@ -2060,7 +2052,6 @@ public class Workspace extends SmoothPagedView
|
||||
|
||||
// Update the current state
|
||||
mState = toState;
|
||||
updateInteractionForState();
|
||||
updateAccessibilityFlags();
|
||||
|
||||
return workspaceAnim;
|
||||
|
||||
Reference in New Issue
Block a user