diff --git a/app/build.gradle b/app/build.gradle index 45dc106..109e2cf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,4 +26,5 @@ android { dependencies { implementation "androidx.annotation:annotation:1.1.0" + implementation "androidx.constraintlayout:constraintlayout:1.1.3" } diff --git a/app/src/main/java/ch/fixme/status/Main.java b/app/src/main/java/ch/fixme/status/Main.java index 4581ac0..e19764b 100644 --- a/app/src/main/java/ch/fixme/status/Main.java +++ b/app/src/main/java/ch/fixme/status/Main.java @@ -37,7 +37,6 @@ import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.RelativeLayout; import android.widget.ScrollView; import android.widget.SectionIndexer; import android.widget.TextView; @@ -60,6 +59,7 @@ import java.util.regex.Pattern; import androidx.annotation.UiThread; +import androidx.constraintlayout.widget.ConstraintLayout; public class Main extends Activity { @@ -700,65 +700,65 @@ private void populateDataHs() { ArrayList> sensorsData = sensors .get(name); for (HashMap elem : sensorsData) { - RelativeLayout rl = (RelativeLayout) iftr.inflate( + ConstraintLayout sensorView = (ConstraintLayout) iftr.inflate( R.layout.entry_sensor, null); if (elem.containsKey(ParseGeneric.API_SENSOR_VALUE)) { - ((TextView) rl.findViewById(R.id.entry_value)) + ((TextView) sensorView.findViewById(R.id.entry_value)) .setText(elem.get(ParseGeneric.API_SENSOR_VALUE)); } else { - rl.findViewById(R.id.entry_value).setVisibility( + sensorView.findViewById(R.id.entry_value).setVisibility( View.GONE); } if (elem.containsKey(ParseGeneric.API_SENSOR_UNIT)) { - ((TextView) rl.findViewById(R.id.entry_unit)) + ((TextView) sensorView.findViewById(R.id.entry_unit)) .setText(elem.get(ParseGeneric.API_SENSOR_UNIT)); } else { - rl.findViewById(R.id.entry_unit).setVisibility( + sensorView.findViewById(R.id.entry_unit).setVisibility( View.GONE); } if (elem.containsKey(ParseGeneric.API_SENSOR_NAME)) { - ((TextView) rl.findViewById(R.id.entry_name)) + ((TextView) sensorView.findViewById(R.id.entry_name)) .setText(elem.get(ParseGeneric.API_SENSOR_NAME)); } else { - rl.findViewById(R.id.entry_name).setVisibility( + sensorView.findViewById(R.id.entry_name).setVisibility( View.GONE); } if (elem.containsKey(ParseGeneric.API_SENSOR_LOCATION)) { - ((TextView) rl.findViewById(R.id.entry_location)) + ((TextView) sensorView.findViewById(R.id.entry_location)) .setText(elem .get(ParseGeneric.API_SENSOR_LOCATION)); } else { - rl.findViewById(R.id.entry_location).setVisibility( + sensorView.findViewById(R.id.entry_location).setVisibility( View.GONE); } if (elem.containsKey(ParseGeneric.API_SENSOR_DESCRIPTION)) { - ((TextView) rl.findViewById(R.id.entry_description)) + ((TextView) sensorView.findViewById(R.id.entry_description)) .setText(elem .get(ParseGeneric.API_SENSOR_DESCRIPTION)); } else { - rl.findViewById(R.id.entry_description) + sensorView.findViewById(R.id.entry_description) .setVisibility(View.GONE); } if (elem.containsKey(ParseGeneric.API_SENSOR_PROPERTIES)) { - ((TextView) rl.findViewById(R.id.entry_properties)) + ((TextView) sensorView.findViewById(R.id.entry_properties)) .setText(elem .get(ParseGeneric.API_SENSOR_PROPERTIES)); } else { - rl.findViewById(R.id.entry_properties) + sensorView.findViewById(R.id.entry_properties) .setVisibility(View.GONE); } if (elem.containsKey(ParseGeneric.API_SENSOR_MACHINES)) { - ((TextView) rl.findViewById(R.id.entry_other)) + ((TextView) sensorView.findViewById(R.id.entry_other)) .setText(elem .get(ParseGeneric.API_SENSOR_MACHINES)); } else if (elem.containsKey(ParseGeneric.API_SENSOR_NAMES)) { - ((TextView) rl.findViewById(R.id.entry_other)) + ((TextView) sensorView.findViewById(R.id.entry_other)) .setText(elem.get(ParseGeneric.API_SENSOR_NAMES)); } else { - rl.findViewById(R.id.entry_other).setVisibility( + sensorView.findViewById(R.id.entry_other).setVisibility( View.GONE); } - vg.addView(rl); + vg.addView(sensorView); } } } diff --git a/app/src/main/res/layout/entry_sensor.xml b/app/src/main/res/layout/entry_sensor.xml index fea2769..3674377 100644 --- a/app/src/main/res/layout/entry_sensor.xml +++ b/app/src/main/res/layout/entry_sensor.xml @@ -3,31 +3,33 @@ Copyright (C) 2012 Aubort Jean-Baptiste (Rorist) Licensed under GNU's GPL 3, see README --> - + + android:src="@android:drawable/sym_contact_card" /> @@ -35,64 +37,63 @@ android:id="@+id/entry_unit" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_toRightOf="@id/entry_value" - android:layout_alignParentTop="true" - android:layout_alignWithParentIfMissing="true" + android:layout_marginStart="4dp" + android:text="°C" android:textAppearance="?android:attr/textAppearanceMedium" android:textIsSelectable="true" - android:text="°C" /> + app:layout_constraintBaseline_toBaselineOf="@id/entry_value" + app:layout_constraintStart_toEndOf="@id/entry_value" /> - +