diff options
| author | 2024-06-04 13:25:50 +0000 | |
|---|---|---|
| committer | 2024-06-04 13:25:50 +0000 | |
| commit | fc6ff5a9b0cf64c17cb46ba32537fd21c208ba8a (patch) | |
| tree | 2a97c7eb70389a801eee4a2e83981ffa5b518930 | |
| parent | 584f2b26530558ddd6894aadd0f0cd344b181ebd (diff) | |
| parent | 129343f7bdbd04b0e4959301cc23a8ea71f89297 (diff) | |
Merge "Add focus outline to the brightness slider" into main
7 files changed, 77 insertions, 7 deletions
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig index 2cb297ad1359..919d7f081f9c 100644 --- a/packages/SystemUI/aconfig/systemui.aconfig +++ b/packages/SystemUI/aconfig/systemui.aconfig @@ -804,6 +804,13 @@ flag { } flag { + name: "brightness_slider_focus_state" + namespace: "systemui" + description: "enables new focus outline for the brightness slider when focused on with physical keyboard" + bug: "329244723" +} + +flag { name: "edgeback_gesture_handler_get_running_tasks_background" namespace: "systemui" description: "Decide whether to get the running tasks from activity manager in EdgebackGestureHandler" diff --git a/packages/SystemUI/res/drawable/brightness_mirror_background.xml b/packages/SystemUI/res/drawable/brightness_mirror_background.xml index b5c181bd896c..c4225f11f293 100644 --- a/packages/SystemUI/res/drawable/brightness_mirror_background.xml +++ b/packages/SystemUI/res/drawable/brightness_mirror_background.xml @@ -14,7 +14,15 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> -<shape xmlns:android="http://schemas.android.com/apk/res/android"> - <solid android:color="?attr/underSurface" /> - <corners android:radius="@dimen/rounded_slider_background_rounded_corner" /> -</shape> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:left="@dimen/rounded_slider_boundary_offset" + android:right="@dimen/rounded_slider_boundary_offset" + android:top="@dimen/rounded_slider_boundary_offset" + android:bottom="@dimen/rounded_slider_boundary_offset"> + <shape> + <solid android:color="?attr/underSurface" /> + <corners android:radius="@dimen/rounded_slider_background_rounded_corner" /> + </shape> + </item> +</layer-list> diff --git a/packages/SystemUI/res/drawable/brightness_slider_focus_bg.xml b/packages/SystemUI/res/drawable/brightness_slider_focus_bg.xml new file mode 100644 index 000000000000..22406ec52d00 --- /dev/null +++ b/packages/SystemUI/res/drawable/brightness_slider_focus_bg.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ 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. + --> + +<selector + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"> + <item android:state_focused="true"> + <inset android:inset="-5dp"> + <shape> + <corners android:radius="16dp"/> + <stroke android:width="3dp" android:color="?androidprv:attr/materialColorSecondaryFixed"/> + </shape> + </inset> + </item> +</selector>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml b/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml index e95c6a79733c..62ceb07d5a4e 100644 --- a/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml +++ b/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml @@ -17,19 +17,20 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/brightness_slider" android:layout_width="match_parent" - android:layout_height="@dimen/brightness_mirror_height" + android:layout_height="wrap_content" android:layout_gravity="center" + android:clipChildren="false" + android:clipToPadding="false" android:contentDescription="@string/accessibility_brightness" android:importantForAccessibility="no" > <com.android.systemui.settings.brightness.ToggleSeekBar android:id="@+id/slider" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="@dimen/brightness_mirror_height" android:layout_gravity="center_vertical" android:minHeight="48dp" android:thumb="@null" - android:background="@null" android:paddingStart="0dp" android:paddingEnd="0dp" android:progressDrawable="@drawable/brightness_progress_drawable" diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 8ce20684d892..f6ab4c854614 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1674,6 +1674,7 @@ <dimen name="rounded_slider_background_padding">8dp</dimen> <!-- rounded_slider_corner_radius + rounded_slider_background_padding --> <dimen name="rounded_slider_background_rounded_corner">32dp</dimen> + <dimen name="rounded_slider_boundary_offset">16dp</dimen> <!-- Location on the screen of the center of the physical power button. This is a reasonable default that should be overridden by device-specific overlays. --> diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSliderView.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSliderView.java index 92006a473ed8..a39d25a5ef30 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSliderView.java +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSliderView.java @@ -67,6 +67,7 @@ public class BrightnessSliderView extends FrameLayout { mSlider = requireViewById(R.id.slider); mSlider.setAccessibilityLabel(getContentDescription().toString()); + setBoundaryOffset(); // Finds the progress drawable. Assumes brightness_progress_drawable.xml try { @@ -80,6 +81,17 @@ public class BrightnessSliderView extends FrameLayout { } } + private void setBoundaryOffset() { + // BrightnessSliderView uses hardware layer; if the background of its children exceed its + // boundary, it'll be cropped. We need to expand its boundary so that the background of + // ToggleSeekBar (i.e. the focus state) can be correctly rendered. + int offset = getResources().getDimensionPixelSize(R.dimen.rounded_slider_boundary_offset); + MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams(); + lp.setMargins(-offset, -offset, -offset, -offset); + setLayoutParams(lp); + setPadding(offset, offset, offset, offset); + } + /** * Attaches a listener to relay touch events. * @param listener use {@code null} to remove listener diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSeekBar.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSeekBar.java index 84156eeb9264..30b6892731f1 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSeekBar.java +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSeekBar.java @@ -16,12 +16,16 @@ package com.android.systemui.settings.brightness; +import static com.android.systemui.Flags.brightnessSliderFocusState; + import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.SeekBar; +import com.android.systemui.res.R; + public class ToggleSeekBar extends SeekBar { private String mAccessibilityLabel; @@ -61,6 +65,14 @@ public class ToggleSeekBar extends SeekBar { return true; } + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + if (brightnessSliderFocusState()) { + setBackground(mContext.getDrawable(R.drawable.brightness_slider_focus_bg)); + } + } + public void setAccessibilityLabel(String label) { mAccessibilityLabel = label; } |