From 227e0224a17c4bf668d3aee7bd90182c810849c4 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Tue, 22 Jan 2019 15:31:24 -0600 Subject: [PATCH] Add location permission request in the Merchants and Tellers screen, and if accepted show the icon on the map so that it can be moved to the current user's location if it is available already. Also, show the zoom UI controls on the map. --- .../fragments/MerchantsFragment.kt | 40 +++++++++++++++++++ .../main/res/layout/fragment_merchants.xml | 18 +++++---- app/src/main/res/values-es/strings.xml | 3 ++ app/src/main/res/values/strings.xml | 3 ++ 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt index 8bfd58f..89e8005 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt @@ -1,5 +1,8 @@ package cy.agorise.bitsybitshareswallet.fragments +import android.Manifest +import android.annotation.SuppressLint +import android.content.pm.PackageManager import android.os.Bundle import android.util.Log import androidx.fragment.app.Fragment @@ -25,13 +28,22 @@ import java.io.IOException import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.drawable.Drawable +import androidx.core.content.ContextCompat import com.google.android.gms.maps.model.BitmapDescriptor import cy.agorise.bitsybitshareswallet.database.entities.Merchant import cy.agorise.bitsybitshareswallet.utils.Constants +import cy.agorise.bitsybitshareswallet.utils.toast class MerchantsFragment : Fragment(), OnMapReadyCallback, retrofit2.Callback> { + companion object { + private const val TAG = "MerchantsFragment" + + // Camera Permission + private const val REQUEST_LOCATION_PERMISSION = 1 + } + private lateinit var mMap: GoogleMap private var merchants: List? = null @@ -55,6 +67,32 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, retrofit2.Callback, grantResults: IntArray) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + + if (requestCode == REQUEST_LOCATION_PERMISSION) { + if ((grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)) { + mMap.isMyLocationEnabled = true + } else { + context?.toast(getString(R.string.msg__location_permission_necessary)) + } + return + } + } + /** * Manipulates the map once available. * This callback is triggered when the map is ready to be used. @@ -67,6 +105,8 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, retrofit2.Callback - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index f1242d8..6f88f45 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -58,6 +58,9 @@ Ignorar cuotas de red Filtrar + + El permiso de localizaciĆ³n es necesario para mostrar tu ubicaciĆ³n actual en el mapa. + Info A diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 187dfc9..d343952 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,6 +58,9 @@ Ignore Network fees Filter + + Location permission is necessary to show your current location on the map. + Info To