Skip to content

Commit

Permalink
Auto restart systemui to avoid wrong colors
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed Apr 25, 2024
1 parent 0cad763 commit ac6400e
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package it.dhd.oxygencustomizer.ui.fragments.mods;

import static android.content.Context.BATTERY_SERVICE;
import static it.dhd.oxygencustomizer.utils.Constants.Packages.SYSTEM_UI;
import static it.dhd.oxygencustomizer.utils.Constants.Preferences.BatteryPrefs.BATTERY_STYLE_DOTTED_CIRCLE;

import android.content.res.Configuration;
Expand All @@ -9,13 +10,16 @@
import android.os.BatteryManager;
import android.os.Bundle;

import androidx.preference.SwitchPreferenceCompat;

import java.util.ArrayList;
import java.util.List;

import it.dhd.oxygencustomizer.R;
import it.dhd.oxygencustomizer.customprefs.ListWithPopUpPreference;
import it.dhd.oxygencustomizer.customprefs.dialogadapter.ListPreferenceAdapter;
import it.dhd.oxygencustomizer.ui.base.ControlledPreferenceFragmentCompat;
import it.dhd.oxygencustomizer.utils.AppUtils;
import it.dhd.oxygencustomizer.utils.Constants;
import it.dhd.oxygencustomizer.xposed.batterystyles.BatteryDrawable;
import it.dhd.oxygencustomizer.xposed.batterystyles.CircleBattery;
Expand Down Expand Up @@ -75,7 +79,7 @@ public boolean hasMenu() {

@Override
public String[] getScopes() {
return new String[]{Constants.Packages.SYSTEM_UI};
return new String[]{SYSTEM_UI};
}


Expand Down Expand Up @@ -129,7 +133,7 @@ public boolean hasMenu() {

@Override
public String[] getScopes() {
return new String[]{Constants.Packages.SYSTEM_UI};
return new String[]{SYSTEM_UI};
}
}

Expand Down Expand Up @@ -157,7 +161,7 @@ public boolean hasMenu() {

@Override
public String[] getScopes() {
return new String[]{Constants.Packages.SYSTEM_UI};
return new String[]{SYSTEM_UI};
}
}

Expand Down Expand Up @@ -272,6 +276,14 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
mChargingIcon.createDefaultAdapter();
mChargingIcon.setAdapterType(ListPreferenceAdapter.TYPE_BATTERY_ICONS);
}

SwitchPreferenceCompat mBatteryCustomize = findPreference("battery_icon_customize");
if (mBatteryCustomize != null) {
mBatteryCustomize.setOnPreferenceChangeListener((preference, newValue) -> {
AppUtils.restartAllScope(new String[]{SYSTEM_UI});
return true;
});
}
}

@Override
Expand All @@ -286,7 +298,7 @@ public boolean hasMenu() {

@Override
public String[] getScopes() {
return new String[]{Constants.Packages.SYSTEM_UI};
return new String[]{SYSTEM_UI};
}
}

Expand Down Expand Up @@ -316,7 +328,7 @@ public boolean hasMenu() {

@Override
public String[] getScopes() {
return new String[]{Constants.Packages.SYSTEM_UI};
return new String[]{SYSTEM_UI};
}
}

Expand Down

0 comments on commit ac6400e

Please sign in to comment.