Skip to content

Commit

Permalink
Fix nullable motion events (#101)
Browse files Browse the repository at this point in the history
* Bump Maps to v10.

* Remove developer-config from tracked files.

* Remove wrong NonNull annotations from SimpleStandardOnGestureListener.

* Update changelog.

* Update README and gradle properties with new version.

* Update docker.

* Fix checkstyle.

* Review comments.

* Fix lint.
  • Loading branch information
yunikkk authored Aug 19, 2022
1 parent 6fc34d9 commit 7fbc4f9
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 118 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog for the Mapbox Gestures for Android

## 0.8.0 - August 19, 2022
#### Minor features
- Updated dependencies : Maps 10.7.0, targetSdk 31, compileSdk 30. [#101](https://github.com/mapbox/mapbox-gestures-android/pull/101)
#### Breaking changes
- Remove NonNull annotations from SimpleStandardOnGestureListener that have no such annotations in Android sources. [#101](https://github.com/mapbox/mapbox-gestures-android/pull/101)

## 0.7.0 - April 30, 2020
#### Minor features
- Expose a `MoveGestureDetector#moveThresholdRect`. When set, the defined screen area prohibits move gesture to be started. [#96](https://github.com/mapbox/mapbox-gestures-android/pull/96)
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ Mapbox Gestures for Android was inspired by [Android Gesture Detector Framework]

The library is implemented in the projects found below, where you can head for more examples:

- [The Mapbox Maps SDK for Android](https://github.com/mapbox/mapbox-gl-native)
- [The Mapbox Maps SDK for Android](https://github.com/mapbox/mapbox-maps-android)
- [This library's sample app](https://github.com/mapbox/mapbox-gestures-android/tree/master/app/src/main/java/com/mapbox/android/gestures/testapp) included in this repository

Are you using the library in your project as well? Let us know or create a PR, we'll be more than happy to add it to the list!


## Documentation

You'll find all of this library's documentation on [our Mapbox Gestures page](https://www.mapbox.com/android-docs/map-sdk/overview/gestures). This includes information on installation, using the API, and links to the API reference.
You'll find all of this library's documentation on [our Maps Guides user interaction page](https://docs.mapbox.com/android/maps/guides/user-interaction/). This includes information on installation, using the API, and links to the API reference.


## Getting Started

If you are looking to include Mapbox Gestures for Android inside of your project, please take a look at [the detailed instructions](https://www.mapbox.com/android-docs/map-sdk/overview/gestures/) found in our docs. If you are interested in building from source, read the contributing guide inside of this project.
If you are looking to include Mapbox Gestures for Android inside of your project, please take a look at [the detailed instructions](https://docs.mapbox.com/android/maps/guides/user-interaction/) found in our docs. If you are interested in building from source, read the contributing guide inside of this project.

To use the Gestures library, include it in your app-level `build.gradle` file.

Expand All @@ -33,7 +33,7 @@ repositories {
```java
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.mapboxsdk:mapbox-android-gestures:0.7.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-gestures:0.8.0'
}
```

Expand All @@ -49,11 +49,15 @@ repositories {
```java
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.mapboxsdk:mapbox-android-gestures:0.8.0-SNAPSHOT'
implementation 'com.mapbox.mapboxsdk:mapbox-android-gestures:0.9.0-SNAPSHOT'
}
```

To run the specific Mapbox activity in this repo's test application, include your [developer access token](https://www.mapbox.com/help/define-access-token/) in the `developer-config.xml` file. An access token is not required to run this repo's test application.
#### Mapbox access tokens

To build test application you need to configure Mapbox access tokens as described at https://docs.mapbox.com/android/maps/guides/install/#configure-credentials.
To build the project you need to specify SDK_REGISTRY_TOKEN as an environmental variable or a gradle property. It is a secret token used to access the SDK Registry (Mapbox Maven instance) during compile time, with a scope set to `DOWNLOADS:READ`.
To run the specific Mapbox activity in this repo's test application, you need to include public token in the [app/src/main/res/values/developer-config.xml] resource file.

## Getting Help

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies {
implementation dependenciesList.kotlinLib
implementation dependenciesList.supportAppcompatV7
implementation dependenciesList.timber
implementation(dependenciesList.mapboxSdk) {
implementation(dependenciesList.mapboxMaps) {
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-gestures'
}

Expand Down
25 changes: 25 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mapbox.android.gestures.testapp">

<uses-sdk tools:overrideLibrary="com.mapbox.maps,
com.mapbox.common.module.okhttp,
com.mapbox.maps.extension.localization,
com.mapbox.maps.extension.style,
com.mapbox.maps.plugin.annotation,
com.mapbox.maps.plugin.logo,
com.mapbox.maps.plugin.compass,
com.mapbox.maps.plugin.gestures,
com.mapbox.maps.plugin.attribution,
com.mapbox.maps.plugin.viewport,
com.mapbox.maps.plugin.locationcomponent,
com.mapbox.maps.plugin.camera.animation,
com.mapbox.maps.plugin.scalebar,
com.mapbox.maps.plugin.overlay,
com.mapbox.maps.plugin.lifecycle,
com.mapbox.maps.module.telemetry,
com.mapbox.maps.base,
com.mapbox.maps.core,
com.mapbox.common.core,
com.mapbox.common.logger,
com.mapbox.common.loader,
com.mapbox.android.telemetry,
"/>

<application
android:name=".MyApplication"
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import androidx.appcompat.app.AppCompatActivity;
import android.text.TextUtils;

import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.maps.MapView;
import com.mapbox.maps.Style;

import timber.log.Timber;

Expand All @@ -22,8 +21,6 @@ public class MapboxActivity extends AppCompatActivity {
+ "automatically include it in the Test App. Otherwise, you can manually include it in the "
+ "res/values/developer-config.xml file in the mapbox-gestures-android/app folder.";

private MapView mapView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -33,54 +30,9 @@ protected void onCreate(Bundle savedInstanceState) {
Timber.e(ACCESS_TOKEN_NOT_SET_MESSAGE);
}

Mapbox.getInstance(getApplicationContext(), mapboxAccessToken);

setContentView(R.layout.activity_mapbox);

mapView = (MapView) findViewById(R.id.map_view);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(Style.MAPBOX_STREETS));
}

@Override
protected void onStart() {
super.onStart();
mapView.onStart();
}

@Override
protected void onResume() {
super.onResume();
mapView.onResume();
}

@Override
protected void onPause() {
super.onPause();
mapView.onPause();
}

@Override
protected void onStop() {
super.onStop();
mapView.onStop();
}

@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}

@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
MapView mapView = (MapView) findViewById(R.id.map_view);
mapView.getMapboxMap().loadStyleUri(Style.MAPBOX_STREETS);
}
}
24 changes: 6 additions & 18 deletions app/src/main/java/com/mapbox/android/gestures/testapp/Utils.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
package com.mapbox.android.gestures.testapp;

import android.content.Context;
import androidx.annotation.NonNull;

import com.mapbox.mapboxsdk.Mapbox;
import androidx.annotation.NonNull;

public class Utils {

/**
* <p>
* Returns the Mapbox access token set in the app resources.
* </p>
* It will first search for a token in the Mapbox object. If not found it
* will then attempt to load the access token from the
* {@code res/values/dev.xml} development file.
* It will attempt to load the access token from the
* {@code res/values/developer-config.xml} development file.
*
* @param context The {@link Context} of the {@link android.app.Activity} or {@link android.app.Fragment}.
* @return The Mapbox access token or null if not found.
*/
public static String getMapboxAccessToken(@NonNull Context context) {
try {
// Read out AndroidManifest
String token = Mapbox.getAccessToken();
if (token == null || token.isEmpty()) {
throw new IllegalArgumentException();
}
return token;
} catch (Exception exception) {
// Use fallback on string resource, used for development
int tokenResId = context.getResources()
.getIdentifier("mapbox_access_token", "string", context.getPackageName());
return tokenResId != 0 ? context.getString(tokenResId) : null;
}
int tokenResId = context.getResources().getIdentifier(
"mapbox_access_token", "string", context.getPackageName());
return tokenResId != 0 ? context.getString(tokenResId) : null;
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_mapbox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_height="match_parent"
tools:context="com.mapbox.android.gestures.testapp.MapboxActivity">

<com.mapbox.mapboxsdk.maps.MapView
<com.mapbox.maps.MapView
android:id="@+id/map_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values/developer-config.xml

This file was deleted.

27 changes: 22 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
apply from: "gradle/dependencies.gradle"
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = System.getenv("SDK_REGISTRY_TOKEN") ?: project.property("SDK_REGISTRY_TOKEN") as String
}
}
}
dependencies {
classpath pluginDependencies.gradle
classpath pluginDependencies.bintrayPlugin
classpath pluginDependencies.androidPublishPlugin
classpath pluginDependencies.artifactory
classpath pluginDependencies.kotlinPlugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = password = System.getenv("SDK_REGISTRY_TOKEN") ?: project.property("SDK_REGISTRY_TOKEN") as String
}
}
maven { url 'https://mapbox.bintray.com/mapbox' }
}
}
Expand Down
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
working_directory: ~/code
docker:
- image: mbgl/android-ndk-r20:7b7c4b42cf
- image: mbgl/android-ndk-r21e:latest
environment:
JVM_OPTS: -Xmx3200m
steps:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
only:
- master
docker:
- image: mbgl/android-ndk-r20:7b7c4b42cf
- image: mbgl/android-ndk-r21e:latest
working_directory: ~/code
steps:
- checkout
Expand Down
32 changes: 16 additions & 16 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
ext {
androidVersions = [
minSdkVersion : 14,
targetSdkVersion : 28,
compileSdkVersion: 28,
targetSdkVersion : 30,
compileSdkVersion: 31,
]

version = [
mapboxSdkVersion : '8.6.0',
mapboxMaps : '10.7.0',
timber : '4.7.1',
junit : '4.12',
junit : '4.13.2',
mockito : '3.2.4',
robolectric : '4.3',
testRunner : '1.1.1',
espresso : '3.2.0',
kotlin : '1.3.41',
appCompat : '1.0.0',
core : '1.0.0',
annotation : '1.0.0'
robolectric : '4.8.1',
testRunner : '1.1.3',
espresso : '3.4.0',
kotlin : '1.5.31',
appCompat : '1.3.0',
core : '1.7.0', // last version compatible with kotlin 1.5.31
annotation : '1.1.0'
]

pluginVersion = [
checkstyle : '8.4',
gradle : '3.4.2',
bintray : '1.8.4',
androidPublish: '3.6.2',
artifactory : '4.9.3',
gradle : '7.0.4',
bintray : '1.8.5',
androidPublish: '3.6.3',
artifactory : '4.29.0'
]

dependenciesList = [

// mapbox
mapboxSdk : "com.mapbox.mapboxsdk:mapbox-android-sdk:${version.mapboxSdkVersion}",
mapboxMaps : "com.mapbox.maps:android:${version.mapboxMaps}",

// support
supportAppcompatV7 : "androidx.appcompat:appcompat:${version.appCompat}",
Expand Down
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 @@
#Fri Jan 18 15:22:24 CET 2019
#Thu Aug 18 15:53:42 EEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
zipStoreBase=GRADLE_USER_HOME
2 changes: 1 addition & 1 deletion library/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=0.8.0-SNAPSHOT
VERSION_NAME=0.9.0-SNAPSHOT
POM_ARTIFACT_ID=mapbox-android-gestures
POM_NAME=Mapbox Android Gestures Library
POM_DESCRIPTION=Mapbox Android Gestures Library
Expand Down
Loading

0 comments on commit 7fbc4f9

Please sign in to comment.