Merge "Fix taskbar layout issues in setup wizard" into sc-v2-dev am: e202a64e56
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/16061630 Change-Id: Ib1fe910bbd5d82a5002e345ba9bbfad0e7d02176
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.launcher3.taskbar;
|
||||
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
|
||||
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
|
||||
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
|
||||
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_IN_APP_SETUP;
|
||||
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
|
||||
|
||||
import android.animation.Animator;
|
||||
@@ -128,7 +129,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
mLauncher.setTaskbarUIController(this);
|
||||
mKeyguardController = taskbarControllers.taskbarKeyguardController;
|
||||
|
||||
onLauncherResumedOrPaused(mLauncher.hasBeenResumed());
|
||||
onLauncherResumedOrPaused(mLauncher.hasBeenResumed(), true /* fromInit */);
|
||||
mIconAlignmentForResumedState.finishAnimation();
|
||||
onIconAlignmentRatioChanged();
|
||||
|
||||
@@ -170,6 +171,10 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
* Should be called from onResume() and onPause(), and animates the Taskbar accordingly.
|
||||
*/
|
||||
public void onLauncherResumedOrPaused(boolean isResumed) {
|
||||
onLauncherResumedOrPaused(isResumed, false /* fromInit */);
|
||||
}
|
||||
|
||||
private void onLauncherResumedOrPaused(boolean isResumed, boolean fromInit) {
|
||||
if (mKeyguardController.isScreenOff()) {
|
||||
if (!isResumed) {
|
||||
return;
|
||||
@@ -180,6 +185,11 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
}
|
||||
|
||||
long duration = QuickstepTransitionManager.CONTENT_ALPHA_DURATION;
|
||||
if (fromInit) {
|
||||
// Since we are creating the starting state, we don't have a state to animate from, so
|
||||
// set our state immediately.
|
||||
duration = 0;
|
||||
}
|
||||
ObjectAnimator anim = mIconAlignmentForResumedState.animateToValue(
|
||||
getCurrentIconAlignmentRatio(), isResumed ? 1 : 0)
|
||||
.setDuration(duration);
|
||||
@@ -191,6 +201,10 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
|
||||
TaskbarStashController stashController = mControllers.taskbarStashController;
|
||||
stashController.updateStateForFlag(FLAG_IN_APP, !isResumed);
|
||||
if (isResumed) {
|
||||
// Launcher is resumed, meaning setup must be finished.
|
||||
stashController.updateStateForFlag(FLAG_STASHED_IN_APP_SETUP, false);
|
||||
}
|
||||
stashController.applyState(duration);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,12 +36,14 @@ import android.animation.ObjectAnimator;
|
||||
import android.annotation.DrawableRes;
|
||||
import android.annotation.IdRes;
|
||||
import android.annotation.LayoutRes;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.graphics.Region.Op;
|
||||
import android.graphics.drawable.AnimatedVectorDrawable;
|
||||
import android.provider.Settings;
|
||||
import android.util.Property;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnHoverListener;
|
||||
@@ -58,6 +60,7 @@ import com.android.launcher3.taskbar.contextual.RotationButton;
|
||||
import com.android.launcher3.taskbar.contextual.RotationButtonController;
|
||||
import com.android.launcher3.util.MultiValueAlpha;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.quickstep.AnimatedFloat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -148,12 +151,33 @@ public class NavbarButtonsViewController {
|
||||
flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0, AnimatedFloat.VALUE, 1, 0));
|
||||
|
||||
// Force nav buttons (specifically back button) to be visible during setup wizard.
|
||||
boolean areButtonsForcedVisible = !SettingsCache.INSTANCE.get(mContext).getValue(
|
||||
boolean isInSetup = !SettingsCache.INSTANCE.get(mContext).getValue(
|
||||
Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0);
|
||||
if (isThreeButtonNav || areButtonsForcedVisible) {
|
||||
if (isThreeButtonNav || isInSetup) {
|
||||
initButtons(mNavButtonContainer, mEndContextualContainer,
|
||||
mControllers.navButtonController);
|
||||
|
||||
if (isInSetup) {
|
||||
// Since setup wizard only has back button enabled, it looks strange to be
|
||||
// end-aligned, so start-align instead.
|
||||
FrameLayout.LayoutParams navButtonsLayoutParams = (FrameLayout.LayoutParams)
|
||||
mNavButtonContainer.getLayoutParams();
|
||||
navButtonsLayoutParams.setMarginStart(navButtonsLayoutParams.getMarginEnd());
|
||||
navButtonsLayoutParams.setMarginEnd(0);
|
||||
navButtonsLayoutParams.gravity = Gravity.START;
|
||||
mNavButtonContainer.requestLayout();
|
||||
|
||||
if (!isThreeButtonNav) {
|
||||
// Tint all the nav buttons since there's no taskbar background in SUW.
|
||||
for (int i = 0; i < mNavButtonContainer.getChildCount(); i++) {
|
||||
if (!(mNavButtonContainer.getChildAt(i) instanceof ImageView)) continue;
|
||||
ImageView button = (ImageView) mNavButtonContainer.getChildAt(i);
|
||||
button.setImageTintList(ColorStateList.valueOf(Themes.getAttrColor(
|
||||
button.getContext(), android.R.attr.textColorPrimary)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Animate taskbar background when IME shows
|
||||
mPropertyHolders.add(new StatePropertyHolder(
|
||||
mControllers.taskbarDragLayerController.getNavbarBackgroundAlpha(),
|
||||
@@ -286,6 +310,13 @@ public class NavbarButtonsViewController {
|
||||
return (mState & FLAG_IME_VISIBLE) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the home button is disabled
|
||||
*/
|
||||
public boolean isHomeDisabled() {
|
||||
return (mState & FLAG_DISABLE_HOME) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the recents (overview) button is disabled
|
||||
*/
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.RevealOutlineAnimation;
|
||||
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
|
||||
import com.android.launcher3.util.Executors;
|
||||
import com.android.launcher3.util.MultiValueAlpha;
|
||||
import com.android.quickstep.AnimatedFloat;
|
||||
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
|
||||
|
||||
@@ -38,6 +39,10 @@ import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
|
||||
*/
|
||||
public class StashedHandleViewController {
|
||||
|
||||
public static final int ALPHA_INDEX_STASHED = 0;
|
||||
public static final int ALPHA_INDEX_HOME_DISABLED = 1;
|
||||
private static final int NUM_ALPHA_CHANNELS = 2;
|
||||
|
||||
/**
|
||||
* The SharedPreferences key for whether the stashed handle region is dark.
|
||||
*/
|
||||
@@ -50,8 +55,7 @@ public class StashedHandleViewController {
|
||||
private final int mStashedHandleWidth;
|
||||
private final int mStashedHandleHeight;
|
||||
private final RegionSamplingHelper mRegionSamplingHelper;
|
||||
private final AnimatedFloat mTaskbarStashedHandleAlpha = new AnimatedFloat(
|
||||
this::updateStashedHandleAlpha);
|
||||
private final MultiValueAlpha mTaskbarStashedHandleAlpha;
|
||||
private final AnimatedFloat mTaskbarStashedHandleHintScale = new AnimatedFloat(
|
||||
this::updateStashedHandleHintScale);
|
||||
|
||||
@@ -69,6 +73,8 @@ public class StashedHandleViewController {
|
||||
mActivity = activity;
|
||||
mPrefs = Utilities.getPrefs(mActivity);
|
||||
mStashedHandleView = stashedHandleView;
|
||||
mTaskbarStashedHandleAlpha = new MultiValueAlpha(mStashedHandleView, NUM_ALPHA_CHANNELS);
|
||||
mTaskbarStashedHandleAlpha.setUpdateVisibility(true);
|
||||
mStashedHandleView.updateHandleColor(
|
||||
mPrefs.getBoolean(SHARED_PREFS_STASHED_HANDLE_REGION_DARK_KEY, false),
|
||||
false /* animate */);
|
||||
@@ -96,7 +102,7 @@ public class StashedHandleViewController {
|
||||
mControllers = controllers;
|
||||
mStashedHandleView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarSize;
|
||||
|
||||
updateStashedHandleAlpha();
|
||||
mTaskbarStashedHandleAlpha.getProperty(ALPHA_INDEX_STASHED).setValue(0);
|
||||
mTaskbarStashedHandleHintScale.updateValue(1f);
|
||||
|
||||
final int stashedTaskbarHeight = mControllers.taskbarStashController.getStashedHeight();
|
||||
@@ -129,7 +135,7 @@ public class StashedHandleViewController {
|
||||
mRegionSamplingHelper.stopAndDestroy();
|
||||
}
|
||||
|
||||
public AnimatedFloat getStashedHandleAlpha() {
|
||||
public MultiValueAlpha getStashedHandleAlpha() {
|
||||
return mTaskbarStashedHandleAlpha;
|
||||
}
|
||||
|
||||
@@ -163,12 +169,20 @@ public class StashedHandleViewController {
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateStashedHandleAlpha() {
|
||||
mStashedHandleView.setAlpha(mTaskbarStashedHandleAlpha.value);
|
||||
}
|
||||
|
||||
protected void updateStashedHandleHintScale() {
|
||||
mStashedHandleView.setScaleX(mTaskbarStashedHandleHintScale.value);
|
||||
mStashedHandleView.setScaleY(mTaskbarStashedHandleHintScale.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called when the home button is disabled, so we can hide this handle as well.
|
||||
*/
|
||||
public void setIsHomeButtonDisabled(boolean homeDisabled) {
|
||||
mTaskbarStashedHandleAlpha.getProperty(ALPHA_INDEX_HOME_DISABLED).setValue(
|
||||
homeDisabled ? 0 : 1);
|
||||
}
|
||||
|
||||
public boolean isStashedHandleVisible() {
|
||||
return mStashedHandleView.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +321,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
|
||||
panelExpanded || inSettings);
|
||||
mControllers.taskbarViewController.setRecentsButtonDisabled(
|
||||
mControllers.navbarButtonsViewController.isRecentsDisabled());
|
||||
mControllers.stashedHandleViewController.setIsHomeButtonDisabled(
|
||||
mControllers.navbarButtonsViewController.isHomeDisabled());
|
||||
mControllers.taskbarKeyguardController.updateStateForSysuiFlags(systemUiStateFlags);
|
||||
mControllers.taskbarStashController.updateStateForSysuiFlags(systemUiStateFlags);
|
||||
}
|
||||
|
||||
@@ -25,15 +25,21 @@ import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.provider.Settings;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.quickstep.AnimatedFloat;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
import com.android.quickstep.interaction.AllSetActivity;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
|
||||
import java.util.function.IntPredicate;
|
||||
|
||||
@@ -47,11 +53,12 @@ public class TaskbarStashController {
|
||||
public static final int FLAG_STASHED_IN_APP_MANUAL = 1 << 1; // long press, persisted
|
||||
public static final int FLAG_STASHED_IN_APP_PINNED = 1 << 2; // app pinning
|
||||
public static final int FLAG_STASHED_IN_APP_EMPTY = 1 << 3; // no hotseat icons
|
||||
public static final int FLAG_IN_STASHED_LAUNCHER_STATE = 1 << 4;
|
||||
public static final int FLAG_STASHED_IN_APP_SETUP = 1 << 4; // setup wizard and AllSetActivity
|
||||
public static final int FLAG_IN_STASHED_LAUNCHER_STATE = 1 << 5;
|
||||
|
||||
// If we're in an app and any of these flags are enabled, taskbar should be stashed.
|
||||
public static final int FLAGS_STASHED_IN_APP = FLAG_STASHED_IN_APP_MANUAL
|
||||
| FLAG_STASHED_IN_APP_PINNED | FLAG_STASHED_IN_APP_EMPTY;
|
||||
| FLAG_STASHED_IN_APP_PINNED | FLAG_STASHED_IN_APP_EMPTY | FLAG_STASHED_IN_APP_SETUP;
|
||||
|
||||
/**
|
||||
* How long to stash/unstash when manually invoked via long press.
|
||||
@@ -103,7 +110,7 @@ public class TaskbarStashController {
|
||||
private AnimatedFloat mIconScaleForStash;
|
||||
private AnimatedFloat mIconTranslationYForStash;
|
||||
// Stashed handle properties.
|
||||
private AnimatedFloat mTaskbarStashedHandleAlpha;
|
||||
private AlphaProperty mTaskbarStashedHandleAlpha;
|
||||
private AnimatedFloat mTaskbarStashedHandleHintScale;
|
||||
|
||||
/** Whether we are currently visually stashed (might change based on launcher state). */
|
||||
@@ -143,12 +150,14 @@ public class TaskbarStashController {
|
||||
|
||||
StashedHandleViewController stashedHandleController =
|
||||
controllers.stashedHandleViewController;
|
||||
mTaskbarStashedHandleAlpha = stashedHandleController.getStashedHandleAlpha();
|
||||
mTaskbarStashedHandleAlpha = stashedHandleController.getStashedHandleAlpha().getProperty(
|
||||
StashedHandleViewController.ALPHA_INDEX_STASHED);
|
||||
mTaskbarStashedHandleHintScale = stashedHandleController.getStashedHandleHintScale();
|
||||
|
||||
boolean isManuallyStashedInApp = supportsManualStashing()
|
||||
&& mPrefs.getBoolean(SHARED_PREFS_STASHED_KEY, DEFAULT_STASHED_PREF);
|
||||
updateStateForFlag(FLAG_STASHED_IN_APP_MANUAL, isManuallyStashedInApp);
|
||||
updateStateForFlag(FLAG_STASHED_IN_APP_SETUP, isInSetup());
|
||||
applyState();
|
||||
|
||||
SystemUiProxy.INSTANCE.get(mActivity)
|
||||
@@ -176,6 +185,23 @@ public class TaskbarStashController {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether we are in Setup Wizard or the corresponding AllSetActivity that follows it.
|
||||
*/
|
||||
private boolean isInSetup() {
|
||||
boolean isInSetup = !SettingsCache.INSTANCE.get(mActivity).getValue(
|
||||
Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0);
|
||||
if (isInSetup) {
|
||||
return true;
|
||||
}
|
||||
ActivityManager.RunningTaskInfo runningTask =
|
||||
ActivityManagerWrapper.getInstance().getRunningTask();
|
||||
if (runningTask == null || runningTask.baseActivity == null) {
|
||||
return false;
|
||||
}
|
||||
return runningTask.baseActivity.equals(new ComponentName(mActivity, AllSetActivity.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the taskbar is currently visually stashed.
|
||||
*/
|
||||
@@ -199,7 +225,12 @@ public class TaskbarStashController {
|
||||
}
|
||||
|
||||
public int getContentHeight() {
|
||||
return isStashed() ? mStashedHeight : mUnstashedHeight;
|
||||
if (isStashed()) {
|
||||
boolean isAnimating = mAnimator != null && mAnimator.isStarted();
|
||||
return mControllers.stashedHandleViewController.isStashedHandleVisible() || isAnimating
|
||||
? mStashedHeight : 0;
|
||||
}
|
||||
return mUnstashedHeight;
|
||||
}
|
||||
|
||||
public int getStashedHeight() {
|
||||
|
||||
Reference in New Issue
Block a user