Moved the enum to standalone in the model package.
This commit is contained in:
parent
3356a4b066
commit
7923e153e6
|
@ -11,9 +11,9 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
||||||
|
|
||||||
public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
|
public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
|
||||||
|
|
||||||
|
@ -60,9 +60,9 @@ public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
|
||||||
short batteryLevel = device.getBatteryLevel();
|
short batteryLevel = device.getBatteryLevel();
|
||||||
if (batteryLevel != GBDevice.BATTERY_UNKNOWN) {
|
if (batteryLevel != GBDevice.BATTERY_UNKNOWN) {
|
||||||
batteryStatusLabel.setText("BAT: " + device.getBatteryLevel() + "%");
|
batteryStatusLabel.setText("BAT: " + device.getBatteryLevel() + "%");
|
||||||
GBDeviceEventBatteryInfo.BatteryState batteryState = device.getBatteryState();
|
BatteryState batteryState = device.getBatteryState();
|
||||||
if (GBDeviceEventBatteryInfo.BatteryState.BATTERY_CHARGING.equals(batteryState) ||
|
if (BatteryState.BATTERY_CHARGING.equals(batteryState) ||
|
||||||
GBDeviceEventBatteryInfo.BatteryState.BATTERY_CHARGING_FULL.equals(batteryState)) {
|
BatteryState.BATTERY_CHARGING_FULL.equals(batteryState)) {
|
||||||
batteryStatusLabel.append(" CHG");
|
batteryStatusLabel.append(" CHG");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3,6 +3,8 @@ package nodomain.freeyourgadget.gadgetbridge.deviceevents;
|
||||||
|
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
||||||
|
|
||||||
public class GBDeviceEventBatteryInfo extends GBDeviceEvent {
|
public class GBDeviceEventBatteryInfo extends GBDeviceEvent {
|
||||||
public GregorianCalendar lastChargeTime= null;
|
public GregorianCalendar lastChargeTime= null;
|
||||||
public BatteryState state = BatteryState.UNKNOWN;
|
public BatteryState state = BatteryState.UNKNOWN;
|
||||||
|
@ -13,15 +15,6 @@ public class GBDeviceEventBatteryInfo extends GBDeviceEvent {
|
||||||
eventClass = EventClass.BATTERY_INFO;
|
eventClass = EventClass.BATTERY_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BatteryState {
|
|
||||||
UNKNOWN,
|
|
||||||
BATTERY_NORMAL,
|
|
||||||
BATTERY_LOW,
|
|
||||||
BATTERY_CHARGING,
|
|
||||||
BATTERY_CHARGING_FULL,
|
|
||||||
BATTERY_NOT_CHARGING_FULL
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean extendedInfoAvailable() {
|
public boolean extendedInfoAvailable() {
|
||||||
if (numCharges != -1 && lastChargeTime != null) {
|
if (numCharges != -1 && lastChargeTime != null) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import android.support.v4.content.LocalBroadcastManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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.model.DeviceType;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ import java.util.Date;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.AppManagerActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.AppManagerActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsHost;
|
import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsHost;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBCallControlReceiver;
|
import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBCallControlReceiver;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
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
|
//show the notification if the battery level is below threshold and only if not connected to charger
|
||||||
if (deviceEvent.level <= gbDevice.getBatteryThresholdPercent() &&
|
if (deviceEvent.level <= gbDevice.getBatteryThresholdPercent() &&
|
||||||
(GBDeviceEventBatteryInfo.BatteryState.BATTERY_LOW.equals(deviceEvent.state) ||
|
(BatteryState.BATTERY_LOW.equals(deviceEvent.state) ||
|
||||||
GBDeviceEventBatteryInfo.BatteryState.BATTERY_NORMAL.equals(deviceEvent.state))
|
BatteryState.BATTERY_NORMAL.equals(deviceEvent.state))
|
||||||
) {
|
) {
|
||||||
GB.updateBatteryNotification(context.getString(R.string.notif_battery_low_percent, gbDevice.getName(), deviceEvent.level),
|
GB.updateBatteryNotification(context.getString(R.string.notif_battery_low_percent, gbDevice.getName(), deviceEvent.level),
|
||||||
deviceEvent.extendedInfoAvailable() ?
|
deviceEvent.extendedInfoAvailable() ?
|
||||||
|
|
|
@ -3,7 +3,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.miband;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo.BatteryState;
|
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
||||||
|
|
||||||
public class BatteryInfo extends AbstractInfo {
|
public class BatteryInfo extends AbstractInfo {
|
||||||
public static final byte DEVICE_BATTERY_NORMAL = 0;
|
public static final byte DEVICE_BATTERY_NORMAL = 0;
|
||||||
|
|
Loading…
Reference in New Issue