Refactor EnvironmentalSensor fragment to use cards.
This commit is contained in:
parent
c3ed9e569a
commit
b6f42a7358
4 changed files with 101 additions and 52 deletions
|
@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import com.google.android.material.chip.Chip;
|
||||
import dev.nuculabs.grpc.EnvironmentSensorData;
|
||||
import dev.nuculabs.grpc.EnvironmentSensorService;
|
||||
import dev.nuculabs.nucuhub.R;
|
||||
|
@ -19,7 +20,7 @@ public class SensorsFragment extends Fragment {
|
|||
private EnvironmentSensorService environmentSensorService;
|
||||
// ui elements
|
||||
private ImageView sensorStatusImageView;
|
||||
private TextView sensorStatusText;
|
||||
private Chip sensorStatusText;
|
||||
private TextView temperatureText;
|
||||
private TextView humidityText;
|
||||
private TextView pressureText;
|
||||
|
@ -34,7 +35,7 @@ public class SensorsFragment extends Fragment {
|
|||
pressureText = root.findViewById(R.id.envSensorPressureText);
|
||||
vocText = root.findViewById(R.id.envSensorVocText);
|
||||
sensorStatusImageView = root.findViewById(R.id.sensorStatusImageView);
|
||||
sensorStatusText = root.findViewById(R.id.sensorStatusText);
|
||||
sensorStatusText = root.findViewById(R.id.sensorStatusChip);
|
||||
|
||||
environmentSensorService = new EnvironmentSensorService("192.168.0.100", 8000);
|
||||
|
||||
|
|
|
@ -29,10 +29,12 @@
|
|||
tools:srcCompat="@drawable/status_neutral" android:adjustViewBounds="true"
|
||||
android:scaleType="center"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp" android:id="@+id/sensorStatusText"
|
||||
tools:text="Sensor Status Explain" android:textStyle="bold" android:layout_margin="20dp"/>
|
||||
<com.google.android.material.chip.Chip
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:id="@+id/sensorStatusChip"
|
||||
android:layout_marginEnd="30dp" android:layout_marginStart="30dp" android:textAlignment="center"
|
||||
tools:text="Sensor Status Explain" android:textStyle="bold" android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="15dp" android:clickable="false"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
<LinearLayout
|
||||
|
@ -65,16 +67,30 @@
|
|||
android:scaleType="fitCenter"
|
||||
android:layout_marginStart="29dp"
|
||||
android:layout_marginTop="21dp"/>
|
||||
<TextView
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="52dp" android:id="@+id/envSensorTempText"
|
||||
android:gravity="center" android:foregroundGravity="center"
|
||||
android:backgroundTint="#00FFFEFE"
|
||||
android:clickable="false" android:drawableTint="#00FFFFFF"
|
||||
android:textStyle="bold" android:textColor="#000000"
|
||||
android:textSize="16sp" android:layout_marginTop="21dp"
|
||||
android:layout_marginStart="29dp" tools:text="10000"
|
||||
android:layout_marginBottom="25dp"/>
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="29dp"
|
||||
android:layout_marginTop="21dp"
|
||||
android:layout_marginBottom="25dp"
|
||||
>
|
||||
<TextView
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="26dp" android:id="@+id/envSensorTempText"
|
||||
android:gravity="center" android:foregroundGravity="center"
|
||||
android:backgroundTint="#00FFFEFE"
|
||||
android:clickable="false" android:drawableTint="#00FFFFFF"
|
||||
android:textStyle="bold" android:textColor="#000000"
|
||||
android:textSize="16sp"
|
||||
tools:text="10000"
|
||||
/>
|
||||
<TextView
|
||||
android:text="@string/temp_sensor_unit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:id="@+id/envSensorTempUnitDesc"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
<androidx.cardview.widget.CardView
|
||||
|
@ -92,18 +108,29 @@
|
|||
android:contentDescription="@string/humidity_icon_desc"
|
||||
android:layout_marginStart="29dp"
|
||||
android:layout_marginTop="21dp"/>
|
||||
<TextView
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="52dp" android:id="@+id/envSensorHumidityText"
|
||||
android:gravity="center" android:foregroundGravity="center"
|
||||
android:backgroundTint="#00FFFEFE"
|
||||
android:clickable="false" android:drawableTint="#00FFFFFF"
|
||||
android:textStyle="bold" android:textColor="#000000"
|
||||
android:textSize="16sp"
|
||||
tools:text="100.11"
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="29dp"
|
||||
android:layout_marginTop="21dp"
|
||||
android:layout_marginBottom="25dp"/>
|
||||
android:layout_marginBottom="25dp"
|
||||
>
|
||||
<TextView
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="26dp" android:id="@+id/envSensorHumidityText"
|
||||
android:gravity="center" android:foregroundGravity="center"
|
||||
android:backgroundTint="#00FFFEFE"
|
||||
android:clickable="false" android:drawableTint="#00FFFFFF"
|
||||
android:textStyle="bold" android:textColor="#000000"
|
||||
android:textSize="16sp"
|
||||
tools:text="100.11"/>
|
||||
<TextView
|
||||
android:text="@string/humidity_sensor_unit"
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="0dp" android:id="@+id/envSensorHumidityUnitDesc"
|
||||
android:layout_weight="1" android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
|
@ -126,18 +153,27 @@
|
|||
android:contentDescription="@string/barometer_icon_desc"
|
||||
android:layout_marginStart="29dp"
|
||||
android:layout_marginTop="21dp"/>
|
||||
<TextView
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="52dp" android:id="@+id/envSensorPressureText"
|
||||
android:gravity="center" android:foregroundGravity="center"
|
||||
android:backgroundTint="#00FFFEFE"
|
||||
android:clickable="false" android:drawableTint="#00FFFFFF"
|
||||
android:textStyle="bold" android:textColor="#000000"
|
||||
android:textSize="16sp"
|
||||
tools:text="1000.5"
|
||||
android:layout_marginStart="29dp"
|
||||
android:layout_marginTop="21dp"
|
||||
android:layout_marginBottom="25dp"/>
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:layout_marginStart="29dp"
|
||||
android:layout_marginTop="21dp" android:layout_marginBottom="25dp">
|
||||
<TextView
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="26dp" android:id="@+id/envSensorPressureText"
|
||||
android:gravity="center" android:foregroundGravity="center"
|
||||
android:backgroundTint="#00FFFEFE"
|
||||
android:clickable="false" android:drawableTint="#00FFFFFF"
|
||||
android:textStyle="bold" android:textColor="#000000"
|
||||
android:textSize="16sp"
|
||||
tools:text="1000.5"
|
||||
/>
|
||||
<TextView
|
||||
android:text="@string/pressure_unit_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:id="@+id/envSensorPressureUnitDesc"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
<androidx.cardview.widget.CardView
|
||||
|
@ -155,19 +191,27 @@
|
|||
android:layout_marginStart="29dp"
|
||||
android:layout_marginTop="21dp"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="52dp" android:id="@+id/envSensorVocText"
|
||||
android:gravity="center" android:foregroundGravity="center"
|
||||
android:backgroundTint="#00FFFEFE"
|
||||
android:clickable="false" android:drawableTint="#00FFFFFF"
|
||||
android:textStyle="bold" android:textColor="#000000"
|
||||
android:textSize="16sp"
|
||||
tools:text="100.11"
|
||||
android:layout_marginStart="29dp"
|
||||
android:layout_marginTop="21dp"
|
||||
android:layout_marginBottom="25dp"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:layout_marginStart="29dp"
|
||||
android:layout_marginTop="21dp" android:layout_marginBottom="25dp">
|
||||
<TextView
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="26dp" android:id="@+id/envSensorVocText"
|
||||
android:gravity="center" android:foregroundGravity="center"
|
||||
android:backgroundTint="#00FFFEFE"
|
||||
android:clickable="false" android:drawableTint="#00FFFFFF"
|
||||
android:textStyle="bold" android:textColor="#000000"
|
||||
android:textSize="16sp"
|
||||
tools:text="100.11"
|
||||
/>
|
||||
<TextView
|
||||
android:text="@string/gasvoc_sensor_unit_descriptio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:id="@+id/textView5"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -15,4 +15,8 @@
|
|||
<string name="temperature_icon_desc">temperature icon</string>
|
||||
<string name="barometer_icon_desc">barometer icon</string>
|
||||
<string name="voc_icon_desc">voc icon</string>
|
||||
<string name="humidity_sensor_unit">Rh%</string>
|
||||
<string name="temp_sensor_unit">Celsius</string>
|
||||
<string name="pressure_unit_desc">hPa</string>
|
||||
<string name="gasvoc_sensor_unit_descriptio">VOC Ω</string>
|
||||
</resources>
|
|
@ -1,6 +1,6 @@
|
|||
<resources>
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
|
|
Loading…
Reference in a new issue