feat: more layout improvements

This commit is contained in:
Stefan Zollinger
2023-12-14 11:51:18 +01:00
parent 6fe6d13dea
commit 9d7a2497cf
4 changed files with 29 additions and 43 deletions

View File

@@ -135,7 +135,7 @@ class DeviceListAdapter(
val measurement = measurements[position] val measurement = measurements[position]
val measurementView = convertView ?: LayoutInflater.from(parent.context) val measurementView = convertView ?: LayoutInflater.from(parent.context)
.inflate(R.layout.row_measurements_list, parent, false) .inflate(R.layout.row_measurements_list, parent, false)
val labelView = measurementView.findViewById<TextView>(R.id.measurement_label) val labelView = measurementView.findViewById<TextView>(R.id.measurement_title)
labelView.text = measurement.getLabel() labelView.text = measurement.getLabel()
labelView.setCompoundDrawablesWithIntrinsicBounds( labelView.setCompoundDrawablesWithIntrinsicBounds(
measurement.getIcon() ?: 0, measurement.getIcon() ?: 0,
@@ -143,7 +143,7 @@ class DeviceListAdapter(
0, 0,
0 0
) )
measurementView.findViewById<TextView>(R.id.measurement_value).text = measurementView.findViewById<TextView>(R.id.measurement_body).text =
measurement.getFormattedValue() measurement.getFormattedValue()
return measurementView return measurementView
} }

View File

@@ -187,11 +187,11 @@ class KirbyDevice(
measurements.reversed().forEach { m -> result.addAll(payloadToMeasurements(m))} measurements.reversed().forEach { m -> result.addAll(payloadToMeasurements(m))}
/*
var pl = Payload(payload = "006b04ab74a1ed0d101404", ts = "2000") var pl = Payload(payload = "006b04ab74a1ed0d101404", ts = "2000")
result.addAll(payloadToMeasurements(pl)) result.addAll(payloadToMeasurements(pl))
result.addAll(payloadToMeasurements(pl)) result.addAll(payloadToMeasurements(pl))
*/
return result return result
} }
@@ -358,19 +358,7 @@ fun bytesToInt32(arr: ByteArray, start: Int): Int {
private fun payloadToMeasurements(payload: Payload): List<Measurement> { private fun payloadToMeasurements(payload: Payload): List<Measurement> {
return listOf(object : Measurement { return listOf(object : Measurement {
override fun getLabel(): String { override fun getLabel(): String {
return "TS" return payload.ts.toString()
}
override fun getFormattedValue(): String {
return "${payload.ts}"
}
override fun getIcon(): Int? {
return R.drawable.baseline_numbers_24
}
}, object : Measurement {
override fun getLabel(): String {
return ""
} }
override fun getFormattedValue(): String { override fun getFormattedValue(): String {
@@ -378,7 +366,7 @@ private fun payloadToMeasurements(payload: Payload): List<Measurement> {
} }
override fun getIcon(): Int? { override fun getIcon(): Int? {
return null return R.drawable.baseline_numbers_24
} }
} }
) )

View File

@@ -130,7 +130,7 @@ class MainActivity : AppCompatActivity() {
} }
//addDummyDevices() addDummyDevices()
} }
private fun addBondedDevices(): Unit { private fun addBondedDevices(): Unit {

View File

@@ -1,38 +1,36 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/measurement_label" android:id="@+id/measurement_title"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/grey"
android:drawablePadding="2dp" android:drawablePadding="2dp"
android:textSize="16sp" android:paddingVertical="5sp"
android:textColor="@color/black" android:text="Title"
app:drawableStartCompat="@drawable/baseline_device_thermostat_24" android:textAppearance="@style/TextAppearance.AppCompat.Title"
app:layout_constraintBottom_toBottomOf="parent" android:textSize="16sp" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Temperature" />
<TextView <TextView
android:id="@+id/measurement_value" android:id="@+id/measurement_body"
android:textColor="@color/black" android:layout_width="match_parent"
android:paddingTop="3sp"
android:layout_width="@dimen/match_constraint" android:paddingBottom="15sp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Hello, I am a TextView"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:text="600°" />
</androidx.constraintlayout.widget.ConstraintLayout> </LinearLayout>