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

Commit a8c2989d authored by Danny Baumann's avatar Danny Baumann
Browse files

Fix power widget appearing after theme change even if disabled.

The power widget used a 'boot completed' listener to initially configure
its appearance. As the status bar is restarted when themes are changed,
and obviously no boot completed intent followed that, the power widget
stayed visible, even if it's disabled in the settings.
Fix that by reading the initial settings in the constructor instead of a
boot completed receiver. I couldn't find any negative impact after that
change, so the exact purpose of the original code (using a boot
completed receiver) is unclear.
parent 95a77d50
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ public class PowerWidget extends FrameLayout {

        // get an initial width
        updateButtonLayoutWidth();
        setupWidget();
        updateVisibility();
    }

    public void setupWidget() {
@@ -155,8 +157,6 @@ public class PowerWidget extends FrameLayout {
        IntentFilter filter = PowerButton.getAllBroadcastIntentFilters();
        // we add this so we can update views and such if the settings for our widget change
        filter.addAction(Settings.SETTINGS_CHANGED);
        // we need to re-setup our widget on boot complete to make sure it is visible if need be
        filter.addAction(Intent.ACTION_BOOT_COMPLETED);
        // we need to detect orientation changes and update the static button width value appropriately
        filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
        // register the receiver
@@ -217,10 +217,7 @@ public class PowerWidget extends FrameLayout {
    // our own broadcast receiver :D
    private class WidgetBroadcastReceiver extends BroadcastReceiver {
        public void onReceive(Context context, Intent intent) {
            if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
                setupWidget();
                updateVisibility();
            } else if(intent.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
            if(intent.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
                updateButtonLayoutWidth();
                setupWidget();
            } else {