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

Commit 32f9e52c authored by Caitlin Cassidy's avatar Caitlin Cassidy Committed by Automerger Merge Worker
Browse files

Merge "[Dagger] Remove ConfigurationController from BatteryMeterView." into...

Merge "[Dagger] Remove ConfigurationController from BatteryMeterView." into sc-v2-dev am: df4f102c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15362950

Change-Id: Ib666a428909a93d72abfa85efcb980330d2ded61
parents 6ff1d2bf df4f102c
Loading
Loading
Loading
Loading
+2 −12
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.battery;
import static android.provider.Settings.System.SHOW_BATTERY_PERCENT;

import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.util.SysuiLifecycle.viewAttachLifecycle;

import static java.lang.annotation.RetentionPolicy.SOURCE;

@@ -61,8 +60,6 @@ import com.android.systemui.settings.CurrentUserTracker;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;

@@ -72,8 +69,7 @@ import java.lang.annotation.Retention;
import java.text.NumberFormat;

public class BatteryMeterView extends LinearLayout implements
        BatteryStateChangeCallback, Tunable, DarkReceiver, ConfigurationListener {

        BatteryStateChangeCallback, Tunable, DarkReceiver {

    @Retention(SOURCE)
    @IntDef({MODE_DEFAULT, MODE_ON, MODE_OFF, MODE_ESTIMATE})
@@ -167,7 +163,6 @@ public class BatteryMeterView extends LinearLayout implements

        setClipChildren(false);
        setClipToPadding(false);
        Dependency.get(ConfigurationController.class).observe(viewAttachLifecycle(this), this);
    }

    private void setupLayoutTransition() {
@@ -398,11 +393,6 @@ public class BatteryMeterView extends LinearLayout implements
        }
    }

    @Override
    public void onDensityOrFontScaleChanged() {
        scaleBatteryMeterViews();
    }

    private Drawable getUnknownStateDrawable() {
        if (mUnknownStateDrawable == null) {
            mUnknownStateDrawable = mContext.getDrawable(R.drawable.ic_battery_unknown);
@@ -432,7 +422,7 @@ public class BatteryMeterView extends LinearLayout implements
    /**
     * Looks up the scale factor for status bar icons and scales the battery view by that amount.
     */
    private void scaleBatteryMeterViews() {
    void scaleBatteryMeterViews() {
        Resources res = getContext().getResources();
        TypedValue typedValue = new TypedValue();

+24 −2
Original line number Diff line number Diff line
@@ -15,22 +15,44 @@
 */
package com.android.systemui.battery;

import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.ViewController;

import javax.inject.Inject;

/** Controller for {@link BatteryMeterView}. **/
public class BatteryMeterViewController extends ViewController<BatteryMeterView> {
    private final ConfigurationController mConfigurationController;

    private final ConfigurationController.ConfigurationListener mConfigurationListener =
            new ConfigurationController.ConfigurationListener() {
                @Override
                public void onDensityOrFontScaleChanged() {
                    mView.scaleBatteryMeterViews();
                }
            };

    @Inject
    public BatteryMeterViewController(BatteryMeterView view) {
    public BatteryMeterViewController(
            BatteryMeterView view,
            ConfigurationController configurationController) {
        super(view);
        mConfigurationController = configurationController;
    }

    @Override
    protected void onViewAttached() {
        mConfigurationController.addCallback(mConfigurationListener);
    }

    @Override
    protected void onViewDetached() {
        destroy();
    }

    @Override
    public void destroy() {
        super.destroy();
        mConfigurationController.removeCallback(mConfigurationListener);
    }
}
 No newline at end of file
+7 −1
Original line number Diff line number Diff line
@@ -159,10 +159,16 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat

    @Override
    protected void onViewDetached() {
        destroy();
    }

    @Override
    public void destroy() {
        // Don't receive future #onViewAttached calls so that we don't accidentally have two
        // controllers registered for the same view.
        // TODO(b/194181195): This shouldn't be necessary.
        destroy();
        super.destroy();
        mBatteryMeterViewController.destroy();

        mConfigurationController.removeCallback(mConfigurationListener);
        mAnimationScheduler.removeCallback(mAnimationCallback);
+1 −1
Original line number Diff line number Diff line
@@ -988,7 +988,7 @@ public class NotificationPanelViewController extends PanelViewController {
                mKeyguardStatusBarViewComponentFactory.build(keyguardStatusBarView);
        if (mKeyguardStatusBarViewController != null) {
            // TODO(b/194181195): This shouldn't be necessary.
            mKeyguardStatusBarViewController.onViewDetached();
            mKeyguardStatusBarViewController.destroy();
        }
        mKeyguardStatusBarViewController =
                statusBarViewComponent.getKeyguardStatusBarViewController();
+1 −1
Original line number Diff line number Diff line
@@ -1212,7 +1212,7 @@ public class StatusBar extends SystemUI implements
                    mPhoneStatusBarViewController.init();

                    mBatteryMeterViewController = new BatteryMeterViewController(
                            mStatusBarView.findViewById(R.id.battery)
                            mStatusBarView.findViewById(R.id.battery), mConfigurationController
                    );
                    mBatteryMeterViewController.init();

Loading