diff --git a/app/src/main/java/pbd/tubes/exe_android/ui/scan/ScanFragment.kt b/app/src/main/java/pbd/tubes/exe_android/ui/scan/ScanFragment.kt index 03dd14c0918f94d76b7a7a397c422dc2380b986e..fcc79a1869da0bfd543d4f7c1a230a607d86063b 100644 --- a/app/src/main/java/pbd/tubes/exe_android/ui/scan/ScanFragment.kt +++ b/app/src/main/java/pbd/tubes/exe_android/ui/scan/ScanFragment.kt @@ -10,6 +10,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Toast +import androidx.activity.result.PickVisualMediaRequest import androidx.activity.result.contract.ActivityResultContracts import androidx.camera.core.CameraSelector import androidx.camera.core.ImageAnalysis @@ -69,6 +70,21 @@ class ScanFragment : Fragment() { return root } + // this function is triggered when + // the Select Image Button is clicked + fun imageChooser() { + registerForActivityResult( + ActivityResultContracts.PickVisualMedia() + ) { + if (it != null){ + Log.d("MyApp", "Picked picture, selected URI: $it") + } else { + Log.d("MyApp", "No picture picked") + } + } + .launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) + } + private fun takePhoto() { // Get a stable reference of the modifiable image capture use case val imageCapture = imageCapture ?: return diff --git a/app/src/main/res/drawable/ic_image_24.xml b/app/src/main/res/drawable/ic_image_24.xml new file mode 100644 index 0000000000000000000000000000000000000000..fd890cefb4f1544083da72c67c5b5989ace76aa0 --- /dev/null +++ b/app/src/main/res/drawable/ic_image_24.xml @@ -0,0 +1,5 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> + + <path android:fillColor="@android:color/white" android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/> + +</vector> diff --git a/app/src/main/res/layout/fragment_scan.xml b/app/src/main/res/layout/fragment_scan.xml index 522bc03866cdabb8d899d15bdafb17f687ad8fd8..e447eec72ee68eae145c4e61a7de0ec061c7d304 100644 --- a/app/src/main/res/layout/fragment_scan.xml +++ b/app/src/main/res/layout/fragment_scan.xml @@ -9,7 +9,9 @@ <androidx.camera.view.PreviewView android:id="@+id/viewFinder" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" > + + </androidx.camera.view.PreviewView> <ImageButton android:id="@+id/image_capture_button" @@ -22,6 +24,21 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintStart_toStartOf="parent" /> + app:layout_constraintStart_toStartOf="parent" + android:contentDescription="@string/take_picture" /> + + <ImageButton + android:id="@+id/pick_image_button" + android:layout_width="60dp" + android:layout_height="60dp" + android:layout_marginEnd="32dp" + android:minWidth="50dp" + android:minHeight="50dp" + android:src="@drawable/ic_image_24" + app:layout_constraintBottom_toBottomOf="@+id/image_capture_button" + app:layout_constraintEnd_toStartOf="@+id/image_capture_button" + app:layout_constraintTop_toTopOf="@+id/image_capture_button" + android:contentDescription="@string/pick_picture" + /> </androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 34018af39bc751f58d7f1cc1509036ef595a1acc..0fb2613f2202f36b156fb47cbf4df4f4e3c4d2ac 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,13 +7,12 @@ <string name="title_scan">Scan</string> <string name="title_chart">Graf</string> <string name="title_settings">Pengaturan</string> - <string name="transaction_operations_fab_text">Transaction Operations</string> - <string name="add_fab_text">Add</string> - <string name="edit_fab_text">Edit</string> - <string name="delete_fab_text">Delete</string> + <string name="transaction_operations_fab_text">Add Transaction</string> <string name="transaction_name_text">Nama Transaksi</string> <string name="transaction_nominal_text">Nominal</string> <string name="transaction_category">Kategori</string> <string name="transaction_location">Lokasi</string> <string name="take_photo">ambil foto</string> + <string name="take_picture">Take Picture</string> + <string name="pick_picture">Pick picture</string> </resources> \ No newline at end of file