use of com.android.settings.datetime.timezone.model.FilteredCountryTimeZones in project android_packages_apps_Settings by omnirom.
the class TimeZoneSettings method onZonePickerRequestResult.
private void onZonePickerRequestResult(TimeZoneData timeZoneData, Intent data) {
String regionId = data.getStringExtra(RegionSearchPicker.EXTRA_RESULT_REGION_ID);
String tzId = data.getStringExtra(RegionZonePicker.EXTRA_RESULT_TIME_ZONE_ID);
// Ignore the result if user didn't change the region or time zone.
if (Objects.equals(regionId, use(RegionPreferenceController.class).getRegionId()) && Objects.equals(tzId, mSelectedTimeZoneId)) {
return;
}
FilteredCountryTimeZones countryTimeZones = timeZoneData.lookupCountryTimeZones(regionId);
if (countryTimeZones == null || !countryTimeZones.getPreferredTimeZoneIds().contains(tzId)) {
Log.e(TAG, "Unknown time zone id is selected: " + tzId);
return;
}
mSelectedTimeZoneId = tzId;
setDisplayedRegion(regionId);
setDisplayedTimeZoneInfo(regionId, mSelectedTimeZoneId);
saveTimeZone(regionId, mSelectedTimeZoneId);
// Switch to the region mode if the user switching from the fixed offset
setSelectByRegion(true);
}
use of com.android.settings.datetime.timezone.model.FilteredCountryTimeZones in project android_packages_apps_Settings by omnirom.
the class RegionZonePicker method getAllTimeZoneInfos.
@Override
public List<TimeZoneInfo> getAllTimeZoneInfos(TimeZoneData timeZoneData) {
if (getArguments() == null) {
Log.e(TAG, "getArguments() == null");
getActivity().finish();
return Collections.emptyList();
}
String regionId = getArguments().getString(EXTRA_REGION_ID);
FilteredCountryTimeZones filteredCountryTimeZones = timeZoneData.lookupCountryTimeZones(regionId);
if (filteredCountryTimeZones == null) {
Log.e(TAG, "region id is not valid: " + regionId);
getActivity().finish();
return Collections.emptyList();
}
// unlikely to be changed drastically.
return getRegionTimeZoneInfo(filteredCountryTimeZones.getPreferredTimeZoneIds());
}
use of com.android.settings.datetime.timezone.model.FilteredCountryTimeZones in project android_packages_apps_Settings by omnirom.
the class RegionSearchPicker method onListItemClick.
private void onListItemClick(RegionItem item) {
final String regionId = item.getId();
final FilteredCountryTimeZones countryTimeZones = mTimeZoneData.lookupCountryTimeZones(regionId);
final Activity activity = getActivity();
if (countryTimeZones == null || countryTimeZones.getPreferredTimeZoneIds().isEmpty()) {
Log.e(TAG, "Region has no time zones: " + regionId);
activity.setResult(Activity.RESULT_CANCELED);
activity.finish();
return;
}
List<String> timeZoneIds = countryTimeZones.getPreferredTimeZoneIds();
// Choose the time zone associated the region if there is only one time zone in that region
if (timeZoneIds.size() == 1) {
final Intent resultData = new Intent().putExtra(EXTRA_RESULT_REGION_ID, regionId).putExtra(EXTRA_RESULT_TIME_ZONE_ID, timeZoneIds.get(0));
getActivity().setResult(Activity.RESULT_OK, resultData);
getActivity().finish();
} else {
// Launch the zone picker and let the user choose a time zone from the list of
// time zones associated with the region.
final Bundle args = new Bundle();
args.putString(RegionZonePicker.EXTRA_REGION_ID, regionId);
new SubSettingLauncher(getContext()).setDestination(RegionZonePicker.class.getCanonicalName()).setArguments(args).setSourceMetricsCategory(getMetricsCategory()).setResultListener(this, REQUEST_CODE_ZONE_PICKER).launch();
}
}
Aggregations