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:
@@ -18,7 +18,10 @@ package com.android.settings.datetime.timezone;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.icu.text.Collator;
|
||||
import android.icu.text.LocaleDisplayNames;
|
||||
import android.icu.util.TimeZone;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -43,8 +46,10 @@ public class RegionZonePicker extends BaseTimeZoneInfoPicker {
|
||||
public static final String EXTRA_REGION_ID =
|
||||
"com.android.settings.datetime.timezone.region_id";
|
||||
|
||||
private @Nullable String mRegionName;
|
||||
|
||||
public RegionZonePicker() {
|
||||
super(R.string.date_time_select_zone, R.string.search_settings, true, false);
|
||||
super(R.string.date_time_set_timezone_title, R.string.search_settings, true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +57,21 @@ public class RegionZonePicker extends BaseTimeZoneInfoPicker {
|
||||
return MetricsProto.MetricsEvent.SETTINGS_ZONE_PICKER_TIME_ZONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final LocaleDisplayNames localeDisplayNames = LocaleDisplayNames.getInstance(getLocale());
|
||||
final String regionId =
|
||||
getArguments() == null ? null : getArguments().getString(EXTRA_REGION_ID);
|
||||
mRegionName = regionId == null ? null : localeDisplayNames.regionDisplayName(regionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable CharSequence getHeaderText() {
|
||||
return mRegionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the extra region id into the result.
|
||||
*/
|
||||
@@ -67,6 +87,7 @@ public class RegionZonePicker extends BaseTimeZoneInfoPicker {
|
||||
if (getArguments() == null) {
|
||||
Log.e(TAG, "getArguments() == null");
|
||||
getActivity().finish();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String regionId = getArguments().getString(EXTRA_REGION_ID);
|
||||
|
||||
@@ -75,6 +96,7 @@ public class RegionZonePicker extends BaseTimeZoneInfoPicker {
|
||||
if (filteredCountryTimeZones == null) {
|
||||
Log.e(TAG, "region id is not valid: " + regionId);
|
||||
getActivity().finish();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// It could be a timely operations if there are many time zones. A region in time zone data
|
||||
|
Reference in New Issue
Block a user