import com.android.systemui.recents.events.ui.StackViewScrolledEvent;
import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent;
import com.android.systemui.recents.events.ui.UserInteractionEvent;
+import com.android.systemui.recents.events.ui.dragndrop.DragEndEvent;
import com.android.systemui.recents.events.ui.focus.DismissFocusedTaskViewEvent;
import com.android.systemui.recents.events.ui.focus.FocusNextTaskViewEvent;
import com.android.systemui.recents.events.ui.focus.FocusPreviousTaskViewEvent;
mIgnoreAltTabRelease = true;
}
+ public final void onBusEvent(final DragEndEvent event) {
+ // Handle the case where we drop onto a dock region
+ if (event.dropTarget instanceof TaskStack.DockState) {
+ mScrimViews.animateScrimToCurrentNavBarState(false /* hasStackTasks */);
+ }
+ }
+
@Override
public boolean onPreDraw() {
mRecentsView.getViewTreeObserver().removeOnPreDrawListener(this);
ssp.registerTaskStackListener(mTaskStackListener);
// Initialize the static configuration resources
- reloadHeaderBarLayout();
+ LayoutInflater inflater = LayoutInflater.from(mContext);
+ mDummyStackView = new TaskStackView(mContext);
+ mHeaderBar = (TaskViewHeader) inflater.inflate(R.layout.recents_task_view_header,
+ null, false);
+ reloadResources();
// When we start, preload the data associated with the previous recent tasks.
// We can use a new plan since the caches will be the same.
}
public void onConfigurationChanged() {
- reloadHeaderBarLayout();
+ reloadResources();
+ mDummyStackView.reloadOnConfigurationChange();
+ mHeaderBar.onConfigurationChanged();
}
/**
}
/**
- * Reloads all the layouts for the header bar transition.
+ * Reloads all the resources for the current configuration.
*/
- private void reloadHeaderBarLayout() {
+ private void reloadResources() {
Resources res = mContext.getResources();
- LayoutInflater inflater = LayoutInflater.from(mContext);
mStatusBarHeight = res.getDimensionPixelSize(
com.android.internal.R.dimen.status_bar_height);
R.dimen.recents_task_view_header_height_tablet_land,
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height_tablet_land);
- mDummyStackView = new TaskStackView(mContext);
- mHeaderBar = (TaskViewHeader) inflater.inflate(R.layout.recents_task_view_header,
- null, false);
}
/**
/**
* Animates the scrim to match the state of the current nav bar.
*/
- private void animateScrimToCurrentNavBarState(boolean hasStackTasks) {
+ public void animateScrimToCurrentNavBarState(boolean hasStackTasks) {
boolean hasNavBarScrim = isNavBarScrimRequired(hasStackTasks);
if (mHasNavBarScrim != hasNavBarScrim) {
AnimationProps animation = hasNavBarScrim
public void updateToInitialState(boolean scrollToInitialState) {
if (scrollToInitialState) {
mStackScroller.setStackScrollToInitialState();
+ mLayoutAlgorithm.updateToInitialState(mStack.getStackTasks());
}
- mLayoutAlgorithm.updateToInitialState(mStack.getStackTasks());
}
/** Updates the list of task views */
// TaskViews with the stack so that we can lay them out
if (mAwaitingFirstLayout || mInitialState != INITIAL_STATE_UPDATE_NONE) {
updateToInitialState(mInitialState != INITIAL_STATE_UPDATE_LAYOUT_ONLY);
- mInitialState = INITIAL_STATE_UPDATE_NONE;
+ if (!mAwaitingFirstLayout) {
+ mInitialState = INITIAL_STATE_UPDATE_NONE;
+ }
}
// Rebind all the views, including the ignore ones
if (mAwaitingFirstLayout || !mEnterAnimationComplete) {
mAwaitingFirstLayout = false;
+ mInitialState = INITIAL_STATE_UPDATE_NONE;
onFirstLayout();
}
}
// Calculate the new task stack bounds that matches the window size that Recents will
// have after the drop
final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget;
+ Rect systemInsets = new Rect(mStableLayoutAlgorithm.mSystemInsets);
+ // When docked, the nav bar insets are consumed and the activity is measured without
+ // insets. However, the window bounds include the insets, so we need to subtract them
+ // here to make them identical.
+ int height = getMeasuredHeight();
+ height -= systemInsets.bottom;
+ systemInsets.bottom = 0;
mStackBounds.set(dockState.getDockedTaskStackBounds(getMeasuredWidth(),
- getMeasuredHeight(), mDividerSize, mLayoutAlgorithm.mSystemInsets,
+ height, mDividerSize, mLayoutAlgorithm.mSystemInsets,
mLayoutAlgorithm, getResources(), mWindowRect));
+ mLayoutAlgorithm.setSystemInsets(systemInsets);
mLayoutAlgorithm.initialize(mWindowRect, mStackBounds,
TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack));
updateLayoutAlgorithm(true /* boundScroll */);
mWindowRect.set(mStableWindowRect);
mStackBounds.set(mStableStackBounds);
removeIgnoreTask(event.task);
+ mLayoutAlgorithm.setSystemInsets(mStableLayoutAlgorithm.mSystemInsets);
mLayoutAlgorithm.initialize(mWindowRect, mStackBounds,
TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack));
updateLayoutAlgorithm(true /* boundScroll */);
}
public final void onBusEvent(ConfigurationChangedEvent event) {
- mStableLayoutAlgorithm.reloadOnConfigurationChange(getContext());
- mLayoutAlgorithm.reloadOnConfigurationChange(getContext());
+ reloadOnConfigurationChange();
// Notify the task views of the configuration change so they can reload their resources
if (!event.fromMultiWindow) {
}
// Trigger a new layout and update to the initial state if necessary
- if (event.fromMultiWindow) {
- mInitialState = INITIAL_STATE_UPDATE_ALL;
- } else if (event.fromOrientationChange) {
+ if (event.fromMultiWindow || event.fromOrientationChange) {
mInitialState = INITIAL_STATE_UPDATE_LAYOUT_ONLY;
+ requestLayout();
}
- requestLayout();
+ }
+
+ public void reloadOnConfigurationChange() {
+ mStableLayoutAlgorithm.reloadOnConfigurationChange(getContext());
+ mLayoutAlgorithm.reloadOnConfigurationChange(getContext());
}
/**
/**
* Update the header view when the configuration changes.
*/
- void onConfigurationChanged() {
+ public void onConfigurationChanged() {
// Update the dimensions of everything in the header. We do this because we need to use
// resources for the display, and not the current configuration.
Resources res = getResources();
- mHeaderBarHeight = TaskStackLayoutAlgorithm.getDimensionForDevice(res,
+ int headerBarHeight = TaskStackLayoutAlgorithm.getDimensionForDevice(res,
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height_tablet_land,
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height_tablet_land);
- mHeaderButtonPadding = TaskStackLayoutAlgorithm.getDimensionForDevice(res,
+ int headerButtonPadding = TaskStackLayoutAlgorithm.getDimensionForDevice(res,
R.dimen.recents_task_view_header_button_padding,
R.dimen.recents_task_view_header_button_padding,
R.dimen.recents_task_view_header_button_padding,
R.dimen.recents_task_view_header_button_padding_tablet_land,
R.dimen.recents_task_view_header_button_padding,
R.dimen.recents_task_view_header_button_padding_tablet_land);
- updateLayoutParams(mIconView, mTitleView, mMoveTaskButton, mDismissButton);
- if (mAppOverlayView != null) {
- updateLayoutParams(mAppIconView, mAppTitleView, null, mAppInfoView);
+ if (headerBarHeight != mHeaderBarHeight || headerButtonPadding != mHeaderButtonPadding) {
+ mHeaderBarHeight = headerBarHeight;
+ mHeaderButtonPadding = headerButtonPadding;
+ updateLayoutParams(mIconView, mTitleView, mMoveTaskButton, mDismissButton);
+ if (mAppOverlayView != null) {
+ updateLayoutParams(mAppIconView, mAppTitleView, null, mAppInfoView);
+ }
}
}
/** Binds the bar view to the task */
public void rebindToTask(Task t, boolean touchExplorationEnabled, boolean disabledInSafeMode) {
- SystemServicesProxy ssp = Recents.getSystemServices();
mTask = t;
// If an activity icon is defined, then we use that as the primary icon to show in the bar,