Search in sources :

Example 1 with FilteredCountryTimeZones

use of com.android.settings.datetime.timezone.model.FilteredCountryTimeZones in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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.getTimeZoneIds().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);
}
Also used : FilteredCountryTimeZones(com.android.settings.datetime.timezone.model.FilteredCountryTimeZones)

Example 2 with FilteredCountryTimeZones

use of com.android.settings.datetime.timezone.model.FilteredCountryTimeZones in project android_packages_apps_Settings by omnirom.

the class TimeZoneSettings method setDisplayedTimeZoneInfo.

private void setDisplayedTimeZoneInfo(String regionId, String tzId) {
    final TimeZoneInfo tzInfo = tzId == null ? null : mTimeZoneInfoFormatter.format(tzId);
    final FilteredCountryTimeZones countryTimeZones = mTimeZoneData.lookupCountryTimeZones(regionId);
    use(RegionZonePreferenceController.class).setTimeZoneInfo(tzInfo);
    // Only clickable when the region has more than 1 time zones or no time zone is selected.
    use(RegionZonePreferenceController.class).setClickable(tzInfo == null || (countryTimeZones != null && countryTimeZones.getPreferredTimeZoneIds().size() > 1));
    use(TimeZoneInfoPreferenceController.class).setTimeZoneInfo(tzInfo);
    updatePreferenceStates();
}
Also used : FilteredCountryTimeZones(com.android.settings.datetime.timezone.model.FilteredCountryTimeZones)

Example 3 with FilteredCountryTimeZones

use of com.android.settings.datetime.timezone.model.FilteredCountryTimeZones in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class TimeZoneSettings method setDisplayedTimeZoneInfo.

private void setDisplayedTimeZoneInfo(String regionId, String tzId) {
    final TimeZoneInfo tzInfo = tzId == null ? null : mTimeZoneInfoFormatter.format(tzId);
    final FilteredCountryTimeZones countryTimeZones = mTimeZoneData.lookupCountryTimeZones(regionId);
    use(RegionZonePreferenceController.class).setTimeZoneInfo(tzInfo);
    // Only clickable when the region has more than 1 time zones or no time zone is selected.
    use(RegionZonePreferenceController.class).setClickable(tzInfo == null || (countryTimeZones != null && countryTimeZones.getTimeZoneIds().size() > 1));
    use(TimeZoneInfoPreferenceController.class).setTimeZoneInfo(tzInfo);
    updatePreferenceStates();
}
Also used : FilteredCountryTimeZones(com.android.settings.datetime.timezone.model.FilteredCountryTimeZones)

Example 4 with FilteredCountryTimeZones

use of com.android.settings.datetime.timezone.model.FilteredCountryTimeZones in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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.getTimeZoneIds());
}
Also used : FilteredCountryTimeZones(com.android.settings.datetime.timezone.model.FilteredCountryTimeZones)

Example 5 with FilteredCountryTimeZones

use of com.android.settings.datetime.timezone.model.FilteredCountryTimeZones in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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.getTimeZoneIds().isEmpty()) {
        Log.e(TAG, "Region has no time zones: " + regionId);
        activity.setResult(Activity.RESULT_CANCELED);
        activity.finish();
        return;
    }
    List<String> timeZoneIds = countryTimeZones.getTimeZoneIds();
    // 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();
    }
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle) Activity(android.app.Activity) Intent(android.content.Intent) FilteredCountryTimeZones(com.android.settings.datetime.timezone.model.FilteredCountryTimeZones)

Aggregations

FilteredCountryTimeZones (com.android.settings.datetime.timezone.model.FilteredCountryTimeZones)8 Activity (android.app.Activity)2 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)2