mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-24 10:56:50 +01:00
Fix crash when opening battery status activity
This commit is contained in:
parent
527773d3d8
commit
d4dc686148
@ -195,8 +195,12 @@ public class BatteryInfoActivity extends AbstractGBActivity {
|
||||
setBatteryLabels();
|
||||
for (BatteryConfig batteryConfig : coordinator.getBatteryConfig(gbDevice)) {
|
||||
if (batteryConfig.getBatteryIndex() == batteryIndex) {
|
||||
battery_status_extra_name.setText(batteryConfig.getBatteryLabel());
|
||||
battery_status_device_icon.setImageResource(batteryConfig.getBatteryIcon());
|
||||
if (batteryConfig.getBatteryLabel() != GBDevice.BATTERY_LABEL_DEFAULT) {
|
||||
battery_status_extra_name.setText(batteryConfig.getBatteryLabel());
|
||||
}
|
||||
if (batteryConfig.getBatteryIcon() != GBDevice.BATTERY_ICON_DEFAULT) {
|
||||
battery_status_device_icon.setImageResource(batteryConfig.getBatteryIcon());
|
||||
}
|
||||
if (gbDevice.isInitialized()) {
|
||||
battery_status_device_icon.setColorFilter(this.getResources().getColor(R.color.accent));
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
||||
final Preference prefHeader = new PreferenceCategory(requireContext());
|
||||
prefHeader.setKey("pref_battery_header_" + batteryConfig.getBatteryIndex());
|
||||
prefHeader.setIconSpaceReserved(false);
|
||||
if (batteryConfig.getBatteryLabel() > 0) {
|
||||
if (batteryConfig.getBatteryLabel() != GBDevice.BATTERY_LABEL_DEFAULT) {
|
||||
prefHeader.setTitle(batteryConfig.getBatteryLabel());
|
||||
} else {
|
||||
prefHeader.setTitle(requireContext().getString(R.string.battery_i, batteryConfig.getBatteryIndex()));
|
||||
|
@ -69,11 +69,21 @@ public class BatteryConfig {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof BatteryConfig)) return false;
|
||||
BatteryConfig that = (BatteryConfig) o;
|
||||
return getBatteryIndex() == that.getBatteryIndex() && getBatteryIcon() == that.getBatteryIcon() && getBatteryLabel() == that.getBatteryLabel();
|
||||
return getBatteryIndex() == that.getBatteryIndex() &&
|
||||
getBatteryIcon() == that.getBatteryIcon() &&
|
||||
getBatteryLabel() == that.getBatteryLabel() &&
|
||||
getDefaultLowThreshold() == that.getDefaultLowThreshold() &&
|
||||
getDefaultFullThreshold() == that.getDefaultFullThreshold();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getBatteryIndex(), getBatteryIcon(), getBatteryLabel());
|
||||
return Objects.hash(
|
||||
getBatteryIndex(),
|
||||
getBatteryIcon(),
|
||||
getBatteryLabel(),
|
||||
getDefaultLowThreshold(),
|
||||
getDefaultFullThreshold()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user