From 227da2953b1f6e59ad88d9a7fe1fbfe66efc6e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cengiz=20G=C3=BCm=C3=BCs?= Date: Wed, 18 Oct 2023 13:15:01 +0200 Subject: [PATCH] Implement not charging battery state --- .../dev/fluttercommunity/plus/battery/BatteryPlusPlugin.kt | 3 ++- .../battery_plus_platform_interface/lib/src/enums.dart | 3 +++ .../battery_plus_platform_interface/lib/src/utils.dart | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/battery_plus/battery_plus/android/src/main/kotlin/dev/fluttercommunity/plus/battery/BatteryPlusPlugin.kt b/packages/battery_plus/battery_plus/android/src/main/kotlin/dev/fluttercommunity/plus/battery/BatteryPlusPlugin.kt index 3dd1bd3699..512916ba02 100644 --- a/packages/battery_plus/battery_plus/android/src/main/kotlin/dev/fluttercommunity/plus/battery/BatteryPlusPlugin.kt +++ b/packages/battery_plus/battery_plus/android/src/main/kotlin/dev/fluttercommunity/plus/battery/BatteryPlusPlugin.kt @@ -191,7 +191,8 @@ class BatteryPlusPlugin : MethodCallHandler, EventChannel.StreamHandler, Flutter return when (status) { BatteryManager.BATTERY_STATUS_CHARGING -> "charging" BatteryManager.BATTERY_STATUS_FULL -> "full" - BatteryManager.BATTERY_STATUS_DISCHARGING, BatteryManager.BATTERY_STATUS_NOT_CHARGING -> "discharging" + BatteryManager.BATTERY_STATUS_DISCHARGING -> "discharging" + BatteryManager.BATTERY_STATUS_NOT_CHARGING -> "not_charging" BatteryManager.BATTERY_STATUS_UNKNOWN -> "unknown" else -> null } diff --git a/packages/battery_plus/battery_plus_platform_interface/lib/src/enums.dart b/packages/battery_plus/battery_plus_platform_interface/lib/src/enums.dart index 30835213ad..7282745695 100644 --- a/packages/battery_plus/battery_plus_platform_interface/lib/src/enums.dart +++ b/packages/battery_plus/battery_plus_platform_interface/lib/src/enums.dart @@ -9,6 +9,9 @@ enum BatteryState { /// The battery is currently losing energy. discharging, + /// The battery is not charging. + notCharging, + /// The state of the battery is unknown. unknown } diff --git a/packages/battery_plus/battery_plus_platform_interface/lib/src/utils.dart b/packages/battery_plus/battery_plus_platform_interface/lib/src/utils.dart index b6a15605d9..7f90049ff5 100644 --- a/packages/battery_plus/battery_plus_platform_interface/lib/src/utils.dart +++ b/packages/battery_plus/battery_plus_platform_interface/lib/src/utils.dart @@ -9,6 +9,8 @@ BatteryState parseBatteryState(String state) { return BatteryState.charging; case 'discharging': return BatteryState.discharging; + case 'not_charging': + return BatteryState.notCharging; case 'unknown': return BatteryState.unknown; default: