Merge "Update the dark theme and EDT description" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
551534959c
@@ -3175,6 +3175,7 @@
|
||||
<string name="dark_ui_summary_on_auto_mode_modes">Will turn off when <xliff:g name="modeName" example="Bedtime">%1$s</xliff:g> ends</string>
|
||||
<!-- Dark theme screen, description of Dark theme feature. [CHAR LIMIT=NONE] -->
|
||||
<string name="dark_ui_text">Dark theme uses a black background to help keep battery alive longer on some screens. Dark theme schedules wait to turn on until your screen is off.</string>
|
||||
<string name="dark_ui_text_force_invert">Use a dark background to make your screen more comfortable to view and reduce battery usage on some screens. Your theme will change if you have a schedule, when the screen is off.</string>
|
||||
<!-- Dark UI screen footer summary text shown when the when Dark theme turns on/off automatically according to a user bedtime schedule. [CHAR LIMIT=NONE] -->
|
||||
<string name="dark_ui_bedtime_footer_summary">Dark theme is currently following your Bedtime mode schedule</string>
|
||||
<!-- Dark UI screen footer action text shown when the when Dark theme turns on/off automatically according to a user bedtime schedule. [CHAR LIMIT=NONE] -->
|
||||
@@ -5572,7 +5573,7 @@
|
||||
<!-- Title for the accessibility preference for forcing all apps to use dark theme. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_force_invert_title">Make more apps dark</string>
|
||||
<!-- Summary for the accessibility preference for forcing all apps to use dark theme. [CHAR LIMIT=100] -->
|
||||
<string name="accessibility_force_invert_summary">Automatically convert light theme apps to dark theme</string>
|
||||
<string name="accessibility_force_invert_summary">Expands dark theme to more apps. May not work with all apps.</string>
|
||||
<!-- Title for the accessibility preference for disabling animations. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_disable_animations">Remove animations</string>
|
||||
<!-- Summary for the accessibility preference for disabling animations. [CHAR LIMIT=60] -->
|
||||
|
@@ -22,8 +22,8 @@
|
||||
|
||||
<com.android.settingslib.widget.TopIntroPreference
|
||||
android:key="dark_ui_top_intro"
|
||||
android:title="@string/dark_ui_text"
|
||||
settings:searchable="false"/>
|
||||
settings:searchable="false"
|
||||
settings:controller="com.android.settings.display.darkmode.DarkModeTopIntroPreferenceController"/>
|
||||
|
||||
<com.android.settingslib.widget.MainSwitchPreference
|
||||
android:key="dark_ui_activated"
|
||||
|
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2025 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.darkmode;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.widget.TopIntroPreference;
|
||||
|
||||
/**
|
||||
* Controller of the top info preference in the Dark Mode settings page.
|
||||
*
|
||||
* This should be removed after the flag android.view.accessibility.force_invert_color is launched.
|
||||
*/
|
||||
public class DarkModeTopIntroPreferenceController extends BasePreferenceController {
|
||||
@Nullable private TopIntroPreference mPreference;
|
||||
|
||||
public DarkModeTopIntroPreferenceController(
|
||||
@NonNull Context context,
|
||||
@NonNull String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE_UNSEARCHABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(@NonNull PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
if (android.view.accessibility.Flags.forceInvertColor()) {
|
||||
mPreference.setTitle(R.string.dark_ui_text_force_invert);
|
||||
} else {
|
||||
mPreference.setTitle(R.string.dark_ui_text);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2025 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.darkmode;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.view.accessibility.Flags;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.widget.TopIntroPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/**
|
||||
* Tests for {@link DarkModeTopIntroPreferenceController}.
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class DarkModeTopIntroPreferenceControllerTest {
|
||||
@Rule
|
||||
public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
private static final String PREFERENCE_KEY = "preference_key";
|
||||
|
||||
@Mock
|
||||
private PreferenceScreen mScreen;
|
||||
@Mock
|
||||
private TopIntroPreference mPreference;
|
||||
private DarkModeTopIntroPreferenceController mController;
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mController = new DarkModeTopIntroPreferenceController(mContext, PREFERENCE_KEY);
|
||||
when(mScreen.findPreference(PREFERENCE_KEY)).thenReturn(mPreference);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_FORCE_INVERT_COLOR)
|
||||
public void enableForceInvert_newPreferenceTitle() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
verify(mPreference).setTitle(eq(R.string.dark_ui_text_force_invert));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_FORCE_INVERT_COLOR)
|
||||
public void disableForceInvert_originalPreferenceTitle() {
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
verify(mPreference).setTitle(eq(R.string.dark_ui_text));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user