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

@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="deploymentTargetDropDown"> <component name="deploymentTargetDropDown">
<targetSelectedWithDropDown> <runningDeviceTargetSelectedWithDropDown>
<Target> <Target>
<type value="QUICK_BOOT_TARGET" /> <type value="RUNNING_DEVICE_TARGET" />
<deviceKey> <deviceKey>
<Key> <Key>
<type value="VIRTUAL_DEVICE_PATH" /> <type value="SERIAL_NUMBER" />
<value value="C:\Android\.android\avd\Pixel_3a_XL_API_29.avd" /> <value value="7abcf1eb" />
</Key> </Key>
</deviceKey> </deviceKey>
</Target> </Target>
</targetSelectedWithDropDown> </runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-07-13T13:52:48.717270500Z" /> <timeTargetWasSelectedWithDropDown value="2022-07-13T21:15:07.915788300Z" />
</component> </component>
</project> </project>

1
.idea/misc.xml generated
View File

@@ -10,6 +10,7 @@
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/activity_main.xml" value="0.425" /> <entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/activity_main.xml" value="0.425" />
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/app_bar_main.xml" value="0.19607843137254902" /> <entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/app_bar_main.xml" value="0.19607843137254902" />
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/content_main.xml" value="0.425" /> <entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/content_main.xml" value="0.425" />
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_add_battery.xml" value="0.5" />
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_add_charge.xml" value="0.5" /> <entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_add_charge.xml" value="0.5" />
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_gallery.xml" value="0.425" /> <entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_gallery.xml" value="0.425" />
<entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_home.xml" value="0.425" /> <entry key="..\:/Users/socrates/AndroidStudioProjects/BatteryTracker/app/src/main/res/layout/fragment_home.xml" value="0.425" />

View File

@@ -35,6 +35,13 @@ android {
} }
dependencies { 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.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2' implementation 'androidx.appcompat:appcompat:1.4.2'

View File

@@ -1,14 +1,80 @@
<?xml version="1.0" encoding="utf-8"?> <?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" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.AddBatteryFragment"> tools:context=".ui.AddBatteryFragment">
<!-- TODO: Update blank fragment layout -->
<TextView <TextView
android:layout_width="match_parent" android:id="@+id/text_battery_id"
android:layout_height="match_parent" android:layout_width="wrap_content"
android:text="@string/hello_blank_fragment" /> 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_marginStart="24dp"
android:layout_marginTop="24dp" android:layout_marginTop="24dp"
android:layout_marginEnd="24dp" android:layout_marginEnd="24dp"
android:hint="Battery ID" android:hint="@string/select_battery_id"
android:minHeight="48dp" android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
@@ -26,19 +26,21 @@
<AutoCompleteTextView <AutoCompleteTextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="text"/> android:inputType="text"
tools:ignore="TextContrastCheck" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<Button <Button
android:id="@+id/edit_date" android:id="@+id/edit_date"
style="@style/Widget.MaterialComponents.Button.TextButton.Icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
app:icon="@drawable/ic_baseline_edit_calendar_24" 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_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 <com.google.android.material.textfield.TextInputLayout
android:id="@+id/edit_charge" android:id="@+id/edit_charge"
@@ -46,7 +48,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginEnd="24dp" android:layout_marginEnd="24dp"
android:hint="Charge, decimal" android:hint="@string/hint_charge"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/edit_date" app:layout_constraintStart_toStartOf="@+id/edit_date"
@@ -58,7 +60,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="numberDecimal" android:inputType="numberDecimal"
/> tools:ignore="TextContrastCheck" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
@@ -75,7 +77,7 @@
android:id="@+id/text_date" android:id="@+id/text_date"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Date" android:text="@string/date"
app:layout_constraintBaseline_toBaselineOf="@+id/edit_date" app:layout_constraintBaseline_toBaselineOf="@+id/edit_date"
app:layout_constraintEnd_toEndOf="@+id/text_battery_id" /> app:layout_constraintEnd_toEndOf="@+id/text_battery_id" />
@@ -83,7 +85,7 @@
android:id="@+id/text_charge" android:id="@+id/text_charge"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Charge" android:text="@string/charge"
app:layout_constraintBaseline_toBaselineOf="@+id/edit_charge" app:layout_constraintBaseline_toBaselineOf="@+id/edit_charge"
app:layout_constraintEnd_toEndOf="@+id/text_date" /> app:layout_constraintEnd_toEndOf="@+id/text_date" />
@@ -92,12 +94,12 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_marginEnd="32dp" android:layout_marginTop="32dp"
android:layout_marginBottom="32dp" android:layout_marginEnd="24dp"
android:contentDescription="@string/button_save_charge" android:contentDescription="@string/button_save_charge"
android:text="@string/button_save_charge" android:text="@string/button_save_charge"
app:icon="@drawable/ic_baseline_check_24" 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> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -18,4 +18,12 @@
<string name="menu_add_battery">Add Battery</string> <string name="menu_add_battery">Add Battery</string>
<string name="battery_id">Battery ID</string> <string name="battery_id">Battery ID</string>
<string name="button_save_charge">Save Charge</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> </resources>