Loading res/xml/color_mode_settings.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- 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. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="color_mode_settings_screen" android:title="@string/color_mode_title" /> src/com/android/settings/display/ColorModePreferenceFragment.java +5 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,11 @@ public class ColorModePreferenceFragment extends RadioButtonPickerFragment { mController = new NightDisplayController(context); } @Override protected int getPreferenceScreenResId() { return R.xml.color_mode_settings; } @Override protected List<? extends CandidateInfo> getCandidates() { Context c = getContext(); Loading src/com/android/settings/widget/RadioButtonPickerFragment.java +3 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,9 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr return view; } @Override protected abstract int getPreferenceScreenResId(); @Override public void onRadioButtonClicked(RadioButtonPreference selected) { final String selectedKey = selected.getKey(); Loading tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,11 @@ public class DefaultAppPickerFragmentTest { return 0; } @Override protected int getPreferenceScreenResId() { return 0; } @Override protected List<DefaultAppInfo> getCandidates() { return new ArrayList<>(); Loading tests/robotests/src/com/android/settings/display/ColorModePreferenceFragmentTest.java +21 −3 Original line number Diff line number Diff line Loading @@ -16,11 +16,18 @@ package com.android.settings.display; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.os.Bundle; import com.android.internal.app.NightDisplayController; import com.android.internal.logging.nano.MetricsProto; import com.android.settings.R; import com.android.settings.TestConfig; import com.android.settings.testutils.SettingsRobolectricTestRunner; import com.android.settings.testutils.shadow.SettingsShadowSystemProperties; Loading Loading @@ -111,20 +118,31 @@ public class ColorModePreferenceFragmentTest { @Test public void setKey_natural() { mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_NATURAL); Mockito.verify(mController).setColorMode(NightDisplayController.COLOR_MODE_NATURAL); verify(mController).setColorMode(NightDisplayController.COLOR_MODE_NATURAL); } @Config(shadows = {SettingsShadowSystemProperties.class}) @Test public void setKey_boosted() { mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_BOOSTED); Mockito.verify(mController).setColorMode(NightDisplayController.COLOR_MODE_BOOSTED); verify(mController).setColorMode(NightDisplayController.COLOR_MODE_BOOSTED); } @Config(shadows = {SettingsShadowSystemProperties.class}) @Test public void setKey_saturated() { mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_SATURATED); Mockito.verify(mController).setColorMode(NightDisplayController.COLOR_MODE_SATURATED); verify(mController).setColorMode(NightDisplayController.COLOR_MODE_SATURATED); } @Test public void onCreatePreferences_useNewTitle_shouldAddColorModePreferences() { doNothing().when(mFragment).addPreferencesFromResource(anyInt()); doNothing().when(mFragment).updateCandidates(); mFragment.onCreatePreferences(Bundle.EMPTY, null /* rootKey */); verify(mFragment).addPreferencesFromResource(R.xml.color_mode_settings); } } Loading
res/xml/color_mode_settings.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- 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. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="color_mode_settings_screen" android:title="@string/color_mode_title" />
src/com/android/settings/display/ColorModePreferenceFragment.java +5 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,11 @@ public class ColorModePreferenceFragment extends RadioButtonPickerFragment { mController = new NightDisplayController(context); } @Override protected int getPreferenceScreenResId() { return R.xml.color_mode_settings; } @Override protected List<? extends CandidateInfo> getCandidates() { Context c = getContext(); Loading
src/com/android/settings/widget/RadioButtonPickerFragment.java +3 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,9 @@ public abstract class RadioButtonPickerFragment extends InstrumentedPreferenceFr return view; } @Override protected abstract int getPreferenceScreenResId(); @Override public void onRadioButtonClicked(RadioButtonPreference selected) { final String selectedKey = selected.getKey(); Loading
tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,11 @@ public class DefaultAppPickerFragmentTest { return 0; } @Override protected int getPreferenceScreenResId() { return 0; } @Override protected List<DefaultAppInfo> getCandidates() { return new ArrayList<>(); Loading
tests/robotests/src/com/android/settings/display/ColorModePreferenceFragmentTest.java +21 −3 Original line number Diff line number Diff line Loading @@ -16,11 +16,18 @@ package com.android.settings.display; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.os.Bundle; import com.android.internal.app.NightDisplayController; import com.android.internal.logging.nano.MetricsProto; import com.android.settings.R; import com.android.settings.TestConfig; import com.android.settings.testutils.SettingsRobolectricTestRunner; import com.android.settings.testutils.shadow.SettingsShadowSystemProperties; Loading Loading @@ -111,20 +118,31 @@ public class ColorModePreferenceFragmentTest { @Test public void setKey_natural() { mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_NATURAL); Mockito.verify(mController).setColorMode(NightDisplayController.COLOR_MODE_NATURAL); verify(mController).setColorMode(NightDisplayController.COLOR_MODE_NATURAL); } @Config(shadows = {SettingsShadowSystemProperties.class}) @Test public void setKey_boosted() { mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_BOOSTED); Mockito.verify(mController).setColorMode(NightDisplayController.COLOR_MODE_BOOSTED); verify(mController).setColorMode(NightDisplayController.COLOR_MODE_BOOSTED); } @Config(shadows = {SettingsShadowSystemProperties.class}) @Test public void setKey_saturated() { mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_SATURATED); Mockito.verify(mController).setColorMode(NightDisplayController.COLOR_MODE_SATURATED); verify(mController).setColorMode(NightDisplayController.COLOR_MODE_SATURATED); } @Test public void onCreatePreferences_useNewTitle_shouldAddColorModePreferences() { doNothing().when(mFragment).addPreferencesFromResource(anyInt()); doNothing().when(mFragment).updateCandidates(); mFragment.onCreatePreferences(Bundle.EMPTY, null /* rootKey */); verify(mFragment).addPreferencesFromResource(R.xml.color_mode_settings); } }