Skip to content

Commit

Permalink
Update Mapzen Android SDK to 1.6 (#831)
Browse files Browse the repository at this point in the history
* Update to Mapzen SDK 1.6

* Move from snapshot to release
  • Loading branch information
sarahsnow1 authored Sep 14, 2017
1 parent 9b14676 commit dc80674
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 268 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ dependencies {
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.mapzen:mapzen-android-sdk:1.4.0'
compile 'com.mapzen:mapzen-android-sdk:1.6.0'
compile "com.google.dagger:dagger:$dagger_version"
compile 'com.squareup:otto:1.3.7'
compile 'com.splunk.mint:mint:4.2.1'
Expand Down
34 changes: 13 additions & 21 deletions app/src/main/java/com/mapzen/erasermap/AndroidModule.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mapzen.erasermap;

import com.mapzen.android.search.MapzenSearch;
import com.mapzen.android.search.MapzenSearchHttpHandler;
import com.mapzen.erasermap.model.AndroidAppSettings;
import com.mapzen.erasermap.model.ApiKeys;
import com.mapzen.erasermap.model.AppSettings;
Expand All @@ -27,7 +28,6 @@
import com.mapzen.erasermap.view.Speaker;
import com.mapzen.erasermap.view.SpeakerboxSpeaker;
import com.mapzen.pelias.Pelias;
import com.mapzen.pelias.PeliasRequestHandler;

import com.squareup.otto.Bus;

Expand Down Expand Up @@ -86,14 +86,12 @@ public AndroidModule(EraserMapApplication application) {
permissionManager, confidenceHandler);
}

@Provides @Singleton RouteManager provideRouteManager(AppSettings settings, ApiKeys apiKeys) {
final ValhallaRouteManager manager = new ValhallaRouteManager(settings,
@Provides @Singleton RouteManager provideRouteManager(AppSettings settings) {
return new ValhallaRouteManager(settings,
new ValhallaRouterFactory(), application.getApplicationContext());
manager.setApiKey(apiKeys.getApiKey());
return manager;
}

@Provides @Singleton TileHttpHandler provideTileHttpHandler(ApiKeys apiKeys) {
@Provides @Singleton TileHttpHandler provideTileHttpHandler() {
final TileHttpHandler handler;
if (Build.VERSION.SDK_INT >= KITKAT) {
File httpCache = new File(application.getExternalCacheDir().getAbsolutePath() +
Expand All @@ -110,26 +108,24 @@ public AndroidModule(EraserMapApplication application) {
return new Bus();
}

@Provides @Singleton MapzenSearch provideMapzenSearch(final ApiKeys apiKeys) {
@Provides @Singleton MapzenSearch provideMapzenSearch() {
final String endpoint = BuildConfig.SEARCH_BASE_URL != null ?
BuildConfig.SEARCH_BASE_URL : Pelias.DEFAULT_SEARCH_ENDPOINT;
MapzenSearch search = new MapzenSearch(application);
Pelias pelias = search.getPelias();
pelias.setEndpoint(endpoint);
pelias.setDebug(BuildConfig.DEBUG);
pelias.setRequestHandler(new PeliasRequestHandler() {
search.setHttpHandler(new MapzenSearchHttpHandler(application) {
@Override public Map<String, String> queryParamsForRequest() {
return null;
}

@Override public Map<String, String> headersForRequest() {
Map<String, String> headers = new HashMap<>();
headers.put(Http.HEADER_DNT, Http.VALUE_HEADER_DNT);
return headers;
}

@Override public Map<String, String> queryParamsForRequest() {
Map<String, String> params = new HashMap<>();
params.put(Http.PARAM_API_KEY, apiKeys.getApiKey());
return params;
}
});
Pelias pelias = search.getPelias();
pelias.setEndpoint(endpoint);
pelias.setDebug(BuildConfig.DEBUG);
return search;
}

Expand All @@ -145,10 +141,6 @@ public AndroidModule(EraserMapApplication application) {
return new PermissionManager();
}

@Provides @Singleton ApiKeys provideApiKeys() {
return ApiKeys.Companion.sharedInstance(application);
}

@Provides @Singleton LocationConverter provideLocationConverter() {
return new LocationConverter();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mapzen.erasermap;

import com.mapzen.erasermap.controller.MainActivity;
import com.mapzen.erasermap.model.ApiKeys;
import com.mapzen.erasermap.receiver.MockLocationReceiver;
import com.mapzen.erasermap.view.DistanceView;
import com.mapzen.erasermap.view.InitActivity;
Expand Down Expand Up @@ -41,6 +42,7 @@ public interface ApplicationComponent {
@Override
public void onCreate() {
super.onCreate();
ApiKeys.Companion.sharedInstance(this);
component = DaggerEraserMapApplication_ApplicationComponent.builder()
.androidModule(new AndroidModule(this))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.widget.RelativeLayout
import android.widget.Toast
import com.mapzen.android.graphics.MapView
import com.mapzen.android.graphics.MapzenMap
import com.mapzen.android.graphics.MapzenMapHttpHandler
import com.mapzen.android.graphics.model.BubbleWrapStyle
import com.mapzen.android.graphics.model.CameraType
import com.mapzen.android.graphics.model.CinnabarStyle
Expand All @@ -35,7 +36,6 @@ import com.mapzen.erasermap.CrashReportService
import com.mapzen.erasermap.EraserMapApplication
import com.mapzen.erasermap.R
import com.mapzen.erasermap.model.AndroidAppSettings
import com.mapzen.erasermap.model.ApiKeys
import com.mapzen.erasermap.model.AppSettings
import com.mapzen.erasermap.model.ConfidenceHandler
import com.mapzen.erasermap.model.LostClientManager
Expand Down Expand Up @@ -98,7 +98,6 @@ class MainActivity : AppCompatActivity(), MainViewController,
@Inject lateinit var mapzenSearch: MapzenSearch
@Inject lateinit var speaker: Speaker
@Inject lateinit var permissionManager: PermissionManager
@Inject lateinit var apiKeys: ApiKeys
@Inject lateinit var lostClientManager: LostClientManager
@Inject lateinit var confidenceHandler: ConfidenceHandler
@Inject lateinit var displayHelper: FeatureDisplayHelper
Expand Down Expand Up @@ -299,7 +298,7 @@ class MainActivity : AppCompatActivity(), MainViewController,
presenter.onClickFindMe()
}
initMapRotateListener()
mapzenMap?.mapController?.setHttpHandler(tileHttpHandler)
mapzenMap?.setHttpHandler(tileHttpHandler)
mapzenLocation.mapzenMap = mapzenMap
routeModeView.mapzenMap = mapzenMap
settings.mapzenMap = mapzenMap
Expand Down Expand Up @@ -385,12 +384,11 @@ class MainActivity : AppCompatActivity(), MainViewController,
val listView = findViewById(R.id.auto_complete) as AutoCompleteListView
val emptyView = findViewById(android.R.id.empty)
val locationProvider = presenter.getPeliasLocationProvider()
val apiKeys = apiKeys
val callback = PeliasCallback()

addSearchViewToActionBar(searchView)
searchController.mainController = this
searchController.initSearchView(searchView, listView, emptyView, presenter, locationProvider, apiKeys, callback)
searchController.initSearchView(searchView, listView, emptyView, presenter, locationProvider, callback)
if (submitQueryOnMenuCreate != null) {
searchView.setQuery(submitQueryOnMenuCreate, true)
submitQueryOnMenuCreate = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.mapzen.erasermap.controller

import android.view.View
import com.mapzen.erasermap.model.ApiKeys
import com.mapzen.erasermap.presenter.MainPresenter
import com.mapzen.erasermap.view.SearchResultsAdapter
import com.mapzen.pelias.PeliasLocationProvider
Expand All @@ -19,7 +18,6 @@ interface SearchViewController {
emptyView: View,
presenter: MainPresenter,
locationProvider: PeliasLocationProvider,
apiKeys: ApiKeys?,
callback: MainActivity.PeliasCallback)
fun setSearchResultsAdapter(adapter: SearchResultsAdapter)
fun showSearchResults()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.mapzen.valhalla.RouteCallback
import com.mapzen.valhalla.Router

interface RouteManager {
var apiKey: String
var origin: ValhallaLocation?
var destination: Feature?
var type: Router.Type
Expand Down
20 changes: 11 additions & 9 deletions app/src/main/kotlin/com/mapzen/erasermap/model/TileHttpHandler.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.mapzen.erasermap.model

import okhttp3.Callback
import com.mapzen.android.graphics.MapzenMapHttpHandler
import java.io.File

class TileHttpHandler : TmpHttpHandler {
constructor() : super() {}

constructor(cacheDir: File, cacheSize: Long) : super(cacheDir, cacheSize) {}
class TileHttpHandler : MapzenMapHttpHandler {
override fun headersForRequest(): MutableMap<String, String> {
return mutableMapOf(Http.HEADER_DNT to Http.VALUE_HEADER_DNT)
}

override fun onRequest(url: String, headers: Map<String, String>, callback: Callback): Boolean {
val emHeaders = mutableMapOf(Http.HEADER_DNT to Http.VALUE_HEADER_DNT)
emHeaders.putAll(headers)
return super.onRequest(url, emHeaders, callback)
override fun queryParamsForRequest(): MutableMap<String, String> {
return mutableMapOf()
}

constructor() : super()

constructor(cacheDir: File, cacheSize: Long) : super(cacheDir, cacheSize)
}
182 changes: 0 additions & 182 deletions app/src/main/kotlin/com/mapzen/erasermap/model/TmpHttpHandler.java

This file was deleted.

Loading

0 comments on commit dc80674

Please sign in to comment.