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

Unverified Commit c0f798b7 authored by LuK1337's avatar LuK1337
Browse files

fixup! BatteryMeterView: Hide icon on battery-less devices

Change-Id: I66eab030f69412def09a4e324f9b3bda74736b6d
parent 629cf3b3
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -116,6 +116,13 @@ public class BatteryMeterViewController extends ViewController<BatteryMeterView>
                    }
                }

                @Override
                public void onBatteryPresentChanged(boolean batteryPresent) {
                    mView.setBatteryPresence(batteryPresent);
                    mView.setVisibility(!batteryPresent || mBatteryHidden
                            ? View.GONE : View.VISIBLE);
                }

                @Override
                public void dump(@NonNull PrintWriter pw, @NonNull String[] args) {
                    pw.print(super.toString());
@@ -162,12 +169,8 @@ public class BatteryMeterViewController extends ViewController<BatteryMeterView>
        mBatteryController = batteryController;

        mView.setBatteryEstimateFetcher(mBatteryController::getEstimatedTimeRemainingString);
        mView.setBatteryPresence(mBatteryController.isPresent());
        mView.setDisplayShieldEnabled(
                getContext().getResources().getBoolean(R.bool.flag_battery_shield_icon));
        if (!mBatteryController.isPresent()) {
            mView.setVisibility(View.GONE);
        }

        mSlotBattery = getResources().getString(com.android.internal.R.string.status_bar_battery);
        mSettingObserver = new SettingObserver(mMainHandler);
+3 −0
Original line number Diff line number Diff line
@@ -170,6 +170,9 @@ public interface BatteryController extends DemoMode,
        default void onIsIncompatibleChargingChanged(boolean isIncompatibleCharging) {
        }

        default void onBatteryPresentChanged(boolean batteryPresent) {
        }

        @Override
        default void dump(@NonNull PrintWriter pw, @NonNull String[] args) {
            pw.println(this);
+12 −1
Original line number Diff line number Diff line
@@ -228,6 +228,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC
        cb.onWirelessChargingChanged(mWirelessCharging);
        cb.onIsBatteryDefenderChanged(mIsBatteryDefender);
        cb.onIsIncompatibleChargingChanged(mIsIncompatibleCharging);
        cb.onBatteryPresentChanged(mPresent);
    }

    @Override
@@ -264,7 +265,12 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC
                fireWirelessChargingChanged();
            }

            mPresent = intent.getBooleanExtra(EXTRA_PRESENT, true);
            boolean present = intent.getBooleanExtra(EXTRA_PRESENT, true);
            if (present != mPresent) {
                mPresent = present;
                fireBatteryPresentChanged();
            }

            boolean unknown = !mPresent;
            if (unknown != mStateUnknown) {
                mStateUnknown = unknown;
@@ -491,6 +497,11 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC
                (callback) -> callback.onIsIncompatibleChargingChanged(mIsIncompatibleCharging));
    }

    private void fireBatteryPresentChanged() {
        dispatchSafeChange(
                (callback) -> callback.onBatteryPresentChanged(mPresent));
    }

    @Override
    public void dispatchDemoCommand(String command, Bundle args) {
        if (!mDemoModeController.isInDemoMode()) {