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

Commit e82bb122 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

fixup: StatusBarSettings: Hide battery category on battery-less devices

Change-Id: I17999dfb7e5f1039c044e249b7d68a917dff9443
parent ca04439e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -5,7 +5,9 @@
 */
package org.lineageos.lineageparts.statusbar;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.os.Bundle;
import android.provider.Settings;
@@ -16,8 +18,6 @@ import android.view.View;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;

import com.android.settingslib.fuelgauge.BatteryUtils;

import org.lineageos.lineageparts.R;
import org.lineageos.lineageparts.SettingsPreferenceFragment;
import org.lineageos.lineageparts.utils.DeviceUtils;
@@ -74,7 +74,7 @@ public class StatusBarSettings extends SettingsPreferenceFragment
        statusBarBattery.setOnPreferenceChangeListener(this);
        enableStatusBarBatteryDependents(statusBarBattery.getIntValue(2));

        Intent intent = BatteryUtils.getBatteryIntent(getContext());
        Intent intent = getBatteryIntent(getContext());
        if (intent != null) {
            mBatteryPresent = intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, true);
        }
@@ -156,6 +156,12 @@ public class StatusBarSettings extends SettingsPreferenceFragment
        mStatusBarBatteryShowPercent.setEnabled(batteryIconStyle != STATUS_BAR_BATTERY_STYLE_TEXT);
    }

    /** Gets the latest sticky battery intent from the Android system. */
    public static Intent getBatteryIntent(Context context) {
        return context.registerReceiver(
                /*receiver=*/ null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    }

    private void updateQuickPulldownSummary(int value) {
        String summary="";
        switch (value) {