diff options
13 files changed, 69 insertions, 394 deletions
diff --git a/packages/SystemUI/res/drawable/brightness_progress_drawable.xml b/packages/SystemUI/res/drawable/brightness_progress_drawable.xml index 45d8dc109330..73b02f4fa481 100644 --- a/packages/SystemUI/res/drawable/brightness_progress_drawable.xml +++ b/packages/SystemUI/res/drawable/brightness_progress_drawable.xml @@ -1,37 +1,37 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2018 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. ---> -<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> +<!-- + ~ Copyright (C) 2020 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. + --> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android" + android:paddingMode="stack" > <item android:id="@android:id/background" - android:gravity="center_vertical|fill_horizontal"> - <shape android:shape="rectangle" - android:tint="?android:attr/colorControlActivated"> - <size android:height="@dimen/seek_bar_height" /> - <solid android:color="@color/white_disabled" /> - <corners android:radius="@dimen/seek_bar_corner_radius" /> - </shape> + android:gravity="center_vertical|fill_horizontal"> + <inset + android:insetLeft="@dimen/rounded_slider_track_inset" + android:insetRight="@dimen/rounded_slider_track_inset" > + <shape> + <size android:height="@dimen/rounded_slider_track_width" /> + <corners android:radius="@dimen/rounded_slider_track_corner_radius" /> + <solid android:color="?android:attr/textColorPrimary" /> + </shape> + </inset> </item> <item android:id="@android:id/progress" android:gravity="center_vertical|fill_horizontal"> - <scale android:scaleWidth="100%"> - <shape android:shape="rectangle" - android:tint="?android:attr/colorControlActivated"> - <size android:height="@dimen/seek_bar_height" /> - <solid android:color="@android:color/white" /> - <corners android:radius="@dimen/seek_bar_corner_radius" /> - </shape> - </scale> + <com.android.systemui.util.RoundedCornerProgressDrawable + android:drawable="@drawable/brightness_progress_full_drawable" + /> </item> -</layer-list> +</layer-list>
\ No newline at end of file diff --git a/packages/SystemUI/res/drawable/brightness_progress_drawable_thick.xml b/packages/SystemUI/res/drawable/brightness_progress_drawable_thick.xml deleted file mode 100644 index 73b02f4fa481..000000000000 --- a/packages/SystemUI/res/drawable/brightness_progress_drawable_thick.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - ~ Copyright (C) 2020 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. - --> -<layer-list xmlns:android="http://schemas.android.com/apk/res/android" - android:paddingMode="stack" > - <item android:id="@android:id/background" - android:gravity="center_vertical|fill_horizontal"> - <inset - android:insetLeft="@dimen/rounded_slider_track_inset" - android:insetRight="@dimen/rounded_slider_track_inset" > - <shape> - <size android:height="@dimen/rounded_slider_track_width" /> - <corners android:radius="@dimen/rounded_slider_track_corner_radius" /> - <solid android:color="?android:attr/textColorPrimary" /> - </shape> - </inset> - </item> - <item android:id="@android:id/progress" - android:gravity="center_vertical|fill_horizontal"> - <com.android.systemui.util.RoundedCornerProgressDrawable - android:drawable="@drawable/brightness_progress_full_drawable" - /> - </item> -</layer-list>
\ 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 9cc09aa42f40..f4d5304d3d0e 100644 --- a/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml +++ b/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2012 The Android Open Source Project +<!-- Copyright (C) 2020 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. @@ -13,69 +13,31 @@ See the License for the specific language governing permissions and limitations under the License. --> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:systemui="http://schemas.android.com/apk/res-auto" +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="match_parent" - android:layout_gravity="center_vertical" - style="@style/BrightnessDialogContainer"> + android:layout_gravity="center"> <com.android.systemui.settings.brightness.BrightnessSliderView android:id="@+id/brightness_slider" - android:layout_width="0dp" + android:layout_width="match_parent" android:layout_height="@dimen/brightness_mirror_height" android:layout_gravity="center_vertical" - android:layout_weight="1" android:contentDescription="@string/accessibility_brightness" - android:importantForAccessibility="no" - systemui:text="@string/status_bar_settings_auto_brightness_label" > + android:importantForAccessibility="no" > - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="match_parent" > - - <CheckBox - android:id="@+id/toggle" - android:layout_width="48dp" - android:layout_height="0dp" - android:layout_alignParentStart="true" - android:layout_alignParentTop="true" - android:layout_alignParentBottom="true" - android:button="@null" - android:background="@*android:drawable/switch_track_material" - android:visibility="gone" - /> <com.android.systemui.settings.brightness.ToggleSeekBar android:id="@+id/slider" - android:layout_width="0dp" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_toEndOf="@id/toggle" - android:layout_centerVertical="true" - android:layout_alignParentStart="true" - android:layout_alignParentEnd="true" - android:paddingStart="20dp" - android:paddingEnd="20dp" - android:paddingTop="16dp" - android:paddingBottom="16dp" - android:thumb="@drawable/ic_brightness_thumb" + 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" android:splitTrack="false" /> - <TextView - android:id="@+id/label" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_alignStart="@id/toggle" - android:layout_alignEnd="@id/toggle" - android:layout_centerVertical="true" - android:gravity="center" - android:paddingTop="26dp" - android:textColor="#666666" - android:textSize="12sp" - android:visibility="gone" - /> - - </RelativeLayout> </com.android.systemui.settings.brightness.BrightnessSliderView> - -</LinearLayout> +</FrameLayout> diff --git a/packages/SystemUI/res/layout/quick_settings_brightness_dialog_thick.xml b/packages/SystemUI/res/layout/quick_settings_brightness_dialog_thick.xml deleted file mode 100644 index 6cee38d27876..000000000000 --- a/packages/SystemUI/res/layout/quick_settings_brightness_dialog_thick.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2020 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. ---> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_height="wrap_content" - android:layout_width="match_parent" - android:layout_gravity="center"> - - <com.android.systemui.settings.brightness.BrightnessSliderView - android:id="@+id/brightness_slider" - android:layout_width="match_parent" - android:layout_height="@dimen/brightness_mirror_height" - android:layout_gravity="center_vertical" - 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_gravity="center_vertical" - android:minHeight="48dp" - android:thumb="@null" - android:background="@null" - android:paddingStart="0dp" - android:paddingEnd="0dp" - android:progressDrawable="@drawable/brightness_progress_drawable_thick" - android:splitTrack="false" - /> - </com.android.systemui.settings.brightness.BrightnessSliderView> -</FrameLayout> diff --git a/packages/SystemUI/res/values-h740dp-port/dimens.xml b/packages/SystemUI/res/values-h740dp-port/dimens.xml index 4a23ee637e2d..966066ffe56b 100644 --- a/packages/SystemUI/res/values-h740dp-port/dimens.xml +++ b/packages/SystemUI/res/values-h740dp-port/dimens.xml @@ -19,9 +19,9 @@ <dimen name="qs_tile_margin_vertical">24dp</dimen> <!-- The height of the qs customize header. Should be - (qs_panel_padding_top (48dp) + brightness_mirror_height (56dp) + qs_tile_margin_top (18dp)) - + (qs_panel_padding_top (48dp) + brightness_mirror_height (48dp) + qs_tile_margin_top (18dp)) - (Toolbar_minWidth (56dp) + qs_tile_margin_top_bottom (12dp)) --> - <dimen name="qs_customize_header_min_height">54dp</dimen> + <dimen name="qs_customize_header_min_height">46dp</dimen> <dimen name="qs_tile_margin_top">18dp</dimen> </resources>
\ No newline at end of file diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 2a2bb99ff8a8..7fc9ab1b0f24 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -449,7 +449,7 @@ <dimen name="notification_panel_width">@dimen/match_parent</dimen> - <dimen name="brightness_mirror_height">56dp</dimen> + <dimen name="brightness_mirror_height">48dp</dimen> <!-- The width of the panel that holds the quick settings. --> <dimen name="qs_panel_width">@dimen/notification_panel_width</dimen> @@ -531,10 +531,10 @@ <dimen name="qs_tile_margin_top_bottom">12dp</dimen> <dimen name="qs_tile_margin_top_bottom_negative">-12dp</dimen> <!-- The height of the qs customize header. Should be - (qs_panel_padding_top (48dp) + brightness_mirror_height (56dp) + qs_tile_margin_top (0dp)) - + (qs_panel_padding_top (48dp) + brightness_mirror_height (48dp) + qs_tile_margin_top (0dp)) - (Toolbar_minWidth (56dp) + qs_tile_margin_top_bottom (12dp)) --> - <dimen name="qs_customize_header_min_height">36dp</dimen> + <dimen name="qs_customize_header_min_height">28dp</dimen> <dimen name="qs_tile_margin_top">0dp</dimen> <dimen name="qs_tile_icon_background_stroke_width">-1dp</dimen> <dimen name="qs_tile_background_size">44dp</dimen> diff --git a/packages/SystemUI/res/values/flags.xml b/packages/SystemUI/res/values/flags.xml index 6af982ddad72..076310924056 100644 --- a/packages/SystemUI/res/values/flags.xml +++ b/packages/SystemUI/res/values/flags.xml @@ -33,8 +33,6 @@ <!-- AOD/Lockscreen alternate layout --> <bool name="flag_keyguard_layout">false</bool> - <bool name="flag_brightness_slider">false</bool> - <!-- People Tile flag --> <bool name="flag_conversations">false</bool> diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java index bdb392608455..357256cba131 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java @@ -58,10 +58,9 @@ public class BrightnessController implements ToggleSlider.Listener { private static final int SLIDER_ANIMATION_DURATION = 3000; private static final int MSG_UPDATE_SLIDER = 1; - private static final int MSG_SET_CHECKED = 2; - private static final int MSG_ATTACH_LISTENER = 3; - private static final int MSG_DETACH_LISTENER = 4; - private static final int MSG_VR_MODE_CHANGED = 5; + private static final int MSG_ATTACH_LISTENER = 2; + private static final int MSG_DETACH_LISTENER = 3; + private static final int MSG_VR_MODE_CHANGED = 4; private static final Uri BRIGHTNESS_MODE_URI = Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE); @@ -80,7 +79,6 @@ public class BrightnessController implements ToggleSlider.Listener { private final int mDisplayId; private final Context mContext; private final ToggleSlider mControl; - private final boolean mAutomaticAvailable; private final DisplayManager mDisplayManager; private final CurrentUserTracker mUserTracker; private final IVrManager mVrManager; @@ -219,16 +217,12 @@ public class BrightnessController implements ToggleSlider.Listener { private final Runnable mUpdateModeRunnable = new Runnable() { @Override public void run() { - if (mAutomaticAvailable) { - int automatic; - automatic = Settings.System.getIntForUser(mContext.getContentResolver(), - Settings.System.SCREEN_BRIGHTNESS_MODE, - Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, - UserHandle.USER_CURRENT); - mAutomatic = automatic != Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL; - } else { - mHandler.obtainMessage(MSG_SET_CHECKED, 0).sendToTarget(); - } + int automatic; + automatic = Settings.System.getIntForUser(mContext.getContentResolver(), + Settings.System.SCREEN_BRIGHTNESS_MODE, + Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, + UserHandle.USER_CURRENT); + mAutomatic = automatic != Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL; } }; @@ -266,9 +260,6 @@ public class BrightnessController implements ToggleSlider.Listener { case MSG_UPDATE_SLIDER: updateSlider(Float.intBitsToFloat(msg.arg1), msg.arg2 != 0); break; - case MSG_SET_CHECKED: - mControl.setChecked(msg.arg1 != 0); - break; case MSG_ATTACH_LISTENER: mControl.setOnChangedListener(BrightnessController.this); break; @@ -312,9 +303,6 @@ public class BrightnessController implements ToggleSlider.Listener { mDefaultBacklightForVr = pm.getBrightnessConstraint( PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_DEFAULT_VR); - - mAutomaticAvailable = context.getResources().getBoolean( - com.android.internal.R.bool.config_automatic_brightness_available); mDisplayManager = context.getSystemService(DisplayManager.class); mVrManager = IVrManager.Stub.asInterface(ServiceManager.getService( Context.VR_SERVICE)); @@ -339,8 +327,7 @@ public class BrightnessController implements ToggleSlider.Listener { } @Override - public void onChanged(boolean tracking, boolean automatic, - int value, boolean stopTracking) { + public void onChanged(boolean tracking, int value, boolean stopTracking) { if (mExternalChange) return; if (mSliderAnimator != null) { @@ -398,12 +385,6 @@ public class BrightnessController implements ToggleSlider.Listener { }); } - private void setMode(int mode) { - Settings.System.putIntForUser(mContext.getContentResolver(), - Settings.System.SCREEN_BRIGHTNESS_MODE, mode, - mUserTracker.getCurrentUserId()); - } - private void setBrightness(float brightness) { mDisplayManager.setTemporaryBrightness(mDisplayId, brightness); } diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSlider.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSlider.java index ab4895e4112c..db8205783173 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSlider.java +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSlider.java @@ -21,7 +21,6 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.widget.CompoundButton; import android.widget.SeekBar; import androidx.annotation.Nullable; @@ -31,7 +30,6 @@ import com.android.systemui.Gefingerpoken; import com.android.systemui.R; import com.android.systemui.classifier.Classifier; import com.android.systemui.plugins.FalsingManager; -import com.android.systemui.statusbar.FeatureFlags; import com.android.systemui.statusbar.policy.BrightnessMirrorController; import com.android.systemui.util.ViewController; @@ -95,14 +93,12 @@ public class BrightnessSlider extends ViewController<View> implements ToggleSlid @Override protected void onViewAttached() { mBrightnessSliderView.setOnSeekBarChangeListener(mSeekListener); - mBrightnessSliderView.setOnCheckedChangeListener(mCheckListener); mBrightnessSliderView.setOnInterceptListener(mOnInterceptListener); } @Override protected void onViewDetached() { mBrightnessSliderView.setOnSeekBarChangeListener(null); - mBrightnessSliderView.setOnCheckedChangeListener(null); mBrightnessSliderView.setOnDispatchTouchEventListener(null); mBrightnessSliderView.setOnInterceptListener(null); } @@ -132,7 +128,6 @@ public class BrightnessSlider extends ViewController<View> implements ToggleSlid private void setMirror(ToggleSlider toggleSlider) { mMirror = toggleSlider; if (mMirror != null) { - mMirror.setChecked(mBrightnessSliderView.isChecked()); mMirror.setMax(mBrightnessSliderView.getMax()); mMirror.setValue(mBrightnessSliderView.getValue()); mBrightnessSliderView.setOnDispatchTouchEventListener(this::mirrorTouchEvent); @@ -166,16 +161,6 @@ public class BrightnessSlider extends ViewController<View> implements ToggleSlid } @Override - public void setChecked(boolean checked) { - mBrightnessSliderView.setChecked(checked); - } - - @Override - public boolean isChecked() { - return mBrightnessSliderView.isChecked(); - } - - @Override public void setMax(int max) { mBrightnessSliderView.setMax(max); if (mMirror != null) { @@ -206,7 +191,7 @@ public class BrightnessSlider extends ViewController<View> implements ToggleSlid @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (mListener != null) { - mListener.onChanged(mTracking, isChecked(), progress, false); + mListener.onChanged(mTracking, progress, false); } } @@ -215,12 +200,9 @@ public class BrightnessSlider extends ViewController<View> implements ToggleSlid mTracking = true; if (mListener != null) { - mListener.onChanged(mTracking, isChecked(), - getValue(), false); + mListener.onChanged(mTracking, getValue(), false); } - setChecked(false); - if (mMirrorController != null) { mMirrorController.showMirror(); mMirrorController.setLocation((View) mBrightnessSliderView.getParent()); @@ -232,8 +214,7 @@ public class BrightnessSlider extends ViewController<View> implements ToggleSlid mTracking = false; if (mListener != null) { - mListener.onChanged(mTracking, isChecked(), - getValue(), true); + mListener.onChanged(mTracking, getValue(), true); } if (mMirrorController != null) { @@ -242,35 +223,15 @@ public class BrightnessSlider extends ViewController<View> implements ToggleSlid } }; - private final CompoundButton.OnCheckedChangeListener mCheckListener = - new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton toggle, boolean checked) { - enableSlider(!checked); - - if (mListener != null) { - mListener.onChanged(mTracking, checked, getValue(), false); - } - - if (mMirror != null) { - mMirror.setChecked(checked); - } - } - }; - /** * Creates a {@link BrightnessSlider} with its associated view. - * - * The views inflated are determined by {@link FeatureFlags#useNewBrightnessSlider()}. */ public static class Factory { - final FeatureFlags mFeatureFlags; private final FalsingManager mFalsingManager; @Inject - public Factory(FeatureFlags featureFlags, FalsingManager falsingManager) { - mFeatureFlags = featureFlags; + public Factory(FalsingManager falsingManager) { mFalsingManager = falsingManager; } @@ -296,9 +257,7 @@ public class BrightnessSlider extends ViewController<View> implements ToggleSlid /** Get the layout to inflate based on what slider to use */ private int getLayout() { - return mFeatureFlags.useNewBrightnessSlider() - ? R.layout.quick_settings_brightness_dialog_thick - : R.layout.quick_settings_brightness_dialog; + return R.layout.quick_settings_brightness_dialog; } } } 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 5b71c626bb22..dbd6758b090d 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSliderView.java +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessSliderView.java @@ -17,18 +17,13 @@ package com.android.systemui.settings.brightness; import android.content.Context; -import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; -import android.widget.CompoundButton; -import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.FrameLayout; import android.widget.SeekBar.OnSeekBarChangeListener; -import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import com.android.settingslib.RestrictedLockUtils; import com.android.systemui.Gefingerpoken; @@ -37,23 +32,11 @@ import com.android.systemui.R; /** * {@code FrameLayout} used to show and manipulate a {@link ToggleSeekBar}. * - * It can additionally control a {@link CompoundButton} and display a label. For the class to work, - * add children before inflation with the following ids: - * <ul> - * <li>{@code @id/slider} of type {@link ToggleSeekBar}</li> - * <li>{@code @id/toggle} of type {@link CompoundButton} (optional)</li> - * <li>{@code @id/label} of type {@link TextView} (optional)</li> - * </ul> */ public class BrightnessSliderView extends FrameLayout { - @Nullable - private CompoundButton mToggle; @NonNull private ToggleSeekBar mSlider; - @Nullable - private TextView mLabel; - private final CharSequence mText; private DispatchTouchEventListener mListener; private Gefingerpoken mOnInterceptListener; @@ -62,31 +45,15 @@ public class BrightnessSliderView extends FrameLayout { } public BrightnessSliderView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public BrightnessSliderView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - - final TypedArray a = context.obtainStyledAttributes( - attrs, R.styleable.ToggleSliderView, defStyle, 0); - mText = a.getString(R.styleable.ToggleSliderView_text); - - a.recycle(); + super(context, attrs); } // Inflated from quick_settings_brightness_dialog or quick_settings_brightness_dialog_thick @Override protected void onFinishInflate() { super.onFinishInflate(); - mToggle = findViewById(R.id.toggle); mSlider = requireViewById(R.id.slider); - - mLabel = findViewById(R.id.label); - if (mLabel != null) { - mLabel.setText(mText); - } mSlider.setAccessibilityLabel(getContentDescription().toString()); } @@ -125,25 +92,11 @@ public class BrightnessSliderView extends FrameLayout { } /** - * Attaches a listener to the {@link CompoundButton} in the view (if present) so changes to its - * state can be observed - * @param checkListener use {@code null} to remove listener - */ - public void setOnCheckedChangeListener(OnCheckedChangeListener checkListener) { - if (mToggle != null) { - mToggle.setOnCheckedChangeListener(checkListener); - } - } - - /** * Enforces admin rules for toggling auto-brightness and changing value of brightness * @param admin * @see ToggleSeekBar#setEnforcedAdmin */ public void setEnforcedAdmin(RestrictedLockUtils.EnforcedAdmin admin) { - if (mToggle != null) { - mToggle.setEnabled(admin == null); - } mSlider.setEnabled(admin == null); mSlider.setEnforcedAdmin(admin); } @@ -157,26 +110,6 @@ public class BrightnessSliderView extends FrameLayout { } /** - * Sets the state of the {@link CompoundButton} if present - * @param checked - */ - public void setChecked(boolean checked) { - if (mToggle != null) { - mToggle.setChecked(checked); - } - } - - /** - * @return the state of the {@link CompoundButton} if present, or {@code true} if not. - */ - public boolean isChecked() { - if (mToggle != null) { - return mToggle.isChecked(); - } - return true; - } - - /** * @return the maximum value of the {@link ToggleSeekBar}. */ public int getMax() { diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSlider.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSlider.java index 71e4818c605a..a988c7aeb436 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSlider.java +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSlider.java @@ -23,8 +23,7 @@ import com.android.systemui.statusbar.policy.BrightnessMirrorController; public interface ToggleSlider { interface Listener { - void onChanged(boolean tracking, boolean automatic, int value, - boolean stopTracking); + void onChanged(boolean tracking, int value, boolean stopTracking); } void setEnforcedAdmin(RestrictedLockUtils.EnforcedAdmin admin); @@ -32,8 +31,6 @@ public interface ToggleSlider { boolean mirrorTouchEvent(MotionEvent ev); void setOnChangedListener(Listener l); - default void setChecked(boolean checked) {} - default boolean isChecked() { return false; } void setMax(int max); int getMax(); void setValue(int value); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java b/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java index b937dad269e9..f51fbedebad2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/FeatureFlags.java @@ -62,11 +62,6 @@ public class FeatureFlags { return mFlagReader.isEnabled(R.bool.flag_keyguard_layout); } - /** b/178485354 */ - public boolean useNewBrightnessSlider() { - return mFlagReader.isEnabled(R.bool.flag_brightness_slider); - } - public boolean useNewLockscreenAnimations() { return mFlagReader.isEnabled(R.bool.flag_lockscreen_animations); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/settings/brightness/BrightnessSliderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/settings/brightness/BrightnessSliderTest.kt index 6d293b5f63b5..3ed8ecf1d809 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/settings/brightness/BrightnessSliderTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/settings/brightness/BrightnessSliderTest.kt @@ -20,7 +20,6 @@ import android.testing.AndroidTestingRunner import android.view.MotionEvent import android.view.View import android.view.ViewGroup -import android.widget.CompoundButton import android.widget.SeekBar import androidx.test.filters.SmallTest import com.android.settingslib.RestrictedLockUtils @@ -37,14 +36,12 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.ArgumentMatchers.anyBoolean -import org.mockito.ArgumentMatchers.anyInt import org.mockito.Captor import org.mockito.Mock import org.mockito.Mockito.isNull import org.mockito.Mockito.mock import org.mockito.Mockito.never import org.mockito.Mockito.notNull -import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations import org.mockito.Mockito.`when` as whenever @@ -72,10 +69,6 @@ class BrightnessSliderTest : SysuiTestCase() { private lateinit var seekBarChangeCaptor: ArgumentCaptor<SeekBar.OnSeekBarChangeListener> @Mock private lateinit var seekBar: SeekBar - @Captor - private lateinit var checkedChangeCaptor: ArgumentCaptor<CompoundButton.OnCheckedChangeListener> - @Mock - private lateinit var compoundButton: CompoundButton private var mFalsingManager: FalsingManagerFake = FalsingManagerFake() private lateinit var mController: BrightnessSlider @@ -101,7 +94,6 @@ class BrightnessSliderTest : SysuiTestCase() { fun testListenersAddedOnAttach() { mController.onViewAttached() - verify(brightnessSliderView).setOnCheckedChangeListener(notNull()) verify(brightnessSliderView).setOnSeekBarChangeListener(notNull()) } @@ -111,7 +103,6 @@ class BrightnessSliderTest : SysuiTestCase() { mController.onViewDetached() verify(brightnessSliderView).setOnSeekBarChangeListener(isNull()) - verify(brightnessSliderView).setOnCheckedChangeListener(isNull()) verify(brightnessSliderView).setOnDispatchTouchEventListener(isNull()) } @@ -127,7 +118,6 @@ class BrightnessSliderTest : SysuiTestCase() { verify(brightnessSliderView, never()).max verify(brightnessSliderView, never()).value - verify(brightnessSliderView, never()).isChecked verify(brightnessSliderView).setOnDispatchTouchEventListener(isNull()) } @@ -139,7 +129,6 @@ class BrightnessSliderTest : SysuiTestCase() { verify(brightnessSliderView, never()).max verify(brightnessSliderView, never()).value - verify(brightnessSliderView, never()).isChecked verify(brightnessSliderView).setOnDispatchTouchEventListener(isNull()) } @@ -150,40 +139,15 @@ class BrightnessSliderTest : SysuiTestCase() { val checked = true whenever(brightnessSliderView.max).thenReturn(maxValue) whenever(brightnessSliderView.value).thenReturn(progress) - whenever(brightnessSliderView.isChecked).thenReturn(checked) mController.setMirrorControllerAndMirror(mirrorController) verify(mirror).max = maxValue - verify(mirror).isChecked = checked verify(mirror).value = progress verify(brightnessSliderView).setOnDispatchTouchEventListener(notNull()) } @Test - fun testSetCheckedRelayed_true() { - mController.isChecked = true - verify(brightnessSliderView).isChecked = true - } - - @Test - fun testSetCheckedRelayed_false() { - mController.isChecked = false - verify(brightnessSliderView).isChecked = false - } - - @Test - fun testGetChecked() { - whenever(brightnessSliderView.isChecked).thenReturn(true) - - assertThat(mController.isChecked).isTrue() - - whenever(brightnessSliderView.isChecked).thenReturn(false) - - assertThat(mController.isChecked).isFalse() - } - - @Test fun testSetMaxRelayed() { mController.max = 120 verify(brightnessSliderView).max = 120 @@ -229,13 +193,12 @@ class BrightnessSliderTest : SysuiTestCase() { @Test fun testSeekBarProgressChanged() { mController.onViewAttached() - whenever(brightnessSliderView.isChecked).thenReturn(true) verify(brightnessSliderView).setOnSeekBarChangeListener(capture(seekBarChangeCaptor)) seekBarChangeCaptor.value.onProgressChanged(seekBar, 23, true) - verify(listener).onChanged(anyBoolean(), eq(true), eq(23), eq(false)) + verify(listener).onChanged(anyBoolean(), eq(23), eq(false)) } @Test @@ -243,7 +206,6 @@ class BrightnessSliderTest : SysuiTestCase() { val parent = mock(ViewGroup::class.java) whenever(brightnessSliderView.value).thenReturn(42) whenever(brightnessSliderView.parent).thenReturn(parent) - whenever(brightnessSliderView.isChecked).thenReturn(true) mController.onViewAttached() mController.setMirrorControllerAndMirror(mirrorController) @@ -251,7 +213,7 @@ class BrightnessSliderTest : SysuiTestCase() { seekBarChangeCaptor.value.onStartTrackingTouch(seekBar) - verify(listener).onChanged(eq(true), eq(true), eq(42), eq(false)) + verify(listener).onChanged(eq(true), eq(42), eq(false)) verify(mirrorController).showMirror() verify(mirrorController).setLocation(parent) } @@ -259,7 +221,6 @@ class BrightnessSliderTest : SysuiTestCase() { @Test fun testSeekBarTrackingStopped() { whenever(brightnessSliderView.value).thenReturn(23) - whenever(brightnessSliderView.isChecked).thenReturn(true) mController.onViewAttached() mController.setMirrorControllerAndMirror(mirrorController) @@ -267,38 +228,7 @@ class BrightnessSliderTest : SysuiTestCase() { seekBarChangeCaptor.value.onStopTrackingTouch(seekBar) - verify(listener).onChanged(eq(false), eq(true), eq(23), eq(true)) + verify(listener).onChanged(eq(false), eq(23), eq(true)) verify(mirrorController).hideMirror() } - - @Test - fun testButtonCheckedChanged_false() { - val checked = false - - mController.onViewAttached() - mController.setMirrorControllerAndMirror(mirrorController) - verify(brightnessSliderView).setOnCheckedChangeListener(capture(checkedChangeCaptor)) - - checkedChangeCaptor.value.onCheckedChanged(compoundButton, checked) - - verify(brightnessSliderView).enableSlider(!checked) - verify(listener).onChanged(anyBoolean(), eq(checked), anyInt(), eq(false)) - // Called once with false when the mirror is set - verify(mirror, times(2)).isChecked = checked - } - - @Test - fun testButtonCheckedChanged_true() { - val checked = true - - mController.onViewAttached() - mController.setMirrorControllerAndMirror(mirrorController) - verify(brightnessSliderView).setOnCheckedChangeListener(capture(checkedChangeCaptor)) - - checkedChangeCaptor.value.onCheckedChanged(compoundButton, checked) - - verify(brightnessSliderView).enableSlider(!checked) - verify(listener).onChanged(anyBoolean(), eq(checked), anyInt(), eq(false)) - verify(mirror).isChecked = checked - } }
\ No newline at end of file |