Skip to content
Browse files

adding map api v2 demo, updating gitignore

  • Loading branch information...
1 parent 2bb1098 commit 3052e6d253bd6a29c3e9b043ba87021242857ba5 @ouchadam ouchadam committed
View
49 .gitignore
@@ -1,17 +1,36 @@
-# need i
-bin
-bin/*
-gen/*
-gen
-.classpath
-.project
-default.*
-.settings/*
-**/.settings/*
-build.properties
-.DS_Store
+# built application files
+*.apk
+*.ap_
+
+# files for the dex VM
+*.dex
+
+# Java class files
*.class
-java/build
-java/*.log
-java/*.log.*
+
+# generated files
+bin/
+gen/
+out/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+.project
+.classpath
+.settings
target/
+libs/
+classes/
+gen-external-apklibs/
+
+# IDEA Ignores
+*.iml
+*.ipr
+*.iws
+.idea/
+local.properties
+project.properties
+
+# MAC
+*.DS_Store
View
41 MapApiV2Demo/.gitignore
@@ -0,0 +1,41 @@
+# built application files
+*.apk
+*.ap_
+
+# files for the dex VM
+*.dex
+
+# Java class files
+*.class
+
+# Jar files
+*.jar
+
+#ApkLibs
+*.apklib
+
+# generated files
+bin/
+gen/
+
+# Local configuration file (sdk path, etc)
+local.properties
+project.properties
+default.properties
+
+classes/
+
+
+#IntelliJ IDEA#
+*.iml
+*.ipr
+*.iws
+.idea
+target
+
+#Eclipse#
+.settings
+.classpath
+.project
+app/gen-external-apklibs/
+*.orig
View
13 MapApiV2Demo/README.md
@@ -0,0 +1,13 @@
+MapApiV2Demo
+============
+
+Based upon the Google-Play-Services r3 maps example.
+
+This project aims to show how simple it is to create a map and show your location on it.
+
+To use this demo you will need to provide your own Maps API Key. This needs to be placed in the AndroidManifest.xml.
+https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key
+
+The google-play-service has also been "mavenised" for ease of use,
+
+enjoy!
View
41 MapApiV2Demo/app/AndroidManifest.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.novoda.mapdemo"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <permission android:name="com.novoda.mapdemo.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
+ <uses-permission android:name="com.novoda.mapdemo.permission.MAPS_RECEIVE"/>
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="16"/>
+
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
+
+ <uses-feature
+ android:glEsVersion="0x00020000"
+ android:required="true"/>
+
+ <application
+ android:icon="@drawable/app_launcher"
+ android:label="@string/app_name"
+ android:hardwareAccelerated="true">
+
+ <meta-data
+ android:name="com.google.android.maps.v2.API_KEY"
+ android:value="YOUR_API_KEY_GOES_HERE"/>
+
+ <activity android:name=".activity.NovodaMapActivity" android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+
+ </application>
+</manifest>
View
106 MapApiV2Demo/app/pom.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>com.novoda</groupId>
+ <artifactId>MapApiV2Demo-parent</artifactId>
+ <version>1.0</version>
+ </parent>
+
+ <groupId>com.novoda</groupId>
+ <artifactId>app</artifactId>
+ <version>1.0</version>
+ <packaging>apk</packaging>
+ <name>MapApiV2Demo - Application</name>
+
+ <profiles>
+ <profile>
+ <id>emma</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.jayway.maven.plugins.android.generation2</groupId>
+ <artifactId>android-maven-plugin</artifactId>
+ <configuration>
+ <emma>
+ <enable>true</enable>
+ <classFolders>${project.basedir}/target/classes/</classFolders>
+ <outputMetaFile>${project.basedir}/target/emma/coverage.em</outputMetaFile>
+ </emma>
+ <dex>
+ <noLocals>true</noLocals>
+ </dex>
+ </configuration>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.android</groupId>
+ <artifactId>android</artifactId>
+ <version>${android.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.android</groupId>
+ <artifactId>support-v4</artifactId>
+ <version>${support-library.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.actionbarsherlock</groupId>
+ <artifactId>library</artifactId>
+ <version>4.1.0</version>
+ <type>apklib</type>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.extras</groupId>
+ <artifactId>google-play-services-src</artifactId>
+ <version>3.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.extras</groupId>
+ <artifactId>google-play-services</artifactId>
+ <version>3.0</version>
+ <type>apklib</type>
+ </dependency>
+
+ <dependency>
+ <groupId>com.novoda</groupId>
+ <artifactId>core</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>com.jayway.maven.plugins.android.generation2</groupId>
+ <artifactId>android-maven-plugin</artifactId>
+ <configuration>
+ <dex>
+ <jvmArguments>
+ <jvmArgument>-Xms256m</jvmArgument>
+ <jvmArgument>-Xmx512m</jvmArgument>
+ </jvmArguments>
+ </dex>
+ <sign>
+ <debug>both</debug>
+ </sign>
+ </configuration>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
View
BIN MapApiV2Demo/app/res/drawable-hdpi/app_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN MapApiV2Demo/app/res/drawable-ldpi/app_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN MapApiV2Demo/app/res/drawable-mdpi/app_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN MapApiV2Demo/app/res/drawable-xhdpi/app_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
19 MapApiV2Demo/app/res/layout/novoda_demo.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/Match"
+ android:orientation="vertical">
+
+ <fragment xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/map"
+ style="@style/Match"
+ android:layout_weight="0.2"
+ android:name="com.novoda.mapdemo.fragment.NovodaMapFragment"/>
+
+ <fragment xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/image_fragment"
+ style="@style/Match"
+ android:layout_weight="0.8"
+ android:name="com.novoda.mapdemo.fragment.SomeOtherFragment"/>
+
+</LinearLayout>
View
11 MapApiV2Demo/app/res/layout/some_other_fragment.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/Match">
+
+ <Button
+ android:id="@+id/fragment_button"
+ style="@style/Match"
+ android:text="Click me!"/>
+
+</LinearLayout>
View
6 MapApiV2Demo/app/res/values/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">MapApiV2Demo</string>
+
+</resources>
View
43 MapApiV2Demo/app/res/values/style_base.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<resources>
+
+ <style name="Vertical">
+ <item name="android:orientation">vertical</item>
+ </style>
+
+ <style name="Match" parent="Vertical">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">match_parent</item>
+ </style>
+
+ <style name="Wrap" parent="Vertical">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ </style>
+
+ <style
+ name="MatchHeight"
+ parent="Match">
+ <item name="android:layout_width">wrap_content</item>
+ </style>
+
+ <style
+ name="MatchWidth"
+ parent="Match">
+ <item name="android:layout_height">wrap_content</item>
+ </style>
+
+ <style
+ name="MatchHorizontal"
+ parent="Match">
+ <item name="android:orientation">horizontal</item>
+ </style>
+
+ <style
+ name="MatchWidthHorizontal"
+ parent="MatchWidth">
+ <item name="android:orientation">horizontal</item>
+ </style>
+
+</resources>
View
15 MapApiV2Demo/app/src/com/novoda/mapdemo/activity/NovodaMapActivity.java
@@ -0,0 +1,15 @@
+package com.novoda.mapdemo.activity;
+
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import com.novoda.mapdemo.R;
+
+public class NovodaMapActivity extends FragmentActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.novoda_demo);
+ }
+
+}
View
55 MapApiV2Demo/app/src/com/novoda/mapdemo/fragment/NovodaMapFragment.java
@@ -0,0 +1,55 @@
+package com.novoda.mapdemo.fragment;
+
+import android.content.Context;
+import android.location.Location;
+import android.location.LocationManager;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.google.android.gms.maps.CameraUpdate;
+import com.google.android.gms.maps.CameraUpdateFactory;
+import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.LatLng;
+
+public class NovodaMapFragment extends SupportMapFragment {
+
+ private static final int ZOOM_LEVEL = 16;
+ private GoogleMap map;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) {
+ View view = super.onCreateView(inflater, viewGroup, bundle);
+ setUpMapIfNeeded();
+ return view;
+ }
+
+ private void setUpMapIfNeeded() {
+ if (map == null) {
+ map = getMap();
+ if (map != null) {
+ setUpMap();
+ }
+ }
+ }
+
+ private void setUpMap() {
+ map.setMyLocationEnabled(true);
+ map.animateCamera(zoomToLastKnownLatLng());
+ }
+
+ private CameraUpdate zoomToLastKnownLatLng() {
+ return CameraUpdateFactory.newLatLngZoom(getLastKnownLatLng(), ZOOM_LEVEL);
+ }
+
+ private LatLng getLastKnownLatLng() {
+ Location location = ((LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE)).getLastKnownLocation("gps");

I think this can return null if no location is known

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ return locationToLatLng(location);
+ }
+
+ private LatLng locationToLatLng(Location location) {
+ return new LatLng(location.getLatitude(), location.getLongitude());
+ }
+
+}
View
32 MapApiV2Demo/app/src/com/novoda/mapdemo/fragment/SomeOtherFragment.java
@@ -0,0 +1,32 @@
+package com.novoda.mapdemo.fragment;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Toast;
+import com.novoda.mapdemo.R;
+
+public class SomeOtherFragment extends Fragment implements View.OnClickListener {
+
+ private static final String FRAGMENT_TOAST_MESSAGE = "Some other fragment logic!";
+
+ public SomeOtherFragment() {}
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.some_other_fragment, container, false);
+ view.findViewById(R.id.fragment_button).setOnClickListener(this);
+ return view;
+ }
+
+ @Override
+ public void onClick(View v) {
+ showToast();
+ }
+
+ private void showToast() {
+ Toast.makeText(getActivity(), FRAGMENT_TOAST_MESSAGE, Toast.LENGTH_SHORT).show();
+ }
+}
View
66 MapApiV2Demo/pom.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>com.novoda</groupId>
+ <artifactId>android</artifactId>
+ <version>2.0.2</version>
+ </parent>
+
+ <groupId>com.novoda</groupId>
+ <artifactId>MapApiV2Demo-parent</artifactId>
+ <version>1.0</version>
+ <packaging>pom</packaging>
+ <name>MapApiV2Demo - Parent</name>
+
+ <modules>
+ <module>app</module>
+ </modules>
+
+ <properties>
+ <android.version>4.1.1.4</android.version>
+ <android-test.version>2.3.3</android-test.version>
+ <android.sdk.platform>16</android.sdk.platform>
+ <android.maven.plugin.version>3.3.2</android.maven.plugin.version>
+ <junit.version>4.10</junit.version>
+ <support-library.version>r7</support-library.version>
+ <scm.branch>master</scm.branch>
+ </properties>
+
+ <repositories>
+
+ <repository>
+ <id>public-mvn-repo-releases</id>
+ <url>
+ https://github.com/novoda/public-mvn-repo/raw/master/releases
+ </url>
+ </repository>
+
+ <repository>
+ <id>jakewharton</id>
+ <url>http://r.jakewharton.com/maven/release/</url>
+ </repository>
+
+ </repositories>
+
+ <pluginRepositories>
+
+ <pluginRepository>
+ <id>public-mvn-repo.plugin-releases</id>
+ <url>https://github.com/novoda/public-mvn-repo/raw/master/releases</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+
+ </pluginRepositories>
+
+ <licenses>
+ <license>
+ <name>Apache 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ </license>
+ </licenses>
+</project>

0 comments on commit 3052e6d

Please sign in to comment.
Something went wrong with that request. Please try again.