aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/res/values/strings.xml2
-rw-r--r--main/src/cgeo/geocaching/StoredList.java13
-rw-r--r--main/src/cgeo/geocaching/cgData.java16
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java6
4 files changed, 31 insertions, 6 deletions
diff --git a/main/res/values/strings.xml b/main/res/values/strings.xml
index 2884bd0..7d3a818 100644
--- a/main/res/values/strings.xml
+++ b/main/res/values/strings.xml
@@ -322,11 +322,13 @@
<!-- caches lists -->
<string name="list_menu">List</string>
<string name="list_menu_create">Create new list</string>
+ <string name="list_menu_all_lists">All caches</string>
<string name="list_menu_drop">Drop current list</string>
<string name="list_menu_change">Change list</string>
<string name="list_menu_rename">Rename current list</string>
<string name="list_title">Pick a list</string>
<string name="list_inbox">Stored</string>
+ <string name="list_all_lists">All caches</string>
<string name="list_dialog_create_title">New list</string>
<string name="list_dialog_create">Create</string>
<string name="list_dialog_cancel">Cancel</string>
diff --git a/main/src/cgeo/geocaching/StoredList.java b/main/src/cgeo/geocaching/StoredList.java
index eaf677d..6cf018a 100644
--- a/main/src/cgeo/geocaching/StoredList.java
+++ b/main/src/cgeo/geocaching/StoredList.java
@@ -18,6 +18,7 @@ import java.util.List;
public class StoredList {
public static final int TEMPORARY_LIST_ID = 0;
public static final int STANDARD_LIST_ID = 1;
+ public static final int ALL_LIST_ID = 2;
public final int id;
public final String title;
@@ -45,6 +46,10 @@ public class StoredList {
}
public void promptForListSelection(final int titleId, final RunnableWithArgument<Integer> runAfterwards) {
+ promptForListSelection(titleId, runAfterwards, false);
+ }
+
+ public void promptForListSelection(final int titleId, final RunnableWithArgument<Integer> runAfterwards, final boolean onlyMoveTargets) {
final List<StoredList> lists = app.getLists();
if (lists == null) {
@@ -55,6 +60,9 @@ public class StoredList {
for (StoredList list : lists) {
listsTitle.add(list.getTitleAndCount());
}
+ if (!onlyMoveTargets) {
+ listsTitle.add("<" + res.getString(R.string.list_menu_all_lists) + ">");
+ }
listsTitle.add("<" + res.getString(R.string.list_menu_create) + ">");
final CharSequence[] items = new CharSequence[listsTitle.size()];
@@ -63,7 +71,10 @@ public class StoredList {
builder.setTitle(res.getString(titleId));
builder.setItems(listsTitle.toArray(items), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int itemId) {
- if (itemId >= lists.size()) {
+ if (itemId == lists.size() && !onlyMoveTargets) {
+ // all lists
+ runAfterwards.run(StoredList.ALL_LIST_ID);
+ } else if (itemId >= lists.size()) {
// create new list on the fly
promptForListCreation(runAfterwards);
}
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java
index 796f1fa..16a1f35 100644
--- a/main/src/cgeo/geocaching/cgData.java
+++ b/main/src/cgeo/geocaching/cgData.java
@@ -2209,8 +2209,8 @@ public class cgData {
StringBuilder specifySql = new StringBuilder();
- specifySql.append("reason = ");
- specifySql.append(Math.max(listId, 1));
+ specifySql.append("reason ");
+ specifySql.append(listId != StoredList.ALL_LIST_ID ? "=" + Math.max(listId, 1) : ">= " + StoredList.STANDARD_LIST_ID);
if (detailedOnly) {
specifySql.append(" and detailed = 1 ");
@@ -2624,6 +2624,10 @@ public class cgData {
return getStatement("CountStandardList", "SELECT count(_id) FROM " + dbTableCaches + " WHERE reason = " + StoredList.STANDARD_LIST_ID);
}
+ private SQLiteStatement getStatementCountAllLists() {
+ return getStatement("CountAllLists", "SELECT count(_id) FROM " + dbTableCaches + " WHERE reason >= " + StoredList.STANDARD_LIST_ID);
+ }
+
public boolean hasLogOffline(final String geocode) {
if (StringUtils.isBlank(geocode)) {
return false;
@@ -2726,6 +2730,11 @@ public class cgData {
return lists.get(0);
}
}
+
+ if (id == StoredList.ALL_LIST_ID) {
+ return new StoredList(StoredList.ALL_LIST_ID, res.getString(R.string.list_all_lists), (int) getStatementCountAllLists().simpleQueryForLong());
+ }
+
// fall back to standard list in case of invalid list id
if (id == StoredList.STANDARD_LIST_ID || id >= customListIdOffset) {
return new StoredList(StoredList.STANDARD_LIST_ID, res.getString(R.string.list_inbox), (int) getStatementCountStandardList().simpleQueryForLong());
@@ -2830,6 +2839,9 @@ public class cgData {
}
public void moveToList(final List<cgCache> caches, final int listId) {
+ if (listId == StoredList.ALL_LIST_ID) {
+ return;
+ }
if (caches.isEmpty()) {
return;
}
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index b435049..a688d07 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -766,7 +766,7 @@ public class cgeocaches extends AbstractListActivity {
}
final boolean hasSelection = adapter != null && adapter.getCheckedCount() > 0;
- final boolean isNonDefaultList = listId != StoredList.STANDARD_LIST_ID;
+ final boolean isNonDefaultList = (listId != StoredList.STANDARD_LIST_ID) && (listId != StoredList.ALL_LIST_ID);
if (type == CacheListType.OFFLINE) { // only offline list
setMenuItemLabel(menu, MENU_DROP_CACHES, R.string.caches_drop_selected, R.string.caches_drop_all);
@@ -1003,7 +1003,7 @@ public class cgeocaches extends AbstractListActivity {
refreshCurrentList();
}
- });
+ }, true);
}
@Override
@@ -1065,7 +1065,7 @@ public class cgeocaches extends AbstractListActivity {
adapter.setSelectMode(false);
refreshCurrentList();
}
- });
+ }, true);
break;
case MENU_STORE_CACHE:
//FIXME: this must use the same handler like in the CacheDetailActivity. Will be done by moving the handler into the store method.