summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommy Webb <tommy@calyxinstitute.org>2023-01-16 13:52:41 -0500
committeralk3pInjection <webmaster@raspii.tech>2023-04-22 01:50:12 +0800
commit89b32f15a977aaad4ef8fe3286265e6fda25ae50 (patch)
treeb53533f544deba5177dacf39af6c1f1d3d8e2eaa
parentbe9463d3940b23ec460a7407bb3fb37d878fbbf1 (diff)
Launcher3: Fix All Apps header protection and spacing again
Redone, again. This time, many comments added. Compared to I586f7332, this primarily results in some fixes for the floating header row(s) (AiAi prediction row) if present. Change-Id: Ib0f383fb89a6847fccbcc96d13b051983d76f0c5
-rw-r--r--res/values/dimens.xml12
-rw-r--r--src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java9
-rw-r--r--src/com/android/launcher3/allapps/BaseAllAppsContainerView.java16
-rw-r--r--src/com/android/launcher3/allapps/FloatingHeaderView.java8
4 files changed, 32 insertions, 13 deletions
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 4d2e1b7c6d..e2800a7d63 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -106,7 +106,12 @@
<dimen name="all_apps_search_bar_field_height">48dp</dimen>
<!-- all_apps_search_bar_field_height / 2 -->
<dimen name="all_apps_search_bar_content_overlap">24dp</dimen>
- <dimen name="all_apps_search_bar_bottom_padding">30dp</dimen>
+ <!-- affects padding above apps lists when tabs and floating header rows are not visible -->
+ <!-- (always affects padding above search results) -->
+ <dimen name="all_apps_search_bar_bottom_padding">24dp</dimen>
+ <!-- margin adjustment for layout relative to bottom of search container -->
+ <!-- if the search container is obscuring things, try adjusting this -->
+ <dimen name="all_apps_search_bar_bottom_adjustment">-6dp</dimen>
<dimen name="all_apps_empty_search_message_top_offset">40dp</dimen>
<dimen name="all_apps_header_pill_height">48dp</dimen>
<dimen name="all_apps_header_pill_corner_radius">12dp</dimen>
@@ -116,7 +121,10 @@
<dimen name="all_apps_header_top_padding">36dp</dimen>
<!-- Additional top padding to add when Floating Searchbar is enabled. -->
<dimen name="all_apps_additional_top_padding_floating_search">16dp</dimen>
- <dimen name="all_apps_header_bottom_padding">14dp</dimen>
+ <!-- influences header protection drawn height below personal/work tabs -->
+ <!-- if app icons are appearing above the protection rectangle, or if they are shifted below
+ it and cropped at the top, try adjusting this -->
+ <dimen name="all_apps_header_bottom_padding">10dp</dimen>
<dimen name="all_apps_header_top_adjustment">6dp</dimen>
<dimen name="all_apps_header_bottom_adjustment">4dp</dimen>
<dimen name="all_apps_work_profile_tab_footer_top_padding">16dp</dimen>
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index fd6bdefb60..792f25e816 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -271,13 +271,15 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
}
RelativeLayout.LayoutParams layoutParams = (LayoutParams) v.getLayoutParams();
- layoutParams.addRule(RelativeLayout.ALIGN_TOP, R.id.search_container_all_apps);
+ layoutParams.addRule(RelativeLayout.BELOW, R.id.search_container_all_apps);
int topMargin = getContext().getResources().getDimensionPixelSize(
- R.dimen.all_apps_header_top_margin);
+ R.dimen.all_apps_search_bar_bottom_adjustment);
if (includeTabsMargin) {
topMargin += getContext().getResources().getDimensionPixelSize(
- R.dimen.all_apps_header_pill_height);
+ R.dimen.all_apps_header_pill_height)
+ + getContext().getResources().getDimensionPixelSize(
+ R.dimen.all_apps_tabs_margin_top);
}
layoutParams.topMargin = topMargin;
}
@@ -314,6 +316,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
layoutParams.removeRule(RelativeLayout.ABOVE);
layoutParams.removeRule(RelativeLayout.ALIGN_TOP);
layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_TOP);
+ layoutParams.removeRule(RelativeLayout.BELOW);
}
@Override
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
index 00e89bacc5..f2502b6a6b 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
@@ -96,6 +96,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
public static final float FLING_VELOCITY_MULTIPLIER = 1200f;
// Render the header protection at all times to debug clipping issues.
+ // This is useful enough to warrant the comment you are reading now to point it out!
private static final boolean DEBUG_HEADER_PROTECTION = false;
private final Paint mHeaderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
@@ -751,13 +752,22 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
tabsHidden);
int padding = mHeader.getMaxTranslation();
- mAH.forEach(adapterHolder -> {
- adapterHolder.mPadding.top = padding;
+ for (int i = 0; i < mAH.size(); i++) {
+ final AdapterHolder adapterHolder = mAH.get(i);
+ // Search and other adapters need to be handled a bit differently; otherwise, when
+ // when leaving search, the All Apps view may be noticeably shifted downward because
+ // its padding was unnecessarily impacted, and never restored, upon entering search.
+ if (i != AdapterHolder.SEARCH && !tabsHidden && mHeader.getFloatingRowsHeight() == 0) {
+ // Only the Search adapter needs padding when there are tabs but no floating rows.
+ adapterHolder.mPadding.top = 0;
+ } else {
+ adapterHolder.mPadding.top = padding;
+ }
adapterHolder.applyPadding();
if (adapterHolder.mRecyclerView != null) {
adapterHolder.mRecyclerView.scrollToTop();
}
- });
+ }
}
public boolean isHeaderVisible() {
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index c18f9e1884..051955b56a 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -225,7 +225,6 @@ public class FloatingHeaderView extends LinearLayout implements
for (FloatingHeaderRow row : mAllRows) {
row.setup(this, mAllRows, tabsHidden);
}
- updateExpectedHeight();
mTabsHidden = tabsHidden;
mTabLayout.setVisibility(tabsHidden ? View.GONE : View.VISIBLE);
@@ -250,6 +249,8 @@ public class FloatingHeaderView extends LinearLayout implements
rvType == AdapterHolder.MAIN ? mMainRV
: rvType == AdapterHolder.WORK ? mWorkRV : mSearchRV;
mCurrentRV.addOnScrollListener(mOnScrollListener);
+
+ updateExpectedHeight();
}
private void updateExpectedHeight() {
@@ -259,10 +260,7 @@ public class FloatingHeaderView extends LinearLayout implements
return;
}
mMaxTranslation += mFloatingRowsHeight;
- if (!mTabsHidden) {
- mMaxTranslation += mTabsAdditionalPaddingBottom
- + getResources().getDimensionPixelSize(R.dimen.all_apps_tabs_margin_top);
- }
+ // No need for mMaxTranslation to be any taller now that we align below the header.
}
int getMaxTranslation() {