aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/cgeocaches.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/cgeocaches.java')
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java78
1 files changed, 45 insertions, 33 deletions
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index 067c9c0..40200db 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -141,6 +141,7 @@ public class cgeocaches extends AbstractListActivity {
private static final int MENU_SORT_FINDS = 62;
private static final int MENU_SORT_STATE = 63;
private static final int MENU_RENAME_LIST = 64;
+ private static final int MENU_DROP_CACHES_AND_LIST = 65;
private static final int CONTEXT_MENU_MOVE_TO_LIST = 1000;
private static final int MENU_MOVE_SELECTED_OR_ALL_TO_LIST = 1200;
@@ -715,7 +716,7 @@ public class cgeocaches extends AbstractListActivity {
// refresh standard list if it has changed (new caches downloaded)
if (type == CacheListType.OFFLINE && listId == cgList.STANDARD_LIST_ID && search != null) {
- cgSearch newSearch = base.searchByOffline(coords, cacheType, listId);
+ cgSearch newSearch = cgBase.searchByOffline(coords, cacheType, listId);
if (newSearch != null && newSearch.totalCnt != search.totalCnt) {
refreshCurrentList();
}
@@ -806,6 +807,7 @@ public class cgeocaches extends AbstractListActivity {
if (type == CacheListType.OFFLINE) {
SubMenu subMenu = menu.addSubMenu(0, SUBMENU_MANAGE_OFFLINE, 0, res.getString(R.string.caches_manage)).setIcon(android.R.drawable.ic_menu_save);
subMenu.add(0, MENU_DROP_CACHES, 0, res.getString(R.string.caches_drop_all)); // delete saved caches
+ subMenu.add(0, MENU_DROP_CACHES_AND_LIST, 0, res.getString(R.string.caches_drop_all_and_list));
subMenu.add(0, MENU_REFRESH_STORED, 0, res.getString(R.string.cache_offline_refresh)); // download details for all caches
subMenu.add(0, MENU_MOVE_TO_LIST, 0, res.getString(R.string.cache_menu_move_list));
subMenu.add(0, MENU_EXPORT_NOTES, 0, res.getString(R.string.cache_export_fieldnote)); // export field notes
@@ -862,6 +864,7 @@ public class cgeocaches extends AbstractListActivity {
} else {
menu.findItem(MENU_DROP_CACHES).setTitle(res.getString(R.string.caches_drop_all));
}
+ menu.findItem(MENU_DROP_CACHES_AND_LIST).setVisible(!hasSelection);
if (hasSelection) {
menu.findItem(MENU_REFRESH_STORED).setTitle(res.getString(R.string.caches_refresh_selected) + " (" + adapter.getChecked() + ")");
@@ -969,8 +972,11 @@ public class cgeocaches extends AbstractListActivity {
refreshStored();
return true;
case MENU_DROP_CACHES:
- dropStored();
+ dropStored(false);
return false;
+ case MENU_DROP_CACHES_AND_LIST:
+ dropStored(true);
+ return true;
case MENU_IMPORT_GPX:
importGpx();
return false;
@@ -978,7 +984,7 @@ public class cgeocaches extends AbstractListActivity {
createList(null);
return false;
case MENU_DROP_LIST:
- removeList();
+ removeList(true);
return false;
case MENU_RENAME_LIST:
renameList();
@@ -1288,7 +1294,7 @@ public class cgeocaches extends AbstractListActivity {
if (adapterInfo != null) {
// create a search for a single cache (as if in details view)
final cgCache cache = getCacheFromAdapter(adapterInfo);
- final cgSearch singleSearch = base.searchByGeocode(cache.getGeocode(), null, 0, false, null);
+ final cgSearch singleSearch = cgBase.searchByGeocode(cache.getGeocode(), null, 0, false, null);
if (NavigationAppFactory.onMenuItemSelected(item, geo, this,
res, cache, singleSearch, null, null)) {
@@ -1296,7 +1302,7 @@ public class cgeocaches extends AbstractListActivity {
}
int logType = id - MENU_LOG_VISIT_OFFLINE;
- cache.logOffline(this, logType, base);
+ cache.logOffline(this, logType);
}
return true;
}
@@ -1357,7 +1363,7 @@ public class cgeocaches extends AbstractListActivity {
list.setLongClickable(true);
list.addFooterView(listFooter);
- adapter = new cgCacheListAdapter(this, cacheList, base);
+ adapter = new cgCacheListAdapter(this, cacheList);
setListAdapter(adapter);
} else {
adapter.notifyDataSetChanged();
@@ -1639,30 +1645,26 @@ public class cgeocaches extends AbstractListActivity {
threadW.start();
}
- public void dropStored() {
+ public void dropStored(final boolean removeListAfterwards) {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setCancelable(true);
dialog.setTitle(res.getString(R.string.caches_drop_stored));
if (adapter != null && adapter.getChecked() > 0) {
dialog.setMessage(res.getString(R.string.caches_drop_selected_ask));
- dialog.setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() {
-
- public void onClick(DialogInterface dialog, int id) {
- dropSelected();
- dialog.cancel();
- }
- });
} else {
dialog.setMessage(res.getString(R.string.caches_drop_all_ask));
- dialog.setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() {
+ }
+ dialog.setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dropSelected();
- dialog.cancel();
+ public void onClick(DialogInterface dialog, int id) {
+ dropSelected();
+ if (removeListAfterwards) {
+ removeList(false);
}
- });
- }
+ dialog.cancel();
+ }
+ });
dialog.setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
@@ -1764,9 +1766,9 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
if (coords != null) {
- search = base.searchByOffline(coords, Settings.getCacheType(), listId);
+ search = cgBase.searchByOffline(coords, Settings.getCacheType(), listId);
} else {
- search = base.searchByOffline(null, Settings.getCacheType(), cgList.STANDARD_LIST_ID);
+ search = cgBase.searchByOffline(null, Settings.getCacheType(), cgList.STANDARD_LIST_ID);
}
handler.sendMessage(new Message());
}
@@ -1782,7 +1784,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
- search = base.searchByHistory(coords != null ? Settings.getCacheType() : CacheType.ALL);
+ search = cgBase.searchByHistory(coords != null ? Settings.getCacheType() : CacheType.ALL);
handler.sendMessage(new Message());
}
}
@@ -1797,7 +1799,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
- search = base.searchByNextPage(this, search, 0, Settings.isShowCaptcha());
+ search = cgBase.searchByNextPage(this, search, 0, Settings.isShowCaptcha());
handler.sendMessage(new Message());
}
@@ -1824,7 +1826,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
- search = base.searchByCoords(this, coords, cacheType, 0, Settings.isShowCaptcha());
+ search = cgBase.searchByCoords(this, coords, cacheType, 0, Settings.isShowCaptcha());
handler.sendMessage(new Message());
}
@@ -1851,7 +1853,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
- search = base.searchByKeyword(this, keyword, cacheType, 0, Settings.isShowCaptcha());
+ search = cgBase.searchByKeyword(this, keyword, cacheType, 0, Settings.isShowCaptcha());
handler.sendMessage(new Message());
}
}
@@ -1877,7 +1879,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
- search = base.searchByUsername(this, username, cacheType, 0, Settings.isShowCaptcha());
+ search = cgBase.searchByUsername(this, username, cacheType, 0, Settings.isShowCaptcha());
handler.sendMessage(new Message());
}
}
@@ -1909,7 +1911,7 @@ public class cgeocaches extends AbstractListActivity {
params.put("cacheType", cacheType.id);
}
- search = base.searchByOwner(this, username, cacheType, 0, Settings.isShowCaptcha());
+ search = cgBase.searchByOwner(this, username, cacheType, 0, Settings.isShowCaptcha());
handler.sendMessage(new Message());
}
@@ -1982,7 +1984,7 @@ public class cgeocaches extends AbstractListActivity {
}
detailProgress++;
- base.storeCache(app, cgeocaches.this, cache, null, reason, null);
+ cgBase.storeCache(app, cgeocaches.this, cache, null, reason, null);
handler.sendEmptyMessage(cacheList.indexOf(cache));
@@ -2057,7 +2059,7 @@ public class cgeocaches extends AbstractListActivity {
handler.sendMessage(mes);
yield();
- base.storeCache(app, cgeocaches.this, null, GCcode,
+ cgBase.storeCache(app, cgeocaches.this, null, GCcode,
reason, null);
Message mes1 = new Message();
@@ -2272,7 +2274,7 @@ public class cgeocaches extends AbstractListActivity {
.append(',')
.append(logTypes.get(log.type))
.append(",\"")
- .append(log.log.replaceAll("\"", "'"))
+ .append(StringUtils.replaceChars(log.log, '"', '\''))
.append("\"\n");
}
}
@@ -2519,7 +2521,7 @@ public class cgeocaches extends AbstractListActivity {
}
}
- private void removeList() {
+ private void removeList(final boolean askForConfirmation) {
// if there are no caches on this list, don't bother the user with questions.
// there is no harm in deleting the list, he could recreate it easily
if (CollectionUtils.isEmpty(cacheList)) {
@@ -2527,6 +2529,11 @@ public class cgeocaches extends AbstractListActivity {
return;
}
+ if (!askForConfirmation) {
+ removeListInternal();
+ return;
+ }
+
// ask him, if there are caches on the list
final AlertDialog.Builder alert = new AlertDialog.Builder(this);
@@ -2557,7 +2564,12 @@ public class cgeocaches extends AbstractListActivity {
return;
}
- CGeoMap.startActivitySearch(this, search, title + " [" + cgeoapplication.getCount(search) + "]", false);
+ int count = cgeoapplication.getCount(search);
+ String mapTitle = title;
+ if (count > 0) {
+ mapTitle = title + " [" + count + "]";
+ }
+ CGeoMap.startActivitySearch(this, search, mapTitle, false);
}
@Override