Loading packages/SystemUI/res/layout/seekbar_with_icon_buttons.xml +56 −43 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ 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. --> 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. --> <merge xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/seekbar_frame" Loading @@ -25,17 +24,24 @@ android:orientation="horizontal" tools:parentTag="android.widget.LinearLayout"> <FrameLayout android:id="@+id/icon_start_frame" android:layout_width="@dimen/min_clickable_item_size" android:layout_height="@dimen/min_clickable_item_size" android:clipChildren="false" android:focusable="true" > <ImageView android:id="@+id/icon_start" android:layout_width="@dimen/magnification_setting_seekbar_icon_size" android:layout_height="@dimen/magnification_setting_seekbar_icon_size" android:layout_width="@dimen/seekbar_icon_size" android:layout_height="@dimen/seekbar_icon_size" android:layout_gravity="center" android:background="?android:attr/selectableItemBackgroundBorderless" android:adjustViewBounds="true" android:focusable="true" android:focusable="false" android:src="@drawable/ic_remove" android:tint="?android:attr/textColorPrimary" android:tintMode="src_in" /> </FrameLayout> <SeekBar android:id="@+id/seekbar" Loading @@ -45,16 +51,23 @@ android:layout_gravity="center_vertical" android:layout_weight="1" /> <FrameLayout android:id="@+id/icon_end_frame" android:layout_width="@dimen/min_clickable_item_size" android:layout_height="@dimen/min_clickable_item_size" android:clipChildren="false" android:focusable="true" > <ImageView android:id="@+id/icon_end" android:layout_width="@dimen/magnification_setting_seekbar_icon_size" android:layout_height="@dimen/magnification_setting_seekbar_icon_size" android:layout_width="@dimen/seekbar_icon_size" android:layout_height="@dimen/seekbar_icon_size" android:layout_gravity="center" android:background="?android:attr/selectableItemBackgroundBorderless" android:adjustViewBounds="true" android:focusable="true" android:focusable="false" android:src="@drawable/ic_add" android:tint="?android:attr/textColorPrimary" android:tintMode="src_in" /> </FrameLayout> </merge> packages/SystemUI/res/values/dimens.xml +2 −1 Original line number Diff line number Diff line Loading @@ -1183,8 +1183,9 @@ <dimen name="magnification_setting_image_button_padding_horizontal">24dp</dimen> <dimen name="magnification_setting_image_button_open_in_full_padding_vertical">16dp</dimen> <dimen name="magnification_setting_image_button_open_in_full_padding_horizontal">28dp</dimen> <dimen name="magnification_setting_seekbar_icon_size">24dp</dimen> <!-- Seekbar with icon buttons --> <dimen name="seekbar_icon_size">24dp</dimen> <!-- How far from the right edge of the screen you need to drag the window before the button repositions to the other side. --> Loading packages/SystemUI/src/com/android/systemui/common/ui/view/SeekBarWithIconButtonsView.java +23 −15 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.SeekBar; Loading @@ -37,6 +38,8 @@ public class SeekBarWithIconButtonsView extends LinearLayout { private static final int DEFAULT_SEEKBAR_MAX = 6; private static final int DEFAULT_SEEKBAR_PROGRESS = 0; private ViewGroup mIconStartFrame; private ViewGroup mIconEndFrame; private ImageView mIconStart; private ImageView mIconEnd; private SeekBar mSeekbar; Loading @@ -62,6 +65,8 @@ public class SeekBarWithIconButtonsView extends LinearLayout { LayoutInflater.from(context).inflate( R.layout.seekbar_with_icon_buttons, this, /* attachToRoot= */ true); mIconStartFrame = findViewById(R.id.icon_start_frame); mIconEndFrame = findViewById(R.id.icon_end_frame); mIconStart = findViewById(R.id.icon_start); mIconEnd = findViewById(R.id.icon_end); mSeekbar = findViewById(R.id.seekbar); Loading @@ -80,24 +85,22 @@ public class SeekBarWithIconButtonsView extends LinearLayout { mSeekbar.setMax(max); setProgress(progress); int iconStartContentDescriptionId = typedArray.getResourceId( int iconStartFrameContentDescriptionId = typedArray.getResourceId( R.styleable.SeekBarWithIconButtonsView_Layout_iconStartContentDescription, /* defValue= */ 0); int iconEndContentDescriptionId = typedArray.getResourceId( int iconEndFrameContentDescriptionId = typedArray.getResourceId( R.styleable.SeekBarWithIconButtonsView_Layout_iconEndContentDescription, /* defValue= */ 0); if (iconStartContentDescriptionId != 0) { if (iconStartFrameContentDescriptionId != 0) { final String contentDescription = context.getString(iconStartContentDescriptionId); mIconStart.setContentDescription(contentDescription); context.getString(iconStartFrameContentDescriptionId); mIconStartFrame.setContentDescription(contentDescription); } if (iconEndContentDescriptionId != 0) { if (iconEndFrameContentDescriptionId != 0) { final String contentDescription = context.getString(iconEndContentDescriptionId); mIconEnd.setContentDescription(contentDescription); context.getString(iconEndFrameContentDescriptionId); mIconEndFrame.setContentDescription(contentDescription); } typedArray.recycle(); } else { mSeekbar.setMax(DEFAULT_SEEKBAR_MAX); setProgress(DEFAULT_SEEKBAR_PROGRESS); Loading @@ -109,7 +112,7 @@ public class SeekBarWithIconButtonsView extends LinearLayout { final int progress = mSeekbar.getProgress(); if (progress > 0) { mSeekbar.setProgress(progress - 1); setIconViewEnabled(mIconStart, mSeekbar.getProgress() > 0); setIconViewAndFrameEnabled(mIconStart, mSeekbar.getProgress() > 0); } }); Loading @@ -117,13 +120,15 @@ public class SeekBarWithIconButtonsView extends LinearLayout { final int progress = mSeekbar.getProgress(); if (progress < mSeekbar.getMax()) { mSeekbar.setProgress(progress + 1); setIconViewEnabled(mIconEnd, mSeekbar.getProgress() < mSeekbar.getMax()); setIconViewAndFrameEnabled(mIconEnd, mSeekbar.getProgress() < mSeekbar.getMax()); } }); } private static void setIconViewEnabled(View iconView, boolean enabled) { private static void setIconViewAndFrameEnabled(View iconView, boolean enabled) { iconView.setEnabled(enabled); final ViewGroup iconFrame = (ViewGroup) iconView.getParent(); iconFrame.setEnabled(enabled); } /** Loading @@ -141,12 +146,15 @@ public class SeekBarWithIconButtonsView extends LinearLayout { * Icon End will need to be enabled when the seekbar progress is less than Max. */ private void updateIconViewIfNeeded(int progress) { setIconViewEnabled(mIconStart, progress > 0); setIconViewEnabled(mIconEnd, progress < mSeekbar.getMax()); setIconViewAndFrameEnabled(mIconStart, progress > 0); setIconViewAndFrameEnabled(mIconEnd, progress < mSeekbar.getMax()); } /** * Sets progress to the seekbar in the layout. * If the progress is smaller than or equals to 0, the IconStart will be disabled. If the * progress is larger than or equals to Max, the IconEnd will be disabled. The seekbar progress * will be constrained in {@link SeekBar}. */ public void setProgress(int progress) { mSeekbar.setProgress(progress); Loading Loading
packages/SystemUI/res/layout/seekbar_with_icon_buttons.xml +56 −43 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ 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. --> 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. --> <merge xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/seekbar_frame" Loading @@ -25,17 +24,24 @@ android:orientation="horizontal" tools:parentTag="android.widget.LinearLayout"> <FrameLayout android:id="@+id/icon_start_frame" android:layout_width="@dimen/min_clickable_item_size" android:layout_height="@dimen/min_clickable_item_size" android:clipChildren="false" android:focusable="true" > <ImageView android:id="@+id/icon_start" android:layout_width="@dimen/magnification_setting_seekbar_icon_size" android:layout_height="@dimen/magnification_setting_seekbar_icon_size" android:layout_width="@dimen/seekbar_icon_size" android:layout_height="@dimen/seekbar_icon_size" android:layout_gravity="center" android:background="?android:attr/selectableItemBackgroundBorderless" android:adjustViewBounds="true" android:focusable="true" android:focusable="false" android:src="@drawable/ic_remove" android:tint="?android:attr/textColorPrimary" android:tintMode="src_in" /> </FrameLayout> <SeekBar android:id="@+id/seekbar" Loading @@ -45,16 +51,23 @@ android:layout_gravity="center_vertical" android:layout_weight="1" /> <FrameLayout android:id="@+id/icon_end_frame" android:layout_width="@dimen/min_clickable_item_size" android:layout_height="@dimen/min_clickable_item_size" android:clipChildren="false" android:focusable="true" > <ImageView android:id="@+id/icon_end" android:layout_width="@dimen/magnification_setting_seekbar_icon_size" android:layout_height="@dimen/magnification_setting_seekbar_icon_size" android:layout_width="@dimen/seekbar_icon_size" android:layout_height="@dimen/seekbar_icon_size" android:layout_gravity="center" android:background="?android:attr/selectableItemBackgroundBorderless" android:adjustViewBounds="true" android:focusable="true" android:focusable="false" android:src="@drawable/ic_add" android:tint="?android:attr/textColorPrimary" android:tintMode="src_in" /> </FrameLayout> </merge>
packages/SystemUI/res/values/dimens.xml +2 −1 Original line number Diff line number Diff line Loading @@ -1183,8 +1183,9 @@ <dimen name="magnification_setting_image_button_padding_horizontal">24dp</dimen> <dimen name="magnification_setting_image_button_open_in_full_padding_vertical">16dp</dimen> <dimen name="magnification_setting_image_button_open_in_full_padding_horizontal">28dp</dimen> <dimen name="magnification_setting_seekbar_icon_size">24dp</dimen> <!-- Seekbar with icon buttons --> <dimen name="seekbar_icon_size">24dp</dimen> <!-- How far from the right edge of the screen you need to drag the window before the button repositions to the other side. --> Loading
packages/SystemUI/src/com/android/systemui/common/ui/view/SeekBarWithIconButtonsView.java +23 −15 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.SeekBar; Loading @@ -37,6 +38,8 @@ public class SeekBarWithIconButtonsView extends LinearLayout { private static final int DEFAULT_SEEKBAR_MAX = 6; private static final int DEFAULT_SEEKBAR_PROGRESS = 0; private ViewGroup mIconStartFrame; private ViewGroup mIconEndFrame; private ImageView mIconStart; private ImageView mIconEnd; private SeekBar mSeekbar; Loading @@ -62,6 +65,8 @@ public class SeekBarWithIconButtonsView extends LinearLayout { LayoutInflater.from(context).inflate( R.layout.seekbar_with_icon_buttons, this, /* attachToRoot= */ true); mIconStartFrame = findViewById(R.id.icon_start_frame); mIconEndFrame = findViewById(R.id.icon_end_frame); mIconStart = findViewById(R.id.icon_start); mIconEnd = findViewById(R.id.icon_end); mSeekbar = findViewById(R.id.seekbar); Loading @@ -80,24 +85,22 @@ public class SeekBarWithIconButtonsView extends LinearLayout { mSeekbar.setMax(max); setProgress(progress); int iconStartContentDescriptionId = typedArray.getResourceId( int iconStartFrameContentDescriptionId = typedArray.getResourceId( R.styleable.SeekBarWithIconButtonsView_Layout_iconStartContentDescription, /* defValue= */ 0); int iconEndContentDescriptionId = typedArray.getResourceId( int iconEndFrameContentDescriptionId = typedArray.getResourceId( R.styleable.SeekBarWithIconButtonsView_Layout_iconEndContentDescription, /* defValue= */ 0); if (iconStartContentDescriptionId != 0) { if (iconStartFrameContentDescriptionId != 0) { final String contentDescription = context.getString(iconStartContentDescriptionId); mIconStart.setContentDescription(contentDescription); context.getString(iconStartFrameContentDescriptionId); mIconStartFrame.setContentDescription(contentDescription); } if (iconEndContentDescriptionId != 0) { if (iconEndFrameContentDescriptionId != 0) { final String contentDescription = context.getString(iconEndContentDescriptionId); mIconEnd.setContentDescription(contentDescription); context.getString(iconEndFrameContentDescriptionId); mIconEndFrame.setContentDescription(contentDescription); } typedArray.recycle(); } else { mSeekbar.setMax(DEFAULT_SEEKBAR_MAX); setProgress(DEFAULT_SEEKBAR_PROGRESS); Loading @@ -109,7 +112,7 @@ public class SeekBarWithIconButtonsView extends LinearLayout { final int progress = mSeekbar.getProgress(); if (progress > 0) { mSeekbar.setProgress(progress - 1); setIconViewEnabled(mIconStart, mSeekbar.getProgress() > 0); setIconViewAndFrameEnabled(mIconStart, mSeekbar.getProgress() > 0); } }); Loading @@ -117,13 +120,15 @@ public class SeekBarWithIconButtonsView extends LinearLayout { final int progress = mSeekbar.getProgress(); if (progress < mSeekbar.getMax()) { mSeekbar.setProgress(progress + 1); setIconViewEnabled(mIconEnd, mSeekbar.getProgress() < mSeekbar.getMax()); setIconViewAndFrameEnabled(mIconEnd, mSeekbar.getProgress() < mSeekbar.getMax()); } }); } private static void setIconViewEnabled(View iconView, boolean enabled) { private static void setIconViewAndFrameEnabled(View iconView, boolean enabled) { iconView.setEnabled(enabled); final ViewGroup iconFrame = (ViewGroup) iconView.getParent(); iconFrame.setEnabled(enabled); } /** Loading @@ -141,12 +146,15 @@ public class SeekBarWithIconButtonsView extends LinearLayout { * Icon End will need to be enabled when the seekbar progress is less than Max. */ private void updateIconViewIfNeeded(int progress) { setIconViewEnabled(mIconStart, progress > 0); setIconViewEnabled(mIconEnd, progress < mSeekbar.getMax()); setIconViewAndFrameEnabled(mIconStart, progress > 0); setIconViewAndFrameEnabled(mIconEnd, progress < mSeekbar.getMax()); } /** * Sets progress to the seekbar in the layout. * If the progress is smaller than or equals to 0, the IconStart will be disabled. If the * progress is larger than or equals to Max, the IconEnd will be disabled. The seekbar progress * will be constrained in {@link SeekBar}. */ public void setProgress(int progress) { mSeekbar.setProgress(progress); Loading