2015-04-19 22:20:47 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.miband;
|
|
|
|
|
2015-05-01 01:26:12 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
|
|
|
2015-04-19 22:20:47 +02:00
|
|
|
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);
|
2015-04-19 22:20:47 +02:00
|
|
|
case 2:
|
2015-05-01 01:26:12 +02:00
|
|
|
return GBApplication.getContext().getString(R.string.battery_medium);
|
2015-04-19 22:20:47 +02:00
|
|
|
case 3:
|
2015-05-01 01:26:12 +02:00
|
|
|
return GBApplication.getContext().getString(R.string.battery_full);
|
2015-04-19 22:20:47 +02:00
|
|
|
case 4:
|
2015-05-01 01:26:12 +02:00
|
|
|
return GBApplication.getContext().getString(R.string.battery_not_charging);
|
2015-04-19 22:20:47 +02:00
|
|
|
}
|
|
|
|
}
|
2015-05-01 01:26:12 +02:00
|
|
|
return GBApplication.getContext().getString(R.string._unknown_);
|
2015-04-19 22:20:47 +02:00
|
|
|
}
|
|
|
|
}
|