OSDN Git Service

Convert auto-brightness switch to a full screen UI.
authorFan Zhang <zhfan@google.com>
Tue, 10 Apr 2018 20:08:22 +0000 (13:08 -0700)
committerFan Zhang <zhfan@google.com>
Tue, 10 Apr 2018 21:21:00 +0000 (14:21 -0700)
Change-Id: Id5e5ec959201102a7c60372a441dc6813ceedbae
Merged-In: Id5e5ec959201102a7c60372a441dc6813ceedbae
Fixes: 69795935
Test: Existing conformance tests still pass (CodeInspectionTest,
      UniquePreferenceTest, manual search test)

res/drawable-nodpi/aab_brightness [new file with mode: 0644]
res/raw/aab_brightness.mp4 [new file with mode: 0644]
res/values/strings.xml
res/xml/auto_brightness_detail.xml [new file with mode: 0644]
res/xml/display_settings.xml
src/com/android/settings/DisplaySettings.java
src/com/android/settings/display/AutoBrightnessSettings.java [new file with mode: 0644]
src/com/android/settings/fuelgauge/SmartBatterySettings.java
src/com/android/settings/search/SearchIndexableResourcesImpl.java

diff --git a/res/drawable-nodpi/aab_brightness b/res/drawable-nodpi/aab_brightness
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/res/raw/aab_brightness.mp4 b/res/raw/aab_brightness.mp4
new file mode 100644 (file)
index 0000000..e69de29
index 0922ebb..b92fb92 100644 (file)
     <string name="help_url_font_size" translatable="false"></string>
     <!-- Help URL, Display size [DO NOT TRANSLATE] -->
     <string name="help_url_display_size" translatable="false"></string>
+    <!-- Help URL, Auto brightness [DO NOT TRANSLATE] -->
+    <string name="help_url_auto_brightness" translatable="false" />
 
     <string name="help_url_network_dashboard" translatable="false"></string>
     <string name="help_url_connected_devices" translatable="false"></string>
diff --git a/res/xml/auto_brightness_detail.xml b/res/xml/auto_brightness_detail.xml
new file mode 100644 (file)
index 0000000..aca9f14
--- /dev/null
@@ -0,0 +1,38 @@
+<?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"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="auto_brightness_detail"
+    android:title="@string/auto_brightness_title"
+    settings:keywords="@string/keywords_display_auto_brightness">
+
+    <com.android.settings.widget.VideoPreference
+        android:key="auto_brightness_video"
+        settings:animation="@raw/aab_brightness"
+        settings:preview="@drawable/aab_brightness"/>
+
+    <!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
+    <com.android.settingslib.RestrictedSwitchPreference
+        android:key="auto_brightness"
+        android:title="@string/auto_brightness_title"
+        settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
+        settings:useAdminDisabledSummary="true"
+        settings:userRestriction="no_config_brightness" />
+
+</PreferenceScreen>
\ No newline at end of file
index eaa4a6b..90198ae 100644 (file)
         settings:widgetLayout="@null"
         settings:keywords="@string/keywords_display_night_display" />
 
-    <!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
-    <com.android.settingslib.RestrictedSwitchPreference
-        android:key="auto_brightness"
+    <Preference
+        android:key="auto_brightness_entry"
         android:title="@string/auto_brightness_title"
         android:summary="@string/auto_brightness_summary"
-        settings:keywords="@string/keywords_display_auto_brightness"
-        settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
-        settings:useAdminDisabledSummary="true"
-        settings:userRestriction="no_config_brightness" />
+        android:fragment="com.android.settings.display.AutoBrightnessSettings"
+        settings:controller="com.android.settings.display.AutoBrightnessPreferenceController" />
 
     <com.android.settingslib.RestrictedPreference
         android:key="wallpaper"
index d8bd447..fef56ad 100644 (file)
@@ -23,7 +23,6 @@ import com.android.internal.hardware.AmbientDisplayConfiguration;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.display.AmbientDisplayPreferenceController;
-import com.android.settings.display.AutoRotatePreferenceController;
 import com.android.settings.display.BrightnessLevelPreferenceController;
 import com.android.settings.display.CameraGesturePreferenceController;
 import com.android.settings.display.ColorModePreferenceController;
@@ -52,7 +51,7 @@ public class DisplaySettings extends DashboardFragment {
 
     private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
     private static final String KEY_AMBIENT_DISPLAY = "ambient_display";
-
+    private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness_entry";
     private static final String KEY_NIGHT_DISPLAY = "night_display";
 
     @Override
@@ -122,6 +121,7 @@ public class DisplaySettings extends DashboardFragment {
                     keys.add(KEY_DISPLAY_SIZE);
                     keys.add(WallpaperPreferenceController.KEY_WALLPAPER);
                     keys.add(KEY_NIGHT_DISPLAY);
+                    keys.add(KEY_AUTO_BRIGHTNESS);
                     return keys;
                 }
 
diff --git a/src/com/android/settings/display/AutoBrightnessSettings.java b/src/com/android/settings/display/AutoBrightnessSettings.java
new file mode 100644 (file)
index 0000000..778acf6
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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.display;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.provider.SearchIndexableResource;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class AutoBrightnessSettings extends DashboardFragment {
+
+    private static final String TAG = "AutoBrightnessSettings";
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        mFooterPreferenceMixin.createFooterPreference()
+                .setTitle(R.string.auto_brightness_description);
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.auto_brightness_detail;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsProto.MetricsEvent.SETTINGS_AUTO_BRIGHTNESS;
+    }
+
+    @Override
+    public int getHelpResource() {
+        return R.string.help_url_auto_brightness;
+    }
+
+    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(
+                        Context context, boolean enabled) {
+                    final SearchIndexableResource sir = new SearchIndexableResource(context);
+                    sir.xmlResId = R.xml.auto_brightness_detail;
+                    return Arrays.asList(sir);
+                }
+            };
+}
index 43ac960..bcbac3f 100644 (file)
@@ -27,7 +27,6 @@ import com.android.settings.core.InstrumentedPreferenceFragment;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.widget.FooterPreferenceMixin;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -39,9 +38,6 @@ import java.util.List;
 public class SmartBatterySettings extends DashboardFragment {
     public static final String TAG = "SmartBatterySettings";
 
-    private final FooterPreferenceMixin mFooterPreferenceMixin =
-            new FooterPreferenceMixin(this, getLifecycle());
-
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
@@ -94,11 +90,6 @@ public class SmartBatterySettings extends DashboardFragment {
                 }
 
                 @Override
-                public List<String> getNonIndexableKeys(Context context) {
-                    return super.getNonIndexableKeys(context);
-                }
-
-                @Override
                 public List<AbstractPreferenceController> createPreferenceControllers(
                         Context context) {
                     return buildPreferenceControllers(context, null, null);
index 78b18a6..decfe33 100644 (file)
@@ -44,6 +44,7 @@ import com.android.settings.deviceinfo.DeviceInfoSettings;
 import com.android.settings.deviceinfo.StorageDashboardFragment;
 import com.android.settings.deviceinfo.StorageSettings;
 import com.android.settings.display.AmbientDisplaySettings;
+import com.android.settings.display.AutoBrightnessSettings;
 import com.android.settings.display.NightDisplaySettings;
 import com.android.settings.display.ScreenZoomSettings;
 import com.android.settings.dream.DreamSettings;
@@ -114,6 +115,7 @@ public class SearchIndexableResourcesImpl implements SearchIndexableResources {
         addIndex(DataUsageSummaryLegacy.class);
         addIndex(ScreenZoomSettings.class);
         addIndex(DisplaySettings.class);
+        addIndex(AutoBrightnessSettings.class);
         addIndex(AmbientDisplaySettings.class);
         addIndex(WallpaperTypeSettings.class);
         addIndex(AppAndNotificationDashboardFragment.class);