Display battery label in RED when battery is LOW #40

live-activity-data
cpfeiffer 2015-09-02 22:46:14 +02:00
parent bc98805809
commit 05ee6e46c6
1 changed files with 11 additions and 3 deletions

View File

@ -1,6 +1,8 @@
package nodomain.freeyourgadget.gadgetbridge.adapter;
import android.content.Context;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -61,9 +63,15 @@ public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
if (batteryLevel != GBDevice.BATTERY_UNKNOWN) {
batteryStatusLabel.setText("BAT: " + device.getBatteryLevel() + "%");
BatteryState batteryState = device.getBatteryState();
if (BatteryState.BATTERY_CHARGING.equals(batteryState) ||
BatteryState.BATTERY_CHARGING_FULL.equals(batteryState)) {
batteryStatusLabel.append(" CHG");
if (BatteryState.BATTERY_LOW.equals(batteryState)) {
batteryStatusLabel.setTextColor(Color.RED);
} else {
batteryStatusLabel.setTextColor(ContextCompat.getColor(getContext(), R.color.secondarytext));
if (BatteryState.BATTERY_CHARGING.equals(batteryState) ||
BatteryState.BATTERY_CHARGING_FULL.equals(batteryState)) {
batteryStatusLabel.append(" CHG");
}
}
} else {
batteryStatusLabel.setText("");