mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 18:15:49 +01:00
Display battery label in RED when battery is LOW #40
This commit is contained in:
parent
bc98805809
commit
05ee6e46c6
@ -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("");
|
||||
|
Loading…
Reference in New Issue
Block a user