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

Commit d8ea484e authored by Adrian Roos's avatar Adrian Roos
Browse files

Make brightness panel behave like volume panel.

Moves the brightness panel to the same spot as the volume panel. To avoid a conflict with the volume panel, brightness is dismissed when the volume keys are pressed.

Bug: 7217009
Bug: 7217154
Change-Id: Ib8331a1e390cbedca40fa237243ea2cfd088e521
parent 4a5eb8fe
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
@@ -67,9 +69,15 @@ public class BrightnessDialog extends Dialog implements
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window window = getWindow();
        window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
        window.getAttributes().privateFlags |=
        window.setGravity(Gravity.TOP);
        WindowManager.LayoutParams lp = window.getAttributes();
        // Offset from the top
        lp.y = getContext().getResources().getDimensionPixelOffset(
                com.android.internal.R.dimen.volume_panel_top);
        lp.type = WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
        lp.privateFlags |=
                WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
        window.setAttributes(lp);
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        window.requestFeature(Window.FEATURE_NO_TITLE);

@@ -108,4 +116,13 @@ public class BrightnessDialog extends Dialog implements
        mHandler.removeCallbacks(mDismissDialogRunnable);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
                keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
                keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
            dismiss();
        }
        return super.onKeyDown(keyCode, event);
    }
}