From e09177c0813476478b210f82d703adcf5a853506 Mon Sep 17 00:00:00 2001 From: Mill Chen Date: Fri, 3 Feb 2023 16:30:44 +0800 Subject: [PATCH] Remove empty space when searching language list Collasping the tool bar when search menu item is invoked. Bug: 266383101 Test: visual test, open the page and the large empty space will be collapsed when searching language list. Change-Id: I6548d3d572082a66778cb27d9333dff760619dab --- .../LocalePickerWithRegionActivity.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java index 9c7e6370db3..5e29df1d278 100644 --- a/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java +++ b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java @@ -31,7 +31,7 @@ import com.android.settings.core.SettingsBaseActivity; /** A activity to show the locale picker page. */ public class LocalePickerWithRegionActivity extends SettingsBaseActivity - implements LocalePickerWithRegion.LocaleSelectedListener { + implements LocalePickerWithRegion.LocaleSelectedListener, MenuItem.OnActionExpandListener { private static final String TAG = LocalePickerWithRegionActivity.class.getSimpleName(); private static final String PARENT_FRAGMENT_NAME = "localeListEditor"; @@ -53,7 +53,9 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity this, LocalePickerWithRegionActivity.this, false /* translate only */, - explicitLocales); + explicitLocales, + null /* appPackageName */, + this); getFragmentManager() .beginTransaction() .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) @@ -97,5 +99,17 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity return Settings.Global.getInt( getContentResolver(), Settings.Global.DEVICE_DEMO_MODE, 0) == 1; } + + @Override + public boolean onMenuItemActionExpand(MenuItem item) { + mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/); + return true; + } + + @Override + public boolean onMenuItemActionCollapse(MenuItem item) { + mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/); + return true; + } }