mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-07-22 06:41:06 +02:00
Display battery level if known. Should work on Miband, untested.
This commit is contained in:
parent
9efcd8974d
commit
3e85efa898
|
@ -30,7 +30,7 @@ public class GBDevice implements Parcelable {
|
||||||
private String mFirmwareVersion = null;
|
private String mFirmwareVersion = null;
|
||||||
private String mHardwareVersion = null;
|
private String mHardwareVersion = null;
|
||||||
private State mState = State.NOT_CONNECTED;
|
private State mState = State.NOT_CONNECTED;
|
||||||
private short mBatteryLevel = 50; // unknown
|
private short mBatteryLevel = -1; // unknown
|
||||||
private String mBatteryState;
|
private String mBatteryState;
|
||||||
private short mRssi = RSSI_UNKNOWN;
|
private short mRssi = RSSI_UNKNOWN;
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,20 @@ public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
|
||||||
TextView deviceStatusLabel = (TextView) view.findViewById(R.id.device_status);
|
TextView deviceStatusLabel = (TextView) view.findViewById(R.id.device_status);
|
||||||
TextView deviceNameLabel = (TextView) view.findViewById(R.id.device_name);
|
TextView deviceNameLabel = (TextView) view.findViewById(R.id.device_name);
|
||||||
TextView deviceInfoLabel = (TextView) view.findViewById(R.id.device_info);
|
TextView deviceInfoLabel = (TextView) view.findViewById(R.id.device_info);
|
||||||
|
TextView batteryStatusLabel = (TextView) view.findViewById(R.id.battery_status);
|
||||||
ImageView deviceImageView = (ImageView) view.findViewById(R.id.device_image);
|
ImageView deviceImageView = (ImageView) view.findViewById(R.id.device_image);
|
||||||
|
|
||||||
deviceStatusLabel.setText(device.getStateString());
|
deviceStatusLabel.setText(device.getStateString());
|
||||||
deviceNameLabel.setText(device.getName());
|
deviceNameLabel.setText(device.getName());
|
||||||
deviceInfoLabel.setText(device.getInfoString());
|
deviceInfoLabel.setText(device.getInfoString());
|
||||||
|
|
||||||
|
short batteryLevel = device.getBatteryLevel();
|
||||||
|
if (batteryLevel > -1) {
|
||||||
|
batteryStatusLabel.setText("BAT: " + device.getBatteryLevel() + "%");
|
||||||
|
} else {
|
||||||
|
batteryStatusLabel.setText("");
|
||||||
|
}
|
||||||
|
|
||||||
switch (device.getType()) {
|
switch (device.getType()) {
|
||||||
case PEBBLE:
|
case PEBBLE:
|
||||||
deviceImageView.setImageResource(R.drawable.ic_device_pebble);
|
deviceImageView.setImageResource(R.drawable.ic_device_pebble);
|
||||||
|
|
|
@ -35,15 +35,24 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/device_name"
|
android:layout_below="@id/device_name"
|
||||||
android:orientation="vertical"
|
android:orientation="horizontal"
|
||||||
android:paddingTop="3dp">
|
android:paddingTop="3dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/device_status"
|
android:id="@+id/device_status"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
|
android:gravity="left"
|
||||||
android:textColor="@color/primarytext"
|
android:textColor="@color/primarytext"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/battery_status"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:gravity="right"
|
||||||
|
android:textColor="@color/secondarytext"
|
||||||
|
android:textStyle="bold" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
Loading…
Reference in New Issue
Block a user