Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/battery_plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.0

- Added "unknown" battery state for batteryless systems.

## 0.9.1

- Send initial battery status for Android
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ private static void publishBatteryStatus(final EventSink events, int status) {
events.success("full");
break;
case BatteryManager.BATTERY_STATUS_DISCHARGING:
case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
events.success("discharging");
break;
case BatteryManager.BATTERY_STATUS_UNKNOWN:
events.success("unknown");
default:
events.error("UNAVAILABLE", "Charging status unavailable", null);
break;
Expand Down
2 changes: 2 additions & 0 deletions packages/battery_plus/ios/Classes/FLTBatteryPlusPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ - (void)sendBatteryStateEvent {
if (!_eventSink) return;
UIDeviceBatteryState state = [[UIDevice currentDevice] batteryState];
switch (state) {
case UIDeviceBatteryStateUnknown:
_eventSink(@"unknown");
case UIDeviceBatteryStateFull:
_eventSink(@"full");
case UIDeviceBatteryStateCharging:
Expand Down
12 changes: 6 additions & 6 deletions packages/battery_plus/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: battery_plus
description: Flutter plugin for accessing information about the battery state(full, charging, discharging).
version: 0.9.1
version: 0.10.0
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/

Expand All @@ -25,11 +25,11 @@ dependencies:
flutter:
sdk: flutter
meta: ^1.0.5
battery_plus_platform_interface: ^0.2.0
battery_plus_linux: ^0.1.0
battery_plus_macos: ^0.1.0
battery_plus_web: ^0.2.0
battery_plus_windows: ^0.1.0
battery_plus_platform_interface: ^0.3.0
battery_plus_linux: ^0.2.0
battery_plus_macos: ^0.2.0
battery_plus_web: ^0.3.0
battery_plus_windows: ^0.2.0

dev_dependencies:
async: ^2.0.8
Expand Down
4 changes: 4 additions & 0 deletions packages/battery_plus_linux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.0

- Added "unknown" battery state for batteryless systems.

## 0.1.0

- Initial Linux support.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import 'package:meta/meta.dart';

import 'upower_device.dart';

// ### TODO: introduce an 'unknown' battery state for workstations?
// https://github.com/fluttercommunity/plus_plugins/issues/61
extension _ToBatteryState on UPowerBatteryState {
BatteryState toBatteryState() {
switch (this) {
case UPowerBatteryState.charging:
return BatteryState.charging;
case UPowerBatteryState.discharging:
return BatteryState.discharging;
default:
case UPowerBatteryState.fullyCharged:
return BatteryState.full;
default:
return BatteryState.unknown;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/battery_plus_linux/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: battery_plus_linux
description: Linux implementation of the battery_plus plugin
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/
version: 0.1.0
version: 0.2.0

environment:
sdk: ">=2.7.0 <3.0.0"
flutter: ">=1.20.0"

dependencies:
battery_plus_platform_interface: ^0.2.0
battery_plus_platform_interface: ^0.3.0
dbus: ^0.1.0
flutter:
sdk: flutter
Expand Down
4 changes: 4 additions & 0 deletions packages/battery_plus_macos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.0

- Added "unknown" battery state for batteryless systems.

## 0.1.0

* Initial macOS release.
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ class BatteryPlusChargingHandler: NSObject, FlutterStreamHandler {

// Returns nil when battery is discharging
if let isCharging = (description[kIOPSPowerSourceStateKey] as? String) {
if isCharging == kIOPSACPowerValue{
if isCharging == kIOPSACPowerValue {
return "charging"
}else {
} else if isCharging == kIOPSBatteryPowerValue {
return "discharging"
} else {
return "unknown"
}
}
return "UNAVAILABLE"
Expand Down
4 changes: 2 additions & 2 deletions packages/battery_plus_macos/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: battery_plus_macos
description: An implementation for the macos platform of the Flutter `battery_plus` plugin.
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/
version: 0.1.0
version: 0.2.0

environment:
sdk: '>=2.6.0 <3.0.0'
flutter: '>=1.20.0'

dependencies:
battery_plus_platform_interface: ^0.2.0
battery_plus_platform_interface: ^0.3.0
flutter:
sdk: flutter

Expand Down
5 changes: 5 additions & 0 deletions packages/battery_plus_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.3.0

- Added "unknown" battery state for batteryless systems.


## 0.2.0

- Rename method channel to avoid conflicts
Expand Down
5 changes: 4 additions & 1 deletion packages/battery_plus_platform_interface/lib/src/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ enum BatteryState {
charging,

/// The battery is currently losing energy.
discharging
discharging,

/// The state of the battery is unknown.
unknown
}
2 changes: 2 additions & 0 deletions packages/battery_plus_platform_interface/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ BatteryState parseBatteryState(String state) {
return BatteryState.charging;
case 'discharging':
return BatteryState.discharging;
case 'unknown':
return BatteryState.unknown;
default:
throw ArgumentError('$state is not a valid BatteryState.');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/battery_plus_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: battery_plus_platform_interface
description: A common platform interface for the battery_plus plugin.
version: 0.2.0
version: 0.3.0
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/

Expand Down
4 changes: 4 additions & 0 deletions packages/battery_plus_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.0

- Added "unknown" battery state for batteryless systems.

## 0.2.0

- Rename method channel to avoid conflicts
Expand Down
4 changes: 2 additions & 2 deletions packages/battery_plus_web/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: battery_plus_web
description: An implementation for the web platform of the Flutter `battery_plus` plugin.
version: 0.2.0
version: 0.3.0
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/

Expand All @@ -12,7 +12,7 @@ flutter:
fileName: battery_plus_web.dart

dependencies:
battery_plus_platform_interface: ^0.2.0
battery_plus_platform_interface: ^0.3.0
flutter_web_plugins:
sdk: flutter
flutter:
Expand Down
4 changes: 4 additions & 0 deletions packages/battery_plus_windows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.0

- Added "unknown" battery state for batteryless systems.

## 0.1.0

- Initial Windows support.
4 changes: 2 additions & 2 deletions packages/battery_plus_windows/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: battery_plus_windows
description: Windows implementation of the battery_plus plugin
version: 0.1.0
version: 0.2.0
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/

Expand All @@ -9,7 +9,7 @@ environment:
flutter: ">=1.20.0"

dependencies:
battery_plus_platform_interface: ^0.2.0
battery_plus_platform_interface: ^0.3.0
flutter:
sdk: flutter

Expand Down
3 changes: 2 additions & 1 deletion packages/battery_plus_windows/windows/system_battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ std::string SystemBattery::GetStatusString() const {
case BatteryStatus::Discharging:
return "discharging";
case BatteryStatus::Full:
return "full";
case BatteryStatus::Unknown:
default:
return "full"; // ### TODO: unknown
return "unknown";
}
}

Expand Down