Skip to content

Commit e0256f8

Browse files
Fix: Fixed the battery current and voltage numbers.
Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
1 parent 8924644 commit e0256f8

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

app/src/main/java/com/github/droidworksstudio/launcher/ui/widgets/WidgetFragment.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,12 @@ class WidgetFragment : Fragment(),
268268
val isCharging = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1)
269269
val health = intent.getIntExtra(BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_UNKNOWN)
270270
val count = intent.getIntExtra(BatteryManager.EXTRA_CYCLE_COUNT, 0)
271-
val current = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW)
271+
val currentMicroAmps = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW)
272+
val current = (currentMicroAmps / 1000.0)
272273
val voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0)
274+
val voltageVolts = (voltage / 1.0)
273275
val temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0)
274-
val temperatureCelsius = temperature / 10.0
276+
val temperatureCelsius = (temperature / 10.0)
275277

276278
val voltageScale = getString(R.string.widget_mv)
277279
val currentScale = getString(R.string.widget_ma)
@@ -296,7 +298,7 @@ class WidgetFragment : Fragment(),
296298
binding.batteryCount.text = getString(R.string.widgets_battery_count, count)
297299
binding.chargingStatus.text = getString(R.string.widgets_battery_status, chargingStatusText)
298300
binding.batteryHealth.text = getString(R.string.widgets_battery_health, healthStatus)
299-
binding.batteryVoltage.text = getString(R.string.widgets_battery_voltage, voltage, voltageScale)
301+
binding.batteryVoltage.text = getString(R.string.widgets_battery_voltage, voltageVolts, voltageScale)
300302
binding.batteryCurrent.text = getString(R.string.widgets_battery_current, current, currentScale)
301303
binding.batteryTemperature.text = getString(R.string.widgets_battery_temperature, temperatureCelsius, temperatureScale)
302304
}

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,10 @@
598598

599599
<string name="widgets_battery_level">Battery Level : %d %%</string>
600600
<string name="widgets_battery_count">Battery Charge Count : %1$d</string>
601-
<string name="widgets_battery_current">Battery Current : %1$d %2$s</string>
601+
<string name="widgets_battery_current">Battery Current : %1$.2f %2$s</string>
602602
<string name="widgets_battery_status">Charging Status : %1$s</string>
603603
<string name="widgets_battery_health">Battery Health : %1$s</string>
604-
<string name="widgets_battery_voltage">Battery Voltage : %1$d %2$s</string>
604+
<string name="widgets_battery_voltage">Battery Voltage : %1$.2f %2$s</string>
605605
<string name="widgets_battery_temperature">Battery Temperature : %1$.2f %2$s</string>
606606

607607
<string name="widgets_settings_display_weather">Weather Widget</string>

0 commit comments

Comments
 (0)