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 mHardwareVersion = null;
|
||||
private State mState = State.NOT_CONNECTED;
|
||||
private short mBatteryLevel = 50; // unknown
|
||||
private short mBatteryLevel = -1; // unknown
|
||||
private String mBatteryState;
|
||||
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 deviceNameLabel = (TextView) view.findViewById(R.id.device_name);
|
||||
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);
|
||||
|
||||
deviceStatusLabel.setText(device.getStateString());
|
||||
deviceNameLabel.setText(device.getName());
|
||||
deviceInfoLabel.setText(device.getInfoString());
|
||||
|
||||
short batteryLevel = device.getBatteryLevel();
|
||||
if (batteryLevel > -1) {
|
||||
batteryStatusLabel.setText("BAT: " + device.getBatteryLevel() + "%");
|
||||
} else {
|
||||
batteryStatusLabel.setText("");
|
||||
}
|
||||
|
||||
switch (device.getType()) {
|
||||
case PEBBLE:
|
||||
deviceImageView.setImageResource(R.drawable.ic_device_pebble);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
android:orientation="vertical"
|
||||
android:paddingLeft="8dp">
|
||||
|
||||
<TextView
|
||||
<TextView
|
||||
android:id="@+id/device_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -35,15 +35,24 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/device_name"
|
||||
android:orientation="vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="3dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/device_status"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="left"
|
||||
android:textColor="@color/primarytext"
|
||||
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>
|
||||
|
||||
<TextView
|
||||
|
|
Loading…
Reference in New Issue