1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 10:35:50 +01:00

Moved the enum to standalone in the model package.

This commit is contained in:
Daniele Gobbetti 2015-08-27 11:50:31 +02:00
parent 3356a4b066
commit 7923e153e6
6 changed files with 21 additions and 17 deletions

View File

@ -11,9 +11,9 @@ import android.widget.TextView;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
@ -60,9 +60,9 @@ public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
short batteryLevel = device.getBatteryLevel();
if (batteryLevel != GBDevice.BATTERY_UNKNOWN) {
batteryStatusLabel.setText("BAT: " + device.getBatteryLevel() + "%");
GBDeviceEventBatteryInfo.BatteryState batteryState = device.getBatteryState();
if (GBDeviceEventBatteryInfo.BatteryState.BATTERY_CHARGING.equals(batteryState) ||
GBDeviceEventBatteryInfo.BatteryState.BATTERY_CHARGING_FULL.equals(batteryState)) {
BatteryState batteryState = device.getBatteryState();
if (BatteryState.BATTERY_CHARGING.equals(batteryState) ||
BatteryState.BATTERY_CHARGING_FULL.equals(batteryState)) {
batteryStatusLabel.append(" CHG");
}
} else {

View File

@ -3,6 +3,8 @@ package nodomain.freeyourgadget.gadgetbridge.deviceevents;
import java.util.GregorianCalendar;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
public class GBDeviceEventBatteryInfo extends GBDeviceEvent {
public GregorianCalendar lastChargeTime= null;
public BatteryState state = BatteryState.UNKNOWN;
@ -13,15 +15,6 @@ public class GBDeviceEventBatteryInfo extends GBDeviceEvent {
eventClass = EventClass.BATTERY_INFO;
}
public enum BatteryState {
UNKNOWN,
BATTERY_NORMAL,
BATTERY_LOW,
BATTERY_CHARGING,
BATTERY_CHARGING_FULL,
BATTERY_NOT_CHARGING_FULL
}
public boolean extendedInfoAvailable() {
if (numCharges != -1 && lastChargeTime != null) {
return true;

View File

@ -9,7 +9,7 @@ import android.support.v4.content.LocalBroadcastManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo.BatteryState;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;

View File

@ -0,0 +1,10 @@
package nodomain.freeyourgadget.gadgetbridge.model;
public enum BatteryState {
UNKNOWN,
BATTERY_NORMAL,
BATTERY_LOW,
BATTERY_CHARGING,
BATTERY_CHARGING_FULL,
BATTERY_NOT_CHARGING_FULL
}

View File

@ -22,6 +22,7 @@ import java.util.Date;
import nodomain.freeyourgadget.gadgetbridge.activities.AppManagerActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsHost;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBCallControlReceiver;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -232,8 +233,8 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
//show the notification if the battery level is below threshold and only if not connected to charger
if (deviceEvent.level <= gbDevice.getBatteryThresholdPercent() &&
(GBDeviceEventBatteryInfo.BatteryState.BATTERY_LOW.equals(deviceEvent.state) ||
GBDeviceEventBatteryInfo.BatteryState.BATTERY_NORMAL.equals(deviceEvent.state))
(BatteryState.BATTERY_LOW.equals(deviceEvent.state) ||
BatteryState.BATTERY_NORMAL.equals(deviceEvent.state))
) {
GB.updateBatteryNotification(context.getString(R.string.notif_battery_low_percent, gbDevice.getName(), deviceEvent.level),
deviceEvent.extendedInfoAvailable() ?

View File

@ -3,7 +3,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.miband;
import java.util.Calendar;
import java.util.GregorianCalendar;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo.BatteryState;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
public class BatteryInfo extends AbstractInfo {
public static final byte DEVICE_BATTERY_NORMAL = 0;