Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit dbe86598 authored by Alberto97's avatar Alberto97 Committed by Michael Bestas
Browse files

SystemUI: Port brightness slider changes

 * Expose AutoBrightness button
 * Add tunables
 * Use vector drawables for brightness icons

[BadDaemon]
 * Adapt to SystemUI changes
 * Change code style to use lambdas and locals where possible

Author: Luca Stefani <luca020400@lineageos.org>
Date:   Thu Apr 20 18:00:52 2017 +0200

    SystemUI: Use AOSP AutoBrightness implementation

    Change-Id: I3e3660065407d460f30c6e936d951d4d5eae30c6

Author: Michael Bestas <mikeioannina@gmail.com>
Date:   Thu Apr 27 14:57:49 2017 +0300

    SystemUI: Use already existing overlay to show QS auto brightness

    * No need for a new overlay when one exists for years

    Change-Id: I9e09a1770f8e645093e880cf1a48597405e0bcf2

Author: Alberto97 <albertop2197@gmail.com>
Date:   Mon May 29 21:07:05 2017 +0200

    SystemUI: Specify user while changing brightness mode

    Allow any user changing brightness mode,
    without this only the main one is able to do that.

    BUGBASH-598

    Change-Id: Ib51e9a45c42837cabb1cfb0d48334165b023a827

Author: Michael Bestas <mkbestas@lineageos.org>
Date:   Sun Apr 30 13:45:39 2017 +0300

    SystemUI: Add tunable for auto brightness icon

    Change-Id: I02fe3f5500f95ba9369b952bbec2a073b7ae8316

Author: Alexander Westphal <westphal.alex94@gmail.com>
Date:   Wed Apr 26 09:20:53 2017 +0100

    SystemUI: use vector drawables for brightness icons

    Change-Id: I8d22f8de22040d68ed1bfab0da3a78aec717fa62

Author: qjohn <townex22@gmail.com>
Date:   Sun Jun 18 16:28:10 2017 +0700

    SystemUI: Remove unnecessary brightness icons

    Change-Id: I7e60ff73125bd0304f9ca14ad5c5a9ce11ffceda

Author: Michael W <baddaemon87@gmail.com>
Date:   Mon May 25 15:38:33 2020 +0200

    SystemUI: Brightness slider: Always show the brightness icon

    * Right now, we reserve the space for the icon but it's not displayed
      (reserved space is there so the slider doesn't jump)
    * Always display the icon (if automatic brightness is available)
      so it's more consistent

    Change-Id: I5238dc6aad51407349a8d42fae840ea76841dc3d

Author: Michael W <baddaemon87@gmail.com>
Date:   Fri May 29 20:09:18 2020 +0200

    SystemUI: Fix for auto brightness icon being shown when disabled

    * With commit 9d42c48c the case of a
      manually disabled auto brightness icon got lost
    * Re-implement it by also respecting the Settings value instead of just
      the build time flag

    Change-Id: I991977be7e1f7c33947073dbd3ce7a800fb158bf

Change-Id: Ic72b0084a4108fb4fa26e893bd6d1eaca96cbb6c
parent 53b5379f
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2017 The LineageOS 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0"
        android:tint="?android:attr/colorControlNormal">
    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M20,8.69L20,4h-4.69L12,0.69 8.69,4L4,4v4.69L0.69,12 4,15.31L4,20h4.69L12,23.31 15.31,20L20,20v-4.69L23.31,12 20,8.69zM12,18c-3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6 6,2.69 6,6 -2.69,6 -6,6zM12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4z"/>
</vector>
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2017 The LineageOS 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0"
        android:tint="?android:attr/colorControlNormal">
    <path
        android:fillColor="#FFFFFFFF"
        android:pathData="M10.85,12.65h2.3L12,9l-1.15,3.65zM20,8.69V4h-4.69L12,0.69 8.69,4H4v4.69L0.69,12 4,15.31V20h4.69L12,23.31 15.31,20H20v-4.69L23.31,12 20,8.69zM14.3,16l-0.7,-2h-3.2l-0.7,2H7.8L11,7h2l3.2,9h-1.9z"/>
</vector>
+15 −2
Original line number Diff line number Diff line
@@ -18,15 +18,16 @@
        android:id="@+id/brightness_slider"
        android:layout_width="match_parent"
        android:layout_height="@dimen/brightness_mirror_height"
        android:layout_gravity="center"
        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_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:minHeight="48dp"
            android:thumb="@null"
            android:background="@null"
@@ -35,4 +36,16 @@
            android:progressDrawable="@drawable/brightness_progress_drawable"
            android:splitTrack="false"
        />

        <ImageView
            android:id="@+id/brightness_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginStart="4dp"
            android:layout_marginEnd="8dp"
            android:src="@drawable/ic_qs_brightness_auto_off"
            android:contentDescription="@null"
            android:visibility="gone"
        />
    </com.android.systemui.settings.brightness.BrightnessSliderView>
+16 −1
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ import com.android.systemui.settings.brightness.BrightnessSliderController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;

import lineageos.providers.LineageSettings;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -54,6 +56,11 @@ import java.util.Objects;
/** View that represents the quick settings tile panel (when expanded/pulled down). **/
public class QSPanel extends LinearLayout implements Tunable {

    public static final String QS_SHOW_AUTO_BRIGHTNESS =
            "lineagesecure:" + LineageSettings.Secure.QS_SHOW_AUTO_BRIGHTNESS;
    public static final String QS_SHOW_BRIGHTNESS_SLIDER =
            "lineagesecure:" + LineageSettings.Secure.QS_SHOW_BRIGHTNESS_SLIDER;

    public static final String QS_SHOW_BRIGHTNESS = "qs_show_brightness";
    public static final String QS_SHOW_HEADER = "qs_show_header";

@@ -72,6 +79,8 @@ public class QSPanel extends LinearLayout implements Tunable {

    @Nullable
    protected View mBrightnessView;
    protected View mAutoBrightnessView;

    @Nullable
    protected BrightnessSliderController mToggleSliderController;

@@ -80,6 +89,7 @@ public class QSPanel extends LinearLayout implements Tunable {

    protected boolean mExpanded;
    protected boolean mListening;
    private boolean mIsAutomaticBrightnessAvailable = false;

    @Nullable protected QSTileHost mHost;
    private final List<OnConfigurationChangedListener> mOnConfigurationChangedListeners =
@@ -120,6 +130,8 @@ public class QSPanel extends LinearLayout implements Tunable {

        mMovableContentStartIndex = getChildCount();

        mIsAutomaticBrightnessAvailable = getResources().getBoolean(
                com.android.internal.R.bool.config_automatic_brightness_available);
    }

    void initialize() {
@@ -178,6 +190,7 @@ public class QSPanel extends LinearLayout implements Tunable {
        }
        addView(view, 0);
        mBrightnessView = view;
        mAutoBrightnessView = view.findViewById(R.id.brightness_icon);

        setBrightnessViewMargin();

@@ -305,7 +318,9 @@ public class QSPanel extends LinearLayout implements Tunable {

    @Override
    public void onTuningChanged(String key, String newValue) {
        if (QS_SHOW_BRIGHTNESS.equals(key) && mBrightnessView != null) {
        if (QS_SHOW_AUTO_BRIGHTNESS.equals(key) && mIsAutomaticBrightnessAvailable) {
            updateViewVisibilityForTuningValue(mAutoBrightnessView, newValue);
        } else if (QS_SHOW_BRIGHTNESS_SLIDER.equals(key) && mBrightnessView != null) {
            updateViewVisibilityForTuningValue(mBrightnessView, newValue);
        }
    }
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.systemui.qs;
import static com.android.systemui.classifier.Classifier.QS_SWIPE;
import static com.android.systemui.media.dagger.MediaModule.QS_PANEL;
import static com.android.systemui.qs.QSPanel.QS_SHOW_BRIGHTNESS;
import static com.android.systemui.qs.QSPanel.QS_SHOW_AUTO_BRIGHTNESS;
import static com.android.systemui.qs.QSPanel.QS_SHOW_BRIGHTNESS_SLIDER;
import static com.android.systemui.qs.dagger.QSFragmentModule.QS_USING_MEDIA_PLAYER;

import android.content.res.Configuration;
@@ -127,6 +129,8 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
        updateMediaDisappearParameters();

        mTunerService.addTunable(mView, QS_SHOW_BRIGHTNESS);
        mTunerService.addTunable(mView, QS_SHOW_AUTO_BRIGHTNESS);
        mTunerService.addTunable(mView, QS_SHOW_BRIGHTNESS_SLIDER);
        mView.updateResources();
        if (mView.isListening()) {
            refreshAllTiles();
Loading