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