From 027cdf6bcdb0a2ef9143134d86bfd6a394f3fe49 Mon Sep 17 00:00:00 2001 From: fadhilAmri <13521066@std.stei.itb.ac.id> Date: Tue, 2 Apr 2024 11:45:41 +0700 Subject: [PATCH] feat: Autofill Location Button in Transaction --- .../transaction/TransactionFragment.kt | 8 +++++-- app/src/main/res/layout/add_transaction.xml | 22 ++++++++++++++----- .../main/res/layout/modify_transaction.xml | 22 ++++++++++++++----- app/src/main/res/values/strings.xml | 1 + 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/example/nerbos/fragments/transaction/TransactionFragment.kt b/app/src/main/java/com/example/nerbos/fragments/transaction/TransactionFragment.kt index 97982af..0b92fd4 100644 --- a/app/src/main/java/com/example/nerbos/fragments/transaction/TransactionFragment.kt +++ b/app/src/main/java/com/example/nerbos/fragments/transaction/TransactionFragment.kt @@ -279,7 +279,7 @@ class TransactionFragment : Fragment() { dialog.dismiss() } - dialog.findViewById<EditText>(R.id.locationInput).setOnClickListener { + dialog.findViewById<ImageView>(R.id.autoFillLocationButton).setOnClickListener { // TODO: Buat percabangan kalau ada internet val etLocation= dialog.findViewById<EditText>(R.id.locationInput) etLocation.setText(getAddressName()) @@ -325,6 +325,11 @@ class TransactionFragment : Fragment() { etNominal.setText(transaction.nominal.toString()) transactionDate.text = Utils.formatDate(transaction.date.toString()) + dialog.findViewById<ImageView>(R.id.autoFillLocationButton).setOnClickListener { + // TODO: Buat percabangan kalau ada internet + etLocation.setText(getAddressName()) + } + dialog.findViewById<Button>(R.id.saveButton).setOnClickListener{ if(updateDataToDatabase(dialog, transaction.id)){ dialog.dismiss() @@ -382,7 +387,6 @@ class TransactionFragment : Fragment() { } private fun getDialogData(view:Dialog): Transaction? { - // TODO: Nanti diganti dengan input beneran, NIM diambil dari decode token JWT try{ // Button Group val radioGroup : RadioGroup = view.findViewById(R.id.categoryInput) diff --git a/app/src/main/res/layout/add_transaction.xml b/app/src/main/res/layout/add_transaction.xml index 8197008..f240675 100644 --- a/app/src/main/res/layout/add_transaction.xml +++ b/app/src/main/res/layout/add_transaction.xml @@ -127,11 +127,11 @@ <EditText android:id="@+id/locationInput" - android:layout_width="match_parent" + android:layout_width="270dp" android:layout_height="wrap_content" android:layout_marginStart="20dp" android:layout_marginTop="15dp" - android:layout_marginEnd="20dp" + android:layout_marginEnd="0dp" android:ems="10" android:hint="@string/location" android:padding="10sp" @@ -142,11 +142,23 @@ android:textSize="18sp" android:textColor="@color/white" android:textColorHint="@color/base_blur" - app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintEnd_toStartOf="@id/autoFillLocationButton" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/nominalInput" android:autofillHints="Location Input" /> + <ImageView + android:id="@+id/autoFillLocationButton" + android:layout_width="40dp" + android:layout_height="40dp" + android:background="@drawable/ic_location" + android:layout_marginTop="15dp" + android:layout_marginEnd="20dp" + app:layout_constraintTop_toBottomOf="@id/nominalInput" + app:layout_constraintStart_toEndOf="@id/locationInput" + app:layout_constraintEnd_toEndOf="parent" + android:contentDescription="@string/autofill_location_button"/> + <Button android:id="@+id/cancelButton" android:layout_width="wrap_content" @@ -154,7 +166,7 @@ android:text="@string/cancel" android:textSize="18sp" android:textColor="@color/white" - android:layout_marginTop="30dp" + android:layout_marginTop="40dp" android:layout_marginBottom="20dp" android:layout_marginStart="20dp" android:background="@drawable/round_corner_button_weak" @@ -166,7 +178,7 @@ android:id="@+id/addButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="30dp" + android:layout_marginTop="40dp" android:layout_marginBottom="20dp" android:layout_marginEnd="20dp" android:textColor="@color/white" diff --git a/app/src/main/res/layout/modify_transaction.xml b/app/src/main/res/layout/modify_transaction.xml index 677185f..b7ac881 100644 --- a/app/src/main/res/layout/modify_transaction.xml +++ b/app/src/main/res/layout/modify_transaction.xml @@ -127,11 +127,11 @@ <EditText android:id="@+id/locationInput" - android:layout_width="match_parent" + android:layout_width="270dp" android:layout_height="wrap_content" android:layout_marginStart="20dp" android:layout_marginTop="15dp" - android:layout_marginEnd="20dp" + android:layout_marginEnd="0dp" android:ems="10" android:hint="@string/location" android:padding="10sp" @@ -142,11 +142,23 @@ android:textSize="18sp" android:textColor="@color/white" android:textColorHint="@color/base_blur" - app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintEnd_toStartOf="@id/autoFillLocationButton" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/nominalInput" android:autofillHints="Location Input" /> + <ImageView + android:id="@+id/autoFillLocationButton" + android:layout_width="40dp" + android:layout_height="40dp" + android:background="@drawable/ic_location" + android:layout_marginTop="15dp" + android:layout_marginEnd="20dp" + app:layout_constraintTop_toBottomOf="@id/nominalInput" + app:layout_constraintStart_toEndOf="@id/locationInput" + app:layout_constraintEnd_toEndOf="parent" + android:contentDescription="@string/autofill_location_button"/> + <TextView android:id="@+id/transactionDateDialog" android:layout_width="match_parent" @@ -173,7 +185,7 @@ android:text="@string/delete" android:textColor="@color/white" android:textSize="18sp" - android:layout_marginTop="30dp" + android:layout_marginTop="40dp" android:layout_marginBottom="20dp" android:layout_marginStart="20dp" android:background="@drawable/round_corner_input_category_outcome" @@ -185,7 +197,7 @@ android:id="@+id/saveButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="30dp" + android:layout_marginTop="40dp" android:layout_marginBottom="20dp" android:layout_marginEnd="20dp" android:textSize="18sp" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6a6d9fa..dfc7cc4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -69,5 +69,6 @@ <string name="email_message">Here is your transaction report</string> <string name="logo">Logo</string> <string name="back_button">Back Button</string> + <string name="autofill_location_button">AutoFill Location Button</string> </resources> \ No newline at end of file -- GitLab