fix: layout and theme issues
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,3 +15,4 @@
|
||||
local.properties
|
||||
deploymentTargetDropDown.xml
|
||||
env.properties
|
||||
app/debug
|
||||
|
||||
@@ -88,14 +88,14 @@ object DecoderIaq {
|
||||
override fun toString(): String {
|
||||
return "M{" +
|
||||
"type=" + msgType +
|
||||
"co2=" + co2 +
|
||||
", co2=" + co2 +
|
||||
", voc=" + voc +
|
||||
", hum=" + humidity +
|
||||
", temp=" + temperature +
|
||||
", press=" + pressure +
|
||||
", occ=" + occupancy +
|
||||
", pm25=" + pm25 +
|
||||
", pm10=" + pm10 +
|
||||
", occ=" + occupancy +
|
||||
'}'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,8 +120,6 @@ class DeviceListAdapter(
|
||||
}
|
||||
|
||||
val measurements = result.getMeasurements()
|
||||
|
||||
val measurementsRowHeight = 100
|
||||
val measurementsAdapter = object :
|
||||
ArrayAdapter<Measurement>(
|
||||
context,
|
||||
@@ -147,7 +145,6 @@ class DeviceListAdapter(
|
||||
)
|
||||
measurementView.findViewById<TextView>(R.id.measurement_value).text =
|
||||
measurement.getFormattedValue()
|
||||
measurementView.layoutParams.height = measurementsRowHeight
|
||||
return measurementView
|
||||
}
|
||||
|
||||
@@ -158,13 +155,11 @@ class DeviceListAdapter(
|
||||
}
|
||||
|
||||
measurementsListView.adapter = measurementsAdapter
|
||||
measurementsListView.divider = null
|
||||
|
||||
if (measurements.isEmpty()) {
|
||||
measurementsListView.visibility = GONE
|
||||
} else {
|
||||
measurementsListView.visibility = VISIBLE
|
||||
measurementsListView.layoutParams.height = measurementsRowHeight * measurements.size
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,8 +185,14 @@ class KirbyDevice(
|
||||
override fun getMeasurements(): List<Measurement> {
|
||||
val result = mutableListOf<Measurement>()
|
||||
|
||||
measurements.forEach { m -> result.addAll(payloadToMeasurements(m))}
|
||||
return result.reversed()
|
||||
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
|
||||
}
|
||||
|
||||
override fun getActions(): List<Action> {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.example.sensortestingapp;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
public class NonScrollListView extends ListView {
|
||||
|
||||
public NonScrollListView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
public NonScrollListView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
public NonScrollListView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
@Override
|
||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
|
||||
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
|
||||
ViewGroup.LayoutParams params = getLayoutParams();
|
||||
params.height = getMeasuredHeight();
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@
|
||||
android:id="@+id/device_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#000000"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
@@ -84,6 +85,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/black"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:text="MAC: XX:XX:XX:XX:XX" />
|
||||
@@ -94,6 +96,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="2dp"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/black"
|
||||
app:drawableEndCompat="@drawable/signal_strength_medium"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
@@ -113,6 +116,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/black"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:text="Device Status" />
|
||||
@@ -120,12 +124,17 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ListView
|
||||
android:layout_marginTop="20dp"
|
||||
<com.example.sensortestingapp.NonScrollListView
|
||||
android:id="@+id/measurement_fields"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/device_meta" />
|
||||
android:layout_marginTop="20dp"
|
||||
android:divider="@color/greyDarker"
|
||||
android:dividerHeight="1px"
|
||||
android:footerDividersEnabled="true"
|
||||
android:headerDividersEnabled="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/device_meta"
|
||||
tools:layout_editor_absoluteX="10dp" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
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"
|
||||
@@ -20,16 +21,18 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/measurement_value"
|
||||
android:textColor="@color/black"
|
||||
|
||||
android:layout_width="@dimen/match_constraint"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="android:layout_margin="18dp" android:maxWidth="250dp" android:text="@string/year" android:maxLines="24" android:textSize="18sp" app:layout_constraintBottom_toBottomOf="parent"" />
|
||||
tools:text="600°" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.SensorTestingApp" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<style name="Base.Theme.SensorTestingApp" parent="Theme.Material3.Light.NoActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
<item name="android:forceDarkAllowed">false</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -1,8 +1,10 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.SensorTestingApp" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<style name="Base.Theme.SensorTestingApp" parent="Theme.Material3.Light.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
<item name="textAppearanceBody1">@color/black</item>
|
||||
<item name="android:forceDarkAllowed">false</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.SensorTestingApp" parent="Base.Theme.SensorTestingApp" />
|
||||
|
||||
Reference in New Issue
Block a user