Split LauncherActivityControllerHelper for Go

As Go will likely have very different implementation since it will be
replacing the app => overview animation, we split
LauncherActivityControllerHelper so that Go can override the class
completely.

Bug: 114136250
Test: Manul test NexusLauncher, Launcher3QuickStepGo, Launcher3IconRecents
Change-Id: Ia5554593ddafffe0f729a4658d0a37aed16d236b
This commit is contained in:
Kevin 2019-01-28 17:40:51 -08:00
parent 4229752c3b
commit be973bfe18
3 changed files with 217 additions and 15 deletions

View File

@ -0,0 +1,201 @@
/*
* Copyright (C) 2019 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.quickstep;
import static com.android.launcher3.LauncherState.OVERVIEW;
import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Rect;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherInitListener;
import com.android.launcher3.LauncherState;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.quickstep.util.TransformedRect;
import com.android.quickstep.views.IconRecentsView;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
/**
* {@link ActivityControlHelper} for the in-launcher recents. As Go does not support most gestures
* from app to overview/home, most of this class is stubbed out.
* TODO: Implement the app to overview animation functionality
*/
public final class LauncherActivityControllerHelper implements ActivityControlHelper<Launcher>{
@Override
public LayoutListener createLayoutListener(Launcher activity) {
// Go does not have draggable task snapshots.
return null;
}
@Override
public void onQuickInteractionStart(Launcher activity, ActivityManager.RunningTaskInfo taskInfo,
boolean activityVisible, TouchInteractionLog touchInteractionLog) {
// Go does not have quick interactions.
}
@Override
public float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp,
Context context) {
// Go does not have quick scrub.
return 0;
}
@Override
public void executeOnWindowAvailable(Launcher activity, Runnable action) {
// Go does not support live tiles.
}
@Override
public void onTransitionCancelled(Launcher activity, boolean activityVisible) {
LauncherState startState = activity.getStateManager().getRestState();
activity.getStateManager().goToState(startState, activityVisible);
}
@Override
public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context,
int interactionType, TransformedRect outRect) {
// TODO Implement outRect depending on where the task should animate to.
// Go does not support swipe up gesture.
return 0;
}
@Override
public void onSwipeUpComplete(Launcher activity) {
// Go does not support swipe up gesture.
}
@Override
public HomeAnimationFactory prepareHomeUI(Launcher activity) {
// Go does not support gestures from app to home.
return null;
}
@Override
public AnimationFactory prepareRecentsUI(Launcher activity,
boolean activityVisible, boolean animateActivity,
Consumer<AnimatorPlaybackController> callback) {
//TODO: Implement this based off where the recents view needs to be for app => recents anim.
return new AnimationFactory() {
@Override
public void createActivityController(long transitionLength,
@TouchConsumer.InteractionType int interactionType) {}
@Override
public void onTransitionCancelled() {}
};
}
@Override
public ActivityInitListener createActivityInitListener(
BiPredicate<Launcher, Boolean> onInitListener) {
return new LauncherInitListener(onInitListener);
}
@Override
public Launcher getCreatedActivity() {
LauncherAppState app = LauncherAppState.getInstanceNoCreate();
if (app == null) {
return null;
}
return (Launcher) app.getModel().getCallback();
}
private Launcher getVisibleLauncher() {
Launcher launcher = getCreatedActivity();
return (launcher != null) && launcher.isStarted() && launcher.hasWindowFocus() ?
launcher : null;
}
@Override
public IconRecentsView getVisibleRecentsView() {
Launcher launcher = getVisibleLauncher();
return launcher != null && launcher.getStateManager().getState().overviewUi
? launcher.getOverviewPanel() : null;
}
@Override
public boolean switchToRecentsIfVisible(boolean fromRecentsButton) {
Launcher launcher = getVisibleLauncher();
if (launcher == null) {
return false;
}
if (fromRecentsButton) {
launcher.getUserEventDispatcher().logActionCommand(
LauncherLogProto.Action.Command.RECENTS_BUTTON,
getContainerType(),
LauncherLogProto.ContainerType.TASKSWITCHER);
}
launcher.getStateManager().goToState(OVERVIEW);
return true;
}
@Override
public Rect getOverviewWindowBounds(Rect homeBounds, RemoteAnimationTargetCompat target) {
return homeBounds;
}
@Override
public boolean shouldMinimizeSplitScreen() {
return true;
}
@Override
public boolean deferStartingActivity(int downHitTarget) {
// Go only supports back to overview so we always defer starting activity.
return true;
}
@Override
public boolean supportsLongSwipe(Launcher activity) {
// Go does not support long swipe from the app.
return false;
}
@Override
public AlphaProperty getAlphaProperty(Launcher activity) {
return activity.getDragLayer().getAlphaProperty(DragLayer.ALPHA_INDEX_SWIPE_UP);
}
@Override
public LongSwipeHelper getLongSwipeController(Launcher activity, int runningTaskId) {
// Go does not support long swipe from the app.
return null;
}
@Override
public int getContainerType() {
final Launcher launcher = getVisibleLauncher();
return launcher != null ? launcher.getStateManager().getState().containerType
: LauncherLogProto.ContainerType.APP;
}
@Override
public boolean isInLiveTileMode() {
// Go does not support live tiles.
return false;
}
}

View File

@ -371,7 +371,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
@Nullable
@UiThread
private Launcher getVisibleLaucher() {
private Launcher getVisibleLauncher() {
Launcher launcher = getCreatedActivity();
return (launcher != null) && launcher.isStarted() && launcher.hasWindowFocus() ?
launcher : null;
@ -380,25 +380,25 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
@Nullable
@Override
public RecentsView getVisibleRecentsView() {
Launcher launcher = getVisibleLaucher();
Launcher launcher = getVisibleLauncher();
return launcher != null && launcher.getStateManager().getState().overviewUi
? launcher.getOverviewPanel() : null;
}
@Override
public boolean switchToRecentsIfVisible(boolean fromRecentsButton) {
Launcher launcher = getVisibleLaucher();
if (launcher != null) {
if (fromRecentsButton) {
launcher.getUserEventDispatcher().logActionCommand(
LauncherLogProto.Action.Command.RECENTS_BUTTON,
getContainerType(),
LauncherLogProto.ContainerType.TASKSWITCHER);
}
launcher.getStateManager().goToState(OVERVIEW);
return true;
Launcher launcher = getVisibleLauncher();
if (launcher == null) {
return false;
}
return false;
if (fromRecentsButton) {
launcher.getUserEventDispatcher().logActionCommand(
LauncherLogProto.Action.Command.RECENTS_BUTTON,
getContainerType(),
LauncherLogProto.ContainerType.TASKSWITCHER);
}
launcher.getStateManager().goToState(OVERVIEW);
return true;
}
@Override
@ -436,7 +436,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
@Override
public int getContainerType() {
final Launcher launcher = getVisibleLaucher();
final Launcher launcher = getVisibleLauncher();
return launcher != null ? launcher.getStateManager().getState().containerType
: LauncherLogProto.ContainerType.APP;
}

View File

@ -24,6 +24,7 @@ import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
import android.os.Handler;
import android.view.View;
import android.view.animation.Interpolator;
import androidx.annotation.NonNull;
@ -87,7 +88,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
@UiThread
@Nullable
RecentsView getVisibleRecentsView();
<T extends View> T getVisibleRecentsView();
@UiThread
boolean switchToRecentsIfVisible(boolean fromRecentsButton);