aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkoem <koem@petoria.de>2013-02-08 18:25:01 +1300
committerkoem <koem@petoria.de>2013-02-08 18:25:01 +1300
commitebda1db90874465df018d5b3c65e5c4393839fe6 (patch)
tree73640ebeeaa354449ced45702dbdc00e3cbf00c9
parenta6443368f75b9635a6ce83328c04eb53b172c906 (diff)
downloadcgeo-ebda1db90874465df018d5b3c65e5c4393839fe6.zip
cgeo-ebda1db90874465df018d5b3c65e5c4393839fe6.tar.gz
cgeo-ebda1db90874465df018d5b3c65e5c4393839fe6.tar.bz2
issue #275 - Move to other list from cache screen
and: choose list when storing
-rw-r--r--main/res/layout/cacheview_details.xml41
-rw-r--r--main/res/layout/init.xml55
-rw-r--r--main/res/values-de/strings.xml6
-rw-r--r--main/res/values/strings.xml4
-rw-r--r--main/res/values/strings_not_translatable.xml2
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java86
-rw-r--r--main/src/cgeo/geocaching/CachePopup.java24
-rw-r--r--main/src/cgeo/geocaching/Geocache.java10
-rw-r--r--main/src/cgeo/geocaching/Settings.java16
-rw-r--r--main/src/cgeo/geocaching/SettingsActivity.java11
-rw-r--r--main/src/cgeo/geocaching/StoredList.java16
-rw-r--r--main/src/cgeo/geocaching/cgData.java4
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java40
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java100
14 files changed, 323 insertions, 92 deletions
diff --git a/main/res/layout/cacheview_details.xml b/main/res/layout/cacheview_details.xml
index 62ee2af..be9219b 100644
--- a/main/res/layout/cacheview_details.xml
+++ b/main/res/layout/cacheview_details.xml
@@ -181,6 +181,47 @@
</RelativeLayout>
</LinearLayout>
+ <!-- list box -->
+
+ <LinearLayout
+ android:id="@+id/list_box"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="gone" >
+
+ <View
+ style="@style/separator_horizontal"
+ android:layout_marginBottom="9dp"
+ android:layout_marginTop="9dp" />
+
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:id="@+id/list_text"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_gravity="left"
+ android:layout_centerVertical="true"
+ android:layout_marginLeft="6dip"
+ android:layout_marginRight="130dip"
+ android:paddingRight="3dip"
+ android:textColor="?text_color"
+ android:textSize="14dip" />
+
+ <Button
+ android:id="@+id/change_list"
+ style="@style/button_small"
+ android:layout_alignParentRight="true"
+ android:text="@string/cache_list_change"
+ android:visibility="visible" />
+
+ </RelativeLayout>
+ </LinearLayout>
+
<!-- License Box -->
<LinearLayout
diff --git a/main/res/layout/init.xml b/main/res/layout/init.xml
index 6aaed9f..730e5b7 100644
--- a/main/res/layout/init.xml
+++ b/main/res/layout/init.xml
@@ -197,40 +197,43 @@
<CheckBox android:id="@+id/captcha"
style="@style/checkbox_full"
android:text="@string/init_captcha" />
+ <CheckBox android:id="@+id/livelist"
+ style="@style/checkbox_full"
+ android:text="@string/init_livelist" />
<CheckBox android:id="@+id/loaddirectionimg"
- style="@style/checkbox_full"
+ style="@style/checkbox_full"
android:text="@string/init_loaddirectionimg" />
- <CheckBox android:id="@+id/useenglish"
- style="@style/checkbox_full"
- android:text="@string/init_useenglish" />
- <CheckBox android:id="@+id/exclude"
- style="@style/checkbox_full"
- android:text="@string/init_exclude" />
- <CheckBox android:id="@+id/disabled"
- style="@style/checkbox_full"
- android:text="@string/init_disabled" />
+ <CheckBox android:id="@+id/useenglish"
+ style="@style/checkbox_full"
+ android:text="@string/init_useenglish" />
+ <CheckBox android:id="@+id/units"
+ style="@style/checkbox_full"
+ android:text="@string/init_units" />
+ <CheckBox android:id="@+id/exclude"
+ style="@style/checkbox_full"
+ android:text="@string/init_exclude" />
+ <CheckBox android:id="@+id/disabled"
+ style="@style/checkbox_full"
+ android:text="@string/init_disabled" />
<CheckBox android:id="@+id/trackautovisit"
- style="@style/checkbox_full"
+ style="@style/checkbox_full"
android:text="@string/init_trackautovisit" />
- <CheckBox android:id="@+id/units"
- style="@style/checkbox_full"
- android:text="@string/init_units" />
- <CheckBox android:id="@+id/livelist"
- style="@style/checkbox_full"
- android:text="@string/init_livelist" />
- <CheckBox android:id="@+id/log_offline"
- style="@style/checkbox_full"
- android:text="@string/init_log_offline" />
- <CheckBox android:id="@+id/trail"
- style="@style/checkbox_full"
- android:text="@string/init_maptrail" />
+ <CheckBox android:id="@+id/log_offline"
+ style="@style/checkbox_full"
+ android:text="@string/init_log_offline" />
+ <CheckBox android:id="@+id/choose_list"
+ style="@style/checkbox_full"
+ android:text="@string/init_choose_list" />
+ <CheckBox android:id="@+id/trail"
+ style="@style/checkbox_full"
+ android:text="@string/init_maptrail" />
<CheckBox android:id="@+id/plain_logs"
- style="@style/checkbox_full"
+ style="@style/checkbox_full"
android:text="@string/init_plain_logs" />
<CheckBox android:id="@+id/use_native_ua"
- style="@style/checkbox_full"
+ style="@style/checkbox_full"
android:text="@string/init_use_native_ua" />
- </LinearLayout>
+ </LinearLayout>
<!-- ** -->
<RelativeLayout style="@style/separator_horizontal_layout" >
<View style="@style/separator_horizontal" />
diff --git a/main/res/values-de/strings.xml b/main/res/values-de/strings.xml
index bea85dc..fd14e0e 100644
--- a/main/res/values-de/strings.xml
+++ b/main/res/values-de/strings.xml
@@ -389,6 +389,7 @@
<string name="init_save_log_img">Logbilder abspeichern</string>
<string name="init_units">Imperiale Einheiten (Meilen/Fuß)</string>
<string name="init_log_offline">Offline loggen (Dialog für Online-Log nicht anzeigen)</string>
+ <string name="init_choose_list">Beim Speichern von Caches nach Liste fragen</string>
<string name="init_livelist">Richtung zum Cache in der Cache-Liste anzeigen</string>
<string name="init_altitude">Höhenkorrektur</string>
<string name="init_altitude_description">Falls das GPS eine falsche Höhe ermittelt, kann dies durch Angabe eines positiven oder negativen Wertes in Metern korrigiert werden.</string>
@@ -506,8 +507,10 @@
<string name="cache_favpoint_not_on">Dieser Cache ist kein Favorit.</string>
<string name="cache_favpoint_add">Hinzufügen</string>
<string name="cache_favpoint_remove">Entfernen</string>
+ <string name="cache_list_text">Liste:</string>
+ <string name="cache_list_change">Verschieben</string>
+ <string name="cache_list_unknown">In keiner Liste</string>
<string name="cache_images">Bilder</string>
- <string name="cache_images_loading">Lade Bilder…</string>
<string name="cache_waypoints">Wegpunkte</string>
<plurals name="waypoints">
<item quantity="one">1 Wegpunkt</item>
@@ -590,6 +593,7 @@
<string name="cache_coordinates_original">Ursprüngliche Koordinaten</string>
<string name="cache_spoiler_images_title">Hinweisbilder</string>
<string name="cache_spoiler_images_loading">Lade Hinweisbilder…</string>
+ <string name="cache_images_loading">Lade Bilder…</string>
<string name="cache_log_types">Logs</string>
<string name="cache_coordinates_no">Dieser Cache hat keine Koordinaten.</string>
<string name="cache_clear_history">Verlauf leeren</string>
diff --git a/main/res/values/strings.xml b/main/res/values/strings.xml
index 991b0a2..cc47681 100644
--- a/main/res/values/strings.xml
+++ b/main/res/values/strings.xml
@@ -392,6 +392,7 @@
<string name="init_save_log_img">Save Images from Logs</string>
<string name="init_units">Use Imperial Units instead of Metric Units</string>
<string name="init_log_offline">Enable Offline Logging\n(Don\'t show online Log screen when logging, don\'t send the Log online)</string>
+ <string name="init_choose_list">Ask for list when storing caches</string>
<string name="init_livelist">Show Direction to caches in the list</string>
<string name="init_altitude">Altitude Correction</string>
<string name="init_altitude_description">If your GPS is calculating a wrong altitude, you can correct it with a positive or negative number. The correction always has to be given in meters.</string>
@@ -511,6 +512,9 @@
<string name="cache_favpoint_not_on">This cache is not one of your favorites.</string>
<string name="cache_favpoint_add">Add</string>
<string name="cache_favpoint_remove">Remove</string>
+ <string name="cache_list_text">List:</string>
+ <string name="cache_list_change">Move</string>
+ <string name="cache_list_unknown">Not in a list</string>
<string name="cache_images">Images</string>
<string name="cache_waypoints">Waypoints</string>
diff --git a/main/res/values/strings_not_translatable.xml b/main/res/values/strings_not_translatable.xml
index a13b9b1..1853fac 100644
--- a/main/res/values/strings_not_translatable.xml
+++ b/main/res/values/strings_not_translatable.xml
@@ -87,6 +87,8 @@
· Inverse sorting of cache lists (hit the same menu again)\n
· View pager in trackable activity\n
· Menu item to delete past events\n
+ · Settings: Option to ask for list to store caches in\n
+ · Change list in cache details\n
· Ability to select \"All\" list from main screen\n
· Default log type for event caches will be \"Attended\" if \"Will attend\" was logged before\n
· Improved and extended cache type detection on live map\n
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 03c0bcf..33d89b3 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -36,6 +36,7 @@ import cgeo.geocaching.utils.HtmlUtils;
import cgeo.geocaching.utils.ImageHelper;
import cgeo.geocaching.utils.Log;
import cgeo.geocaching.utils.MatcherWrapper;
+import cgeo.geocaching.utils.RunnableWithArgument;
import cgeo.geocaching.utils.TranslationUtils;
import cgeo.geocaching.utils.UnknownTagsHandler;
@@ -1240,6 +1241,11 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
buttonFavPointRemove.setOnClickListener(new FavoriteRemoveClickListener());
updateFavPointBox();
+ // list
+ Button buttonChangeList = (Button) view.findViewById(R.id.change_list);
+ buttonChangeList.setOnClickListener(new ChangeListClickListener());
+ updateListBox();
+
// data license
IConnector connector = ConnectorFactory.getConnector(cache);
if (connector != null) {
@@ -1309,6 +1315,21 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
return;
}
+ if (Settings.getChooseList()) {
+ // let user select list to store cache in
+ new StoredList.UserInterface(CacheDetailActivity.this).promptForListSelection(R.string.list_title,
+ new RunnableWithArgument<Integer>() {
+ @Override
+ public void run(final Integer selectedListId) {
+ storeCache(selectedListId);
+ }
+ }, true, StoredList.TEMPORARY_LIST_ID);
+ } else {
+ storeCache(StoredList.TEMPORARY_LIST_ID);
+ }
+ }
+
+ protected void storeCache(int listId) {
final StoreCacheHandler storeCacheHandler = new StoreCacheHandler();
progress.show(CacheDetailActivity.this, res.getString(R.string.cache_dialog_offline_save_title), res.getString(R.string.cache_dialog_offline_save_message), true, storeCacheHandler.cancelMessage());
@@ -1317,7 +1338,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
storeThread.interrupt();
}
- storeThread = new StoreCacheThread(storeCacheHandler);
+ storeThread = new StoreCacheThread(listId, storeCacheHandler);
storeThread.start();
}
}
@@ -1344,15 +1365,17 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
}
private class StoreCacheThread extends Thread {
+ final private int listId;
final private CancellableHandler handler;
- public StoreCacheThread(final CancellableHandler handler) {
+ public StoreCacheThread(final int listId, final CancellableHandler handler) {
+ this.listId = listId;
this.handler = handler;
}
@Override
public void run() {
- cache.store(handler);
+ cache.store(listId, handler);
}
}
@@ -1537,6 +1560,38 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
}
/**
+ * Listener for "change list" button
+ */
+ private class ChangeListClickListener implements View.OnClickListener {
+ @Override
+ public void onClick(View view) {
+ new StoredList.UserInterface(CacheDetailActivity.this).promptForListSelection(R.string.list_title,
+ new RunnableWithArgument<Integer>() {
+ @Override
+ public void run(final Integer selectedListId) {
+ switchListById(selectedListId);
+ }
+ }, true, cache.getListId());
+ }
+ }
+
+ /**
+ * move cache to another list
+ *
+ * @param listId
+ * the ID of the list
+ */
+ public void switchListById(int listId) {
+ if (listId < 0) {
+ return;
+ }
+
+ Settings.saveLastList(listId);
+ cgData.moveToList(cache, listId);
+ updateListBox();
+ }
+
+ /**
* shows/hides buttons, sets text in watchlist box
*/
private void updateWatchlistBox() {
@@ -1604,6 +1659,31 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
}
/**
+ * shows/hides/updates list box
+ */
+ private void updateListBox() {
+ View box = view.findViewById(R.id.list_box);
+
+ if (cache.isOffline()) {
+ // show box
+ box.setVisibility(View.VISIBLE);
+
+ // update text
+ TextView text = (TextView) view.findViewById(R.id.list_text);
+ StoredList list = cgData.getList(cache.getListId());
+ if (list != null) {
+ text.setText(res.getString(R.string.cache_list_text) + " " + list.title);
+ } else {
+ // this should not happen
+ text.setText(R.string.cache_list_unknown);
+ }
+ } else {
+ // hide box
+ box.setVisibility(View.GONE);
+ }
+ }
+
+ /**
* Handler, called when watchlist add or remove is done
*/
private class WatchlistHandler extends Handler {
diff --git a/main/src/cgeo/geocaching/CachePopup.java b/main/src/cgeo/geocaching/CachePopup.java
index 7441b79..e6d0148 100644
--- a/main/src/cgeo/geocaching/CachePopup.java
+++ b/main/src/cgeo/geocaching/CachePopup.java
@@ -6,6 +6,7 @@ import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.ui.CacheDetailsCreator;
import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.Log;
+import cgeo.geocaching.utils.RunnableWithArgument;
import org.apache.commons.lang3.StringUtils;
@@ -114,22 +115,39 @@ public class CachePopup extends AbstractPopupActivity {
return;
}
+ if (Settings.getChooseList()) {
+ // let user select list to store cache in
+ new StoredList.UserInterface(CachePopup.this).promptForListSelection(R.string.list_title,
+ new RunnableWithArgument<Integer>() {
+ @Override
+ public void run(final Integer selectedListId) {
+ storeCache(selectedListId);
+ }
+ }, true, StoredList.TEMPORARY_LIST_ID);
+ } else {
+ storeCache(StoredList.TEMPORARY_LIST_ID);
+ }
+ }
+
+ protected void storeCache(final int listId) {
final StoreCacheHandler storeCacheHandler = new StoreCacheHandler();
progress.show(CachePopup.this, res.getString(R.string.cache_dialog_offline_save_title), res.getString(R.string.cache_dialog_offline_save_message), true, storeCacheHandler.cancelMessage());
- new StoreCacheThread(storeCacheHandler).start();
+ new StoreCacheThread(listId, storeCacheHandler).start();
}
}
private class StoreCacheThread extends Thread {
+ final private int listId;
final private CancellableHandler handler;
- public StoreCacheThread(final CancellableHandler handler) {
+ public StoreCacheThread(final int listId, final CancellableHandler handler) {
+ this.listId = listId;
this.handler = handler;
}
@Override
public void run() {
- cache.store(handler);
+ cache.store(listId, handler);
invalidateOptionsMenuCompatible();
}
}
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java
index eb74d8c..7613665 100644
--- a/main/src/cgeo/geocaching/Geocache.java
+++ b/main/src/cgeo/geocaching/Geocache.java
@@ -1,8 +1,8 @@
package cgeo.geocaching;
+import cgeo.geocaching.cgData.StorageLocation;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.activity.IAbstractActivity;
-import cgeo.geocaching.cgData.StorageLocation;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.IConnector;
import cgeo.geocaching.connector.capability.ISearchByCenter;
@@ -1374,7 +1374,13 @@ public class Geocache implements ICache, IWaypoint {
}
public void store(CancellableHandler handler) {
- final int listId = Math.max(getListId(), StoredList.STANDARD_LIST_ID);
+ store(StoredList.TEMPORARY_LIST_ID, handler);
+ }
+
+ public void store(int listId, CancellableHandler handler) {
+ if (listId < StoredList.STANDARD_LIST_ID) {
+ listId = Math.max(getListId(), StoredList.STANDARD_LIST_ID);
+ }
storeCache(this, null, listId, false, handler);
}
diff --git a/main/src/cgeo/geocaching/Settings.java b/main/src/cgeo/geocaching/Settings.java
index 0e5a406..0c157e1 100644
--- a/main/src/cgeo/geocaching/Settings.java
+++ b/main/src/cgeo/geocaching/Settings.java
@@ -86,6 +86,7 @@ public final class Settings {
private static final String KEY_MEMBER_STATUS = "memberstatus";
private static final String KEY_COORD_INPUT_FORMAT = "coordinputformat";
private static final String KEY_LOG_OFFLINE = "log_offline";
+ private static final String KEY_CHOOSE_LIST = "choose_list";
private static final String KEY_LOAD_DIRECTION_IMG = "loaddirectionimg";
private static final String KEY_GC_CUSTOM_DATE = "gccustomdate";
private static final String KEY_SHOW_WAYPOINTS_THRESHOLD = "gcshowwaypointsthreshold";
@@ -204,6 +205,7 @@ public final class Settings {
e.putString(KEY_MEMBER_STATUS, old.getString(KEY_MEMBER_STATUS, ""));
e.putInt(KEY_COORD_INPUT_FORMAT, old.getInt(KEY_COORD_INPUT_FORMAT, 0));
e.putBoolean(KEY_LOG_OFFLINE, old.getBoolean(KEY_LOG_OFFLINE, false));
+ e.putBoolean(KEY_CHOOSE_LIST, old.getBoolean(KEY_CHOOSE_LIST, false));
e.putBoolean(KEY_LOAD_DIRECTION_IMG, old.getBoolean(KEY_LOAD_DIRECTION_IMG, true));
e.putString(KEY_GC_CUSTOM_DATE, old.getString(KEY_GC_CUSTOM_DATE, null));
e.putInt(KEY_SHOW_WAYPOINTS_THRESHOLD, old.getInt(KEY_SHOW_WAYPOINTS_THRESHOLD, 0));
@@ -552,6 +554,20 @@ public final class Settings {
return sharedPrefs.getBoolean(KEY_LOG_OFFLINE, false);
}
+ static void setChooseList(final boolean choose) {
+ editSharedSettings(new PrefRunnable() {
+
+ @Override
+ public void edit(Editor edit) {
+ edit.putBoolean(KEY_CHOOSE_LIST, choose);
+ }
+ });
+ }
+
+ public static boolean getChooseList() {
+ return sharedPrefs.getBoolean(KEY_CHOOSE_LIST, false);
+ }
+
static void setLoadDirImg(final boolean value) {
editSharedSettings(new PrefRunnable() {
diff --git a/main/src/cgeo/geocaching/SettingsActivity.java b/main/src/cgeo/geocaching/SettingsActivity.java
index a099c85..3463204 100644
--- a/main/src/cgeo/geocaching/SettingsActivity.java
+++ b/main/src/cgeo/geocaching/SettingsActivity.java
@@ -521,6 +521,17 @@ public class SettingsActivity extends AbstractActivity {
}
});
+ final CheckBox chooseList = (CheckBox) findViewById(R.id.choose_list);
+ chooseList.setChecked(Settings.getChooseList());
+ chooseList.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Settings.setChooseList(!Settings.getChooseList());
+ chooseList.setChecked(Settings.getChooseList());
+ }
+ });
+
final CheckBox plainLogs = (CheckBox) findViewById(R.id.plain_logs);
plainLogs.setChecked(Settings.getPlainLogs());
plainLogs.setOnClickListener(new View.OnClickListener() {
diff --git a/main/src/cgeo/geocaching/StoredList.java b/main/src/cgeo/geocaching/StoredList.java
index b75f25a..5a6f132 100644
--- a/main/src/cgeo/geocaching/StoredList.java
+++ b/main/src/cgeo/geocaching/StoredList.java
@@ -1,6 +1,6 @@
package cgeo.geocaching;
-import cgeo.geocaching.activity.IAbstractActivity;
+import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.utils.RunnableWithArgument;
import org.apache.commons.lang3.StringUtils;
@@ -54,11 +54,11 @@ public class StoredList {
}
public static class UserInterface {
- private final IAbstractActivity activity;
+ private final Activity activity;
private final cgeoapplication app;
private final Resources res;
- public UserInterface(final IAbstractActivity activity) {
+ public UserInterface(final Activity activity) {
this.activity = activity;
app = cgeoapplication.getInstance();
res = app.getResources();
@@ -93,7 +93,7 @@ public class StoredList {
final CharSequence[] items = new CharSequence[listsTitle.size()];
- AlertDialog.Builder builder = new AlertDialog.Builder((Activity) activity);
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(res.getString(titleId));
builder.setItems(listsTitle.toArray(items), new DialogInterface.OnClickListener() {
@Override
@@ -123,20 +123,20 @@ public class StoredList {
final int newId = cgData.createList(listName);
if (newId >= cgData.customListIdOffset) {
- activity.showToast(res.getString(R.string.list_dialog_create_ok));
+ ActivityMixin.showToast(activity, res.getString(R.string.list_dialog_create_ok));
if (runAfterwards != null) {
runAfterwards.run(newId);
}
} else {
- activity.showToast(res.getString(R.string.list_dialog_create_err));
+ ActivityMixin.showToast(activity, res.getString(R.string.list_dialog_create_err));
}
}
});
}
private void handleListNameInput(final String defaultValue, int dialogTitle, int buttonTitle, final RunnableWithArgument<String> runnable) {
- final AlertDialog.Builder alert = new AlertDialog.Builder((Activity) activity);
- final View view = ((Activity) activity).getLayoutInflater().inflate(R.layout.list_create_dialog, null);
+ final AlertDialog.Builder alert = new AlertDialog.Builder(activity);
+ final View view = activity.getLayoutInflater().inflate(R.layout.list_create_dialog, null);
final EditText input = (EditText) view.findViewById(R.id.text);
input.setText(defaultValue);
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java
index 2a62f0b..13546f3 100644
--- a/main/src/cgeo/geocaching/cgData.java
+++ b/main/src/cgeo/geocaching/cgData.java
@@ -2581,6 +2581,10 @@ public class cgData {
return status;
}
+ public static void moveToList(final Geocache cache, final int listId) {
+ moveToList(Collections.singletonList(cache), listId);
+ }
+
public static void moveToList(final List<Geocache> caches, final int listId) {
if (listId == StoredList.ALL_LIST_ID) {
return;
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index 372bb68..cf10fb5 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -828,7 +828,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
invalidateOptionsMenuCompatible();
return true;
case MENU_REFRESH_STORED:
- refreshStored();
+ refreshStored(adapter.getCheckedOrAllCaches());
invalidateOptionsMenuCompatible();
return true;
case MENU_DROP_CACHES:
@@ -1042,8 +1042,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
}, true, listId);
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.
- cache.store(null);
+ refreshStored(Collections.singletonList(cache));
break;
case MENU_EXPORT:
ExportFactory.showExportMenu(Collections.singletonList(cache), this);
@@ -1175,8 +1174,27 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
refreshCurrentList();
}
- public void refreshStored() {
- detailTotal = adapter.getCheckedOrAllCount();
+ public void refreshStored(final List<Geocache> caches) {
+ detailTotal = caches.size();
+ if (detailTotal == 0) {
+ return;
+ }
+
+ if (Settings.getChooseList() && type != CacheListType.OFFLINE) {
+ // let user select list to store cache in
+ new StoredList.UserInterface(this).promptForListSelection(R.string.list_title,
+ new RunnableWithArgument<Integer>() {
+ @Override
+ public void run(final Integer selectedListId) {
+ refreshStored(caches, selectedListId);
+ }
+ }, true, StoredList.TEMPORARY_LIST_ID);
+ } else {
+ refreshStored(caches, this.listId);
+ }
+ }
+
+ private void refreshStored(final List<Geocache> caches, final int storeListId) {
detailProgress = 0;
showProgress(false);
@@ -1194,7 +1212,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
detailProgressTime = System.currentTimeMillis();
- threadDetails = new LoadDetailsThread(loadDetailsHandler, listId);
+ threadDetails = new LoadDetailsThread(loadDetailsHandler, caches, storeListId);
threadDetails.start();
}
@@ -1413,11 +1431,11 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
final private int listIdLD;
private volatile boolean needToStop = false;
private long last = 0L;
- final private List<Geocache> selected;
+ final private List<Geocache> caches;
- public LoadDetailsThread(Handler handlerIn, int listId) {
+ public LoadDetailsThread(Handler handlerIn, List<Geocache> caches, int listId) {
handler = handlerIn;
- selected = adapter.getCheckedOrAllCaches();
+ this.caches = caches;
// in case of online lists, set the list id to the standard list
this.listIdLD = Math.max(listId, StoredList.STANDARD_LIST_ID);
@@ -1431,8 +1449,8 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
public void run() {
removeGeoAndDir();
- final List<Geocache> cachesWithStaticMaps = new ArrayList<Geocache>(selected.size());
- for (Geocache cache : selected) {
+ final List<Geocache> cachesWithStaticMaps = new ArrayList<Geocache>(this.caches.size());
+ for (Geocache cache : this.caches) {
if (Settings.isStoreOfflineMaps() && cache.hasStaticMap()) {
cachesWithStaticMaps.add(cache);
continue;
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index 88cf2dc..5df0845 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -8,10 +8,10 @@ import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
import cgeo.geocaching.StoredList;
import cgeo.geocaching.Waypoint;
-import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.cgData;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.cgeocaches;
+import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.gc.Login;
import cgeo.geocaching.enumerations.CacheType;
@@ -36,6 +36,7 @@ import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.GeoDirHandler;
import cgeo.geocaching.utils.LeastRecentlyUsedSet;
import cgeo.geocaching.utils.Log;
+import cgeo.geocaching.utils.RunnableWithArgument;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -652,42 +653,18 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
return true;
}
- final LoadDetailsHandler loadDetailsHandler = new LoadDetailsHandler();
-
- waitDialog = new ProgressDialog(activity);
- waitDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
- waitDialog.setCancelable(true);
- waitDialog.setCancelMessage(loadDetailsHandler.cancelMessage());
- waitDialog.setMax(detailTotal);
- waitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
-
- @Override
- public void onCancel(DialogInterface arg0) {
- try {
- if (loadDetailsThread != null) {
- loadDetailsThread.stopIt();
- }
-
- geoDirUpdate.startDir();
- } catch (Exception e) {
- Log.e("cgeocaches.onPrepareOptionsMenu.onCancel", e);
- }
- }
- });
-
- float etaTime = detailTotal * 7.0f / 60.0f;
- int roundedEta = Math.round(etaTime);
- if (etaTime < 0.4) {
- waitDialog.setMessage(res.getString(R.string.caches_downloading) + " " + res.getString(R.string.caches_eta_ltm));
- } else {
- waitDialog.setMessage(res.getString(R.string.caches_downloading) + " " + roundedEta + " " + res.getQuantityString(R.plurals.caches_eta_mins, roundedEta));
+ if (Settings.getChooseList()) {
+ // let user select list to store cache in
+ new StoredList.UserInterface(activity).promptForListSelection(R.string.list_title,
+ new RunnableWithArgument<Integer>() {
+ @Override
+ public void run(final Integer selectedListId) {
+ storeCaches(geocodes, selectedListId);
+ }
+ }, true, StoredList.TEMPORARY_LIST_ID);
+ } else {
+ storeCaches(geocodes, StoredList.STANDARD_LIST_ID);
}
- waitDialog.show();
-
- detailProgressTime = System.currentTimeMillis();
-
- loadDetailsThread = new LoadDetails(loadDetailsHandler, geocodes);
- loadDetailsThread.start();
}
return true;
case MENU_CIRCLE_MODE:
@@ -1343,6 +1320,51 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
/**
+ * store caches, invoked by "store offline" menu item
+ *
+ * @param listId
+ * the list to store the caches in
+ */
+ private void storeCaches(List<String> geocodes, int listId) {
+ final LoadDetailsHandler loadDetailsHandler = new LoadDetailsHandler();
+
+ waitDialog = new ProgressDialog(activity);
+ waitDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ waitDialog.setCancelable(true);
+ waitDialog.setCancelMessage(loadDetailsHandler.cancelMessage());
+ waitDialog.setMax(detailTotal);
+ waitDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
+
+ @Override
+ public void onCancel(DialogInterface arg0) {
+ try {
+ if (loadDetailsThread != null) {
+ loadDetailsThread.stopIt();
+ }
+
+ geoDirUpdate.startDir();
+ } catch (Exception e) {
+ Log.e("cgeocaches.onPrepareOptionsMenu.onCancel", e);
+ }
+ }
+ });
+
+ float etaTime = detailTotal * 7.0f / 60.0f;
+ int roundedEta = Math.round(etaTime);
+ if (etaTime < 0.4) {
+ waitDialog.setMessage(res.getString(R.string.caches_downloading) + " " + res.getString(R.string.caches_eta_ltm));
+ } else {
+ waitDialog.setMessage(res.getString(R.string.caches_downloading) + " " + roundedEta + " " + res.getQuantityString(R.plurals.caches_eta_mins, roundedEta));
+ }
+ waitDialog.show();
+
+ detailProgressTime = System.currentTimeMillis();
+
+ loadDetailsThread = new LoadDetails(loadDetailsHandler, geocodes, listId);
+ loadDetailsThread.start();
+ }
+
+ /**
* Thread to store the caches in the viewport. Started by Activity.
*/
@@ -1350,11 +1372,13 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
final private CancellableHandler handler;
final private List<String> geocodes;
+ final private int listId;
private long last = 0L;
- public LoadDetails(final CancellableHandler handler, final List<String> geocodes) {
+ public LoadDetails(final CancellableHandler handler, final List<String> geocodes, final int listId) {
this.handler = handler;
this.geocodes = geocodes;
+ this.listId = listId;
}
public void stopIt() {
@@ -1395,7 +1419,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
break;
}
- Geocache.storeCache(null, geocode, StoredList.STANDARD_LIST_ID, false, handler);
+ Geocache.storeCache(null, geocode, listId, false, handler);
}
} catch (Exception e) {
Log.e("cgeocaches.LoadDetails.run", e);