Skip to content

Commit

Permalink
Bump libraries and update to Kotlin 1.6
Browse files Browse the repository at this point in the history
- Set compileSdk to 31.
Any client app must also bump to latest SDK.

Koin has a known issue with Kotlin 1.6
but it is currently mitigated.

Fixes #92 #89

Signed-off-by: Rafael Chagas <[email protected]>
  • Loading branch information
rtchagas committed Jan 7, 2022
1 parent 091006f commit f693926
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 64 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.5.21'
ext.kotlin_version = '1.6.10'

repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0'
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.google.gms:google-services:4.3.10'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Expand Down
29 changes: 14 additions & 15 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'maven-publish'

android {

compileSdkVersion 30
compileSdkVersion 31

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -20,7 +20,7 @@ android {

defaultConfig {
minSdkVersion 19
targetSdkVersion 30
targetSdkVersion 31
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -41,44 +41,43 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

// KTX
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.core:core-ktx:1.7.0'

// Anko Commons
implementation "org.jetbrains.anko:anko-commons:0.10.8"

// Support library
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'com.google.android.material:material:1.5.0-alpha02'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'com.google.android.material:material:1.5.0-rc01'

// Android architecture components
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.3.1'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.4.0'

// Google Play Services
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
implementation 'com.google.android.gms:play-services-location:19.0.1'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
implementation 'com.google.maps.android:android-maps-utils:2.2.5'
implementation 'com.google.android.libraries.places:places:2.4.0'
implementation 'com.google.android.libraries.places:places:2.5.0'

// Koin for Android
implementation 'io.insert-koin:koin-android:2.2.3'
implementation 'io.insert-koin:koin-android-viewmodel:2.2.3'
implementation 'io.insert-koin:koin-android:3.1.5'

// Rx
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'com.jakewharton.rxbinding3:rxbinding:3.1.0'

// Moshi
implementation 'com.squareup.moshi:moshi:1.12.0'
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.12.0'
implementation 'com.squareup.moshi:moshi:1.13.0'
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.13.0'

// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'

// Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
Expand Down
21 changes: 11 additions & 10 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.rtchagas.pingplacepicker"
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rtchagas.pingplacepicker">

<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
android:required="true" />

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

<application>

<activity
android:name=".ui.PlacePickerActivity"
android:launchMode="singleTop"
android:theme="@style/PingTheme.NoStatus"/>
android:theme="@style/PingTheme.NoStatus" />

<uses-library
android:name="org.apache.http.legacy"
android:required="false"/>
android:required="false" />

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
android:value="@integer/google_play_services_version" />

</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.rtchagas.pingplacepicker.inject

import android.content.Context
import com.rtchagas.pingplacepicker.BuildConfig
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.Koin
import org.koin.core.component.KoinApiExtension
import org.koin.core.component.KoinComponent
import org.koin.core.logger.Level
import org.koin.dsl.koinApplication

object PingKoinContext {
Expand All @@ -14,7 +15,7 @@ object PingKoinContext {

val koin: Koin by lazy {
koinApplication {
androidLogger()
androidLogger(if (BuildConfig.DEBUG) Level.ERROR else Level.NONE)
androidContext(appContext)
modules(listOf(repositoryModule, viewModelModule))
}.koin
Expand All @@ -30,7 +31,6 @@ object PingKoinContext {
}
}

@OptIn(KoinApiExtension::class)
interface PingKoinComponent : KoinComponent {

override fun getKoin(): Koin = PingKoinContext.koin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.rtchagas.pingplacepicker.inject

import com.rtchagas.pingplacepicker.viewmodel.PlaceConfirmDialogViewModel
import com.rtchagas.pingplacepicker.viewmodel.PlacePickerViewModel
import org.koin.android.viewmodel.dsl.viewModel
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module

val viewModelModule = module {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class CustomPlace(
return null
}

override fun getIconBackgroundColor(): Int? {
return null
}

override fun getPriceLevel(): Int? {
return null
}
Expand All @@ -72,6 +76,10 @@ class CustomPlace(
return placeAddress
}

override fun getIconUrl(): String? {
return null
}

override fun getPlusCode(): PlusCode? {
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import kotlin.math.absoluteValue
/**
* Place without any additional info. Just latitude and longitude.
*/
internal class PlaceFromCoordinates(private val latitude: Double, private val longitude: Double) :
Place() {
internal class PlaceFromCoordinates(
private val latitude: Double,
private val longitude: Double
) : Place() {

constructor(parcel: Parcel) : this(
parcel.readDouble(),
parcel.readDouble()
Expand Down Expand Up @@ -59,6 +62,10 @@ internal class PlaceFromCoordinates(private val latitude: Double, private val lo
return null
}

override fun getIconBackgroundColor(): Int? {
return null
}

override fun getPriceLevel(): Int? {
return null
}
Expand All @@ -75,6 +82,10 @@ internal class PlaceFromCoordinates(private val latitude: Double, private val lo
return null
}

override fun getIconUrl(): String? {
return null
}

override fun getPlusCode(): PlusCode? {
return null
}
Expand Down Expand Up @@ -118,22 +129,26 @@ internal class PlaceFromCoordinates(private val latitude: Double, private val lo

private fun formatLatitude(latitude: Double): String {
val direction = if (latitude > 0) "N" else "S"
return "${replaceDelimiters(
Location.convert(
latitude.absoluteValue,
Location.FORMAT_SECONDS
return "${
replaceDelimiters(
Location.convert(
latitude.absoluteValue,
Location.FORMAT_SECONDS
)
)
)} $direction"
} $direction"
}

private fun formatLongitude(longitude: Double): String {
val direction = if (longitude > 0) "W" else "E"
return "${replaceDelimiters(
Location.convert(
longitude.absoluteValue,
Location.FORMAT_SECONDS
return "${
replaceDelimiters(
Location.convert(
longitude.absoluteValue,
Location.FORMAT_SECONDS
)
)
)} $direction"
} $direction"
}

private fun replaceDelimiters(original: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatDialogFragment
import androidx.core.view.isVisible
import androidx.lifecycle.Observer
import androidx.transition.TransitionManager
import com.google.android.libraries.places.api.model.Place
import com.rtchagas.pingplacepicker.Config
Expand All @@ -25,7 +24,7 @@ import com.rtchagas.pingplacepicker.viewmodel.Resource
import com.squareup.picasso.Callback
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.fragment_dialog_place_confirm.view.*
import org.koin.android.viewmodel.ext.android.viewModel
import org.koin.androidx.viewmodel.ext.android.viewModel
import java.util.*


Expand Down Expand Up @@ -72,7 +71,7 @@ class PlaceConfirmDialogFragment : AppCompatDialogFragment(), PingKoinComponent

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {

val builder = AlertDialog.Builder(activity!!)
val builder = AlertDialog.Builder(requireActivity())

builder.setTitle(R.string.picker_place_confirm)
.setView(getContentView(requireContext()))
Expand Down Expand Up @@ -138,7 +137,7 @@ class PlaceConfirmDialogFragment : AppCompatDialogFragment(), PingKoinComponent
) {
val photoMetadata = photoMetadatas[0]
viewModel.getPlacePhoto(photoMetadata).observe(this,
Observer { handlePlacePhotoLoaded(contentView, it) })
{ handlePlacePhotoLoaded(contentView, it) })
} else {
handlePlacePhotoLoaded(contentView, Resource.noData())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import com.rtchagas.pingplacepicker.viewmodel.Resource
import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.activity_place_picker.*
import org.jetbrains.anko.toast
import org.koin.android.viewmodel.ext.android.viewModel
import org.koin.androidx.viewmodel.ext.android.viewModel
import kotlin.math.abs

class PlacePickerActivity : AppCompatActivity(),
Expand Down Expand Up @@ -178,10 +178,11 @@ class PlacePickerActivity : AppCompatActivity(),
disposables.clear()
}

override fun onMapReady(map: GoogleMap?) {
@SuppressLint("PotentialBehaviorOverride")
override fun onMapReady(map: GoogleMap) {
googleMap = map
setMapStyle()
map?.setOnMarkerClickListener(this)
map.setOnMarkerClickListener(this)
checkForPermission()
}

Expand Down
14 changes: 7 additions & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'kotlin-android-extensions'

android {

compileSdkVersion 30
compileSdkVersion 31

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -14,7 +14,7 @@ android {
defaultConfig {
applicationId "com.rtchagas.pingsample"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 31
versionCode 1
versionName "1.0"

Expand All @@ -35,18 +35,18 @@ dependencies {
implementation project(':library')

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

// Anko Commons
implementation "org.jetbrains.anko:anko-commons:0.10.8"

// Support library
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'com.google.android.material:material:1.5.0-alpha02'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'com.google.android.material:material:1.5.0-rc01'

// Places library
implementation 'com.google.android.libraries.places:places:2.4.0'
implementation 'com.google.android.libraries.places:places:2.5.0'

// Other
implementation 'com.github.mcginty:material-colors:1.1.0'
Expand Down
Loading

0 comments on commit f693926

Please sign in to comment.