bump gl-native submodule and bring platform changes

This commit is contained in:
Łukasz Paczos
2019-11-13 14:14:21 +01:00
parent b381086338
commit dfdbaf5493
8 changed files with 182 additions and 6 deletions

View File

@@ -2,6 +2,17 @@
Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started.
## master
### Features
- Added support for [image expression](https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-types-image) in core library. Runtime APIs for image expression will be implemented separately. [#15877](https://github.com/mapbox/mapbox-gl-native/pull/15877)
- Introduce `OfflineManager#packDatabase` and `OfflineRegion#deleteAndSkipPackDatabase` API in order to decouple offline storage vacuum and delete region operations and thus to gain performance benefits e.g. when several regions should be deleted in a row [#15899](https://github.com/mapbox/mapbox-gl-native/pull/15899)
### Bugs
- Fixed Geo JSON source flickering on style transition [#15907](https://github.com/mapbox/mapbox-gl-native/pull/15907)
### Performance improvements
- Convert GeoJSON features to tiles for the loaded source description in a background thread and thus unblock the UI thread [#15885](https://github.com/mapbox/mapbox-gl-native/pull/15885)
## 8.5.0-alpha.4 - October 24, 2019
[Changes](https://github.com/mapbox/mapbox-gl-native-android/compare/android-v8.5.0-alpha.3...android-v8.5.0-alpha.4) since [Mapbox Maps SDK for Android v8.5.0-alpha.3](https://github.com/mapbox/mapbox-gl-native-android/releases/tag/android-v8.5.0-alpha.3):
### Bug fixes

View File

@@ -8,6 +8,7 @@ import android.support.annotation.Keep;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import com.mapbox.mapboxsdk.LibraryLoader;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.R;
@@ -306,6 +307,47 @@ public class OfflineManager {
});
}
/**
* Packs the existing database file into a minimal amount of disk space.
* <p>
* When the operation is complete or encounters an error, the given callback will be
* executed on the database thread; it is the responsibility of the SDK bindings
* to re-execute a user-provided callback on the main thread.
* </p>
*
* @param callback the callback to be invoked when the database was reset or when the operation erred.
*/
public void packDatabase(@Nullable final FileSourceCallback callback) {
fileSource.activate();
nativePackDatabase(new FileSourceCallback() {
@Override
public void onSuccess() {
handler.post(new Runnable() {
@Override
public void run() {
fileSource.deactivate();
if (callback != null) {
callback.onSuccess();
}
}
});
}
@Override
public void onError(@NonNull final String message) {
handler.post(new Runnable() {
@Override
public void run() {
fileSource.deactivate();
if (callback != null) {
callback.onError(message);
}
}
});
}
});
}
/**
* Forces re-validation of the ambient cache.
* <p>
@@ -648,6 +690,9 @@ public class OfflineManager {
@Keep
private native void nativeResetDatabase(@Nullable FileSourceCallback callback);
@Keep
private native void nativePackDatabase(@Nullable FileSourceCallback callback);
@Keep
private native void nativeInvalidateAmbientCache(@Nullable FileSourceCallback callback);

View File

@@ -401,7 +401,55 @@ public class OfflineRegion {
if (!isDeleted) {
isDeleted = true;
fileSource.activate();
deleteOfflineRegion(new OfflineRegionDeleteCallback() {
deleteOfflineRegion(true /*pack*/, new OfflineRegionDeleteCallback() {
@Override
public void onDelete() {
handler.post(new Runnable() {
@Override
public void run() {
fileSource.deactivate();
callback.onDelete();
OfflineRegion.this.finalize();
}
});
}
@Override
public void onError(final String error) {
handler.post(new Runnable() {
@Override
public void run() {
isDeleted = false;
fileSource.deactivate();
callback.onError(error);
}
});
}
});
}
}
/**
* Same as {@link OfflineRegion#delete} but skipping database file packing for performance reasons.
* <p>
* Database file packing can be done later with {@link OfflineManager#packDatabase}.
* This method is a useful optimization e.g. when several regions should be deleted in a row.
* </p>
* <p>
* When the operation is complete or encounters an error, the given callback will be
* executed on the main thread.
* </p>
* <p>
* After you call this method, you may not call any additional methods on this object.
* </p>
*
* @param callback the callback to be invoked
*/
public void deleteAndSkipPackDatabase(@NonNull final OfflineRegionDeleteCallback callback) {
if (!isDeleted) {
isDeleted = true;
fileSource.activate();
deleteOfflineRegion(false /*pack*/, new OfflineRegionDeleteCallback() {
@Override
public void onDelete() {
handler.post(new Runnable() {
@@ -521,7 +569,7 @@ public class OfflineRegion {
private native void getOfflineRegionStatus(OfflineRegionStatusCallback callback);
@Keep
private native void deleteOfflineRegion(OfflineRegionDeleteCallback callback);
private native void deleteOfflineRegion(boolean pack, OfflineRegionDeleteCallback callback);
@Keep
private native void updateOfflineRegionMetadata(byte[] metadata, OfflineRegionUpdateMetadataCallback callback);

View File

@@ -5,6 +5,7 @@ import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
@@ -3150,7 +3151,7 @@ public class Expression {
* If set, the min-fraction-digits and max-fraction-digits arguments specify the minimum and maximum number
* of fractional digits to include.
*
* @param number number expression
* @param number number expression
* @param options number formatting options
* @return expression
*/
@@ -3169,7 +3170,7 @@ public class Expression {
* If set, the min-fraction-digits and max-fraction-digits arguments specify the minimum and maximum number
* of fractional digits to include.
*
* @param number number expression
* @param number number expression
* @param options number formatting options
* @return expression
*/
@@ -3409,6 +3410,49 @@ public class Expression {
return new FormatEntry(literal(text), null);
}
/**
* Returns image expression for use in '*-pattern' and 'icon-image' layer properties. Compared to
* string literals that can be used to represent an image, image expression allows to determine an
* image's availability at runtime, thus, can be used in conditional <a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-coalesce">coalesce operator</a>.
*
* <p>
* Example usage:
* </p>
* <pre>
* {@code
* SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id");
* symbolLayer.setProperties(
* iconImage(image(get("key-to-feature")))
* );
* }
* </pre>
*
* <p>
* Example usage with coalesce operator:
* </p>
* <pre>
* {@code
* SymbolLayer symbolLayer = new SymbolLayer("layer-id", "source-id");
* symbolLayer.setProperties(
* iconImage(
* coalesce(
* image(literal("maki-11")),
* image(literal("bicycle-15")),
* image(literal("default-icon"))
* )
* )
* );
* }
* </pre>
*
* @param input expression input
* @return expression
* @see <a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-types-image">Image expression</a>
*/
public static Expression image(@NonNull Expression input) {
return new Expression("image", input);
}
/**
* Asserts that the input value is an object. If it is not, the expression is an error
* The asserted input value is returned as result.
@@ -4430,7 +4474,7 @@ public class Expression {
/**
* Create an option option entry that is encapsulated as a json object member for an expression.
*
* @param type json object member name
* @param type json object member name
* @param value json object member value
*/
Option(@NonNull String type, @NonNull Expression value) {

View File

@@ -85,4 +85,20 @@ class CacheTest {
}
countDownLatch.await()
}
@Test
fun testSetPackDatabase() {
rule.activity.runOnUiThread {
OfflineManager.getInstance(context).packDatabase(object : OfflineManager.FileSourceCallback {
override fun onSuccess() {
countDownLatch.countDown()
}
override fun onError(message: String) {
Assert.assertNull("onError should not be called", message)
}
})
}
countDownLatch.await()
}
}

View File

@@ -151,6 +151,8 @@ public class <%- camelize(type) %>LayerTest extends BaseLayerTest {
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("{token}"));
<% if (property.type === 'formatted') { -%>
assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), <%- defaultExpressionJava(property) %>(Expression.formatEntry(Expression.toString(Expression.get("token")))));
<% } else if (property.type === 'resolvedImage') {-%>
assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), <%- defaultExpressionJava(property) %>(Expression.toString(Expression.get("token"))));
<% } else {-%>
assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), Expression.toString(Expression.get("token")));
<% } -%>
@@ -169,6 +171,8 @@ public class <%- camelize(type) %>LayerTest extends BaseLayerTest {
// Set and Get
<% if (property.type === 'formatted') { -%>
Expression expression = <%- defaultExpressionJava(property) %>(Expression.formatEntry(Expression.get("undefined"), FormatOption.formatFontScale(2.0), FormatOption.formatTextFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})));
<% } else if (property.type === 'resolvedImage') { -%>
Expression expression = <%- defaultExpressionJava(property) %>(string(Expression.get("undefined")));
<% } else { -%>
Expression expression = <%- defaultExpressionJava(property) %>(Expression.get("undefined"));
<% } -%>

View File

@@ -72,6 +72,7 @@ global.propertyType = function propertyType(property) {
case 'formatted':
return 'Formatted';
case 'string':
case 'resolvedImage':
return 'String';
case 'enum':
return 'String';
@@ -93,6 +94,7 @@ global.propertyJavaType = function propertyType(property) {
case 'formatted':
return 'Formatted';
case 'string':
case 'resolvedImage':
return 'String';
case 'enum':
return 'String';
@@ -141,6 +143,7 @@ global.propertyNativeType = function (property) {
return 'float';
case 'formatted':
case 'string':
case 'resolvedImage': // TODO: replace once we implement image expressions
return 'std::string';
case 'enum':
if(property['light-property']){
@@ -176,7 +179,10 @@ global.defaultExpressionJava = function(property) {
return 'number';
case 'formatted':
return 'format';
case 'resolvedImage':
return "image";
case 'string':
case 'image':
return "string";
case 'enum':
return "string";
@@ -203,6 +209,7 @@ global.defaultValueJava = function(property) {
case 'formatted':
return 'new Formatted(new FormattedSection("default"))'
case 'string':
case 'resolvedImage':
return '"' + property['default'] + '"';
case 'enum':
return snakeCaseUpper(property.name) + "_" + snakeCaseUpper(Object.keys(property.values)[0]);
@@ -335,6 +342,7 @@ global.evaluatedType = function (property) {
return 'float';
case 'formatted':
case 'string':
case 'image':
return 'std::string';
case 'enum':
return (isLightProperty(property) ? 'Light' : '') + `${camelize(property.name)}Type`;