Merge "Disabling the nav bar scrim when Recents is docked." into nyc-dev

am: 8f55b89

* commit '8f55b89530f52119db6956e588f7fcda0a1f4f9b':
  Disabling the nav bar scrim when Recents is docked.

Change-Id: Ife90958b7e112f918bdfb179a730d76cf48461c5
This commit is contained in:
Winson
2016-04-02 00:34:36 +00:00
committed by android-build-merger
5 changed files with 102 additions and 52 deletions

View File

@@ -344,7 +344,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
// Update the nav bar scrim, but defer the animation until the enter-window event
boolean animateNavBarScrim = !launchState.launchedViaDockGesture;
updateNavBarScrim(animateNavBarScrim, null);
mScrimViews.updateNavBarScrim(animateNavBarScrim, stack.getTaskCount() > 0, null);
// If this is a new instance relaunched by AM, without going through the normal mechanisms,
// then we have to manually trigger the enter animation state
@@ -417,39 +417,43 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Update the nav bar for the current orientation
updateNavBarScrim(false /* animateNavBarScrim */, AnimationProps.IMMEDIATE);
// Notify of the config change
int newOrientation = getResources().getConfiguration().orientation;
int numStackTasks = mRecentsView.getStack().getStackTaskCount();
EventBus.getDefault().send(new ConfigurationChangedEvent(false /* fromMultiWindow */,
(mLastOrientation != newOrientation)));
(mLastOrientation != newOrientation), numStackTasks > 0));
mLastOrientation = newOrientation;
}
@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
super.onMultiWindowModeChanged(isInMultiWindowMode);
// Reload the task stack completely
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(this);
loader.preloadTasks(loadPlan, -1 /* topTaskId */, false /* isTopTaskHome */);
RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
loadOpts.numVisibleTasks = launchState.launchedNumVisibleTasks;
loadOpts.numVisibleTaskThumbnails = launchState.launchedNumVisibleThumbnails;
loader.loadTasks(this, loadPlan, loadOpts);
TaskStack stack = loadPlan.getTaskStack();
int numStackTasks = stack.getStackTaskCount();
EventBus.getDefault().send(new ConfigurationChangedEvent(true /* fromMultiWindow */,
false /* fromOrientationChange */));
false /* fromOrientationChange */, numStackTasks > 0));
if (mRecentsView != null) {
// Reload the task stack completely
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(this);
loader.preloadTasks(loadPlan, -1 /* topTaskId */, false /* isTopTaskHome */);
RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
loadOpts.numVisibleTasks = launchState.launchedNumVisibleTasks;
loadOpts.numVisibleTaskThumbnails = launchState.launchedNumVisibleThumbnails;
loader.loadTasks(this, loadPlan, loadOpts);
mRecentsView.updateStack(loadPlan.getTaskStack());
mRecentsView.updateStack(stack);
}
EventBus.getDefault().send(new MultiWindowStateChangedEvent(isInMultiWindowMode));
EventBus.getDefault().send(new MultiWindowStateChangedEvent(isInMultiWindowMode,
numStackTasks > 0));
}
@Override
@@ -729,18 +733,4 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
});
return true;
}
/**
* Updates the nav bar scrim.
*/
private void updateNavBarScrim(boolean animateNavBarScrim, AnimationProps animation) {
// Animate the SystemUI scrims into view
SystemServicesProxy ssp = Recents.getSystemServices();
int taskCount = mRecentsView.getStack().getTaskCount();
boolean hasNavBarScrim = (taskCount > 0) && !ssp.hasTransposedNavBar();
mScrimViews.prepareEnterRecentsAnimation(hasNavBarScrim, animateNavBarScrim);
if (animateNavBarScrim && animation != null) {
mScrimViews.animateNavBarScrimVisibility(true, animation);
}
}
}

View File

@@ -25,9 +25,12 @@ public class ConfigurationChangedEvent extends EventBus.AnimatedEvent {
public final boolean fromMultiWindow;
public final boolean fromOrientationChange;
public final boolean hasStackTasks;
public ConfigurationChangedEvent(boolean fromMultiWindow, boolean fromOrientationChange) {
public ConfigurationChangedEvent(boolean fromMultiWindow, boolean fromOrientationChange,
boolean hasStackTasks) {
this.fromMultiWindow = fromMultiWindow;
this.fromOrientationChange = fromOrientationChange;
this.hasStackTasks = hasStackTasks;
}
}

View File

@@ -24,8 +24,10 @@ import com.android.systemui.recents.events.EventBus;
public class MultiWindowStateChangedEvent extends EventBus.Event {
public final boolean inMultiWindow;
public final boolean hasStackTasks;
public MultiWindowStateChangedEvent(boolean inMultiWindow) {
public MultiWindowStateChangedEvent(boolean inMultiWindow, boolean hasStackTasks) {
this.inMultiWindow = inMultiWindow;
this.hasStackTasks = hasStackTasks;
}
}

View File

@@ -16,40 +16,58 @@
package com.android.systemui.recents.views;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsActivity;
import com.android.systemui.recents.events.activity.ConfigurationChangedEvent;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.ui.DismissAllTaskViewsEvent;
import com.android.systemui.recents.events.activity.MultiWindowStateChangedEvent;
import com.android.systemui.recents.misc.SystemServicesProxy;
/** Manages the scrims for the various system bars. */
public class SystemBarScrimViews {
Context mContext;
private static final int DEFAULT_ANIMATION_DURATION = 150;
View mNavBarScrimView;
private Context mContext;
boolean mHasNavBarScrim;
boolean mShouldAnimateNavBarScrim;
private View mNavBarScrimView;
int mNavBarScrimEnterDuration;
private boolean mHasNavBarScrim;
private boolean mShouldAnimateNavBarScrim;
public SystemBarScrimViews(Activity activity) {
private int mNavBarScrimEnterDuration;
public SystemBarScrimViews(RecentsActivity activity) {
mContext = activity;
mNavBarScrimView = activity.findViewById(R.id.nav_bar_scrim);
mNavBarScrimView.forceHasOverlappingRendering(false);
mNavBarScrimEnterDuration = activity.getResources().getInteger(
R.integer.recents_nav_bar_scrim_enter_duration);
}
/**
* Updates the nav bar scrim.
*/
public void updateNavBarScrim(boolean animateNavBarScrim, boolean hasStackTasks,
AnimationProps animation) {
prepareEnterRecentsAnimation(isNavBarScrimRequired(hasStackTasks), animateNavBarScrim);
if (animateNavBarScrim && animation != null) {
animateNavBarScrimVisibility(true, animation);
}
}
/**
* Prepares the scrim views for animating when entering Recents. This will be called before
* the first draw, unless we are updating the scrim on configuration change.
*/
public void prepareEnterRecentsAnimation(boolean hasNavBarScrim, boolean animateNavBarScrim) {
private void prepareEnterRecentsAnimation(boolean hasNavBarScrim, boolean animateNavBarScrim) {
mHasNavBarScrim = hasNavBarScrim;
mShouldAnimateNavBarScrim = animateNavBarScrim;
@@ -60,7 +78,7 @@ public class SystemBarScrimViews {
/**
* Animates the nav bar scrim visibility.
*/
public void animateNavBarScrimVisibility(boolean visible, AnimationProps animation) {
private void animateNavBarScrimVisibility(boolean visible, AnimationProps animation) {
int toY = 0;
if (visible) {
mNavBarScrimView.setVisibility(View.VISIBLE);
@@ -79,6 +97,14 @@ public class SystemBarScrimViews {
}
}
/**
* @return Whether to show the nav bar scrim.
*/
private boolean isNavBarScrimRequired(boolean hasStackTasks) {
SystemServicesProxy ssp = Recents.getSystemServices();
return hasStackTasks && !ssp.hasTransposedNavBar() && !ssp.hasDockedTask();
}
/**** EventBus events ****/
/**
@@ -101,21 +127,48 @@ public class SystemBarScrimViews {
*/
public final void onBusEvent(DismissRecentsToHomeAnimationStarted event) {
if (mHasNavBarScrim) {
AnimationProps animation = new AnimationProps()
.setDuration(AnimationProps.BOUNDS,
TaskStackAnimationHelper.EXIT_TO_HOME_TRANSLATION_DURATION)
.setInterpolator(AnimationProps.BOUNDS, Interpolators.FAST_OUT_SLOW_IN);
AnimationProps animation = createBoundsAnimation(
TaskStackAnimationHelper.EXIT_TO_HOME_TRANSLATION_DURATION);
animateNavBarScrimVisibility(false, animation);
}
}
public final void onBusEvent(DismissAllTaskViewsEvent event) {
if (mHasNavBarScrim) {
AnimationProps animation = new AnimationProps()
.setDuration(AnimationProps.BOUNDS,
TaskStackAnimationHelper.EXIT_TO_HOME_TRANSLATION_DURATION)
.setInterpolator(AnimationProps.BOUNDS, Interpolators.FAST_OUT_SLOW_IN);
AnimationProps animation = createBoundsAnimation(
TaskStackAnimationHelper.EXIT_TO_HOME_TRANSLATION_DURATION);
animateNavBarScrimVisibility(false, animation);
}
}
public final void onBusEvent(ConfigurationChangedEvent event) {
animateScrimToCurrentNavBarState(event.hasStackTasks);
}
public final void onBusEvent(MultiWindowStateChangedEvent event) {
animateScrimToCurrentNavBarState(event.hasStackTasks);
}
/**
* Animates the scrim to match the state of the current nav bar.
*/
private void animateScrimToCurrentNavBarState(boolean hasStackTasks) {
boolean hasNavBarScrim = isNavBarScrimRequired(hasStackTasks);
if (mHasNavBarScrim != hasNavBarScrim) {
AnimationProps animation = hasNavBarScrim
? createBoundsAnimation(DEFAULT_ANIMATION_DURATION)
: AnimationProps.IMMEDIATE;
animateNavBarScrimVisibility(hasNavBarScrim, animation);
}
mHasNavBarScrim = hasNavBarScrim;
}
/**
* @return a default animation to aniamte the bounds of the scrim.
*/
private AnimationProps createBoundsAnimation(int duration) {
return new AnimationProps()
.setDuration(AnimationProps.BOUNDS, duration)
.setInterpolator(AnimationProps.BOUNDS, Interpolators.FAST_OUT_SLOW_IN);
}
}

View File

@@ -537,11 +537,13 @@ public class TaskStackLayoutAlgorithm {
} else {
mInitialScrollP = Utilities.clamp(launchTaskIndex - 1, mMinScrollP, mMaxScrollP);
}
mInitialNormX = null;
} else if (!ssp.hasFreeformWorkspaceSupport() && mNumStackTasks == 1) {
// If there is one stack task, ignore the min/max/initial scroll positions
mMinScrollP = 0;
mMaxScrollP = 0;
mInitialScrollP = 0;
mInitialNormX = null;
} else {
// Set the max scroll to be the point where the front most task is visible with the
// stack bottom offset