Skip to content

Commit

Permalink
SCMI-112253 Only add the default location if permission not granted
Browse files Browse the repository at this point in the history
  • Loading branch information
arturo.jimenez committed Jan 10, 2024
1 parent 4020a2c commit a5509b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/adevinta/mappicker/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class MainActivity : AppCompatActivity() {
private fun onLaunchMapPickerClicked(context: Context) {
val activity = context as MainActivity
val locationPickerIntent = LocationPickerActivity.Builder(activity)
.withLocation(DEMO_LATITUDE, DEMO_LONGITUDE)
// .withGeolocApiKey("<PUT API KEY HERE>")
// .withGooglePlacesApiKey("<PUT API KEY HERE>")
.withSearchZone("es_ES")
Expand Down
15 changes: 10 additions & 5 deletions leku/src/main/java/com/adevinta/leku/LocationPickerActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.adevinta.leku

import android.Manifest
import android.annotation.SuppressLint
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.content.IntentSender
import android.content.pm.PackageManager
import android.content.res.Resources
import android.graphics.PorterDuff
import android.location.Address
Expand Down Expand Up @@ -39,6 +41,7 @@ import androidx.activity.result.ActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RawRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
Expand Down Expand Up @@ -1213,11 +1216,13 @@ class LocationPickerActivity :
}

private fun setDefaultLocation() {
currentLocation = Location(getString(R.string.leku_network_resource))
currentLocation?.latitude = 0.0
currentLocation?.longitude = 0.0
setCurrentPositionLocation()
isLocationInformedFromBundle = true
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
currentLocation = Location(getString(R.string.leku_network_resource))
currentLocation?.latitude = 0.0
currentLocation?.longitude = 0.0
setCurrentPositionLocation()
isLocationInformedFromBundle = true
}
}

private fun startVoiceRecognitionActivity() {
Expand Down

0 comments on commit a5509b3

Please sign in to comment.