Skip to content

Commit d1d5ab6

Browse files
committed
恢复代码
1 parent ba01f12 commit d1d5ab6

File tree

6 files changed

+89
-71
lines changed

6 files changed

+89
-71
lines changed

src/com/android/launcher3/Launcher.java

+4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
139139
import static com.android.launcher3.LauncherState.NORMAL;
140140
import static com.android.launcher3.LauncherState.OVERVIEW;
141+
import static com.android.launcher3.LauncherState.SPRING_LOADED;
141142
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOAD;
142143
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
143144
import static com.android.launcher3.logging.LoggerUtils.newTarget;
@@ -1623,6 +1624,9 @@ public void onBackPressed() {
16231624
ued.logActionCommand(Action.Command.BACK, mStateManager.getState().containerType,
16241625
lastState.containerType);
16251626
mStateManager.goToState(lastState);
1627+
} else if (isInState(SPRING_LOADED)) {
1628+
XLog.e(XLog.getTag(), XLog.TAG_GU_STATE + "is Normal----");
1629+
mStateManager.goToState(NORMAL);
16261630
} else {
16271631
// Back button is a no-op here, but give at least some feedback for the button press
16281632
mWorkspace.showOutlinesTemporarily();

src/com/android/launcher3/LauncherStateManager.java

+79-65
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@
1616

1717
package com.android.launcher3;
1818

19-
import static android.view.View.VISIBLE;
20-
import static com.android.launcher3.LauncherState.NORMAL;
21-
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE;
22-
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
23-
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_FADE;
24-
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_SCALE;
25-
import static com.android.launcher3.anim.Interpolators.ACCEL;
26-
import static com.android.launcher3.anim.Interpolators.DEACCEL;
27-
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
28-
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
29-
import static com.android.launcher3.anim.Interpolators.clampToProgress;
30-
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
31-
3219
import android.animation.Animator;
3320
import android.animation.AnimatorListenerAdapter;
3421
import android.animation.AnimatorSet;
@@ -42,51 +29,65 @@
4229
import com.android.launcher3.anim.PropertySetter;
4330
import com.android.launcher3.anim.PropertySetter.AnimatedPropertySetter;
4431
import com.android.launcher3.uioverrides.UiFactory;
32+
import com.android.mxlibrary.util.XLog;
4533

4634
import java.lang.annotation.Retention;
4735
import java.lang.annotation.RetentionPolicy;
4836
import java.util.ArrayList;
4937

38+
import static android.view.View.VISIBLE;
39+
import static com.android.launcher3.LauncherState.NORMAL;
40+
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE;
41+
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
42+
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_FADE;
43+
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_SCALE;
44+
import static com.android.launcher3.anim.Interpolators.ACCEL;
45+
import static com.android.launcher3.anim.Interpolators.DEACCEL;
46+
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
47+
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
48+
import static com.android.launcher3.anim.Interpolators.clampToProgress;
49+
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
50+
5051
/**
5152
* TODO: figure out what kind of tests we can write for this
52-
*
53+
* <p>
5354
* Things to test when changing the following class.
54-
* - Home from workspace
55-
* - from center screen
56-
* - from other screens
57-
* - Home from all apps
58-
* - from center screen
59-
* - from other screens
60-
* - Back from all apps
61-
* - from center screen
62-
* - from other screens
63-
* - Launch app from workspace and quit
64-
* - with back
65-
* - with home
66-
* - Launch app from all apps and quit
67-
* - with back
68-
* - with home
69-
* - Go to a screen that's not the default, then all
70-
* apps, and launch and app, and go back
71-
* - with back
72-
* -with home
73-
* - On workspace, long press power and go back
74-
* - with back
75-
* - with home
76-
* - On all apps, long press power and go back
77-
* - with back
78-
* - with home
79-
* - On workspace, power off
80-
* - On all apps, power off
81-
* - Launch an app and turn off the screen while in that app
82-
* - Go back with home key
83-
* - Go back with back key TODO: make this not go to workspace
84-
* - From all apps
85-
* - From workspace
86-
* - Enter and exit car mode (becase it causes an extra configuration changed)
87-
* - From all apps
88-
* - From the center workspace
89-
* - From another workspace
55+
* - Home from workspace
56+
* - from center screen
57+
* - from other screens
58+
* - Home from all apps
59+
* - from center screen
60+
* - from other screens
61+
* - Back from all apps
62+
* - from center screen
63+
* - from other screens
64+
* - Launch app from workspace and quit
65+
* - with back
66+
* - with home
67+
* - Launch app from all apps and quit
68+
* - with back
69+
* - with home
70+
* - Go to a screen that's not the default, then all
71+
* apps, and launch and app, and go back
72+
* - with back
73+
* -with home
74+
* - On workspace, long press power and go back
75+
* - with back
76+
* - with home
77+
* - On all apps, long press power and go back
78+
* - with back
79+
* - with home
80+
* - On workspace, power off
81+
* - On all apps, power off
82+
* - Launch an app and turn off the screen while in that app
83+
* - Go back with home key
84+
* - Go back with back key TODO: make this not go to workspace
85+
* - From all apps
86+
* - From workspace
87+
* - Enter and exit car mode (becase it causes an extra configuration changed)
88+
* - From all apps
89+
* - From the center workspace
90+
* - From another workspace
9091
*/
9192
public class LauncherStateManager {
9293

@@ -101,7 +102,9 @@ public class LauncherStateManager {
101102
ATOMIC_COMPONENT
102103
})
103104
@Retention(RetentionPolicy.SOURCE)
104-
public @interface AnimationComponents {}
105+
public @interface AnimationComponents {
106+
}
107+
105108
public static final int NON_ATOMIC_COMPONENT = 1 << 0;
106109
public static final int ATOMIC_COMPONENT = 1 << 1;
107110

@@ -113,10 +116,10 @@ public class LauncherStateManager {
113116
private final ArrayList<StateListener> mListeners = new ArrayList<>();
114117

115118
private StateHandler[] mStateHandlers;
116-
private LauncherState mState = NORMAL;
119+
private LauncherState mState = LauncherState.NORMAL;
117120

118-
private LauncherState mLastStableState = NORMAL;
119-
private LauncherState mCurrentStableState = NORMAL;
121+
private LauncherState mLastStableState = LauncherState.NORMAL;
122+
private LauncherState mCurrentStableState = LauncherState.NORMAL;
120123

121124
private LauncherState mRestState;
122125

@@ -162,8 +165,7 @@ public void goToState(LauncherState state, boolean animated) {
162165
* Changes the Launcher state to the provided state.
163166
*
164167
* @param animated false if the state should change immediately without any animation,
165-
* true otherwise
166-
* @paras onCompleteRunnable any action to perform at the end of the transition, of null.
168+
* true otherwise
167169
*/
168170
public void goToState(LauncherState state, boolean animated, Runnable onCompleteRunnable) {
169171
goToState(state, animated, 0, onCompleteRunnable);
@@ -198,8 +200,17 @@ public void reapplyState(boolean cancelCurrentAnimation) {
198200
}
199201
}
200202

203+
/**
204+
* 切换状态动画控制
205+
*
206+
* @param state 目标状态
207+
* @param animated 是否显示动画(长按拖拽进入拖拽模式为true)
208+
* @param delay 延迟时间
209+
* @param onCompleteRunnable 状态完成回调
210+
*/
201211
private void goToState(LauncherState state, boolean animated, long delay,
202-
final Runnable onCompleteRunnable) {
212+
final Runnable onCompleteRunnable) {
213+
XLog.e(XLog.getTag(),XLog.TAG_GU_STATE +" state.containerType= "+ state.containerType + " , animated= " + animated + " , delay= " + delay);
203214
if (mLauncher.isInState(state)) {
204215
if (mConfig.mCurrentAnimation == null) {
205216
// Run any queued runnable
@@ -265,7 +276,7 @@ public void onAnimationSuccess(Animator animator) {
265276
* - MxSettings some start values (e.g. scale) for views that are hidden but about to be shown.
266277
*/
267278
public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toState,
268-
AnimatorSetBuilder builder) {
279+
AnimatorSetBuilder builder) {
269280
if (fromState == NORMAL && toState.overviewUi) {
270281
builder.setInterpolator(ANIM_WORKSPACE_SCALE, OVERSHOOT_1_2);
271282
builder.setInterpolator(ANIM_WORKSPACE_FADE, OVERSHOOT_1_2);
@@ -299,9 +310,10 @@ public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toS
299310
/**
300311
* Creates a {@link AnimatorPlaybackController} that can be used for a controlled
301312
* state transition.
302-
* @param state the final state for the transition.
313+
*
314+
* @param state the final state for the transition.
303315
* @param duration intended duration for normal playback. Use higher duration for better
304-
* accuracy.
316+
* accuracy.
305317
*/
306318
public AnimatorPlaybackController createAnimationToNewWorkspace(
307319
LauncherState state, long duration) {
@@ -315,8 +327,8 @@ public AnimatorPlaybackController createAnimationToNewWorkspace(
315327
}
316328

317329
public AnimatorPlaybackController createAnimationToNewWorkspace(LauncherState state,
318-
AnimatorSetBuilder builder, long duration, Runnable onCancelRunnable,
319-
@AnimationComponents int animComponents) {
330+
AnimatorSetBuilder builder, long duration, Runnable onCancelRunnable,
331+
@AnimationComponents int animComponents) {
320332
mConfig.reset();
321333
mConfig.userControlled = true;
322334
mConfig.animComponents = animComponents;
@@ -328,7 +340,7 @@ public AnimatorPlaybackController createAnimationToNewWorkspace(LauncherState st
328340
}
329341

330342
protected AnimatorSet createAnimationToNewWorkspaceInternal(final LauncherState state,
331-
AnimatorSetBuilder builder, final Runnable onCompleteRunnable) {
343+
AnimatorSetBuilder builder, final Runnable onCompleteRunnable) {
332344

333345
for (StateHandler handler : getStateHandlers()) {
334346
builder.startTag(handler);
@@ -500,7 +512,8 @@ public static class AnimationConfig extends AnimatorListenerAdapter {
500512
public long duration;
501513
public boolean userControlled;
502514
public AnimatorPlaybackController playbackController;
503-
public @AnimationComponents int animComponents = ANIM_ALL;
515+
public @AnimationComponents
516+
int animComponents = ANIM_ALL;
504517
private PropertySetter mPropertySetter;
505518

506519
private AnimatorSet mCurrentAnimation;
@@ -569,7 +582,7 @@ public interface StateHandler {
569582
* Sets the UI to {@param state} by animating any changes.
570583
*/
571584
void setStateWithAnimation(LauncherState toState,
572-
AnimatorSetBuilder builder, AnimationConfig config);
585+
AnimatorSetBuilder builder, AnimationConfig config);
573586
}
574587

575588
public interface StateListener {
@@ -580,6 +593,7 @@ public interface StateListener {
580593
void onStateSetImmediately(LauncherState state);
581594

582595
void onStateTransitionStart(LauncherState toState);
596+
583597
void onStateTransitionComplete(LauncherState finalState);
584598
}
585599
}

src/com/android/launcher3/menu/CircleMenuView.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ public void close(boolean animate) {
653653

654654
@Override
655655
public void setInsets(Rect insets) {
656-
LayoutParams lp = (LayoutParams) getLayoutParams();
656+
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
657657
DeviceProfile grid = mLauncher.getDeviceProfile();
658658
// TODO 设置宽高
659659

src/com/android/launcher3/menu/MenuLayout.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void fillInLogContainerData(View v, ItemInfo info, LauncherLogProto.Targe
5252

5353
@Override
5454
public void setInsets(Rect insets) {
55-
LayoutParams lp = (LayoutParams) getLayoutParams();
55+
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
5656
DeviceProfile grid = mLauncher.getDeviceProfile();
5757
lp.gravity = Gravity.BOTTOM;
5858
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;

src/com/android/launcher3/model/BaseModelUpdateTask.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
import com.android.launcher3.util.GridOccupancy;
3737
import com.android.launcher3.util.ItemInfoMatcher;
3838
import com.android.launcher3.util.MultiHashMap;
39-
import com.android.launcher3.widget.WidgetListRowEntry;
4039
import com.android.mxlibrary.util.XLog;
40+
import com.android.launcher3.widget.WidgetListRowEntry;
4141

4242
import java.util.ArrayList;
4343
import java.util.List;

src/com/android/launcher3/touch/AbstractStateChangeTouchController.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
import com.android.launcher3.util.TouchController;
4141

4242
import static com.android.launcher3.LauncherAnimUtils.MIN_PROGRESS_TO_MENU;
43-
import static com.android.launcher3.LauncherState.EDITING;
4443
import static com.android.launcher3.LauncherState.MENU;
4544
import static com.android.launcher3.LauncherState.NORMAL;
4645
import static com.android.launcher3.LauncherState.OVERVIEW;
46+
import static com.android.launcher3.LauncherState.OVERVIEW_SPRING_LOADED;
4747
import static com.android.launcher3.LauncherStateManager.ANIM_ALL;
4848
import static com.android.launcher3.LauncherStateManager.ATOMIC_COMPONENT;
4949
import static com.android.launcher3.LauncherStateManager.NON_ATOMIC_COMPONENT;
@@ -233,8 +233,8 @@ public void onDragStart(boolean start) {
233233
mStartContainerType = getLogContainerTypeForNormalState();
234234
} else if (mStartState == OVERVIEW) {
235235
mStartContainerType = LauncherLogProto.ContainerType.TASKSWITCHER;
236-
} else if (mStartState == EDITING) {
237-
mStartContainerType = LauncherLogProto.ContainerType.EDITING;
236+
} else if (mStartState == OVERVIEW_SPRING_LOADED) {
237+
mStartContainerType = LauncherLogProto.ContainerType.OVERVIEW_SPRING_LOADED;
238238
}
239239
if (mCurrentAnimation == null) {
240240
mFromState = mStartState;

0 commit comments

Comments
 (0)