Removing state definition from Launcher
State is only maintained is workspace and is used for all the UI
Bug: 67678570
Change-Id: Ie3cce5a1f4ada3913d0480f7918c27460dacbd34
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 3643971..2ab08b2 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -52,7 +52,6 @@
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.config.FeatureFlags;
-import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.folder.PreviewBackground;
import com.android.launcher3.graphics.DragPreviewProvider;
import com.android.launcher3.util.CellAndSpan;
@@ -342,7 +341,7 @@
// the home screen mode, however, once in overview mode stylus button press should be
// enabled to allow rearranging the different home screens. So check what mode
// the workspace is in, and only perform stylus button presses while in overview mode.
- if (mLauncher.mWorkspace.isInOverviewMode()
+ if (mLauncher.isInState(LauncherState.OVERVIEW)
&& mStylusEventHelper.onMotionEvent(ev)) {
return true;
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 24e7083..4efb911 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -79,7 +79,6 @@
import android.view.View;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
-import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.OvershootInterpolator;
@@ -186,11 +185,6 @@
*/
protected static final int REQUEST_LAST = 100;
- private static final int SOFT_INPUT_MODE_DEFAULT =
- WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN;
- private static final int SOFT_INPUT_MODE_ALL_APPS =
- WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
-
// The Intent extra that defines whether to ignore the launch animation
static final String INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION =
"com.android.launcher3.intent.extra.shortcut.INGORE_LAUNCH_ANIMATION";
@@ -208,10 +202,6 @@
static final String APPS_VIEW_SHOWN = "launcher.apps_view_shown";
- /** The different states that Launcher can be in. */
- enum State { WORKSPACE, WORKSPACE_SPRING_LOADED, APPS}
-
- @Thunk State mState = State.WORKSPACE;
@Thunk LauncherStateTransitionAnimation mStateTransitionAnimation;
private boolean mIsSafeModeEnabled;
@@ -601,7 +591,7 @@
}
return;
} else if (requestCode == REQUEST_PICK_WALLPAPER) {
- if (resultCode == RESULT_OK && mWorkspace.isInOverviewMode()) {
+ if (resultCode == RESULT_OK && isInState(LauncherState.OVERVIEW)) {
// User could have free-scrolled between pages before picking a wallpaper; make sure
// we move to the closest one now.
mWorkspace.setCurrentPage(mWorkspace.getPageNearestToCenterOfScreen());
@@ -1001,8 +991,7 @@
AbstractFloatingView.closeAllOpenViews(this);
// Show the overview mode if we are on the workspace
- if (mState == State.WORKSPACE && !mWorkspace.isInOverviewMode() &&
- !mWorkspace.isSwitchingState()) {
+ if (isInState(LauncherState.NORMAL) && !mWorkspace.isSwitchingState()) {
mOverviewPanel.requestFocus();
showOverviewMode(true, true /* requestButtonFocus */);
}
@@ -1023,6 +1012,10 @@
Selection.setSelection(mDefaultKeySsb, 0);
}
+ public boolean isInState(LauncherState state) {
+ return mWorkspace.getState() == state;
+ }
+
/**
* Restores the previous state, if it exists.
*
@@ -1033,12 +1026,15 @@
return;
}
- int stateOrdinal = savedState.getInt(RUNTIME_STATE, State.WORKSPACE.ordinal());
- State[] stateValues = State.values();
- State state = (stateOrdinal >= 0 && stateOrdinal < stateValues.length)
- ? stateValues[stateOrdinal] : State.WORKSPACE;
- if (state == State.APPS) {
- showAppsView(false /* animated */);
+ int stateOrdinal = savedState.getInt(RUNTIME_STATE, LauncherState.NORMAL.ordinal());
+ LauncherState[] stateValues = LauncherState.values();
+ LauncherState state = stateValues[stateOrdinal];
+ if (!state.doNotRestore) {
+ if (state == LauncherState.ALL_APPS) {
+ showAppsView(false /* animated */);
+ } else {
+ // TODO: Add logic for other states
+ }
}
PendingRequestArgs requestArgs = savedState.getParcelable(RUNTIME_STATE_PENDING_REQUEST_ARGS);
@@ -1419,8 +1415,8 @@
!= Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
// Check this condition before handling isActionMain, as this will get reset.
- boolean shouldMoveToDefaultScreen = alreadyOnHome &&
- mState == State.WORKSPACE && AbstractFloatingView.getTopOpenView(this) == null;
+ boolean shouldMoveToDefaultScreen = alreadyOnHome && isInState(LauncherState.NORMAL)
+ && AbstractFloatingView.getTopOpenView(this) == null;
boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction());
if (isActionMain) {
@@ -1499,7 +1495,7 @@
outState.putInt(RUNTIME_STATE_CURRENT_SCREEN, mWorkspace.getNextPage());
}
- outState.putInt(RUNTIME_STATE, mState.ordinal());
+ outState.putInt(RUNTIME_STATE, mWorkspace.getState().ordinal());
AbstractFloatingView widgets = AbstractFloatingView
@@ -1893,10 +1889,10 @@
AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this);
if (topView != null) {
topView.onBackPressed();
- } else if (isAppsViewVisible()) {
+ } else if (isInState(LauncherState.ALL_APPS)) {
ued.logActionCommand(Action.Command.BACK, ContainerType.ALLAPPS);
showWorkspace(true);
- } else if (mWorkspace.isInOverviewMode()) {
+ } else if (isInState(LauncherState.OVERVIEW)) {
ued.logActionCommand(Action.Command.BACK, ContainerType.OVERVIEW);
showWorkspace(true);
} else {
@@ -1922,7 +1918,7 @@
}
if (v instanceof Workspace) {
- if (mWorkspace.isInOverviewMode()) {
+ if (isInState(LauncherState.OVERVIEW)) {
getUserEventDispatcher().logActionOnContainer(LauncherLogProto.Action.Type.TOUCH,
LauncherLogProto.Action.Direction.NONE,
LauncherLogProto.ContainerType.OVERVIEW, mWorkspace.getCurrentPage());
@@ -1932,7 +1928,7 @@
}
if (v instanceof CellLayout) {
- if (mWorkspace.isInOverviewMode()) {
+ if (isInState(LauncherState.OVERVIEW)) {
int page = mWorkspace.indexOfChild(v);
getUserEventDispatcher().logActionOnContainer(LauncherLogProto.Action.Type.TOUCH,
LauncherLogProto.Action.Direction.NONE,
@@ -2010,7 +2006,7 @@
*/
protected void onClickAllAppsButton(View v) {
if (LOGD) Log.d(TAG, "onClickAllAppsButton");
- if (!isAppsViewVisible()) {
+ if (!isInState(LauncherState.ALL_APPS)) {
getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
ControlType.ALL_APPS_BUTTON);
showAppsView(true /* animated */);
@@ -2340,13 +2336,13 @@
public boolean onLongClick(View v) {
if (!isDraggingEnabled()) return false;
if (isWorkspaceLocked()) return false;
- if (mState != State.WORKSPACE) return false;
+ if (!isInState(LauncherState.NORMAL)) return false;
boolean ignoreLongPressToOverview =
mDeviceProfile.shouldIgnoreLongPressToOverview(mLastDispatchTouchEventX);
if (v instanceof Workspace) {
- if (!mWorkspace.isInOverviewMode()) {
+ if (!isInState(LauncherState.OVERVIEW)) {
if (!mWorkspace.isTouchActive() && !ignoreLongPressToOverview) {
getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
Action.Direction.NONE, ContainerType.WORKSPACE,
@@ -2377,7 +2373,7 @@
if (!mDragController.isDragging()) {
if (itemUnderLongClick == null) {
// User long pressed on empty space
- if (mWorkspace.isInOverviewMode()) {
+ if (isInState(LauncherState.OVERVIEW)) {
mWorkspace.startReordering(v);
getUserEventDispatcher().logActionOnContainer(Action.Touch.LONGPRESS,
Action.Direction.NONE, ContainerType.OVERVIEW);
@@ -2427,17 +2423,6 @@
}
}
- /**
- * For overridden classes.
- */
- public boolean isAllAppsVisible() {
- return isAppsViewVisible();
- }
-
- public boolean isAppsViewVisible() {
- return mState == State.APPS;
- }
-
@Override
public void onTrimMemory(int level) {
super.onTrimMemory(level);
@@ -2459,11 +2444,10 @@
}
public boolean showWorkspace(boolean animated, Runnable onCompleteRunnable) {
- boolean changed = mState != State.WORKSPACE ||
- mWorkspace.getState() != LauncherState.NORMAL;
+ boolean changed = !isInState(LauncherState.NORMAL);
if (changed || mAllAppsController.isTransitioning()) {
mWorkspace.setVisibility(View.VISIBLE);
- mStateTransitionAnimation.startAnimationToWorkspace(mState, mWorkspace.getState(),
+ mStateTransitionAnimation.startAnimationToWorkspace(
LauncherState.NORMAL, animated, onCompleteRunnable);
// Set focus to the AppsCustomize button
@@ -2472,9 +2456,6 @@
}
}
- // Change the state *after* we've called all the transition code
- setState(State.WORKSPACE);
-
if (changed) {
// Send an accessibility event to announce the context change
getWindow().getDecorView()
@@ -2508,32 +2489,14 @@
};
}
mWorkspace.setVisibility(View.VISIBLE);
- mStateTransitionAnimation.startAnimationToWorkspace(mState, mWorkspace.getState(),
+ mStateTransitionAnimation.startAnimationToWorkspace(
LauncherState.OVERVIEW, animated, postAnimRunnable);
- setState(State.WORKSPACE);
// If animated from long press, then don't allow any of the controller in the drag
// layer to intercept any remaining touch.
mWorkspace.requestDisallowInterceptTouchEvent(animated);
}
- private void setState(State state) {
- this.mState = state;
- updateSoftInputMode();
- }
-
- private void updateSoftInputMode() {
- if (FeatureFlags.LAUNCHER3_UPDATE_SOFT_INPUT_MODE) {
- final int mode;
- if (isAppsViewVisible()) {
- mode = SOFT_INPUT_MODE_ALL_APPS;
- } else {
- mode = SOFT_INPUT_MODE_DEFAULT;
- }
- getWindow().setSoftInputMode(mode);
- }
- }
-
/**
* Shows the apps view.
*
@@ -2544,8 +2507,8 @@
public boolean showAppsView(boolean animated) {
markAppsViewShown();
- if (!(mState == State.WORKSPACE ||
- (mState == State.APPS && mAllAppsController.isTransitioning()))) {
+ if (!(isInState(LauncherState.NORMAL) ||
+ (isInState(LauncherState.ALL_APPS) && mAllAppsController.isTransitioning()))) {
return false;
}
@@ -2558,7 +2521,6 @@
mStateTransitionAnimation.startAnimationToAllApps(animated);
// Change the state *after* we've called all the transition code
- setState(State.APPS);
AbstractFloatingView.closeAllOpenViews(this);
// Send an accessibility event to announce the context change
@@ -2568,8 +2530,9 @@
}
public void enterSpringLoadedDragMode() {
- if (LOGD) Log.d(TAG, String.format("enterSpringLoadedDragMode [mState=%s", mState.name()));
- if (isStateSpringLoaded()) {
+ if (LOGD) Log.d(TAG, String.format("enterSpringLoadedDragMode [mState=%s",
+ mWorkspace.getState().name()));
+ if (isInState(LauncherState.SPRING_LOADED)) {
return;
}
@@ -2582,10 +2545,9 @@
// in spring loaded mode
InstallShortcutReceiver.enableInstallQueue(InstallShortcutReceiver.FLAG_DRAG_AND_DROP);
- mStateTransitionAnimation.startAnimationToWorkspace(mState, mWorkspace.getState(),
+ mStateTransitionAnimation.startAnimationToWorkspace(
LauncherState.SPRING_LOADED, true /* animated */,
null /* onCompleteRunnable */);
- setState(State.WORKSPACE_SPRING_LOADED);
}
public void exitSpringLoadedDragMode(int delay) {
@@ -2593,7 +2555,7 @@
}
public void exitSpringLoadedDragMode(int delay, final Runnable onCompleteRunnable) {
- if (!isStateSpringLoaded()) return;
+ if (!isInState(LauncherState.SPRING_LOADED)) return;
// Unlock rotation lock
unlockScreenOrientation(false);
@@ -2615,17 +2577,13 @@
mHandler.postDelayed(mExitSpringLoadedModeRunnable, delay);
}
- boolean isStateSpringLoaded() {
- return mState == State.WORKSPACE_SPRING_LOADED;
- }
-
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
final boolean result = super.dispatchPopulateAccessibilityEvent(event);
final List<CharSequence> text = event.getText();
text.clear();
// Populate event with a fake title based on the current state.
- if (mState == State.APPS) {
+ if (isInState(LauncherState.ALL_APPS)) {
text.add(getString(R.string.all_apps_button_label));
} else if (mWorkspace != null) {
text.add(mWorkspace.getCurrentPageDescription());
@@ -3182,7 +3140,7 @@
if (mAppsView != null) {
Executor pendingExecutor = getPendingExecutor();
- if (pendingExecutor != null && mState != State.APPS) {
+ if (pendingExecutor != null && !isInState(LauncherState.ALL_APPS)) {
// Wait until the fade in animation has finished before setting all apps list.
pendingExecutor.execute(r);
return;
@@ -3389,8 +3347,8 @@
}
private boolean shouldShowDiscoveryBounce() {
- UserManagerCompat um = UserManagerCompat.getInstance(this);
- return mState == State.WORKSPACE && !mSharedPrefs.getBoolean(APPS_VIEW_SHOWN, false) && !um.isDemoUser();
+ return isInState(LauncherState.NORMAL) && !mSharedPrefs.getBoolean(APPS_VIEW_SHOWN, false)
+ && !UserManagerCompat.getInstance(this).isDemoUser();
}
/**
@@ -3448,7 +3406,7 @@
List<KeyboardShortcutGroup> data, Menu menu, int deviceId) {
ArrayList<KeyboardShortcutInfo> shortcutInfos = new ArrayList<>();
- if (mState == State.WORKSPACE) {
+ if (isInState(LauncherState.NORMAL)) {
shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.all_apps_button_label),
KeyEvent.KEYCODE_A, KeyEvent.META_CTRL_ON));
}
@@ -3474,7 +3432,7 @@
if (event.hasModifiers(KeyEvent.META_CTRL_ON)) {
switch (keyCode) {
case KeyEvent.KEYCODE_A:
- if (mState == State.WORKSPACE) {
+ if (isInState(LauncherState.NORMAL)) {
showAppsView(true);
return true;
}
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 8ddc491..c51b920 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -22,6 +22,7 @@
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;
import static com.android.launcher3.StateFlags.FLAG_DISABLE_ACCESSIBILITY;
+import static com.android.launcher3.StateFlags.FLAG_DO_NOT_RESTORE;
import static com.android.launcher3.StateFlags.FLAG_HIDE_HOTSEAT;
import static com.android.launcher3.StateFlags.FLAG_MULTI_PAGE;
import static com.android.launcher3.StateFlags.FLAG_SHOW_SCRIM;
@@ -33,6 +34,7 @@
int FLAG_MULTI_PAGE = 1 << 1;
int FLAG_HIDE_HOTSEAT = 1 << 2;
int FLAG_DISABLE_ACCESSIBILITY = 1 << 3;
+ int FLAG_DO_NOT_RESTORE = 1 << 4;
}
/**
@@ -40,16 +42,32 @@
*/
public enum LauncherState {
- NORMAL (ContainerType.WORKSPACE, 0, 0),
+ NORMAL (ContainerType.WORKSPACE, 0, FLAG_DO_NOT_RESTORE),
ALL_APPS (ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, FLAG_DISABLE_ACCESSIBILITY),
SPRING_LOADED (ContainerType.WORKSPACE, SPRING_LOADED_TRANSITION_MS,
- FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_DISABLE_ACCESSIBILITY),
+ FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_DISABLE_ACCESSIBILITY | FLAG_DO_NOT_RESTORE),
OVERVIEW (ContainerType.OVERVIEW, OVERVIEW_TRANSITION_MS,
- FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT);
+ FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT | FLAG_DO_NOT_RESTORE);
+ /**
+ * Used for containerType in {@link com.android.launcher3.logging.UserEventDispatcher}
+ */
public final int containerType;
+ /**
+ * True if the state can be persisted across activity restarts.
+ */
+ public final boolean doNotRestore;
+
+ /**
+ * True if workspace has multiple pages visible.
+ */
public final boolean hasMultipleVisiblePages;
+
+ /**
+ * Accessibility flag for workspace and its pages.
+ * @see android.view.View#setImportantForAccessibility(int)
+ */
public final int workspaceAccessibilityFlag;
// Properties related to state transition animation.
@@ -67,5 +85,6 @@
this.workspaceAccessibilityFlag = (flags & FLAG_DISABLE_ACCESSIBILITY) != 0
? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
: IMPORTANT_FOR_ACCESSIBILITY_AUTO;
+ this.doNotRestore = (flags & FLAG_DO_NOT_RESTORE) != 0;
}
}
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index f07f1bf..40d5495 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -145,8 +145,7 @@
/**
* Starts an animation to the workspace from the current overlay view.
*/
- public void startAnimationToWorkspace(final Launcher.State fromState,
- final LauncherState fromWorkspaceState, final LauncherState toWorkspaceState,
+ public void startAnimationToWorkspace(final LauncherState toWorkspaceState,
final boolean animated, final Runnable onCompleteRunnable) {
if (toWorkspaceState != LauncherState.NORMAL &&
toWorkspaceState != LauncherState.SPRING_LOADED &&
@@ -154,12 +153,11 @@
Log.e(TAG, "Unexpected call to startAnimationToWorkspace");
}
- if (fromState == Launcher.State.APPS || mAllAppsController.isTransitioning()) {
- startAnimationToWorkspaceFromAllApps(fromWorkspaceState, toWorkspaceState,
- animated, onCompleteRunnable);
+ if (mLauncher.isInState(LauncherState.ALL_APPS) || mAllAppsController.isTransitioning()) {
+ startAnimationToWorkspaceFromAllApps(mLauncher.getWorkspace().getState(),
+ toWorkspaceState, animated, onCompleteRunnable);
} else {
- startAnimationToNewWorkspaceState(fromWorkspaceState, toWorkspaceState,
- animated, onCompleteRunnable);
+ startAnimationToNewWorkspaceState(toWorkspaceState, animated, onCompleteRunnable);
}
}
@@ -233,7 +231,7 @@
/**
* Starts an animation to the workspace from another workspace state, e.g. normal to overview.
*/
- private void startAnimationToNewWorkspaceState(final LauncherState fromWorkspaceState,
+ private void startAnimationToNewWorkspaceState(
final LauncherState toWorkspaceState, final boolean animated,
final Runnable onCompleteRunnable) {
final View fromWorkspace = mLauncher.getWorkspace();
diff --git a/src/com/android/launcher3/PinchThresholdManager.java b/src/com/android/launcher3/PinchThresholdManager.java
index 8cbc33d..4937633 100644
--- a/src/com/android/launcher3/PinchThresholdManager.java
+++ b/src/com/android/launcher3/PinchThresholdManager.java
@@ -29,12 +29,14 @@
public static final float THRESHOLD_TWO = 0.70f;
public static final float THRESHOLD_THREE = 0.95f;
- private Workspace mWorkspace;
+ private final Workspace mWorkspace;
+ private final Launcher mLauncher;
private float mPassedThreshold = THRESHOLD_ZERO;
public PinchThresholdManager(Workspace workspace) {
mWorkspace = workspace;
+ mLauncher = mWorkspace.mLauncher;
}
/**
@@ -50,7 +52,7 @@
*/
public float updateAndAnimatePassedThreshold(float progress,
PinchAnimationManager animationManager) {
- if (!mWorkspace.isInOverviewMode()) {
+ if (!mLauncher.isInState(LauncherState.OVERVIEW)) {
// Invert the progress, because going from workspace to overview is 1 to 0.
progress = 1f - progress;
}
@@ -68,10 +70,9 @@
}
if (mPassedThreshold != previousPassedThreshold) {
- LauncherState fromState = mWorkspace.isInOverviewMode() ? LauncherState.OVERVIEW
- : LauncherState.NORMAL;
- LauncherState toState = mWorkspace.isInOverviewMode() ? LauncherState.NORMAL
- : LauncherState.OVERVIEW;
+ LauncherState fromState = mLauncher.getWorkspace().getState();
+ LauncherState toState = mLauncher.isInState(LauncherState.OVERVIEW)
+ ? LauncherState.NORMAL : LauncherState.OVERVIEW;
float thresholdToAnimate = mPassedThreshold;
if (mPassedThreshold < previousPassedThreshold) {
// User reversed pinch, so heading back to the state that they started from.
diff --git a/src/com/android/launcher3/PinchToOverviewListener.java b/src/com/android/launcher3/PinchToOverviewListener.java
index 2a5899c..a1288b4 100644
--- a/src/com/android/launcher3/PinchToOverviewListener.java
+++ b/src/com/android/launcher3/PinchToOverviewListener.java
@@ -80,7 +80,7 @@
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
- if (mLauncher.mState != Launcher.State.WORKSPACE) {
+ if (!mLauncher.isInState(LauncherState.NORMAL)) {
// Don't listen for the pinch gesture if on all apps, widget picker, -1, etc.
return false;
}
@@ -107,9 +107,9 @@
return false;
}
- mPreviousProgress = mWorkspace.isInOverviewMode() ? OVERVIEW_PROGRESS : WORKSPACE_PROGRESS;
+ mPreviousProgress = mLauncher.isInState(LauncherState.OVERVIEW) ? OVERVIEW_PROGRESS : WORKSPACE_PROGRESS;
mPreviousTimeMillis = System.currentTimeMillis();
- mInterpolator = mWorkspace.isInOverviewMode() ? new LogDecelerateInterpolator(100, 0)
+ mInterpolator = mLauncher.isInState(LauncherState.OVERVIEW) ? new LogDecelerateInterpolator(100, 0)
: new LogAccelerateInterpolator(100, 0);
mPinchStarted = true;
mWorkspace.onPrepareStateTransition(true);
@@ -122,21 +122,21 @@
float progressVelocity = mProgressDelta / mTimeDelta;
float passedThreshold = mThresholdManager.getPassedThreshold();
- boolean isFling = mWorkspace.isInOverviewMode() && progressVelocity >= FLING_VELOCITY
- || !mWorkspace.isInOverviewMode() && progressVelocity <= -FLING_VELOCITY;
+ boolean isFling = mLauncher.isInState(LauncherState.OVERVIEW) && progressVelocity >= FLING_VELOCITY
+ || !mLauncher.isInState(LauncherState.OVERVIEW) && progressVelocity <= -FLING_VELOCITY;
boolean shouldCancelPinch = !isFling && passedThreshold < PinchThresholdManager.THRESHOLD_ONE;
// If we are going towards overview, mPreviousProgress is how much further we need to
// go, since it is going from 1 to 0. If we are going to workspace, we want
// 1 - mPreviousProgress.
float remainingProgress = mPreviousProgress;
- if (mWorkspace.isInOverviewMode() || shouldCancelPinch) {
+ if (mLauncher.isInState(LauncherState.OVERVIEW) || shouldCancelPinch) {
remainingProgress = 1f - mPreviousProgress;
}
int duration = computeDuration(remainingProgress, progressVelocity);
if (shouldCancelPinch) {
cancelPinch(mPreviousProgress, duration);
} else if (passedThreshold < PinchThresholdManager.THRESHOLD_THREE) {
- float toProgress = mWorkspace.isInOverviewMode() ?
+ float toProgress = mLauncher.isInState(LauncherState.OVERVIEW) ?
WORKSPACE_PROGRESS : OVERVIEW_PROGRESS;
mAnimationManager.animateToProgress(mPreviousProgress, toProgress, duration,
mThresholdManager);
@@ -165,7 +165,7 @@
private void cancelPinch(float currentProgress, int duration) {
if (mPinchCanceled) return;
mPinchCanceled = true;
- float toProgress = mWorkspace.isInOverviewMode() ? OVERVIEW_PROGRESS : WORKSPACE_PROGRESS;
+ float toProgress = mLauncher.isInState(LauncherState.OVERVIEW) ? OVERVIEW_PROGRESS : WORKSPACE_PROGRESS;
mAnimationManager.animateToProgress(currentProgress, toProgress, duration,
mThresholdManager);
mPinchStarted = false;
@@ -182,15 +182,15 @@
}
float pinchDist = detector.getCurrentSpan() - detector.getPreviousSpan();
- if (pinchDist < 0 && mWorkspace.isInOverviewMode() ||
- pinchDist > 0 && !mWorkspace.isInOverviewMode()) {
+ if (pinchDist < 0 && mLauncher.isInState(LauncherState.OVERVIEW) ||
+ pinchDist > 0 && !mLauncher.isInState(LauncherState.OVERVIEW)) {
// Pinching the wrong way, so ignore.
return false;
}
// Pinch distance must equal the workspace width before switching states.
int pinchDistanceToCompleteTransition = mWorkspace.getWidth();
float overviewScale = mWorkspace.getOverviewModeShrinkFactor();
- float initialWorkspaceScale = mWorkspace.isInOverviewMode() ? overviewScale : 1f;
+ float initialWorkspaceScale = mLauncher.isInState(LauncherState.OVERVIEW) ? overviewScale : 1f;
float pinchScale = initialWorkspaceScale + pinchDist / pinchDistanceToCompleteTransition;
// Bound the scale between the overview scale and the normal workspace scale (1f).
pinchScale = Math.max(overviewScale, Math.min(pinchScale, 1f));
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 213eaad..671ba07 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1351,7 +1351,7 @@
@Override
public void announceForAccessibility(CharSequence text) {
// Don't announce if apps is on top of us.
- if (!mLauncher.isAppsViewVisible()) {
+ if (!mLauncher.isInState(LauncherState.ALL_APPS)) {
super.announceForAccessibility(text);
}
}
@@ -1547,10 +1547,6 @@
enableLayoutTransitions();
}
- public boolean isInOverviewMode() {
- return mState == LauncherState.OVERVIEW;
- }
-
public void snapToPageFromOverView(int whichPage) {
snapToPage(whichPage, OVERVIEW_TRANSITION_MS, new ZoomInInterpolator());
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 4de31f4..a1f37ba 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -38,6 +38,7 @@
import com.android.launcher3.Insettable;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
import com.android.launcher3.PromiseAppInfo;
import com.android.launcher3.R;
import com.android.launcher3.anim.SpringAnimationHandler;
@@ -292,7 +293,7 @@
@Override
public boolean onLongClick(final View v) {
// When we have exited all apps or are in transition, disregard long clicks
- if (!mLauncher.isAppsViewVisible() ||
+ if (!mLauncher.isInState(LauncherState.ALL_APPS) ||
mLauncher.getWorkspace().isSwitchingState()) return false;
// Return if global dragging is not enabled or we are already dragging
if (!mLauncher.isDraggingEnabled()) return false;
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 5642b4c..2243a9c 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -11,13 +11,13 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
-import android.view.animation.Animation;
import android.view.animation.Interpolator;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
+import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateTransitionAnimation.AnimationConfig;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -113,9 +113,9 @@
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
mNoIntercept = false;
mTouchEventStartedOnHotseat = mLauncher.getDragLayer().isEventOverHotseat(ev);
- if (!mLauncher.isAllAppsVisible() && mLauncher.getWorkspace().workspaceInModalState()) {
+ if (!mLauncher.isInState(LauncherState.ALL_APPS) && mLauncher.getWorkspace().workspaceInModalState()) {
mNoIntercept = true;
- } else if (mLauncher.isAllAppsVisible() &&
+ } else if (mLauncher.isInState(LauncherState.ALL_APPS) &&
!mAppsView.shouldContainerScroll(ev)) {
mNoIntercept = true;
} else if (AbstractFloatingView.getTopOpenView(mLauncher) != null) {
@@ -127,7 +127,7 @@
boolean ignoreSlopWhenSettling = false;
if (mDetector.isIdleState()) {
- if (mLauncher.isAllAppsVisible()) {
+ if (mLauncher.isInState(LauncherState.ALL_APPS)) {
directionsToDetectScroll |= SwipeDetector.DIRECTION_NEGATIVE;
} else {
directionsToDetectScroll |= SwipeDetector.DIRECTION_POSITIVE;
@@ -212,7 +212,7 @@
if (velocity < 0) {
calculateDuration(velocity, mAppsView.getTranslationY());
- if (!mLauncher.isAllAppsVisible()) {
+ if (!mLauncher.isInState(LauncherState.ALL_APPS)) {
mLauncher.getUserEventDispatcher().logActionOnContainer(
Action.Touch.FLING,
Action.Direction.UP,
@@ -235,7 +235,7 @@
mLauncher.showWorkspace(true);
} else {
calculateDuration(velocity, Math.abs(mAppsView.getTranslationY()));
- if (!mLauncher.isAllAppsVisible()) {
+ if (!mLauncher.isInState(LauncherState.ALL_APPS)) {
mLauncher.getUserEventDispatcher().logActionOnContainer(
Action.Touch.SWIPE,
Action.Direction.UP,
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index 8a1bc63..f01923f 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -35,8 +35,6 @@
public static boolean LAUNCHER3_DISABLE_PINCH_TO_OVERVIEW = false;
// When enabled allows to use any point on the fast scrollbar to start dragging.
public static final boolean LAUNCHER3_DIRECT_SCROLL = true;
- // When enabled while all-apps open, the soft input will be set to adjust resize .
- public static final boolean LAUNCHER3_UPDATE_SOFT_INPUT_MODE = false;
// When enabled the promise icon is visible in all apps while installation an app.
public static final boolean LAUNCHER3_PROMISE_APPS_IN_ALL_APPS = false;
// When enabled allows use of physics based motions in the Launcher.