Add a header view to show the country in RegionZonePicker
Extra fixes in this CL - Minor string update in time zone picker. Use date_time_search_region string in search bar, and date_time_set_timezone_title string for lower case "zone". - Fixed b/76893139. Remove the unnecessary top padding in RecyclerView. Create a new layout file time_zone_items_list.xml without the padding. - Add missing return statement when region ISO code is invalid in RegionZonePicker#getAllTimeZoneInfos Bug: 76209571 Bug: 76893139 Test: m RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.datetime.timezone Test: Verified that the strings are updated in the UI Change-Id: I1fb3e2abf80da3cb53cfbc3363bbe46e40a6ac22
This commit is contained in:
@@ -23,6 +23,7 @@ import android.content.res.Resources;
|
||||
import android.icu.text.DateFormat;
|
||||
import android.icu.text.SimpleDateFormat;
|
||||
import android.icu.util.Calendar;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.datetime.timezone.model.TimeZoneData;
|
||||
@@ -47,10 +48,17 @@ public abstract class BaseTimeZoneInfoPicker extends BaseTimeZonePicker {
|
||||
@Override
|
||||
protected BaseTimeZoneAdapter createAdapter(TimeZoneData timeZoneData) {
|
||||
mAdapter = new ZoneAdapter(getContext(), getAllTimeZoneInfos(timeZoneData),
|
||||
this::onListItemClick, getLocale());
|
||||
this::onListItemClick, getLocale(), getHeaderText());
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the text shown in the header, or null to show no header.
|
||||
*/
|
||||
protected @Nullable CharSequence getHeaderText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void onListItemClick(TimeZoneInfoItem item) {
|
||||
final TimeZoneInfo timeZoneInfo = item.mTimeZoneInfo;
|
||||
getActivity().setResult(Activity.RESULT_OK, prepareResultData(timeZoneInfo));
|
||||
@@ -66,9 +74,11 @@ public abstract class BaseTimeZoneInfoPicker extends BaseTimeZonePicker {
|
||||
protected static class ZoneAdapter extends BaseTimeZoneAdapter<TimeZoneInfoItem> {
|
||||
|
||||
public ZoneAdapter(Context context, List<TimeZoneInfo> timeZones,
|
||||
OnListItemClickListener<TimeZoneInfoItem> onListItemClickListener, Locale locale) {
|
||||
OnListItemClickListener<TimeZoneInfoItem> onListItemClickListener, Locale locale,
|
||||
CharSequence headerText) {
|
||||
super(createTimeZoneInfoItems(context, timeZones, locale),
|
||||
onListItemClickListener, locale, true /* showItemSummary */);
|
||||
onListItemClickListener, locale, true /* showItemSummary */,
|
||||
headerText /* headerText */);
|
||||
}
|
||||
|
||||
private static List<TimeZoneInfoItem> createTimeZoneInfoItems(Context context,
|
||||
|
Reference in New Issue
Block a user