aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2015-02-21 18:13:45 +0100
committerBananeweizen <bananeweizen@gmx.de>2015-02-21 18:13:45 +0100
commit6730171634cc41a4ea46cb8bfc91b4d822ae4a0c (patch)
treee54dfb36020374d64ebbf06418be8647b5023e02 /main
parent491aa856303b4c01da8cda8bb033e58e5b8eb975 (diff)
downloadcgeo-6730171634cc41a4ea46cb8bfc91b4d822ae4a0c.zip
cgeo-6730171634cc41a4ea46cb8bfc91b4d822ae4a0c.tar.gz
cgeo-6730171634cc41a4ea46cb8bfc91b4d822ae4a0c.tar.bz2
fix up navigation once more
Diffstat (limited to 'main')
-rw-r--r--main/res/values/changelog_master.xml1
-rw-r--r--main/src/cgeo/geocaching/activity/ActivityMixin.java20
2 files changed, 11 insertions, 10 deletions
diff --git a/main/res/values/changelog_master.xml b/main/res/values/changelog_master.xml
index 015c70b..4cb262d 100644
--- a/main/res/values/changelog_master.xml
+++ b/main/res/values/changelog_master.xml
@@ -24,6 +24,7 @@
· Fix: Do not limit to 10 logs for OC caches\n
· Fix: Recognize more hyperlinks of opencaching caches\n
· Fix: Remove empty space in some opencaching logs\n
+ · Fix: Allow up navigation when opening the app from a link\n
\n
</string>
</resources>
diff --git a/main/src/cgeo/geocaching/activity/ActivityMixin.java b/main/src/cgeo/geocaching/activity/ActivityMixin.java
index e9d3249..5b3be70 100644
--- a/main/src/cgeo/geocaching/activity/ActivityMixin.java
+++ b/main/src/cgeo/geocaching/activity/ActivityMixin.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.activity;
+import cgeo.geocaching.CgeoApplication;
+import cgeo.geocaching.MainActivity;
import cgeo.geocaching.R;
import cgeo.geocaching.settings.Settings;
@@ -155,20 +157,18 @@ public final class ActivityMixin {
editText.setSelection(newCursor);
}
- /**
- * This is the exact code from Google to implement Up navigation, with one exception: activity.isTaskRoot() was
- * added as {@link NavUtils#shouldUpRecreateTask(Activity, Intent)} seems not to handle the case, that this activity
- * was created from an intent by another app, and our own app is not yet running. The bug seems to be fixed in
- * Android 4.4.something, however.
- *
- */
public static boolean navigateUp(@NonNull final Activity activity) {
- // see http://developer.android.com/training/implementing-navigation/ancestral.html
- final Intent upIntent = NavUtils.getParentActivityIntent(activity);
- if (upIntent == null) {
+ // first check if there is a parent declared in the manifest
+ Intent upIntent = NavUtils.getParentActivityIntent(activity);
+ // if there is no parent, and if this was not a new task, then just go back to simulate going to a parent
+ if (upIntent == null && !activity.isTaskRoot()) {
activity.finish();
return true;
}
+ // use the main activity, if there was no back stack and no manifest based parent
+ if (upIntent == null) {
+ upIntent = new Intent(CgeoApplication.getInstance(), MainActivity.class);
+ }
if (NavUtils.shouldUpRecreateTask(activity, upIntent) || activity.isTaskRoot()) {
// This activity is NOT part of this app's task, so create a new task
// when navigating up, with a synthesized back stack.