Skip to content

Commit

Permalink
[style-extension] Rename reference to style plugin and converting the…
Browse files Browse the repository at this point in the history
…m to style extension. (#123)
  • Loading branch information
pengdev authored Feb 23, 2021
1 parent c237400 commit 6fbada4
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.text.DateFormat.getDateTimeInstance
import java.util.*

/**
* Example showcasing usage of style-plugin.
* Example showcasing usage of style extension.
*/
class DSLStylingActivity : AppCompatActivity(), OnMapClickListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import kotlinx.android.synthetic.main.activity_simple_map.*
import java.nio.ByteBuffer

/**
* Example showcasing usage of style-plugin.
* Example showcasing usage of style extension.
*/
class RuntimeStylingActivity : AppCompatActivity() {

Expand Down Expand Up @@ -55,7 +55,7 @@ class RuntimeStylingActivity : AppCompatActivity() {
addImageSource(style)
addRasterLayer(style)

addLayerWithoutStylePlugin(style)
addLayerWithoutStyleExtension(style)

val source = style.getSource("composite") as VectorSource
Logger.e(TAG, "getSource: $source")
Expand Down Expand Up @@ -333,7 +333,7 @@ class RuntimeStylingActivity : AppCompatActivity() {
style.addLayer(raster)
}

private fun addLayerWithoutStylePlugin(style: Style) {
private fun addLayerWithoutStyleExtension(style: Style) {
val bitmap = ContextCompat.getDrawable(this, R.drawable.android_symbol)?.toBitmap(64, 64)
val byteBuffer = ByteBuffer.allocate(bitmap!!.byteCount)
bitmap.copyPixelsToBuffer(byteBuffer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.mapbox.maps.extension.style.sources.*
import com.mapbox.maps.extension.style.terrain.generated.Terrain

/**
* The concrete implementation of style plugin.
* The concrete implementation of style extension.
*/
class StyleExtensionImpl private constructor(builder: Builder) : StyleContract.StyleExtension {

Expand Down Expand Up @@ -44,7 +44,7 @@ class StyleExtensionImpl private constructor(builder: Builder) : StyleContract.S
override val terrain: Terrain? = builder.terrain

/**
* The builder for style plugin.
* The builder for style extension.
*/
class Builder(
/**
Expand Down Expand Up @@ -138,7 +138,7 @@ class StyleExtensionImpl private constructor(builder: Builder) : StyleContract.S
}

/**
* DSL function to construct a style plugin.
* DSL function to construct a style extension.
*/
fun style(styleUri: String, block: Builder.() -> Unit) =
Builder(styleUri).apply(block).build()
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fun image(imageId: String, block: ImageExtensionImpl.Builder.() -> Unit): ImageE
ImageExtensionImpl.Builder(imageId).apply(block).build()

/**
* Extension function to add an image provided by the Style Plugin to the Style.
* Extension function to add an image provided by the Style Extension to the Style.
*
* @param image The image to be added
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ abstract class Layer : StyleContract.StyleLayerExtension {
}

/**
* Extension function to get a Layer provided by the Style Plugin by layer id.
* Extension function to get a Layer provided by the Style Extension by layer id.
*
* @param layerId the layer id
* @return StyleLayerPlugin
Expand Down Expand Up @@ -223,7 +223,7 @@ fun <T : Layer> StyleManagerInterface.getLayerAs(layerId: String): T {
}

/**
* Extension function to add a Layer provided by the Style Plugin to the Style.
* Extension function to add a Layer provided by the Style Extension to the Style.
*
* @param layer The layer to be added
* @param below the layer id that the current layer is added below
Expand All @@ -233,7 +233,7 @@ fun StyleManagerInterface.addLayerBelow(layer: StyleContract.StyleLayerExtension
}

/**
* Extension function to add a Layer provided by the Style Plugin to the Style.
* Extension function to add a Layer provided by the Style Extension to the Style.
*
* @param layer The layer to be added
* @param above the layer id that the current layer is added above
Expand All @@ -243,7 +243,7 @@ fun StyleManagerInterface.addLayerAbove(layer: StyleContract.StyleLayerExtension
}

/**
* Extension function to add a Layer provided by the Style Plugin to the Style.
* Extension function to add a Layer provided by the Style Extension to the Style.
*
* @param layer The layer to be added
* @param index the index that the current layer is added on
Expand All @@ -253,7 +253,7 @@ fun StyleManagerInterface.addLayerAt(layer: StyleContract.StyleLayerExtension, i
}

/**
* Extension function to add a Layer provided by the Style Plugin to the Style.
* Extension function to add a Layer provided by the Style Extension to the Style.
*
* @param layer The layer to be added
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ abstract class Source(
}

/**
* Extension function to get a Source provided by the Style Plugin by source id.
* Extension function to get a Source provided by the Style Extension by source id.
*
* @param sourceId the source id
* @return StyleSourcePlugin
Expand Down Expand Up @@ -177,7 +177,7 @@ inline fun <reified T : Source> StyleManagerInterface.getSourceAs(sourceId: Stri
}

/**
* Extension function to add a Source provided by the Style Plugin to the Style.
* Extension function to add a Source provided by the Style Extension to the Style.
*
* @param source The light to be added
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import java.nio.ByteBuffer
*/
interface StyleContract {
/**
* Define the interfaces for the Style plugin.
* Define the interfaces for the Style Extension.
*/
interface StyleExtension {
/**
Expand Down
12 changes: 6 additions & 6 deletions sdk/src/main/java/com/mapbox/maps/MapboxMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ class MapboxMap internal constructor(
}

/**
* Load style JSON
* Load style JSON.
*/
fun loadStyleJSON(
json: String,
onStyleLoaded: Style.OnStyleLoaded
) = loadStyleJSON(json, onStyleLoaded, null)

/**
* Load the style from Style plugin.
* Load the style from Style Extension.
*/
fun loadStyle(
styleExtension: StyleContract.StyleExtension,
Expand All @@ -130,23 +130,23 @@ class MapboxMap internal constructor(
terrainEnabled = false
this.loadStyleUri(
styleExtension.styleUri,
{ style -> onFinishLoadingStylePlugin(style, styleExtension, onStyleLoaded) },
{ style -> onFinishLoadingStyleExtension(style, styleExtension, onStyleLoaded) },
onMapLoadErrorListener
)
}

/**
* Load the style from Style plugin.
* Load the style from Style Extension.
*/
fun loadStyle(
styleExtension: StyleContract.StyleExtension,
onStyleLoaded: Style.OnStyleLoaded
) = loadStyle(styleExtension, onStyleLoaded, null)

/**
* Handle the style loading from Style plugin.
* Handle the style loading from Style Extension.
*/
internal fun onFinishLoadingStylePlugin(
internal fun onFinishLoadingStyleExtension(
style: Style,
styleExtension: StyleContract.StyleExtension,
onStyleLoaded: Style.OnStyleLoaded? = null
Expand Down
28 changes: 14 additions & 14 deletions sdk/src/test/java/com/mapbox/maps/MapboxMapTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ class MapboxMapTest {

@Test
fun loadStyle() {
val stylePlugin = mockk<StyleContract.StyleExtension>()
every { stylePlugin.styleUri } returns "foobar"
val styleExtension = mockk<StyleContract.StyleExtension>()
every { styleExtension.styleUri } returns "foobar"
val onMapLoadError = mockk<OnMapLoadErrorListener>()
val onStyleLoadError = mockk<Style.OnStyleLoaded>()
mapboxMap.loadStyle(stylePlugin, onStyleLoadError, onMapLoadError)
mapboxMap.loadStyle(styleExtension, onStyleLoadError, onMapLoadError)
verify { nativeMap.styleURI = "foobar" }
}

@Test
fun loadStyleLambda() {
val stylePlugin = mockk<StyleContract.StyleExtension>()
every { stylePlugin.styleUri } returns "foobar"
mapboxMap.loadStyle(stylePlugin) {}
val styleExtension = mockk<StyleContract.StyleExtension>()
every { styleExtension.styleUri } returns "foobar"
mapboxMap.loadStyle(styleExtension) {}
verify { nativeMap.styleURI = "foobar" }
}

Expand All @@ -84,30 +84,30 @@ class MapboxMapTest {
}

@Test
fun finishLoadingStylePlugin() {
fun finishLoadingStyleExtension() {
val style = mockk<Style>()
val stylePlugin = mockk<StyleContract.StyleExtension>()
val styleExtension = mockk<StyleContract.StyleExtension>()

val source = mockk<StyleContract.StyleSourceExtension>(relaxed = true)
every { stylePlugin.sources } returns listOf(source)
every { styleExtension.sources } returns listOf(source)

val image = mockk<StyleContract.StyleImageExtension>(relaxed = true)
every { stylePlugin.images } returns listOf(image)
every { styleExtension.images } returns listOf(image)

val layer = mockk<StyleContract.StyleLayerExtension>(relaxed = true)
val layerPosition = LayerPosition(null, null, 0)
every { stylePlugin.layers } returns listOf(
every { styleExtension.layers } returns listOf(
Pair(layer, layerPosition)
)

val light = mockk<StyleContract.StyleLightExtension>(relaxed = true)
every { stylePlugin.light } returns light
every { styleExtension.light } returns light

val terrain = mockk<StyleContract.StyleTerrainExtension>(relaxed = true)
every { stylePlugin.terrain } returns terrain
every { styleExtension.terrain } returns terrain

val styleLoadCallback = mockk<Style.OnStyleLoaded>(relaxed = true)
mapboxMap.onFinishLoadingStylePlugin(style, stylePlugin, styleLoadCallback)
mapboxMap.onFinishLoadingStyleExtension(style, styleExtension, styleLoadCallback)

assertEquals(mapboxMap.style, style)
verify { source.bindTo(style) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MapDelegateProviderTest {
}

@Test
fun stylePluginDelegate() {
fun styleExtensionDelegate() {
val captureCallback = slot<Style.OnStyleLoaded>()
every { mapboxMap.getStyle(capture(captureCallback)) } answers {
captureCallback.captured.onStyleLoaded(mockk())
Expand Down

0 comments on commit 6fbada4

Please sign in to comment.