Permalink
Browse files

simple my-location Maps V2 sample

  • Loading branch information...
1 parent b45a3ce commit 13d9d08ea5f95228bf9e1aa99d973b2ae5bb83b5 @commonsguy committed Mar 19, 2013
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>MapsV2MyLocation</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.commonsware.android.mapsv2.mylocation"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="9"
+ android:targetSdkVersion="16"/>
+
+ <permission
+ android:name="com.commonsware.android.mapsv2.mylocation.permission.MAPS_RECEIVE"
+ android:protectionLevel="signature"/>
+
+ <uses-permission android:name="com.commonsware.android.mapsv2.mylocation.permission.MAPS_RECEIVE"/>
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
+
+ <uses-feature
+ android:glEsVersion="0x00020000"
+ android:required="true"/>
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/Theme.Sherlock.Light.DarkActionBar">
+ <activity
+ android:name="MainActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+ <activity android:name="LegalNoticesActivity">
+ </activity>
+
+ <meta-data
+ android:name="com.google.android.maps.v2.API_KEY"
+ android:value="AIzaSyCis4NzxMw1aJyvUIrjGILjPkSdxrRfof4"/>
+ </application>
+
+</manifest>
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
@@ -0,0 +1,16 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-17
+android.library.reference.1=../../external/ActionBarSherlock
+android.library.reference.2=../../../../../../../../../opt/android-sdk-linux_x86/extras/google/google_play_services/libproject/google-play-services_lib
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,5 @@
+<fragment xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/map"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ class="com.google.android.gms.maps.SupportMapFragment"/>
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView
+ android:id="@+id/legal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"/>
+
+</ScrollView>
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:padding="2dip"
+ android:src="@drawable/ic_launcher"
+ android:contentDescription="@string/icon"/>
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="25sp"
+ android:textStyle="bold"/>
+
+ <TextView
+ android:id="@+id/snippet"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="15sp"/>
+ </LinearLayout>
+
+</LinearLayout>
@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@+id/legal"
+ android:orderInCategory="100"
+ android:showAsAction="never"
+ android:title="@string/legal"/>
+
+</menu>
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">MapsV2 My Location</string>
+ <string name="legal">Legal Notices</string>
+ <string name="no_maps">Google Maps V2 not available!</string>
+ <string name="normal">Normal</string>
+ <string name="hybrid">Hybrid</string>
+ <string name="satellite">Satellite</string>
+ <string name="terrain">Terrain</string>
+ <string name="un">UN</string>
+ <string name="united_nations">United Nations</string>
+ <string name="lincoln_center">Lincoln Center</string>
+ <string name="lincoln_center_snippet">Home of Jazz at Lincoln Center</string>
+ <string name="carnegie_hall">Carnegie Hall</string>
+ <string name="practice_x3">Where you go with practice, practice, practice</string>
+ <string name="downtown_club">The Downtown Club</string>
+ <string name="heisman_trophy">Original home of the Heisman Trophy</string>
+ <string name="icon">CommonsWare logo</string>
+
+</resources>
@@ -0,0 +1,100 @@
+/***
+ Copyright (c) 2012 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Android Development_
+ http://commonsware.com/Android
+ */
+
+package com.commonsware.android.mapsv2.mylocation;
+
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.widget.Toast;
+import com.actionbarsherlock.app.SherlockFragmentActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
+import com.google.android.gms.common.ConnectionResult;
+import com.google.android.gms.common.GooglePlayServicesUtil;
+
+public class AbstractMapActivity extends SherlockFragmentActivity {
+ protected static final String TAG_ERROR_DIALOG_FRAGMENT="errorDialog";
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getSupportMenuInflater().inflate(R.menu.activity_main, menu);
+
+ return(super.onCreateOptionsMenu(menu));
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == R.id.legal) {
+ startActivity(new Intent(this, LegalNoticesActivity.class));
+
+ return(true);
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ protected boolean readyToGo() {
+ int status=
+ GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
+
+ if (status == ConnectionResult.SUCCESS) {
+ return(true);
+ }
+ else if (GooglePlayServicesUtil.isUserRecoverableError(status)) {
+ ErrorDialogFragment.newInstance(status)
+ .show(getSupportFragmentManager(),
+ TAG_ERROR_DIALOG_FRAGMENT);
+ }
+ else {
+ Toast.makeText(this, R.string.no_maps, Toast.LENGTH_LONG).show();
+ finish();
+ }
+
+ return(false);
+ }
+
+ public static class ErrorDialogFragment extends DialogFragment {
+ static final String ARG_STATUS="status";
+
+ static ErrorDialogFragment newInstance(int status) {
+ Bundle args=new Bundle();
+
+ args.putInt(ARG_STATUS, status);
+
+ ErrorDialogFragment result=new ErrorDialogFragment();
+
+ result.setArguments(args);
+
+ return(result);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ Bundle args=getArguments();
+
+ return GooglePlayServicesUtil.getErrorDialog(args.getInt(ARG_STATUS),
+ getActivity(), 0);
+ }
+
+ @Override
+ public void onDismiss(DialogInterface dlg) {
+ if (getActivity() != null) {
+ getActivity().finish();
+ }
+ }
+ }
+}
@@ -0,0 +1,32 @@
+/***
+ Copyright (c) 2012 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Android Development_
+ http://commonsware.com/Android
+ */
+
+package com.commonsware.android.mapsv2.mylocation;
+
+import android.os.Bundle;
+import android.widget.TextView;
+import com.actionbarsherlock.app.SherlockActivity;
+import com.google.android.gms.common.GooglePlayServicesUtil;
+
+public class LegalNoticesActivity extends SherlockActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.legal);
+
+ TextView legal=(TextView)findViewById(R.id.legal);
+
+ legal.setText(GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(this));
+ }
+}
Oops, something went wrong.

0 comments on commit 13d9d08

Please sign in to comment.