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

Commit 3de28072 authored by Luca Stefani's avatar Luca Stefani Committed by Michael Bestas
Browse files

SystemUI: Use AOSP AutoBrightness implementation

Change-Id: I3e3660065407d460f30c6e936d951d4d5eae30c6
parent fe901354
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -21,16 +21,6 @@
    android:paddingRight="16dp"
    style="@style/BrightnessDialogContainer">

    <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" />

    <com.android.systemui.settings.ToggleSlider
        android:id="@+id/brightness_slider"
        android:layout_width="0dp"
@@ -41,4 +31,13 @@
        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:src="@drawable/ic_qs_brightness_auto_off"
        android:contentDescription="@null"
        android:visibility="gone" />

</LinearLayout>
+3 −0
Original line number Diff line number Diff line
@@ -293,4 +293,7 @@

    <bool name="config_show4gForIWlan">false</bool>
    <bool name="config_showSignalForIWlan">false</bool>

    <!-- When true, show the AutoBrightness imageview -->
    <bool name="config_show_auto_brightness">true</bool>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -109,6 +109,9 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {
                R.layout.qs_paged_tile_layout, this, false);
        mTileLayout.setListening(mListening);
        addView((View) mTileLayout);
        if (getResources().getBoolean(R.bool.config_show_auto_brightness)) {
            ((ImageView) findViewById(R.id.brightness_icon)).setVisibility(View.VISIBLE);
        }
    }

    public boolean isShowingCustomize() {
+12 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.provider.Settings;
import android.service.vr.IVrManager;
import android.service.vr.IVrStateCallbacks;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.android.internal.logging.MetricsLogger;
@@ -42,7 +43,6 @@ import java.util.ArrayList;

public class BrightnessController implements ToggleSlider.Listener {
    private static final String TAG = "StatusBar.BrightnessController";
    private static final boolean SHOW_AUTOMATIC_ICON = false;

    /**
     * {@link android.provider.Settings.System#SCREEN_AUTO_BRIGHTNESS_ADJ} uses the range [-1, 1].
@@ -296,6 +296,16 @@ public class BrightnessController implements ToggleSlider.Listener {
                com.android.internal.R.bool.config_automatic_brightness_available);
        mPower = IPowerManager.Stub.asInterface(ServiceManager.getService("power"));
        mVrManager = IVrManager.Stub.asInterface(ServiceManager.getService("vrmanager"));

        mIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Settings.System.putInt(mContext.getContentResolver(),
                    Settings.System.SCREEN_BRIGHTNESS_MODE,
                    !mAutomatic ? Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC
                    : Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
            }
        });
    }

    public void setBackgroundLooper(Looper backgroundLooper) {
@@ -431,7 +441,7 @@ public class BrightnessController implements ToggleSlider.Listener {

    private void updateIcon(boolean automatic) {
        if (mIcon != null) {
            mIcon.setImageResource(automatic && SHOW_AUTOMATIC_ICON ?
            mIcon.setImageResource(mAutomatic ?
                    com.android.systemui.R.drawable.ic_qs_brightness_auto_on :
                    com.android.systemui.R.drawable.ic_qs_brightness_auto_off);
        }