Skip to content
Merged
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
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ '**' ]

jobs:
build:
runs-on: ubuntu-latest
container:
image: mbgl/android-sdk:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check code style
run: make checkstyle

- name: Run Lint
run: ./gradlew lint

- name: Run unit-test in Android libraries
run: make test

- name: Upload reports
uses: actions/upload-artifact@v4
with:
name: reports
path: app/build/reports

- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: app/build/test-results
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog for the Mapbox Gestures for Android

## 0.9.2 - September 29, 2025
* Fix concurrent modification exception for detectors

## 0.9.1 - November 27, 2023
Minor release with internal fixes for publishing library

Expand Down
14 changes: 0 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ buildscript {
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 {
Expand All @@ -28,13 +21,6 @@ allprojects {
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
}
}
}
}
Expand Down
34 changes: 0 additions & 34 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ workflows:
version: 2
default:
jobs:
- build
- release:
filters:
branches:
Expand All @@ -13,39 +12,6 @@ workflows:
only: /^v.*/

jobs:
build:
working_directory: ~/code
docker:
- image: mbgl/android-ndk-r21e:latest
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "library/build.gradle" }}-{{ checksum "gradle/dependencies.gradle" }}
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "library/build.gradle" }}-{{ checksum "gradle/dependencies.gradle" }}
- run:
name: Check code style
command: make checkstyle
- run:
name: Run Lint
command: ./gradlew lint
- run:
name: Run unit-test in Android libraries
command: make test
- store_artifacts:
path: app/build/reports
destination: reports
- store_test_results:
path: app/build/test-results

# ------------------------------------------------------------------------------
release:
docker:
- image: mbgl/android-ndk-r21e:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;

/**
* Entry point for all of the detectors. Set listener for gestures you'd like to be notified about
Expand Down Expand Up @@ -58,7 +59,7 @@ public class AndroidGesturesManager {
public static final int GESTURE_TYPE_QUICK_SCALE = 15;

private final List<Set<Integer>> mutuallyExclusiveGestures = new ArrayList<>();
private final List<BaseGesture> detectors = new ArrayList<>();
private final List<BaseGesture> detectors;

private final StandardGestureDetector standardGestureDetector;
private final StandardScaleGestureDetector standardScaleGestureDetector;
Expand Down Expand Up @@ -128,13 +129,15 @@ public AndroidGesturesManager(Context context, List<Set<Integer>> exclusiveGestu
moveGestureDetector = new MoveGestureDetector(context, this);
standardGestureDetector = new StandardGestureDetector(context, this);

detectors.add(rotateGestureDetector);
detectors.add(standardScaleGestureDetector);
detectors.add(shoveGestureDetector);
detectors.add(sidewaysShoveGestureDetector);
detectors.add(multiFingerTapGestureDetector);
detectors.add(moveGestureDetector);
detectors.add(standardGestureDetector);
detectors = new CopyOnWriteArrayList<BaseGesture>(Arrays.asList(
rotateGestureDetector,
standardScaleGestureDetector,
shoveGestureDetector,
sidewaysShoveGestureDetector,
multiFingerTapGestureDetector,
moveGestureDetector,
standardGestureDetector
));

if (applyDefaultThresholds) {
initDefaultThresholds();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.mapbox.android.gestures;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import android.view.MotionEvent;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -11,9 +17,6 @@
import java.util.List;
import java.util.Set;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

@RunWith(RobolectricTestRunner.class)
public class AndroidGesturesManagerTest {
private AndroidGesturesManager androidGesturesManager;
Expand Down Expand Up @@ -44,9 +47,9 @@ public void setUp() throws Exception {
mutuallyExclusivesList.add(set3);

androidGesturesManager =
new AndroidGesturesManager(
RuntimeEnvironment.application.getApplicationContext(),
mutuallyExclusivesList, true);
new AndroidGesturesManager(
RuntimeEnvironment.application.getApplicationContext(),
mutuallyExclusivesList, true);
}

@Test
Expand All @@ -69,4 +72,24 @@ public void setMutuallyExclusivesTest() throws Exception {
androidGesturesManager.setMutuallyExclusiveGestures(mutuallyExclusivesList);
assertEquals(androidGesturesManager.getMutuallyExclusiveGestures(), mutuallyExclusivesList);
}

@Test
public void onSingleTapModifyDetectorsTest() {
final StandardGestureDetector standardGestureDetector = new StandardGestureDetector(
RuntimeEnvironment.getApplication().getApplicationContext(),
androidGesturesManager
);

androidGesturesManager.setStandardGestureListener(new StandardGestureDetector.SimpleStandardOnGestureListener() {
@Override
public boolean onDown(MotionEvent e) {
androidGesturesManager.getDetectors().add(standardGestureDetector);
return true;
}
});

MotionEvent downEvent = TestUtils.INSTANCE.getMotionEvent(MotionEvent.ACTION_DOWN, 0, 0, null);
androidGesturesManager.onTouchEvent(downEvent);
assertTrue(androidGesturesManager.getDetectors().contains(standardGestureDetector));
}
}
Loading