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

Commit b029e00b 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

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

Change-Id: Ic72b0084a4108fb4fa26e893bd6d1eaca96cbb6c
parent 828d71fc
Loading
Loading
Loading
Loading
+27 −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>
+27 −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>
+10 −0
Original line number Diff line number Diff line
@@ -32,4 +32,14 @@
        android:importantForAccessibility="no"
        systemui:text="@string/status_bar_settings_auto_brightness_label" />

    <ImageView
        android:id="@+id/brightness_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginEnd="8dp"
        android:src="@drawable/ic_qs_brightness_auto_off"
        android:contentDescription="@null"
        android:visibility="gone" />

</LinearLayout>
+20 −3
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.service.quicksettings.Tile;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.android.internal.logging.MetricsLogger;
@@ -54,6 +55,8 @@ import com.android.systemui.statusbar.policy.BrightnessMirrorController.Brightne
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;

import lineageos.providers.LineageSettings;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -66,7 +69,10 @@ import javax.inject.Named;
public class QSPanel extends LinearLayout implements Tunable, Callback, BrightnessMirrorListener,
        Dumpable {

    public static final String QS_SHOW_BRIGHTNESS = "qs_show_brightness";
    private 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_HEADER = "qs_show_header";

    private static final String TAG = "QSPanel";
@@ -74,12 +80,14 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
    protected final Context mContext;
    protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
    protected final View mBrightnessView;
    protected final ImageView mAutoBrightnessView;
    private final H mHandler = new H();
    private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
    private final QSTileRevealController mQsTileRevealController;

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

    private QSDetail.Callback mCallback;
    private BrightnessController mBrightnessController;
@@ -134,8 +142,14 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
        updateResources();

        mBrightnessController = new BrightnessController(getContext(),
                findViewById(R.id.brightness_icon),
                findViewById(R.id.brightness_slider));
        mDumpController = dumpController;

        mAutoBrightnessView = findViewById(R.id.brightness_icon);

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

    protected void addDivider() {
@@ -179,7 +193,8 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        final TunerService tunerService = Dependency.get(TunerService.class);
        tunerService.addTunable(this, QS_SHOW_BRIGHTNESS);
        tunerService.addTunable(this, QS_SHOW_AUTO_BRIGHTNESS);
        tunerService.addTunable(this, QS_SHOW_BRIGHTNESS_SLIDER);

        if (mHost != null) {
            setTiles(mHost.getTiles());
@@ -213,7 +228,9 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne

    @Override
    public void onTuningChanged(String key, String newValue) {
        if (QS_SHOW_BRIGHTNESS.equals(key)) {
        if (QS_SHOW_AUTO_BRIGHTNESS.equals(key) && mIsAutomaticBrightnessAvailable) {
            updateViewVisibilityForTuningValue(mAutoBrightnessView, newValue);
        } else if (QS_SHOW_BRIGHTNESS_SLIDER.equals(key)) {
            updateViewVisibilityForTuningValue(mBrightnessView, newValue);
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ public class QuickQSPanel extends QSPanel {

    @Override
    public void onTuningChanged(String key, String newValue) {
        if (QS_SHOW_BRIGHTNESS.equals(key)) {
        if (QS_SHOW_BRIGHTNESS_SLIDER.equals(key)) {
            // No Brightness or Tooltip for you!
            super.onTuningChanged(key, "0");
        }
Loading