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 measurementView = convertView ?: LayoutInflater.from(parent.context)
.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.setCompoundDrawablesWithIntrinsicBounds(
measurement.getIcon() ?: 0,
@@ -143,7 +143,7 @@ class DeviceListAdapter(
0,
0
)
measurementView.findViewById<TextView>(R.id.measurement_value).text =
measurementView.findViewById<TextView>(R.id.measurement_body).text =
measurement.getFormattedValue()
return measurementView
}

View File

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

View File

@@ -1,38 +1,36 @@
<?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_height="wrap_content">
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<TextView
android:id="@+id/measurement_label"
android:layout_width="wrap_content"
android:id="@+id/measurement_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/grey"
android:drawablePadding="2dp"
android:textSize="16sp"
android:textColor="@color/black"
app:drawableStartCompat="@drawable/baseline_device_thermostat_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Temperature" />
android:paddingVertical="5sp"
android:text="Title"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:textSize="16sp" />
<TextView
android:id="@+id/measurement_value"
android:textColor="@color/black"
android:id="@+id/measurement_body"
android:layout_width="match_parent"
android:paddingTop="3sp"
android:layout_width="@dimen/match_constraint"
android:paddingBottom="15sp"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:text="Hello, I am a TextView"
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>