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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Developers often come across a requirement of adding precise location. So, a pla
![image](/media/vanillaplacepicker-autocomplete.gif) ![image](/media/vanillaplacepicker-map.gif)

## Key features
* Android 12 support
* Android 13 support
* Simple implementation for place picker either using Autocomplete, Map or both
* Set your own custom map styles
* Customise map pin icon
Expand Down
12 changes: 8 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
}

android {
compileSdk 32
namespace 'com.mindinventory.placepicker'
compileSdk 34
defaultConfig {
applicationId "com.mindinventory.placepicker"
minSdk 21
targetSdk 32
targetSdk 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -32,11 +32,15 @@ android {
buildFeatures {
viewBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:1.5.0"
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "androidx.cardview:cardview:1.0.0"

testImplementation 'junit:junit:4.13.2'
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mindinventory.placepicker">

<!--permissions which we need to use through out app.-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- permissions which we need to use through out app. -->
<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" />
Expand All @@ -29,6 +27,9 @@
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${googleMapsApiKey}" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>

</manifest>
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
agp_version = '8.2.0'
kotlin_version = '1.8.10'
}

repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
classpath "com.google.gms:google-services:4.3.13"
classpath "com.android.tools.build:gradle:$agp_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.gms:google-services:4.4.1"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -26,6 +30,6 @@ allprojects {
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
android.defaults.buildfeatures.buildconfig=true
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Mar 01 18:23:58 IST 2022
#Fri Mar 01 12:21:32 IST 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 16 additions & 19 deletions vanillaplacepicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ plugins {
group='com.github.Mindinventory'

android {
compileSdk 32
namespace 'com.vanillaplacepicker'
compileSdk 34

defaultConfig {
minSdk 21
targetSdk 32
versionCode 15
versionName "0.3.0"
targetSdk 34
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand All @@ -26,12 +25,8 @@ android {
}

compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

kotlinOptions {
jvmTarget = "1.8"
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

testOptions {
Expand All @@ -45,26 +40,28 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.recyclerview:recyclerview:1.3.2"
implementation 'androidx.test:monitor:1.6.1'
testImplementation 'junit:junit:4.13.2'

// Location
api 'com.google.android.gms:play-services-location:20.0.0'
api 'com.google.android.gms:play-services-maps:18.1.0'
api 'com.google.android.gms:play-services-location:21.1.0'
api 'com.google.android.gms:play-services-maps:18.2.0'

// Google material
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.material:material:1.11.0'

implementation "com.google.android.libraries.places:places:2.6.0"
implementation "com.google.android.libraries.places:places:3.3.0"

//unittest
testImplementation 'org.mockito:mockito-core:3.5.13'
testImplementation 'org.mockito:mockito-core:5.10.0'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
testImplementation 'org.mockito:mockito-inline:3.5.13'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'android.arch.core:core-testing:1.1.1'
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.3.2'
androidTestImplementation 'junit:junit:4.13.2'
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
package com.vanillaplacepicker;

import static org.junit.Assert.assertEquals;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import androidx.test.platform.app.InstrumentationRegistry;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;
import org.junit.runners.JUnit4;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
@RunWith(JUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();

assertEquals("com.miplacepicker.test", appContext.getPackageName());
}
Expand Down
9 changes: 4 additions & 5 deletions vanillaplacepicker/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vanillaplacepicker">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Expand All @@ -8,11 +7,11 @@
<application android:supportsRtl="true">

<activity
android:name="com.vanillaplacepicker.presentation.map.VanillaMapActivity"
android:theme="@style/AppTheme"/>
android:name="com.vanillaplacepicker.presentation.map.VanillaMapActivity"
android:theme="@style/AppTheme" />

<service
android:name="com.vanillaplacepicker.service.FetchAddressIntentService"
android:name=".service.FetchAddressIntentService"
android:exported="false" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.vanillaplacepicker.domain.common
import androidx.lifecycle.Observer

class SafeObserver<T>(private val notifier: (T) -> Unit) : Observer<T> {
override fun onChanged(t: T?) {
t?.let { notifier(t) }
override fun onChanged(value: T) {
value?.let { notifier(it) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.vanillaplacepicker.presentation.builder

import android.os.Parcelable
import com.google.android.gms.maps.model.LatLng
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
data class SearchZoneRect(val lowerLeft: LatLng, val upperRight: LatLng) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.vanillaplacepicker.presentation.builder
import android.content.Context
import android.content.ContextWrapper
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.util.Log
import com.google.android.gms.maps.model.LatLng
Expand All @@ -11,7 +12,12 @@ import com.vanillaplacepicker.data.VanillaAddress
import com.vanillaplacepicker.data.common.AutoCompleteAddressDetailsMapper
import com.vanillaplacepicker.extenstion.isRequiredField
import com.vanillaplacepicker.presentation.map.VanillaMapActivity
import com.vanillaplacepicker.utils.*
import com.vanillaplacepicker.utils.AutoCompleteUtils
import com.vanillaplacepicker.utils.BundleUtils
import com.vanillaplacepicker.utils.KeyUtils
import com.vanillaplacepicker.utils.MapType
import com.vanillaplacepicker.utils.PickerLanguage
import com.vanillaplacepicker.utils.PickerType
import wrap


Expand All @@ -22,7 +28,15 @@ class VanillaPlacePicker {

fun getPlaceResult(data: Intent?): VanillaAddress? {
if (data != null) {
val selectedPlace = data.getSerializableExtra(KeyUtils.SELECTED_PLACE)
val selectedPlace =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
data.getSerializableExtra(
KeyUtils.SELECTED_PLACE,
VanillaAddress::class.java
)
} else {
data.getSerializableExtra(KeyUtils.SELECTED_PLACE)
}
return if (selectedPlace is VanillaAddress) {
selectedPlace
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.vanillaplacepicker.presentation.common

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import androidx.annotation.CallSuper
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModel
import androidx.viewbinding.ViewBinding

abstract class VanillaBaseViewModelActivity<VB : ViewBinding, T : ViewModel> : AppCompatActivity() {
abstract class VanillaBaseViewModelActivity<VB : ViewBinding, T : ViewModel> : AppCompatActivity(){

private var _binding: VB? = null
protected val binding get() = _binding!!
Expand Down Expand Up @@ -40,4 +41,6 @@ abstract class VanillaBaseViewModelActivity<VB : ViewBinding, T : ViewModel> : A
super.onDestroy()
_binding = null
}


}
Loading