From afe8fadc150b024ace70b0d8966d64f052604a9c Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Tue, 9 Nov 2021 16:11:58 -0800 Subject: [PATCH] Add FeatureFlag to enable two line label inside all apps Bug: 201388851 Test: screenshot on the bug Change-Id: Id01d6f9f9e25b98cad8368ac0faf671addf793f8 --- res/layout/all_apps_icon_twoline.xml | 25 +++++++++++++++++++ res/values/dimens.xml | 3 ++- .../launcher3/allapps/AllAppsGridAdapter.java | 11 +++++++- .../launcher3/config/FeatureFlags.java | 3 +++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 res/layout/all_apps_icon_twoline.xml diff --git a/res/layout/all_apps_icon_twoline.xml b/res/layout/all_apps_icon_twoline.xml new file mode 100644 index 0000000000..54c714734c --- /dev/null +++ b/res/layout/all_apps_icon_twoline.xml @@ -0,0 +1,25 @@ + + + + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 4d137c84b5..f685f01329 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -104,8 +104,9 @@ 2dp 128dp 150dp - 8dp + 6dp + 2dp 2dp diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index 874fe80ef0..6951562cde 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -41,6 +41,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.BubbleTextView; import com.android.launcher3.R; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.util.PackageManagerHelper; @@ -273,6 +274,8 @@ public class AllAppsGridAdapter extends // The intent to send off to the market app, updated each time the search query changes. private Intent mMarketSearchIntent; + private final int mExtraHeight; + public AllAppsGridAdapter(BaseDraggingActivity launcher, LayoutInflater inflater, AlphabeticalAppsList apps, BaseAdapterProvider[] adapterProviders) { Resources res = launcher.getResources(); @@ -288,6 +291,7 @@ public class AllAppsGridAdapter extends mAdapterProviders = adapterProviders; setAppsPerRow(mLauncher.getDeviceProfile().numShownAllAppsColumns); + mExtraHeight = launcher.getResources().getDimensionPixelSize(R.dimen.all_apps_height_extra); } public void setAppsPerRow(int appsPerRow) { @@ -347,14 +351,19 @@ public class AllAppsGridAdapter extends public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { switch (viewType) { case VIEW_TYPE_ICON: + int layout = !FeatureFlags.ENABLE_TWOLINE_ALLAPPS.get() ? R.layout.all_apps_icon + : R.layout.all_apps_icon_twoline; BubbleTextView icon = (BubbleTextView) mLayoutInflater.inflate( - R.layout.all_apps_icon, parent, false); + layout, parent, false); icon.setLongPressTimeoutFactor(1f); icon.setOnFocusChangeListener(mIconFocusListener); icon.setOnClickListener(mOnIconClickListener); icon.setOnLongClickListener(mOnIconLongClickListener); // Ensure the all apps icon height matches the workspace icons in portrait mode. icon.getLayoutParams().height = mLauncher.getDeviceProfile().allAppsCellHeightPx; + if (FeatureFlags.ENABLE_TWOLINE_ALLAPPS.get()) { + icon.getLayoutParams().height += mExtraHeight; + } return new ViewHolder(icon); case VIEW_TYPE_EMPTY_SEARCH: return new ViewHolder(mLayoutInflater.inflate(R.layout.all_apps_empty_search, diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 13583874b9..f298ad58b6 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -94,6 +94,9 @@ public final class FeatureFlags { public static final BooleanFlag ENABLE_ONE_SEARCH = new DeviceFlag("ENABLE_ONE_SEARCH", false, "Use homescreen search box to complete allApps searches"); + public static final BooleanFlag ENABLE_TWOLINE_ALLAPPS = getDebugFlag( + "ENABLE_TWOLINE_ALLAPPS", false, "Enables two line label inside all apps."); + public static final BooleanFlag ENABLE_DEVICE_SEARCH_PERFORMANCE_LOGGING = new DeviceFlag( "ENABLE_DEVICE_SEARCH_PERFORMANCE_LOGGING", true, "Allows on device search in all apps logging");