aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java20
-rw-r--r--main/src/cgeo/geocaching/ICache.java4
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java5
3 files changed, 14 insertions, 15 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 49f52ba..3c1a36d 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -21,7 +21,14 @@ import cgeo.geocaching.network.Parameters;
import cgeo.geocaching.ui.CacheDetailsCreator;
import cgeo.geocaching.ui.DecryptTextClickListener;
import cgeo.geocaching.ui.Formatter;
-import cgeo.geocaching.utils.*;
+import cgeo.geocaching.utils.BaseUtils;
+import cgeo.geocaching.utils.CancellableHandler;
+import cgeo.geocaching.utils.ClipboardUtils;
+import cgeo.geocaching.utils.CryptUtils;
+import cgeo.geocaching.utils.GeoDirHandler;
+import cgeo.geocaching.utils.Log;
+import cgeo.geocaching.utils.TranslationUtils;
+import cgeo.geocaching.utils.UnknownTagsHandler;
import com.viewpagerindicator.TitlePageIndicator;
import com.viewpagerindicator.TitleProvider;
@@ -1680,10 +1687,7 @@ public class CacheDetailActivity extends AbstractActivity {
Button buttonRemove = (Button) view.findViewById(R.id.remove_from_watchlist);
TextView text = (TextView) view.findViewById(R.id.watchlist_text);
- //TODO: We already have cache.isOwn(). Those 2 should be combined.
- boolean userIsOwner = StringUtils.equals(cache.getOwnerReal(), Settings.getUsername());
-
- if (cache.isOnWatchlist() || userIsOwner) {
+ if (cache.isOnWatchlist() || cache.isOwn()) {
buttonAdd.setVisibility(View.GONE);
buttonRemove.setVisibility(View.VISIBLE);
text.setText(R.string.cache_watchlist_on);
@@ -1694,7 +1698,7 @@ public class CacheDetailActivity extends AbstractActivity {
}
// the owner of a cache has it always on his watchlist. Adding causes an error
- if (userIsOwner) {
+ if (cache.isOwn()) {
buttonAdd.setEnabled(false);
buttonAdd.setVisibility(View.GONE);
buttonRemove.setEnabled(false);
@@ -1707,12 +1711,10 @@ public class CacheDetailActivity extends AbstractActivity {
* shows/hides buttons, sets text in watchlist box
*/
private void updateFavPointBox() {
- boolean userIsOwner = StringUtils.equals(cache.getOwnerReal(), Settings.getUsername());
-
LinearLayout layout = (LinearLayout) view.findViewById(R.id.favpoint_box);
boolean supportsFavoritePoints = cache.supportsFavoritePoints();
layout.setVisibility(supportsFavoritePoints ? View.VISIBLE : View.GONE);
- if (!supportsFavoritePoints || userIsOwner || !Settings.isPremiumMember()) {
+ if (!supportsFavoritePoints || cache.isOwn() || !Settings.isPremiumMember()) {
return;
}
Button buttonAdd = (Button) view.findViewById(R.id.add_to_favpoint);
diff --git a/main/src/cgeo/geocaching/ICache.java b/main/src/cgeo/geocaching/ICache.java
index dccdb85..7cb2ce2 100644
--- a/main/src/cgeo/geocaching/ICache.java
+++ b/main/src/cgeo/geocaching/ICache.java
@@ -23,7 +23,7 @@ public interface ICache extends IBasicCache {
public String getOwner();
/**
- * @return GC username of the owner
+ * @return GC username of the (actual) owner, might differ from the owner. Never empty.
*/
public String getOwnerReal();
@@ -105,7 +105,7 @@ public interface ICache extends IBasicCache {
/**
* immutable list of attributes, never <code>null</code>
- *
+ *
* @return the list of attributes for this cache
*/
public List<String> getAttributes();
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index dc69043..c590001 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -378,10 +378,7 @@ public abstract class GCParser {
// owner real name
cache.setOwnerReal(URLDecoder.decode(BaseUtils.getMatch(page, GCConstants.PATTERN_OWNERREAL, true, cache.getOwnerReal())));
- final String username = Settings.getUsername();
- if (cache.getOwnerReal() != null && username != null && cache.getOwnerReal().equalsIgnoreCase(username)) {
- cache.setOwn(true);
- }
+ cache.setOwn(StringUtils.equals(cache.getOwnerReal(), Settings.getUsername()));
String tableInside = page;