[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
This commit is contained in:
@@ -24,6 +24,8 @@ import android.provider.Settings;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
|
||||||
import com.android.internal.app.LocalePickerWithRegion;
|
import com.android.internal.app.LocalePickerWithRegion;
|
||||||
import com.android.internal.app.LocaleStore;
|
import com.android.internal.app.LocaleStore;
|
||||||
import com.android.settings.R;
|
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 TAG = LocalePickerWithRegionActivity.class.getSimpleName();
|
||||||
private static final String PARENT_FRAGMENT_NAME = "localeListEditor";
|
private static final String PARENT_FRAGMENT_NAME = "localeListEditor";
|
||||||
|
|
||||||
|
private LocalePickerWithRegion mSelector;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -49,7 +53,7 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
|||||||
Log.i(TAG, "Has explicit locales : " + explicitLocales);
|
Log.i(TAG, "Has explicit locales : " + explicitLocales);
|
||||||
}
|
}
|
||||||
|
|
||||||
final LocalePickerWithRegion selector = LocalePickerWithRegion.createLanguagePicker(
|
mSelector = LocalePickerWithRegion.createLanguagePicker(
|
||||||
this,
|
this,
|
||||||
LocalePickerWithRegionActivity.this,
|
LocalePickerWithRegionActivity.this,
|
||||||
false /* translate only */,
|
false /* translate only */,
|
||||||
@@ -59,7 +63,7 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
|||||||
getFragmentManager()
|
getFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||||
.replace(R.id.content_frame, selector)
|
.replace(R.id.content_frame, mSelector)
|
||||||
.addToBackStack(PARENT_FRAGMENT_NAME)
|
.addToBackStack(PARENT_FRAGMENT_NAME)
|
||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
@@ -102,13 +106,17 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||||
|
// To prevent a large space on tool bar.
|
||||||
mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
|
mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
|
||||||
|
// To prevent user can expand the collpasing tool bar view.
|
||||||
|
ViewCompat.setNestedScrollingEnabled(mSelector.getListView(), false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||||
mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
|
mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
|
||||||
|
ViewCompat.setNestedScrollingEnabled(mSelector.getListView(), true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user