Tweak search result for adaptive brightness
- Create a new controller for auto brightness in auto_brightness_detail.xml. - We only show slice version for search result. - Change slice summary for adaptive brightness. Test: visual Fixes: 130651278 Change-Id: If9b71735bbb2a0ee22676d9dfedab2cf9e778493
This commit is contained in:
@@ -2759,6 +2759,8 @@
|
|||||||
<string name="brightness_summary">Adjust the brightness of the screen</string>
|
<string name="brightness_summary">Adjust the brightness of the screen</string>
|
||||||
<!-- Sound & display settings screen, setting option name to enable adaptive brightness [CHAR LIMIT=30] -->
|
<!-- Sound & display settings screen, setting option name to enable adaptive brightness [CHAR LIMIT=30] -->
|
||||||
<string name="auto_brightness_title">Adaptive brightness</string>
|
<string name="auto_brightness_title">Adaptive brightness</string>
|
||||||
|
<!-- Summary about the feature adaptive brightness [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="auto_brightness_summary">Screen brightness adjusts to environment</string>
|
||||||
<!-- Setting option summary when adaptive brightness is on [CHAR LIMIT=NONE] -->
|
<!-- Setting option summary when adaptive brightness is on [CHAR LIMIT=NONE] -->
|
||||||
<string name="auto_brightness_summary_on">On</string>
|
<string name="auto_brightness_summary_on">On</string>
|
||||||
<!-- Setting option summary when adaptive brightness is off [CHAR LIMIT=NONE] -->
|
<!-- Setting option summary when adaptive brightness is off [CHAR LIMIT=NONE] -->
|
||||||
@@ -7188,8 +7190,6 @@
|
|||||||
<string name="keywords_wifi">wifi, wi-fi, network connection, internet, wireless, data, wi fi</string>
|
<string name="keywords_wifi">wifi, wi-fi, network connection, internet, wireless, data, wi fi</string>
|
||||||
<!-- Search keyword for "Open Network Notification" settings. [CHAR_LIMIT=NONE]-->
|
<!-- Search keyword for "Open Network Notification" settings. [CHAR_LIMIT=NONE]-->
|
||||||
<string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string>
|
<string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string>
|
||||||
<!-- Search keyword for "Adaptive brightness" settings. [CHAR_LIMIT=NONE]-->
|
|
||||||
<string name="keywords_auto_brightness">Auto brightness</string>
|
|
||||||
<!-- Search keyword for "Vibrate on touch" settings. [CHAR_LIMIT=NONE]-->
|
<!-- Search keyword for "Vibrate on touch" settings. [CHAR_LIMIT=NONE]-->
|
||||||
<string name="keywords_vibrate_on_touch">Stop vibration, tap, keyboard</string>
|
<string name="keywords_vibrate_on_touch">Stop vibration, tap, keyboard</string>
|
||||||
<!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->
|
<!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->
|
||||||
@@ -7276,7 +7276,7 @@
|
|||||||
<string name="keywords_fingerprint_settings">fingerprint, add fingerprint</string>
|
<string name="keywords_fingerprint_settings">fingerprint, add fingerprint</string>
|
||||||
|
|
||||||
<!-- Search keywords for adaptive brightness setting [CHAR LIMIT=NONE]-->
|
<!-- Search keywords for adaptive brightness setting [CHAR LIMIT=NONE]-->
|
||||||
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness</string>
|
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness, Auto brightness</string>
|
||||||
|
|
||||||
<!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]-->
|
<!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]-->
|
||||||
<string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
|
<string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
|
||||||
|
@@ -32,8 +32,9 @@
|
|||||||
<com.android.settingslib.RestrictedSwitchPreference
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
android:key="auto_brightness"
|
android:key="auto_brightness"
|
||||||
android:title="@string/auto_brightness_title"
|
android:title="@string/auto_brightness_title"
|
||||||
|
android:summary="@string/auto_brightness_summary"
|
||||||
settings:keywords="@string/keywords_display_auto_brightness"
|
settings:keywords="@string/keywords_display_auto_brightness"
|
||||||
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
|
settings:controller="com.android.settings.display.AutoBrightnessDetailPreferenceController"
|
||||||
settings:useAdminDisabledSummary="true"
|
settings:useAdminDisabledSummary="true"
|
||||||
settings:userRestriction="no_config_brightness"
|
settings:userRestriction="no_config_brightness"
|
||||||
settings:allowDividerAbove="true" />
|
settings:allowDividerAbove="true" />
|
||||||
|
@@ -44,8 +44,7 @@
|
|||||||
android:title="@string/auto_brightness_title"
|
android:title="@string/auto_brightness_title"
|
||||||
android:summary="@string/summary_placeholder"
|
android:summary="@string/summary_placeholder"
|
||||||
android:fragment="com.android.settings.display.AutoBrightnessSettings"
|
android:fragment="com.android.settings.display.AutoBrightnessSettings"
|
||||||
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
|
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"/>
|
||||||
settings:keywords="@string/keywords_auto_brightness"/>
|
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="wallpaper"
|
android:key="wallpaper"
|
||||||
|
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
public class AutoBrightnessDetailPreferenceController extends AutoBrightnessPreferenceController {
|
||||||
|
|
||||||
|
public AutoBrightnessDetailPreferenceController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@AvailabilityStatus
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
return mContext.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_automatic_brightness_available)
|
||||||
|
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSliceable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -19,7 +19,6 @@ import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.TogglePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
@@ -52,15 +51,10 @@ public class AutoBrightnessPreferenceController extends TogglePreferenceControll
|
|||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return mContext.getResources().getBoolean(
|
return mContext.getResources().getBoolean(
|
||||||
com.android.internal.R.bool.config_automatic_brightness_available)
|
com.android.internal.R.bool.config_automatic_brightness_available)
|
||||||
? AVAILABLE
|
? AVAILABLE_UNSEARCHABLE
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSliceable() {
|
|
||||||
return TextUtils.equals(getPreferenceKey(), "auto_brightness");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
return mContext.getText(isChecked()
|
return mContext.getText(isChecked()
|
||||||
|
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* 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 static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Config(shadows = {SettingsShadowResources.class})
|
||||||
|
public class AutoBrightnessDetailPreferenceControllerTest {
|
||||||
|
|
||||||
|
private AutoBrightnessDetailPreferenceController mController;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mController = new AutoBrightnessDetailPreferenceController(
|
||||||
|
RuntimeEnvironment.application, "test_key");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isSliceable_returnTrue() {
|
||||||
|
mController.onPreferenceChange(null, true);
|
||||||
|
|
||||||
|
assertThat(mController.isSliceable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_configTrueSet_shouldReturnAvailable() {
|
||||||
|
SettingsShadowResources.overrideResource(
|
||||||
|
com.android.internal.R.bool.config_automatic_brightness_available, true);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatus_configFalseSet_shouldReturnUnsupportedOnDevice() {
|
||||||
|
SettingsShadowResources.overrideResource(
|
||||||
|
com.android.internal.R.bool.config_automatic_brightness_available, false);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
}
|
@@ -20,6 +20,9 @@ import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
|
|||||||
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
|
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
|
||||||
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
|
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
|
||||||
|
|
||||||
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
@@ -27,6 +30,7 @@ import android.content.Context;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -34,8 +38,10 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Config(shadows = {SettingsShadowResources.class})
|
||||||
public class AutoBrightnessPreferenceControllerTest {
|
public class AutoBrightnessPreferenceControllerTest {
|
||||||
|
|
||||||
private static final String PREFERENCE_KEY = "auto_brightness";
|
private static final String PREFERENCE_KEY = "auto_brightness";
|
||||||
@@ -115,17 +121,18 @@ public class AutoBrightnessPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSliceable_correctKey_returnsTrue() {
|
public void getAvailabilityStatus_configTrueSet_shouldReturnAvailableUnsearchable() {
|
||||||
final AutoBrightnessPreferenceController controller =
|
SettingsShadowResources.overrideResource(
|
||||||
new AutoBrightnessPreferenceController(mContext,
|
com.android.internal.R.bool.config_automatic_brightness_available, true);
|
||||||
"auto_brightness");
|
|
||||||
assertThat(controller.isSliceable()).isTrue();
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSliceable_incorrectKey_returnsFalse() {
|
public void getAvailabilityStatus_configFalseSet_shouldReturnUnsupportedOnDevice() {
|
||||||
final AutoBrightnessPreferenceController controller =
|
SettingsShadowResources.overrideResource(
|
||||||
new AutoBrightnessPreferenceController(mContext, "bad_key");
|
com.android.internal.R.bool.config_automatic_brightness_available, false);
|
||||||
assertThat(controller.isSliceable()).isFalse();
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user