Merge "Handle AddDesktopButton's visibility in different launcher states" into main
This commit is contained in:
@@ -27,17 +27,16 @@ import com.android.launcher3.anim.AnimatedFloat
|
||||
import com.android.launcher3.anim.AnimatorListeners.forSuccessCallback
|
||||
import com.android.launcher3.anim.PendingAnimation
|
||||
import com.android.launcher3.anim.PropertySetter
|
||||
import com.android.launcher3.logging.StatsLogManager.LauncherEvent
|
||||
import com.android.launcher3.statemanager.StateManager.StateHandler
|
||||
import com.android.launcher3.states.StateAnimationConfig
|
||||
import com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_ACTIONS_FADE
|
||||
import com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE
|
||||
import com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_MODAL
|
||||
import com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE
|
||||
import com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SPLIT_SELECT_INSTRUCTIONS_FADE
|
||||
import com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X
|
||||
import com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y
|
||||
import com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW
|
||||
import com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE
|
||||
import com.android.quickstep.util.AnimUtils
|
||||
import com.android.quickstep.views.ClearAllButton
|
||||
import com.android.quickstep.views.RecentsView
|
||||
@@ -226,8 +225,8 @@ class RecentsViewStateController(private val launcher: QuickstepLauncher) :
|
||||
builder: PendingAnimation,
|
||||
animate: Boolean,
|
||||
) {
|
||||
val goingToOverviewFromWorkspaceContextual = toState == LauncherState.OVERVIEW &&
|
||||
launcher.isSplitSelectionActive
|
||||
val goingToOverviewFromWorkspaceContextual =
|
||||
toState == LauncherState.OVERVIEW && launcher.isSplitSelectionActive
|
||||
if (
|
||||
toState != LauncherState.OVERVIEW_SPLIT_SELECT &&
|
||||
!goingToOverviewFromWorkspaceContextual
|
||||
@@ -302,6 +301,14 @@ class RecentsViewStateController(private val launcher: QuickstepLauncher) :
|
||||
overviewButtonAlpha,
|
||||
config.getInterpolator(ANIM_OVERVIEW_ACTIONS_FADE, LINEAR),
|
||||
)
|
||||
recentsView.addDeskButton?.let {
|
||||
propertySetter.setFloat(
|
||||
it.visibilityAlphaProperty,
|
||||
MULTI_PROPERTY_VALUE,
|
||||
if (state.areElementsVisible(launcher, LauncherState.ADD_DESK_BUTTON)) 1f else 0f,
|
||||
LINEAR,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOverviewInterpolator(fromState: LauncherState, toState: LauncherState) =
|
||||
|
||||
@@ -77,7 +77,8 @@ public class BackgroundAppState extends OverviewState {
|
||||
return super.getVisibleElements(launcher)
|
||||
& ~OVERVIEW_ACTIONS
|
||||
& ~CLEAR_ALL_BUTTON
|
||||
& ~VERTICAL_SWIPE_INDICATOR;
|
||||
& ~VERTICAL_SWIPE_INDICATOR
|
||||
& ~ADD_DESK_BUTTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,7 +45,7 @@ public class OverviewModalTaskState extends OverviewState {
|
||||
|
||||
@Override
|
||||
public int getVisibleElements(Launcher launcher) {
|
||||
return OVERVIEW_ACTIONS | CLEAR_ALL_BUTTON;
|
||||
return OVERVIEW_ACTIONS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -110,7 +110,7 @@ public class OverviewState extends LauncherState {
|
||||
|
||||
@Override
|
||||
public int getVisibleElements(Launcher launcher) {
|
||||
int elements = CLEAR_ALL_BUTTON | OVERVIEW_ACTIONS;
|
||||
int elements = CLEAR_ALL_BUTTON | OVERVIEW_ACTIONS | ADD_DESK_BUTTON;
|
||||
DeviceProfile dp = launcher.getDeviceProfile();
|
||||
boolean showFloatingSearch;
|
||||
if (dp.isPhone) {
|
||||
@@ -124,7 +124,7 @@ public class OverviewState extends LauncherState {
|
||||
elements |= FLOATING_SEARCH_BAR;
|
||||
}
|
||||
if (launcher.isSplitSelectionActive()) {
|
||||
elements &= ~CLEAR_ALL_BUTTON;
|
||||
elements &= ~CLEAR_ALL_BUTTON & ~ADD_DESK_BUTTON;
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TR
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE;
|
||||
import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW;
|
||||
import static com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE;
|
||||
import static com.android.quickstep.fallback.RecentsState.OVERVIEW_SPLIT_SELECT;
|
||||
import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_HORIZONTAL_OFFSET;
|
||||
import static com.android.quickstep.views.RecentsView.DESKTOP_CAROUSEL_DETACH_PROGRESS;
|
||||
@@ -99,6 +100,11 @@ public class FallbackRecentsStateController implements StateHandler<RecentsState
|
||||
float clearAllButtonAlpha = state.hasClearAllButton() ? 1 : 0;
|
||||
setter.setFloat(mRecentsView.getClearAllButton(), ClearAllButton.VISIBILITY_ALPHA,
|
||||
clearAllButtonAlpha, LINEAR);
|
||||
if (mRecentsView.getAddDeskButton() != null) {
|
||||
float addDeskButtonAlpha = state.hasAddDeskButton() ? 1 : 0;
|
||||
setter.setFloat(mRecentsView.getAddDeskButton().getVisibilityAlphaProperty(),
|
||||
MULTI_PROPERTY_VALUE, addDeskButtonAlpha, LINEAR);
|
||||
}
|
||||
float overviewButtonAlpha = state.hasOverviewActions() ? 1 : 0;
|
||||
setter.setFloat(mRecentsViewContainer.getActionsView().getVisibilityAlpha(),
|
||||
AnimatedFloat.VALUE, overviewButtonAlpha, LINEAR);
|
||||
|
||||
@@ -45,14 +45,16 @@ public class RecentsState implements BaseState<RecentsState> {
|
||||
private static final int FLAG_RECENTS_VIEW_VISIBLE = BaseState.getFlag(7);
|
||||
private static final int FLAG_TASK_THUMBNAIL_SPLASH = BaseState.getFlag(8);
|
||||
private static final int FLAG_DETACH_DESKTOP_CAROUSEL = BaseState.getFlag(9);
|
||||
private static final int FLAG_ADD_DESK_BUTTON = BaseState.getFlag(10);
|
||||
|
||||
private static final RecentsState[] sAllStates = new RecentsState[6];
|
||||
|
||||
public static final RecentsState DEFAULT = new RecentsState(0,
|
||||
FLAG_DISABLE_RESTORE | FLAG_CLEAR_ALL_BUTTON | FLAG_OVERVIEW_ACTIONS | FLAG_SHOW_AS_GRID
|
||||
| FLAG_SCRIM | FLAG_LIVE_TILE | FLAG_RECENTS_VIEW_VISIBLE);
|
||||
| FLAG_SCRIM | FLAG_LIVE_TILE | FLAG_RECENTS_VIEW_VISIBLE
|
||||
| FLAG_ADD_DESK_BUTTON);
|
||||
public static final RecentsState MODAL_TASK = new ModalState(1,
|
||||
FLAG_DISABLE_RESTORE | FLAG_CLEAR_ALL_BUTTON | FLAG_OVERVIEW_ACTIONS | FLAG_MODAL
|
||||
FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_ACTIONS | FLAG_MODAL
|
||||
| FLAG_SHOW_AS_GRID | FLAG_SCRIM | FLAG_LIVE_TILE | FLAG_RECENTS_VIEW_VISIBLE);
|
||||
public static final RecentsState BACKGROUND_APP = new BackgroundAppState(2,
|
||||
FLAG_DISABLE_RESTORE | FLAG_NON_INTERACTIVE | FLAG_FULL_SCREEN
|
||||
@@ -121,6 +123,13 @@ public class RecentsState implements BaseState<RecentsState> {
|
||||
return hasFlag(FLAG_CLEAR_ALL_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* For this state, whether add desk button should be shown.
|
||||
*/
|
||||
public boolean hasAddDeskButton() {
|
||||
return hasFlag(FLAG_ADD_DESK_BUTTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* For this state, whether overview actions should be shown.
|
||||
*/
|
||||
|
||||
@@ -20,10 +20,12 @@ import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.ImageButton
|
||||
import com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.util.MultiPropertyFactory
|
||||
import com.android.launcher3.util.MultiValueAlpha
|
||||
import com.android.quickstep.util.BorderAnimator
|
||||
import com.android.quickstep.util.BorderAnimator.Companion.createSimpleBorderAnimator
|
||||
|
||||
@@ -34,6 +36,22 @@ import com.android.quickstep.util.BorderAnimator.Companion.createSimpleBorderAni
|
||||
class AddDesktopButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
ImageButton(context, attrs) {
|
||||
|
||||
private enum class Alpha {
|
||||
CONTENT,
|
||||
VISIBILITY,
|
||||
}
|
||||
|
||||
private val addDeskButtonAlpha = MultiValueAlpha(this, Alpha.entries.size)
|
||||
|
||||
var contentAlpha
|
||||
set(value) {
|
||||
addDeskButtonAlpha.get(Alpha.CONTENT.ordinal).value = value
|
||||
}
|
||||
get() = addDeskButtonAlpha.get(Alpha.CONTENT.ordinal).value
|
||||
|
||||
val visibilityAlphaProperty: MultiPropertyFactory<View>.MultiProperty
|
||||
get() = addDeskButtonAlpha.get(Alpha.VISIBILITY.ordinal)
|
||||
|
||||
private enum class TranslationX {
|
||||
GRID,
|
||||
OFFSET,
|
||||
|
||||
@@ -4762,9 +4762,8 @@ public abstract class RecentsView<
|
||||
}
|
||||
mClearAllButton.setContentAlpha(mContentAlpha);
|
||||
|
||||
// TODO(b/389209338): Handle the visibility of the `mAddDesktopButton`.
|
||||
if (mAddDesktopButton != null) {
|
||||
mAddDesktopButton.setAlpha(mContentAlpha);
|
||||
mAddDesktopButton.setContentAlpha(mContentAlpha);
|
||||
}
|
||||
int alphaInt = Math.round(alpha * 255);
|
||||
mEmptyMessagePaint.setAlpha(alphaInt);
|
||||
@@ -6329,6 +6328,11 @@ public abstract class RecentsView<
|
||||
return mClearAllButton;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public AddDesktopButton getAddDeskButton() {
|
||||
return mAddDesktopButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return How many pixels the running task is offset on the currently laid out dominant axis.
|
||||
*/
|
||||
|
||||
@@ -70,6 +70,7 @@ public abstract class LauncherState implements BaseState<LauncherState> {
|
||||
public static final int WORKSPACE_PAGE_INDICATOR = 1 << 5;
|
||||
public static final int SPLIT_PLACHOLDER_VIEW = 1 << 6;
|
||||
public static final int FLOATING_SEARCH_BAR = 1 << 7;
|
||||
public static final int ADD_DESK_BUTTON = 1 << 8;
|
||||
|
||||
// Flag indicating workspace has multiple pages visible.
|
||||
public static final int FLAG_MULTI_PAGE = BaseState.getFlag(0);
|
||||
|
||||
Reference in New Issue
Block a user