diff --git a/build.gradle b/build.gradle index 831659a..2ea1658 100644 --- a/build.gradle +++ b/build.gradle @@ -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 } @@ -20,8 +19,7 @@ buildscript { allprojects { repositories { google() - jcenter() - + mavenCentral() } } diff --git a/placepicker/build.gradle b/placepicker/build.gradle index b29c9cf..557e0e8 100644 --- a/placepicker/build.gradle +++ b/placepicker/build.gradle @@ -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" @@ -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' } diff --git a/placepicker/src/main/java/com/sucho/placepicker/IntentExtensions.kt b/placepicker/src/main/java/com/sucho/placepicker/IntentExtensions.kt new file mode 100644 index 0000000..957e3cf --- /dev/null +++ b/placepicker/src/main/java/com/sucho/placepicker/IntentExtensions.kt @@ -0,0 +1,16 @@ +package com.sucho.placepicker + +import android.content.Intent +import android.os.Build +import java.io.Serializable + +inline fun 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? + } diff --git a/placepicker/src/main/java/com/sucho/placepicker/PlacePickerActivity.kt b/placepicker/src/main/java/com/sucho/placepicker/PlacePickerActivity.kt index db9d581..b934373 100644 --- a/placepicker/src/main/java/com/sucho/placepicker/PlacePickerActivity.kt +++ b/placepicker/src/main/java/com/sucho/placepicker/PlacePickerActivity.kt @@ -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, @@ -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) @@ -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 } } @@ -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() { diff --git a/placepicker/src/main/res/values/strings.xml b/placepicker/src/main/res/values/strings.xml index 2a7833e..e8ff5b1 100644 --- a/placepicker/src/main/res/values/strings.xml +++ b/placepicker/src/main/res/values/strings.xml @@ -1,6 +1,7 @@ PlacePicker Map + %1$s, %2$s Not a valid Address