Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update project #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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 .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
- name: Build with Gradle
run: ./gradlew build jacocoTestReport assembleAndroidTest
- name: Codecov
uses: codecov/codecov-action@v1.0.7
uses: codecov/codecov-action@v3.1.4


6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android:
components:
- tools
- platform-tools
- build-tools-29.0.0
- android-29
- build-tools-33.0.2
- android-33

- extra-google-google_play_services
- extra-google-m2repository
Expand All @@ -23,7 +23,7 @@ android:
- 'android-sdk-license-.+'

before_install:
- yes | sdkmanager "platforms;android-29"
- yes | sdkmanager "platforms;android-33"

script:
- ./gradlew clean check --stacktrace --no-daemon
Expand Down
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apply plugin: 'com.android.application'

android {
namespace 'com.yayandroid.locationmanager.sample'

compileSdkVersion versions.compileSdkVersion
buildToolsVersion versions.buildToolsVersion

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning" >

<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
25 changes: 12 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,44 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath 'org.jacoco:org.jacoco.core:0.8.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}


allprojects {
repositories {
google()
jcenter()
mavenCentral()
}

project.ext {
versions = [
minSdkVersion : 14,
compileSdkVersion: 29,
targetSdkVersion : 29,
buildToolsVersion: '29.0.0'
compileSdkVersion: 33,
targetSdkVersion : 33,
buildToolsVersion: '33.0.2'
]

libraries = [
appCompat : 'androidx.appcompat:appcompat:1.1.0',
googlePlayServices: 'com.google.android.gms:play-services-location:17.0.0',
appCompat : 'androidx.appcompat:appcompat:1.6.1',
googlePlayServices: 'com.google.android.gms:play-services-location:21.0.1',

junit : 'junit:junit:4.12',
assertJ : 'com.squareup.assertj:assertj-android:1.1.1',
mockito : 'org.mockito:mockito-core:2.7.2',
mockito : 'org.mockito:mockito-core:4.2.0',

leakcanary : 'com.squareup.leakcanary:leakcanary-android:2.4'
leakcanary : 'com.squareup.leakcanary:leakcanary-android:2.12'
]
}
}
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Sat Feb 01 14:17:05 CET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
4 changes: 3 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
apply plugin: 'com.android.library'
apply plugin: 'jacoco-android'
apply plugin: 'jacoco'

android {
namespace 'com.yayandroid.locationmanager'

compileSdkVersion versions.compileSdkVersion
buildToolsVersion versions.buildToolsVersion

Expand Down
4 changes: 2 additions & 2 deletions library/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
POM_NAME=LocationManager Library
POM_ARTIFACT_ID=LocationManager
POM_PACKAGING=aar
VERSION_NAME=2.4.1
VERSION_CODE=29
VERSION_NAME=2.5.0
VERSION_CODE=30
GROUP=com.yayandroid

POM_DESCRIPTION=LocationManager Library
Expand Down
109 changes: 54 additions & 55 deletions library/maven_push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'

def isReleaseBuild() {
Expand All @@ -39,74 +39,73 @@ def getRepositoryPassword() {
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
}

afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
publishing {
publications {
maven(MavenPublication) {

pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME

repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
pom {
name.set(POM_NAME)
packaging POM_PACKAGING
description POM_DESCRIPTION
url.set(POM_URL)

pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL

scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
scm {
url.set(POM_SCM_URL)
connection.set(POM_SCM_CONNECTION)
developerConnection.set(POM_SCM_DEV_CONNECTION)
}

licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
licenses {
license {
name.set(POM_LICENCE_NAME)
url.set(POM_LICENCE_URL)
distribution.set(POM_LICENCE_DIST)
}
}

developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
developers {
developer {
id.set(POM_DEVELOPER_ID)
name.set(POM_DEVELOPER_NAME)
}
}
}
}
}

signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
repositories {
maven {
url = version.endsWith("SNAPSHOT") ? getSnapshotRepositoryUrl() : getReleaseRepositoryUrl()
credentials {
username getRepositoryUsername()
password getRepositoryPassword()
}
}
}
}

//task androidJavadocs(type: Javadoc) {
//source = android.sourceSets.main.allJava
//}
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}

//task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
//classifier = 'javadoc'
//from androidJavadocs.destinationDir
//}
//task androidJavadocs(type: Javadoc) {
//source = android.sourceSets.main.allJava
//}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
//task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
//classifier = 'javadoc'
//from androidJavadocs.destinationDir
//}

artifacts {
archives androidSourcesJar
}
tasks.register('androidSourcesJar', Jar) {
archiveClassifier.set("sources")
from android.sourceSets.main.java.sourceFiles
}

artifacts {
archives androidSourcesJar
}
5 changes: 4 additions & 1 deletion library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.yayandroid.locationmanager" />
<manifest package="com.yayandroid.locationmanager"
xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@

public class LocationManager implements PermissionListener {

private LocationListener listener;
private LocationConfiguration configuration;
private LocationProvider activeProvider;
private PermissionProvider permissionProvider;
private final LocationListener listener;
private final LocationConfiguration configuration;
private final LocationProvider activeProvider;
private final PermissionProvider permissionProvider;

/**
* Library tries to log as much as possible in order to make it transparent to see what is actually going on
* under the hood. You can enable it for debug purposes, but do not forget to disable on production.
*
* <p>
* Log is disabled as default.
*/
public static void enableLog(boolean enable) {
Expand Down Expand Up @@ -60,7 +60,7 @@ private LocationManager(Builder builder) {

public static class Builder {

private ContextProcessor contextProcessor;
private final ContextProcessor contextProcessor;
private LocationListener listener;
private LocationConfiguration configuration;
private LocationProvider activeProvider;
Expand Down Expand Up @@ -159,7 +159,7 @@ public LocationConfiguration getConfiguration() {

/**
* Google suggests to stop location updates when the activity is no longer in focus
* http://developer.android.com/training/location/receive-location-updates.html#stop-updates
* <a href="http://developer.android.com/training/location/receive-location-updates.html#stop-updates">...</a>
*/
public void onPause() {
activeProvider.onPause();
Expand Down Expand Up @@ -240,7 +240,7 @@ void askForPermission() {
LogUtils.logI("Waiting until we receive any callback from PermissionProvider...");
} else {
LogUtils.logI("Couldn't get permission, Abort!");
failed(FailType.PERMISSION_DENIED);
failed();
}
}
}
Expand All @@ -255,9 +255,9 @@ private void permissionGranted(boolean alreadyHadPermission) {
activeProvider.get();
}

private void failed(@FailType int type) {
private void failed() {
if (listener != null) {
listener.onLocationFailed(type);
listener.onLocationFailed(FailType.PERMISSION_DENIED);
}
}

Expand All @@ -268,6 +268,6 @@ public void onPermissionsGranted() {

@Override
public void onPermissionsDenied() {
failed(FailType.PERMISSION_DENIED);
failed();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.yayandroid.locationmanager.base;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

Expand Down Expand Up @@ -35,11 +36,14 @@ protected void getLocation() {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
locationManager = new LocationManager.Builder(getContext().getApplicationContext())
.configuration(getLocationConfiguration())
.fragment(this)
.notify(this)
.build();
Context context = getContext();
if (context != null) {
locationManager = new LocationManager.Builder(context.getApplicationContext())
.configuration(getLocationConfiguration())
.fragment(this)
.notify(this)
.build();
}
}

@CallSuper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static LocationConfiguration silentConfiguration() {
* Returns a LocationConfiguration that will never ask user anything and will try to use whatever possible options
* that application has to obtain location. If there is no sufficient permission, provider, etc... then
* LocationManager will call {@linkplain LocationListener#onLocationFailed(int)} silently
*
* <p>
* # Best use case of this configuration is within Service implementations
*/
public static LocationConfiguration silentConfiguration(boolean keepTracking) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public Builder gpsMessage(String gpsMessage) {
* implementation of {@linkplain DialogProvider} and manager will use that implementation to display the dialog.
* Important, if you set your own implementation, please make sure to handle gpsMessage as well.
* Because {@linkplain DefaultProviderConfiguration.Builder#gpsMessage} will be ignored in that case.
*
* <p>
* If you don't specify any dialogProvider implementation {@linkplain SimpleMessageDialogProvider} will be used with
* given {@linkplain DefaultProviderConfiguration.Builder#gpsMessage}
*/
Expand Down
Loading