From 01ab36b3011fbeb8ed8b014eef27682d34f44529 Mon Sep 17 00:00:00 2001
From: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date: Mon, 1 Apr 2024 21:48:01 +0700
Subject: [PATCH] Squashed commit of the following:

commit 922c1801d45d8f12544e7ce4b029769fd539053f
Merge: 7e7808a 681fd98
Author: Nigel  Sahl <13521043@std.stei.itb.ac.id>
Date:   Mon Apr 1 13:53:23 2024 +0000

    Merge branch 'feature/gmail' into 'main'

    Feature/gmail

    See merge request NerbFox/if3210-2024-android-nos!13

commit 681fd98b8d4bf4efc1346ab44a1bda5f55db0df3
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Mon Apr 1 21:01:23 2024 +0700

    feat: intent gmail for send transaction

commit 7e7808a6a52f45fdfcc364ef0d5b11c0bd6c2013
Merge: 42a52dc 836f08e
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Mon Apr 1 10:16:33 2024 +0000

    Merge branch 'feature/save-transaction' into 'main'

    Feature/save transaction

    See merge request NerbFox/if3210-2024-android-nos!12

commit 836f08eb5752c6af82df0f3b0017192867fe8987
Merge: 6485434 42a52dc
Author: Muhammad Fadhil Amri <13521066@std.stei.itb.ac.id>
Date:   Mon Apr 1 10:13:51 2024 +0000

    Merge branch 'main' into 'feature/save-transaction'

    # Conflicts:
    #   app/src/main/res/values/strings.xml

commit 6485434bb71c5d1597871f44acb2ffe854dd5aa9
Author: fadhilAmri <13521066@std.stei.itb.ac.id>
Date:   Mon Apr 1 17:22:14 2024 +0700

    feat: Toast for download success

commit a56fbae0921ce1bf5dbb2e7e387ddaa63156d4d4
Author: fadhilAmri <13521066@std.stei.itb.ac.id>
Date:   Mon Apr 1 17:10:34 2024 +0700

    feat: create excel from list transactions and write it to internal storage

commit 42a52dcfb0d70b8e3ef61d532bcef3c3ede4e981
Merge: 7d6a913 13d8150
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Mon Apr 1 09:26:49 2024 +0000

    Merge branch 'feature/graph' into 'main'

    Feature/graph

    See merge request NerbFox/if3210-2024-android-nos!11

commit 13d81506df0eca80b2e05c3a907af09d1dbacdfe
Merge: 83e6e2b 7d6a913
Author: Nigel  Sahl <13521043@std.stei.itb.ac.id>
Date:   Mon Apr 1 08:42:03 2024 +0000

    Merge branch 'main' into 'feature/graph'

    # Conflicts:
    #   app/src/main/res/values/strings.xml

commit 83e6e2bf8bfe58fa7119c73016e2257a540284c9
Author: Nigel Sahl <93074692+NerbFox@users.noreply.github.com>
Date:   Mon Apr 1 15:50:08 2024 +0700

    update: use coroutine

commit 0e7d9460ad349b8ffa9dfdc7103613e211a5c485
Author: Nigel Sahl <93074692+NerbFox@users.noreply.github.com>
Date:   Mon Apr 1 15:49:56 2024 +0700

    update: add getSum function

commit 4947a3ada2df9668cade52654acb6769c342585c
Author: Nigel Sahl <93074692+NerbFox@users.noreply.github.com>
Date:   Mon Apr 1 14:27:50 2024 +0700

    update: res

commit 14d98284faa6fd31d6b0c9b05a0a3ef9aa7d72f0
Author: Nigel Sahl <93074692+NerbFox@users.noreply.github.com>
Date:   Mon Apr 1 14:27:36 2024 +0700

    update: rotating screen and graph

commit 7d6a91371c23c22bffc9b63a3b68c98f03b3686e
Merge: 07d4b55 8502ec8
Author: Muhammad Fadhil Amri <13521066@std.stei.itb.ac.id>
Date:   Mon Apr 1 05:43:58 2024 +0000

    Merge branch 'feature/scan' into 'main'

    Feature/scan

    See merge request NerbFox/if3210-2024-android-nos!10

commit 8502ec82d4e8ae856cf171150c66d9b33e7dec5b
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Mon Apr 1 12:51:05 2024 +0700

    feat: user input scan + map integration

commit e8c2c6e0655d82bc208ee4c78e344f9120a42a56
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Mon Apr 1 10:53:58 2024 +0700

    feat: insert transaction from scan

commit d3a260f0a8a80559169980fa65881c7e08513d49
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Sun Mar 31 23:13:09 2024 +0700

    feat: received scan response from server

commit 3c3d6e4dd39b525ec7cb9d0cf173ad0a1b5328b0
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Sun Mar 31 21:35:04 2024 +0700

    feat: gradle build caching

commit 28a2b448d33889b7f1bf26e34ab3f1ea2e5eebe7
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Sat Mar 30 16:46:20 2024 +0700

    feat: take & choose picture

commit 7ab56e5cb1ccdb8bad3d8b3daf072bf16200ad54
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Sat Mar 30 15:12:04 2024 +0700

    style: updated scan style

commit c3bb908a7f3da90985fcb863145e682c73210264
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Sat Mar 30 14:15:13 2024 +0700

    fix: camera permission

commit f4e95d708bc417ec08ced52ea5dd14a7035cfde3
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Sat Mar 30 13:50:30 2024 +0700

    feat: access camera preview

commit 07d4b55033511b13b6564d24a5ed3b982706fa18
Merge: 56ed163 440b3e6
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Mon Apr 1 03:57:10 2024 +0000

    Merge branch 'feature/location' into 'main'

    Feature/location

    See merge request NerbFox/if3210-2024-android-nos!9

commit 440b3e618846e7aad15b150284af1230cb8f2d9a
Merge: 1ca3577 56ed163
Author: Muhammad Fadhil Amri <13521066@std.stei.itb.ac.id>
Date:   Mon Apr 1 03:56:12 2024 +0000

    Merge branch 'main' into 'feature/location'

    # Conflicts:
    #   app/src/main/AndroidManifest.xml
    #   app/src/main/res/values/strings.xml

commit 1ca3577c0fe415dd4e83a2bb31298ed5506e64ec
Author: fadhilAmri <13521066@std.stei.itb.ac.id>
Date:   Mon Apr 1 11:02:33 2024 +0700

    fix: Back Button Navigation from Maps Activity to Main Activity

commit 341bc15557d461ad3189c286428d73c661ffeaf8
Author: fadhilAmri <13521066@std.stei.itb.ac.id>
Date:   Mon Apr 1 10:45:09 2024 +0700

    feat: show location in Google Maps

commit 454ea8debb0c3a7dd4dc366c9edd3ed2422cf345
Author: Nigel Sahl <93074692+NerbFox@users.noreply.github.com>
Date:   Mon Apr 1 10:41:02 2024 +0700

    update: graph display

commit 5b874e6a650e416a06168c67254a47f04ce1ed33
Author: fadhilAmri <13521066@std.stei.itb.ac.id>
Date:   Mon Apr 1 09:24:17 2024 +0700

    feat: intent to MapsActivity

commit 1584c00da104005b7ebb8f9b3650ff6b3cffdfb2
Author: fadhilAmri <13521066@std.stei.itb.ac.id>
Date:   Mon Apr 1 09:10:16 2024 +0700

    feat: location sensor

commit 2568756013761483160d2d1dbe2ab03935408dca
Author: Nigel Sahl <93074692+NerbFox@users.noreply.github.com>
Date:   Sun Mar 31 23:24:08 2024 +0700

    update: statistics fragment

commit 56ed163f75f77c54f8f516d58ce79e4c399132e0
Merge: ac9e0f1 2568756
Author: Ghazi Akmal Fauzan <13521058@std.stei.itb.ac.id>
Date:   Sun Mar 31 16:15:14 2024 +0000

    Merge branch 'feature/graph' into 'main'

    update: statistics fragment

    See merge request NerbFox/if3210-2024-android-nos!8
---
 app/build.gradle.kts                          |  2 +-
 .../transaction/TransactionFragment.kt        | 31 +++++++++++++++++++
 .../example/nerbos/service/Authentication.kt  |  1 -
 app/src/main/res/layout/activity_maps.xml     |  1 +
 app/src/main/res/values/strings.xml           |  1 -
 5 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 6c05b57..a165ea8 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -108,4 +108,4 @@ dependencies {
 
     //DataBinding
     kapt ("com.android.databinding:compiler:3.2.0-alpha10")
-}
+}
\ No newline at end of file
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 0b92fd4..d5eb6b3 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
@@ -450,6 +450,37 @@ class TransactionFragment : Fragment() {
         }
     }
 
+    private fun setLocation(){
+        if (ActivityCompat.checkSelfPermission(
+                requireContext(),
+                Manifest.permission.ACCESS_FINE_LOCATION
+            ) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
+                requireContext(),
+                Manifest.permission.ACCESS_COARSE_LOCATION
+            ) != PackageManager.PERMISSION_GRANTED
+        ) {
+            ActivityCompat.requestPermissions(requireActivity(), arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), permissionCode)
+            return
+        }
+        fusedLocationProviderClient.lastLocation.addOnSuccessListener (requireActivity()){
+                location ->
+            currentLocation = location
+        }
+    }
+
+    @Suppress("DEPRECATION")
+    private fun getAddressName() : String{
+        // Hanya set otomatis jika mendapatkan permission, jika tidak input lokasi string
+        setLocation()
+        return if (currentLocation!=null){
+            // Geocode to get the address string
+            val address = geocoder.getFromLocation(currentLocation!!.latitude, currentLocation!!.longitude, 1)
+            address!![0].getAddressLine(0)
+        } else {
+            ""
+        }
+    }
+
     private fun inputCheck(name: String,  nominal:Float, location:String): Boolean {
         return !(TextUtils.isEmpty(name) || TextUtils.isEmpty(location) || (nominal<=0) )
     }
diff --git a/app/src/main/java/com/example/nerbos/service/Authentication.kt b/app/src/main/java/com/example/nerbos/service/Authentication.kt
index 2e691dd..6d99233 100644
--- a/app/src/main/java/com/example/nerbos/service/Authentication.kt
+++ b/app/src/main/java/com/example/nerbos/service/Authentication.kt
@@ -150,7 +150,6 @@ class Authentication(private val context: Context) {
         return String(decryptedToken, Charsets.UTF_8)
     }
 
-
     fun checkToken(callback: AuthCallback) {
         // check network availability
         if (!isNetworkAvailable()) {
diff --git a/app/src/main/res/layout/activity_maps.xml b/app/src/main/res/layout/activity_maps.xml
index 0b74760..ccb06b5 100644
--- a/app/src/main/res/layout/activity_maps.xml
+++ b/app/src/main/res/layout/activity_maps.xml
@@ -17,6 +17,7 @@
         android:layout_height="match_parent"
         map:layout_constraintTop_toTopOf="parent"
     />
+    
     <TextView
         android:id="@+id/title"
         android:layout_width="match_parent"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index dfc7cc4..cc66f87 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -21,7 +21,6 @@
     <string name="android_key_store">AndroidKeyStore</string>
     <string name="authorization">Authorization</string>
     <string name="bearer">Bearer</string>
-
     <string name="no_internet">No Internet Connection</string>
     <string name="server_error">Server Error</string>
     <string name="preferences">NosPreferences</string>
-- 
GitLab