Skip to content

Commit

Permalink
removes version from manifest and cleans key downloading logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kingofirony committed Jul 27, 2015
1 parent 1fb9fe6 commit 23d7197
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
4 changes: 1 addition & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapzen.erasermap"
android:versionCode="2"
android:versionName="0.1">
package="com.mapzen.erasermap">

<uses-feature android:glEsVersion="0x00020000" android:required="true" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

public class CrashReportService {
public void initAndStartSession(Context context) {
Mint.initAndStartSession(context, BuildConfig.MINT_API_KEY);
if(BuildConfig.MINT_API_KEY != null) {
Mint.initAndStartSession(context, BuildConfig.MINT_API_KEY);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
package com.mapzen.erasermap.model

import com.google.common.io.Files

import android.content.Context
import android.os.AsyncTask
import android.util.Log
import com.google.gson.Gson
import com.squareup.okhttp.OkHttpClient
import com.squareup.okhttp.Request
import com.squareup.okhttp.Response
import com.google.gson.JsonParseException
import com.mapzen.erasermap.model.ManifestModel
import com.squareup.okhttp.*

import java.io.BufferedInputStream
import java.io.File
import java.io.IOException
import java.io.InputStream
import java.net.HttpURLConnection
import java.net.MalformedURLException
import java.net.URL
import java.util.concurrent.TimeUnit
import javax.inject.Inject

public class ManifestDownLoader() {
private var client: OkHttpClient? = null
Expand Down
21 changes: 11 additions & 10 deletions app/src/main/kotlin/com/mapzen/erasermap/view/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class MainActivity : AppCompatActivity(), MainViewController, Router.Call
super<AppCompatActivity>.onCreate(savedInstanceState)
app = getApplication() as EraserMapApplication
app?.component()?.inject(this)
initCrashReportService()
setContentView(R.layout.activity_main)
presenter?.mainViewController = this
presenter?.bus = bus
Expand All @@ -93,7 +94,7 @@ public class MainActivity : AppCompatActivity(), MainViewController, Router.Call
initReverseButton()
centerMapOnCurrentLocation()
presenter?.onRestoreViewState()
getApiKeys({initCrashReportService()})
getApiKeys()
}

override fun onStart() {
Expand Down Expand Up @@ -148,16 +149,16 @@ public class MainActivity : AppCompatActivity(), MainViewController, Router.Call
crashReportService?.initAndStartSession(this)
}

private fun getApiKeys(callback : () -> Unit) {
private fun getApiKeys() {
var dl: ManifestDownLoader = ManifestDownLoader()
dl.download(apiKeys, callback)

if(apiKeys?.getValhallaApiKey()== null) {
apiKeys?.setValhallaApiKey(BuildConfig.VALHALLA_API_KEY)
}
if(apiKeys?.getVectorTileApiKeyReleaseProp()== null) {
apiKeys?.setVectorTileApiKeyReleaseProp(BuildConfig.VECTOR_TILE_API_KEY)
}
dl.download(apiKeys, {
if(apiKeys?.getValhallaApiKey()== null) {
apiKeys?.setValhallaApiKey(BuildConfig.VALHALLA_API_KEY)
}
if(apiKeys?.getVectorTileApiKeyReleaseProp()== null) {
apiKeys?.setVectorTileApiKeyReleaseProp(BuildConfig.VECTOR_TILE_API_KEY)
}
})
}

private fun initLocationUpdates() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ManifestDownLoaderTest {
throws(Exception::class)
public fun shouldRequestManifest() {
server?.enqueue(MockResponse().setBody(sampleResponse))
downLoader?.download(ManifestModel(), {})
downLoader?.download(ManifestModel())
var request = server?.takeRequest(1000, TimeUnit.MILLISECONDS);
assertThat(request?.getPath().toString()).isEqualTo("/erasermap_manifest")
}
Expand All @@ -52,8 +52,7 @@ public class ManifestDownLoaderTest {
public fun shouldSetManifestModelObject() {
var keys: ManifestModel = ManifestModel()
server?.enqueue(MockResponse().setBody(sampleResponse))
downLoader?.download(keys, {
})
downLoader?.download(keys)
server?.takeRequest(1000, TimeUnit.MILLISECONDS);
assertThat(keys.getValhallaApiKey()).isEqualTo("routeKey")
assertThat(keys.getVectorTileApiKeyReleaseProp()).isEqualTo("vectorKey")
Expand Down

0 comments on commit 23d7197

Please sign in to comment.