From 384e60e99d6a5925e0ba1d6534db3f1b57b7d6b0 Mon Sep 17 00:00:00 2001 From: Matthew Ng Date: Mon, 31 Oct 2016 16:44:01 -0700 Subject: [PATCH] Fixes header bar sizes when changing display sizes Fixed by capturing the correct task algorithm margin sizes and conducting a re-inflate on the TaskStackHeader upon configuration changes. Bug: 30370789 Fixes: 30370789 Test: manual - changed display sizes and toggled rencents Change-Id: Ia1b823433ea1920293cdeca6b7e48ffe15f78b61 --- .../android/systemui/recents/RecentsImpl.java | 16 ++++-------- .../views/TaskStackLayoutAlgorithm.java | 25 +++++++++---------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index 64ef997a85c85..abde44e1c2f5a 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -181,10 +181,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener ssp.registerTaskStackListener(mTaskStackListener); // Initialize the static configuration resources - LayoutInflater inflater = LayoutInflater.from(mContext); mDummyStackView = new TaskStackView(mContext); - mHeaderBar = (TaskViewHeader) inflater.inflate(R.layout.recents_task_view_header, - null, false); reloadResources(); } @@ -205,14 +202,6 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener Resources res = mContext.getResources(); reloadResources(); mDummyStackView.reloadOnConfigurationChange(); - // Update the header bar direction directly as it is not attached to anything and does not - // layout except in updateHeaderBarLayout() - mHeaderBar.setLayoutDirection(res.getConfiguration().getLayoutDirection()); - mHeaderBar.onConfigurationChanged(); - mHeaderBar.forceLayout(); - mHeaderBar.measure( - MeasureSpec.makeMeasureSpec(mHeaderBar.getMeasuredWidth(), MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(mHeaderBar.getMeasuredHeight(), MeasureSpec.EXACTLY)); } /** @@ -586,6 +575,11 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener 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); + + LayoutInflater inflater = LayoutInflater.from(mContext); + mHeaderBar = (TaskViewHeader) inflater.inflate(R.layout.recents_task_view_header, + null, false); + mHeaderBar.setLayoutDirection(res.getConfiguration().getLayoutDirection()); } /** diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java index fce7f9d51ea49..571c0f67e18e9 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java @@ -344,19 +344,6 @@ public class TaskStackLayoutAlgorithm { mContext = context; mCb = cb; mFreeformLayoutAlgorithm = new FreeformWorkspaceLayoutAlgorithm(context); - mMinMargin = res.getDimensionPixelSize(R.dimen.recents_layout_min_margin); - mBaseTopMargin = getDimensionForDevice(context, - R.dimen.recents_layout_top_margin_phone, - R.dimen.recents_layout_top_margin_tablet, - R.dimen.recents_layout_top_margin_tablet_xlarge); - mBaseSideMargin = getDimensionForDevice(context, - R.dimen.recents_layout_side_margin_phone, - R.dimen.recents_layout_side_margin_tablet, - R.dimen.recents_layout_side_margin_tablet_xlarge); - mBaseBottomMargin = res.getDimensionPixelSize(R.dimen.recents_layout_bottom_margin); - mFreeformStackGap = - res.getDimensionPixelSize(R.dimen.recents_freeform_layout_bottom_margin); - reloadOnConfigurationChange(context); } @@ -390,6 +377,18 @@ public class TaskStackLayoutAlgorithm { R.dimen.recents_layout_initial_bottom_offset_tablet, R.dimen.recents_layout_initial_bottom_offset_tablet); mFreeformLayoutAlgorithm.reloadOnConfigurationChange(context); + mMinMargin = res.getDimensionPixelSize(R.dimen.recents_layout_min_margin); + mBaseTopMargin = getDimensionForDevice(context, + R.dimen.recents_layout_top_margin_phone, + R.dimen.recents_layout_top_margin_tablet, + R.dimen.recents_layout_top_margin_tablet_xlarge); + mBaseSideMargin = getDimensionForDevice(context, + R.dimen.recents_layout_side_margin_phone, + R.dimen.recents_layout_side_margin_tablet, + R.dimen.recents_layout_side_margin_tablet_xlarge); + mBaseBottomMargin = res.getDimensionPixelSize(R.dimen.recents_layout_bottom_margin); + mFreeformStackGap = + res.getDimensionPixelSize(R.dimen.recents_freeform_layout_bottom_margin); } /**