summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2014-12-18 19:29:55 +1100
committerLeith Bade <leith@mapbox.com>2014-12-18 19:29:55 +1100
commit465ae587a2ed6169df00b182d51f4f647f23c4f6 (patch)
tree69e9069dbf59d187180ecd84c80bc9522e72ff25
parent62038bb344645483f65c02b99b65e84e83fbe255 (diff)
downloadqtlocation-mapboxgl-465ae587a2ed6169df00b182d51f4f647f23c4f6.tar.gz
Use file for access token
-rw-r--r--README.md14
-rw-r--r--android/java/.gitignore3
-rw-r--r--android/java/app/src/main/java/com/mapbox/mapboxgl/app/MapFragment.java12
-rwxr-xr-xscripts/travis_before_install.sh4
4 files changed, 23 insertions, 10 deletions
diff --git a/README.md b/README.md
index c80e731ae5..0230ab378a 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ implemented in C++11, currently targeting iOS, OS X, and Ubuntu Linux.
We try to link to as many system-provided libraries as possible. When these are unavailable or too outdated, we run a thin build-script layer called [Mason](https://github.com/mapbox/mason) to automate builds, and load precompiled binary packages when possible.
-Be sure to pull down all submodules first:
+Be sure to pull down all submodules first:
git submodule init
git submodule update
@@ -114,7 +114,7 @@ Or the OPEN JDK:
sudo apt-get install -y openjdk-7-jdk
-Install Android NDK:
+Install Android NDK:
sudo apt-get install p7zip-full
wget http://dl.google.com/android/ndk/android-ndk-r10c-linux-x86_64.bin
@@ -123,7 +123,7 @@ Install Android NDK:
export ANDROID_NDK_PATH="$(pwd)/android-ndk-r10c"
export NDK_PATH=${ANDROID_NDK_PATH}
-Install Android SDK:
+Install Android SDK:
sudo apt-get install lib32stdc++6 lib32z1
wget http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz
@@ -131,7 +131,7 @@ Install Android SDK:
./android-sdk-linux/tools/android update sdk -u -a -t tools,platform-tools,build-tools-21.1.1,android-21,extra-android-m2repository,extra-google-m2repository
export ANDROID_HOME="$(pwd)/android-sdk-linux"
-Run:
+Run:
make android
@@ -141,11 +141,11 @@ You can also open `android/java` in Android Studio.
## Android (on OS X)
-Install the [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html) for 64-bit OS X.
+Install the [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html) for 64-bit OS X.
export ANDROID_NDK_PATH="/dir/to/android-ndk-r10c"
-Install the Android SDK. We recommend doing this by way of [Android Studio](https://developer.android.com/sdk/installing/studio.html). The latest versions recommend that you place the SDK someplace like `/usr/local/android-sdk-macosx`.
+Install the Android SDK. We recommend doing this by way of [Android Studio](https://developer.android.com/sdk/installing/studio.html). The latest versions recommend that you place the SDK someplace like `/usr/local/android-sdk-macosx`.
export ANDROID_HOME="/dir/to/android-sdk-macosx"
@@ -175,7 +175,7 @@ For iOS and OS X use of the demo apps in Xcode, setup the access token by editin
For Linux, set the environment variable `MAPBOX_ACCESS_TOKEN` to your token.
-For Android, open the class MapFragment and look for the line with `mMap.setAccessToken("access token goes here");`.
+For Android, create the file `android/java/app/src/main/res/raw/token.txt` and insert the token as a single line.
# Style
diff --git a/android/java/.gitignore b/android/java/.gitignore
index 2e8c5e2ba4..4c79b6763d 100644
--- a/android/java/.gitignore
+++ b/android/java/.gitignore
@@ -16,3 +16,6 @@ lib/src/main/assets/
# Local settings
local.properties
+
+# Token file
+app/src/main/res/raw/token.txt
diff --git a/android/java/app/src/main/java/com/mapbox/mapboxgl/app/MapFragment.java b/android/java/app/src/main/java/com/mapbox/mapboxgl/app/MapFragment.java
index 25723ea975..a9e6f0c89f 100644
--- a/android/java/app/src/main/java/com/mapbox/mapboxgl/app/MapFragment.java
+++ b/android/java/app/src/main/java/com/mapbox/mapboxgl/app/MapFragment.java
@@ -9,6 +9,10 @@ import android.view.ViewGroup;
import com.mapbox.mapboxgl.lib.MapView;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
public class MapFragment extends Fragment {
//
@@ -39,7 +43,13 @@ public class MapFragment extends Fragment {
mMap = (MapView) inflater.inflate(R.layout.fragment_main, container, true);
// Load the access token
- mMap.setAccessToken("access token goes here");
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(getActivity().getApplicationContext().getResources().openRawResource(R.raw.token)));
+ String line = reader.readLine();
+ mMap.setAccessToken(line);
+ } catch (IOException e) {
+ // Do nothing
+ }
// Need to pass on any saved state to the map
mMap.onCreate(savedInstanceState);
diff --git a/scripts/travis_before_install.sh b/scripts/travis_before_install.sh
index acddd16a49..4f07db4d29 100755
--- a/scripts/travis_before_install.sh
+++ b/scripts/travis_before_install.sh
@@ -46,7 +46,7 @@ if [[ "${MASON_PLATFORM}" == "android" ]]; then
echo y | ./android-sdk/tools/android update sdk -u -a -t tools,platform-tools,build-tools-21.1.2,android-21,extra-android-m2repository,extra-google-m2repository
echo "inserting access token"
- sed -i "s/access token goes here/${ANDROID_KEY}/g" android/java/app/src/main/java/com/mapbox/mapboxgl/app/MapFragment.java
+ echo "${ANDROID_KEY}" > android/java/app/src/res/token.txt
elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then
@@ -79,7 +79,7 @@ if [[ "${MASON_PLATFORM}" == "android" ]]; then
echo y | ./android-sdk/tools/android update sdk -u -a -t tools,platform-tools,build-tools-21.1.2,android-21,extra-android-m2repository,extra-google-m2repository
echo "inserting access token"
- sed -i "" "s/access token goes here/${ANDROID_KEY}/g" android/java/app/src/main/java/com/mapbox/mapboxgl/app/MapFragment.java
+ echo "${ANDROID_KEY}" > android/java/app/src/res/token.txt
fi