diff options
-rw-r--r-- | main/src/cgeo/geocaching/StaticMapsActivity.java | 27 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java | 12 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeo.java | 11 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeoimages.java | 2 |
4 files changed, 34 insertions, 18 deletions
diff --git a/main/src/cgeo/geocaching/StaticMapsActivity.java b/main/src/cgeo/geocaching/StaticMapsActivity.java index 71ea656..a95f4d2 100644 --- a/main/src/cgeo/geocaching/StaticMapsActivity.java +++ b/main/src/cgeo/geocaching/StaticMapsActivity.java @@ -7,6 +7,8 @@ import cgeo.geocaching.utils.Log; import org.apache.commons.collections.CollectionUtils; import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; @@ -23,6 +25,9 @@ import java.util.List; public class StaticMapsActivity extends AbstractActivity { + private static final String EXTRAS_WAYPOINT = "waypoint"; + private static final String EXTRAS_DOWNLOAD = "download"; + private static final String EXTRAS_GEOCODE = "geocode"; private static final int MENU_REFRESH = 1; private final List<Bitmap> maps = new ArrayList<Bitmap>(); private boolean download = false; @@ -96,10 +101,10 @@ public class StaticMapsActivity extends AbstractActivity { // try to get data from extras if (extras != null) { - download = extras.getBoolean("download", false); - geocode = extras.getString("geocode"); - if (extras.containsKey("waypoint")) { - waypoint_id = extras.getInt("waypoint"); + download = extras.getBoolean(EXTRAS_DOWNLOAD, false); + geocode = extras.getString(EXTRAS_GEOCODE); + if (extras.containsKey(EXTRAS_WAYPOINT)) { + waypoint_id = extras.getInt(EXTRAS_WAYPOINT); } } @@ -207,4 +212,18 @@ public class StaticMapsActivity extends AbstractActivity { showToast(res.getString(R.string.err_detail_not_load_map_static)); return false; } + + public static void startActivity(final Context activity, final String geocode, final boolean download, final cgWaypoint waypoint) { + final Intent intent = new Intent(activity, StaticMapsActivity.class); + // if resuming our app within this activity, finish it and return to the cache activity + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); + intent.putExtra(EXTRAS_GEOCODE, geocode); + if (download) { + intent.putExtra(EXTRAS_DOWNLOAD, true); + } + if (waypoint != null) { + intent.putExtra(EXTRAS_WAYPOINT, waypoint.getId()); + } + activity.startActivity(intent); + } }
\ No newline at end of file diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java index ffcac8e..2edd030 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java @@ -12,7 +12,6 @@ import cgeo.geocaching.activity.ActivityMixin; import org.apache.commons.lang3.StringUtils; import android.app.Activity; -import android.content.Intent; abstract class AbstractStaticMapsApp extends AbstractNavigationApp { public AbstractStaticMapsApp(String name) { @@ -53,16 +52,7 @@ abstract class AbstractStaticMapsApp extends AbstractNavigationApp { return true; } - final Intent intent = new Intent(activity, StaticMapsActivity.class); - intent.putExtra("geocode", geocode); - if (download) { - intent.putExtra("download", true); - } - if (waypoint != null) { - intent.putExtra("waypoint", waypoint.getId()); - } - activity.startActivity(intent); - + StaticMapsActivity.startActivity(activity, geocode, download, waypoint); return true; } diff --git a/main/src/cgeo/geocaching/cgeo.java b/main/src/cgeo/geocaching/cgeo.java index 8be8d9c..63b4dfc 100644 --- a/main/src/cgeo/geocaching/cgeo.java +++ b/main/src/cgeo/geocaching/cgeo.java @@ -301,9 +301,7 @@ public class cgeo extends AbstractActivity { cgeocaches.startActivityHistory(this); return true; case MENU_SCAN: - Intent intent = new Intent(SCAN_INTENT); - intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); - startActivityForResult(intent, SCAN_REQUEST_CODE); + startScannerApplication(); return true; default: break; @@ -312,6 +310,13 @@ public class cgeo extends AbstractActivity { return false; } + private void startScannerApplication() { + Intent intent = new Intent(SCAN_INTENT); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // when resuming our app, cancel this activity + intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); + startActivityForResult(intent, SCAN_REQUEST_CODE); + } + @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == SCAN_REQUEST_CODE) { diff --git a/main/src/cgeo/geocaching/cgeoimages.java b/main/src/cgeo/geocaching/cgeoimages.java index 6d4c77a..ba48ba3 100644 --- a/main/src/cgeo/geocaching/cgeoimages.java +++ b/main/src/cgeo/geocaching/cgeoimages.java @@ -227,6 +227,8 @@ public class cgeoimages extends AbstractActivity { private static void startActivity(final Context fromActivity, final String geocode, ArrayList<cgImage> logImages, int imageType) { final Intent logImgIntent = new Intent(fromActivity, cgeoimages.class); + // if resuming our app within this activity, finish it and return to the cache activity + logImgIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); logImgIntent.putExtra("geocode", geocode.toUpperCase()); logImgIntent.putExtra("type", imageType); logImgIntent.putParcelableArrayListExtra("images", logImages); |