Added GUI to FragmentAddBattery, added Room dependencies.

This commit is contained in:
sockenklaus
2022-07-14 21:01:16 +02:00
parent b8abc9326e
commit b25f1aea76
6 changed files with 108 additions and 24 deletions

View File

@@ -35,6 +35,13 @@ android {
}
dependencies {
def room_version = "2.4.2"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-rxjava3:$room_version"
implementation "androidx.room:room-paging:2.5.0-alpha02"
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'

View File

@@ -1,14 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.AddBatteryFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
android:id="@+id/text_battery_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="@string/battery_id"
app:layout_constraintBaseline_toBaselineOf="@+id/battery_id"
app:layout_constraintStart_toStartOf="parent" />
</FrameLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/battery_id"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginTop="24dp"
android:hint="@string/hint_enter_battery_id"
app:layout_constraintStart_toStartOf="@id/declared_capacity"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"/>
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/text_declared_capacity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="@string/declared_capacity"
app:layout_constraintBaseline_toBaselineOf="@+id/declared_capacity"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/declared_capacity"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="16dp"
android:hint="@string/hint_enter_declared_capacity"
app:layout_constraintStart_toEndOf="@id/text_declared_capacity"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/battery_id">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginTop="32dp"
android:layout_marginEnd="24dp"
android:contentDescription="@string/button_save_battery"
android:text="@string/button_save_battery"
app:icon="@drawable/ic_baseline_check_24"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/declared_capacity" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -13,7 +13,7 @@
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="24dp"
android:hint="Battery ID"
android:hint="@string/select_battery_id"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="parent"
@@ -26,19 +26,21 @@
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"/>
android:inputType="text"
tools:ignore="TextContrastCheck" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/edit_date"
style="@style/Widget.MaterialComponents.Button.TextButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:icon="@drawable/ic_baseline_edit_calendar_24"
style="@style/Widget.MaterialComponents.Button.TextButton.Icon"
app:layout_constraintStart_toStartOf="@+id/edit_battery_id"
app:layout_constraintTop_toBottomOf="@+id/edit_battery_id" />
app:layout_constraintTop_toBottomOf="@+id/edit_battery_id"
tools:ignore="SpeakableTextPresentCheck" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/edit_charge"
@@ -46,7 +48,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
android:hint="Charge, decimal"
android:hint="@string/hint_charge"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/edit_date"
@@ -58,7 +60,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
/>
tools:ignore="TextContrastCheck" />
</com.google.android.material.textfield.TextInputLayout>
@@ -75,7 +77,7 @@
android:id="@+id/text_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date"
android:text="@string/date"
app:layout_constraintBaseline_toBaselineOf="@+id/edit_date"
app:layout_constraintEnd_toEndOf="@+id/text_battery_id" />
@@ -83,7 +85,7 @@
android:id="@+id/text_charge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Charge"
android:text="@string/charge"
app:layout_constraintBaseline_toBaselineOf="@+id/edit_charge"
app:layout_constraintEnd_toEndOf="@+id/text_date" />
@@ -92,12 +94,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="24dp"
android:contentDescription="@string/button_save_charge"
android:text="@string/button_save_charge"
app:icon="@drawable/ic_baseline_check_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edit_charge" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -18,4 +18,12 @@
<string name="menu_add_battery">Add Battery</string>
<string name="battery_id">Battery ID</string>
<string name="button_save_charge">Save Charge</string>
<string name="date">Date</string>
<string name="charge">Charge</string>
<string name="hint_charge">Enter Charge, decimal</string>
<string name="select_battery_id">Select Battery ID</string>
<string name="hint_enter_battery_id">Enter Battery ID</string>
<string name="hint_enter_declared_capacity">Enter declared capacity</string>
<string name="declared_capacity">Declared Capacity</string>
<string name="button_save_battery">Save Battery</string>
</resources>