diff options
-rw-r--r-- | main/res/drawable-hdpi/marker_transparent.png | bin | 0 -> 3332 bytes | |||
-rw-r--r-- | main/res/drawable-hdpi/tick.png | bin | 0 -> 1645 bytes | |||
-rw-r--r-- | main/res/drawable-mdpi/marker_transparent.png | bin | 0 -> 2964 bytes | |||
-rw-r--r-- | main/res/layout/edit_waypoint_activity.xml | 6 | ||||
-rw-r--r-- | main/res/values/strings.xml | 1 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 13 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/EditWaypointActivity.java | 15 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/Waypoint.java | 26 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 20 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 13 |
10 files changed, 78 insertions, 16 deletions
diff --git a/main/res/drawable-hdpi/marker_transparent.png b/main/res/drawable-hdpi/marker_transparent.png Binary files differnew file mode 100644 index 0000000..072b56f --- /dev/null +++ b/main/res/drawable-hdpi/marker_transparent.png diff --git a/main/res/drawable-hdpi/tick.png b/main/res/drawable-hdpi/tick.png Binary files differnew file mode 100644 index 0000000..69eaa90 --- /dev/null +++ b/main/res/drawable-hdpi/tick.png diff --git a/main/res/drawable-mdpi/marker_transparent.png b/main/res/drawable-mdpi/marker_transparent.png Binary files differnew file mode 100644 index 0000000..f9897db --- /dev/null +++ b/main/res/drawable-mdpi/marker_transparent.png diff --git a/main/res/layout/edit_waypoint_activity.xml b/main/res/layout/edit_waypoint_activity.xml index 4c95284..e96d4ff 100644 --- a/main/res/layout/edit_waypoint_activity.xml +++ b/main/res/layout/edit_waypoint_activity.xml @@ -89,6 +89,12 @@ android:minLines="5" android:singleLine="false" /> + <CheckBox + android:id="@+id/wpt_visited_checkbox" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/waypoint_visited" /> + <RadioGroup android:id="@+id/modify_cache_coordinates_group" android:layout_width="wrap_content" diff --git a/main/res/values/strings.xml b/main/res/values/strings.xml index 287e1c4..2053e14 100644 --- a/main/res/values/strings.xml +++ b/main/res/values/strings.xml @@ -686,6 +686,7 @@ <string name="waypoint_edit_title">Edit waypoint</string> <string name="waypoint_add_title">Add waypoint</string> <string name="waypoint_note">Note</string> + <string name="waypoint_visited">Visited</string> <string name="waypoint_save">Save</string> <string name="waypoint_loading">Loading waypoint…</string> <string name="waypoint_do_not_touch_cache_coordinates">No change to cache coordinates</string> diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 5da9ca0..2009bff 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -2228,6 +2228,11 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc } wpt.setIcon(res, nameView); + // visited + if (wpt.isVisited()) { + nameView.setTextColor(getResources().getColor(R.color.text_grey_dark)); + } + // note if (StringUtils.isNotBlank(wpt.getNote())) { final TextView noteView = (TextView) waypointView.findViewById(R.id.note); @@ -2348,7 +2353,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.waypoint_reset_cache_coords); - String[] items = new String[] {res.getString(R.string.waypoint_localy_reset_cache_coords), res.getString(R.string.waypoint_reset_local_and_remote_cache_coords)}; + String[] items = new String[] { res.getString(R.string.waypoint_localy_reset_cache_coords), res.getString(R.string.waypoint_reset_local_and_remote_cache_coords) }; builder.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() { @Override @@ -2522,9 +2527,9 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc } static void updateOfflineBox(final View view, final Geocache cache, final Resources res, - final OnClickListener refreshCacheClickListener, - final OnClickListener dropCacheClickListener, - final OnClickListener storeCacheClickListener) { + final OnClickListener refreshCacheClickListener, + final OnClickListener dropCacheClickListener, + final OnClickListener storeCacheClickListener) { // offline use final TextView offlineText = (TextView) view.findViewById(R.id.offline_text); final Button offlineRefresh = (Button) view.findViewById(R.id.offline_refresh); diff --git a/main/src/cgeo/geocaching/EditWaypointActivity.java b/main/src/cgeo/geocaching/EditWaypointActivity.java index bae0ead..8d00d1e 100644 --- a/main/src/cgeo/geocaching/EditWaypointActivity.java +++ b/main/src/cgeo/geocaching/EditWaypointActivity.java @@ -32,6 +32,9 @@ import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.Button; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.EditText; import android.widget.RadioButton; import android.widget.Spinner; @@ -51,6 +54,7 @@ public class EditWaypointActivity extends AbstractActivity { private String prefix = "OWN"; private String lookup = "---"; private boolean own = true; + private boolean visited = false; ArrayList<WaypointType> wpTypes = null; String distanceUnit = ""; @@ -71,6 +75,7 @@ public class EditWaypointActivity extends AbstractActivity { prefix = waypoint.getPrefix(); lookup = waypoint.getLookup(); own = waypoint.isUserDefined(); + visited = waypoint.isVisited(); if (waypoint.getCoords() != null) { ((Button) findViewById(R.id.buttonLatitude)).setText(waypoint.getCoords().format(GeopointFormatter.Format.LAT_DECMINUTE)); @@ -90,6 +95,7 @@ public class EditWaypointActivity extends AbstractActivity { if (own) { initializeWaypointTypeSelector(); } + ((CheckBox) findViewById(R.id.wpt_visited_checkbox)).setChecked(visited); initializeDistanceUnitSelector(); } catch (Exception e) { @@ -165,6 +171,14 @@ public class EditWaypointActivity extends AbstractActivity { IConnector con = ConnectorFactory.getConnector(geocode); setCoordsModificationVisibility(con, cache); } + CheckBox visitedCheckBox = ((CheckBox) findViewById(R.id.wpt_visited_checkbox)); + visitedCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + visited = isChecked; + } + }); + buttonLat.setOnClickListener(new coordDialogListener()); initializeDistanceUnitSelector(); @@ -471,6 +485,7 @@ public class EditWaypointActivity extends AbstractActivity { waypoint.setLookup(lookup); waypoint.setCoords(coordsToSave); waypoint.setNote(note); + waypoint.setVisited(visited); waypoint.setId(id); Geocache cache = cgData.loadCache(geocode, LoadFlags.LOAD_WAYPOINTS); diff --git a/main/src/cgeo/geocaching/Waypoint.java b/main/src/cgeo/geocaching/Waypoint.java index 1d88c40..e3b2be0 100644 --- a/main/src/cgeo/geocaching/Waypoint.java +++ b/main/src/cgeo/geocaching/Waypoint.java @@ -6,6 +6,8 @@ import cgeo.geocaching.geopoint.Geopoint; import org.apache.commons.lang3.StringUtils; import android.content.res.Resources; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; import android.widget.TextView; import java.util.HashMap; @@ -27,6 +29,7 @@ public class Waypoint implements IWaypoint, Comparable<Waypoint> { private String note = ""; private int cachedOrder = ORDER_UNDEFINED; private boolean own = false; + private boolean visited = false; /** * require name and type for every waypoint @@ -52,7 +55,19 @@ public class Waypoint implements IWaypoint, Comparable<Waypoint> { } public void setIcon(final Resources res, final TextView nameView) { - nameView.setCompoundDrawablesWithIntrinsicBounds(res.getDrawable(waypointType.markerId), null, null, null); + Drawable icon; + if (visited) { + LayerDrawable ld = new LayerDrawable(new Drawable[] { + res.getDrawable(waypointType.markerId), + res.getDrawable(R.drawable.tick) }); + ld.setLayerInset(0, 0, 0, 10, 10); + ld.setLayerInset(1, 10, 10, 0, 0); + icon = ld; + } else { + icon = res.getDrawable(waypointType.markerId); + } + final Drawable fIcon = icon; + nameView.setCompoundDrawablesWithIntrinsicBounds(fIcon, null, null, null); } public void merge(final Waypoint old) { @@ -82,6 +97,7 @@ public class Waypoint implements IWaypoint, Comparable<Waypoint> { if (id < 0) { id = old.id; } + visited = old.visited; } public static void mergeWayPoints(final List<Waypoint> newPoints, final List<Waypoint> oldPoints, final boolean forceMerge) { @@ -238,4 +254,12 @@ public class Waypoint implements IWaypoint, Comparable<Waypoint> { public String getCoordType() { return "waypoint"; } + + public void setVisited(boolean visited) { + this.visited = visited; + } + + public boolean isVisited() { + return visited; + } } diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index cbbd852..359083b 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -73,7 +73,7 @@ public class cgData { //TODO: remove "latlon" field from cache table /** The list of fields needed for mapping. */ - private static final String[] WAYPOINT_COLUMNS = new String[] { "_id", "geocode", "updated", "type", "prefix", "lookup", "name", "latlon", "latitude", "longitude", "note", "own" }; + private static final String[] WAYPOINT_COLUMNS = new String[] { "_id", "geocode", "updated", "type", "prefix", "lookup", "name", "latlon", "latitude", "longitude", "note", "own", "visited" }; /** Number of days (as ms) after temporarily saved caches are deleted */ private final static long DAYS_AFTER_CACHE_IS_DELETED = 3 * 24 * 60 * 60 * 1000; @@ -84,7 +84,7 @@ public class cgData { private static int[] cacheColumnIndex; private static CacheCache cacheCache = new CacheCache(); private static SQLiteDatabase database = null; - private static final int dbVersion = 65; + private static final int dbVersion = 66; public static final int customListIdOffset = 10; private static final String dbName = "data"; private static final String dbTableCaches = "cg_caches"; @@ -175,6 +175,7 @@ public class cgData { + "longitude double, " + "note text, " + "own integer default 0" + + "visited integer default 0" + "); "; private static final String dbCreateSpoilers = "" + "create table " + dbTableSpoilers + " (" @@ -663,6 +664,15 @@ public class cgData { Log.e("Failed to upgrade to ver. 65:", e); } } + // Introduces visited feature on waypoints + if (oldVersion < 66) { + try { + db.execSQL("alter table " + dbTableWaypoints + " add column visited integer default 0"); + } catch (Exception e) { + Log.e("Failed to upgrade to ver. 66", e); + + } + } } db.setTransactionSuccessful(); @@ -1135,7 +1145,7 @@ public class cgData { putCoords(values, oneWaypoint.getCoords()); values.put("note", oneWaypoint.getNote()); values.put("own", oneWaypoint.isUserDefined() ? 1 : 0); - + values.put("visited", oneWaypoint.isVisited() ? 1 : 0); if (oneWaypoint.getId() < 0) { final long rowId = database.insert(dbTableWaypoints, null, values); oneWaypoint.setId((int) rowId); @@ -1199,7 +1209,7 @@ public class cgData { putCoords(values, waypoint.getCoords()); values.put("note", waypoint.getNote()); values.put("own", waypoint.isUserDefined() ? 1 : 0); - + values.put("visited", waypoint.isVisited() ? 1 : 0); if (id <= 0) { final long rowId = database.insert(dbTableWaypoints, null, values); waypoint.setId((int) rowId); @@ -1707,7 +1717,7 @@ public class cgData { final WaypointType type = WaypointType.findById(cursor.getString(cursor.getColumnIndex("type"))); final boolean own = cursor.getInt(cursor.getColumnIndex("own")) != 0; final Waypoint waypoint = new Waypoint(name, type, own); - + waypoint.setVisited(cursor.getInt(cursor.getColumnIndex("visited")) != 0); waypoint.setId(cursor.getInt(cursor.getColumnIndex("_id"))); waypoint.setGeocode(cursor.getString(cursor.getColumnIndex("geocode"))); waypoint.setPrefix(cursor.getString(cursor.getColumnIndex("prefix"))); diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 9dde6ec..4b8d1a0 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -85,7 +85,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto /** max. number of caches displayed in the Live Map */ public static final int MAX_CACHES = 500; - /**Controls the behaviour of the map*/ + /** Controls the behaviour of the map */ public enum MapMode { /** Live Map */ LIVE, @@ -96,6 +96,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto /** Map with a list of caches (no reload on move) */ LIST } + /** Handler Messages */ private static final int HIDE_PROGRESS = 0; private static final int SHOW_PROGRESS = 1; @@ -189,7 +190,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto // views private ImageSwitcher myLocSwitch = null; - /**Controls the map behaviour*/ + /** Controls the map behaviour */ private MapMode mapMode = null; /** Live mode enabled for map. **/ private boolean isLiveEnabled; @@ -289,7 +290,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto waitDialog.setMessage(res.getString(R.string.caches_downloading) + " " + res.getString(R.string.caches_eta_ltm)); } else { int minsRemaining = secondsRemaining / 60; - waitDialog.setMessage(res.getString(R.string.caches_downloading) + " " + minsRemaining + " " + res.getQuantityString(R.plurals.caches_eta_mins,minsRemaining)); + waitDialog.setMessage(res.getString(R.string.caches_downloading) + " " + minsRemaining + " " + res.getQuantityString(R.plurals.caches_eta_mins, minsRemaining)); } } } else if (msg.what == FINISHED_LOADING_DETAILS) { @@ -1275,7 +1276,6 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } } - /** * Thread to display one point. Started on opening if in single mode. */ @@ -1716,9 +1716,10 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto private CachesOverlayItemImpl getWaypointItem(final Waypoint waypoint) { final CachesOverlayItemImpl item = mapItemFactory.getCachesOverlayItem(waypoint, null); + Drawable marker = getResources().getDrawable(!waypoint.isVisited() ? R.drawable.marker : R.drawable.marker_transparent); final Drawable[] layers = new Drawable[] { - getResources().getDrawable(R.drawable.marker), - getResources().getDrawable(waypoint.getWaypointType().markerId) + marker, + getResources().getDrawable(waypoint.getWaypointType().markerId) }; final LayerDrawable ld = new LayerDrawable(layers); if (layers[0].getIntrinsicWidth() > 40) { |