From b61e129f358ca0d8e02d92618a0b1f2a4efd492a Mon Sep 17 00:00:00 2001 From: Omer Osman Date: Fri, 22 Apr 2022 02:10:26 +0000 Subject: [PATCH 1/2] Add support for selection of Opus in Developer Options Stub implementation for LC3 is added due to the interfaces being present. The BT stack does not currently implement LC3 over A2DP. Bug: 226441860 Test: BluetoothCodecDialogPreferenceControllerTest Change-Id: I40546c97370872b37c0258d10e67a3871f9d9af5 --- res/layout/bluetooth_audio_codec_dialog.xml | 9 ++++ ...ctBluetoothDialogPreferenceController.java | 6 ++- .../BluetoothCodecDialogPreference.java | 2 + ...etoothCodecDialogPreferenceController.java | 13 +++++ ...thCodecDialogPreferenceControllerTest.java | 54 ++++++++++++++++--- 5 files changed, 76 insertions(+), 8 deletions(-) diff --git a/res/layout/bluetooth_audio_codec_dialog.xml b/res/layout/bluetooth_audio_codec_dialog.xml index 96364270558..3a260a655e7 100644 --- a/res/layout/bluetooth_audio_codec_dialog.xml +++ b/res/layout/bluetooth_audio_codec_dialog.xml @@ -54,6 +54,15 @@ + + + + + mCodecConfigs = Arrays.asList(mCodecConfigOPUS, + mCodecConfigAAC, mCodecConfigSBC); + mCodecStatus = new BluetoothCodecStatus.Builder() + .setCodecConfig(mCodecConfigOPUS) + .setCodecsSelectableCapabilities(mCodecConfigs) + .build(); + when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus); + when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn( + BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED); + mController.onBluetoothServiceConnected(mBluetoothA2dp); + + mController.onHDAudioEnabled(/* enabled= */ true); + + verify(mBluetoothA2dpConfigStore, atLeastOnce()).setCodecType( + eq(SOURCE_CODEC_TYPE_OPUS)); // TODO(b/240635097): update in U + } + @Test public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsAAC() { - List mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC); + List mCodecConfigs = Arrays.asList(mCodecConfigOPUS, + mCodecConfigAAC, mCodecConfigSBC); mCodecStatus = new BluetoothCodecStatus.Builder() .setCodecConfig(mCodecConfigAAC) .setCodecsSelectableCapabilities(mCodecConfigs) @@ -223,7 +262,8 @@ public class BluetoothCodecDialogPreferenceControllerTest { } @Test public void onHDAudioEnabled_optionalCodecDisabled_setsCodecTypeAsSBC() { - List mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC); + List mCodecConfigs = Arrays.asList(mCodecConfigOPUS, + mCodecConfigAAC, mCodecConfigSBC); mCodecStatus = new BluetoothCodecStatus.Builder() .setCodecConfig(mCodecConfigAAC) .setCodecsSelectableCapabilities(mCodecConfigs) From 7924108893716722acfb48ccb038a86b913a6382 Mon Sep 17 00:00:00 2001 From: Edgar Wang Date: Tue, 26 Jul 2022 13:13:49 +0800 Subject: [PATCH 2/2] Apply phrase based line breaking on most of preference. Bug: 232992171 Test: manual Change-Id: I5104e9d30f744f892bd921bffa168488e1c1e625 --- res/layout/accessibility_launch_activity_preference.xml | 1 + res/layout/accessibility_shortcut_secondary_action.xml | 2 ++ res/layout/apn_preference_layout.xml | 1 + res/layout/app_preference_item.xml | 2 ++ res/layout/battery_active_view.xml | 1 + res/layout/dream_preference_layout.xml | 3 ++- res/layout/homepage_preference.xml | 2 ++ res/layout/horizontal_preference.xml | 2 ++ res/layout/notification_app.xml | 2 ++ res/layout/preference_app_restrictions.xml | 2 ++ res/layout/preference_balance_slider.xml | 1 + res/layout/preference_icon.xml | 1 + res/layout/preference_labeled_slider.xml | 2 ++ res/layout/preference_multiline_title.xml | 2 ++ res/layout/preference_progress_category.xml | 1 + res/layout/preference_radio_with_extra_widget.xml | 1 + res/layout/preference_single_target.xml | 1 + res/layout/preference_two_target_radio.xml | 1 + res/layout/radio_with_summary.xml | 2 ++ res/layout/running_services_app_item.xml | 2 ++ res/layout/settings_summary_preference.xml | 4 +++- res/layout/usage_side_label.xml | 3 ++- src/com/android/settings/core/SettingsBaseActivity.java | 7 +++++++ 23 files changed, 43 insertions(+), 3 deletions(-) diff --git a/res/layout/accessibility_launch_activity_preference.xml b/res/layout/accessibility_launch_activity_preference.xml index 0e3e2251d44..26a1c334212 100644 --- a/res/layout/accessibility_launch_activity_preference.xml +++ b/res/layout/accessibility_launch_activity_preference.xml @@ -34,5 +34,6 @@ android:ellipsize="end" android:textAppearance="?android:attr/textAppearanceListItem" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" style="@style/MainSwitchText.Settingslib" /> diff --git a/res/layout/accessibility_shortcut_secondary_action.xml b/res/layout/accessibility_shortcut_secondary_action.xml index ddbadb5b911..b3b81fe5593 100644 --- a/res/layout/accessibility_shortcut_secondary_action.xml +++ b/res/layout/accessibility_shortcut_secondary_action.xml @@ -60,6 +60,7 @@ android:singleLine="true" android:textAppearance="?android:attr/textAppearanceListItem" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" android:ellipsize="marquee" /> diff --git a/res/layout/apn_preference_layout.xml b/res/layout/apn_preference_layout.xml index 2c453aa591e..241be74fe29 100644 --- a/res/layout/apn_preference_layout.xml +++ b/res/layout/apn_preference_layout.xml @@ -52,6 +52,7 @@ android:textColor="?android:attr/textColorSecondary" android:focusable="false" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" android:maxLines="2" /> diff --git a/res/layout/app_preference_item.xml b/res/layout/app_preference_item.xml index c6857604c79..7e7ff392bd6 100755 --- a/res/layout/app_preference_item.xml +++ b/res/layout/app_preference_item.xml @@ -57,6 +57,7 @@ android:ellipsize="marquee" android:duplicateParentState="true" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" /> diff --git a/res/layout/horizontal_preference.xml b/res/layout/horizontal_preference.xml index d87963cc446..922143b4df2 100644 --- a/res/layout/horizontal_preference.xml +++ b/res/layout/horizontal_preference.xml @@ -31,6 +31,7 @@ android:layout_height="wrap_content" android:layout_width="wrap_content" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" android:layout_weight="1" /> diff --git a/res/layout/notification_app.xml b/res/layout/notification_app.xml index 2d17c8d9b15..15e83f1837b 100644 --- a/res/layout/notification_app.xml +++ b/res/layout/notification_app.xml @@ -39,6 +39,7 @@ android:singleLine="true" android:textAlignment="viewStart" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" android:textAppearance="?android:attr/textAppearanceMedium" /> diff --git a/res/layout/preference_balance_slider.xml b/res/layout/preference_balance_slider.xml index 3f1c4edfb9d..278cf793d43 100644 --- a/res/layout/preference_balance_slider.xml +++ b/res/layout/preference_balance_slider.xml @@ -46,6 +46,7 @@ android:textColor="?android:attr/textColorPrimary" android:ellipsize="marquee" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" android:fadingEdge="horizontal"/> diff --git a/res/layout/preference_labeled_slider.xml b/res/layout/preference_labeled_slider.xml index 610b79f1e13..a11d574b319 100644 --- a/res/layout/preference_labeled_slider.xml +++ b/res/layout/preference_labeled_slider.xml @@ -36,6 +36,7 @@ android:singleLine="true" android:textAppearance="?android:attr/textAppearanceListItem" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" android:textColor="?android:attr/textColorPrimary" /> diff --git a/res/layout/preference_progress_category.xml b/res/layout/preference_progress_category.xml index 9e33c5d4476..b04f5bee659 100644 --- a/res/layout/preference_progress_category.xml +++ b/res/layout/preference_progress_category.xml @@ -48,6 +48,7 @@ android:layout_gravity="start|center" android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" android:textColor="?android:attr/colorAccent"/> diff --git a/res/layout/preference_two_target_radio.xml b/res/layout/preference_two_target_radio.xml index e5e6d4a3a00..ece07464f52 100644 --- a/res/layout/preference_two_target_radio.xml +++ b/res/layout/preference_two_target_radio.xml @@ -74,6 +74,7 @@ android:textAppearance="?android:attr/textAppearanceListItemSecondary" android:textColor="?android:attr/textColorSecondary" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" android:maxLines="10" /> diff --git a/res/layout/radio_with_summary.xml b/res/layout/radio_with_summary.xml index 2f39e6746c9..ac65a0e81e4 100644 --- a/res/layout/radio_with_summary.xml +++ b/res/layout/radio_with_summary.xml @@ -34,6 +34,7 @@ android:paddingStart="20dp" android:drawableStart="?android:attr/listChoiceIndicatorSingle" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" android:ellipsize="marquee" /> @@ -45,6 +46,7 @@ android:textAppearance="?android:attr/textAppearanceListItemSecondary" android:textColor="?android:attr/textColorSecondary" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" android:maxLines="10" /> diff --git a/res/layout/running_services_app_item.xml b/res/layout/running_services_app_item.xml index f2585303aea..65328bab338 100644 --- a/res/layout/running_services_app_item.xml +++ b/res/layout/running_services_app_item.xml @@ -56,6 +56,7 @@ android:fadingEdge="horizontal" android:maxLines="2" android:hyphenationFrequency="normalFast" + android:lineBreakWordStyle="phrase" android:textAppearance="?android:attr/textAppearanceListItem"/> diff --git a/res/layout/settings_summary_preference.xml b/res/layout/settings_summary_preference.xml index 2f899e170f9..894a5e54661 100644 --- a/res/layout/settings_summary_preference.xml +++ b/res/layout/settings_summary_preference.xml @@ -33,7 +33,8 @@ android:textColor="?android:attr/textColorPrimary" android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Display1" android:hyphenationFrequency="normalFast" - /> + android:lineBreakWordStyle="phrase" + /> diff --git a/src/com/android/settings/core/SettingsBaseActivity.java b/src/com/android/settings/core/SettingsBaseActivity.java index 9c24a238051..5f15093259f 100644 --- a/src/com/android/settings/core/SettingsBaseActivity.java +++ b/src/com/android/settings/core/SettingsBaseActivity.java @@ -23,6 +23,7 @@ import android.content.ComponentName; import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.TypedArray; +import android.graphics.text.LineBreakConfig; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; @@ -109,6 +110,12 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa if (mCollapsingToolbarLayout != null) { mCollapsingToolbarLayout.setLineSpacingMultiplier(TOOLBAR_LINE_SPACING_MULTIPLIER); mCollapsingToolbarLayout.setHyphenationFrequency(HYPHENATION_FREQUENCY_NORMAL_FAST); + mCollapsingToolbarLayout.setStaticLayoutBuilderConfigurer(builder -> + builder.setLineBreakConfig( + new LineBreakConfig.Builder() + .setLineBreakWordStyle( + LineBreakConfig.LINE_BREAK_WORD_STYLE_PHRASE) + .build())); } disableCollapsingToolbarLayoutScrollingBehavior(); } else {