Changing LauncherState to a class to allow adding custom functionality
Bug: 67678570 Change-Id: I777e335e9fdf7014b041addff6b8e54fb94167bb
This commit is contained in:
@@ -1026,7 +1026,7 @@ public class Launcher extends BaseActivity
|
||||
return;
|
||||
}
|
||||
|
||||
int stateOrdinal = savedState.getInt(RUNTIME_STATE, LauncherState.NORMAL.ordinal());
|
||||
int stateOrdinal = savedState.getInt(RUNTIME_STATE, LauncherState.NORMAL.ordinal);
|
||||
LauncherState[] stateValues = LauncherState.values();
|
||||
LauncherState state = stateValues[stateOrdinal];
|
||||
if (!state.doNotRestore) {
|
||||
@@ -1495,7 +1495,7 @@ public class Launcher extends BaseActivity
|
||||
outState.putInt(RUNTIME_STATE_CURRENT_SCREEN, mWorkspace.getNextPage());
|
||||
|
||||
}
|
||||
outState.putInt(RUNTIME_STATE, mWorkspace.getState().ordinal());
|
||||
outState.putInt(RUNTIME_STATE, mWorkspace.getState().ordinal);
|
||||
|
||||
|
||||
AbstractFloatingView widgets = AbstractFloatingView
|
||||
@@ -2336,7 +2336,7 @@ public class Launcher extends BaseActivity
|
||||
public boolean onLongClick(View v) {
|
||||
if (!isDraggingEnabled()) return false;
|
||||
if (isWorkspaceLocked()) return false;
|
||||
if (!isInState(LauncherState.NORMAL)) return false;
|
||||
if (!isInState(LauncherState.NORMAL) && !isInState(LauncherState.OVERVIEW)) return false;
|
||||
|
||||
boolean ignoreLongPressToOverview =
|
||||
mDeviceProfile.shouldIgnoreLongPressToOverview(mLastDispatchTouchEventX);
|
||||
@@ -2531,7 +2531,7 @@ public class Launcher extends BaseActivity
|
||||
|
||||
public void enterSpringLoadedDragMode() {
|
||||
if (LOGD) Log.d(TAG, String.format("enterSpringLoadedDragMode [mState=%s",
|
||||
mWorkspace.getState().name()));
|
||||
mWorkspace.getState().ordinal));
|
||||
if (isInState(LauncherState.SPRING_LOADED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,34 +21,41 @@ import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
|
||||
import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS;
|
||||
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;
|
||||
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
||||
|
||||
interface StateFlags {
|
||||
int FLAG_SHOW_SCRIM = 1 << 0;
|
||||
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;
|
||||
}
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
* Various states for launcher
|
||||
*/
|
||||
public enum LauncherState {
|
||||
public class LauncherState {
|
||||
|
||||
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_DO_NOT_RESTORE),
|
||||
OVERVIEW (ContainerType.OVERVIEW, OVERVIEW_TRANSITION_MS,
|
||||
protected static final int FLAG_SHOW_SCRIM = 1 << 0;
|
||||
protected static final int FLAG_MULTI_PAGE = 1 << 1;
|
||||
protected static final int FLAG_HIDE_HOTSEAT = 1 << 2;
|
||||
protected static final int FLAG_DISABLE_ACCESSIBILITY = 1 << 3;
|
||||
protected static final int FLAG_DO_NOT_RESTORE = 1 << 4;
|
||||
|
||||
private static final LauncherState[] sAllStates = new LauncherState[4];
|
||||
|
||||
public static LauncherState NORMAL = new LauncherState(0, ContainerType.WORKSPACE,
|
||||
0, FLAG_DO_NOT_RESTORE);
|
||||
|
||||
public static LauncherState ALL_APPS = new LauncherState(1, ContainerType.ALLAPPS,
|
||||
ALL_APPS_TRANSITION_MS, FLAG_DISABLE_ACCESSIBILITY);
|
||||
|
||||
public static LauncherState SPRING_LOADED = new LauncherState(2, ContainerType.WORKSPACE,
|
||||
SPRING_LOADED_TRANSITION_MS,
|
||||
FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_DISABLE_ACCESSIBILITY | FLAG_DO_NOT_RESTORE);
|
||||
|
||||
public static LauncherState OVERVIEW = new LauncherState(3, ContainerType.OVERVIEW,
|
||||
OVERVIEW_TRANSITION_MS,
|
||||
FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT | FLAG_DO_NOT_RESTORE);
|
||||
|
||||
public final int ordinal;
|
||||
|
||||
/**
|
||||
* Used for containerType in {@link com.android.launcher3.logging.UserEventDispatcher}
|
||||
*/
|
||||
@@ -75,7 +82,7 @@ public enum LauncherState {
|
||||
public final boolean hideHotseat;
|
||||
public final int transitionDuration;
|
||||
|
||||
LauncherState(int containerType, int transitionDuration, int flags) {
|
||||
public LauncherState(int id, int containerType, int transitionDuration, int flags) {
|
||||
this.containerType = containerType;
|
||||
this.transitionDuration = transitionDuration;
|
||||
|
||||
@@ -86,5 +93,12 @@ public enum LauncherState {
|
||||
? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
|
||||
: IMPORTANT_FOR_ACCESSIBILITY_AUTO;
|
||||
this.doNotRestore = (flags & FLAG_DO_NOT_RESTORE) != 0;
|
||||
|
||||
this.ordinal = id;
|
||||
sAllStates[id] = this;
|
||||
}
|
||||
|
||||
public static LauncherState[] values() {
|
||||
return Arrays.copyOf(sAllStates, sAllStates.length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.android.launcher3;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.DRAWABLE_ALPHA;
|
||||
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.LauncherState.SPRING_LOADED;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
@@ -187,18 +189,15 @@ public class WorkspaceStateTransitionAnimation {
|
||||
int finalBackgroundAlpha = state.hasScrim ? 255 : 0;
|
||||
|
||||
final float finalWorkspaceTranslationY;
|
||||
switch (state) {
|
||||
case OVERVIEW:
|
||||
mNewScale = mOverviewModeShrinkFactor;
|
||||
finalWorkspaceTranslationY = mWorkspace.getOverviewModeTranslationY();
|
||||
break;
|
||||
case SPRING_LOADED:
|
||||
mNewScale = mSpringLoadedShrinkFactor;
|
||||
finalWorkspaceTranslationY = mWorkspace.getSpringLoadedTranslationY();
|
||||
break;
|
||||
default:
|
||||
mNewScale = 1f;
|
||||
finalWorkspaceTranslationY = 0;
|
||||
if (state == OVERVIEW) {
|
||||
mNewScale = mOverviewModeShrinkFactor;
|
||||
finalWorkspaceTranslationY = mWorkspace.getOverviewModeTranslationY();
|
||||
} else if (state == SPRING_LOADED) {
|
||||
mNewScale = mSpringLoadedShrinkFactor;
|
||||
finalWorkspaceTranslationY = mWorkspace.getSpringLoadedTranslationY();
|
||||
} else {
|
||||
mNewScale = 1f;
|
||||
finalWorkspaceTranslationY = 0;
|
||||
}
|
||||
|
||||
int toPage = mWorkspace.getPageNearestToCenterOfScreen();
|
||||
|
||||
Reference in New Issue
Block a user