Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0cdbe189 authored by Joachim Sauer's avatar Joachim Sauer
Browse files

New manual time zone picker.

This implements a new manual time zone picker that allows selection of a
time zone for a selected country. It also allows selecting a fixed
offset time zone (most importantly Etc/UTC, which is a frequently
requested feature).

The new time zone picker is currently behind a feature flag
(settings_zone_picker_v2), which is disabled by default.

Test: manual
Test: SettingsFunctionalTests
Test: SettingsRobotTests
Bug: 62255208
Change-Id: I89c5a04bcb562b6facf5f31a8aa4ad1cdd51ab10
parent 0bed37a0
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
<!--
    Copyright (C) 2017 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/tz_region_spinner_layout"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/actionBarSize"
        android:background="?android:attr/colorAccent"
        android:gravity="center_vertical"
        android:paddingEnd="@dimen/switchbar_subsettings_margin_end"
        android:orientation="horizontal">

        <Spinner
            android:id="@+id/tz_region_spinner"
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:paddingStart="64dp"
            android:layout_weight="1"
            android:background="@drawable/app_filter_spinner_background"/>
    </LinearLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/tz_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>
+62 −0
Original line number Diff line number Diff line
<!--
    Copyright (C) 2017 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?android:attr/selectableItemBackground"
    android:gravity="center_vertical"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:orientation="vertical"
    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">

    <TextView
        android:id="@+id/tz_item_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="TimeZone name"
        android:textAppearance="?android:attr/textAppearanceListItem" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/tz_item_details"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textAppearance="?android:attr/textAppearanceListItemSecondary"
            android:textColor="?android:attr/textColorSecondary" />

        <TextView
            android:id="@+id/tz_item_time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAlignment="viewEnd"
            android:textAppearance="?android:attr/textAppearanceListItemSecondary"
            android:textColor="?android:attr/textColorSecondary" />
    </LinearLayout>

    <TextView
        android:id="@+id/tz_item_dst"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceListItemSecondary"
        android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
@@ -752,6 +752,17 @@
    <string name="zone_list_menu_sort_alphabetically">Sort alphabetically</string>
    <!-- Menu item on Select time zone screen -->
    <string name="zone_list_menu_sort_by_timezone">Sort by time zone</string>
    <!-- Label describing when a given time zone changes to DST or standard time -->
    <string name="zone_change_to_from_dst"><xliff:g id="time_type" example="Pacific Summer Time">%1$s</xliff:g> starts on <xliff:g id="transition_date" example="Mar 11 2018">%2$s</xliff:g>.</string>
    <!-- Describes the time type "daylight savings time" (used in zone_change_to_from_dst, when no zone specific name is available) -->
    <string name="zone_time_type_dst">Daylight savings time</string>
    <!-- Describes the time type "standard time" (used in zone_change_to_from_dst, when no zone specific name is available) -->
    <string name="zone_time_type_standard">Standard time</string>
    <!-- The menu item to switch to selecting a time zone by region (default) -->
    <string name="zone_menu_by_region">Time zone by region</string>
    <!-- The menu item to switch to selecting a time zone with a fixed offset (such as UTC or GMT+0200) -->
    <string name="zone_menu_by_offset">Fixed offset time zones</string>
    <!-- Title string shown above DatePicker, letting a user select system date
         [CHAR LIMIT=20] -->
    <string name="date_picker_title">Date</string>
+1 −0
Original line number Diff line number Diff line
@@ -26,4 +26,5 @@ public class FeatureFlags {
    public static final String BATTERY_SETTINGS_V2 = "settings_battery_v2";
    public static final String BATTERY_DISPLAY_APP_LIST = "settings_battery_display_app_list";
    public static final String SECURITY_SETTINGS_V2 = "settings_security_settings_v2";
    public static final String ZONE_PICKER_V2 = "settings_zone_picker_v2";
}
+8 −0
Original line number Diff line number Diff line
@@ -20,7 +20,10 @@ import android.content.Context;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;

import android.util.FeatureFlagUtils;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.datetime.timezone.ZonePicker;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.datetime.ZoneGetter;
@@ -33,11 +36,13 @@ public class TimeZonePreferenceController extends AbstractPreferenceController
    private static final String KEY_TIMEZONE = "timezone";

    private final AutoTimeZonePreferenceController mAutoTimeZonePreferenceController;
    private final boolean mZonePickerV2;

    public TimeZonePreferenceController(Context context,
            AutoTimeZonePreferenceController autoTimeZonePreferenceController) {
        super(context);
        mAutoTimeZonePreferenceController = autoTimeZonePreferenceController;
        mZonePickerV2 = FeatureFlagUtils.isEnabled(mContext, FeatureFlags.ZONE_PICKER_V2);
    }

    @Override
@@ -45,6 +50,9 @@ public class TimeZonePreferenceController extends AbstractPreferenceController
        if (!(preference instanceof RestrictedPreference)) {
            return;
        }
        if (mZonePickerV2) {
            preference.setFragment(ZonePicker.class.getName());
        }
        preference.setSummary(getTimeZoneOffsetAndName());
        if( !((RestrictedPreference) preference).isDisabledByAdmin()) {
            preference.setEnabled(!mAutoTimeZonePreferenceController.isEnabled());
Loading