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

Commit 999e4f44 authored by Victor Chang's avatar Victor Chang Committed by Android (Google) Code Review
Browse files

Merge "New time zone picker page" into pi-dev

parents ef6eb853 d5adf42c
Loading
Loading
Loading
Loading
+42 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 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.
-->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:key="time_zone_settings_screen"
    android:title="@string/date_time_set_timezone">

    <PreferenceCategory
        android:key="time_zone_region_preference_category">
        <com.android.settingslib.RestrictedPreference
            android:key="region"
            android:title="@string/date_time_select_region"
            android:summary="@string/summary_placeholder" />
        <com.android.settingslib.RestrictedPreference
            android:key="region_zone"
            android:title="@string/date_time_select_zone"
            android:summary="@string/summary_placeholder" />
        <com.android.settingslib.widget.FooterPreference/>
    </PreferenceCategory>

    <PreferenceCategory
        android:key="time_zone_fixed_offset_preference_category">
        <com.android.settingslib.RestrictedPreference
            android:key="fixed_offset"
            android:title="@string/date_time_select_fixed_offset_time_zones"
            android:summary="@string/summary_placeholder"/>
    </PreferenceCategory>
</PreferenceScreen>
+51 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2018 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.
 */

package com.android.settings.datetime.timezone;

import android.content.Context;
import android.support.v7.preference.Preference;

import com.android.settings.core.BasePreferenceController;

import com.google.common.base.Objects;

public abstract class BaseTimeZonePreferenceController extends BasePreferenceController {
    private OnPreferenceClickListener mOnClickListener;

    protected BaseTimeZonePreferenceController(Context context, String preferenceKey) {
        super(context, preferenceKey);
    }

    @Override
    public int getAvailabilityStatus() {
        return AVAILABLE;
    }

    @Override
    public boolean handlePreferenceTreeClick(Preference preference) {
        if (mOnClickListener == null || !Objects.equal(getPreferenceKey(), preference.getKey())) {
            return false;
        }

        mOnClickListener.onClick();
        return true;
    }

    public void setOnClickListener(OnPreferenceClickListener listener) {
        mOnClickListener = listener;
    }
}
+46 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2018 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.
 */

package com.android.settings.datetime.timezone;

import android.content.Context;
import android.support.v7.preference.Preference;

public class FixedOffsetPreferenceController extends BaseTimeZonePreferenceController {

    private static final String PREFERENCE_KEY = "fixed_offset";

    private TimeZoneInfo mTimeZoneInfo;

    public FixedOffsetPreferenceController(Context context) {
        super(context, PREFERENCE_KEY);
    }

    @Override
    public CharSequence getSummary() {
        // This is a Spannable object, which contains TTS span. It shouldn't be converted to String.
        return mTimeZoneInfo == null ? "" : mTimeZoneInfo.getGmtOffset();
    }

    public void setTimeZoneInfo(TimeZoneInfo timeZoneInfo) {
        mTimeZoneInfo = timeZoneInfo;
    }

    public TimeZoneInfo getTimeZoneInfo() {
        return mTimeZoneInfo;
    }
}
+24 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2018 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.
 */

package com.android.settings.datetime.timezone;

/**
 * Callback when a preference is clicked in {@class TimeZoneSettings}
 */
public interface OnPreferenceClickListener {
    void onClick();
}
+49 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2018 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.
 */
package com.android.settings.datetime.timezone;

import android.content.Context;
import android.icu.text.LocaleDisplayNames;
import android.support.v7.preference.Preference;

import java.util.Locale;

public class RegionPreferenceController extends BaseTimeZonePreferenceController {
    private static final String PREFERENCE_KEY = "region";

    private final LocaleDisplayNames mLocaleDisplayNames;
    private String mRegionId = "";

    public RegionPreferenceController(Context context) {
        super(context, PREFERENCE_KEY);
        Locale locale = context.getResources().getConfiguration().getLocales().get(0);
        mLocaleDisplayNames = LocaleDisplayNames.getInstance(locale);

    }

    @Override
    public CharSequence getSummary() {
        return mLocaleDisplayNames.regionDisplayName(mRegionId);
    }

    public void setRegionId(String regionId) {
        mRegionId = regionId;
    }

    public String getRegionId() {
        return mRegionId;
    }
}
Loading