aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Priegnitz <koem@petoria.de>2011-09-12 14:13:20 +0200
committerKarsten Priegnitz <koem@petoria.de>2011-09-12 14:13:20 +0200
commit6792a4a775f38d633aa1e9fb28cc3283cd23fcba (patch)
treeff100c99da6ed24da0dc47b363ac1551f7d6c4cf
parentac21e4d660dcdff30e99c7073a9164a3128a298a (diff)
downloadcgeo-6792a4a775f38d633aa1e9fb28cc3283cd23fcba.zip
cgeo-6792a4a775f38d633aa1e9fb28cc3283cd23fcba.tar.gz
cgeo-6792a4a775f38d633aa1e9fb28cc3283cd23fcba.tar.bz2
locus API as jar
-rw-r--r--libs/locus-api-4.0.jarbin0 -> 29175 bytes
-rw-r--r--src/cgeo/geocaching/apps/AbstractLocusApp.java27
-rwxr-xr-xsrc/cgeo/geocaching/apps/LocusDataStorageProvider.java68
-rwxr-xr-xsrc/cgeo/geocaching/enumerations/CacheSize.java9
-rwxr-xr-xsrc/cgeo/geocaching/enumerations/CacheType.java9
-rwxr-xr-xsrc/cgeo/geocaching/enumerations/WaypointType.java35
-rw-r--r--src/menion/android/locus/addon/publiclib/DisplayData.java109
-rw-r--r--src/menion/android/locus/addon/publiclib/LocusConst.java12
-rw-r--r--src/menion/android/locus/addon/publiclib/LocusUtils.java137
-rw-r--r--src/menion/android/locus/addon/publiclib/geoData/Point.java146
-rw-r--r--src/menion/android/locus/addon/publiclib/geoData/PointGeocachingAttributes.java122
-rw-r--r--src/menion/android/locus/addon/publiclib/geoData/PointGeocachingData.java316
-rw-r--r--src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataLog.java69
-rw-r--r--src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataTravelBug.java86
-rw-r--r--src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataWaypoint.java80
-rw-r--r--src/menion/android/locus/addon/publiclib/geoData/PointsData.java122
-rw-r--r--src/menion/android/locus/addon/publiclib/utils/DataCursor.java331
-rw-r--r--src/menion/android/locus/addon/publiclib/utils/DataStorage.java28
18 files changed, 130 insertions, 1576 deletions
diff --git a/libs/locus-api-4.0.jar b/libs/locus-api-4.0.jar
new file mode 100644
index 0000000..8b6b5a9
--- /dev/null
+++ b/libs/locus-api-4.0.jar
Binary files differ
diff --git a/src/cgeo/geocaching/apps/AbstractLocusApp.java b/src/cgeo/geocaching/apps/AbstractLocusApp.java
index f86a465..1b21b8e 100644
--- a/src/cgeo/geocaching/apps/AbstractLocusApp.java
+++ b/src/cgeo/geocaching/apps/AbstractLocusApp.java
@@ -23,6 +23,9 @@ import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.WaypointType;
+/**
+ * @see http://forum.asamm.cz/viewtopic.php?f=29&t=767
+ */
public abstract class AbstractLocusApp extends AbstractApp {
private static final String INTENT = Intent.ACTION_VIEW;
private static final SimpleDateFormat ISO8601DATE = new SimpleDateFormat("yyyy-MM-dd'T'");
@@ -105,18 +108,10 @@ public abstract class AbstractLocusApp extends AbstractApp {
pg.name = cache.name;
pg.placedBy = cache.owner;
if (cache.hidden != null) pg.hidden = ISO8601DATE.format(cache.hidden.getTime());
- for (CacheType ct : CacheType.values()) {
- if (ct.cgeoId.equals(cache.type)) {
- if (ct.locusId != CacheType.NO_LOCUS_ID) pg.type = ct.locusId;
- break;
- }
- }
- for (CacheSize cs : CacheSize.values()) {
- if (cs.cgeoId.equals(cache.size)) {
- pg.container = cs.locusId;
- break;
- }
- }
+ CacheType ct = CacheType.findByCgeoId(cache.type);
+ if (ct != null && ct.locusId != CacheType.NO_LOCUS_ID) pg.type = ct.locusId;
+ CacheSize cs = CacheSize.findByCgeoId(cache.size);
+ if (cs != null) pg.container = cs.locusId;
if (cache.difficulty != null) pg.difficulty = cache.difficulty;
if (cache.terrain != null) pg.terrain = cache.terrain;
pg.found = cache.found;
@@ -128,12 +123,8 @@ public abstract class AbstractLocusApp extends AbstractApp {
PointGeocachingDataWaypoint wp = new PointGeocachingDataWaypoint();
wp.code = waypoint.geocode;
wp.name = waypoint.name;
- for (WaypointType wt : WaypointType.values()) {
- if (wt.cgeoId.equals(waypoint.type)) {
- wp.type = wt.locusId;
- break;
- }
- }
+ WaypointType wt = WaypointType.findByCgeoId(waypoint.type);
+ if (wt != null) wp.type = wt.locusId;
wp.lat = waypoint.coords.getLatitude();
wp.lon = waypoint.coords.getLongitude();
pg.waypoints.add(wp);
diff --git a/src/cgeo/geocaching/apps/LocusDataStorageProvider.java b/src/cgeo/geocaching/apps/LocusDataStorageProvider.java
new file mode 100755
index 0000000..8da7160
--- /dev/null
+++ b/src/cgeo/geocaching/apps/LocusDataStorageProvider.java
@@ -0,0 +1,68 @@
+package cgeo.geocaching.apps;
+
+import java.util.ArrayList;
+
+import menion.android.locus.addon.publiclib.geoData.PointsData;
+import menion.android.locus.addon.publiclib.utils.DataCursor;
+import menion.android.locus.addon.publiclib.utils.DataStorage;
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Parcel;
+
+public class LocusDataStorageProvider extends ContentProvider {
+
+// private final static String TAG = "DataStorageProvider";
+
+ @Override
+ public Cursor query(Uri aUri, String[] aProjection, String aSelection,
+ String[] aSelectionArgs, String aSortOrder) {
+
+ DataCursor cursor = new DataCursor(new String[] {"data"});
+
+ ArrayList<PointsData> data = DataStorage.getData();
+ if (data == null || data.size() == 0)
+ return cursor;
+
+ for (int i = 0; i < data.size(); i++) {
+ // get byte array
+ Parcel par = Parcel.obtain();
+ data.get(i).writeToParcel(par, 0);
+ byte[] byteData = par.marshall();
+ // add to row
+ cursor.addRow(new Object[] {byteData});
+ }
+ // data filled to cursor, clear reference to prevent some memory issue
+ DataStorage.clearData();
+ // now finally return filled cursor
+ return cursor;
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return null;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ return null;
+ }
+
+ @Override
+ public boolean onCreate() {
+ return false;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection,
+ String[] selectionArgs) {
+ return 0;
+ }
+
+}
diff --git a/src/cgeo/geocaching/enumerations/CacheSize.java b/src/cgeo/geocaching/enumerations/CacheSize.java
index b6b9d34..1d0577d 100755
--- a/src/cgeo/geocaching/enumerations/CacheSize.java
+++ b/src/cgeo/geocaching/enumerations/CacheSize.java
@@ -24,4 +24,13 @@ public enum CacheSize {
this.comparable = comparable;
this.locusId = locusId;
}
+
+ public static CacheSize findByCgeoId(String cgeoId) {
+ if (cgeoId == null) return null;
+ for (CacheSize cs : CacheSize.values()) {
+ if (cs.cgeoId.equals(cgeoId)) return cs;
+ }
+ return null;
+ }
+
}
diff --git a/src/cgeo/geocaching/enumerations/CacheType.java b/src/cgeo/geocaching/enumerations/CacheType.java
index a521c0e..923972b 100755
--- a/src/cgeo/geocaching/enumerations/CacheType.java
+++ b/src/cgeo/geocaching/enumerations/CacheType.java
@@ -44,4 +44,13 @@ public enum CacheType {
this.stringId = stringId;
this.locusId = locusId;
}
+
+ public static CacheType findByCgeoId(String cgeoId) {
+ if (cgeoId == null) return null;
+ for (CacheType ct : CacheType.values()) {
+ if (ct.cgeoId.equals(cgeoId)) return ct;
+ }
+ return null;
+ }
+
}
diff --git a/src/cgeo/geocaching/enumerations/WaypointType.java b/src/cgeo/geocaching/enumerations/WaypointType.java
new file mode 100755
index 0000000..ec442a0
--- /dev/null
+++ b/src/cgeo/geocaching/enumerations/WaypointType.java
@@ -0,0 +1,35 @@
+package cgeo.geocaching.enumerations;
+
+import menion.android.locus.addon.publiclib.geoData.PointGeocachingData;
+
+/**
+ * Enum listing waypoint types
+ *
+ * @author koem
+ */
+public enum WaypointType {
+ FLAG ("flag", PointGeocachingData.CACHE_WAYPOINT_TYPE_FINAL),
+ OWN ("own", PointGeocachingData.CACHE_WAYPOINT_TYPE_STAGES),
+ PKG ("pkg", PointGeocachingData.CACHE_WAYPOINT_TYPE_PARKING),
+ PUZZLE ("puzzle", PointGeocachingData.CACHE_WAYPOINT_TYPE_QUESTION),
+ STAGE ("stage", PointGeocachingData.CACHE_WAYPOINT_TYPE_STAGES),
+ TRAILHEAD ("trailhead", PointGeocachingData.CACHE_WAYPOINT_TYPE_TRAILHEAD),
+ WAYPOINT ("waypoint", PointGeocachingData.CACHE_WAYPOINT_TYPE_STAGES);
+
+ public final String cgeoId;
+ public final String locusId;
+
+ private WaypointType(String cgeoId, String locusId) {
+ this.cgeoId = cgeoId;
+ this.locusId = locusId;
+ }
+
+ public static WaypointType findByCgeoId(String cgeoId) {
+ if (cgeoId == null) return null;
+ for (WaypointType wt : WaypointType.values()) {
+ if (wt.cgeoId.equals(cgeoId)) return wt;
+ }
+ return null;
+ }
+
+}
diff --git a/src/menion/android/locus/addon/publiclib/DisplayData.java b/src/menion/android/locus/addon/publiclib/DisplayData.java
deleted file mode 100644
index e3f86db..0000000
--- a/src/menion/android/locus/addon/publiclib/DisplayData.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package menion.android.locus.addon.publiclib;
-
-import java.util.ArrayList;
-
-import menion.android.locus.addon.publiclib.geoData.PointsData;
-import menion.android.locus.addon.publiclib.utils.DataStorage;
-
-import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
-
-public class DisplayData {
-
- private static final String TAG = "TAG";
-
- /**
- * Simple way how to send data over intent to Locus. Count that intent in
- * Android have some size limits so for larger data, use another method
- * @param context actual context
- * @param data PointsData object that should be send to Locus
- * @param callImport wheather import with this data should be called after Locus starts
- * @return true if success
- */
- public static boolean sendData(Context context, PointsData data, boolean callImport) {
- if (data == null)
- return false;
- Intent intent = new Intent();
- intent.putExtra(LocusConst.EXTRA_POINTS_DATA, data);
- return sendData(context, intent, callImport);
- }
-
- /**
- * Simple way how to send ArrayList<PointsData> object over intent to Locus. Count that
- * intent in Android have some size limits so for larger data, use another method
- * @param context actual context
- * @param data ArrayList of data that should be send to Locus
- * @return true if success
- */
- public static boolean sendData(Context context, ArrayList<PointsData> data, boolean callImport) {
- if (data == null)
- return false;
- Intent intent = new Intent();
- intent.putParcelableArrayListExtra(LocusConst.EXTRA_POINTS_DATA_ARRAY, data);
- return sendData(context, intent, callImport);
- }
-
- /**
- * Way how to send ArrayList<PointsData> object over intent to Locus. Data are
- * stored in ContentProvider so don't forget to register it in manifest. More in
- * sample application. This is recommended way how to send huge data to Locus
- * @param context actual context
- * @param data ArrayList of data that should be send to Locus
- * @param callImport wheather import with this data should be called after Locus starts
- * @return true if success
- */
- public static boolean sendDataCursor(Context context, PointsData data, String uri, boolean callImport) {
- if (data == null)
- return false;
- // set data
- DataStorage.setData(data);
- Intent intent = new Intent();
- intent.putExtra(LocusConst.EXTRA_POINTS_CURSOR_URI, uri);
- return sendData(context, intent, callImport);
- }
-
- /**
- * Way how to send ArrayList<PointsData> object over intent to Locus. Data are
- * stored in ContentProvider so don't forget to register it in manifest. More in
- * sample application. This is recommended way how to send huge data to Locus
- * @param context actual context
- * @param data ArrayList of data that should be send to Locus
- * @return true if success
- */
- public static boolean sendDataCursor(Context context, ArrayList<PointsData> data,
- String uri, boolean callImport) {
- if (data == null)
- return false;
- // set data
- DataStorage.setData(data);
- Intent intent = new Intent();
- intent.putExtra(LocusConst.EXTRA_POINTS_CURSOR_URI, uri);
- return sendData(context, intent, callImport);
- }
-
- // private final call to Locus
- private static boolean sendData(Context context, Intent intent, boolean callImport) {
- // really exist locus?
- if (!LocusUtils.isLocusAvailable(context)) {
- Log.w(TAG, "Locus is not installed");
- return false;
- }
-
- // check intent firstly
- if (intent == null || (intent.getParcelableArrayListExtra(LocusConst.EXTRA_POINTS_DATA_ARRAY) == null &&
- intent.getParcelableExtra(LocusConst.EXTRA_POINTS_DATA) == null &&
- intent.getStringExtra(LocusConst.EXTRA_POINTS_CURSOR_URI) == null)) {
- Log.w(TAG, "Intent 'null' or not contain any data");
- return false;
- }
-
- intent.putExtra(LocusConst.EXTRA_CALL_IMPORT, callImport);
-
- // create intent with right calling method
- intent.setAction(LocusConst.INTENT_DISPLAY_DATA);
- // finally start activity
- context.startActivity(intent);
- return true;
- }
-}
diff --git a/src/menion/android/locus/addon/publiclib/LocusConst.java b/src/menion/android/locus/addon/publiclib/LocusConst.java
deleted file mode 100644
index e96a31f..0000000
--- a/src/menion/android/locus/addon/publiclib/LocusConst.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package menion.android.locus.addon.publiclib;
-
-public class LocusConst {
-
- public static final String INTENT_DISPLAY_DATA = "android.intent.action.LOCUS_PUBLIC_LIB_DATA";
-
- public static final String EXTRA_POINTS_DATA = "EXTRA_POINTS_DATA";
- public static final String EXTRA_POINTS_DATA_ARRAY = "EXTRA_POINTS_DATA_ARRAY";
- public static final String EXTRA_POINTS_CURSOR_URI = "EXTRA_POINTS_CURSOR_URI";
-
- public static final String EXTRA_CALL_IMPORT = "EXTRA_CALL_IMPORT";
-}
diff --git a/src/menion/android/locus/addon/publiclib/LocusUtils.java b/src/menion/android/locus/addon/publiclib/LocusUtils.java
deleted file mode 100644
index 45de4bd..0000000
--- a/src/menion/android/locus/addon/publiclib/LocusUtils.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package menion.android.locus.addon.publiclib;
-
-import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-
-/**
- * Locus Helper class
- *
- * @author Menion Asamm
- * @author Arcao
- *
- */
-public class LocusUtils {
-
- /** Locus Free package name */
- public static final String LOCUS_FREE_PACKAGE_NAME = "menion.android.locus";
- /** Locus Pro package name */
- public static final String LOCUS_PRO_PACKAGE_NAME = "menion.android.locus.pro";
- /** All Locus package names */
- public static final String[] LOCUS_PACKAGE_NAMES = new String[] {
- LOCUS_PRO_PACKAGE_NAME, LOCUS_FREE_PACKAGE_NAME };
-
- /**
- * Returns <code>true</code> if Locus Pro or Locus Free is installed.
- *
- * @param context
- * actual {@link Context}
- * @return true or false
- */
- public static boolean isLocusAvailable(Context context) {
- return getLocusPackageInfo(context) != null;
- }
-
- /**
- * Returns {@link PackageInfo} with information about Locus or null if Locus
- * is not installed.
- *
- * @param context
- * actual {@link Context}
- * @return instance of PackageInfo object
- */
- public static PackageInfo getLocusPackageInfo(Context context) {
- PackageInfo info = null;
- for (String p : LOCUS_PACKAGE_NAMES) {
- try {
- info = context.getPackageManager().getPackageInfo(p, 0);
- break;
- } catch (PackageManager.NameNotFoundException e) {
- }
- }
-
- return info;
- }
-
- /**
- * Returns Locus version, e.g. <code>"1.9.5.1"</code>. If Locus is not
- * installed returns <code>null</code>.
- *
- * @param context
- * actual {@link Context}
- * @return version
- */
- public static String getLocusVersion(Context context) {
- PackageInfo info = getLocusPackageInfo(context);
-
- if (info == null)
- return null;
-
- return info.versionName;
- }
-
- /**
- * Returns Locus version code, e.g. <code>99</code>. If Locus is not
- * installed returns <code>-1</code>.
- *
- * @param context
- * actual {@link Context}
- * @return version code
- */
- public static int getLocusVersionCode(Context context) {
- PackageInfo info = getLocusPackageInfo(context);
-
- if (info == null)
- return -1;
-
- return info.versionCode;
- }
-
- /**
- * Returns <code>true</code> if Locus Pro is installed.
- *
- * @param context
- * actual {@link Context}
- * @return true or false
- */
- public static boolean isLocusProInstalled(Context context) {
- try {
- context.getPackageManager().getPackageInfo(LOCUS_PRO_PACKAGE_NAME,
- 0);
- return true;
- } catch (PackageManager.NameNotFoundException e) {
- return false;
- }
- }
-
- /**
- * Returns a package name of Locus (Pro). If Locus is not installed returns
- * null.
- *
- * @param context
- * actual {@link Context}
- * @return package name
- */
- public static String getLocusPackageName(Context context) {
- PackageInfo info = getLocusPackageInfo(context);
- if (info == null)
- return null;
- return info.packageName;
- }
-
- /**
- * Returns a package name like {@link #getLocusPackageName(Context)} but if
- * Locus is not installed returns a default package name constant
- * {@link #LOCUS_FREE_PACKAGE_NAME}.
- *
- * @param context
- * actual {@link Context}
- * @return package name
- */
- public static String getLocusDefaultPackageName(Context context) {
- String name = getLocusPackageName(context);
- if (name == null)
- return LOCUS_FREE_PACKAGE_NAME;
- return name;
- }
-}
diff --git a/src/menion/android/locus/addon/publiclib/geoData/Point.java b/src/menion/android/locus/addon/publiclib/geoData/Point.java
deleted file mode 100644
index e0f0f63..0000000
--- a/src/menion/android/locus/addon/publiclib/geoData/Point.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package menion.android.locus.addon.publiclib.geoData;
-
-import android.location.Location;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-public class Point implements Parcelable {
-
- private static final int VERSION = 0;
-
- /* mName of object */
- private String mName;
- /* mDesc of object */
- private String mDesc;
- /* mLoc of this point */
- private Location mLoc;
- /* extra intent data */
- private String mExtraData;
- /* additional geoCaching data */
- private PointGeocachingData mGeoCachingData;
-
- public Point(String name, Location loc) {
- this.mName = name;
- this.mDesc = null;
- this.mLoc = loc;
- this.mExtraData = null;
- this.mGeoCachingData = null;
- }
-
- public String getName() {
- return mName;
- }
-
- public String getDescription() {
- return mDesc;
- }
-
- public void setDescription(String desc) {
- this.mDesc = desc;
- }
-
- public Location getLocation() {
- return mLoc;
- }
-
- public String getExtra() {
- return mExtraData;
- }
-
- /**
- * Simply allow set callback value on point
- * @param btnName Name displayed on button
- * @param packageName this value is used for creating intent that
- * will be called in callback (for example com.super.application)
- * @param className the name of the class inside of com.super.application
- * that implements the component (for example com.super.application.Main)
- * @param returnDataName String uder which data will be stored. Can be
- * retrieved by String data = getIntent.getStringExtra("returnData");
- * @param returnDataValue String uder which data will be stored. Can be
- * retrieved by String data = getIntent.getStringExtra("returnData");
- */
- public void setCallback(String btnName, String packageName, String className,
- String returnDataName, String returnDataValue) {
- StringBuffer buff = new StringBuffer();
- buff.append("intent").append(";");
- buff.append(btnName).append(";");
- buff.append(packageName).append(";");
- buff.append(className).append(";");
- buff.append(returnDataName).append(";");
- buff.append(returnDataValue).append(";");
- this.mExtraData = buff.toString();
- }
-
- public PointGeocachingData getGeocachingData() {
- return mGeoCachingData;
- }
-
- public void setGeocachingData(PointGeocachingData gcData) {
- this.mGeoCachingData = gcData;
- }
-
- /****************************/
- /* PARCELABLE PART */
- /****************************/
-
- public static final Parcelable.Creator<Point> CREATOR = new Parcelable.Creator<Point>() {
- public Point createFromParcel(Parcel in) {
- return new Point(in);
- }
-
- public Point[] newArray(int size) {
- return new Point[size];
- }
- };
-
- private Point(Parcel in) {
- switch (in.readInt()) {
- case 0:
- // load name
- mName = in.readString();
- // load description
- mDesc = in.readString();
- // load separate location
- mLoc = new Location(in.readString());
- mLoc.setTime(in.readLong());
- mLoc.setLatitude(in.readDouble());
- mLoc.setLongitude(in.readDouble());
- mLoc.setAltitude(in.readDouble());
- mLoc.setAccuracy(in.readFloat());
- mLoc.setBearing(in.readFloat());
- mLoc.setSpeed(in.readFloat());
- // load extra data
- mExtraData = in.readString();
- // load geocaching data
- mGeoCachingData = in.readParcelable(PointGeocachingData.class.getClassLoader());//PointGeocachingData.CREATOR.createFromParcel(in);
- break;
- }
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(VERSION);
- // write name
- dest.writeString(mName);
- // write description
- dest.writeString(mDesc);
- // write location as separate values (due to some problems with 'magic number'
- dest.writeString(mLoc.getProvider());
- dest.writeLong(mLoc.getTime());
- dest.writeDouble(mLoc.getLatitude());
- dest.writeDouble(mLoc.getLongitude());
- dest.writeDouble(mLoc.getAltitude());
- dest.writeFloat(mLoc.getAccuracy());
- dest.writeFloat(mLoc.getBearing());
- dest.writeFloat(mLoc.getSpeed());
- // write extra
- dest.writeString(mExtraData);
- // write geocaching data
- dest.writeParcelable(mGeoCachingData, flags);
- }
-}
diff --git a/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingAttributes.java b/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingAttributes.java
deleted file mode 100644
index f734302..0000000
--- a/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingAttributes.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
- *
- * Copyright (C) 2009-2010 Menion. All rights reserved.
- *
- * This file is part of the LocA & SmartMaps software.
- *
- * Email menion@asamm.cz for more information.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- ***************************************************************************/
-package menion.android.locus.addon.publiclib.geoData;
-
-import java.util.Hashtable;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * @author menion
- * @since 25.1.2010 2010
- */
-public class PointGeocachingAttributes implements Parcelable {
-
- private static final int VERSION = 0;
-
- public int id;
-
- public PointGeocachingAttributes() {
- id = 0;
- }
-
- private static Hashtable<String, Integer> attrIds = new Hashtable<String, Integer>();
- static {
- attrIds.put("http://www.geocaching.com/images/attributes/dogs", 1);
- attrIds.put("http://www.geocaching.com/images/attributes/fee", 2);
- attrIds.put("http://www.geocaching.com/images/attributes/rappelling", 3);
- attrIds.put("http://www.geocaching.com/images/attributes/boat", 4);
- attrIds.put("http://www.geocaching.com/images/attributes/scuba", 5);
- attrIds.put("http://www.geocaching.com/images/attributes/kids", 6);
- attrIds.put("http://www.geocaching.com/images/attributes/onehour", 7);
- attrIds.put("http://www.geocaching.com/images/attributes/scenic", 8);
- attrIds.put("http://www.geocaching.com/images/attributes/hiking", 9);
- attrIds.put("http://www.geocaching.com/images/attributes/climbing", 10);
- attrIds.put("http://www.geocaching.com/images/attributes/wading", 11);
- attrIds.put("http://www.geocaching.com/images/attributes/swimming", 12);
- attrIds.put("http://www.geocaching.com/images/attributes/available", 13);
- attrIds.put("http://www.geocaching.com/images/attributes/night", 14);
- attrIds.put("http://www.geocaching.com/images/attributes/winter", 15);
- attrIds.put("http://www.geocaching.com/images/attributes/camping", 16);
- attrIds.put("http://www.geocaching.com/images/attributes/poisonoak", 17);
- attrIds.put("http://www.geocaching.com/images/attributes/snakes", 18);
- attrIds.put("http://www.geocaching.com/images/attributes/ticks", 19);
- attrIds.put("http://www.geocaching.com/images/attributes/mine", 20);
- attrIds.put("http://www.geocaching.com/images/attributes/cliff", 21);
- attrIds.put("http://www.geocaching.com/images/attributes/hunting", 22);
- attrIds.put("http://www.geocaching.com/images/attributes/danger", 23);
- attrIds.put("http://www.geocaching.com/images/attributes/wheelchair", 24);
- attrIds.put("http://www.geocaching.com/images/attributes/parking", 25);
- attrIds.put("http://www.geocaching.com/images/attributes/public", 26);
- attrIds.put("http://www.geocaching.com/images/attributes/water", 27);
- attrIds.put("http://www.geocaching.com/images/attributes/restrooms", 28);
- attrIds.put("http://www.geocaching.com/images/attributes/phone", 29);
- attrIds.put("http://www.geocaching.com/images/attributes/picnic", 30);
- attrIds.put("http://www.geocaching.com/images/attributes/camping", 31);
- attrIds.put("http://www.geocaching.com/images/attributes/bicycles", 32);
- attrIds.put("http://www.geocaching.com/images/attributes/motorcycles", 33);
- attrIds.put("http://www.geocaching.com/images/attributes/quads", 34);
- attrIds.put("http://www.geocaching.com/images/attributes/jeeps", 35);
- attrIds.put("http://www.geocaching.com/images/attributes/snowmobiles", 36);
- attrIds.put("http://www.geocaching.com/images/attributes/horses", 37);
- attrIds.put("http://www.geocaching.com/images/attributes/campfires", 38);
- attrIds.put("http://www.geocaching.com/images/attributes/thorn",39 );
- attrIds.put("http://www.geocaching.com/images/attributes/stealth", 40);
- attrIds.put("http://www.geocaching.com/images/attributes/stroller", 41);
- attrIds.put("http://www.geocaching.com/images/attributes/firstaid", 42);
- attrIds.put("http://www.geocaching.com/images/attributes/cow", 43);
- attrIds.put("http://www.geocaching.com/images/attributes/flashlight", 44);
- }
-
- public void setByImgUrl(String url) {
- if (url != null && url.length() > 0) {
- id = attrIds.get(url.substring(0, url.lastIndexOf("-")));
- if (url.contains("-yes."))
- id += 100;
- }
- }
-
- /****************************/
- /* PARCELABLE PART */
- /****************************/
-
- public static final Parcelable.Creator<PointGeocachingAttributes> CREATOR = new Parcelable.Creator<PointGeocachingAttributes>() {
- public PointGeocachingAttributes createFromParcel(Parcel in) {
- return new PointGeocachingAttributes(in);
- }
-
- public PointGeocachingAttributes[] newArray(int size) {
- return new PointGeocachingAttributes[size];
- }
- };
-
- public PointGeocachingAttributes(Parcel in) {
- switch (in.readInt()) {
- case 0:
- id = in.readInt();
- break;
- }
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(VERSION);
- dest.writeInt(id);
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-}
diff --git a/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingData.java b/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingData.java
deleted file mode 100644
index 420da0c..0000000
--- a/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingData.java
+++ /dev/null
@@ -1,316 +0,0 @@
-package menion.android.locus.addon.publiclib.geoData;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.util.Log;
-
-public class PointGeocachingData implements Parcelable {
-
- private static final int VERSION = 2;
-
- public static final int CACHE_NUMBER_OF_TYPES = 14;
-
- public static final int CACHE_TYPE_TRADITIONAL = 0;
- public static final int CACHE_TYPE_MULTI = 1;
- public static final int CACHE_TYPE_MYSTERY = 2;
- public static final int CACHE_TYPE_VIRTUAL = 3;
- public static final int CACHE_TYPE_EARTH = 4;
- public static final int CACHE_TYPE_PROJECT_APE = 5;
- public static final int CACHE_TYPE_LETTERBOX = 6;
- public static final int CACHE_TYPE_WHERIGO = 7;
- public static final int CACHE_TYPE_EVENT = 8;
- public static final int CACHE_TYPE_MEGA_EVENT = 9;
- public static final int CACHE_TYPE_CACHE_IN_TRASH_OUT = 10;
- public static final int CACHE_TYPE_GPS_ADVENTURE = 11;
- public static final int CACHE_TYPE_WEBCAM = 12;
- public static final int CACHE_TYPE_LOCATIONLESS = 13;
-
- public static final int CACHE_LOG_TYPE_UNKNOWN = -1;
- public static final int CACHE_LOG_TYPE_FOUNDED = 0;
- public static final int CACHE_LOG_TYPE_NOT_FOUNDED = 1;
- public static final int CACHE_LOG_TYPE_WRITE_NOTE = 2;
- public static final int CACHE_LOG_TYPE_NEEDS_MAINTENANCE = 3;
- public static final int CACHE_LOG_TYPE_OWNER_MAINTENANCE = 4;
- public static final int CACHE_LOG_TYPE_PUBLISH_LISTING = 5;
- public static final int CACHE_LOG_TYPE_ENABLE_LISTING = 6;
- public static final int CACHE_LOG_TYPE_TEMPORARILY_DISABLE_LISTING = 7;
- public static final int CACHE_LOG_TYPE_UPDATE_COORDINATES = 8;
- public static final int CACHE_LOG_TYPE_ANNOUNCEMENT = 9;
- public static final int CACHE_LOG_TYPE_WILL_ATTEND = 10;
- public static final int CACHE_LOG_TYPE_ATTENDED = 11;
- public static final int CACHE_LOG_TYPE_POST_REVIEWER_NOTE = 12;
- public static final int CACHE_LOG_TYPE_NEEDS_ARCHIVED = 13;
- public static final int CACHE_LOG_TYPE_WEBCAM_PHOTO_TAKEN = 14;
- public static final int CACHE_LOG_TYPE_RETRACT_LISTING = 15;
-
- public static final int CACHE_SIZE_NOT_CHOSEN = 0;
- public static final int CACHE_SIZE_MICRO = 1;
- public static final int CACHE_SIZE_SMALL = 2;
- public static final int CACHE_SIZE_REGULAR = 3;
- public static final int CACHE_SIZE_LARGE = 4;
- public static final int CACHE_SIZE_HUGE = 5;
- public static final int CACHE_SIZE_OTHER = 6;
-
- public static final String CACHE_WAYPOINT_TYPE_QUESTION = "Question to Answer";
- public static final String CACHE_WAYPOINT_TYPE_FINAL = "Final Location";
- public static final String CACHE_WAYPOINT_TYPE_PARKING = "Parking Area";
- public static final String CACHE_WAYPOINT_TYPE_TRAILHEAD = "Trailhead";
- public static final String CACHE_WAYPOINT_TYPE_STAGES = "Stages of a Multicache";
- public static final String CACHE_WAYPOINT_TYPE_REFERENCE = "Reference Point";
-
- /* id of point - not needed as I remember */
- public int id;
- /* whole cache ID from gc.com - so GC... - !REQUIRED! */
- public String cacheID;
- /* is available or disable */
- public boolean available;
- /* cache already archived or not */
- public boolean archived;
- /* available only for premium members */
- public boolean premiumOnly;
- /* name of cache - !REQUIRED! */
- public String name;
- /* String with date of last update - groundspeak:lastUpdated*/
- public String lastUpdated;
- /* String with date of last exported - groundspeak:exported */
- public String exported;
- /* name of person who placed cache - groundspeak:placed_by */
- public String placedBy;
- /* name of cache owner - groundspeak:owner */
- public String owner;
- /* String with date of hidden - value from CachePrinter */
- public String hidden;
- /* cache type */
- public int type;
- /* container size */
- public int container;
- /* dificulty value - 1.0 - 5.0 (by 0.5) */
- public float difficulty;
- /* terrain value - 1.0 - 5.0 (by 0.5) */
- public float terrain;
- /* country name */
- public String country;
- /* state name */
- public String state;
- /* short description of cache */
- public String shortDescription;
- /* full description with complete (HTML) listing */
- public String longDescription;
- /* encoded hints */
- public String encodedHints;
- /* list of attributes */
- public ArrayList<PointGeocachingAttributes> attributes;
- /* list of logs */
- public ArrayList<PointGeocachingDataLog> logs;
- /* list of travel bugs */
- public ArrayList<PointGeocachingDataTravelBug> travelBugs;
- /* list of waypoints */
- public ArrayList<PointGeocachingDataWaypoint> waypoints;
- /* user notes */
- public String notes;
- /* if cache is already computed - have final waypoint and is placed on it's location */
- public boolean computed;
- /* if cache is already found */
- public boolean found;
-
- public PointGeocachingData() {
- id = 0;
- cacheID = "";
- available = true;
- archived = false;
- premiumOnly = false;
- name = "";
- lastUpdated = "";
- exported = "";
- placedBy = "";
- owner = "";
- hidden = "";
- type = CACHE_TYPE_TRADITIONAL;
- container = CACHE_SIZE_NOT_CHOSEN;
- difficulty = -1.0f;
- terrain = -1.0f;
- country = "";
- state = "";
- shortDescription = "";
- longDescription = "";
- encodedHints = "";
- attributes = new ArrayList<PointGeocachingAttributes>();
- logs = new ArrayList<PointGeocachingDataLog>();
- travelBugs = new ArrayList<PointGeocachingDataTravelBug>();
- waypoints = new ArrayList<PointGeocachingDataWaypoint>();
- notes = "";
- computed = false;
- found = false;
- }
-
- /****************************/
- /* PARCELABLE PART */
- /****************************/
-
- public static final Parcelable.Creator<PointGeocachingData> CREATOR = new Parcelable.Creator<PointGeocachingData>() {
- public PointGeocachingData createFromParcel(Parcel in) {
- return new PointGeocachingData(in);
- }
-
- public PointGeocachingData[] newArray(int size) {
- return new PointGeocachingData[size];
- }
- };
-
- @SuppressWarnings("unchecked")
- public PointGeocachingData(Parcel in) {
- int version = in.readInt();
- if (version == 0) {
- id = in.readInt();
- cacheID = in.readString();
- available = in.readInt() == 1;
- archived = in.readInt() == 1;
- premiumOnly = in.readInt() == 1;
- name = in.readString();
- lastUpdated = in.readString();
- exported = in.readString();
- placedBy = in.readString();
- owner = in.readString();
- hidden = in.readString();
- type = in.readInt();
- container = in.readInt();
- difficulty = in.readFloat();
- terrain = in.readFloat();
- country = in.readString();
- state = in.readString();
- shortDescription = in.readString();
- longDescription = in.readString();
- encodedHints = in.readString();
- attributes = in.readArrayList(PointGeocachingAttributes.class.getClassLoader());
- logs = in.readArrayList(PointGeocachingDataLog.class.getClassLoader());
- travelBugs = in.readArrayList(PointGeocachingDataTravelBug.class.getClassLoader());
- waypoints = in.readArrayList(PointGeocachingDataWaypoint.class.getClassLoader());
- notes = in.readString();
- computed = in.readInt() == 1;
- } else if (version > 0) {
- id = in.readInt();
- cacheID = in.readString();
- available = in.readInt() == 1;
- archived = in.readInt() == 1;
- premiumOnly = in.readInt() == 1;
- name = in.readString();
- lastUpdated = in.readString();
- exported = in.readString();
- placedBy = in.readString();
- owner = in.readString();
- hidden = in.readString();
- type = in.readInt();
- container = in.readInt();
- difficulty = in.readFloat();
- terrain = in.readFloat();
- country = in.readString();
- state = in.readString();
- try {
- int size = in.readInt();
- int lengthSD = in.readInt();
-
- byte[] data = new byte[size];
- in.readByteArray(data);
-
- GZIPInputStream zis = new GZIPInputStream(new ByteArrayInputStream(data), 10240);
- StringBuffer buffer = new StringBuffer();
-
-// byte[] dataD = new byte[10240];
-// int bytesRead;
-// while ((bytesRead = zis.read(dataD)) != -1) {
-// buffer.append(new String(dataD, 0, bytesRead, "utf-8"));
-// }
-// String result = buffer.toString();
-// zis.close();
-
- InputStreamReader isr = new InputStreamReader(zis, "UTF-8");
- char[] dataD = new char[1024];
- int charsRead;
- while ((charsRead = isr.read(dataD)) != -1) {
- buffer.append(dataD, 0, charsRead);
- }
- String result = buffer.toString();
- isr.close();
-
- // read short description
- if (lengthSD > 0)
- shortDescription = result.substring(0, lengthSD);
-
- // read long description
- longDescription = result.substring(lengthSD);
- } catch (Exception e) {
- Log.e("PointGeocachingData", "Problem in ZIP compression - read", e);
- }
- encodedHints = in.readString();
- attributes = in.readArrayList(PointGeocachingAttributes.class.getClassLoader());
- logs = in.readArrayList(PointGeocachingDataLog.class.getClassLoader());
- travelBugs = in.readArrayList(PointGeocachingDataTravelBug.class.getClassLoader());
- waypoints = in.readArrayList(PointGeocachingDataWaypoint.class.getClassLoader());
- notes = in.readString();
- computed = in.readInt() == 1;
- if (version == 2) {
- found = in.readInt() == 1;
- }
- }
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(VERSION);
- dest.writeInt(id);
- dest.writeString(cacheID);
- dest.writeInt(available ? 1 : 0);
- dest.writeInt(archived ? 1 : 0);
- dest.writeInt(premiumOnly ? 1 : 0);
- dest.writeString(name);
- dest.writeString(lastUpdated);
- dest.writeString(exported);
- dest.writeString(placedBy);
- dest.writeString(owner);
- dest.writeString(hidden);
- dest.writeInt(type);
- dest.writeInt(container);
- dest.writeFloat(difficulty);
- dest.writeFloat(terrain);
- dest.writeString(country);
- dest.writeString(state);
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- GZIPOutputStream zos = new GZIPOutputStream(baos);
-
- zos.write(shortDescription.getBytes("utf-8"));
- zos.write(longDescription.getBytes("utf-8"));
- zos.close();
-
- byte[] data = baos.toByteArray();
- baos.close();
-
- dest.writeInt(data.length);
- dest.writeInt(shortDescription.length());
- dest.writeByteArray(data);
- } catch (Exception e) {
- Log.e("PointGeocachingData", "Problem in ZIP compression - write", e);
- }
-
- dest.writeString(encodedHints);
- dest.writeList(attributes);
- dest.writeList(logs);
- dest.writeList(travelBugs);
- dest.writeList(waypoints);
- dest.writeString(notes);
- dest.writeInt(computed ? 1 : 0);
- dest.writeInt(found ? 1 : 0);
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-}
diff --git a/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataLog.java b/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataLog.java
deleted file mode 100644
index 9e7624b..0000000
--- a/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataLog.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package menion.android.locus.addon.publiclib.geoData;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-public class PointGeocachingDataLog implements Parcelable {
-
- private static final int VERSION = 1;
-
- public int id;
- public int type;
- public String date;
- public String finder;
- public int finderFound;
- public String logText;
-
- public PointGeocachingDataLog() {
- id = 0;
- type = PointGeocachingData.CACHE_LOG_TYPE_UNKNOWN;
- date = "";
- finder = "";
- finderFound = 0;
- logText = "";
- }
-
- /****************************/
- /* PARCELABLE PART */
- /****************************/
-
- public static final Parcelable.Creator<PointGeocachingDataLog> CREATOR = new Parcelable.Creator<PointGeocachingDataLog>() {
- public PointGeocachingDataLog createFromParcel(Parcel in) {
- return new PointGeocachingDataLog(in);
- }
-
- public PointGeocachingDataLog[] newArray(int size) {
- return new PointGeocachingDataLog[size];
- }
- };
-
- public PointGeocachingDataLog(Parcel in) {
- switch (in.readInt()) {
- case 1:
- id = in.readInt();
- case 0:
- type = in.readInt();
- date = in.readString();
- finder = in.readString();
- finderFound = in.readInt();
- logText = in.readString();
- break;
- }
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(VERSION);
- dest.writeInt(id);
- dest.writeInt(type);
- dest.writeString(date);
- dest.writeString(finder);
- dest.writeInt(finderFound);
- dest.writeString(logText);
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-} \ No newline at end of file
diff --git a/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataTravelBug.java b/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataTravelBug.java
deleted file mode 100644
index 9ab6c85..0000000
--- a/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataTravelBug.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package menion.android.locus.addon.publiclib.geoData;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-public class PointGeocachingDataTravelBug implements Parcelable {
-
- private static final int VERSION = 0;
-
- /* name of travel bug */
- public String name;
- /* image url to this travel bug */
- public String imgUrl;
- /* original page data */
- public String srcDetails;
-
- /* owner of TB */
- public String owner;
- /* String date of release */
- public String released;
- /* origin place */
- public String origin;
- /* goal of this TB */
- public String goal;
- /* details */
- public String details;
-
- public PointGeocachingDataTravelBug() {
- name = "";
- imgUrl = "";
- srcDetails = "";
-
- owner = "";
- released = "";
- origin = "";
- goal = "";
- details = "";
- }
-
- /****************************/
- /* PARCELABLE PART */
- /****************************/
-
- public static final Parcelable.Creator<PointGeocachingDataTravelBug> CREATOR = new Parcelable.Creator<PointGeocachingDataTravelBug>() {
- public PointGeocachingDataTravelBug createFromParcel(Parcel in) {
- return new PointGeocachingDataTravelBug(in);
- }
-
- public PointGeocachingDataTravelBug[] newArray(int size) {
- return new PointGeocachingDataTravelBug[size];
- }
- };
-
- public PointGeocachingDataTravelBug(Parcel in) {
- switch (in.readInt()) {
- case 0:
- name = in.readString();
- imgUrl = in.readString();
- srcDetails = in.readString();
- owner = in.readString();
- released = in.readString();
- origin = in.readString();
- goal = in.readString();
- details = in.readString();
- break;
- }
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(VERSION);
- dest.writeString(name);
- dest.writeString(imgUrl);
- dest.writeString(srcDetails);
- dest.writeString(owner);
- dest.writeString(released);
- dest.writeString(origin);
- dest.writeString(goal);
- dest.writeString(details);
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-} \ No newline at end of file
diff --git a/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataWaypoint.java b/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataWaypoint.java
deleted file mode 100644
index e478cbb..0000000
--- a/src/menion/android/locus/addon/publiclib/geoData/PointGeocachingDataWaypoint.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package menion.android.locus.addon.publiclib.geoData;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-public class PointGeocachingDataWaypoint implements Parcelable {
-
- private static final int VERSION = 1;
-
- /* code of wpt */
- public String code;
- /* name of waypoint */
- public String name;
- /* description (may be HTML code) */
- public String description;
- /* type of waypoint (defined in PointGeocachingData) */
- public String type;
- /* image URL to this wpt (not needed) */
- public String typeImagePath;
- /* latitude of waypoint */
- public double lat;
- /* longitude of waypoint */
- public double lon;
-
- public PointGeocachingDataWaypoint() {
- code = "";
- name = "";
- description = "";
- type = "";
- typeImagePath = "";
- lat = 0.0;
- lon = 0.0;
- }
-
- /****************************/
- /* PARCELABLE PART */
- /****************************/
-
- public static final Parcelable.Creator<PointGeocachingDataWaypoint> CREATOR = new Parcelable.Creator<PointGeocachingDataWaypoint>() {
- public PointGeocachingDataWaypoint createFromParcel(Parcel in) {
- return new PointGeocachingDataWaypoint(in);
- }
-
- public PointGeocachingDataWaypoint[] newArray(int size) {
- return new PointGeocachingDataWaypoint[size];
- }
- };
-
- public PointGeocachingDataWaypoint(Parcel in) {
- switch (in.readInt()) {
- case 1:
- code = in.readString();
- case 0:
- name = in.readString();
- description = in.readString();
- type = in.readString();
- typeImagePath = in.readString();
- lat = in.readDouble();
- lon = in.readDouble();
- break;
- }
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(VERSION);
- dest.writeString(code);
- dest.writeString(name);
- dest.writeString(description);
- dest.writeString(type);
- dest.writeString(typeImagePath);
- dest.writeDouble(lat);
- dest.writeDouble(lon);
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-} \ No newline at end of file
diff --git a/src/menion/android/locus/addon/publiclib/geoData/PointsData.java b/src/menion/android/locus/addon/publiclib/geoData/PointsData.java
deleted file mode 100644
index ab8f193..0000000
--- a/src/menion/android/locus/addon/publiclib/geoData/PointsData.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package menion.android.locus.addon.publiclib.geoData;
-
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-public class PointsData implements Parcelable {
-
- private static final int VERSION = 0;
-
- // Unique name. PointsData send to Locus with same name will be overwrited in Locus
- private String mName;
- // icon applied to whole PointsData
- private Bitmap mBitmap;
- // ArrayList of all points stored in this object
- private ArrayList<Point> mPoints;
-
- public PointsData(String uniqueName) {
- this.mName = uniqueName;
- this.mBitmap = null;
- this.mPoints = new ArrayList<Point>();
- }
-
- public String getName() {
- return mName;
- }
-
- public Bitmap getBitmap() {
- return mBitmap;
- }
-
- public void setBitmap(Bitmap bitmap) {
- this.mBitmap = bitmap;
- }
-
- public void addPoint(Point point) {
- this.mPoints.add(point);
- }
-
- public ArrayList<Point> getPoints() {
- return mPoints;
- }
-
- /****************************/
- /* PARCELABLE PART */
- /****************************/
-
- public static final Parcelable.Creator<PointsData> CREATOR = new Parcelable.Creator<PointsData>() {
- public PointsData createFromParcel(Parcel in) {
- return new PointsData(in);
- }
-
- public PointsData[] newArray(int size) {
- return new PointsData[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @SuppressWarnings("unchecked")
- private PointsData(Parcel in) {
- switch (in.readInt()) {
- case 0:
- mName = in.readString();
- int size = in.readInt();
- if (size > 0) {
- byte[] data = new byte[size];
- in.readByteArray(data);
- mBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
- } else {
- mBitmap = null;
- }
-
- mPoints = in.readArrayList(Point.class.getClassLoader());
- break;
- }
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(VERSION);
- dest.writeString(mName);
- if (mBitmap == null) {
- dest.writeInt(0);
- } else {
- byte[] data = getBitmapAsByte(mBitmap);
- if (data == null || data.length == 0) {
- dest.writeInt(0);
- } else {
- dest.writeInt(data.length);
- dest.writeByteArray(data);
- }
- }
- dest.writeList(mPoints);
- }
-
- private static byte[] getBitmapAsByte(Bitmap bitmap) {
- ByteArrayOutputStream baos = null;
- try {
- baos = new ByteArrayOutputStream();
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
- return baos.toByteArray();
- } catch (Exception e) {
- return null;
- } finally {
- try {
- if (baos != null){
- baos.close();
- baos = null;
- }
- } catch (Exception e) {}
- }
- }
-
-}
diff --git a/src/menion/android/locus/addon/publiclib/utils/DataCursor.java b/src/menion/android/locus/addon/publiclib/utils/DataCursor.java
deleted file mode 100644
index 5f3912e..0000000
--- a/src/menion/android/locus/addon/publiclib/utils/DataCursor.java
+++ /dev/null
@@ -1,331 +0,0 @@
-package menion.android.locus.addon.publiclib.utils;
-
-import java.util.ArrayList;
-
-import android.database.AbstractCursor;
-import android.database.CursorIndexOutOfBoundsException;
-import android.database.CursorWindow;
-
-/**
- * A mutable cursor implementation backed by an array of {@code Object}s. Use
- * {@link #newRow()} to add rows. Automatically expands internal capacity as
- * needed.
- */
-public class DataCursor extends AbstractCursor {
-
- private final String[] columnNames;
- private Object[] data;
- private int rowCount = 0;
- private final int columnCount;
-
- /**
- * Constructs a new cursor with the given initial capacity.
- *
- * @param columnNames
- * names of the columns, the ordering of which determines column
- * ordering elsewhere in this cursor
- * @param initialCapacity
- * in rows
- */
- public DataCursor(String[] columnNames, int initialCapacity) {
- this.columnNames = columnNames;
- this.columnCount = columnNames.length;
-
- if (initialCapacity < 1) {
- initialCapacity = 1;
- }
-
- this.data = new Object[columnCount * initialCapacity];
- }
-
- /**
- * Constructs a new cursor.
- *
- * @param columnNames
- * names of the columns, the ordering of which determines column
- * ordering elsewhere in this cursor
- */
- public DataCursor(String[] columnNames) {
- this(columnNames, 16);
- }
-
- /**
- * Gets value at the given column for the current row.
- */
- private Object get(int column) {
- if (column < 0 || column >= columnCount) {
- throw new CursorIndexOutOfBoundsException("Requested column: "
- + column + ", # of columns: " + columnCount);
- }
- if (mPos < 0) {
- throw new CursorIndexOutOfBoundsException("Before first row.");
- }
- if (mPos >= rowCount) {
- throw new CursorIndexOutOfBoundsException("After last row.");
- }
- return data[mPos * columnCount + column];
- }
-
- /**
- * Adds a new row to the end and returns a builder for that row. Not safe
- * for concurrent use.
- *
- * @return builder which can be used to set the column values for the new
- * row
- */
- public RowBuilder newRow() {
- rowCount++;
- int endIndex = rowCount * columnCount;
- ensureCapacity(endIndex);
- int start = endIndex - columnCount;
- return new RowBuilder(start, endIndex);
- }
-
- /**
- * Adds a new row to the end with the given column values. Not safe for
- * concurrent use.
- *
- * @throws IllegalArgumentException
- * if {@code columnValues.length !=
- * columnNames.length}
- * @param columnValues
- * in the same order as the the column names specified at cursor
- * construction time
- */
- public void addRow(Object[] columnValues) {
- if (columnValues.length != columnCount) {
- throw new IllegalArgumentException("columnNames.length = "
- + columnCount + ", columnValues.length = "
- + columnValues.length);
- }
-
- int start = rowCount++ * columnCount;
- ensureCapacity(start + columnCount);
- System.arraycopy(columnValues, 0, data, start, columnCount);
- }
-
- /**
- * Adds a new row to the end with the given column values. Not safe for
- * concurrent use.
- *
- * @throws IllegalArgumentException
- * if {@code columnValues.size() !=
- * columnNames.length}
- * @param columnValues
- * in the same order as the the column names specified at cursor
- * construction time
- */
- public void addRow(Iterable<?> columnValues) {
- int start = rowCount * columnCount;
- int end = start + columnCount;
- ensureCapacity(end);
-
- if (columnValues instanceof ArrayList<?>) {
- addRow((ArrayList<?>) columnValues, start);
- return;
- }
-
- int current = start;
- Object[] localData = data;
- for (Object columnValue : columnValues) {
- if (current == end) {
- // TODO: null out row?
- throw new IllegalArgumentException(
- "columnValues.size() > columnNames.length");
- }
- localData[current++] = columnValue;
- }
-
- if (current != end) {
- // TODO: null out row?
- throw new IllegalArgumentException(
- "columnValues.size() < columnNames.length");
- }
-
- // Increase row count here in case we encounter an exception.
- rowCount++;
- }
-
- /** Optimization for {@link ArrayList}. */
- private void addRow(ArrayList<?> columnValues, int start) {
- int size = columnValues.size();
- if (size != columnCount) {
- throw new IllegalArgumentException("columnNames.length = "
- + columnCount + ", columnValues.size() = " + size);
- }
-
- rowCount++;
- Object[] localData = data;
- for (int i = 0; i < size; i++) {
- localData[start + i] = columnValues.get(i);
- }
- }
-
- /** Ensures that this cursor has enough capacity. */
- private void ensureCapacity(int size) {
- if (size > data.length) {
- Object[] oldData = this.data;
- int newSize = data.length * 2;
- if (newSize < size) {
- newSize = size;
- }
- this.data = new Object[newSize];
- System.arraycopy(oldData, 0, this.data, 0, oldData.length);
- }
- }
-
- /**
- * Builds a row, starting from the left-most column and adding one column
- * value at a time. Follows the same ordering as the column names specified
- * at cursor construction time.
- */
- public class RowBuilder {
-
- private int index;
- private final int endIndex;
-
- RowBuilder(int index, int endIndex) {
- this.index = index;
- this.endIndex = endIndex;
- }
-
- /**
- * Sets the next column value in this row.
- *
- * @throws CursorIndexOutOfBoundsException
- * if you try to add too many values
- * @return this builder to support chaining
- */
- public RowBuilder add(Object columnValue) {
- if (index == endIndex) {
- throw new CursorIndexOutOfBoundsException(
- "No more columns left.");
- }
-
- data[index++] = columnValue;
- return this;
- }
- }
-
- // AbstractCursor implementation.
-
- @Override
- public int getCount() {
- return rowCount;
- }
-
- @Override
- public String[] getColumnNames() {
- return columnNames;
- }
-
- @Override
- public String getString(int column) {
- Object value = get(column);
- if (value == null)
- return null;
- return value.toString();
- }
-
- @Override
- public short getShort(int column) {
- Object value = get(column);
- if (value == null)
- return 0;
- if (value instanceof Number)
- return ((Number) value).shortValue();
- return Short.parseShort(value.toString());
- }
-
- @Override
- public int getInt(int column) {
- Object value = get(column);
- if (value == null)
- return 0;
- if (value instanceof Number)
- return ((Number) value).intValue();
- return Integer.parseInt(value.toString());
- }
-
- @Override
- public long getLong(int column) {
- Object value = get(column);
- if (value == null)
- return 0;
- if (value instanceof Number)
- return ((Number) value).longValue();
- return Long.parseLong(value.toString());
- }
-
- @Override
- public float getFloat(int column) {
- Object value = get(column);
- if (value == null)
- return 0.0f;
- if (value instanceof Number)
- return ((Number) value).floatValue();
- return Float.parseFloat(value.toString());
- }
-
- @Override
- public double getDouble(int column) {
- Object value = get(column);
- if (value == null)
- return 0.0d;
- if (value instanceof Number)
- return ((Number) value).doubleValue();
- return Double.parseDouble(value.toString());
- }
-
- @Override
- public byte[] getBlob(int column) {
- Object value = get(column);
- if (value == null)
- return new byte[0];
- if (value instanceof byte[])
- return ((byte[]) value);
- return new byte[0];
- }
-
- @Override
- public boolean isNull(int column) {
- return get(column) == null;
- }
-
- public void fillWindow(int position, CursorWindow window) {
- if (position < 0 || position >= getCount()) {
- return;
- }
- window.acquireReference();
- try {
- int oldpos = mPos;
- mPos = position - 1;
- window.clear();
- window.setStartPosition(position);
- int columnNum = getColumnCount();
- window.setNumColumns(columnNum);
- while (moveToNext() && window.allocRow()) {
- for (int i = 0; i < columnNum; i++) {
- byte[] field = getBlob(i);
- if (field != null) {
- if (!window.putBlob(field, mPos, i)) {
- window.freeLastRow();
- break;
- }
- } else {
- if (!window.putNull(mPos, i)) {
- window.freeLastRow();
- break;
- }
- }
- }
- }
-
- mPos = oldpos;
- } catch (IllegalStateException e) {
- // simply ignore it
- } finally {
- window.releaseReference();
- }
- }
-}
diff --git a/src/menion/android/locus/addon/publiclib/utils/DataStorage.java b/src/menion/android/locus/addon/publiclib/utils/DataStorage.java
deleted file mode 100644
index 8705b04..0000000
--- a/src/menion/android/locus/addon/publiclib/utils/DataStorage.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package menion.android.locus.addon.publiclib.utils;
-
-import java.util.ArrayList;
-
-import menion.android.locus.addon.publiclib.geoData.PointsData;
-
-public class DataStorage {
-
- private static ArrayList<PointsData> mData;
-
- public static ArrayList<PointsData> getData() {
- return mData;
- }
-
- public static void setData(ArrayList<PointsData> data) {
- DataStorage.mData = data;
- }
-
- public static void setData(PointsData data) {
- DataStorage.mData = new ArrayList<PointsData>();
- DataStorage.mData.add(data);
- }
-
- public static void clearData() {
- DataStorage.mData.clear();
- DataStorage.mData = null;
- }
-}