├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── akhgupta │ │ │ └── easylocation │ │ │ └── demo │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── akhgupta │ │ │ └── easylocation │ │ │ └── demo │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── akhgupta │ │ └── easylocation │ │ └── demo │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── android-easylocation ├── .gitignore ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── akhgupta │ │ │ │ └── easylocation │ │ │ │ ├── IntentKey.java │ │ │ │ ├── EasyLocationListener.java │ │ │ │ ├── AppConstants.java │ │ │ │ ├── EasyLocation.java │ │ │ │ ├── LocationBroadcastReceiver.java │ │ │ │ ├── PreferenceUtil.java │ │ │ │ ├── EasyLocationActivity.java │ │ │ │ ├── EasyLocationRequest.java │ │ │ │ ├── EasyLocationAppCompatActivity.java │ │ │ │ ├── EasyLocationRequestBuilder.java │ │ │ │ ├── LocationBgService.java │ │ │ │ └── EasyLocationDelegate.java │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── akhgupta │ │ │ └── easylocation │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── akhgupta │ │ └── easylocation │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /android-easylocation/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':android-easylocation' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akhgupta/Android-EasyLocation/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akhgupta/Android-EasyLocation/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akhgupta/Android-EasyLocation/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akhgupta/Android-EasyLocation/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akhgupta/Android-EasyLocation/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akhgupta/Android-EasyLocation/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | EasyLocation-Demo 3 | Request Single Location fix 4 | Request Continuous Location updates 5 | Stop Location updates 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /android-easylocation/src/main/java/com/akhgupta/easylocation/IntentKey.java: -------------------------------------------------------------------------------- 1 | package com.akhgupta.easylocation; 2 | 3 | class IntentKey { 4 | public static final String LOCATION_REQUEST = "location_request"; 5 | public static final String LOCATION_FETCH_MODE = "location_fetch_mode"; 6 | public static final String LOCATION = "location"; 7 | public static final String FALLBACK_TO_LAST_LOCATION_TIME = "fallback_to_last_location_time"; 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /android-easylocation/src/main/java/com/akhgupta/easylocation/EasyLocationListener.java: -------------------------------------------------------------------------------- 1 | package com.akhgupta.easylocation; 2 | 3 | import android.location.Location; 4 | 5 | interface EasyLocationListener { 6 | void onLocationPermissionGranted(); 7 | void onLocationPermissionDenied(); 8 | void onLocationReceived(Location location); 9 | void noLocationReceived(); 10 | void onLocationProviderEnabled(); 11 | void onLocationProviderDisabled(); 12 | } -------------------------------------------------------------------------------- /android-easylocation/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | EasyLocation 3 | Location permission needed 4 | Enable Location permission now? 5 | Location services OFF 6 | Enable location services now? 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/akhgupta/easylocation/demo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.akhgupta.easylocation.demo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /android-easylocation/src/test/java/com/akhgupta/easylocation/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.akhgupta.easylocation; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /android-easylocation/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 9 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /android-easylocation/src/main/java/com/akhgupta/easylocation/AppConstants.java: -------------------------------------------------------------------------------- 1 | package com.akhgupta.easylocation; 2 | 3 | class AppConstants { 4 | public static final int SINGLE_FIX = 1; 5 | public static final int CONTINUOUS_LOCATION_UPDATES = 2; 6 | public static final String ACTION_LOCATION_FETCH_START = "location.fetch.start"; 7 | public static final String ACTION_LOCATION_FETCH_STOP = "location.fetch.stop"; 8 | public static final String INTENT_LOCATION_RECEIVED = "intent.location.received"; 9 | public static final String INTENT_NO_LOCATION_RECEIVED = "intent.no.location.received"; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | *.DS_Store 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | .idea 16 | .idea/** 17 | build/** 18 | # Gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # Log Files 29 | *.log 30 | 31 | # Android Studio Navigation editor temp files 32 | .navigation/ 33 | 34 | # Android Studio captures folder 35 | captures/ 36 | 37 | # Intellij 38 | *.iml 39 | .idea/workspace.xml 40 | 41 | # Keystore files 42 | *.jks 43 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/akhil/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /android-easylocation/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/akhil/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # suppress inspection "UnusedProperty" 13 | org.gradle.jvmargs=-Xmx1536m 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /android-easylocation/src/main/java/com/akhgupta/easylocation/EasyLocation.java: -------------------------------------------------------------------------------- 1 | package com.akhgupta.easylocation; 2 | 3 | import android.location.Location; 4 | 5 | class EasyLocation { 6 | private final Location location; 7 | 8 | public EasyLocation(Location location) { 9 | this.location = location; 10 | } 11 | 12 | @Override 13 | public boolean equals(Object o) { 14 | if (this == o) return true; 15 | if (o == null || getClass() != o.getClass()) return false; 16 | EasyLocation that = (EasyLocation) o; 17 | return location != null ? location.equals(that.location) : that.location == null; 18 | 19 | } 20 | 21 | @Override 22 | public int hashCode() { 23 | return location != null ? location.hashCode() : 0; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return location.getLatitude() +","+location.getLongitude(); 29 | } 30 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/akhgupta/easylocation/demo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.akhgupta.easylocation.demo; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.akhgupta.easylocation.demo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android-easylocation/src/androidTest/java/com/akhgupta/easylocation/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.akhgupta.easylocation; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.akhgupta.easylocation.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android-easylocation/src/main/java/com/akhgupta/easylocation/LocationBroadcastReceiver.java: -------------------------------------------------------------------------------- 1 | package com.akhgupta.easylocation; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.location.Location; 7 | 8 | class LocationBroadcastReceiver extends BroadcastReceiver { 9 | private final EasyLocationListener easyLocationListener; 10 | 11 | public LocationBroadcastReceiver(EasyLocationListener easyLocationListener) { 12 | this.easyLocationListener = easyLocationListener; 13 | } 14 | 15 | @Override 16 | public void onReceive(Context context, Intent intent) { 17 | if (intent.getAction().equals(AppConstants.INTENT_LOCATION_RECEIVED)) { 18 | Location location = intent.getParcelableExtra(IntentKey.LOCATION); 19 | easyLocationListener.onLocationReceived(location); 20 | } else if (AppConstants.INTENT_NO_LOCATION_RECEIVED.equals(intent.getAction())) { 21 | easyLocationListener.noLocationReceived(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'android-apt' 3 | 4 | //noinspection GroovyMissingReturnStatement,GroovyMissingReturnStatement 5 | android { 6 | compileSdkVersion 24 7 | buildToolsVersion "24.0.3" 8 | defaultConfig { 9 | applicationId "com.akhgupta.easylocation.demo" 10 | minSdkVersion 15 11 | targetSdkVersion 24 12 | versionCode 1 13 | versionName "1.0" 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(include: ['*.jar'], dir: 'libs') 26 | compile 'com.jakewharton:butterknife:8.4.0' 27 | apt 'com.jakewharton:butterknife-compiler:8.4.0' 28 | compile "com.google.android.gms:play-services-location:9.6.0" 29 | 30 | 31 | 32 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 33 | exclude group: 'com.android.support', module: 'support-annotations' 34 | }) 35 | compile 'com.android.support:appcompat-v7:24.2.1' 36 | testCompile 'junit:junit:4.12' 37 | compile project(':android-easylocation') 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 |