Changing the state UI logic for normal build and quickStep build
> Creating ShareHandlers for managing UI > In normal build, hotseat is hidden in overview, while in QuickStepBuild, it is visible Change-Id: I5f8d35c75b861d912d93fce186b5dd74106184c3
This commit is contained in:
parent
16764588c9
commit
c4fa8c312b
|
@ -16,16 +16,11 @@
|
||||||
package com.android.launcher3.uioverrides;
|
package com.android.launcher3.uioverrides;
|
||||||
|
|
||||||
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
|
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
|
||||||
import static com.android.launcher3.Utilities.isAccessibilityEnabled;
|
|
||||||
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.accessibility.AccessibilityNodeInfo;
|
|
||||||
|
|
||||||
import com.android.launcher3.DeviceProfile;
|
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.LauncherState;
|
import com.android.launcher3.LauncherState;
|
||||||
import com.android.launcher3.Workspace;
|
|
||||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
||||||
import com.android.quickstep.RecentsView;
|
import com.android.quickstep.RecentsView;
|
||||||
|
|
||||||
|
@ -37,7 +32,7 @@ public class OverviewState extends LauncherState {
|
||||||
// The percent to shrink the workspace during overview mode
|
// The percent to shrink the workspace during overview mode
|
||||||
public static final float SCALE_FACTOR = 0.7f;
|
public static final float SCALE_FACTOR = 0.7f;
|
||||||
|
|
||||||
private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT;
|
private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE;
|
||||||
|
|
||||||
public OverviewState(int id) {
|
public OverviewState(int id) {
|
||||||
super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, 1f, STATE_FLAGS);
|
super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, 1f, STATE_FLAGS);
|
||||||
|
@ -46,7 +41,7 @@ public class OverviewState extends LauncherState {
|
||||||
@Override
|
@Override
|
||||||
public float[] getWorkspaceScaleAndTranslation(Launcher launcher) {
|
public float[] getWorkspaceScaleAndTranslation(Launcher launcher) {
|
||||||
// TODO: Find a better transition
|
// TODO: Find a better transition
|
||||||
return new float[] {SCALE_FACTOR, 0};
|
return new float[] {0f, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.android.launcher3.uioverrides;
|
||||||
|
|
||||||
|
import static com.android.launcher3.WorkspaceStateTransitionAnimation.NO_ANIM_PROPERTY_SETTER;
|
||||||
|
|
||||||
|
import android.animation.AnimatorSet;
|
||||||
|
|
||||||
|
import com.android.launcher3.Launcher;
|
||||||
|
import com.android.launcher3.LauncherState;
|
||||||
|
import com.android.launcher3.LauncherStateManager.AnimationConfig;
|
||||||
|
import com.android.launcher3.LauncherStateManager.StateHandler;
|
||||||
|
import com.android.launcher3.WorkspaceStateTransitionAnimation.AnimatedPropertySetter;
|
||||||
|
import com.android.launcher3.WorkspaceStateTransitionAnimation.PropertySetter;
|
||||||
|
import com.android.launcher3.anim.AnimationLayerSet;
|
||||||
|
|
||||||
|
public class RecentsViewStateController implements StateHandler {
|
||||||
|
|
||||||
|
private final Launcher mLauncher;
|
||||||
|
|
||||||
|
public RecentsViewStateController(Launcher launcher) {
|
||||||
|
mLauncher = launcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setState(LauncherState state) {
|
||||||
|
setState(state, NO_ANIM_PROPERTY_SETTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
|
||||||
|
AnimatorSet anim, AnimationConfig config) {
|
||||||
|
setState(toState, new AnimatedPropertySetter(config.duration, layerViews, anim));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setState(LauncherState state, PropertySetter setter) {
|
||||||
|
setter.setViewAlpha(null, mLauncher.getOverviewPanel(),
|
||||||
|
state == LauncherState.OVERVIEW ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ package com.android.launcher3.uioverrides;
|
||||||
import android.view.View.AccessibilityDelegate;
|
import android.view.View.AccessibilityDelegate;
|
||||||
|
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
|
import com.android.launcher3.LauncherStateManager.StateHandler;
|
||||||
import com.android.launcher3.VerticalSwipeController;
|
import com.android.launcher3.VerticalSwipeController;
|
||||||
import com.android.launcher3.util.TouchController;
|
import com.android.launcher3.util.TouchController;
|
||||||
|
|
||||||
|
@ -31,4 +32,10 @@ public class UiFactory {
|
||||||
public static AccessibilityDelegate newPageIndicatorAccessibilityDelegate() {
|
public static AccessibilityDelegate newPageIndicatorAccessibilityDelegate() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StateHandler[] getStateHandler(Launcher launcher) {
|
||||||
|
return new StateHandler[] {
|
||||||
|
launcher.getAllAppsController(), launcher.getWorkspace(),
|
||||||
|
new RecentsViewStateController(launcher)};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,19 @@
|
||||||
package com.android.quickstep;
|
package com.android.quickstep;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.HorizontalScrollView;
|
import android.widget.HorizontalScrollView;
|
||||||
|
|
||||||
|
import com.android.launcher3.DeviceProfile;
|
||||||
|
import com.android.launcher3.Insettable;
|
||||||
|
import com.android.launcher3.Launcher;
|
||||||
|
import com.android.launcher3.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A placeholder view for recents
|
* A placeholder view for recents
|
||||||
*/
|
*/
|
||||||
public class RecentsView extends HorizontalScrollView {
|
public class RecentsView extends HorizontalScrollView implements Insettable {
|
||||||
public RecentsView(Context context) {
|
public RecentsView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +41,23 @@ public class RecentsView extends HorizontalScrollView {
|
||||||
public RecentsView(Context context, AttributeSet attrs, int defStyleAttr) {
|
public RecentsView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
setAlpha(0);
|
setAlpha(0);
|
||||||
|
setVisibility(INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setViewVisible(boolean isVisible) { }
|
public void setViewVisible(boolean isVisible) { }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInsets(Rect insets) {
|
||||||
|
MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
|
||||||
|
lp.topMargin = insets.top;
|
||||||
|
lp.bottomMargin = insets.bottom;
|
||||||
|
lp.leftMargin = insets.left;
|
||||||
|
lp.rightMargin = insets.right;
|
||||||
|
|
||||||
|
DeviceProfile dp = Launcher.getLauncher(getContext()).getDeviceProfile();
|
||||||
|
if (!dp.isVerticalBarLayout()) {
|
||||||
|
lp.bottomMargin += dp.hotseatBarSizePx + getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.dynamic_grid_min_page_indicator_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,7 +339,7 @@ public class Launcher extends BaseActivity
|
||||||
|
|
||||||
mDragController = new DragController(this);
|
mDragController = new DragController(this);
|
||||||
mAllAppsController = new AllAppsTransitionController(this);
|
mAllAppsController = new AllAppsTransitionController(this);
|
||||||
mStateManager = new LauncherStateManager(this, mAllAppsController);
|
mStateManager = new LauncherStateManager(this);
|
||||||
|
|
||||||
mAppWidgetManager = AppWidgetManagerCompat.getInstance(this);
|
mAppWidgetManager = AppWidgetManagerCompat.getInstance(this);
|
||||||
|
|
||||||
|
@ -1287,6 +1287,10 @@ public class Launcher extends BaseActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AllAppsTransitionController getAllAppsController() {
|
||||||
|
return mAllAppsController;
|
||||||
|
}
|
||||||
|
|
||||||
public DragLayer getDragLayer() {
|
public DragLayer getDragLayer() {
|
||||||
return mDragLayer;
|
return mDragLayer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,8 @@ public class LauncherState {
|
||||||
|
|
||||||
protected static final int FLAG_SHOW_SCRIM = 1 << 0;
|
protected static final int FLAG_SHOW_SCRIM = 1 << 0;
|
||||||
protected static final int FLAG_MULTI_PAGE = 1 << 1;
|
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 << 2;
|
||||||
protected static final int FLAG_DISABLE_ACCESSIBILITY = 1 << 3;
|
protected static final int FLAG_DO_NOT_RESTORE = 1 << 3;
|
||||||
protected static final int FLAG_DO_NOT_RESTORE = 1 << 4;
|
|
||||||
|
|
||||||
private static final LauncherState[] sAllStates = new LauncherState[4];
|
private static final LauncherState[] sAllStates = new LauncherState[4];
|
||||||
|
|
||||||
|
@ -80,7 +79,6 @@ public class LauncherState {
|
||||||
* @see WorkspaceStateTransitionAnimation
|
* @see WorkspaceStateTransitionAnimation
|
||||||
*/
|
*/
|
||||||
public final boolean hasScrim;
|
public final boolean hasScrim;
|
||||||
public final boolean hideHotseat;
|
|
||||||
public final int transitionDuration;
|
public final int transitionDuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,7 +95,6 @@ public class LauncherState {
|
||||||
|
|
||||||
this.hasScrim = (flags & FLAG_SHOW_SCRIM) != 0;
|
this.hasScrim = (flags & FLAG_SHOW_SCRIM) != 0;
|
||||||
this.hasMultipleVisiblePages = (flags & FLAG_MULTI_PAGE) != 0;
|
this.hasMultipleVisiblePages = (flags & FLAG_MULTI_PAGE) != 0;
|
||||||
this.hideHotseat = (flags & FLAG_HIDE_HOTSEAT) != 0;
|
|
||||||
this.workspaceAccessibilityFlag = (flags & FLAG_DISABLE_ACCESSIBILITY) != 0
|
this.workspaceAccessibilityFlag = (flags & FLAG_DISABLE_ACCESSIBILITY) != 0
|
||||||
? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
|
? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
|
||||||
: IMPORTANT_FOR_ACCESSIBILITY_AUTO;
|
: IMPORTANT_FOR_ACCESSIBILITY_AUTO;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||||
import com.android.launcher3.anim.AnimationLayerSet;
|
import com.android.launcher3.anim.AnimationLayerSet;
|
||||||
import com.android.launcher3.anim.AnimationSuccessListener;
|
import com.android.launcher3.anim.AnimationSuccessListener;
|
||||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||||
|
import com.android.launcher3.uioverrides.UiFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: figure out what kind of tests we can write for this
|
* TODO: figure out what kind of tests we can write for this
|
||||||
|
@ -78,21 +79,26 @@ public class LauncherStateManager {
|
||||||
private final AnimationConfig mConfig = new AnimationConfig();
|
private final AnimationConfig mConfig = new AnimationConfig();
|
||||||
private final Handler mUiHandler;
|
private final Handler mUiHandler;
|
||||||
private final Launcher mLauncher;
|
private final Launcher mLauncher;
|
||||||
private final AllAppsTransitionController mAllAppsController;
|
|
||||||
|
|
||||||
|
private StateHandler[] mStateHandlers;
|
||||||
private LauncherState mState = NORMAL;
|
private LauncherState mState = NORMAL;
|
||||||
|
|
||||||
public LauncherStateManager(
|
public LauncherStateManager(Launcher l) {
|
||||||
Launcher l, AllAppsTransitionController allAppsController) {
|
|
||||||
mUiHandler = new Handler(Looper.getMainLooper());
|
mUiHandler = new Handler(Looper.getMainLooper());
|
||||||
mLauncher = l;
|
mLauncher = l;
|
||||||
mAllAppsController = allAppsController;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LauncherState getState() {
|
public LauncherState getState() {
|
||||||
return mState;
|
return mState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StateHandler[] getStateHandlers() {
|
||||||
|
if (mStateHandlers == null) {
|
||||||
|
mStateHandlers = UiFactory.getStateHandler(mLauncher);
|
||||||
|
}
|
||||||
|
return mStateHandlers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #goToState(LauncherState, boolean, Runnable)
|
* @see #goToState(LauncherState, boolean, Runnable)
|
||||||
*/
|
*/
|
||||||
|
@ -148,8 +154,9 @@ public class LauncherStateManager {
|
||||||
|
|
||||||
if (!animated) {
|
if (!animated) {
|
||||||
setState(state);
|
setState(state);
|
||||||
mAllAppsController.setFinalProgress(state.verticalProgress);
|
for (StateHandler handler : getStateHandlers()) {
|
||||||
mLauncher.getWorkspace().setState(state);
|
handler.setState(state);
|
||||||
|
}
|
||||||
mLauncher.getUserEventDispatcher().resetElapsedContainerMillis();
|
mLauncher.getUserEventDispatcher().resetElapsedContainerMillis();
|
||||||
|
|
||||||
// Run any queued runnable
|
// Run any queued runnable
|
||||||
|
@ -190,14 +197,12 @@ public class LauncherStateManager {
|
||||||
|
|
||||||
protected AnimatorSet createAnimationToNewWorkspaceInternal(final LauncherState state,
|
protected AnimatorSet createAnimationToNewWorkspaceInternal(final LauncherState state,
|
||||||
final Runnable onCompleteRunnable) {
|
final Runnable onCompleteRunnable) {
|
||||||
|
|
||||||
final AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
|
final AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
|
||||||
final AnimationLayerSet layerViews = new AnimationLayerSet();
|
final AnimationLayerSet layerViews = new AnimationLayerSet();
|
||||||
|
|
||||||
mAllAppsController.animateToFinalProgress(state.verticalProgress, animation, mConfig);
|
for (StateHandler handler : getStateHandlers()) {
|
||||||
mLauncher.getWorkspace().setStateWithAnimation(state,
|
handler.setStateWithAnimation(state, layerViews, animation, mConfig);
|
||||||
layerViews, animation, mConfig);
|
}
|
||||||
|
|
||||||
animation.addListener(layerViews);
|
animation.addListener(layerViews);
|
||||||
animation.addListener(new AnimationSuccessListener() {
|
animation.addListener(new AnimationSuccessListener() {
|
||||||
|
|
||||||
|
@ -285,4 +290,18 @@ public class LauncherStateManager {
|
||||||
mCurrentAnimation.addListener(this);
|
mCurrentAnimation.addListener(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface StateHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the UI to {@param state} without any animations
|
||||||
|
*/
|
||||||
|
void setState(LauncherState state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the UI to {@param state} by animating any changes.
|
||||||
|
*/
|
||||||
|
void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
|
||||||
|
AnimatorSet anim, AnimationConfig config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ import java.util.Set;
|
||||||
public class Workspace extends PagedView
|
public class Workspace extends PagedView
|
||||||
implements DropTarget, DragSource, View.OnTouchListener,
|
implements DropTarget, DragSource, View.OnTouchListener,
|
||||||
DragController.DragListener, ViewGroup.OnHierarchyChangeListener,
|
DragController.DragListener, ViewGroup.OnHierarchyChangeListener,
|
||||||
Insettable {
|
Insettable, LauncherStateManager.StateHandler {
|
||||||
private static final String TAG = "Launcher.Workspace";
|
private static final String TAG = "Launcher.Workspace";
|
||||||
|
|
||||||
/** The value that {@link #mTransitionProgress} must be greater than for
|
/** The value that {@link #mTransitionProgress} must be greater than for
|
||||||
|
@ -1558,6 +1558,7 @@ public class Workspace extends PagedView
|
||||||
/**
|
/**
|
||||||
* Sets the current workspace {@link LauncherState} and updates the UI without any animations
|
* Sets the current workspace {@link LauncherState} and updates the UI without any animations
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setState(LauncherState toState) {
|
public void setState(LauncherState toState) {
|
||||||
onStartStateTransition(toState);
|
onStartStateTransition(toState);
|
||||||
mStateTransitionAnimation.setState(toState);
|
mStateTransitionAnimation.setState(toState);
|
||||||
|
@ -1567,6 +1568,7 @@ public class Workspace extends PagedView
|
||||||
/**
|
/**
|
||||||
* Sets the current workspace {@link LauncherState}, then animates the UI
|
* Sets the current workspace {@link LauncherState}, then animates the UI
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
|
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
|
||||||
AnimatorSet anim, AnimationConfig config) {
|
AnimatorSet anim, AnimationConfig config) {
|
||||||
StateTransitionListener listener = new StateTransitionListener(toState);
|
StateTransitionListener listener = new StateTransitionListener(toState);
|
||||||
|
|
|
@ -90,7 +90,7 @@ class AlphaUpdateListener extends AnimatorListenerAdapter implements ValueAnimat
|
||||||
*/
|
*/
|
||||||
public class WorkspaceStateTransitionAnimation {
|
public class WorkspaceStateTransitionAnimation {
|
||||||
|
|
||||||
private static final PropertySetter NO_ANIM_PROPERTY_SETTER = new PropertySetter();
|
public static final PropertySetter NO_ANIM_PROPERTY_SETTER = new PropertySetter();
|
||||||
|
|
||||||
public final int mWorkspaceScrimAlpha;
|
public final int mWorkspaceScrimAlpha;
|
||||||
|
|
||||||
|
@ -141,14 +141,6 @@ public class WorkspaceStateTransitionAnimation {
|
||||||
propertySetter);
|
propertySetter);
|
||||||
}
|
}
|
||||||
|
|
||||||
float finalHotseatAlpha = state.hideHotseat ? 0f : 1f;
|
|
||||||
|
|
||||||
// This is true when transitioning between:
|
|
||||||
// - Overview <-> Workspace
|
|
||||||
propertySetter.setViewAlpha(null, mLauncher.getOverviewPanel(), 1 - finalHotseatAlpha);
|
|
||||||
propertySetter.setViewAlpha(mWorkspace.createHotseatAlphaAnimator(finalHotseatAlpha),
|
|
||||||
mLauncher.getHotseat(), finalHotseatAlpha);
|
|
||||||
|
|
||||||
propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, Interpolators.ZOOM_IN);
|
propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, Interpolators.ZOOM_IN);
|
||||||
propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
|
propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
|
||||||
finalWorkspaceTranslationY, Interpolators.ZOOM_IN);
|
finalWorkspaceTranslationY, Interpolators.ZOOM_IN);
|
||||||
|
@ -176,7 +168,7 @@ public class WorkspaceStateTransitionAnimation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PropertySetter {
|
public static class PropertySetter {
|
||||||
|
|
||||||
public void setViewAlpha(Animator anim, View view, float alpha) {
|
public void setViewAlpha(Animator anim, View view, float alpha) {
|
||||||
if (anim != null) {
|
if (anim != null) {
|
||||||
|
@ -204,13 +196,14 @@ public class WorkspaceStateTransitionAnimation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AnimatedPropertySetter extends PropertySetter {
|
public static class AnimatedPropertySetter extends PropertySetter {
|
||||||
|
|
||||||
private final long mDuration;
|
private final long mDuration;
|
||||||
private final AnimationLayerSet mLayerViews;
|
private final AnimationLayerSet mLayerViews;
|
||||||
private final AnimatorSet mStateAnimator;
|
private final AnimatorSet mStateAnimator;
|
||||||
|
|
||||||
AnimatedPropertySetter(long duration, AnimationLayerSet layerView, AnimatorSet anim) {
|
public AnimatedPropertySetter(
|
||||||
|
long duration, AnimationLayerSet layerView, AnimatorSet anim) {
|
||||||
mDuration = duration;
|
mDuration = duration;
|
||||||
mLayerViews = layerView;
|
mLayerViews = layerView;
|
||||||
mStateAnimator = anim;
|
mStateAnimator = anim;
|
||||||
|
|
|
@ -15,10 +15,12 @@ import android.view.animation.Interpolator;
|
||||||
import com.android.launcher3.Hotseat;
|
import com.android.launcher3.Hotseat;
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.LauncherState;
|
import com.android.launcher3.LauncherState;
|
||||||
|
import com.android.launcher3.LauncherStateManager;
|
||||||
import com.android.launcher3.LauncherStateManager.AnimationConfig;
|
import com.android.launcher3.LauncherStateManager.AnimationConfig;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.Workspace;
|
import com.android.launcher3.Workspace;
|
||||||
|
import com.android.launcher3.anim.AnimationLayerSet;
|
||||||
import com.android.launcher3.anim.AnimationSuccessListener;
|
import com.android.launcher3.anim.AnimationSuccessListener;
|
||||||
import com.android.launcher3.anim.Interpolators;
|
import com.android.launcher3.anim.Interpolators;
|
||||||
import com.android.launcher3.graphics.GradientView;
|
import com.android.launcher3.graphics.GradientView;
|
||||||
|
@ -35,7 +37,8 @@ import com.android.launcher3.util.Themes;
|
||||||
* If release velocity < THRES1, snap according to either top or bottom depending on whether it's
|
* If release velocity < THRES1, snap according to either top or bottom depending on whether it's
|
||||||
* closer to top or closer to the page indicator.
|
* closer to top or closer to the page indicator.
|
||||||
*/
|
*/
|
||||||
public class AllAppsTransitionController implements SearchUiManager.OnScrollRangeChangeListener {
|
public class AllAppsTransitionController
|
||||||
|
implements SearchUiManager.OnScrollRangeChangeListener, LauncherStateManager.StateHandler {
|
||||||
|
|
||||||
private static final Property<AllAppsTransitionController, Float> PROGRESS =
|
private static final Property<AllAppsTransitionController, Float> PROGRESS =
|
||||||
new Property<AllAppsTransitionController, Float>(Float.class, "progress") {
|
new Property<AllAppsTransitionController, Float>(Float.class, "progress") {
|
||||||
|
@ -122,8 +125,8 @@ public class AllAppsTransitionController implements SearchUiManager.OnScrollRang
|
||||||
*
|
*
|
||||||
* @param progress value between 0 and 1, 0 shows all apps and 1 shows workspace
|
* @param progress value between 0 and 1, 0 shows all apps and 1 shows workspace
|
||||||
*
|
*
|
||||||
* @see #setFinalProgress(float)
|
* @see #setState(LauncherState)
|
||||||
* @see #animateToFinalProgress(float, AnimatorSet, AnimationConfig)
|
* @see #setStateWithAnimation(LauncherState, AnimationLayerSet, AnimatorSet, AnimationConfig)
|
||||||
*/
|
*/
|
||||||
public void setProgress(float progress) {
|
public void setProgress(float progress) {
|
||||||
mProgress = progress;
|
mProgress = progress;
|
||||||
|
@ -161,33 +164,32 @@ public class AllAppsTransitionController implements SearchUiManager.OnScrollRang
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the vertical transition progress to {@param progress} and updates all the dependent UI
|
* Sets the vertical transition progress to {@param state} and updates all the dependent UI
|
||||||
* accordingly.
|
* accordingly.
|
||||||
*/
|
*/
|
||||||
public void setFinalProgress(float progress) {
|
@Override
|
||||||
setProgress(progress);
|
public void setState(LauncherState state) {
|
||||||
|
setProgress(state.verticalProgress);
|
||||||
onProgressAnimationEnd();
|
onProgressAnimationEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an animation which updates the vertical transition progress and updates all the
|
* Creates an animation which updates the vertical transition progress and updates all the
|
||||||
* dependent UI using various animation events
|
* dependent UI using various animation events
|
||||||
*
|
|
||||||
* @param progress the final vertical progress at the end of the animation
|
|
||||||
* @param animationOut the target AnimatorSet where this animation should be added
|
|
||||||
* @param outConfig an in/out configuration which can be shared with other animations
|
|
||||||
*/
|
*/
|
||||||
public void animateToFinalProgress(
|
@Override
|
||||||
float progress, AnimatorSet animationOut, AnimationConfig outConfig) {
|
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
|
||||||
if (Float.compare(mProgress, progress) == 0) {
|
AnimatorSet animationOut, AnimationConfig config) {
|
||||||
|
if (Float.compare(mProgress, toState.verticalProgress) == 0) {
|
||||||
// Fail fast
|
// Fail fast
|
||||||
onProgressAnimationEnd();
|
onProgressAnimationEnd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Interpolator interpolator = outConfig.userControlled ? LINEAR : FAST_OUT_SLOW_IN;
|
Interpolator interpolator = config.userControlled ? LINEAR : FAST_OUT_SLOW_IN;
|
||||||
ObjectAnimator anim = ObjectAnimator.ofFloat(this, PROGRESS, mProgress, progress);
|
ObjectAnimator anim = ObjectAnimator.ofFloat(
|
||||||
anim.setDuration(outConfig.duration);
|
this, PROGRESS, mProgress, toState.verticalProgress);
|
||||||
|
anim.setDuration(config.duration);
|
||||||
anim.setInterpolator(interpolator);
|
anim.setInterpolator(interpolator);
|
||||||
anim.addListener(new AnimationSuccessListener() {
|
anim.addListener(new AnimationSuccessListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,12 +15,14 @@
|
||||||
*/
|
*/
|
||||||
package com.android.launcher3.uioverrides;
|
package com.android.launcher3.uioverrides;
|
||||||
|
|
||||||
|
import static com.android.launcher3.WorkspaceStateTransitionAnimation.NO_ANIM_PROPERTY_SETTER;
|
||||||
|
|
||||||
|
import android.animation.AnimatorSet;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
@ -28,14 +30,20 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.launcher3.Insettable;
|
import com.android.launcher3.Insettable;
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
|
import com.android.launcher3.LauncherState;
|
||||||
|
import com.android.launcher3.LauncherStateManager;
|
||||||
|
import com.android.launcher3.LauncherStateManager.AnimationConfig;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
|
import com.android.launcher3.WorkspaceStateTransitionAnimation.AnimatedPropertySetter;
|
||||||
|
import com.android.launcher3.WorkspaceStateTransitionAnimation.PropertySetter;
|
||||||
|
import com.android.launcher3.anim.AnimationLayerSet;
|
||||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
|
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
|
||||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
|
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
|
||||||
import com.android.launcher3.widget.WidgetsFullSheet;
|
import com.android.launcher3.widget.WidgetsFullSheet;
|
||||||
|
|
||||||
public class OverviewPanel extends LinearLayout implements Insettable, View.OnClickListener,
|
public class OverviewPanel extends LinearLayout implements Insettable, View.OnClickListener,
|
||||||
View.OnLongClickListener {
|
View.OnLongClickListener, LauncherStateManager.StateHandler {
|
||||||
|
|
||||||
// Out of 100, the percent of space the overview bar should try and take vertically.
|
// Out of 100, the percent of space the overview bar should try and take vertically.
|
||||||
private static final float OVERVIEW_ICON_ZONE_RATIO = 0.22f;
|
private static final float OVERVIEW_ICON_ZONE_RATIO = 0.22f;
|
||||||
|
@ -154,10 +162,30 @@ public class OverviewPanel extends LinearLayout implements Insettable, View.OnCl
|
||||||
getContext().startActivity(intent, mLauncher.getActivityLaunchOptions(v));
|
getContext().startActivity(intent, mLauncher.getActivityLaunchOptions(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setState(LauncherState state) {
|
||||||
|
setState(state, NO_ANIM_PROPERTY_SETTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStateWithAnimation(LauncherState toState, AnimationLayerSet layerViews,
|
||||||
|
AnimatorSet anim, AnimationConfig config) {
|
||||||
|
setState(toState, new AnimatedPropertySetter(config.duration, layerViews, anim));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setState(LauncherState state, PropertySetter setter) {
|
||||||
|
boolean isOverview = state == LauncherState.OVERVIEW;
|
||||||
|
float finalHotseatAlpha = isOverview ? 0 : 1;
|
||||||
|
|
||||||
|
setter.setViewAlpha(null, this, isOverview ? 1 : 0);
|
||||||
|
setter.setViewAlpha(
|
||||||
|
mLauncher.getWorkspace().createHotseatAlphaAnimator(finalHotseatAlpha),
|
||||||
|
mLauncher.getHotseat(), finalHotseatAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
public static int getButtonBarHeight(Launcher launcher) {
|
public static int getButtonBarHeight(Launcher launcher) {
|
||||||
int zoneHeight = (int) (OVERVIEW_ICON_ZONE_RATIO *
|
int zoneHeight = (int) (OVERVIEW_ICON_ZONE_RATIO *
|
||||||
launcher.getDeviceProfile().availableWidthPx);
|
launcher.getDeviceProfile().availableHeightPx);
|
||||||
Resources res = launcher.getResources();
|
Resources res = launcher.getResources();
|
||||||
int overviewModeMinIconZoneHeightPx =
|
int overviewModeMinIconZoneHeightPx =
|
||||||
res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_min_icon_zone_height);
|
res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_min_icon_zone_height);
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class OverviewState extends LauncherState {
|
||||||
// The percent to shrink the workspace during overview mode
|
// The percent to shrink the workspace during overview mode
|
||||||
public static final float SCALE_FACTOR = 0.7f;
|
public static final float SCALE_FACTOR = 0.7f;
|
||||||
|
|
||||||
private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE | FLAG_HIDE_HOTSEAT;
|
private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE;
|
||||||
|
|
||||||
public OverviewState(int id) {
|
public OverviewState(int id) {
|
||||||
super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, 1f, STATE_FLAGS);
|
super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, 1f, STATE_FLAGS);
|
||||||
|
|
|
@ -19,6 +19,7 @@ package com.android.launcher3.uioverrides;
|
||||||
import android.view.View.AccessibilityDelegate;
|
import android.view.View.AccessibilityDelegate;
|
||||||
|
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
|
import com.android.launcher3.LauncherStateManager.StateHandler;
|
||||||
import com.android.launcher3.VerticalSwipeController;
|
import com.android.launcher3.VerticalSwipeController;
|
||||||
import com.android.launcher3.util.TouchController;
|
import com.android.launcher3.util.TouchController;
|
||||||
|
|
||||||
|
@ -32,4 +33,10 @@ public class UiFactory {
|
||||||
public static AccessibilityDelegate newPageIndicatorAccessibilityDelegate() {
|
public static AccessibilityDelegate newPageIndicatorAccessibilityDelegate() {
|
||||||
return new OverviewAccessibilityDelegate();
|
return new OverviewAccessibilityDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StateHandler[] getStateHandler(Launcher launcher) {
|
||||||
|
return new StateHandler[] {
|
||||||
|
(OverviewPanel) launcher.getOverviewPanel(),
|
||||||
|
launcher.getAllAppsController(), launcher.getWorkspace() };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue