From 7026760615c030afb200828c972afe434f87f57f Mon Sep 17 00:00:00 2001 From: Zoey Chen Date: Tue, 18 Apr 2023 17:13:09 +0000 Subject: [PATCH] [Settings] Remove the large space when searching language Don't expand the tool bar when users search the language because they will see a large space on the top. Bug: 254387685 Test: local test Change-Id: I52fbf4be47885ea6c7d2b6abb75db99c1690edca --- .../localepicker/LocalePickerWithRegionActivity.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java index 5e29df1d278..b8c80f33d13 100644 --- a/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java +++ b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java @@ -24,6 +24,8 @@ import android.provider.Settings; import android.util.Log; import android.view.MenuItem; +import androidx.core.view.ViewCompat; + import com.android.internal.app.LocalePickerWithRegion; import com.android.internal.app.LocaleStore; import com.android.settings.R; @@ -35,6 +37,8 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity private static final String TAG = LocalePickerWithRegionActivity.class.getSimpleName(); private static final String PARENT_FRAGMENT_NAME = "localeListEditor"; + private LocalePickerWithRegion mSelector; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -49,7 +53,7 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity Log.i(TAG, "Has explicit locales : " + explicitLocales); } - final LocalePickerWithRegion selector = LocalePickerWithRegion.createLanguagePicker( + mSelector = LocalePickerWithRegion.createLanguagePicker( this, LocalePickerWithRegionActivity.this, false /* translate only */, @@ -59,7 +63,7 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity getFragmentManager() .beginTransaction() .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) - .replace(R.id.content_frame, selector) + .replace(R.id.content_frame, mSelector) .addToBackStack(PARENT_FRAGMENT_NAME) .commit(); } @@ -102,13 +106,17 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity @Override public boolean onMenuItemActionExpand(MenuItem item) { + // To prevent a large space on tool bar. mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/); + // To prevent user can expand the collpasing tool bar view. + ViewCompat.setNestedScrollingEnabled(mSelector.getListView(), false); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/); + ViewCompat.setNestedScrollingEnabled(mSelector.getListView(), true); return true; } }