Preview default threshold battery colours
This commit is contained in:
@@ -278,6 +278,14 @@ public final class BatteryBarFragment extends Fragment {
|
||||
int labelRes,
|
||||
String colour,
|
||||
int emptyLabelRes) {
|
||||
updateColourButtonLabel(button, labelRes, colour, emptyLabelRes, "");
|
||||
}
|
||||
|
||||
private void updateColourButtonLabel(MaterialButton button,
|
||||
int labelRes,
|
||||
String colour,
|
||||
int emptyLabelRes,
|
||||
String defaultPreviewColour) {
|
||||
if (button == null) {
|
||||
return;
|
||||
}
|
||||
@@ -287,6 +295,11 @@ public final class BatteryBarFragment extends Fragment {
|
||||
boolean hasBackground = false;
|
||||
if (BatteryBarStyle.isThresholdChargeDefault(colour)) {
|
||||
value = getString(R.string.battery_bar_colour_same_as_default);
|
||||
String defaultPreview = BatteryBarStyle.normalizeColor(defaultPreviewColour);
|
||||
if (!defaultPreview.isEmpty()) {
|
||||
backgroundColor = resolvePreviewColour(defaultPreview);
|
||||
hasBackground = true;
|
||||
}
|
||||
} else if (normalised.isEmpty()) {
|
||||
value = getString(emptyLabelRes);
|
||||
} else {
|
||||
@@ -962,11 +975,19 @@ public final class BatteryBarFragment extends Fragment {
|
||||
row.addView(dischargeButton);
|
||||
|
||||
MaterialButton chargeButton = createRowButton(context);
|
||||
String defaultChargeColour = prefs.getString(
|
||||
SbtSettings.KEY_BATTERY_BAR_DEFAULT_CHARGE_COLOR,
|
||||
SbtDefaults.BATTERY_BAR_DEFAULT_CHARGE_COLOR_DEFAULT);
|
||||
String thresholdDefaultPreview = BatteryBarStyle.normalizeColor(defaultChargeColour);
|
||||
if (thresholdDefaultPreview.isEmpty()) {
|
||||
thresholdDefaultPreview = threshold.dischargeColor;
|
||||
}
|
||||
updateColourButtonLabel(
|
||||
chargeButton,
|
||||
R.string.battery_bar_threshold_charge_colour,
|
||||
threshold.chargeColor,
|
||||
R.string.battery_bar_colour_same_as_default);
|
||||
R.string.battery_bar_colour_same_as_default,
|
||||
thresholdDefaultPreview);
|
||||
chargeButton.setOnClickListener(v -> showThresholdColourDialog(
|
||||
threshold,
|
||||
false,
|
||||
|
||||
Reference in New Issue
Block a user