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

Commit f5d1841c authored by Yi Jiang's avatar Yi Jiang
Browse files

Merge Screen Attention and Screen timeout Settings.

Bug: 155051311
Test: atest
Change-Id: I6f6ee52618eab629a41b28982be32ead5f9ba08d
parent e94d2581
Loading
Loading
Loading
Loading

res/xml/adaptive_sleep_detail.xml

deleted100644 → 0
+0 −54
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2019 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"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:title="@string/adaptive_sleep_title">

    <com.android.settings.widget.VideoPreference
        android:key="adaptive_sleep_video"
        android:title="@string/summary_placeholder"
        settings:animation="@raw/adaptive_sleep"
        settings:preview="@drawable/adaptive_sleep"
        settings:controller="com.android.settings.widget.VideoPreferenceController"/>

    <Preference
        android:key="adaptive_sleep_permission"
        android:title="@string/adaptive_sleep_title_no_permission"
        android:summary="@string/adaptive_sleep_summary_no_permission"
        android:icon="@drawable/ic_info_outline_24"
        settings:controller="com.android.settings.display.AdaptiveSleepPermissionPreferenceController"
    />

    <com.android.settingslib.RestrictedSwitchPreference
        android:key="adaptive_sleep"
        android:title="@string/adaptive_sleep_title"
        android:summary="@string/adaptive_sleep_description"
        settings:keywords="@string/keywords_display_adaptive_sleep"
        settings:controller="com.android.settings.display.AdaptiveSleepDetailPreferenceController"
        settings:useAdminDisabledSummary="true"
        settings:allowDividerAbove="true" />

    <com.android.settingslib.widget.FooterPreference
        android:key="adaptive_sleep_footer"
        android:title="@string/adaptive_sleep_privacy"
        android:icon="@drawable/ic_privacy_shield_24dp"
        android:selectable="false"
        settings:searchable="false" />

</PreferenceScreen>
+3 −11
Original line number Diff line number Diff line
@@ -63,20 +63,12 @@
    </com.android.settingslib.RestrictedPreference>

    <!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
    <com.android.settings.display.TimeoutListPreference
    <Preference
        android:key="screen_timeout"
        android:title="@string/screen_timeout"
        android:summary="@string/summary_placeholder"
        android:entries="@array/screen_timeout_entries"
        android:entryValues="@array/screen_timeout_values"
        settings:keywords="@string/keywords_screen_timeout" />

    <Preference
        android:key="adaptive_sleep_entry"
        android:title="@string/adaptive_sleep_title"
        android:summary="@string/summary_placeholder"
        android:fragment="com.android.settings.display.AdaptiveSleepSettings"
        settings:controller="com.android.settings.display.AdaptiveSleepPreferenceController" />
        android:fragment="com.android.settings.display.ScreenTimeoutSettings"
        settings:controller="com.android.settings.display.ScreenTimeoutPreferenceController" />

    <SwitchPreference
        android:key="auto_rotate"
+19 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2020 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:title="@string/screen_timeout"/>
 No newline at end of file
+0 −4
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import com.android.settings.display.ScreenSaverPreferenceController;
import com.android.settings.display.ShowOperatorNamePreferenceController;
import com.android.settings.display.TapToWakePreferenceController;
import com.android.settings.display.ThemePreferenceController;
import com.android.settings.display.TimeoutPreferenceController;
import com.android.settings.display.VrDisplayPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -44,8 +43,6 @@ import java.util.List;
public class DisplaySettings extends DashboardFragment {
    private static final String TAG = "DisplaySettings";

    private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";

    @Override
    public int getMetricsCategory() {
        return SettingsEnums.DISPLAY;
@@ -85,7 +82,6 @@ public class DisplaySettings extends DashboardFragment {
        controllers.add(new NightModePreferenceController(context));
        controllers.add(new ScreenSaverPreferenceController(context));
        controllers.add(new TapToWakePreferenceController(context));
        controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
        controllers.add(new VrDisplayPreferenceController(context));
        controllers.add(new ShowOperatorNamePreferenceController(context));
        controllers.add(new ThemePreferenceController(context));
+0 −66
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.display;

import android.content.Context;
import android.os.UserManager;

import androidx.preference.Preference;

import com.android.settings.bluetooth.RestrictionUtils;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedSwitchPreference;

public class AdaptiveSleepDetailPreferenceController extends AdaptiveSleepPreferenceController {
    private RestrictionUtils mRestrictionUtils;

    public AdaptiveSleepDetailPreferenceController(Context context, String key,
            RestrictionUtils restrictionUtils) {
        super(context, key);
        mRestrictionUtils = restrictionUtils;
    }

    public AdaptiveSleepDetailPreferenceController(Context context, String key) {
        this(context, key, new RestrictionUtils());
    }

    @Override
    @AvailabilityStatus
    public int getAvailabilityStatus() {
        return mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_adaptive_sleep_available)
                ? AVAILABLE
                : UNSUPPORTED_ON_DEVICE;
    }

    @Override
    public boolean isPublicSlice() {
        return true;
    }

    @Override
    public void updateState(Preference preference) {
        super.updateState(preference);
        final EnforcedAdmin enforcedAdmin = mRestrictionUtils.checkIfRestrictionEnforced(mContext,
                UserManager.DISALLOW_CONFIG_SCREEN_TIMEOUT);
        if (enforcedAdmin != null) {
            ((RestrictedSwitchPreference) preference).setDisabledByAdmin(enforcedAdmin);
        } else {
            preference.setEnabled(hasSufficientPermission(mContext.getPackageManager()));
        }
    }
}
 No newline at end of file
Loading