diff --git a/.classpath b/.classpath deleted file mode 100644 index 6c635c0..0000000 --- a/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/.gitignore b/.gitignore index 0e19489..7100567 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,13 @@ -# Built app files +# Android Tools +# Is generated when importing via Eclipse +project.properties + + +# Android ########################### +# Source: https://github.com/github/gitignore/blob/master/Android.gitignore + +# Built application files +*.apk *.ap_ # files for the dex VM @@ -12,4 +21,58 @@ bin/ gen/ # Local configuration file (sdk path, etc) -local.properties \ No newline at end of file +local.properties + +# Eclipse project files +.classpath +.project + +# Proguard folder generated by Eclipse +proguard/ + +# Intellij project files +*.iml +*.ipr +*.iws +.idea/ +gen-external-apklibs + + + +# Maven ########################### +https://github.com/github/gitignore/blob/master/Maven.gitignore + +# Maven build folder +target/ + + + +# Eclipse ########################### +# Source: https://raw.github.com/github/gitignore/master/Global/Eclipse.gitignore + +*.pydevproject +.project +.metadata +bin/** +tmp/** +tmp/**/* +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath diff --git a/.project b/.project deleted file mode 100644 index c4f1c03..0000000 --- a/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - MapChange - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/AndroidManifest.xml b/AndroidManifest.xml deleted file mode 100644 index 8ad3e24..0000000 --- a/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7fb45e9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,24 @@ +Change Log +=============================================================================== + +Version 0.1.0-SNAPSHOT *(2013-06-07)* +------------------------------------- +* Split the project into a separate library and sample project. +* Add Maven support. +* Successfully tested with Eclipse 4.2.2, IntelliJ 12.1.3, Android Studio 0.1.1. +* Remove project files generated by Eclipse. +* Update .gitignore to exclude IDE noise and generated files. +* Remove .apk from repository. +* Set version tag to `0.1.0-SNAPSHOT`. +* Update `README.md`. +* Add this changelog file. + + +No official version *(2012-12-03)* +------------------------------------- +* Add support for double tap gesture. Allows to zoom in the map. + + +No official version *(2011-10-31)* +------------------------------------- +* Original release. diff --git a/MapChangeLibrary/AndroidManifest.xml b/MapChangeLibrary/AndroidManifest.xml new file mode 100644 index 0000000..2ec6bd9 --- /dev/null +++ b/MapChangeLibrary/AndroidManifest.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/MapChangeLibrary/pom.xml b/MapChangeLibrary/pom.xml new file mode 100644 index 0000000..5c14295 --- /dev/null +++ b/MapChangeLibrary/pom.xml @@ -0,0 +1,58 @@ + + + + + + 4.0.0 + + com.bricolsoftconsulting + mapchange-library + 0.1.0-SNAPSHOT + apklib + MapChange Library + https://github.com/bricolsoftconsulting/MapChangeLibrary + Google Maps notifications on panning, zooming or both + + + com.bricolsoftconsulting + mapchange-parent + 0.1.0-SNAPSHOT + + + + ${project.artifactId} + + src + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + ${android-maven-plugin.version} + + + ${sdk.platform} + + + true + + + + diff --git a/proguard.cfg b/MapChangeLibrary/proguard.cfg similarity index 100% rename from proguard.cfg rename to MapChangeLibrary/proguard.cfg diff --git a/res/drawable-hdpi/icon.png b/MapChangeLibrary/res/drawable-hdpi/icon.png similarity index 100% rename from res/drawable-hdpi/icon.png rename to MapChangeLibrary/res/drawable-hdpi/icon.png diff --git a/res/drawable-ldpi/icon.png b/MapChangeLibrary/res/drawable-ldpi/icon.png similarity index 100% rename from res/drawable-ldpi/icon.png rename to MapChangeLibrary/res/drawable-ldpi/icon.png diff --git a/res/drawable-mdpi/icon.png b/MapChangeLibrary/res/drawable-mdpi/icon.png similarity index 100% rename from res/drawable-mdpi/icon.png rename to MapChangeLibrary/res/drawable-mdpi/icon.png diff --git a/res/values/strings.xml b/MapChangeLibrary/res/values/strings.xml similarity index 100% rename from res/values/strings.xml rename to MapChangeLibrary/res/values/strings.xml diff --git a/src/com/bricolsoftconsulting/mapchange/MyMapView.java b/MapChangeLibrary/src/com/bricolsoftconsulting/mapchange/MyMapView.java similarity index 96% rename from src/com/bricolsoftconsulting/mapchange/MyMapView.java rename to MapChangeLibrary/src/com/bricolsoftconsulting/mapchange/MyMapView.java index b5c2430..d725cf8 100644 --- a/src/com/bricolsoftconsulting/mapchange/MyMapView.java +++ b/MapChangeLibrary/src/com/bricolsoftconsulting/mapchange/MyMapView.java @@ -1,5 +1,5 @@ /* -Copyright 2012 Bricolsoft Consulting +Copyright 2013 Bricolsoft Consulting Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -24,21 +24,21 @@ import com.google.android.maps.MapView; public class MyMapView extends MapView -{ +{ // ------------------------------------------------------------------------ // LISTENER DEFINITIONS // ------------------------------------------------------------------------ - + // Change listener public interface OnChangeListener { public void onChange(MapView view, GeoPoint newCenter, GeoPoint oldCenter, int newZoom, int oldZoom); } - + // ------------------------------------------------------------------------ // MEMBERS // ------------------------------------------------------------------------ - + private MyMapView mThis; private long mEventsTimeout = 250L; // Set this variable to your preferred timeout private boolean mIsTouched = false; @@ -46,11 +46,11 @@ public interface OnChangeListener private int mLastZoomLevel; //private Timer mChangeDelayTimer = new Timer(); private MyMapView.OnChangeListener mChangeListener = null; - + // ------------------------------------------------------------------------ // RUNNABLES // ------------------------------------------------------------------------ - + private Runnable mOnChangeTask = new Runnable() { @Override @@ -58,43 +58,43 @@ public void run() { if (mChangeListener != null) mChangeListener.onChange(mThis, getMapCenter(), mLastCenterPosition, getZoomLevel(), mLastZoomLevel); mLastCenterPosition = getMapCenter(); - mLastZoomLevel = getZoomLevel(); + mLastZoomLevel = getZoomLevel(); } }; - + // ------------------------------------------------------------------------ // CONSTRUCTORS // ------------------------------------------------------------------------ - + public MyMapView(Context context, String apiKey) { super(context, apiKey); init(); } - + public MyMapView(Context context, AttributeSet attrs) { super(context, attrs); init(); } - + public MyMapView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } - + private void init() { mThis = this; mLastCenterPosition = this.getMapCenter(); mLastZoomLevel = this.getZoomLevel(); } - + // ------------------------------------------------------------------------ // GETTERS / SETTERS // ------------------------------------------------------------------------ - + public void setOnChangeListener(MyMapView.OnChangeListener l) { mChangeListener = l; @@ -103,10 +103,10 @@ public void setOnChangeListener(MyMapView.OnChangeListener l) // ------------------------------------------------------------------------ // EVENT HANDLERS // ------------------------------------------------------------------------ - + @Override public boolean onTouchEvent(MotionEvent ev) - { + { // Set touch internal mIsTouched = (ev.getAction() != MotionEvent.ACTION_UP); @@ -117,11 +117,11 @@ public boolean onTouchEvent(MotionEvent ev) public void computeScroll() { super.computeScroll(); - + // Check for change if (isSpanChange() || isZoomChange()) { - // If computeScroll called before timer counts down we should drop it and + // If computeScroll called before timer counts down we should drop it and // start counter over again resetMapChangeTimer(); } @@ -130,25 +130,25 @@ public void computeScroll() // ------------------------------------------------------------------------ // TIMER RESETS // ------------------------------------------------------------------------ - + private void resetMapChangeTimer() { MyMapView.this.removeCallbacks(mOnChangeTask); MyMapView.this.postDelayed(mOnChangeTask, mEventsTimeout); } - + // ------------------------------------------------------------------------ // CHANGE FUNCTIONS // ------------------------------------------------------------------------ - + private boolean isSpanChange() { return !mIsTouched && !getMapCenter().equals(mLastCenterPosition); } - + private boolean isZoomChange() { return (getZoomLevel() != mLastZoomLevel); } - -} \ No newline at end of file + +} diff --git a/src/com/bricolsoftconsulting/mapchange/MyOverlay.java b/MapChangeLibrary/src/com/bricolsoftconsulting/mapchange/MyOverlay.java similarity index 96% rename from src/com/bricolsoftconsulting/mapchange/MyOverlay.java rename to MapChangeLibrary/src/com/bricolsoftconsulting/mapchange/MyOverlay.java index 662a90b..41b171a 100644 --- a/src/com/bricolsoftconsulting/mapchange/MyOverlay.java +++ b/MapChangeLibrary/src/com/bricolsoftconsulting/mapchange/MyOverlay.java @@ -1,5 +1,5 @@ /* -Copyright 2012 Bricolsoft Consulting +Copyright 2013 Bricolsoft Consulting Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -52,32 +52,32 @@ public boolean onDoubleTap(MotionEvent e) return true; } }; - + // ------------------------------------------------------------------------ // CONSTRUCTOR // ------------------------------------------------------------------------ - - MyOverlay(Context context, MapView mapView) + + public MyOverlay(Context context, MapView mapView) { mMapView = mapView; - mGestureDetector = new GestureDetector(context, mGestureListener); + mGestureDetector = new GestureDetector(context, mGestureListener); } - + // ------------------------------------------------------------------------ // LISTENER DEFINITIONS // ------------------------------------------------------------------------ - + // Tap listener public interface OnTapListener { public void onTap(GeoPoint p, MapView mapView); public void onDoubleTap(GeoPoint p, MapView mapView); } - + // ------------------------------------------------------------------------ // GETTERS / SETTERS // ------------------------------------------------------------------------ - + // Setters public void setOnTapListener(OnTapListener listener) { @@ -87,15 +87,15 @@ public void setOnTapListener(OnTapListener listener) // ------------------------------------------------------------------------ // MEMBERS // ------------------------------------------------------------------------ - + private OnTapListener mTapListener; - + // ------------------------------------------------------------------------ // EVENT HANDLERS // ------------------------------------------------------------------------ - + public boolean onTouchEvent(MotionEvent motionEvent, MapView mapView) { return mGestureDetector.onTouchEvent(motionEvent); } -} \ No newline at end of file +} diff --git a/MapChangeSample/AndroidManifest.xml b/MapChangeSample/AndroidManifest.xml new file mode 100644 index 0000000..e925fba --- /dev/null +++ b/MapChangeSample/AndroidManifest.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/MapChangeSample/pom.xml b/MapChangeSample/pom.xml new file mode 100644 index 0000000..a2ff8e6 --- /dev/null +++ b/MapChangeSample/pom.xml @@ -0,0 +1,90 @@ + + + + + + 4.0.0 + + + com.bricolsoftconsulting + mapchange-parent + 0.1.0-SNAPSHOT + + + com.bricolsoftconsulting + mapchange-sample + 0.1.0-SNAPSHOT + apk + MapChange Sample + https://github.com/bricolsoftconsulting/MapChangeSample + Google Maps notifications on panning, zooming or both + + + 2.6 + + + + + com.bricolsoftconsulting + mapchange-library + 0.1.0-SNAPSHOT + compile + apklib + + + + + ${project.artifactId} + + src + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + ${android-maven-plugin.version} + + + ${sdk.platform} + + true + + true + + + maven-resources-plugin + ${maven-resources-plugin.version} + + + initialize + + resources + + + + default-resources + DISABLED + + + + + + + diff --git a/MapChangeSample/proguard.cfg b/MapChangeSample/proguard.cfg new file mode 100644 index 0000000..12dd039 --- /dev/null +++ b/MapChangeSample/proguard.cfg @@ -0,0 +1,36 @@ +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.preference.Preference +-keep public class com.android.vending.licensing.ILicensingService + +-keepclasseswithmembernames class * { + native ; +} + +-keepclasseswithmembernames class * { + public (android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembernames class * { + public (android.content.Context, android.util.AttributeSet, int); +} + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} diff --git a/MapChangeSample/res/drawable-hdpi/icon.png b/MapChangeSample/res/drawable-hdpi/icon.png new file mode 100644 index 0000000..8074c4c Binary files /dev/null and b/MapChangeSample/res/drawable-hdpi/icon.png differ diff --git a/MapChangeSample/res/drawable-ldpi/icon.png b/MapChangeSample/res/drawable-ldpi/icon.png new file mode 100644 index 0000000..1095584 Binary files /dev/null and b/MapChangeSample/res/drawable-ldpi/icon.png differ diff --git a/MapChangeSample/res/drawable-mdpi/icon.png b/MapChangeSample/res/drawable-mdpi/icon.png new file mode 100644 index 0000000..a07c69f Binary files /dev/null and b/MapChangeSample/res/drawable-mdpi/icon.png differ diff --git a/res/layout/map.xml b/MapChangeSample/res/layout/map.xml similarity index 83% rename from res/layout/map.xml rename to MapChangeSample/res/layout/map.xml index d7eb8e7..4ab7a35 100644 --- a/res/layout/map.xml +++ b/MapChangeSample/res/layout/map.xml @@ -4,14 +4,14 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" > - + + android:id="@+id/theMap" + android:apiKey="@string/google_maps_api_key"> - + diff --git a/MapChangeSample/res/values/apikeys.xml b/MapChangeSample/res/values/apikeys.xml new file mode 100644 index 0000000..e3c76ab --- /dev/null +++ b/MapChangeSample/res/values/apikeys.xml @@ -0,0 +1,4 @@ + + + ENTER_GOOGLE_MAPS_API_KEY_HERE + diff --git a/MapChangeSample/res/values/strings.xml b/MapChangeSample/res/values/strings.xml new file mode 100644 index 0000000..5202606 --- /dev/null +++ b/MapChangeSample/res/values/strings.xml @@ -0,0 +1,4 @@ + + + MapChange + diff --git a/src/com/bricolsoftconsulting/mapchange/MyMapActivity.java b/MapChangeSample/src/com/bricolsoftconsulting/mapchange/MyMapActivity.java similarity index 95% rename from src/com/bricolsoftconsulting/mapchange/MyMapActivity.java rename to MapChangeSample/src/com/bricolsoftconsulting/mapchange/MyMapActivity.java index 9bf0d0a..e4918c0 100644 --- a/src/com/bricolsoftconsulting/mapchange/MyMapActivity.java +++ b/MapChangeSample/src/com/bricolsoftconsulting/mapchange/MyMapActivity.java @@ -1,5 +1,5 @@ /* -Copyright 2012 Bricolsoft Consulting +Copyright 2013 Bricolsoft Consulting Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -31,29 +31,29 @@ public class MyMapActivity extends MapActivity MyMapView mMapView; MyOverlay mMapOverlay; Handler mHandler = new Handler(); - + /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map); - + // Populate the map member mMapView = (MyMapView) findViewById(R.id.theMap); - + // Add overlay mMapOverlay = new MyOverlay(getBaseContext(), mMapView); - mMapView.getOverlays().add(mMapOverlay); - + mMapView.getOverlays().add(mMapOverlay); + // Add zoom controls mMapView.setBuiltInZoomControls(true); - + // Add listeners mMapView.setOnChangeListener(new MapViewChangeListener()); mMapOverlay.setOnTapListener(new MapViewTapListener()); } - + private class MapViewChangeListener implements MyMapView.OnChangeListener { @@ -73,9 +73,9 @@ else if (newZoom != oldZoom) { Toast.makeText(MyMapActivity.this, "Map Zoom", Toast.LENGTH_SHORT).show(); } - } + } } - + private class MapViewTapListener implements MyOverlay.OnTapListener { @Override @@ -92,7 +92,7 @@ public void onDoubleTap(GeoPoint p, MapView mapView) Point screenPoint = new Point(); mMapView.getProjection().toPixels(p, screenPoint); mMapView.getController().zoomInFixing(screenPoint.x, screenPoint.y); - + // Display message Toast.makeText(MyMapActivity.this, "Map Double Tap", Toast.LENGTH_SHORT).show(); } @@ -103,4 +103,4 @@ protected boolean isRouteDisplayed() { return false; } -} \ No newline at end of file +} diff --git a/README.md b/README.md index 14d36e2..77863b5 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,47 @@ What is MapChange? --------------------- MapChange is an Android app that shows how to extend Google Maps' MapView class to get notifications when the map has been panned, zoomed or both. + Installation ------------ To setup this project: 1. Download a copy of this code. -1. Edit the `map.xml` file in `/res/layout` to add your Google Maps API Key on this line: +1. Edit the `apikeys.xml` file in `/res/values` to add your Google Maps API Key on this line: - android:apiKey="ENTER_GOOGLE_MAPS_API_KEY_HERE" + `google_maps_api_key="ENTER_GOOGLE_MAPS_API_KEY_HERE"` Usage ----- Pan, zoom or pinch the map. The app will tell you what you just did (panned, zoomed or both). + +Project structure +----------------- +There is a library project named `MapChangeLibrary` which can be used with other applications. +The sample application named `MapChangeSample` shows how to integrate the functionality of the library. + +IDEs +---- +The projects have been set up to work with common IDEs such as Eclipse, IntelliJ or Android Studio. + + +Maven +----- + +MapChange is **not** yet available from Maven central repository. You can however easily install it into your local repository. + +In order to use the library project add the following dependency to your application `pom.xml`: + + + com.bricolsoftconsulting + mapchange-library + 0.1.0-SNAPSHOT + compile + apklib + + + Credits ------- Thanks to [Dave Smith](https://github.com/devunwired) for suggesting the use of View.postDelayed instead of a timer so the change events are not launched on the timer's background thread. His wonderful suggestion has been incorporated in this code. @@ -26,10 +54,17 @@ Thanks to [Tobias](https://github.com/johnjohndoe) for his patch to support map Copyright --------- -Copyright 2012 Bricolsoft Consulting -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 + Copyright 2013 Bricolsoft Consulting + + 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 + 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. \ No newline at end of file + 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. diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..5e9b73e --- /dev/null +++ b/pom.xml @@ -0,0 +1,110 @@ + + + + + + 4.0.0 + + com.bricolsoftconsulting + mapchange-parent + 0.1.0-SNAPSHOT + pom + MapChange Library Parent + Google Maps notifications on panning, zooming or both + + + MapChangeLibrary + MapChangeSample + + + + https://github.com/bricolsoftconsulting/MapChangeLibrary/issues + GitHub Issues + + + + + Apache License Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.html + repo + + + + + https://github.com/bricolsoftconsulting/MapChange + scm:git:git://github.com/bricolsoftconsulting/MapChange.git + scm:git:git@github.com:bricolsoftconsulting/MapChange.git + + + + + Bricolsoftconsulting Consulting + https://github.com/bricolsoftconsulting + bricolsoftconsulting + + + + + UTF-8 + + + 1.6 + 7 + 3.6.0 + 2.3.2 + + + 4.1.1.4 + 7_r1 + + + + + com.google.android + android + provided + ${android.version} + + + com.google.android.maps + maps + ${android.maps.version} + provided + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${jdk.version} + ${jdk.version} + + + + + + + diff --git a/project.properties b/project.properties deleted file mode 100644 index 6adb3d6..0000000 --- a/project.properties +++ /dev/null @@ -1,11 +0,0 @@ -# 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 use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=Google Inc.:Google APIs:7 diff --git a/release/MapChange.apk b/release/MapChange.apk deleted file mode 100644 index 0c3509d..0000000 Binary files a/release/MapChange.apk and /dev/null differ