Skip to content
Snippets Groups Projects
Commit 317de0c8 authored by DewanaGustavus's avatar DewanaGustavus
Browse files

feat: scanner result redirect

parent 35e30677
Branches
Tags
3 merge requests!13Release,!11proper save for gmail,!9Scan nota
package com.example.bondoyap.ui.scanner
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.example.bondoyap.databinding.FragmentScanResultBinding
class ScanResultFragment : Fragment() {
// This property is only valid between onCreateView and
// onDestroyView.
private var _binding: FragmentScanResultBinding? = null
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentScanResultBinding.inflate(inflater, container, false)
val root: View = binding.root
return root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
\ No newline at end of file
......@@ -20,6 +20,9 @@ import androidx.camera.core.Preview
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.fragment.findNavController
import com.example.bondoyap.R
import com.example.bondoyap.databinding.FragmentScannerBinding
import com.example.bondoyap.service.api.ApiClient
import com.example.bondoyap.service.api.data.BillResponse
......@@ -38,6 +41,7 @@ class ScannerFragment : Fragment() {
// onDestroyView.
private var _binding: FragmentScannerBinding? = null
private val binding get() = _binding!!
private lateinit var navController: NavController
// Camera
private var isBackCamera = true
......@@ -64,6 +68,7 @@ class ScannerFragment : Fragment() {
_binding = FragmentScannerBinding.inflate(inflater, container, false)
val root: View = binding.root
navController = findNavController()
cacheDir = requireContext().cacheDir
contentResolver = requireContext().contentResolver
apiClient = ApiClient()
......@@ -221,6 +226,7 @@ class ScannerFragment : Fragment() {
if (response.isSuccessful) {
val billResponse = response.body()
Log.d("Bill Upload", "Server Response: $billResponse")
navController.navigate(R.id.action_to_scanResultFragment)
} else {
Log.e("Bill Upload", "Error: ${response.code()}")
}
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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.scanner.ScanResultFragment">
</RelativeLayout>
\ No newline at end of file
......@@ -18,26 +18,25 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/switch_camera_button"
app:layout_constraintTop_toBottomOf="@id/preview_view"
app:layout_constraintStart_toStartOf="parent"
/>
app:layout_constraintTop_toBottomOf="@id/preview_view" />
<Button
android:id="@+id/capture_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/capture_button"
app:layout_constraintTop_toBottomOf="@id/preview_view"
app:layout_constraintStart_toEndOf="@+id/switch_camera_button"
/>
app:layout_constraintTop_toBottomOf="@id/preview_view" />
<Button
android:id="@+id/gallery_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/gallery_button"
app:layout_constraintTop_toBottomOf="@id/preview_view"
app:layout_constraintStart_toEndOf="@+id/capture_button"
app:layout_constraintEnd_toEndOf="parent"
/>
app:layout_constraintStart_toEndOf="@+id/capture_button"
app:layout_constraintTop_toBottomOf="@id/preview_view" />
<Button
......@@ -45,7 +44,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/upload_button"
app:layout_constraintTop_toBottomOf="@id/capture_button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent" />
app:layout_constraintTop_toBottomOf="@id/capture_button" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -5,11 +5,11 @@
android:id="@+id/mobile_navigation"
app:startDestination="@+id/navigation_transactions">
<!-- <fragment-->
<!-- android:id="@+id/navigation_login"-->
<!-- android:name="com.example.bondoyap.ui.login.LoginActivity"-->
<!-- android:label="@string/title_login"-->
<!-- tools:layout="@layout/fragment_transactions" />-->
<!-- <fragment-->
<!-- android:id="@+id/navigation_login"-->
<!-- android:name="com.example.bondoyap.ui.login.LoginActivity"-->
<!-- android:label="@string/title_login"-->
<!-- tools:layout="@layout/fragment_transactions" />-->
<fragment
android:id="@+id/navigation_transactions"
......@@ -21,7 +21,19 @@
android:id="@+id/navigation_scanner"
android:name="com.example.bondoyap.ui.scanner.ScannerFragment"
android:label="@string/title_scanner"
tools:layout="@layout/fragment_scanner" />
tools:layout="@layout/fragment_scanner">
<action
android:id="@+id/action_to_scanResultFragment"
app:destination="@id/navigation_scan_result" />
</fragment>
<fragment
android:id="@+id/navigation_scan_result"
android:name="com.example.bondoyap.ui.scanner.ScanResultFragment"
android:label="@string/title_scan_result"
tools:layout="@layout/fragment_scan_result" />
<fragment
android:id="@+id/navigation_graph"
......
......@@ -4,6 +4,7 @@
<string name="title_scanner">Scanner</string>
<string name="title_graph">Graph</string>
<string name="title_settings">Pengaturan</string>
<string name="title_scan_result">Scan Result</string>
<string name="title_login">Login</string>
<string name="prompt_email">Email</string>
......@@ -25,4 +26,7 @@
<string name="switch_camera_button">switch camera</string>
<string name="gallery_button">gallery</string>
<string name="upload_button">upload</string>
<string name="cancel_button">cancel</string>
<string name="save_button">save</string>
</resources>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment