Read styles from APK

This commit is contained in:
Leith Bade
2014-11-17 23:17:22 +11:00
parent aee724d6cf
commit f0e4e27cd3
10 changed files with 130 additions and 128 deletions

View File

@@ -33,7 +33,7 @@ public class Assetbridge {
// only extract what we need
ArrayList<String> assets = new ArrayList<String>();
assets.add("ca-bundle.crt");
assets.add("styles");
//assets.add("styles");
// iterate on the files...
for(String asset : assets) {

View File

@@ -141,13 +141,14 @@ public class MapView extends SurfaceView {
// Get the cache path
String cachePath = context.getCacheDir().getAbsolutePath();
String dataPath = context.getFilesDir().getAbsolutePath();
String apkPath = context.getPackageCodePath();
// Extract the asset files
Assetbridge.unpack(context);
// Load the map style and API key
//mStyleUrl = "https://mapbox.github.io/mapbox-gl-styles/styles/bright-v6.json";
mStyleUrl = "file://" + dataPath + "/styles/styles/bright-v6.json";
mStyleUrl = "asset://styles/styles/bright-v6.json";
mAccessToken = "pk.eyJ1IjoibGpiYWRlIiwiYSI6IlJSQ0FEZ2MifQ.7mE4aOegldh3595AG9dxpQ";
// Are we a debug build?
@@ -155,7 +156,7 @@ public class MapView extends SurfaceView {
ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE;
// Create the NativeMapView
mNativeMapView = new NativeMapView(this, cachePath, dataPath);
mNativeMapView = new NativeMapView(this, cachePath, dataPath, apkPath);
mNativeMapView.setStyleURL(mStyleUrl);
mNativeMapView.setAccessToken(mAccessToken);
mNativeMapView.setDebug(isDebuggable);

View File

@@ -37,11 +37,11 @@ class NativeMapView {
// Constructors
//
public NativeMapView(MapView mapView, String cachePath, String dataPath) {
public NativeMapView(MapView mapView, String cachePath, String dataPath, String apkPath) {
mMapView = mapView;
// Create the NativeMapView
mNativeMapViewPtr = nativeCreate(cachePath, dataPath);
mNativeMapViewPtr = nativeCreate(cachePath, dataPath, apkPath);
}
//
@@ -407,7 +407,7 @@ class NativeMapView {
super.finalize();
}
private native long nativeCreate(String cachePath, String dataPath);
private native long nativeCreate(String cachePath, String dataPath, String apkPath);
private native void nativeDestroy(long nativeMapViewPtr);