mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-13 13:39:26 +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;
|
package nodomain.freeyourgadget.gadgetbridge.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -61,10 +63,16 @@ public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
|
|||||||
if (batteryLevel != GBDevice.BATTERY_UNKNOWN) {
|
if (batteryLevel != GBDevice.BATTERY_UNKNOWN) {
|
||||||
batteryStatusLabel.setText("BAT: " + device.getBatteryLevel() + "%");
|
batteryStatusLabel.setText("BAT: " + device.getBatteryLevel() + "%");
|
||||||
BatteryState batteryState = device.getBatteryState();
|
BatteryState batteryState = device.getBatteryState();
|
||||||
|
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) ||
|
if (BatteryState.BATTERY_CHARGING.equals(batteryState) ||
|
||||||
BatteryState.BATTERY_CHARGING_FULL.equals(batteryState)) {
|
BatteryState.BATTERY_CHARGING_FULL.equals(batteryState)) {
|
||||||
batteryStatusLabel.append(" CHG");
|
batteryStatusLabel.append(" CHG");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
batteryStatusLabel.setText("");
|
batteryStatusLabel.setText("");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user