Remove old contrastDialog from dev options
Flag: NA Bug: 333905689 Test: treehugger, manual Change-Id: I400ab2b14cf8589be97123f3bcf3b26c98009d07
This commit is contained in:
@@ -3049,9 +3049,6 @@
|
|||||||
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES"/>
|
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES"/>
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="com.android.intent.action.SHOW_CONTRAST_DIALOG" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
android:value="com.android.settings.development.DevelopmentSettingsDashboardFragment" />
|
android:value="com.android.settings.development.DevelopmentSettingsDashboardFragment" />
|
||||||
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
|
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
|
||||||
|
@@ -5586,8 +5586,6 @@
|
|||||||
<string name="keywords_color_correction">adjust color </string>
|
<string name="keywords_color_correction">adjust color </string>
|
||||||
<!-- List of synonyms used in the settings search bar to find the “Color inversion”. [CHAR LIMIT=NONE] -->
|
<!-- List of synonyms used in the settings search bar to find the “Color inversion”. [CHAR LIMIT=NONE] -->
|
||||||
<string name="keywords_color_inversion">turn screen dark, turn screen light</string>
|
<string name="keywords_color_inversion">turn screen dark, turn screen light</string>
|
||||||
<!-- List of synonyms used in the settings search bar to find the “Contrast”. [CHAR LIMIT=NONE] -->
|
|
||||||
<string name="keywords_contrast">color contrast</string>
|
|
||||||
<!-- List of synonyms used in the settings search bar to find the “Accessibility Menu”. [CHAR LIMIT=NONE] -->
|
<!-- List of synonyms used in the settings search bar to find the “Accessibility Menu”. [CHAR LIMIT=NONE] -->
|
||||||
<string name="keywords_accessibility_menu"></string>
|
<string name="keywords_accessibility_menu"></string>
|
||||||
<!-- List of synonyms used in the settings search bar to find the “Switch Access”. [CHAR LIMIT=NONE] -->
|
<!-- List of synonyms used in the settings search bar to find the “Switch Access”. [CHAR LIMIT=NONE] -->
|
||||||
@@ -13168,11 +13166,7 @@
|
|||||||
<!-- Button to close the dialog without saving in screen flash color selection dialog. [CHAR LIMIT=20] -->
|
<!-- Button to close the dialog without saving in screen flash color selection dialog. [CHAR LIMIT=20] -->
|
||||||
<string name="color_selector_dialog_cancel">Cancel</string>
|
<string name="color_selector_dialog_cancel">Cancel</string>
|
||||||
|
|
||||||
<!-- Title for the contrast preference fragment [CHAR LIMIT=35] -->
|
|
||||||
<string name="contrast_title">Contrast</string>
|
|
||||||
<!-- 'Standard' contrast option [CHAR LIMIT=20] -->
|
<!-- 'Standard' contrast option [CHAR LIMIT=20] -->
|
||||||
<string name="contrast_standard">Standard</string>
|
|
||||||
<!-- 'Default' contrast option [CHAR LIMIT=20] -->
|
|
||||||
<string name="contrast_default">Default</string>
|
<string name="contrast_default">Default</string>
|
||||||
<!-- 'Medium' contrast option [CHAR LIMIT=20] -->
|
<!-- 'Medium' contrast option [CHAR LIMIT=20] -->
|
||||||
<string name="contrast_medium">Medium</string>
|
<string name="contrast_medium">Medium</string>
|
||||||
|
@@ -567,12 +567,6 @@
|
|||||||
android:title="@string/transparent_navigation_bar"
|
android:title="@string/transparent_navigation_bar"
|
||||||
android:summary="@string/transparent_navigation_bar_summary" />
|
android:summary="@string/transparent_navigation_bar_summary" />
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="contrast_preference"
|
|
||||||
android:title="@string/contrast_title"
|
|
||||||
android:persistent="false"
|
|
||||||
settings:keywords="@string/keywords_contrast" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
@@ -21,7 +21,6 @@ import static android.service.quicksettings.TileService.ACTION_QS_TILE_PREFERENC
|
|||||||
import static android.view.flags.Flags.sensitiveContentAppProtectionApi;
|
import static android.view.flags.Flags.sensitiveContentAppProtectionApi;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.UiModeManager;
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.bluetooth.BluetoothA2dp;
|
import android.bluetooth.BluetoothA2dp;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
@@ -79,7 +78,6 @@ import com.android.settings.development.storage.SharedDataPreferenceController;
|
|||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.actionbar.SearchMenuController;
|
import com.android.settings.search.actionbar.SearchMenuController;
|
||||||
import com.android.settings.theme.ContrastPreferenceController;
|
|
||||||
import com.android.settings.widget.SettingsMainSwitchBar;
|
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
@@ -786,8 +784,6 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
|||||||
controllers.add(new IngressRateLimitPreferenceController((context)));
|
controllers.add(new IngressRateLimitPreferenceController((context)));
|
||||||
controllers.add(new BackAnimationPreferenceController(context, fragment));
|
controllers.add(new BackAnimationPreferenceController(context, fragment));
|
||||||
controllers.add(new PhantomProcessPreferenceController(context));
|
controllers.add(new PhantomProcessPreferenceController(context));
|
||||||
controllers.add(new ContrastPreferenceController(
|
|
||||||
context, context.getSystemService(UiModeManager.class)));
|
|
||||||
controllers.add(new ForceEnableNotesRolePreferenceController(context));
|
controllers.add(new ForceEnableNotesRolePreferenceController(context));
|
||||||
controllers.add(new GrammaticalGenderPreferenceController(context));
|
controllers.add(new GrammaticalGenderPreferenceController(context));
|
||||||
controllers.add(new SensitiveContentProtectionPreferenceController(context));
|
controllers.add(new SensitiveContentProtectionPreferenceController(context));
|
||||||
|
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 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.theme
|
|
||||||
|
|
||||||
import android.app.UiModeManager
|
|
||||||
import android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_HIGH
|
|
||||||
import android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_MEDIUM
|
|
||||||
import android.app.UiModeManager.ContrastUtils.toContrastLevel
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.UserHandle
|
|
||||||
import android.text.TextUtils
|
|
||||||
import androidx.preference.Preference
|
|
||||||
import com.android.internal.annotations.VisibleForTesting
|
|
||||||
import com.android.settings.R
|
|
||||||
import com.android.settings.Utils
|
|
||||||
import com.android.settings.core.BasePreferenceController
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller that opens the contrast dialog and updates the text describing the current contrast
|
|
||||||
*/
|
|
||||||
class ContrastPreferenceController(
|
|
||||||
private val context: Context,
|
|
||||||
private val uiModeManager: UiModeManager) : BasePreferenceController(context, KEY) {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@VisibleForTesting
|
|
||||||
const val KEY = "contrast_preference"
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getAvailabilityStatus(): Int {
|
|
||||||
return AVAILABLE
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun handlePreferenceTreeClick(preference: Preference): Boolean {
|
|
||||||
if (TextUtils.equals(preference.key, preferenceKey)) {
|
|
||||||
val intent = Intent(Intent.ACTION_SHOW_CONTRAST_DIALOG)
|
|
||||||
intent.setPackage(Utils.SYSTEMUI_PACKAGE_NAME)
|
|
||||||
context.startActivityAsUser(intent, UserHandle(UserHandle.USER_CURRENT))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getSummary(): CharSequence = getSummary(toContrastLevel(uiModeManager.contrast))
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
fun getSummary(contrast: Int): String {
|
|
||||||
return when (contrast) {
|
|
||||||
CONTRAST_LEVEL_HIGH -> context.getString(R.string.contrast_high)
|
|
||||||
CONTRAST_LEVEL_MEDIUM -> context.getString(R.string.contrast_medium)
|
|
||||||
else -> context.getString(R.string.contrast_standard)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,113 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2023 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.theme;
|
|
||||||
|
|
||||||
import static android.app.UiModeManager.ContrastUtils;
|
|
||||||
import static android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_HIGH;
|
|
||||||
import static android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_MEDIUM;
|
|
||||||
import static android.app.UiModeManager.ContrastUtils.CONTRAST_LEVEL_STANDARD;
|
|
||||||
import static android.provider.Settings.Secure.CONTRAST_LEVEL;
|
|
||||||
|
|
||||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.clearInvocations;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import android.app.UiModeManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Ignore;
|
|
||||||
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;
|
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class ContrastPreferenceControllerTest {
|
|
||||||
|
|
||||||
@Rule
|
|
||||||
public MockitoRule mocks = MockitoJUnit.rule();
|
|
||||||
|
|
||||||
private ContrastPreferenceController mController;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private UiModeManager mMockUiModeManager;
|
|
||||||
private Context mContext;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setup() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
|
||||||
mController = new ContrastPreferenceController(mContext, mMockUiModeManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void controllerIsAvailable() {
|
|
||||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Ignore("b/313614100")
|
|
||||||
@Test
|
|
||||||
public void testHandlePreferenceTreeClick() {
|
|
||||||
Preference preference = new Preference(mContext);
|
|
||||||
preference.setKey(ContrastPreferenceController.KEY);
|
|
||||||
assertThat(mController.handlePreferenceTreeClick(preference)).isTrue();
|
|
||||||
|
|
||||||
Preference otherPreference = new Preference(mContext);
|
|
||||||
otherPreference.setKey("wrong key");
|
|
||||||
assertThat(mController.handlePreferenceTreeClick(otherPreference)).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void controllerSummary() {
|
|
||||||
float initialContrast = mContext.getSystemService(UiModeManager.class).getContrast();
|
|
||||||
try {
|
|
||||||
allContrastValues().forEach(contrastLevel -> {
|
|
||||||
float contrast = ContrastUtils.fromContrastLevel(contrastLevel);
|
|
||||||
clearInvocations(mMockUiModeManager);
|
|
||||||
when(mMockUiModeManager.getContrast()).thenReturn(contrast);
|
|
||||||
String summary = mController.getSummary().toString();
|
|
||||||
verify(mMockUiModeManager).getContrast();
|
|
||||||
assertThat(summary).isEqualTo(mController.getSummary(contrastLevel));
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
putContrastInSettings(initialContrast);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Stream<Integer> allContrastValues() {
|
|
||||||
return Stream.of(CONTRAST_LEVEL_STANDARD, CONTRAST_LEVEL_MEDIUM, CONTRAST_LEVEL_HIGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void putContrastInSettings(float contrast) {
|
|
||||||
Settings.Secure.putFloat(mContext.getContentResolver(), CONTRAST_LEVEL, contrast);
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user