Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/miband/BatteryInfo.java

35 lines
1.1 KiB
Java
Raw Normal View History

package nodomain.freeyourgadget.gadgetbridge.miband;
2015-05-01 01:26:12 +02:00
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
public class BatteryInfo extends AbstractInfo {
public BatteryInfo(byte[] data) {
super(data);
}
public int getLevelInPercent() {
if (mData.length >= 1) {
return mData[0];
}
return 50; // actually unknown
}
public String getStatus() {
if (mData.length >= 10) {
int value = mData[9];
switch (value) {
case 1:
2015-05-01 01:26:12 +02:00
return GBApplication.getContext().getString(R.string.battery_low);
case 2:
2015-05-01 01:26:12 +02:00
return GBApplication.getContext().getString(R.string.battery_medium);
case 3:
2015-05-01 01:26:12 +02:00
return GBApplication.getContext().getString(R.string.battery_full);
case 4:
2015-05-01 01:26:12 +02:00
return GBApplication.getContext().getString(R.string.battery_not_charging);
}
}
2015-05-01 01:26:12 +02:00
return GBApplication.getContext().getString(R.string._unknown_);
}
}