From 64bb5bbb786f1d7020984c1b1bfbb93099f12ba7 Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 18 Apr 2019 17:17:06 -0700 Subject: [PATCH] Ensure recents scrolled to first task in landscape The app should animate to the bottom view which means we should ensure the bottom view is scrolled to be visible at the bottom when we animate in. Note that this is only a consideration in landscape since in portrait, all tasks are always visible and the recyclver view is not scrollable. Bug: 114136250 Test: Go to recents Go from app in landscape mode Change-Id: If4ea35759cc881f2c32565368d031620b62a45dd --- .../android/quickstep/views/IconRecentsView.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java index ec02e9d705..b7ed5b59f3 100644 --- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java +++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java @@ -15,6 +15,8 @@ */ package com.android.quickstep.views; +import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; + import static androidx.recyclerview.widget.LinearLayoutManager.VERTICAL; import static com.android.quickstep.TaskAdapter.CHANGE_EVENT_TYPE_EMPTY_TO_CONTENT; @@ -99,6 +101,7 @@ public final class IconRecentsView extends FrameLayout { private final Context mContext; private final TaskListLoader mTaskLoader; private final TaskAdapter mTaskAdapter; + private final LinearLayoutManager mTaskLayoutManager; private final TaskActionController mTaskActionController; private final DefaultItemAnimator mDefaultItemAnimator = new DefaultItemAnimator(); private final ContentFillItemAnimator mLoadingContentItemAnimator = @@ -138,6 +141,7 @@ public final class IconRecentsView extends FrameLayout { mTaskAdapter.setOnClearAllClickListener(view -> animateClearAllTasks()); mTaskActionController = new TaskActionController(mTaskLoader, mTaskAdapter); mTaskAdapter.setActionController(mTaskActionController); + mTaskLayoutManager = new LinearLayoutManager(mContext, VERTICAL, true /* reverseLayout */); RecentsModel.INSTANCE.get(context).addThumbnailChangeListener(listener); } @@ -147,8 +151,7 @@ public final class IconRecentsView extends FrameLayout { if (mTaskRecyclerView == null) { mTaskRecyclerView = findViewById(R.id.recent_task_recycler_view); mTaskRecyclerView.setAdapter(mTaskAdapter); - mTaskRecyclerView.setLayoutManager( - new LinearLayoutManager(mContext, VERTICAL, true /* reverseLayout */)); + mTaskRecyclerView.setLayoutManager(mTaskLayoutManager); ItemTouchHelper helper = new ItemTouchHelper( new TaskSwipeCallback(mTaskActionController)); helper.attachToRecyclerView(mTaskRecyclerView); @@ -211,6 +214,12 @@ public final class IconRecentsView extends FrameLayout { * becomes visible. */ public void onBeginTransitionToOverview() { + if (mContext.getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE) { + // Scroll to bottom of task in landscape mode. This is a non-issue in portrait mode as + // all tasks should be visible to fill up the screen in portrait mode and the view will + // not be scrollable. + mTaskLayoutManager.scrollToPositionWithOffset(TASKS_START_POSITION, 0 /* offset */); + } scheduleFadeInLayoutAnimation(); // Load any task changes if (!mTaskLoader.needsToLoad()) {