Updated Android SDK, all dependencies, and did the gradle migarion, fixed unit tests and ktlint (#627)

Co-authored-by: Artak Kalantarian <artak@amazon.com>
This commit is contained in:
Artak Kalantarian
2022-12-21 18:11:43 +04:00
committed by GitHub
parent c6dd558665
commit b038aeddb0
95 changed files with 796 additions and 704 deletions

View File

@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
compileSdkVersion 33
defaultConfig {
applicationId = 'com.mapbox.mapboxsdk.maps.benchmark_runner'
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 33
def abi = 'all'
if (project.hasProperty('mapbox.abis')) {
abi = project.getProperty('mapbox.abis')
@@ -44,9 +44,9 @@ android {
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
androidTestImplementation 'androidx.test:rules:1.5.0'
}

View File

@@ -2,7 +2,7 @@ package android.app;
import android.util.Log;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
@@ -12,7 +12,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
@LargeTest
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class NativeActivityTest {
@Rule

View File

@@ -14,6 +14,7 @@ dependencies {
implementation dependenciesList.okhttp3
implementation dependenciesList.gmsLocation
implementation dependenciesList.timber
implementation dependenciesList.interpolator
testImplementation dependenciesList.junit
testImplementation dependenciesList.mockito
@@ -22,6 +23,9 @@ dependencies {
testImplementation dependenciesList.kotlinLib
testImplementation dependenciesList.commonsIO
testImplementation dependenciesList.assertjcore
androidTestImplementation dependenciesList.testRunner
androidTestImplementation dependenciesList.testRules
}
android {
@@ -56,11 +60,6 @@ android {
main.res.srcDirs += 'src/main/res-public'
}
lintOptions {
disable 'MissingTranslation', 'TypographyQuotes', 'ObsoleteLintCustomCheck', 'MissingPermission', 'WrongThreadInterprocedural'
checkAllWarnings true
warningsAsErrors false
}
testOptions {
unitTests {
@@ -78,6 +77,12 @@ android {
jniDebuggable true
}
}
namespace 'com.mapbox.mapboxsdk'
lint {
checkAllWarnings true
disable 'MissingTranslation', 'TypographyQuotes', 'ObsoleteLintCustomCheck', 'MissingPermission', 'WrongThreadInterprocedural'
warningsAsErrors false
}
}
licenseReport {

View File

@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Dec 20 16:17:15 PST 2022
sdk.dir=/Users/artak/Library/Android/sdk

View File

@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapbox.mapboxsdk">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature
android:glEsVersion="0x00020000"
@@ -11,5 +10,6 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

View File

@@ -33,6 +33,7 @@ class MapboxMapTest {
@Mock
private lateinit var context: Context
@Mock
private lateinit var appContext: Context

View File

@@ -16,14 +16,14 @@ import java.util.List;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyByte;
import static org.mockito.Matchers.anyDouble;
import static org.mockito.Matchers.anyFloat;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyByte;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

View File

@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Dec 20 16:17:45 PST 2022
sdk.dir=/Users/artak/Library/Android/sdk

View File

@@ -1,15 +1,17 @@
package com.mapbox.mapboxsdk.lint
/*
import com.android.tools.lint.checks.infrastructure.TestFiles.java
import com.android.tools.lint.checks.infrastructure.TestLintTask.lint
import org.junit.Test
*/
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class KeepDetectorTest {
@Test
/* @Test
fun correctClassName() {
lint()
.allowMissingSdk()
@@ -22,11 +24,12 @@ class KeepDetectorTest {
|
|@Keep
|class TestClass {
|}""".trimMargin()
|}
""".trimMargin()
)
)
.issues(KeepDetector.ISSUE_NOT_KEPT)
.run()
.expectClean()
}
}*/
}

View File

@@ -20,20 +20,12 @@ android {
}
nativeBuild(["example-custom-layer"])
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'LICENSE.txt'
resources {
excludes += ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt', 'LICENSE.txt']
}
}
lintOptions {
baseline file("lint-baseline-local.xml")
checkAllWarnings true
warningsAsErrors true
disable 'MissingTranslation', 'GoogleAppIndexingWarning', 'UnpackedNativeCode', 'IconDipSize', 'TypographyQuotes'
abortOnError false
}
buildTypes {
debug {
@@ -49,11 +41,14 @@ android {
signingConfig signingConfigs.debug
}
}
dexOptions {
maxProcessCount 8
javaMaxHeapSize "2g"
preDexLibraries true
namespace 'com.mapbox.mapboxsdk.testapp'
testNamespace '${applicationId}'
lint {
abortOnError false
baseline file('lint-baseline-local.xml')
checkAllWarnings true
disable 'MissingTranslation', 'GoogleAppIndexingWarning', 'UnpackedNativeCode', 'IconDipSize', 'TypographyQuotes'
warningsAsErrors true
}
}
@@ -85,6 +80,7 @@ dependencies {
androidTestImplementation dependenciesList.testEspressoContrib
androidTestImplementation dependenciesList.testUiAutomator
androidTestImplementation dependenciesList.appCenter
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
}
apply from: "${rootDir}/gradle/gradle-make.gradle"

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:tools="http://schemas.android.com/tools" package="${applicationId}">
<manifest xmlns:tools="http://schemas.android.com/tools">
<uses-sdk tools:overrideLibrary="android_libs.ub_uiautomator"/>
</manifest>

View File

@@ -2,7 +2,7 @@ package com.mapbox.mapboxsdk.camera
import android.graphics.PointF
import androidx.test.annotation.UiThreadTest
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.geometry.LatLngBounds
import com.mapbox.mapboxsdk.testapp.activity.BaseTest
@@ -13,7 +13,7 @@ import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class CameraUpdateFactoryTest : BaseTest() {
override fun getActivityClass(): Class<*> {

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.integration
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import androidx.test.uiautomator.UiSelector
import com.mapbox.mapboxsdk.testapp.activity.fragment.FragmentBackStackActivity
@@ -12,7 +12,7 @@ import org.junit.runner.RunWith
/**
* Regression test that validates MapFragment integration on the backstack
*/
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class FragmentBackStackTest : BaseIntegrationTest() {
@get:Rule

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.integration
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
import org.junit.Rule
@@ -11,7 +11,7 @@ import org.junit.runner.RunWith
/**
* Regression test that validates reopening an Activity with a GLSurfaceView
*/
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class GLSurfaceViewReopenTest : BaseIntegrationTest() {
@get:Rule

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.integration
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
import org.junit.Rule
@@ -11,7 +11,7 @@ import org.junit.runner.RunWith
/**
* Regression test that validates if a GLSurfaceView surface can be recreated without crashing.
*/
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class GLSurfaceViewReuseTest : BaseIntegrationTest() {
@get:Rule

View File

@@ -1,14 +1,14 @@
package com.mapbox.mapboxsdk.integration
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class OrientationChangeTest : BaseIntegrationTest() {
@get:Rule

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.integration
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxCountActivity
import org.junit.Rule
@@ -11,7 +11,7 @@ import org.junit.runner.RunWith
/**
* Regression test that validates reopening an Activity and querying the map before surface recreation #14394
*/
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class QueryRenderedFeaturesBoxCountTest : BaseIntegrationTest() {
@get:Rule

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.integration
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.textureview.TextureViewDebugModeActivity
import org.junit.Rule
@@ -11,7 +11,7 @@ import org.junit.runner.RunWith
/**
* Regression test that validates reopening an Activity with a TextureView
*/
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class TextureViewReopenTest : BaseIntegrationTest() {
@get:Rule

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.integration
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.maplayout.TextureRecyclerViewActivity
import org.junit.Rule
@@ -11,7 +11,7 @@ import org.junit.runner.RunWith
/**
* Regression test that validates if a GLSurfaceView surface can be recreated without crashing.
*/
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class TextureViewReuseTest : BaseIntegrationTest() {
@get:Rule

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.integration
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import androidx.test.uiautomator.UiSelector
import com.mapbox.mapboxsdk.testapp.activity.fragment.ViewPagerActivity
@@ -12,7 +12,7 @@ import org.junit.runner.RunWith
/**
* Regression test that validates MapFragment integration with a ViewPager
*/
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class ViewPagerScrollTest : BaseIntegrationTest() {
@get:Rule

View File

@@ -11,7 +11,7 @@ import androidx.test.espresso.IdlingRegistry
import androidx.test.espresso.UiController
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.GrantPermissionRule
import com.mapbox.geojson.Point
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
@@ -35,7 +35,7 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class LocationComponentTest : EspressoTest() {
@Rule

View File

@@ -5,7 +5,7 @@ package com.mapbox.mapboxsdk.location;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
@@ -39,7 +39,7 @@ import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for LocationIndicatorLayer
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class LocationIndicatorLayerTest extends BaseLayerTest {
private LocationIndicatorLayer layer;

View File

@@ -11,7 +11,7 @@ import androidx.test.espresso.UiController
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.GrantPermissionRule
import androidx.test.rule.GrantPermissionRule.grant
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
@@ -40,7 +40,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import kotlin.math.abs
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class LocationLayerControllerTest : EspressoTest() {
@Rule

View File

@@ -1,12 +1,12 @@
package com.mapbox.mapboxsdk.maps
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.platform.app.InstrumentationRegistry
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.style.layers.Layer
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
abstract class BaseLayerTest : AppCenter() {
private lateinit var nativeMapView: NativeMap

View File

@@ -1,18 +1,17 @@
package com.mapbox.mapboxsdk.maps
import androidx.test.annotation.UiThreadTest
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.platform.app.InstrumentationRegistry
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.Mapbox
import com.mapbox.mapboxsdk.WellKnownTileServer
import com.mapbox.mapboxsdk.storage.FileSource
import com.mapbox.mapboxsdk.testapp.MapboxApplication
import com.mapbox.mapboxsdk.util.TileServerOptions
import org.junit.*
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class BootstrapTest : AppCenter() {
var apiKeyBackup: String? = null
@@ -27,7 +26,7 @@ class BootstrapTest : AppCenter() {
@UiThreadTest
fun after() {
val context = InstrumentationRegistry.getInstrumentation().context
Mapbox.getInstance(context, apiKeyBackup, MapboxApplication.TILE_SERVER)
Mapbox.getInstance(context)
}
@Test

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.maps;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.AppCenter;
import com.mapbox.mapboxsdk.Mapbox;
@@ -18,7 +18,7 @@ import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertSame;
import static junit.framework.Assert.assertTrue;
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class MapboxTest extends AppCenter {
private static final String API_KEY = "pk.0000000001";

View File

@@ -3,7 +3,7 @@ package com.mapbox.mapboxsdk.maps
import android.content.Context
import android.graphics.PointF
import androidx.test.annotation.UiThreadTest
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.platform.app.InstrumentationRegistry
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.Mapbox
@@ -14,7 +14,6 @@ import com.mapbox.mapboxsdk.geometry.LatLngBounds
import com.mapbox.mapboxsdk.geometry.ProjectedMeters
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer
import com.mapbox.mapboxsdk.style.layers.TransitionOptions
import com.mapbox.mapboxsdk.testapp.MapboxApplication
import com.mapbox.mapboxsdk.testapp.utils.TestConstants
import junit.framework.Assert.*
import org.junit.After
@@ -23,7 +22,7 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class NativeMapViewTest : AppCenter() {
private lateinit var nativeMapView: NativeMap
@@ -55,7 +54,7 @@ class NativeMapViewTest : AppCenter() {
fun after() {
val context = InstrumentationRegistry.getInstrumentation().context
val apiKey = Mapbox.getApiKey()
Mapbox.getInstance(context, apiKey, MapboxApplication.TILE_SERVER)
Mapbox.getInstance(context)
nativeMapView.destroy()
}

View File

@@ -1,6 +1,6 @@
package com.mapbox.mapboxsdk.offline
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.geojson.Point
import com.mapbox.mapboxsdk.log.Logger
@@ -16,7 +16,7 @@ import java.util.concurrent.TimeoutException
/**
* Integration test that validates downloading an offline region from a point geometry at zoomlevel 17
*/
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class OfflineDownloadTest : OfflineRegion.OfflineRegionObserver {
@Rule
@@ -42,7 +42,7 @@ class OfflineDownloadTest : OfflineRegion.OfflineRegionObserver {
override fun onError(error: String) {
Logger.e(TAG, "Error while creating offline region: $error")
}
}
},
)
}
@@ -74,7 +74,7 @@ class OfflineDownloadTest : OfflineRegion.OfflineRegionObserver {
17.0,
17.0,
1.0f,
false
false,
)
}

View File

@@ -1,6 +1,6 @@
package com.mapbox.mapboxsdk.snapshotter
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
@@ -20,7 +20,7 @@ import java.util.concurrent.TimeoutException
/**
* Integration test that validates if a snapshotter creation
*/
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class MapSnapshotterTest {
@Rule

View File

@@ -5,7 +5,7 @@
// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`.
package com.mapbox.mapboxsdk.testapp.activity.gen.<%- subPackage %>;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.testapp.activity.BaseTest;
import com.mapbox.mapboxsdk.testapp.activity.<%- subPackage %>.<%- activity %>;
@@ -17,7 +17,7 @@ import org.junit.runner.RunWith;
/**
* Sanity test for <%- activity %>
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class <%- activity %>Test extends BaseTest {
@Test

View File

@@ -4,8 +4,8 @@ import androidx.test.espresso.Espresso
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.testapp.R
@@ -18,7 +18,7 @@ import org.junit.runner.RunWith
/**
* Regression test that validates that a map inside a DialogFragment can be opened and closed.
*/
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
@LargeTest
class MapDialogFragmentTest : AppCenter() {
@@ -26,7 +26,7 @@ class MapDialogFragmentTest : AppCenter() {
var activityRule: ActivityTestRule<MapInDialogActivity> = ActivityTestRule(MapInDialogActivity::class.java)
@Test
@Ignore
@Ignore("Probably does not work")
fun openCloseDialog() {
onView(withId(R.id.button_open_dialog)).perform(click())
Thread.sleep(2500)

View File

@@ -1,6 +1,6 @@
package com.mapbox.mapboxsdk.testapp.maps
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.maps.MapView
@@ -16,7 +16,7 @@ import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class ImageMissingTest : AppCenter() {
@Rule

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.testapp.maps
import android.graphics.Bitmap
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
@@ -20,7 +20,7 @@ import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class RemoveUnusedImagesTest : AppCenter() {
@Rule

View File

@@ -3,7 +3,7 @@ package com.mapbox.mapboxsdk.testapp.maps
import android.view.TextureView
import android.view.ViewGroup
import androidx.test.annotation.UiThreadTest
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.maps.MapView
@@ -17,7 +17,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import java.util.concurrent.CountDownLatch
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class RenderViewGetterTest : AppCenter() {
@Rule

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.testapp.maps
import android.graphics.PointF
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.geometry.LatLng
@@ -17,7 +17,7 @@ import org.junit.runner.RunWith
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class ScreenCoordinateConversion : AppCenter() {
@Rule

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.testapp.maps
import androidx.test.espresso.UiController
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
@@ -12,7 +12,7 @@ import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class StyleLoadTest : EspressoTest() {
@Test

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.testapp.offline
import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.offline.OfflineManager
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
@@ -11,7 +11,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import java.util.concurrent.CountDownLatch
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class CacheTest {
@Rule

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.testapp.offline
import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.offline.OfflineManager
@@ -18,7 +18,7 @@ import java.io.IOException
import java.util.concurrent.CountDownLatch
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class OfflineManagerTest : AppCenter() {
companion object {

View File

@@ -1,6 +1,6 @@
package com.mapbox.mapboxsdk.testapp.offline;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.AppCenter;
import com.mapbox.mapboxsdk.testapp.utils.OfflineUtils;
@@ -15,7 +15,7 @@ import static com.mapbox.mapboxsdk.testapp.activity.offline.OfflineActivity.JSON
import static junit.framework.Assert.assertEquals;
import static junit.framework.TestCase.assertTrue;
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class OfflineUtilsTest extends AppCenter {
private static final String REGION_NAME = "hello world";

View File

@@ -5,7 +5,7 @@ import android.Manifest;
import androidx.test.espresso.IdlingPolicies;
import androidx.test.espresso.IdlingRegistry;
import androidx.test.espresso.IdlingResourceTimeoutException;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.GrantPermissionRule;
@@ -32,7 +32,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.withId;
/**
* Instrumentation render tests
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class RenderTest extends AppCenter {
private static final int RENDER_TEST_TIMEOUT = 30;

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.testapp.storage
import androidx.test.annotation.UiThreadTest
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.storage.FileSource
@@ -15,7 +15,7 @@ import org.junit.rules.TestName
import org.junit.runner.RunWith
import java.util.concurrent.CountDownLatch
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
open class FileSourceMapTest : AppCenter() {
private lateinit var fileSourceTestUtils: FileSourceTestUtils

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.testapp.storage
import androidx.test.annotation.UiThreadTest
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.storage.FileSource
@@ -12,7 +12,7 @@ import org.junit.runner.RunWith
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class FileSourceStandaloneTest : AppCenter() {
private lateinit var fileSourceTestUtils: FileSourceTestUtils

View File

@@ -1,6 +1,6 @@
package com.mapbox.mapboxsdk.testapp.string;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
@@ -15,7 +15,7 @@ import static junit.framework.Assert.assertEquals;
* See core test in https://github.com/mapbox/mapbox-gl-native/blob/master/test/util/text_conversions.test.cpp
* </p>
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class UppperLowerCaseTest extends EspressoTest {
@Test

View File

@@ -5,7 +5,7 @@ package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
@@ -34,7 +34,7 @@ import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for BackgroundLayer
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class BackgroundLayerTest extends BaseLayerTest {
private BackgroundLayer layer;

View File

@@ -5,7 +5,7 @@ package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
@@ -61,7 +61,7 @@ import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for CircleLayer
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class CircleLayerTest extends BaseLayerTest {
private CircleLayer layer;

View File

@@ -1,9 +1,5 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
@@ -25,9 +21,11 @@ import com.mapbox.mapboxsdk.utils.ColorUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.IOException;
import android.graphics.Color;
import java.util.HashMap;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatFontScale;
@@ -70,9 +68,8 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class ExpressionTest extends EspressoTest {
private FillLayer layer;
@Test
@@ -87,7 +84,7 @@ public class ExpressionTest extends EspressoTest {
// set color expression
layer.setProperties(
fillColor(inputExpression)
fillColor(inputExpression)
);
// get color value
@@ -110,7 +107,7 @@ public class ExpressionTest extends EspressoTest {
// set get expression
layer.setProperties(
fillColor(inputExpression)
fillColor(inputExpression)
);
// get actual expression
@@ -133,15 +130,15 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
// create camera function expression
Expression inputExpression = interpolate(
exponential(0.5f), zoom(),
stop(1.0f, rgba(255.0f, 0.0f, 0.0f, 1.0f)),
stop(5.0f, rgba(0.0f, 0.0f, 255.0f, 1.0f)),
stop(10.0f, rgba(0.0f, 255.0f, 0.0f, 1.0f))
exponential(0.5f), zoom(),
stop(1.0f, rgba(255.0f, 0.0f, 0.0f, 1.0f)),
stop(5.0f, rgba(0.0f, 0.0f, 255.0f, 1.0f)),
stop(10.0f, rgba(0.0f, 255.0f, 0.0f, 1.0f))
);
// set camera function expression
layer.setProperties(
fillColor(inputExpression)
fillColor(inputExpression)
);
// get camera function expression
@@ -164,7 +161,7 @@ public class ExpressionTest extends EspressoTest {
// set camera function expression
layer.setProperties(
fillColor(inputExpression)
fillColor(inputExpression)
);
// get camera function expression
@@ -184,22 +181,22 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
// create camera function expression
Expression inputExpression = step(zoom(),
rgba(255.0f, 255.0f, 255.0f, 1.0f),
stop(7.0f, match(
string(get("name")),
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
rgba(255.0f, 255.0f, 255.0f, 1.0f)
)),
stop(8.0f, match(
string(get("name")),
literal("Westerpark"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
rgba(255.0f, 255.0f, 255.0f, 1.0f)
))
rgba(255.0f, 255.0f, 255.0f, 1.0f),
stop(7.0f, match(
string(get("name")),
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
rgba(255.0f, 255.0f, 255.0f, 1.0f)
)),
stop(8.0f, match(
string(get("name")),
literal("Westerpark"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
rgba(255.0f, 255.0f, 255.0f, 1.0f)
))
);
// set camera function expression
layer.setProperties(
fillColor(inputExpression)
fillColor(inputExpression)
);
// get camera function expression
@@ -216,7 +213,7 @@ public class ExpressionTest extends EspressoTest {
setupStyle();
invoke(mapboxMap, (uiController, mapboxMap) -> {
layer.setProperties(
fillColor(literal("#4286f4"))
fillColor(literal("#4286f4"))
);
});
}
@@ -227,14 +224,14 @@ public class ExpressionTest extends EspressoTest {
setupStyle();
invoke(mapboxMap, (uiController, mapboxMap) -> {
Expression expression = match(literal("something"), literal(0f),
stop("1", get("1")),
stop("2", get("2")),
stop("3", get("3")),
stop("4", get("4"))
stop("1", get("1")),
stop("2", get("2")),
stop("3", get("3")),
stop("4", get("4"))
);
layer.setProperties(
fillColor(expression)
fillColor(expression)
);
expression.toArray();
});
@@ -248,43 +245,43 @@ public class ExpressionTest extends EspressoTest {
Expression expression1 = eq(literal("Łukasz"), literal("lukasz"), collator(true, true));
Expression expression2 = eq(literal("Łukasz"), literal("lukasz"), collator(literal(false), eq(literal(1),
literal(1)), literal("en")));
literal(1)), literal("en")));
Expression expression3 = eq(literal("Łukasz"), literal("lukasz"), collator(literal(false), eq(literal(2),
literal(1))));
literal(1))));
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
Layer layer = new CircleLayer("layer", "source")
.withProperties(circleColor(
switchCase(
expression1, literal(ColorUtils.colorToRgbaString(Color.GREEN)),
literal(ColorUtils.colorToRgbaString(Color.RED))
)
));
.withProperties(circleColor(
switchCase(
expression1, literal(ColorUtils.colorToRgbaString(Color.GREEN)),
literal(ColorUtils.colorToRgbaString(Color.RED))
)
));
mapboxMap.getStyle().addLayer(layer);
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
.isEmpty());
layer.setProperties(circleColor(
switchCase(
expression2, literal(ColorUtils.colorToRgbaString(Color.GREEN)),
literal(ColorUtils.colorToRgbaString(Color.RED))
)
switchCase(
expression2, literal(ColorUtils.colorToRgbaString(Color.GREEN)),
literal(ColorUtils.colorToRgbaString(Color.RED))
)
));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
.isEmpty());
layer.setProperties(circleColor(
switchCase(
expression3, literal(ColorUtils.colorToRgbaString(Color.GREEN)),
literal(ColorUtils.colorToRgbaString(Color.RED))
)
switchCase(
expression3, literal(ColorUtils.colorToRgbaString(Color.GREEN)),
literal(ColorUtils.colorToRgbaString(Color.RED))
)
));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
.isEmpty());
});
}
@@ -294,18 +291,18 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry("test")
formatEntry("test")
);
layer.setProperties(textField(expression));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
.isEmpty());
assertNull(layer.getTextField().getExpression());
assertEquals(new Formatted(new FormattedSection("test")), layer.getTextField().getValue());
});
@@ -317,18 +314,18 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry("test", formatFontScale(1.75))
formatEntry("test", formatFontScale(1.75))
);
layer.setProperties(textField(expression));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
.isEmpty());
assertNull(layer.getTextField().getExpression());
assertEquals(new Formatted(new FormattedSection("test", 1.75)), layer.getTextField().getValue());
});
@@ -340,26 +337,26 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry(
literal("test"),
formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
)
formatEntry(
literal("test"),
formatTextFont(new String[]{"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
)
);
layer.setProperties(textField(expression));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
);
assertNull(layer.getTextField().getExpression());
assertEquals(new Formatted(
new FormattedSection("test",
new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
new FormattedSection("test",
new String[]{"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
), layer.getTextField().getValue());
});
}
@@ -370,25 +367,25 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry(
literal("test"),
formatTextColor(literal("yellow"))
)
formatEntry(
literal("test"),
formatTextColor(literal("yellow"))
)
);
layer.setProperties(textField(expression));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
);
assertNull(layer.getTextField().getExpression());
assertEquals(new Formatted(
new FormattedSection("test", null, null, "rgba(255,255,0,1)")
new FormattedSection("test", null, null, "rgba(255,255,0,1)")
), layer.getTextField().getValue());
});
}
@@ -399,30 +396,30 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry(
"test",
formatFontScale(0.5),
formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"}),
formatTextColor(rgb(126, 0, 0))
)
formatEntry(
"test",
formatFontScale(0.5),
formatTextFont(new String[]{"DIN Offc Pro Regular", "Arial Unicode MS Regular"}),
formatTextColor(rgb(126, 0, 0))
)
);
layer.setProperties(textField(expression));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
);
assertNull(layer.getTextField().getExpression());
assertEquals(new Formatted(
new FormattedSection("test",
0.5,
new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"},
"rgba(126,0,0,1)")
new FormattedSection("test",
0.5,
new String[]{"DIN Offc Pro Regular", "Arial Unicode MS Regular"},
"rgba(126,0,0,1)")
), layer.getTextField().getValue());
});
}
@@ -433,31 +430,33 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry(
"test",
formatFontScale(1.5),
formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
),
formatEntry("\ntest2", formatFontScale(2), formatTextColor(Color.BLUE)),
formatEntry("\ntest3", formatFontScale(2.5), formatTextColor(toColor(literal("rgba(0, 128, 255, 0.5)"))))
formatEntry(
"test",
formatFontScale(1.5),
formatTextFont(new String[]{"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
),
formatEntry("\ntest2", formatFontScale(2), formatTextColor(Color.BLUE)),
formatEntry("\ntest3", formatFontScale(2.5),
formatTextColor(toColor(literal("rgba(0, 128, 255, 0.5)"))))
);
layer.setProperties(textField(expression));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty()
);
assertNull(layer.getTextField().getExpression());
assertEquals(new Formatted(
new FormattedSection("test", 1.5,
new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"}),
new FormattedSection("\ntest2", 2.0, null, "rgba(0,0,255,1)"),
new FormattedSection("\ntest3", 2.5, null, "rgba(0,128,255,0.5)")
new FormattedSection("test", 1.5,
new String[]{"DIN Offc Pro Regular", "Arial Unicode MS Regular"}),
new FormattedSection("\ntest2", 2.0, null, "rgba(0,0,255,1)"),
new FormattedSection("\ntest3", 2.5, null, "rgba(0,128,255,0.5)")
), layer.getTextField().getValue());
});
}
@@ -476,18 +475,18 @@ public class ExpressionTest extends EspressoTest {
mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry(
get("test_property"),
Expression.FormatOption.formatFontScale(number(get("test_property_number"))),
formatTextFont(new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"}),
formatTextColor(toColor(get("test_property_color")))
)
formatEntry(
get("test_property"),
Expression.FormatOption.formatFontScale(number(get("test_property_number"))),
formatTextFont(new String[]{"Arial Unicode MS Regular", "DIN Offc Pro Regular"}),
formatTextColor(toColor(get("test_property_color")))
)
);
layer.setProperties(textField(expression));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
.isEmpty());
assertEquals(expression, layer.getTextField().getExpression());
assertNull(layer.getTextField().getValue());
});
@@ -507,19 +506,19 @@ public class ExpressionTest extends EspressoTest {
mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry(
get("test_property"),
formatFontScale(1.25),
formatTextFont(new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"}),
formatTextColor(toColor(get("test_property_color")))
),
formatEntry("\ntest2", formatFontScale(2))
formatEntry(
get("test_property"),
formatFontScale(1.25),
formatTextFont(new String[]{"Arial Unicode MS Regular", "DIN Offc Pro Regular"}),
formatTextColor(toColor(get("test_property_color")))
),
formatEntry("\ntest2", formatFontScale(2))
);
layer.setProperties(textField(expression), textColor("rgba(128, 0, 0, 1)"));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
.isEmpty());
assertEquals(expression, layer.getTextField().getExpression());
assertNull(layer.getTextField().getValue());
});
@@ -531,7 +530,7 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
@@ -539,10 +538,10 @@ public class ExpressionTest extends EspressoTest {
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
.isEmpty());
assertNull(layer.getTextField().getExpression());
assertEquals(new Formatted(
new FormattedSection("test")), layer.getTextField().getValue());
new FormattedSection("test")), layer.getTextField().getValue());
});
}
@@ -552,20 +551,21 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
Formatted formatted = new Formatted(
new FormattedSection("test", 1.5),
new FormattedSection("\ntest", 0.5, new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"}),
new FormattedSection("test", null, null, "rgba(0,255,0,1)")
new FormattedSection("test", 1.5),
new FormattedSection("\ntest", 0.5, new String[]{"Arial Unicode MS Regular",
"DIN Offc Pro Regular"}),
new FormattedSection("test", null, null, "rgba(0,255,0,1)")
);
layer.setProperties(textField(formatted), textColor("rgba(128,0,0,1)"));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
.isEmpty());
assertNull(layer.getTextField().getExpression());
assertEquals(formatted, layer.getTextField().getValue());
});
@@ -577,19 +577,19 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
layer.setProperties(
textField(
numberFormat(12.345, locale("en-US"), currency("USD"))
)
textField(
numberFormat(12.345, locale("en-US"), currency("USD"))
)
);
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
);
assertNull(layer.getTextField().getExpression());
assertEquals("$12.35", layer.getTextField().getValue().getFormattedSections()[0].getText());
@@ -602,19 +602,19 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
layer.setProperties(
textField(
numberFormat(12.34567890, maxFractionDigits(5), minFractionDigits(0))
)
textField(
numberFormat(12.34567890, maxFractionDigits(5), minFractionDigits(0))
)
);
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
);
assertNull(layer.getTextField().getExpression());
assertEquals("12.34568", layer.getTextField().getValue().getFormattedSections()[0].getText());
@@ -627,19 +627,19 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
layer.setProperties(
textField(
numberFormat(12.0000001, maxFractionDigits(5), minFractionDigits(0))
)
textField(
numberFormat(12.0000001, maxFractionDigits(5), minFractionDigits(0))
)
);
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
);
assertNull(layer.getTextField().getExpression());
assertEquals("12", layer.getTextField().getValue().getFormattedSections()[0].getText());
@@ -652,19 +652,20 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
layer.setProperties(
textField(
numberFormat(12.0000001, locale("nl-BE"), maxFractionDigits(5), minFractionDigits(1))
)
textField(
numberFormat(12.0000001, locale("nl-BE"), maxFractionDigits(5),
minFractionDigits(1))
)
);
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
);
assertNull(layer.getTextField().getExpression());
assertEquals("12,0", layer.getTextField().getValue().getFormattedSections()[0].getText());
@@ -688,17 +689,17 @@ public class ExpressionTest extends EspressoTest {
mapboxMap.getStyle().addLayer(layer);
Expression numberFormatExpression = numberFormat(
number(number(get("number_value"))),
locale(string(get("locale_value"))),
maxFractionDigits(number(get("max_value"))),
minFractionDigits(number(get("min_value")))
number(number(get("number_value"))),
locale(string(get("locale_value"))),
maxFractionDigits(number(get("max_value"))),
minFractionDigits(number(get("min_value")))
);
layer.setProperties(textField(numberFormatExpression));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
);
assertNotNull(layer.getTextField().getExpression());
@@ -706,10 +707,10 @@ public class ExpressionTest extends EspressoTest {
// Expressions evaluated to string are wrapped by a format expression, take array index 1 to get original
Object[] returnExpression = (Object[]) layer.getTextField().getExpression().toArray()[1];
Object[] setExpression = numberFormatExpression.toArray();
assertEquals("Number format should match",returnExpression[0], setExpression[0]);
assertEquals("Number format should match", returnExpression[0], setExpression[0]);
assertArrayEquals("Get value expression should match",
(Object[]) returnExpression[1],
(Object[]) setExpression[1]
(Object[]) returnExpression[1],
(Object[]) setExpression[1]
);
// number format objects
@@ -717,18 +718,18 @@ public class ExpressionTest extends EspressoTest {
HashMap<String, Object> setMap = (HashMap<String, Object>) returnExpression[2];
assertArrayEquals("Number format min fraction digits should match ",
(Object[]) returnMap.get("min-fraction-digits"),
(Object[]) setMap.get("min-fraction-digits")
(Object[]) returnMap.get("min-fraction-digits"),
(Object[]) setMap.get("min-fraction-digits")
);
assertArrayEquals("Number format max fraction digits should match ",
(Object[]) returnMap.get("max-fraction-digits"),
(Object[]) setMap.get("max-fraction-digits")
(Object[]) returnMap.get("max-fraction-digits"),
(Object[]) setMap.get("max-fraction-digits")
);
assertArrayEquals("Number format min fraction digits should match ",
(Object[]) returnMap.get("locale"),
(Object[]) setMap.get("locale")
(Object[]) returnMap.get("locale"),
(Object[]) setMap.get("locale")
);
});
@@ -743,16 +744,16 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle().addSource(
new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()))
new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()))
);
CircleLayer layer = new CircleLayer("layer", "source");
mapboxMap.getStyle().addLayer(layer);
Expression input = interpolate(
exponential(0.5f), zoom(),
stop(-0.1, color(Color.RED)),
stop(0, color(Color.BLUE))
Expression input = interpolate(
exponential(0.5f), zoom(),
stop(-0.1, color(Color.RED)),
stop(0, color(Color.BLUE))
);
layer.setProperties(circleColor(input));
@@ -766,21 +767,17 @@ public class ExpressionTest extends EspressoTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
// Add a source
Source source;
try {
source = new GeoJsonSource("amsterdam-parks-source",
ResourceUtils.readRawResource(rule.getActivity(), R.raw.amsterdam));
mapboxMap.getStyle().addSource(source);
} catch (IOException ioException) {
return;
}
source = new GeoJsonSource("amsterdam-parks-source",
ResourceUtils.readRawResource(rule.getActivity(), R.raw.amsterdam));
mapboxMap.getStyle().addSource(source);
// Add a fill layer
mapboxMap.getStyle().addLayer(layer = new FillLayer("amsterdam-parks-layer", source.getId())
.withProperties(
fillColor(rgba(0.0f, 0.0f, 0.0f, 0.5f)),
fillOutlineColor(rgb(0, 0, 255)),
fillAntialias(true)
)
.withProperties(
fillColor(rgba(0.0f, 0.0f, 0.0f, 0.5f)),
fillOutlineColor(rgb(0, 0, 255)),
fillAntialias(true)
)
);
});
}

View File

@@ -5,7 +5,7 @@ package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
@@ -57,7 +57,7 @@ import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for FillExtrusionLayer
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class FillExtrusionLayerTest extends BaseLayerTest {
private FillExtrusionLayer layer;

View File

@@ -5,7 +5,7 @@ package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
@@ -57,7 +57,7 @@ import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for FillLayer
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class FillLayerTest extends BaseLayerTest {
private FillLayer layer;

View File

@@ -1,11 +1,5 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.view.View;
import androidx.annotation.RawRes;
import androidx.test.espresso.ViewAction;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection;
import com.mapbox.geojson.Point;
@@ -23,11 +17,14 @@ import org.hamcrest.Matcher;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.IOException;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
import timber.log.Timber;
import androidx.annotation.RawRes;
import androidx.test.espresso.ViewAction;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static org.junit.Assert.assertEquals;
@@ -35,7 +32,7 @@ import static org.junit.Assert.assertEquals;
/**
* Tests for {@link GeoJsonSource}
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class GeoJsonSourceTests extends EspressoTest {
@Test
@@ -43,12 +40,8 @@ public class GeoJsonSourceTests extends EspressoTest {
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
GeoJsonSource source = null;
try {
source = new GeoJsonSource("source", FeatureCollection
.fromJson(ResourceUtils.readRawResource(rule.getActivity(), R.raw.test_feature_collection)));
} catch (IOException exception) {
Timber.e(exception);
}
source = new GeoJsonSource("source", FeatureCollection
.fromJson(ResourceUtils.readRawResource(rule.getActivity(), R.raw.test_feature_collection)));
mapboxMap.getStyle().addSource(source);
mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
});
@@ -69,12 +62,8 @@ public class GeoJsonSourceTests extends EspressoTest {
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
GeoJsonSource source = null;
try {
source = new GeoJsonSource("source",
ResourceUtils.readRawResource(rule.getActivity(), R.raw.test_feature_properties));
} catch (IOException exception) {
Timber.e(exception);
}
source = new GeoJsonSource("source",
ResourceUtils.readRawResource(rule.getActivity(), R.raw.test_feature_properties));
mapboxMap.getStyle().addSource(source);
mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
});
@@ -90,17 +79,13 @@ public class GeoJsonSourceTests extends EspressoTest {
source.setGeoJson(Point.fromLngLat(0, 0));
source.setGeoJson(Point.fromLngLat(-25, -25));
try {
source.setGeoJson(ResourceUtils.readRawResource(rule.getActivity(), R.raw.test_feature_properties));
} catch (IOException exception) {
Timber.e(exception);
}
source.setGeoJson(ResourceUtils.readRawResource(rule.getActivity(), R.raw.test_feature_properties));
source.setGeoJson(Point.fromLngLat(20, 55));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertEquals(1, mapboxMap.queryRenderedFeatures(
mapboxMap.getProjection().toScreenLocation(
new LatLng(55, 20)), "layer").size());
mapboxMap.getProjection().toScreenLocation(
new LatLng(55, 20)), "layer").size());
});
}
@@ -163,11 +148,7 @@ public class GeoJsonSourceTests extends EspressoTest {
Layer layer = new CircleLayer("layer", source.getId());
mapboxMap.getStyle().addLayer(layer);
try {
source.setGeoJson(Feature.fromJson(ResourceUtils.readRawResource(rule.getActivity(), resource)));
} catch (IOException exception) {
Timber.e(exception);
}
source.setGeoJson(Feature.fromJson(ResourceUtils.readRawResource(rule.getActivity(), resource)));
mapboxMap.getStyle().removeLayer(layer);
mapboxMap.getStyle().removeSource(source);

View File

@@ -3,7 +3,7 @@
package com.mapbox.mapboxsdk.testapp.style;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
@@ -47,7 +47,7 @@ import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for HeatmapLayer
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class HeatmapLayerTest extends BaseLayerTest {
private HeatmapLayer layer;

View File

@@ -5,7 +5,7 @@ package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
@@ -38,7 +38,7 @@ import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for HillshadeLayer
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class HillshadeLayerTest extends BaseLayerTest {
private HillshadeLayer layer;

View File

@@ -2,7 +2,7 @@ package com.mapbox.mapboxsdk.testapp.style
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
@@ -15,7 +15,7 @@ import java.util.*
/**
* CRUD tests around Image
*/
@RunWith(AndroidJUnit4::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class ImageTest : EspressoTest() {
companion object {

View File

@@ -5,7 +5,7 @@ import android.view.View;
import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
@@ -35,7 +35,7 @@ import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class LightTest extends BaseTest {
private Light light;

View File

@@ -5,7 +5,7 @@ package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
@@ -66,7 +66,7 @@ import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for LineLayer
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class LineLayerTest extends BaseLayerTest {
private LineLayer layer;

View File

@@ -3,7 +3,7 @@
package com.mapbox.mapboxsdk.testapp.style;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
@@ -38,7 +38,7 @@ import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for RasterLayer
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class RasterLayerTest extends BaseLayerTest {
private RasterLayer layer;

View File

@@ -6,7 +6,7 @@ import android.view.View;
import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
@@ -47,7 +47,7 @@ import static org.junit.Assert.fail;
/**
* Basic smoke tests for Layer and Source
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class RuntimeStyleTests extends EspressoTest {
@Test

View File

@@ -1,6 +1,6 @@
package com.mapbox.mapboxsdk.testapp.style;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.testapp.activity.BaseTest;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTimingTestActivity;
@@ -11,7 +11,7 @@ import org.junit.runner.RunWith;
/**
* Basic smoke tests for adding Layer and Source as early as possible (in onCreate)
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class RuntimeStyleTimingTests extends BaseTest {
@Override

View File

@@ -5,7 +5,7 @@ package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
@@ -120,7 +120,7 @@ import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for SymbolLayer
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class SymbolLayerTest extends BaseLayerTest {
private SymbolLayer layer;

View File

@@ -12,7 +12,7 @@ package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
@@ -53,7 +53,7 @@ import java.util.List;
/**
* Basic smoke tests for <%- camelize(type) %>Layer
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class <%- camelize(type) %>LayerTest extends BaseLayerTest {
private <%- camelize(type) %>Layer layer;

View File

@@ -6,7 +6,7 @@ package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import android.view.View;
import com.mapbox.mapboxsdk.style.light.Light;
@@ -38,7 +38,7 @@ import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class LightTest extends BaseTest {
private Light light;

View File

@@ -1,6 +1,6 @@
package com.mapbox.mapboxsdk.utils;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
@@ -10,7 +10,7 @@ import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class FontUtilsTest {
@Test

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapbox.mapboxsdk.testapp">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

View File

@@ -51,16 +51,14 @@ class DynamicMarkerChangeActivity : AppCompatActivity() {
val fab = findViewById<FloatingActionButton>(R.id.fab)
fab.setColorFilter(ContextCompat.getColor(this, R.color.primary))
fab.setOnClickListener { view: View? ->
if (mapboxMap != null) {
updateMarker()
}
updateMarker()
}
}
private fun updateMarker() {
// update model
val first = mapView!!.tag as Boolean
mapView!!.tag = !first
val first = mapView.tag as Boolean
mapView.tag = !first
// update marker
marker!!.position =
@@ -68,15 +66,19 @@ class DynamicMarkerChangeActivity : AppCompatActivity() {
marker!!.icon = IconUtils.drawableToIcon(
this,
R.drawable.ic_stars,
if (first) ResourcesCompat.getColor(
resources,
R.color.blueAccent,
theme
) else ResourcesCompat.getColor(
resources,
R.color.redAccent,
theme
)
if (first) {
ResourcesCompat.getColor(
resources,
R.color.blueAccent,
theme
)
} else {
ResourcesCompat.getColor(
resources,
R.color.redAccent,
theme
)
}
)
marker!!.title =
if (first) getString(R.string.dynamic_marker_chelsea_title) else getString(R.string.dynamic_marker_arsenal_title)
@@ -86,37 +88,37 @@ class DynamicMarkerChangeActivity : AppCompatActivity() {
override fun onStart() {
super.onStart()
mapView!!.onStart()
mapView.onStart()
}
override fun onResume() {
super.onResume()
mapView!!.onResume()
mapView.onResume()
}
override fun onPause() {
super.onPause()
mapView!!.onPause()
mapView.onPause()
}
override fun onStop() {
super.onStop()
mapView!!.onStop()
mapView.onStop()
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mapView!!.onSaveInstanceState(outState)
mapView.onSaveInstanceState(outState)
}
override fun onDestroy() {
super.onDestroy()
mapView!!.onDestroy()
mapView.onDestroy()
}
override fun onLowMemory() {
super.onLowMemory()
mapView!!.onLowMemory()
mapView.onLowMemory()
}
companion object {

View File

@@ -63,21 +63,25 @@ class QueryRenderedFeaturesBoxCountActivity : AppCompatActivity() {
private fun debugOutput(features: List<Feature>) {
Timber.i("Got %s features", features.size)
for (feature in features) {
if (feature != null) {
Timber.i(
"Got feature %s with %s properties and Geometry %s",
feature.id(),
if (feature.properties() != null) feature.properties()!!
.entrySet().size else "<null>",
if (feature.geometry() != null) feature.geometry()!!::class.java.simpleName else "<null>"
)
Timber.i(
"Got feature %s with %s properties and Geometry %s",
feature.id(),
if (feature.properties() != null) {
for ((key, value) in feature.properties()!!.entrySet()) {
Timber.i("Prop %s - %s", key, value)
}
feature.properties()!!
.entrySet().size
} else {
"<null>"
},
if (feature.geometry() != null) {
feature.geometry()!!::class.java.simpleName
} else {
"<null>"
}
)
if (feature.properties() != null) {
for ((key, value) in feature.properties()!!.entrySet()) {
Timber.i("Prop %s - %s", key, value)
}
} else {
Timber.i("Got 0 features")
}
}
}

View File

@@ -1,5 +1,3 @@
package com.mapbox.mapboxsdk.testapp.activity.feature
import android.graphics.Color
@@ -78,21 +76,25 @@ class QueryRenderedFeaturesPropertiesActivity : AppCompatActivity() {
private fun debugOutput(features: List<Feature>) {
Timber.i("Got %s features", features.size)
for (feature in features) {
if (feature != null) {
Timber.i(
"Got feature %s with %s properties and Geometry %s",
feature.id(),
if (feature.properties() != null) feature.properties()!!
.entrySet().size else "<null>",
if (feature.geometry() != null) feature.geometry()!!::class.java.simpleName else "<null>"
)
Timber.i(
"Got feature %s with %s properties and Geometry %s",
feature.id(),
if (feature.properties() != null) {
for ((key, value) in feature.properties()!!.entrySet()) {
Timber.i("Prop %s - %s", key, value)
}
feature.properties()!!
.entrySet().size
} else {
"<null>"
},
if (feature.geometry() != null) {
feature.geometry()!!::class.java.simpleName
} else {
"<null>"
}
)
if (feature.properties() != null) {
for ((key, value) in feature.properties()!!.entrySet()) {
Timber.i("Prop %s - %s", key, value)
}
} else {
Timber.i("Got NULL feature")
}
}
}

View File

@@ -96,7 +96,7 @@ class NestedViewPagerActivity : AppCompatActivity() {
}
}
class MapPagerAdapter(private val context: Context, fm: androidx.fragment.app.FragmentManager?) : androidx.fragment.app.FragmentStatePagerAdapter(fm) {
class MapPagerAdapter(private val context: Context, fm: androidx.fragment.app.FragmentManager) : androidx.fragment.app.FragmentStatePagerAdapter(fm) {
override fun getItem(position: Int): androidx.fragment.app.Fragment {
val options = MapboxMapOptions.createFromAttributes(context)
@@ -151,9 +151,7 @@ class NestedViewPagerActivity : AppCompatActivity() {
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val textView = TextView(inflater.context)
textView.text = "This is an empty Fragment"
return textView
return TextView(inflater.context)
}
}
}

View File

@@ -41,7 +41,7 @@ class ViewPagerActivity : AppCompatActivity() {
return NUM_ITEMS
}
override fun getItem(position: Int): androidx.fragment.app.Fragment? {
override fun getItem(position: Int): androidx.fragment.app.Fragment {
val options = MapboxMapOptions.createFromAttributes(context)
options.textureMode(true)
options.camera(

View File

@@ -27,7 +27,6 @@ import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.testapp.R
import java.util.ArrayList
/**
* This activity shows how to customize the LocationComponent's pulsing circle.
@@ -244,9 +243,9 @@ class CustomizedLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyC
pulsingCircleDurationButton!!.text = selectedMode
if (selectedMode.contentEquals(
String.format(
"%sms",
DEFAULT_LOCATION_CIRCLE_PULSE_DURATION_MS.toString()
)
"%sms",
DEFAULT_LOCATION_CIRCLE_PULSE_DURATION_MS.toString()
)
)
) {
LOCATION_CIRCLE_PULSE_DURATION = DEFAULT_LOCATION_CIRCLE_PULSE_DURATION_MS
@@ -256,9 +255,9 @@ class CustomizedLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyC
)
} else if (selectedMode.contentEquals(
String.format(
"%sms",
SECOND_LOCATION_CIRCLE_PULSE_DURATION_MS.toString()
)
"%sms",
SECOND_LOCATION_CIRCLE_PULSE_DURATION_MS.toString()
)
)
) {
LOCATION_CIRCLE_PULSE_DURATION = SECOND_LOCATION_CIRCLE_PULSE_DURATION_MS
@@ -268,9 +267,9 @@ class CustomizedLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyC
)
} else if (selectedMode.contentEquals(
String.format(
"%sms",
THIRD_LOCATION_CIRCLE_PULSE_DURATION_MS.toString()
)
"%sms",
THIRD_LOCATION_CIRCLE_PULSE_DURATION_MS.toString()
)
)
) {
LOCATION_CIRCLE_PULSE_DURATION = THIRD_LOCATION_CIRCLE_PULSE_DURATION_MS

View File

@@ -31,7 +31,6 @@ import com.mapbox.mapboxsdk.maps.MapboxMap.CancelableCallback
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.testapp.R
import java.util.ArrayList
class LocationModesActivity :
AppCompatActivity(),
@@ -228,9 +227,14 @@ class LocationModesActivity :
}
mapboxMap!!.getStyle { style: Style ->
val styleUrl =
if (Style.getPredefinedStyle("Bright") == style.uri) Style.getPredefinedStyle("Bright") else Style.getPredefinedStyle(
"Pastel"
Style.getPredefinedStyle(
if (Style.getPredefinedStyle("Bright") == style.uri) {
"Bright"
} else {
"Pastel"
}
)
mapboxMap!!.setStyle(Style.Builder().fromUri(styleUrl))
}
}
@@ -253,7 +257,7 @@ class LocationModesActivity :
if (locationComponent == null) {
return
}
val rectF = RectF(0f, 0f, mapView!!.width / 2f, mapView!!.height / 2f)
val rectF = RectF(0f, 0f, mapView.width / 2f, mapView.height / 2f)
protectedGestureArea!!.layoutParams.height = rectF.bottom.toInt()
protectedGestureArea!!.layoutParams.width = rectF.right.toInt()
val options = locationComponent!!
@@ -268,28 +272,28 @@ class LocationModesActivity :
override fun onStart() {
super.onStart()
mapView!!.onStart()
mapView.onStart()
}
override fun onResume() {
super.onResume()
mapView!!.onResume()
mapView.onResume()
}
override fun onPause() {
super.onPause()
mapView!!.onPause()
mapView.onPause()
}
override fun onStop() {
super.onStop()
mapView!!.onStop()
mapView.onStop()
}
@SuppressLint("MissingPermission")
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mapView!!.onSaveInstanceState(outState)
mapView.onSaveInstanceState(outState)
outState.putInt(SAVED_STATE_CAMERA, cameraMode)
outState.putInt(SAVED_STATE_RENDER, renderMode)
if (locationComponent != null) {
@@ -299,12 +303,12 @@ class LocationModesActivity :
override fun onDestroy() {
super.onDestroy()
mapView!!.onDestroy()
mapView.onDestroy()
}
override fun onLowMemory() {
super.onLowMemory()
mapView!!.onLowMemory()
mapView.onLowMemory()
}
override fun onLocationComponentClick() {
@@ -326,7 +330,7 @@ class LocationModesActivity :
listPopup.anchorView = locationModeBtn
listPopup.setOnItemClickListener { parent: AdapterView<*>?, itemView: View?, position: Int, id: Long ->
val selectedMode = modes[position]
locationModeBtn!!.text = selectedMode
locationModeBtn.text = selectedMode
if (selectedMode.contentEquals("Normal")) {
setRendererMode(RenderMode.NORMAL)
} else if (selectedMode.contentEquals("Compass")) {
@@ -339,15 +343,16 @@ class LocationModesActivity :
listPopup.show()
}
@SuppressLint("SetTextI18n")
private fun setRendererMode(@RenderMode.Mode mode: Int) {
renderMode = mode
locationComponent!!.renderMode = mode
if (mode == RenderMode.NORMAL) {
locationModeBtn!!.text = "Normal"
locationModeBtn.text = "Normal"
} else if (mode == RenderMode.COMPASS) {
locationModeBtn!!.text = "Compass"
locationModeBtn.text = "Compass"
} else if (mode == RenderMode.GPS) {
locationModeBtn!!.text = "Gps"
locationModeBtn.text = "Gps"
}
}
@@ -370,7 +375,7 @@ class LocationModesActivity :
listPopup.anchorView = locationTrackingBtn
listPopup.setOnItemClickListener { parent: AdapterView<*>?, itemView: View?, position: Int, id: Long ->
val selectedTrackingType = trackingTypes[position]
locationTrackingBtn!!.text = selectedTrackingType
locationTrackingBtn.text = selectedTrackingType
if (selectedTrackingType.contentEquals("None")) {
setCameraTrackingMode(CameraMode.NONE)
} else if (selectedTrackingType.contentEquals("None Compass")) {
@@ -418,26 +423,28 @@ class LocationModesActivity :
)
}
@SuppressLint("SetTextI18n")
override fun onCameraTrackingDismissed() {
locationTrackingBtn!!.text = "None"
locationTrackingBtn.text = "None"
}
@SuppressLint("SetTextI18n")
override fun onCameraTrackingChanged(currentMode: Int) {
cameraMode = currentMode
if (currentMode == CameraMode.NONE) {
locationTrackingBtn!!.text = "None"
locationTrackingBtn.text = "None"
} else if (currentMode == CameraMode.NONE_COMPASS) {
locationTrackingBtn!!.text = "None Compass"
locationTrackingBtn.text = "None Compass"
} else if (currentMode == CameraMode.NONE_GPS) {
locationTrackingBtn!!.text = "None GPS"
locationTrackingBtn.text = "None GPS"
} else if (currentMode == CameraMode.TRACKING) {
locationTrackingBtn!!.text = "Tracking"
locationTrackingBtn.text = "Tracking"
} else if (currentMode == CameraMode.TRACKING_COMPASS) {
locationTrackingBtn!!.text = "Tracking Compass"
locationTrackingBtn.text = "Tracking Compass"
} else if (currentMode == CameraMode.TRACKING_GPS) {
locationTrackingBtn!!.text = "Tracking GPS"
locationTrackingBtn.text = "Tracking GPS"
} else if (currentMode == CameraMode.TRACKING_GPS_NORTH) {
locationTrackingBtn!!.text = "Tracking GPS North"
locationTrackingBtn.text = "Tracking GPS North"
}
}

View File

@@ -56,9 +56,9 @@ class OverlayMapActivity : AppCompatActivity() {
mapView.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle?, outPersistentState: PersistableBundle?) {
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
super.onSaveInstanceState(outState, outPersistentState)
outState?.let {
outState.let {
mapView.onSaveInstanceState(it)
}
}

View File

@@ -40,7 +40,7 @@ class VisibilityChangeActivity : AppCompatActivity() {
override fun onStart() {
super.onStart()
mapView!!.onStart()
mapView.onStart()
handler.post(
VisibilityRunner(
mapView,
@@ -52,7 +52,7 @@ class VisibilityChangeActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()
mapView!!.onResume()
mapView.onResume()
}
private class VisibilityRunner internal constructor(
@@ -85,43 +85,43 @@ class VisibilityChangeActivity : AppCompatActivity() {
}
private val visibilityForStep: Int
private get() = if (currentStep == 1 || currentStep == 5) View.GONE else View.INVISIBLE
get() = if (currentStep == 1 || currentStep == 5) View.GONE else View.INVISIBLE
private val isFifthOrSeventhStep: Boolean
private get() = currentStep == 5 || currentStep == 7
get() = currentStep == 5 || currentStep == 7
private val isFirstOrThirdStep: Boolean
private get() = currentStep == 1 || currentStep == 3
get() = currentStep == 1 || currentStep == 3
private val isEvenStep: Boolean
private get() = currentStep == 0 || currentStep % 2 == 0
get() = currentStep == 0 || currentStep % 2 == 0
private val isViewHiearchyReady: Boolean
private get() = mapView != null && viewParent != null
get() = mapView != null && viewParent != null
}
override fun onPause() {
super.onPause()
mapView!!.onPause()
mapView.onPause()
}
override fun onStop() {
super.onStop()
if (runnable != null) {
handler.removeCallbacks(runnable)
runnable?.let {
handler.removeCallbacks(it)
runnable = null
}
mapView!!.onStop()
mapView.onStop()
}
override fun onLowMemory() {
super.onLowMemory()
mapView!!.onLowMemory()
mapView.onLowMemory()
}
override fun onDestroy() {
super.onDestroy()
mapView!!.onDestroy()
mapView.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mapView!!.onSaveInstanceState(outState)
mapView.onSaveInstanceState(outState)
}
}

View File

@@ -20,12 +20,8 @@ import timber.log.Timber
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.lang.Exception
import java.lang.RuntimeException
import java.lang.ref.WeakReference
import java.nio.charset.Charset
import java.util.ArrayList
import java.util.HashMap
/**
* Activity that generates map snapshots based on the node render test suite.
@@ -86,13 +82,15 @@ class RenderTestActivity : AppCompatActivity() {
protected override fun doInBackground(vararg p0: Void?): List<RenderTestDefinition>? {
val definitions: MutableList<RenderTestDefinition> = ArrayList()
val assetManager = renderTestActivityWeakReference.get()!!.assets
var categories = arrayOfNulls<String>(0)
try {
categories = assetManager.list(RENDER_TEST_BASE_PATH)
} catch (exception: IOException) {
Timber.e(exception)
}
for (counter in categories.indices.reversed()) {
val categories =
try {
assetManager.list(RENDER_TEST_BASE_PATH)
} catch (exception: IOException) {
Timber.e(exception)
throw exception
}
for (counter in categories!!.indices.reversed()) {
try {
val tests = assetManager.list(
String.format(
@@ -101,7 +99,7 @@ class RenderTestActivity : AppCompatActivity() {
categories[counter]
)
)
for (test in tests) {
for (test in tests!!) {
val styleJson = loadStyleJson(assetManager, categories[counter], test)
val renderTestStyleDefinition = Gson()
.fromJson(styleJson, RenderTestStyleDefinition::class.java)

View File

@@ -6,6 +6,7 @@ import android.view.ViewTreeObserver.OnGlobalLayoutListener
import android.widget.GridLayout
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.res.ResourcesCompat
import com.google.gson.JsonObject
import com.google.gson.JsonPrimitive
import com.mapbox.geojson.Feature
@@ -19,14 +20,18 @@ import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.snapshotter.MapSnapshot
import com.mapbox.mapboxsdk.snapshotter.MapSnapshotter
import com.mapbox.mapboxsdk.style.expressions.Expression
import com.mapbox.mapboxsdk.style.layers.*
import com.mapbox.mapboxsdk.style.layers.Property
import com.mapbox.mapboxsdk.style.layers.PropertyFactory
import com.mapbox.mapboxsdk.style.layers.RasterLayer
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
import com.mapbox.mapboxsdk.style.sources.RasterSource
import com.mapbox.mapboxsdk.style.sources.Source
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.utils.BitmapUtils
import timber.log.Timber
import java.util.*
import java.util.Objects
import java.util.Random
/**
* Test activity showing how to use a the [com.mapbox.mapboxsdk.snapshotter.MapSnapshotter]
@@ -52,8 +57,8 @@ class MapSnapshotterActivity : AppCompatActivity() {
private fun addSnapshots() {
Timber.i("Creating snapshotters")
for (row in 0 until grid!!.rowCount) {
for (column in 0 until grid!!.columnCount) {
for (row in 0 until grid.rowCount) {
for (column in 0 until grid.columnCount) {
startSnapShot(row, column)
}
}
@@ -63,15 +68,19 @@ class MapSnapshotterActivity : AppCompatActivity() {
// Optionally the style
val builder = Style.Builder()
.fromUri(
if ((column + row) % 2 == 0) Style.getPredefinedStyle("Streets") else Style.getPredefinedStyle(
"Pastel"
Style.getPredefinedStyle(
if ((column + row) % 2 == 0) {
"Streets"
} else {
"Pastel"
}
)
)
// Define the dimensions
val options = MapSnapshotter.Options(
grid!!.measuredWidth / grid!!.columnCount,
grid!!.measuredHeight / grid!!.rowCount
grid.measuredWidth / grid.columnCount,
grid.measuredHeight / grid.rowCount
) // Optionally the pixel ratio
.withPixelRatio(1f)
.withLocalIdeographFontFamily(MapboxConstants.DEFAULT_FONT)
@@ -103,11 +112,15 @@ class MapSnapshotterActivity : AppCompatActivity() {
options.withCameraPosition(
CameraPosition.Builder()
.target(
if (options.region != null) options.region!!.center else LatLng(
randomInRange(-80f, 80f).toDouble(),
randomInRange(-160f, 160f)
.toDouble()
)
if (options.region != null) {
options.region!!.center
} else {
LatLng(
randomInRange(-80f, 80f).toDouble(),
randomInRange(-160f, 160f)
.toDouble()
)
}
)
.bearing(randomInRange(0f, 360f).toDouble())
.tilt(randomInRange(0f, 60f).toDouble())
@@ -122,12 +135,12 @@ class MapSnapshotterActivity : AppCompatActivity() {
RasterSource("my-raster-source", "maptiler://sources/satellite", 512)
builder.withLayerAbove(
RasterLayer("satellite-layer", "my-raster-source"),
if ((column + row) % 2 == 0) "country_1" else "country_label"
"country_1"
)
builder.withSource(source)
} else if (row == 0 && column == 2) {
val carBitmap = BitmapUtils.getBitmapFromDrawable(
resources.getDrawable(R.drawable.ic_directions_car_black)
ResourcesCompat.getDrawable(resources, R.drawable.ic_directions_car_black, null)
)
// marker source
@@ -165,7 +178,7 @@ class MapSnapshotterActivity : AppCompatActivity() {
PropertyFactory.iconAnchor(Property.ICON_ANCHOR_BOTTOM),
PropertyFactory.iconColor(Color.BLUE)
)
builder.withImage("Car", Objects.requireNonNull(carBitmap)!!, false)
builder.withImage("Car", Objects.requireNonNull(carBitmap!!), false)
.withSources(markerSource)
.withLayers(markerSymbolLayer)
options
@@ -192,7 +205,7 @@ class MapSnapshotterActivity : AppCompatActivity() {
override fun onStyleImageMissing(imageName: String) {
val androidIcon =
BitmapUtils.getBitmapFromDrawable(resources.getDrawable(R.drawable.ic_android_2))
BitmapUtils.getBitmapFromDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_android_2, null))
snapshotter.addImage(imageName, androidIcon!!, false)
}
})
@@ -200,7 +213,7 @@ class MapSnapshotterActivity : AppCompatActivity() {
Timber.i("Got the snapshot")
val imageView = ImageView(this@MapSnapshotterActivity)
imageView.setImageBitmap(snapshot.bitmap)
grid!!.addView(
grid.addView(
imageView,
GridLayout.LayoutParams(GridLayout.spec(row), GridLayout.spec(column))
)

View File

@@ -54,39 +54,43 @@ class AnimatedImageSourceActivity : AppCompatActivity(), OnMapReadyCallback {
.withLayer(layer)
) { style: Style? ->
runnable = RefreshImageRunnable(imageSource, handler)
handler.postDelayed(runnable, 100)
runnable?.let {
handler.postDelayed(it, 100)
}
}
}
override fun onStart() {
super.onStart()
mapView!!.onStart()
mapView.onStart()
}
public override fun onResume() {
super.onResume()
mapView!!.onResume()
mapView.onResume()
}
public override fun onPause() {
super.onPause()
mapView!!.onPause()
mapView.onPause()
}
override fun onStop() {
super.onStop()
mapView!!.onStop()
handler.removeCallbacks(runnable)
mapView.onStop()
runnable?.let {
handler.removeCallbacks(it)
}
}
override fun onDestroy() {
super.onDestroy()
mapView!!.onDestroy()
mapView.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mapView!!.onSaveInstanceState(outState)
mapView.onSaveInstanceState(outState)
}
private class RefreshImageRunnable internal constructor(

View File

@@ -159,29 +159,34 @@ class CircleLayerActivity : AppCompatActivity(), View.OnClickListener {
)
val pointCount = Expression.toNumber(Expression.get("point_count"))
circles.setFilter(
if (i == 0) Expression.all(
Expression.has("point_count"),
Expression.gte(
pointCount,
Expression.literal(
layers[i][0]
if (i == 0) {
Expression.all(
Expression.has("point_count"),
Expression.gte(
pointCount,
Expression.literal(
layers[i][0]
)
)
)
} else {
Expression.all(
Expression.has("point_count"),
Expression.gt(
pointCount,
Expression.literal(
layers[i][0]
)
),
Expression.lt(
pointCount,
Expression.literal(
layers[i - 1][0]
)
)
)
) else Expression.all(
Expression.has("point_count"),
Expression.gt(
pointCount,
Expression.literal(
layers[i][0]
)
),
Expression.lt(
pointCount,
Expression.literal(
layers[i - 1][0]
)
)
)
}
)
mapboxMap!!.style!!.addLayer(circles)
}

View File

@@ -120,7 +120,7 @@ class DistanceExpressionActivity : AppCompatActivity() {
mapView.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle?, outPersistentState: PersistableBundle?) {
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
super.onSaveInstanceState(outState, outPersistentState)
outState?.let {
mapView.onSaveInstanceState(it)

View File

@@ -334,7 +334,7 @@ class DraggableMarkerActivity : AppCompatActivity() {
mapView.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle?, outPersistentState: PersistableBundle?) {
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
super.onSaveInstanceState(outState, outPersistentState)
outState?.let {
mapView.onSaveInstanceState(it)

View File

@@ -16,7 +16,9 @@ import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.style.expressions.Expression
import com.mapbox.mapboxsdk.style.layers.*
import com.mapbox.mapboxsdk.style.layers.CircleLayer
import com.mapbox.mapboxsdk.style.layers.PropertyFactory
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
import com.mapbox.mapboxsdk.testapp.R
@@ -24,7 +26,7 @@ import com.mapbox.mapboxsdk.utils.BitmapUtils
import timber.log.Timber
import java.net.URI
import java.net.URISyntaxException
import java.util.*
import java.util.Objects
/**
* Test activity showcasing using a geojson source and visualise that source as a cluster by using filters.
@@ -83,7 +85,7 @@ class GeoJsonClusteringActivity : AppCompatActivity() {
.withImage(
"icon-id",
Objects.requireNonNull(
BitmapUtils.getBitmapFromDrawable(resources.getDrawable(R.drawable.ic_hearing_black_24dp))
BitmapUtils.getBitmapFromDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_hearing_black_24dp, null))
)!!,
true
)
@@ -181,29 +183,27 @@ class GeoJsonClusteringActivity : AppCompatActivity() {
)
val pointCount = Expression.toNumber(Expression.get("point_count"))
circles.setFilter(
if (level == 0) Expression.all(
Expression.has("point_count"),
Expression.gte(
pointCount,
Expression.literal(
layerColors[level][0]
if (level == 0) {
Expression.all(
Expression.has("point_count"),
Expression.gte(
pointCount,
Expression.literal(layerColors[level][0])
)
)
) else Expression.all(
Expression.has("point_count"),
Expression.gt(
pointCount,
Expression.literal(
layerColors[level][0]
)
),
Expression.lt(
pointCount,
Expression.literal(
layerColors[level - 1][0]
} else {
Expression.all(
Expression.has("point_count"),
Expression.gt(
pointCount,
Expression.literal(layerColors[level][0])
),
Expression.lt(
pointCount,
Expression.literal(layerColors[level - 1][0])
)
)
)
}
)
return circles
}
@@ -227,37 +227,37 @@ class GeoJsonClusteringActivity : AppCompatActivity() {
override fun onStart() {
super.onStart()
mapView!!.onStart()
mapView.onStart()
}
override fun onResume() {
super.onResume()
mapView!!.onResume()
mapView.onResume()
}
override fun onPause() {
super.onPause()
mapView!!.onPause()
mapView.onPause()
}
override fun onStop() {
super.onStop()
mapView!!.onStop()
mapView.onStop()
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mapView!!.onSaveInstanceState(outState)
mapView.onSaveInstanceState(outState)
}
override fun onDestroy() {
super.onDestroy()
mapView!!.onDestroy()
mapView.onDestroy()
}
override fun onLowMemory() {
super.onLowMemory()
mapView!!.onLowMemory()
mapView.onLowMemory()
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
@@ -266,6 +266,7 @@ class GeoJsonClusteringActivity : AppCompatActivity() {
onBackPressed()
true
}
else -> super.onOptionsItemSelected(item)
}
}

View File

@@ -68,7 +68,7 @@ class NoStyleActivity : AppCompatActivity() {
mapView.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle?, outPersistentState: PersistableBundle?) {
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
super.onSaveInstanceState(outState, outPersistentState)
outState?.let {
mapView.onSaveInstanceState(it)

View File

@@ -49,7 +49,9 @@ class RealTimeGeoJsonActivity : AppCompatActivity(), OnMapReadyCallback {
// loop refresh geojson
handler = Handler()
runnable = RefreshGeoJsonRunnable(mapboxMap!!, handler!!)
handler!!.postDelayed(runnable, 2000)
runnable?.let {
handler!!.postDelayed(it, 2000)
}
}
}
@@ -71,7 +73,9 @@ class RealTimeGeoJsonActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onStop() {
super.onStop()
mapView!!.onStop()
handler!!.removeCallbacks(runnable)
runnable?.let {
handler!!.removeCallbacks(it)
}
}
override fun onDestroy() {

View File

@@ -13,17 +13,32 @@ import com.mapbox.geojson.Point
import com.mapbox.geojson.Polygon
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.*
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.MapboxMap.CancelableCallback
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.style.expressions.Expression
import com.mapbox.mapboxsdk.style.layers.*
import com.mapbox.mapboxsdk.style.sources.*
import com.mapbox.mapboxsdk.style.layers.CircleLayer
import com.mapbox.mapboxsdk.style.layers.FillLayer
import com.mapbox.mapboxsdk.style.layers.Layer
import com.mapbox.mapboxsdk.style.layers.LineLayer
import com.mapbox.mapboxsdk.style.layers.Property
import com.mapbox.mapboxsdk.style.layers.PropertyFactory
import com.mapbox.mapboxsdk.style.layers.RasterLayer
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
import com.mapbox.mapboxsdk.style.layers.TransitionOptions
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
import com.mapbox.mapboxsdk.style.sources.RasterSource
import com.mapbox.mapboxsdk.style.sources.Source
import com.mapbox.mapboxsdk.style.sources.TileSet
import com.mapbox.mapboxsdk.style.sources.VectorSource
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils
import timber.log.Timber
import java.io.IOException
import java.lang.StringBuilder
import java.util.*
import java.util.Arrays
import java.util.Collections
/**
* Test activity showcasing the runtime style API.
@@ -140,84 +155,105 @@ class RuntimeStyleActivity : AppCompatActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return if (!styleLoaded) {
false
} else when (item.itemId) {
R.id.action_list_layers -> {
listLayers()
true
} else {
when (item.itemId) {
R.id.action_list_layers -> {
listLayers()
true
}
R.id.action_list_sources -> {
listSources()
true
}
R.id.action_water_color -> {
setWaterColor()
true
}
R.id.action_background_opacity -> {
setBackgroundOpacity()
true
}
R.id.action_road_avoid_edges -> {
setRoadSymbolPlacement()
true
}
R.id.action_layer_visibility -> {
setLayerInvisible()
true
}
R.id.action_remove_layer -> {
removeBuildings()
true
}
R.id.action_add_parks_layer -> {
addParksLayer()
true
}
R.id.action_add_dynamic_parks_layer -> {
addDynamicParksLayer()
true
}
R.id.action_add_terrain_layer -> {
addTerrainLayer()
true
}
R.id.action_add_satellite_layer -> {
addSatelliteLayer()
true
}
R.id.action_update_water_color_on_zoom -> {
updateWaterColorOnZoom()
true
}
R.id.action_add_custom_tiles -> {
addCustomTileSource()
true
}
R.id.action_fill_filter -> {
styleFillFilterLayer()
true
}
R.id.action_textsize_filter -> {
styleTextSizeFilterLayer()
true
}
R.id.action_line_filter -> {
styleLineFilterLayer()
true
}
R.id.action_numeric_filter -> {
styleNumericFillLayer()
true
}
R.id.action_bring_water_to_front -> {
bringWaterToFront()
true
}
R.id.action_fill_filter_color -> {
styleFillColorLayer()
true
}
else -> super.onOptionsItemSelected(item)
}
R.id.action_list_sources -> {
listSources()
true
}
R.id.action_water_color -> {
setWaterColor()
true
}
R.id.action_background_opacity -> {
setBackgroundOpacity()
true
}
R.id.action_road_avoid_edges -> {
setRoadSymbolPlacement()
true
}
R.id.action_layer_visibility -> {
setLayerInvisible()
true
}
R.id.action_remove_layer -> {
removeBuildings()
true
}
R.id.action_add_parks_layer -> {
addParksLayer()
true
}
R.id.action_add_dynamic_parks_layer -> {
addDynamicParksLayer()
true
}
R.id.action_add_terrain_layer -> {
addTerrainLayer()
true
}
R.id.action_add_satellite_layer -> {
addSatelliteLayer()
true
}
R.id.action_update_water_color_on_zoom -> {
updateWaterColorOnZoom()
true
}
R.id.action_add_custom_tiles -> {
addCustomTileSource()
true
}
R.id.action_fill_filter -> {
styleFillFilterLayer()
true
}
R.id.action_textsize_filter -> {
styleTextSizeFilterLayer()
true
}
R.id.action_line_filter -> {
styleLineFilterLayer()
true
}
R.id.action_numeric_filter -> {
styleNumericFillLayer()
true
}
R.id.action_bring_water_to_front -> {
bringWaterToFront()
true
}
R.id.action_fill_filter_color -> {
styleFillColorLayer()
true
}
else -> super.onOptionsItemSelected(item)
}
}

View File

@@ -7,6 +7,7 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.res.ResourcesCompat
import com.google.gson.JsonObject
import com.google.gson.JsonPrimitive
import com.mapbox.geojson.Feature
@@ -14,8 +15,12 @@ import com.mapbox.geojson.FeatureCollection
import com.mapbox.geojson.Point
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.*
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.MapboxMap.OnMapClickListener
import com.mapbox.mapboxsdk.maps.MapboxMapOptions
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.style.expressions.Expression
import com.mapbox.mapboxsdk.style.expressions.Expression.FormatEntry
import com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption
@@ -28,7 +33,9 @@ import com.mapbox.mapboxsdk.style.sources.Source
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.utils.BitmapUtils
import timber.log.Timber
import java.util.*
import java.util.Arrays
import java.util.Objects
import java.util.Random
/**
* Test activity showcasing runtime manipulation of symbol layers.
@@ -72,7 +79,7 @@ class SymbolLayerActivity : AppCompatActivity(), OnMapClickListener, OnMapReadyC
if (style != null) {
Timber.e("Adding image with id: %s", id)
val androidIcon =
BitmapUtils.getBitmapFromDrawable(resources.getDrawable(R.drawable.ic_android_2))
BitmapUtils.getBitmapFromDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_android_2, null))
style.addImage(id!!, Objects.requireNonNull(androidIcon)!!)
}
}
@@ -81,7 +88,7 @@ class SymbolLayerActivity : AppCompatActivity(), OnMapClickListener, OnMapReadyC
override fun onMapReady(mapboxMap: MapboxMap) {
this.mapboxMap = mapboxMap
val carBitmap = BitmapUtils.getBitmapFromDrawable(
resources.getDrawable(R.drawable.ic_directions_car_black)
ResourcesCompat.getDrawable(resources, R.drawable.ic_directions_car_black, null)
)
// marker source
@@ -201,9 +208,11 @@ class SymbolLayerActivity : AppCompatActivity(), OnMapClickListener, OnMapReadyC
val size: Number? = markerSymbolLayer!!.textSize.getValue()
if (size != null) {
markerSymbolLayer!!.setProperties(
if (size as Float > 10) PropertyFactory.textSize(
10f
) else PropertyFactory.textSize(20f)
if (size as Float > 10) {
PropertyFactory.textSize(10f)
} else {
PropertyFactory.textSize(20f)
}
)
}
}
@@ -320,14 +329,17 @@ class SymbolLayerActivity : AppCompatActivity(), OnMapClickListener, OnMapReadyC
toggleTextSize()
true
}
R.id.action_toggle_text_field -> {
toggleTextField()
true
}
R.id.action_toggle_text_font -> {
toggleTextFont()
true
}
else -> super.onOptionsItemSelected(item)
}
}

View File

@@ -8,8 +8,11 @@ import com.google.gson.JsonObject
import com.mapbox.geojson.Feature
import com.mapbox.geojson.FeatureCollection
import com.mapbox.geojson.Point
import com.mapbox.mapboxsdk.maps.*
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.MapboxMap.OnMapClickListener
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.style.expressions.Expression
import com.mapbox.mapboxsdk.style.layers.Property
import com.mapbox.mapboxsdk.style.layers.PropertyFactory
@@ -78,10 +81,11 @@ class ZoomFunctionSymbolLayerActivity : AppCompatActivity() {
}
private fun createFeatureCollection(): FeatureCollection {
val point = if (isInitialPosition) Point.fromLngLat(
-74.01618140,
40.701745
) else Point.fromLngLat(-73.988097, 40.749864)
val point = if (isInitialPosition) {
Point.fromLngLat(-74.01618140, 40.701745)
} else {
Point.fromLngLat(-73.988097, 40.749864)
}
val properties = JsonObject()
properties.addProperty(KEY_PROPERTY_SELECTED, isSelected)
val feature = Feature.fromGeometry(point, properties)

View File

@@ -45,7 +45,7 @@ class TextureViewAnimationActivity : AppCompatActivity() {
setFpsView(mapboxMap)
// Animate the map view
val animation = ObjectAnimator.ofFloat(mapView, "rotationY", 0.0f, 360f)
val animation = ObjectAnimator.ofFloat(mapView!!, "rotationY", 0.0f, 360f)
animation.duration = 3600
animation.repeatCount = ObjectAnimator.INFINITE
animation.start()
@@ -65,7 +65,9 @@ class TextureViewAnimationActivity : AppCompatActivity() {
delayed = null
flyTo(mapboxMap, place, zoom)
}
handler!!.postDelayed(delayed, 2000)
delayed?.let {
handler!!.postDelayed(it, 2000)
}
}
override fun onFinish() {
@@ -101,7 +103,7 @@ class TextureViewAnimationActivity : AppCompatActivity() {
super.onStop()
mapView!!.onStop()
if (handler != null && delayed != null) {
handler!!.removeCallbacks(delayed)
handler!!.removeCallbacks(delayed!!)
}
}

View File

@@ -204,11 +204,9 @@ class MapSnapshotterWithinExpression : AppCompatActivity() {
mapView.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle?, outPersistentState: PersistableBundle?) {
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
super.onSaveInstanceState(outState, outPersistentState)
outState?.let {
mapView.onSaveInstanceState(it)
}
mapView.onSaveInstanceState(outState)
}
private fun bufferLineStringGeometry(): Polygon {

View File

@@ -136,7 +136,7 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL
mapView.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle?, outPersistentState: PersistableBundle?) {
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
super.onSaveInstanceState(outState, outPersistentState)
outState?.let {
mapView.onSaveInstanceState(it)

View File

@@ -193,7 +193,7 @@ class WithinExpressionActivity : AppCompatActivity() {
mapView.onDestroy()
}
override fun onSaveInstanceState(outState: Bundle?, outPersistentState: PersistableBundle?) {
override fun onSaveInstanceState(outState: Bundle, outPersistentState: PersistableBundle) {
super.onSaveInstanceState(outState, outPersistentState)
outState?.let {
mapView.onSaveInstanceState(it)

View File

@@ -7,7 +7,7 @@ import android.view.View
import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.google.android.material.bottomsheet.BottomSheetBehavior
class LockableBottomSheetBehavior<V : View?>(context: Context?, attrs: AttributeSet?) :
class LockableBottomSheetBehavior<V : View?>(context: Context, attrs: AttributeSet?) :
BottomSheetBehavior<V>(context, attrs) {
private var locked = false
fun setLocked(locked: Boolean) {

View File

@@ -2,56 +2,58 @@ ext {
androidVersions = [
minSdkVersion : 14,
targetSdkVersion : 28,
compileSdkVersion: 28,
targetSdkVersion : 33,
compileSdkVersion: 33,
]
versions = [
mapLibreServices: '5.9.0',
mapboxCore : '2.0.1',
mapboxGestures : '0.7.0',
appCompat : '1.0.0',
constraintLayout: '1.1.3',
recyclerView : '1.1.0',
material : '1.0.0',
appCompat : '1.5.1',
constraintLayout: '2.1.4',
interpolator : '1.0.0',
recyclerView : '1.2.1',
material : '1.7.0',
uiAutomator : '2.2.0',
espresso : '3.2.0',
testRunner : '1.1.1',
fragment : '1.0.0',
annotation : '1.0.0',
leakCanary : '2.8.1',
junit : '4.12',
mockito : '3.0.0',
mockk : '1.9.3',
robolectric : '4.7.3',
timber : '4.7.1',
okhttp : '3.12.3',
espresso : '3.5.0',
testRunner : '1.1.4',
testRules : '1.5.0',
fragment : '1.5.5',
annotation : '1.5.0',
leakCanary : '2.10',
junit : '4.13.2',
mockito : '4.10.0',
mockk : '1.13.3',
robolectric : '4.9.1',
timber : '5.0.1',
okhttp : '4.10.0',
kotlin : '1.7.20',
licenses : '0.8.80',
lint : '26.4.2',
gms : '17.0.0',
lint : '30.3.1',
gms : '21.0.1',
// jacoco : '0.8.5',
appcenter : '1.4',
ktlint : '0.40.0',
commonsIO : '2.6',
assertj : "3.11.1",
appcenter : '1.5',
commonsIO : '2.11.0',
assertj : '3.23.1',
gradleNexus : "1.1.0",
multidex : "2.0.1"
]
dependenciesList = [
mapboxJavaGeoJSON : "org.maplibre.gl:android-sdk-geojson:${versions.mapLibreServices}",
mapboxAndroidGestures : "com.mapbox.mapboxsdk:mapbox-android-gestures:${versions.mapboxGestures}",
mapboxJavaTurf : "org.maplibre.gl:android-sdk-turf:${versions.mapLibreServices}",
junit : "junit:junit:${versions.junit}",
amdroidxJunit : "androidx.test.ext:junit:1.1.4",
mockito : "org.mockito:mockito-core:${versions.mockito}",
mockk : "io.mockk:mockk:${versions.mockk}",
robolectric : "org.robolectric:robolectric:${versions.robolectric}",
assertjcore : "org.assertj:assertj-core:${versions.assertj}",
testRunner : "androidx.test.ext:junit:${versions.testRunner}",
testRules : "androidx.test:rules:${versions.testRunner}",
testRules : "androidx.test:rules:${versions.testRules}",
testEspressoCore : "androidx.test.espresso:espresso-core:${versions.espresso}",
testEspressoIntents : "androidx.test.espresso:espresso-intents:${versions.espresso}",
testEspressoContrib : "androidx.test.espresso:espresso-contrib:${versions.espresso}",
@@ -61,6 +63,7 @@ ext {
supportFragmentV4 : "androidx.fragment:fragment:${versions.fragment}",
supportRecyclerView : "androidx.recyclerview:recyclerview:${versions.recyclerView}",
supportConstraintLayout: "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}",
interpolator : "androidx.interpolator:interpolator:${versions.interpolator}",
supportDesign : "com.google.android.material:material:${versions.material}",
multidex : "androidx.multidex:multidex:${versions.multidex}",
@@ -80,7 +83,6 @@ ext {
lintApi : "com.android.tools.lint:lint-api:${versions.lint}",
lintChecks : "com.android.tools.lint:lint-checks:${versions.lint}",
lintTests : "com.android.tools.lint:lint-tests:${versions.lint}",
ktlint : "com.pinterest:ktlint:${versions.ktlint}",
gradleNexus : "io.github.gradle-nexus:publish-plugin:${versions.gradleNexus}"
]

View File

@@ -1,7 +1,7 @@
apply from: "${rootDir}/gradle/dependencies.gradle"
repositories {
jcenter()
mavenCentral()
}
configurations {
@@ -9,14 +9,18 @@ configurations {
}
dependencies {
ktlint dependenciesList.ktlint
ktlint("com.pinterest:ktlint:0.48.0") {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
}
}
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "--disabled_rules=no-wildcard-imports", "src/**/*.kt"
args "--disabled_rules=no-wildcard-imports,trailing-comma-on-call-site,trailing-comma-on-declaration-site", "src/**/*.kt"
}
task ktlintFormat(type: JavaExec, group: "formatting") {

View File

@@ -13,7 +13,7 @@ ext.nativeBuild = { nativeTargets ->
// When building from Android Studio, gradle.properties sets `android.buildOnlyTargetAbi=true` so that
// only the architecture for the device you're running on gets built.
def abi = 'all'
if (!project.hasProperty('android.injected.invoked.from.ide') || project.hasProperty("mapbox.abis")) {
if (!project.hasProperty('android.injected.invoked.from.ide') && project.hasProperty("mapbox.abis")) {
// Errors when the user invokes Gradle from the command line and didn't set mapbox.abis
abi = project.getProperty("mapbox.abis")
}

View File

@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
compileSdkVersion 33
defaultConfig {
applicationId = 'com.mapbox.mapboxsdk.maps.render_test_runner'
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 33
def abi = 'all'
if (project.hasProperty('mapbox.abis')) {
abi = project.getProperty('mapbox.abis')
@@ -30,6 +30,7 @@ android {
}
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
externalNativeBuild {
cmake {
@@ -45,9 +46,9 @@ android {
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-beta01'
androidTestImplementation 'androidx.test:rules:1.2.0-beta01'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
androidTestImplementation 'androidx.test:rules:1.5.0'
}

View File

@@ -2,7 +2,7 @@ package android.app;
import android.util.Log;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
@@ -12,7 +12,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
@LargeTest
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class NativeActivityTest {
@Rule

View File

@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
compileSdkVersion 33
defaultConfig {
applicationId = 'com.mapbox.mapboxsdk.maps.test_runner'
minSdkVersion 28
targetSdkVersion 28
targetSdkVersion 33
def abi = 'all'
if (project.hasProperty('mapbox.abis')) {
abi = project.getProperty('mapbox.abis')
@@ -44,9 +44,9 @@ android {
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
androidTestImplementation 'androidx.test:rules:1.5.0'
}

View File

@@ -2,7 +2,7 @@ package android.app;
import android.util.Log;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
@@ -12,7 +12,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
@LargeTest
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class NativeActivityTest {
@Rule