mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-26 00:21:45 +01:00
UM25: added some fields to UI
This commit is contained in:
parent
a6ed6c91da
commit
1a892aa159
@ -20,10 +20,16 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.um25.Support.UM25Sup
|
|||||||
public class DataActivity extends AbstractGBActivity {
|
public class DataActivity extends AbstractGBActivity {
|
||||||
private HashMap<Integer, TextView> valueViews = new HashMap<>(ValueDisplay.values().length);
|
private HashMap<Integer, TextView> valueViews = new HashMap<>(ValueDisplay.values().length);
|
||||||
|
|
||||||
|
private TextView chargeDurationTextView;
|
||||||
|
|
||||||
private enum ValueDisplay{
|
private enum ValueDisplay{
|
||||||
VOLTAGE("voltage", "%.3fV", R.id.um25_text_voltage, 1000),
|
VOLTAGE("voltage", "%.3fV", R.id.um25_text_voltage, 1000),
|
||||||
CURRENT("current", "%.4fA", R.id.um25_text_current, 10000),
|
CURRENT("current", "%.4fA", R.id.um25_text_current, 10000),
|
||||||
|
CURRENT_SUM("chargedCurrent", "%.0fmAh", R.id.um25_text_current_sum, 1),
|
||||||
WATTAGE("wattage", "%.3fW", R.id.um25_text_wattage, 1000),
|
WATTAGE("wattage", "%.3fW", R.id.um25_text_wattage, 1000),
|
||||||
|
WATTAGE_SUM("chargedWattage", "%.3fWh", R.id.um25_text_wattage_sum, 1000),
|
||||||
|
TEMPERATURE_CELCIUS("temperatureCelcius", "%.0f°", R.id.um25_text_temperature, 1),
|
||||||
|
CABLE_RESISTANCE("cableResistance", "%.1fΩ", R.id.um25_cable_resistance, 10),
|
||||||
;
|
;
|
||||||
|
|
||||||
private String variableName;
|
private String variableName;
|
||||||
@ -43,6 +49,8 @@ public class DataActivity extends AbstractGBActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_um25_data);
|
setContentView(R.layout.activity_um25_data);
|
||||||
|
|
||||||
|
chargeDurationTextView = findViewById(R.id.um25_text_charge_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -81,6 +89,19 @@ public class DataActivity extends AbstractGBActivity {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int durationSeconds = data.getChargingSeconds();
|
||||||
|
int hours = durationSeconds / 3600;
|
||||||
|
int minutes = durationSeconds % 3600 / 60;
|
||||||
|
int seconds = durationSeconds % 60;
|
||||||
|
|
||||||
|
String timeString = String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
||||||
|
|
||||||
|
int thresholdCurrent = data.getThresholdCurrent();
|
||||||
|
int current = data.getCurrent() / 10;
|
||||||
|
|
||||||
|
chargeDurationTextView.setTextColor(current > thresholdCurrent ? 0xff669900 : 0xffcc0000);
|
||||||
|
chargeDurationTextView.setText(timeString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BroadcastReceiver measurementReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver measurementReceiver = new BroadcastReceiver() {
|
||||||
|
@ -74,7 +74,7 @@ public class MeasurementData implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getThresholdCurrent() {
|
public int getThresholdCurrent() {
|
||||||
return thresholdCurrent;
|
return thresholdCurrent * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getChargingSeconds() {
|
public int getChargingSeconds() {
|
||||||
|
@ -1,36 +1,100 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/um25_text_voltage"
|
android:id="@+id/um25_text_voltage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:textColor="@android:color/holo_green_dark"
|
||||||
|
android:textSize="@dimen/um25_value_text_size" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:textSize="@dimen/um25_value_text_size"
|
android:orientation="vertical">
|
||||||
android:textColor="@android:color/holo_green_dark"/>
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/um25_text_current"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@android:color/holo_red_dark"
|
||||||
|
android:textSize="@dimen/um25_value_text_size" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/um25_text_current_sum"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@android:color/holo_red_dark"
|
||||||
|
android:textSize="@dimen/um25_value_text_size_small" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/um25_text_wattage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="@dimen/um25_value_text_size" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/um25_text_wattage_sum"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="@dimen/um25_value_text_size_small" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/um25_text_charge_duration"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/um25_text_current"
|
android:layout_margin="10dp"
|
||||||
android:gravity="center_horizontal"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="@dimen/um25_value_text_size"
|
android:textSize="@dimen/um25_value_text_size" />
|
||||||
android:textColor="@android:color/holo_red_dark"/>
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/um25_text_wattage"
|
android:layout_margin="10dp"
|
||||||
android:gravity="center_horizontal"
|
android:orientation="horizontal">
|
||||||
android:textSize="@dimen/um25_value_text_size"
|
|
||||||
android:textColor="@android:color/white"/>
|
<TextView
|
||||||
|
android:id="@+id/um25_text_temperature"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="@dimen/um25_value_text_size_small"
|
||||||
|
android:layout_marginEnd="20dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/um25_cable_resistance"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="@dimen/um25_value_text_size_small" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -15,4 +15,5 @@ http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
|
|||||||
<dimen name="fab_margin">16dp</dimen>
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
<dimen name="dialog_margin">20dp</dimen>
|
<dimen name="dialog_margin">20dp</dimen>
|
||||||
<dimen name="um25_value_text_size">60dp</dimen>
|
<dimen name="um25_value_text_size">60dp</dimen>
|
||||||
|
<dimen name="um25_value_text_size_small">30dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user