Merge "Support live tile for 3rd party launchers" into sc-dev

This commit is contained in:
TreeHugger Robot 2021-05-05 06:04:10 +00:00 committed by Android (Google) Code Review
commit 7645422e37
7 changed files with 44 additions and 14 deletions

View File

@ -163,7 +163,9 @@ public final class FallbackActivityInterface extends
@Override
public boolean isInLiveTileMode() {
return false;
RecentsActivity activity = getCreatedActivity();
return activity != null && activity.getStateManager().getState() == DEFAULT &&
activity.isStarted();
}
@Override

View File

@ -25,6 +25,7 @@ import static com.android.launcher3.Utilities.createHomeIntent;
import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
import static com.android.quickstep.TaskViewUtils.createRecentsWindowAnimator;
import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
import android.animation.Animator;
@ -69,6 +70,7 @@ import com.android.quickstep.fallback.RecentsState;
import com.android.quickstep.util.RecentsAtomicAnimationFactory;
import com.android.quickstep.util.SplitSelectStateController;
import com.android.quickstep.views.OverviewActionsView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.SplitPlaceholderView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.system.ActivityOptionsCompat;
@ -291,6 +293,16 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
super.onConfigurationChanged(newConfig);
}
@Override
public void onStateSetEnd(RecentsState state) {
super.onStateSetEnd(state);
if (state == RecentsState.DEFAULT) {
AccessibilityManagerCompat.sendStateEventToTest(getBaseContext(),
OVERVIEW_STATE_ORDINAL);
}
}
/**
* Initialize/update the device profile.
*/
@ -329,6 +341,16 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
}
public void startHome() {
if (LIVE_TILE.get()) {
RecentsView recentsView = getOverviewPanel();
recentsView.switchToScreenshot(() -> recentsView.finishRecentsAnimation(true,
this::startHomeInternal));
} else {
startHomeInternal();
}
}
private void startHomeInternal() {
startActivity(createHomeIntent());
}

View File

@ -39,12 +39,14 @@ public class RecentsState implements BaseState<RecentsState> {
private static final int FLAG_OVERVIEW_ACTIONS = BaseState.getFlag(3);
private static final int FLAG_SHOW_AS_GRID = BaseState.getFlag(4);
private static final int FLAG_SCRIM = BaseState.getFlag(5);
private static final int FLAG_LIVE_TILE = BaseState.getFlag(6);
public static final RecentsState DEFAULT = new RecentsState(0,
FLAG_CLEAR_ALL_BUTTON | FLAG_OVERVIEW_ACTIONS | FLAG_SHOW_AS_GRID | FLAG_SCRIM);
FLAG_CLEAR_ALL_BUTTON | FLAG_OVERVIEW_ACTIONS | FLAG_SHOW_AS_GRID | FLAG_SCRIM
| FLAG_LIVE_TILE);
public static final RecentsState MODAL_TASK = new ModalState(1,
FLAG_DISABLE_RESTORE | FLAG_CLEAR_ALL_BUTTON | FLAG_OVERVIEW_ACTIONS | FLAG_MODAL
| FLAG_SHOW_AS_GRID | FLAG_SCRIM);
| FLAG_SHOW_AS_GRID | FLAG_SCRIM | FLAG_LIVE_TILE);
public static final RecentsState BACKGROUND_APP = new BackgroundAppState(2,
FLAG_DISABLE_RESTORE | FLAG_NON_INTERACTIVE | FLAG_FULL_SCREEN);
public static final RecentsState HOME = new RecentsState(3, 0);
@ -107,6 +109,13 @@ public class RecentsState implements BaseState<RecentsState> {
return hasFlag(FLAG_OVERVIEW_ACTIONS);
}
/**
* For this state, whether live tile should be shown.
*/
public boolean hasLiveTile() {
return hasFlag(FLAG_LIVE_TILE);
}
/**
* For this state, what color scrim should be drawn behind overview.
*/

View File

@ -15,6 +15,8 @@
*/
package com.android.quickstep.fallback;
import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE;
import com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController;
import com.android.quickstep.RecentsActivity;
@ -26,7 +28,8 @@ public class RecentsTaskController extends TaskViewTouchController<RecentsActivi
@Override
protected boolean isRecentsInteractive() {
return mActivity.hasWindowFocus();
return mActivity.hasWindowFocus() || (LIVE_TILE.get()
&& mActivity.getStateManager().getState().hasLiveTile());
}
@Override

View File

@ -20,8 +20,6 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TI
import android.content.Context;
import com.android.quickstep.OverviewComponentObserver;
import com.android.quickstep.RecentsAnimationDeviceState;
import com.android.quickstep.SysUINavigationMode;
import java.util.function.Predicate;
@ -37,7 +35,6 @@ public class NavigationModeFeatureFlag implements
private final Supplier<Boolean> mBasePredicate;
private final Predicate<SysUINavigationMode.Mode> mModePredicate;
private boolean mSupported;
private OverviewComponentObserver mObserver;
private NavigationModeFeatureFlag(Supplier<Boolean> basePredicate,
Predicate<SysUINavigationMode.Mode> modePredicate) {
@ -46,17 +43,12 @@ public class NavigationModeFeatureFlag implements
}
public boolean get() {
return mBasePredicate.get() && mSupported && mObserver != null
&& mObserver.isHomeAndOverviewSame();
return mBasePredicate.get() && mSupported;
}
public void initialize(Context context) {
onNavigationModeChanged(SysUINavigationMode.INSTANCE.get(context).getMode());
SysUINavigationMode.INSTANCE.get(context).addModeChangeListener(this);
// Temporary solution to disable live tile for the fallback launcher
RecentsAnimationDeviceState rads = new RecentsAnimationDeviceState(context);
mObserver = new OverviewComponentObserver(context, rads);
}
@Override

View File

@ -2249,7 +2249,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
mPendingAnimation.addEndListener(new Consumer<Boolean>() {
@Override
public void accept(Boolean success) {
if (LIVE_TILE.get() && taskView.isRunningTask() && success) {
if (LIVE_TILE.get() && mEnableDrawingLiveTile && taskView.isRunningTask()
&& success) {
finishRecentsAnimation(true /* toHome */, () -> onEnd(success));
} else {
onEnd(success);

View File

@ -553,6 +553,7 @@ public class TaskView extends FrameLayout implements Reusable {
@Override
public void onAnimationEnd(Animator animator) {
recentsView.getLiveTileTaskViewSimulator().setDrawsBelowRecents(true);
mIsClickableAsLiveTile = true;
}
});