Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.31'
ext.kotlin_version = '1.7.20'
repositories {
google()
jcenter()

mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.android.tools.build:gradle:3.4.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -20,8 +19,7 @@ buildscript {
allprojects {
repositories {
google()
jcenter()

mavenCentral()
}
}

Expand Down
16 changes: 8 additions & 8 deletions placepicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.github.dcendents.android-maven'

android {
compileSdkVersion 31
compileSdkVersion 33

defaultConfig {
minSdkVersion 14
targetSdkVersion 31
targetSdkVersion 33
versionCode 1
versionName "1.1.2"

Expand All @@ -33,10 +33,10 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha09'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.google.android.libraries.places:places:2.2.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.libraries.places:places:2.7.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.sucho.placepicker

import android.content.Intent
import android.os.Build
import java.io.Serializable

inline fun <reified T:Serializable> Intent.getSerializableExtraCompat(key:String):T? =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
{
getSerializableExtra(key,T::class.java)
}
else
{
@Suppress("DEPRECATION")
getSerializableExtra(key) as T?
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class PlacePickerActivity : AppCompatActivity(), OnMapReadyCallback {
as AutocompleteSupportFragment

placeAutocomplete.setPlaceFields(
Arrays.asList(
listOf(
Place.Field.ID,
Place.Field.NAME,
Place.Field.LAT_LNG,
Expand Down Expand Up @@ -195,7 +195,7 @@ class PlacePickerActivity : AppCompatActivity(), OnMapReadyCallback {
secondaryTextColorRes = intent.getIntExtra(Constants.SECONDARY_TEXT_COLOR_RES_INTENT, -1)
bottomViewColorRes = intent.getIntExtra(Constants.BOTTOM_VIEW_COLOR_RES_INTENT, -1)
mapRawResourceStyleRes = intent.getIntExtra(Constants.MAP_RAW_STYLE_RES_INTENT, -1)
mapType = intent.getSerializableExtra(Constants.MAP_TYPE_INTENT) as MapType
mapType = intent.getSerializableExtraCompat(Constants.MAP_TYPE_INTENT) ?: mapType
onlyCoordinates = intent.getBooleanExtra(Constants.ONLY_COORDINATES_INTENT, false)
googleApiKey = intent.getStringExtra(Constants.GOOGLE_API_KEY)
searchBarEnable = intent.getBooleanExtra(Constants.SEARCH_BAR_ENABLE, false)
Expand Down Expand Up @@ -268,7 +268,6 @@ class PlacePickerActivity : AppCompatActivity(), OnMapReadyCallback {
MapType.HYBRID -> GoogleMap.MAP_TYPE_HYBRID
MapType.TERRAIN -> GoogleMap.MAP_TYPE_TERRAIN
MapType.NONE -> GoogleMap.MAP_TYPE_NONE
else -> GoogleMap.MAP_TYPE_NORMAL
}
}

Expand All @@ -294,9 +293,13 @@ class PlacePickerActivity : AppCompatActivity(), OnMapReadyCallback {
}
placeProgressBar.visibility = View.INVISIBLE

placeNameTextView.text = if (shortAddress.isEmpty()) "Dropped Pin" else shortAddress
placeNameTextView.text = shortAddress.ifEmpty { "Dropped Pin" }
placeAddressTextView.text = fullAddress
placeCoordinatesTextView.text = Location.convert(latitude, Location.FORMAT_DEGREES) + ", " + Location.convert(longitude, Location.FORMAT_DEGREES)
placeCoordinatesTextView.text = getString(
R.string.lat_lng_coordinates,
Location.convert(latitude, Location.FORMAT_DEGREES),
Location.convert(longitude, Location.FORMAT_DEGREES)
)
}

private fun getAddressForLocation() {
Expand Down
1 change: 1 addition & 0 deletions placepicker/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<resources>
<string name="app_name">PlacePicker</string>
<string name="title_activity_place_picker">Map</string>
<string name="lat_lng_coordinates">%1$s, %2$s</string>

<string name="no_address">Not a valid Address</string>
</resources>