Merge "Removing back-button alpha animation code" into tm-qpr-dev
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.statehandlers;
|
||||
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.util.NavigationMode.TWO_BUTTONS;
|
||||
import static com.android.quickstep.AnimatedFloat.VALUE;
|
||||
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.statemanager.StateManager.StateHandler;
|
||||
import com.android.launcher3.states.StateAnimationConfig;
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.UiThreadHelper;
|
||||
import com.android.quickstep.AnimatedFloat;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
|
||||
/**
|
||||
* State handler for animating back button alpha in two-button nav mode.
|
||||
*/
|
||||
public class BackButtonAlphaHandler implements StateHandler<LauncherState> {
|
||||
|
||||
private final QuickstepLauncher mLauncher;
|
||||
private final AnimatedFloat mBackAlpha = new AnimatedFloat(this::updateBackAlpha);
|
||||
|
||||
public BackButtonAlphaHandler(QuickstepLauncher launcher) {
|
||||
mLauncher = launcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(LauncherState state) { }
|
||||
|
||||
@Override
|
||||
public void setStateWithAnimation(LauncherState toState, StateAnimationConfig config,
|
||||
PendingAnimation animation) {
|
||||
if (DisplayController.getNavigationMode(mLauncher) != TWO_BUTTONS) {
|
||||
return;
|
||||
}
|
||||
|
||||
mBackAlpha.value = SystemUiProxy.INSTANCE.get(mLauncher).getLastNavButtonAlpha();
|
||||
animation.setFloat(mBackAlpha, VALUE,
|
||||
mLauncher.shouldBackButtonBeHidden(toState) ? 0 : 1, LINEAR);
|
||||
}
|
||||
|
||||
private void updateBackAlpha() {
|
||||
UiThreadHelper.setBackButtonAlphaAsync(mLauncher,
|
||||
QuickstepLauncher.SET_BACK_BUTTON_ALPHA, mBackAlpha.value, false /* animate */);
|
||||
}
|
||||
}
|
||||
@@ -17,14 +17,11 @@ package com.android.launcher3.uioverrides;
|
||||
|
||||
import static android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED;
|
||||
|
||||
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
|
||||
import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_BACK_BUTTON;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.FLAG_HIDE_BACK_BUTTON;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.NO_OFFSET;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
@@ -47,7 +44,6 @@ import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
|
||||
import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
import static com.android.launcher3.util.NavigationMode.TWO_BUTTONS;
|
||||
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
@@ -72,7 +68,6 @@ import android.window.SplashScreen;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
@@ -96,7 +91,6 @@ import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.popup.SystemShortcut;
|
||||
import com.android.launcher3.proxy.ProxyActivityStarter;
|
||||
import com.android.launcher3.proxy.StartActivityParams;
|
||||
import com.android.launcher3.statehandlers.BackButtonAlphaHandler;
|
||||
import com.android.launcher3.statehandlers.DepthController;
|
||||
import com.android.launcher3.statemanager.StateManager.AtomicAnimationFactory;
|
||||
import com.android.launcher3.statemanager.StateManager.StateHandler;
|
||||
@@ -171,12 +165,6 @@ public class QuickstepLauncher extends Launcher {
|
||||
*/
|
||||
public static final AsyncCommand SET_SHELF_HEIGHT = (context, arg1, arg2) ->
|
||||
SystemUiProxy.INSTANCE.get(context).setShelfHeight(arg1 != 0, arg2);
|
||||
/**
|
||||
* Reusable command for applying the back button alpha on the background thread.
|
||||
*/
|
||||
public static final AsyncCommand SET_BACK_BUTTON_ALPHA =
|
||||
(context, arg1, arg2) -> SystemUiProxy.INSTANCE.get(context).setNavBarButtonAlpha(
|
||||
Float.intBitsToFloat(arg1), arg2 != 0);
|
||||
|
||||
private FixedContainerItems mAllAppsPredictions;
|
||||
private HotseatPredictionController mHotseatPredictionController;
|
||||
@@ -299,11 +287,6 @@ public class QuickstepLauncher extends Launcher {
|
||||
|
||||
@Override
|
||||
protected void onActivityFlagsChanged(int changeBits) {
|
||||
if ((changeBits
|
||||
& (ACTIVITY_STATE_WINDOW_FOCUSED | ACTIVITY_STATE_TRANSITION_ACTIVE)) != 0) {
|
||||
onLauncherStateOrFocusChanged();
|
||||
}
|
||||
|
||||
if ((changeBits & ACTIVITY_STATE_STARTED) != 0) {
|
||||
mDepthController.setActivityStarted(isStarted());
|
||||
}
|
||||
@@ -729,7 +712,6 @@ public class QuickstepLauncher extends Launcher {
|
||||
super.collectStateHandlers(out);
|
||||
out.add(getDepthController());
|
||||
out.add(new RecentsViewStateController(this));
|
||||
out.add(new BackButtonAlphaHandler(this));
|
||||
}
|
||||
|
||||
public DepthController getDepthController() {
|
||||
@@ -787,39 +769,6 @@ public class QuickstepLauncher extends Launcher {
|
||||
? new float[] {1, 1} : new float[] {1.1f, NO_OFFSET};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDragLayerHierarchyChanged() {
|
||||
onLauncherStateOrFocusChanged();
|
||||
}
|
||||
|
||||
public boolean shouldBackButtonBeHidden(LauncherState toState) {
|
||||
NavigationMode mode = DisplayController.getNavigationMode(this);
|
||||
boolean shouldBackButtonBeHidden = mode.hasGestures
|
||||
&& toState.hasFlag(FLAG_HIDE_BACK_BUTTON)
|
||||
&& hasWindowFocus()
|
||||
&& (getActivityFlags() & ACTIVITY_STATE_TRANSITION_ACTIVE) == 0;
|
||||
if (shouldBackButtonBeHidden) {
|
||||
// Show the back button if there is a floating view visible.
|
||||
shouldBackButtonBeHidden = AbstractFloatingView.getTopOpenViewWithType(this,
|
||||
TYPE_ALL & ~TYPE_HIDE_BACK_BUTTON) == null;
|
||||
}
|
||||
return shouldBackButtonBeHidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the back button visibility based on the current state/window focus.
|
||||
*/
|
||||
private void onLauncherStateOrFocusChanged() {
|
||||
boolean shouldBackButtonBeHidden = shouldBackButtonBeHidden(getStateManager().getState());
|
||||
if (DisplayController.getNavigationMode(this) == TWO_BUTTONS) {
|
||||
UiThreadHelper.setBackButtonAlphaAsync(this, SET_BACK_BUTTON_ALPHA,
|
||||
shouldBackButtonBeHidden ? 0f : 1f, true /* animate */);
|
||||
}
|
||||
if (getDragLayer() != null) {
|
||||
getRootView().setDisallowBackGesture(shouldBackButtonBeHidden);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishBindingItems(IntSet pagesBoundFirst) {
|
||||
super.finishBindingItems(pagesBoundFirst);
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.android.quickstep;
|
||||
|
||||
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
|
||||
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
@@ -43,8 +42,6 @@ import android.view.RemoteAnimationTarget;
|
||||
import android.view.SurfaceControl;
|
||||
import android.window.IOnBackInvokedCallback;
|
||||
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions;
|
||||
import com.android.systemui.shared.recents.ISystemUiProxy;
|
||||
@@ -72,7 +69,7 @@ import java.util.Arrays;
|
||||
/**
|
||||
* Holds the reference to SystemUI.
|
||||
*/
|
||||
public class SystemUiProxy implements ISystemUiProxy, DisplayController.DisplayInfoChangeListener {
|
||||
public class SystemUiProxy implements ISystemUiProxy {
|
||||
private static final String TAG = SystemUiProxy.class.getSimpleName();
|
||||
|
||||
public static final MainThreadInitializedObject<SystemUiProxy> INSTANCE =
|
||||
@@ -106,28 +103,15 @@ public class SystemUiProxy implements ISystemUiProxy, DisplayController.DisplayI
|
||||
// Used to dedupe calls to SystemUI
|
||||
private int mLastShelfHeight;
|
||||
private boolean mLastShelfVisible;
|
||||
private float mLastNavButtonAlpha;
|
||||
private boolean mLastNavButtonAnimate;
|
||||
private boolean mHasNavButtonAlphaBeenSet = false;
|
||||
private Runnable mPendingSetNavButtonAlpha = null;
|
||||
private Context mContext;
|
||||
|
||||
// TODO(141886704): Find a way to remove this
|
||||
private int mLastSystemUiStateFlags;
|
||||
|
||||
public SystemUiProxy(Context context) {
|
||||
DisplayController.INSTANCE.get(context).addChangeListener(this);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayInfoChanged(Context context, Info info, int flags) {
|
||||
if ((flags & CHANGE_NAVIGATION_MODE) != 0) {
|
||||
// Whenever the nav mode changes, force reset the nav button alpha
|
||||
setNavBarButtonAlpha(1f, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (mSystemUiProxy != null) {
|
||||
@@ -205,11 +189,6 @@ public class SystemUiProxy implements ISystemUiProxy, DisplayController.DisplayI
|
||||
if (mBackAnimation != null && mBackToLauncherCallback != null) {
|
||||
setBackToLauncherCallback(mBackToLauncherCallback);
|
||||
}
|
||||
|
||||
if (mPendingSetNavButtonAlpha != null) {
|
||||
mPendingSetNavButtonAlpha.run();
|
||||
mPendingSetNavButtonAlpha = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void clearProxy() {
|
||||
@@ -272,31 +251,6 @@ public class SystemUiProxy implements ISystemUiProxy, DisplayController.DisplayI
|
||||
}
|
||||
}
|
||||
|
||||
public float getLastNavButtonAlpha() {
|
||||
return mLastNavButtonAlpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNavBarButtonAlpha(float alpha, boolean animate) {
|
||||
boolean changed = Float.compare(alpha, mLastNavButtonAlpha) != 0
|
||||
|| animate != mLastNavButtonAnimate
|
||||
|| !mHasNavButtonAlphaBeenSet;
|
||||
if (changed) {
|
||||
if (mSystemUiProxy == null) {
|
||||
mPendingSetNavButtonAlpha = () -> setNavBarButtonAlpha(alpha, animate);
|
||||
} else {
|
||||
mLastNavButtonAlpha = alpha;
|
||||
mLastNavButtonAnimate = animate;
|
||||
mHasNavButtonAlphaBeenSet = true;
|
||||
try {
|
||||
mSystemUiProxy.setNavBarButtonAlpha(alpha, animate);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed call setNavBarButtonAlpha", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusBarMotionEvent(MotionEvent event) {
|
||||
if (mSystemUiProxy != null) {
|
||||
@@ -895,8 +849,7 @@ public class SystemUiProxy implements ISystemUiProxy, DisplayController.DisplayI
|
||||
if (mRecentTasks != null
|
||||
&& mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PC)) {
|
||||
try {
|
||||
return new ArrayList<ActivityManager.RunningTaskInfo>(
|
||||
Arrays.asList(mRecentTasks.getRunningTasks(numTasks)));
|
||||
return new ArrayList<>(Arrays.asList(mRecentTasks.getRunningTasks(numTasks)));
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed call getRunningTasks", e);
|
||||
}
|
||||
|
||||
@@ -109,10 +109,6 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
|
||||
| TYPE_ALL_APPS_EDU | TYPE_ICON_SURFACE | TYPE_WIDGETS_EDUCATION_DIALOG
|
||||
| TYPE_TASKBAR_EDUCATION_DIALOG | TYPE_TASKBAR_ALL_APPS | TYPE_OPTIONS_POPUP_DIALOG;
|
||||
|
||||
// Usually we show the back button when a floating view is open. Instead, hide for these types.
|
||||
public static final int TYPE_HIDE_BACK_BUTTON = TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE
|
||||
| TYPE_SNACKBAR | TYPE_WIDGET_RESIZE_FRAME | TYPE_LISTENER;
|
||||
|
||||
public static final int TYPE_ACCESSIBLE = TYPE_ALL & ~TYPE_DISCOVERY_BOUNCE & ~TYPE_LISTENER
|
||||
& ~TYPE_ALL_APPS_EDU;
|
||||
|
||||
|
||||
@@ -1122,6 +1122,7 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
.log(getAllAppsEntryEvent().get());
|
||||
}
|
||||
}
|
||||
updateDisallowBack();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3122,7 +3123,18 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
|
||||
public void useFadeOutAnimationForLauncherStart(CancellationSignal signal) { }
|
||||
|
||||
public void onDragLayerHierarchyChanged() { }
|
||||
public void onDragLayerHierarchyChanged() {
|
||||
updateDisallowBack();
|
||||
}
|
||||
|
||||
private void updateDisallowBack() {
|
||||
LauncherRootView rv = getRootView();
|
||||
if (rv != null) {
|
||||
boolean disableBack = getStateManager().getState() == NORMAL
|
||||
&& AbstractFloatingView.getTopOpenView(this) == null;
|
||||
rv.setDisallowBackGesture(disableBack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void returnToHomescreen() {
|
||||
|
||||
@@ -71,17 +71,14 @@ public abstract class LauncherState implements BaseState<LauncherState> {
|
||||
public static final int FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED = BaseState.getFlag(2);
|
||||
// Flag to indicate that workspace should draw page background
|
||||
public static final int FLAG_WORKSPACE_HAS_BACKGROUNDS = BaseState.getFlag(3);
|
||||
// True if the back button should be hidden when in this state (assuming no floating views are
|
||||
// open, launcher has window focus, etc).
|
||||
public static final int FLAG_HIDE_BACK_BUTTON = BaseState.getFlag(4);
|
||||
// Flag to indicate if the state would have scrim over sysui region: statu sbar and nav bar
|
||||
public static final int FLAG_HAS_SYS_UI_SCRIM = BaseState.getFlag(5);
|
||||
public static final int FLAG_HAS_SYS_UI_SCRIM = BaseState.getFlag(4);
|
||||
// Flag to inticate that all popups should be closed when this state is enabled.
|
||||
public static final int FLAG_CLOSE_POPUPS = BaseState.getFlag(6);
|
||||
public static final int FLAG_OVERVIEW_UI = BaseState.getFlag(7);
|
||||
public static final int FLAG_CLOSE_POPUPS = BaseState.getFlag(5);
|
||||
public static final int FLAG_OVERVIEW_UI = BaseState.getFlag(6);
|
||||
|
||||
// Flag indicating that hotseat and its contents are not accessible.
|
||||
public static final int FLAG_HOTSEAT_INACCESSIBLE = BaseState.getFlag(8);
|
||||
public static final int FLAG_HOTSEAT_INACCESSIBLE = BaseState.getFlag(7);
|
||||
|
||||
|
||||
public static final float NO_OFFSET = 0;
|
||||
@@ -110,8 +107,7 @@ public abstract class LauncherState implements BaseState<LauncherState> {
|
||||
*/
|
||||
public static final LauncherState NORMAL = new LauncherState(NORMAL_STATE_ORDINAL,
|
||||
LAUNCHER_STATE_HOME,
|
||||
FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HIDE_BACK_BUTTON |
|
||||
FLAG_HAS_SYS_UI_SCRIM) {
|
||||
FLAG_DISABLE_RESTORE | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_HAS_SYS_UI_SCRIM) {
|
||||
@Override
|
||||
public int getTransitionDuration(Context context, boolean isToState) {
|
||||
// Arbitrary duration, when going to NORMAL we use the state we're coming from instead.
|
||||
|
||||
@@ -31,8 +31,7 @@ public class SpringLoadedState extends LauncherState {
|
||||
|
||||
private static final int STATE_FLAGS = FLAG_MULTI_PAGE
|
||||
| FLAG_WORKSPACE_INACCESSIBLE | FLAG_DISABLE_RESTORE
|
||||
| FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_WORKSPACE_HAS_BACKGROUNDS
|
||||
| FLAG_HIDE_BACK_BUTTON;
|
||||
| FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED | FLAG_WORKSPACE_HAS_BACKGROUNDS;
|
||||
|
||||
public SpringLoadedState(int id) {
|
||||
super(id, LAUNCHER_STATE_HOME, STATE_FLAGS);
|
||||
|
||||
@@ -39,11 +39,6 @@ public class UiThreadHelper {
|
||||
.sendToTarget();
|
||||
}
|
||||
|
||||
public static void setBackButtonAlphaAsync(Context context, AsyncCommand command, float alpha,
|
||||
boolean animate) {
|
||||
runAsyncCommand(context, command, Float.floatToIntBits(alpha), animate ? 1 : 0);
|
||||
}
|
||||
|
||||
public static void runAsyncCommand(Context context, AsyncCommand command, int arg1, int arg2) {
|
||||
Message.obtain(HANDLER.get(context), MSG_RUN_COMMAND, arg1, arg2, command).sendToTarget();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user