[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
diff --git a/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java
index 5e29df1..b8c80f3 100644
--- a/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java
+++ b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java
@@ -24,6 +24,8 @@
 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 @@
     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 @@
             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 @@
         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 @@
 
     @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;
     }
 }