From b246d2e8152eda94691a463a70973166e98c39c9 Mon Sep 17 00:00:00 2001 From: Edgar Wang Date: Tue, 8 Oct 2024 13:02:27 +0000 Subject: [PATCH 1/9] [Homepage Revamp] hide the scroll bar of homepage Bug: 364612225 Test: visual Flag: EXEMPT bugfix Change-Id: I0d4c48ef6debfa82597db48a4320b0500f330b1b --- src/com/android/settings/homepage/TopLevelSettings.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/com/android/settings/homepage/TopLevelSettings.java b/src/com/android/settings/homepage/TopLevelSettings.java index 99441b0cc50..87e5560c959 100644 --- a/src/com/android/settings/homepage/TopLevelSettings.java +++ b/src/com/android/settings/homepage/TopLevelSettings.java @@ -251,6 +251,8 @@ public class TopLevelSettings extends DashboardFragment implements SplitLayoutLi Bundle savedInstanceState) { RecyclerView recyclerView = super.onCreateRecyclerView(inflater, parent, savedInstanceState); + recyclerView.setVerticalScrollBarEnabled(false); + recyclerView.setHorizontalScrollBarEnabled(false); recyclerView.setPadding(mPaddingHorizontal, 0, mPaddingHorizontal, 0); return recyclerView; } From ff275c82aab78f6b563fa0a87683186ff1b4d4de Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 13 Sep 2024 20:26:25 +0000 Subject: [PATCH 2/9] Mouse: Add preference toggle for mouse reverse vertical scrolling Bug: 359349392 Bug: 352598211 Test: Local DUT with aconfig flags enabled, verified settings appears and is togglable. Verified toggle affects mouse scroll direction. Flag: com.android.hardware.input.mouse_reverse_vertical_scrolling Change-Id: I9620ac9bd33da7660c7a53f969426becc4f283cc --- res/values/strings.xml | 4 + res/xml/trackpad_settings.xml | 7 + ...VerticalScrollingPreferenceController.java | 57 ++++++++ ...icalScrollingPreferenceControllerTest.java | 122 ++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 src/com/android/settings/inputmethod/MouseReverseVerticalScrollingPreferenceController.java create mode 100644 tests/robotests/src/com/android/settings/inputmethod/MouseReverseVerticalScrollingPreferenceControllerTest.java diff --git a/res/values/strings.xml b/res/values/strings.xml index 5326fa5d7a9..9f1dbb75501 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4543,6 +4543,10 @@ Mouse keys Use your keyboard to control the pointer + + Mouse reverse scrolling + + Scroll up to move the page down Keyboard shortcuts diff --git a/res/xml/trackpad_settings.xml b/res/xml/trackpad_settings.xml index 7e9494476fe..862a48a9603 100644 --- a/res/xml/trackpad_settings.xml +++ b/res/xml/trackpad_settings.xml @@ -62,6 +62,13 @@ android:selectable="false" settings:controller="com.android.settings.inputmethod.TrackpadPointerSpeedPreferenceController"/> + + Date: Fri, 20 Sep 2024 22:47:52 +0000 Subject: [PATCH 3/9] mouse: Add preference toggle for Mouse swap primary button Bug: 359349392 Bug: 352598211 Test: Local DUT with aconfig flags enabled, verified settings appeared and swaps the mouse primary button Flag: com.android.hardware.input.mouse_swap_primary_button Change-Id: Ib762240c10e2cadcfa4a23cd78df81fcad8197dd --- res/values/strings.xml | 4 + res/xml/trackpad_settings.xml | 7 + ...SwapPrimaryButtonPreferenceController.java | 57 ++++++++ ...PrimaryButtonPreferenceControllerTest.java | 122 ++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 src/com/android/settings/inputmethod/MouseSwapPrimaryButtonPreferenceController.java create mode 100644 tests/robotests/src/com/android/settings/inputmethod/MouseSwapPrimaryButtonPreferenceControllerTest.java diff --git a/res/values/strings.xml b/res/values/strings.xml index 9f1dbb75501..a87fecb9c98 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4547,6 +4547,10 @@ Mouse reverse scrolling Scroll up to move the page down + + Swap left and right buttons + + Use the left mouse button as your right Keyboard shortcuts diff --git a/res/xml/trackpad_settings.xml b/res/xml/trackpad_settings.xml index 862a48a9603..2f7c7fcdd4a 100644 --- a/res/xml/trackpad_settings.xml +++ b/res/xml/trackpad_settings.xml @@ -69,6 +69,13 @@ settings:controller="com.android.settings.inputmethod.MouseReverseVerticalScrollingPreferenceController" android:order="45"/> + + Date: Thu, 10 Oct 2024 00:56:43 +0000 Subject: [PATCH 4/9] Pass the actual quantity/count to the MessageFormat and let it decide Bug: 185400417 Test: manual (the autoclick location has changed to Settings > System > Trackpad & mouse > Pointer & touch accessibility > Autoclick) Flag: EXEMPT low risk localization fix Change-Id: Iee63b87513550a6758db9dce376e88a12a51d9f8 --- .../accessibility/AutoclickUtils.java | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/com/android/settings/accessibility/AutoclickUtils.java b/src/com/android/settings/accessibility/AutoclickUtils.java index 89f2ceb57f9..eec89d616af 100644 --- a/src/com/android/settings/accessibility/AutoclickUtils.java +++ b/src/com/android/settings/accessibility/AutoclickUtils.java @@ -16,18 +16,11 @@ package com.android.settings.accessibility; -import static java.lang.annotation.RetentionPolicy.SOURCE; - -import android.annotation.IntDef; -import android.annotation.PluralsRes; import android.annotation.StringRes; import android.content.Context; -import android.content.res.Resources; -import com.android.settings.R; import com.android.settingslib.utils.StringUtil; -import java.lang.annotation.Retention; import java.util.HashMap; import java.util.Map; @@ -52,16 +45,6 @@ public final class AutoclickUtils { */ static final int AUTOCLICK_DELAY_STEP = 100; - @Retention(SOURCE) - @IntDef({ - Quantity.ONE, - Quantity.FEW - }) - private @interface Quantity { - int ONE = 1; - int FEW = 3; - } - /** * Gets string that should be used for provided autoclick delay. * @@ -73,13 +56,12 @@ public final class AutoclickUtils { */ public static CharSequence getAutoclickDelaySummary(Context context, @StringRes int id, int delayMillis) { - final int quantity = (delayMillis == 1000) ? Quantity.ONE : Quantity.FEW; final float delaySecond = (float) delayMillis / 1000; // Only show integer when delay time is 1. final String decimalFormat = (delaySecond == 1) ? "%.0f" : "%.1f"; Map arguments = new HashMap<>(); - arguments.put("count", quantity); + arguments.put("count", delaySecond); arguments.put("time", String.format(decimalFormat, delaySecond)); return StringUtil.getIcuPluralsString(context, arguments, id); } From 8aeca8e75552f97dfcb8d70cb7fab86e3ebcd934 Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Thu, 10 Oct 2024 14:41:24 +0800 Subject: [PATCH 5/9] Disable the phone number when no subscription To align with SIM status, if no sim in this slot, show "Not available" and disable instead. Fix: 333386151 Flag: EXEMPT bug fix Test: manual - on about phone Test: unit test Change-Id: I5053863cc69ff468036df87a8c87447ab0c2aaed --- .../PhoneNumberPreferenceController.java | 23 ++++++------------- .../PhoneNumberPreferenceControllerTest.java | 11 ++++----- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java index 6df100ca4ec..421963eb31c 100644 --- a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java +++ b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java @@ -84,7 +84,7 @@ public class PhoneNumberPreferenceController extends BasePreferenceController { for (int simSlotNumber = 0; simSlotNumber < mPreferenceList.size(); simSlotNumber++) { final Preference simStatusPreference = mPreferenceList.get(simSlotNumber); simStatusPreference.setTitle(getPreferenceTitle(simSlotNumber)); - simStatusPreference.setSummary(getPhoneNumber(simSlotNumber)); + setPhoneNumber(simSlotNumber); } } @@ -93,24 +93,15 @@ public class PhoneNumberPreferenceController extends BasePreferenceController { return true; } - private CharSequence getFirstPhoneNumber() { - final List subscriptionInfoList = - mSubscriptionManager.getActiveSubscriptionInfoList(); - if (subscriptionInfoList == null || subscriptionInfoList.isEmpty()) { - return mContext.getText(R.string.device_info_default); - } - - // For now, We only return first result for slice view. - return getFormattedPhoneNumber(subscriptionInfoList.get(0)); - } - - private CharSequence getPhoneNumber(int simSlot) { + private void setPhoneNumber(int simSlot) { + final Preference simStatusPreference = mPreferenceList.get(simSlot); final SubscriptionInfo subscriptionInfo = getSubscriptionInfo(simSlot); + simStatusPreference.setEnabled(subscriptionInfo != null); if (subscriptionInfo == null) { - return mContext.getText(R.string.device_info_default); + simStatusPreference.setSummary(mContext.getString(R.string.device_info_not_available)); + } else { + simStatusPreference.setSummary(getFormattedPhoneNumber(subscriptionInfo)); } - - return getFormattedPhoneNumber(subscriptionInfo); } private CharSequence getPreferenceTitle(int simSlot) { diff --git a/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java index 9a5399c5f07..05e2f246dbd 100644 --- a/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java +++ b/tests/unit/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java @@ -37,6 +37,7 @@ import androidx.preference.PreferenceScreen; import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.android.settings.R; import com.android.settings.testutils.ResourcesUtils; import org.junit.Before; @@ -135,25 +136,23 @@ public class PhoneNumberPreferenceControllerTest { } @Test - public void getSummary_cannotGetActiveSubscriptionInfo_shouldShowUnknown() { + public void getSummary_cannotGetActiveSubscriptionInfo_shouldShowNotAvailable() { when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(null); mController.displayPreference(mScreen); mController.updateState(mPreference); - verify(mPreference).setSummary(ResourcesUtils.getResourcesString( - mContext, "device_info_default")); + verify(mPreference).setSummary(mContext.getString(R.string.device_info_not_available)); } @Test - public void getSummary_getEmptySubscriptionInfo_shouldShowUnknown() { + public void getSummary_getEmptySubscriptionInfo_shouldShowNotAvailable() { List infos = new ArrayList<>(); when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(infos); mController.displayPreference(mScreen); mController.updateState(mPreference); - verify(mPreference).setSummary(ResourcesUtils.getResourcesString( - mContext, "device_info_default")); + verify(mPreference).setSummary(mContext.getString(R.string.device_info_not_available)); } } From ea06748ee2e14301beb5440fa7e810599f1e0c73 Mon Sep 17 00:00:00 2001 From: Riley Jones Date: Tue, 8 Oct 2024 21:33:55 +0000 Subject: [PATCH 6/9] Provides an ordered array of shortcut types so Settings presents shortcuts in the desired order NO_IFTTT=corrects ui order Flag: android.provider.a11y_standalone_gesture_enabled Test: atest AccessibilityUtilTest Bug: 371463731 Change-Id: Ia1864076faa281cf57c469a2d0d34f859858d859 --- res/xml/accessibility_edit_shortcuts.xml | 8 +------- .../AccessibilityShortcutsTutorial.java | 5 +---- .../accessibility/AccessibilityUtil.java | 19 +++++++++++++------ .../accessibility/PreferredShortcuts.java | 3 +-- ...ScreenMagnificationPreferenceFragment.java | 5 ++--- 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/res/xml/accessibility_edit_shortcuts.xml b/res/xml/accessibility_edit_shortcuts.xml index bb555271864..77c09dace28 100644 --- a/res/xml/accessibility_edit_shortcuts.xml +++ b/res/xml/accessibility_edit_shortcuts.xml @@ -90,11 +90,5 @@ settings:allowDividerAbove="false" settings:allowDividerBelow="false" settings:controller="com.android.settings.accessibility.shortcuts.TripleTapShortcutOptionController" /> - + \ No newline at end of file diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java b/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java index de3cb8a7b46..c613181d489 100644 --- a/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java +++ b/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java @@ -64,7 +64,6 @@ import androidx.core.widget.TextViewCompat; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; -import com.android.internal.accessibility.common.ShortcutConstants; import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType; import com.android.internal.accessibility.util.ShortcutUtils; import com.android.settings.R; @@ -490,11 +489,10 @@ public final class AccessibilityShortcutsTutorial { static List createShortcutTutorialPages( @NonNull Context context, int shortcutTypes, @NonNull CharSequence featureName, boolean inSetupWizard) { - // LINT.IfChange(shortcut_type_ui_order) final List tutorialPages = new ArrayList<>(); int buttonMode = ShortcutUtils.getButtonMode(context, context.getUserId()); - for (int shortcutType: ShortcutConstants.USER_SHORTCUT_TYPES) { + for (int shortcutType: AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { if ((shortcutTypes & shortcutType) == 0) { continue; } @@ -506,7 +504,6 @@ public final class AccessibilityShortcutsTutorial { createShortcutTutorialPage( context, shortcutType, buttonMode, featureName, inSetupWizard)); } - // LINT.ThenChange(/res/xml/accessibility_edit_shortcuts.xml:shortcut_type_ui_order) return tutorialPages; } diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java index 5e178db2f89..82d32815bf5 100644 --- a/src/com/android/settings/accessibility/AccessibilityUtil.java +++ b/src/com/android/settings/accessibility/AccessibilityUtil.java @@ -50,7 +50,6 @@ import androidx.annotation.NonNull; import androidx.annotation.StringRes; import androidx.annotation.VisibleForTesting; -import com.android.internal.accessibility.common.ShortcutConstants; import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType; import com.android.internal.accessibility.util.ShortcutUtils; import com.android.settings.R; @@ -66,6 +65,16 @@ import java.util.StringJoiner; /** Provides utility methods to accessibility settings only. */ public final class AccessibilityUtil { + // LINT.IfChange(shortcut_type_ui_order) + static final int[] SHORTCUTS_ORDER_IN_UI = { + QUICK_SETTINGS, + SOFTWARE, // FAB displays before gesture. Navbar displays without gesture. + GESTURE, + HARDWARE, + TWOFINGER_DOUBLETAP, + TRIPLETAP + }; + // LINT.ThenChange(/res/xml/accessibility_edit_shortcuts.xml:shortcut_type_ui_order) private AccessibilityUtil(){} @@ -344,7 +353,7 @@ public final class AccessibilityUtil { */ static boolean hasValuesInSettings(Context context, int shortcutTypes, @NonNull ComponentName componentName) { - for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) { + for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { if (!android.view.accessibility.Flags.a11yQsShortcut()) { if ((shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) { continue; @@ -395,7 +404,7 @@ public final class AccessibilityUtil { static int getUserShortcutTypesFromSettings(Context context, @NonNull ComponentName componentName) { int shortcutTypes = DEFAULT; - for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) { + for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { if (!android.view.accessibility.Flags.a11yQsShortcut()) { if ((shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) { continue; @@ -511,8 +520,7 @@ public final class AccessibilityUtil { public static CharSequence getShortcutSummaryList(Context context, int shortcutTypes) { final List list = new ArrayList<>(); - // LINT.IfChange(shortcut_type_ui_order) - for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) { + for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { if (!android.view.accessibility.Flags.a11yQsShortcut() && (shortcutType & QUICK_SETTINGS) == QUICK_SETTINGS) { continue; @@ -548,7 +556,6 @@ public final class AccessibilityUtil { list.sort(CharSequence::compare); return CaseMap.toTitle().wholeString().noLowercase().apply(Locale.getDefault(), /* iter= */ null, LocaleUtils.getConcatenatedString(list)); - // LINT.ThenChange(/res/xml/accessibility_edit_shortcuts.xml:shortcut_type_ui_order) } @VisibleForTesting diff --git a/src/com/android/settings/accessibility/PreferredShortcuts.java b/src/com/android/settings/accessibility/PreferredShortcuts.java index c3e64ab9ab0..9006609091d 100644 --- a/src/com/android/settings/accessibility/PreferredShortcuts.java +++ b/src/com/android/settings/accessibility/PreferredShortcuts.java @@ -30,7 +30,6 @@ import android.view.accessibility.Flags; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; -import com.android.internal.accessibility.common.ShortcutConstants; import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType; import com.android.internal.accessibility.util.ShortcutUtils; @@ -123,7 +122,7 @@ public final class PreferredShortcuts { public static void updatePreferredShortcutsFromSettings( @NonNull Context context, @NonNull Set components) { final Map> shortcutTypeToTargets = new ArrayMap<>(); - for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) { + for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { if (!Flags.a11yQsShortcut() && shortcutType == QUICK_SETTINGS) { // Skip saving quick setting as preferred shortcut option when flag is not enabled diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java index ee49450f82d..68089d50d7e 100644 --- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java @@ -55,7 +55,6 @@ import androidx.preference.Preference; import androidx.preference.PreferenceCategory; import androidx.preference.SwitchPreferenceCompat; -import com.android.internal.accessibility.common.ShortcutConstants; import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType; import com.android.internal.annotations.VisibleForTesting; import com.android.server.accessibility.Flags; @@ -740,7 +739,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends @VisibleForTesting static boolean hasMagnificationValuesInSettings(Context context, int shortcutTypes) { - for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) { + for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { if ((shortcutTypes & shortcutType) == 0) { continue; } @@ -791,7 +790,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends private static int getUserShortcutTypeFromSettings(Context context) { int shortcutTypes = DEFAULT; - for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) { + for (int shortcutType : AccessibilityUtil.SHORTCUTS_ORDER_IN_UI) { if ((shortcutType & (TWOFINGER_DOUBLETAP | QUICK_SETTINGS | GESTURE | TRIPLETAP)) == shortcutType && !android.view.accessibility.Flags.a11yQsShortcut()) { From ae4ec175c9255a663b0e6f8b0e8a220c34ceda42 Mon Sep 17 00:00:00 2001 From: Wesley Wang Date: Fri, 11 Oct 2024 02:54:38 +0000 Subject: [PATCH 7/9] Fix BatterySaverScheduleRadioButtonsControllerTest Test was failing because it was not setting the EXTRA_LOW_POWER_WARNING_ACKNOWLEDGED setting. Change-Id: Id9e95c0240908dafbaa791e7f4f4b9ded9d39d9b Test: atest BatterySaverScheduleRadioButtonsControllerTest Bug: 370883745 Fix: 370883745 Flag: EXEMPT for simple bug fix --- .../BatterySaverScheduleRadioButtonsControllerTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java b/tests/unit/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java index bb2d2ef4674..f0a24844659 100644 --- a/tests/unit/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java +++ b/tests/unit/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java @@ -53,6 +53,8 @@ public class BatterySaverScheduleRadioButtonsControllerTest { public void setDefaultKey_percentage_shouldSuppressNotification() { Secure.putInt( mContext.getContentResolver(), Secure.LOW_POWER_WARNING_ACKNOWLEDGED, 1); + Secure.putInt( + mContext.getContentResolver(), Secure.EXTRA_LOW_POWER_WARNING_ACKNOWLEDGED, 1); Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE, PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE); Settings.Global.putInt(mResolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 5); From 29036fd2a9e9236a9d2b5900af5f7d89c3d12dbe Mon Sep 17 00:00:00 2001 From: Mill Chen Date: Tue, 8 Oct 2024 11:23:43 +0000 Subject: [PATCH 8/9] Sound screen migration - Add a flag for sound and vibration migration - Adding skeleton of sound screen Bug: 360015496 Test: atest SoundScreenTest Flag: com.android.settings.flags.catalyst_sound_screen Change-Id: Id3a51663d3c1203be0046d12b312c5b64dc26683 --- aconfig/catalyst/sound_screen.aconfig | 9 ++++ .../settings/notification/SoundScreen.kt | 47 ++++++++++++++++ .../settings/notification/SoundSettings.java | 35 +++++++----- .../settings/notification/SoundScreenTest.kt | 53 +++++++++++++++++++ 4 files changed, 131 insertions(+), 13 deletions(-) create mode 100644 aconfig/catalyst/sound_screen.aconfig create mode 100644 src/com/android/settings/notification/SoundScreen.kt create mode 100644 tests/robotests/src/com/android/settings/notification/SoundScreenTest.kt diff --git a/aconfig/catalyst/sound_screen.aconfig b/aconfig/catalyst/sound_screen.aconfig new file mode 100644 index 00000000000..ea5f77131dc --- /dev/null +++ b/aconfig/catalyst/sound_screen.aconfig @@ -0,0 +1,9 @@ +package: "com.android.settings.flags" +container: "system" + +flag { + name: "catalyst_sound_screen" + namespace: "android_settings" + description: "Flag for sound and vibration page" + bug: "323791114" +} \ No newline at end of file diff --git a/src/com/android/settings/notification/SoundScreen.kt b/src/com/android/settings/notification/SoundScreen.kt new file mode 100644 index 00000000000..ecb0c85ed5d --- /dev/null +++ b/src/com/android/settings/notification/SoundScreen.kt @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2024 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.notification + +import android.content.Context +import androidx.fragment.app.Fragment +import com.android.settings.R +import com.android.settings.flags.Flags +import com.android.settingslib.metadata.ProvidePreferenceScreen +import com.android.settingslib.metadata.preferenceHierarchy +import com.android.settingslib.preference.PreferenceScreenCreator + +@ProvidePreferenceScreen +class SoundScreen : PreferenceScreenCreator { + override val key: String + get() = KEY + + override val title: Int + get() = R.string.sound_settings + + override val keywords: Int + get() = R.string.keywords_sounds + + override fun isFlagEnabled(context: Context): Boolean = Flags.catalystSoundScreen() + + override fun fragmentClass(): Class? = SoundSettings::class.java + + override fun getPreferenceHierarchy(context: Context) = + preferenceHierarchy(this) {} + + companion object { + const val KEY = "sound_screen" + } +} \ No newline at end of file diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java index 4575708bbbd..596f19bc62a 100644 --- a/src/com/android/settings/notification/SoundSettings.java +++ b/src/com/android/settings/notification/SoundSettings.java @@ -29,6 +29,8 @@ import android.os.UserHandle; import android.preference.SeekBarVolumizer; import android.text.TextUtils; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.preference.ListPreference; import androidx.preference.Preference; @@ -193,21 +195,23 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult @Override public void onAttach(Context context) { super.onAttach(context); - ArrayList volumeControllers = new ArrayList<>(); - volumeControllers.add(use(AlarmVolumePreferenceController.class)); - volumeControllers.add(use(MediaVolumePreferenceController.class)); - volumeControllers.add(use(SeparateRingVolumePreferenceController.class)); - volumeControllers.add(use(NotificationVolumePreferenceController.class)); - volumeControllers.add(use(CallVolumePreferenceController.class)); + if (!isCatalystEnabled()) { + ArrayList volumeControllers = new ArrayList<>(); + volumeControllers.add(use(AlarmVolumePreferenceController.class)); + volumeControllers.add(use(MediaVolumePreferenceController.class)); + volumeControllers.add(use(SeparateRingVolumePreferenceController.class)); + volumeControllers.add(use(NotificationVolumePreferenceController.class)); + volumeControllers.add(use(CallVolumePreferenceController.class)); - use(HandsFreeProfileOutputPreferenceController.class).setCallback(listPreference -> - onPreferenceDataChanged(listPreference)); - mHfpOutputControllerKey = - use(HandsFreeProfileOutputPreferenceController.class).getPreferenceKey(); + use(HandsFreeProfileOutputPreferenceController.class).setCallback(listPreference -> + onPreferenceDataChanged(listPreference)); + mHfpOutputControllerKey = + use(HandsFreeProfileOutputPreferenceController.class).getPreferenceKey(); - for (VolumeSeekBarPreferenceController controller : volumeControllers) { - controller.setCallback(mVolumeCallback); - getSettingsLifecycle().addObserver(controller); + for (VolumeSeekBarPreferenceController controller : volumeControllers) { + controller.setCallback(mVolumeCallback); + getSettingsLifecycle().addObserver(controller); + } } } @@ -321,4 +325,9 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult mDialogFragment.onListPreferenceUpdated(preference); } } + + @Override + public @Nullable String getPreferenceScreenBindingKey(@NonNull Context context) { + return SoundScreen.KEY; + } } diff --git a/tests/robotests/src/com/android/settings/notification/SoundScreenTest.kt b/tests/robotests/src/com/android/settings/notification/SoundScreenTest.kt new file mode 100644 index 00000000000..83b29d2907f --- /dev/null +++ b/tests/robotests/src/com/android/settings/notification/SoundScreenTest.kt @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 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.notification + +import android.content.Context +import android.platform.test.annotations.DisableFlags +import android.platform.test.annotations.EnableFlags +import android.platform.test.flag.junit.SetFlagsRule +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.android.settings.flags.Flags +import com.google.common.truth.Truth.assertThat +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class SoundScreenTest { + @get:Rule val setFlagsRule = SetFlagsRule() + private val context: Context = ApplicationProvider.getApplicationContext() + private val soundScreen = SoundScreen() + + @Test + fun key() { + assertThat(soundScreen.key).isEqualTo(SoundScreen.KEY) + } + + @Test + @EnableFlags(Flags.FLAG_CATALYST_SOUND_SCREEN) + fun isFlagEnabled_returnTrue() { + assertThat(soundScreen.isFlagEnabled(context)).isTrue() + } + + @Test + @DisableFlags(Flags.FLAG_CATALYST_SOUND_SCREEN) + fun isFlagEnabled_returnFalse() { + assertThat(soundScreen.isFlagEnabled(context)).isFalse() + } + +} \ No newline at end of file From 57b8d612848b067581e7b66b67fe57430890aaad Mon Sep 17 00:00:00 2001 From: Candice Date: Fri, 11 Oct 2024 07:00:49 +0000 Subject: [PATCH 9/9] Add comments for setting the searchable attribute false in DarkModePreference Bug: 354772684 Test: None Add comments for existing codes Flag: EXEMPT Add comments for existing codes Change-Id: Ida20a5e3291a3e267caa5a5db6e8f2ef27928e3c --- res/xml/accessibility_color_and_motion.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/res/xml/accessibility_color_and_motion.xml b/res/xml/accessibility_color_and_motion.xml index a500b72d958..6b47a9d62f5 100644 --- a/res/xml/accessibility_color_and_motion.xml +++ b/res/xml/accessibility_color_and_motion.xml @@ -39,6 +39,8 @@ settings:keywords="@string/keywords_color_inversion" settings:controller="com.android.settings.accessibility.ColorInversionPreferenceController"/> +