diff options
Diffstat (limited to 'main/src')
| -rw-r--r-- | main/src/cgeo/geocaching/CacheListActivity.java | 11 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/CreateShortcutActivity.java | 55 |
2 files changed, 64 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/CacheListActivity.java b/main/src/cgeo/geocaching/CacheListActivity.java index 08d41d0..be9b59c 100644 --- a/main/src/cgeo/geocaching/CacheListActivity.java +++ b/main/src/cgeo/geocaching/CacheListActivity.java @@ -444,7 +444,8 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA } private boolean isInvokedFromAttachment() { - return Intent.ACTION_VIEW.equals(getIntent().getAction()); + final Intent intent = getIntent(); + return Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getData() != null; } private void importGpxAttachement() { @@ -1550,7 +1551,13 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA AbstractSearchLoader loader = null; switch (enumType) { case OFFLINE: - listId = Settings.getLastList(); + // open either the requested or the last list + if (extras.containsKey(Intents.EXTRA_LIST_ID)) { + listId = extras.getInt(Intents.EXTRA_LIST_ID); + } + else { + listId = Settings.getLastList(); + } if (listId <= StoredList.TEMPORARY_LIST_ID) { listId = StoredList.STANDARD_LIST_ID; title = res.getString(R.string.stored_caches_button); diff --git a/main/src/cgeo/geocaching/CreateShortcutActivity.java b/main/src/cgeo/geocaching/CreateShortcutActivity.java new file mode 100644 index 0000000..7b91ba1 --- /dev/null +++ b/main/src/cgeo/geocaching/CreateShortcutActivity.java @@ -0,0 +1,55 @@ +package cgeo.geocaching; + +import cgeo.geocaching.activity.AbstractActivity; +import cgeo.geocaching.list.StoredList; +import cgeo.geocaching.utils.RunnableWithArgument; + +import android.content.Intent; +import android.content.Intent.ShortcutIconResource; +import android.os.Bundle; + +public class CreateShortcutActivity extends AbstractActivity { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // init + setTheme(); + + promptForShortcut(); + } + + private void promptForShortcut() { + new StoredList.UserInterface(this).promptForListSelection(R.string.create_shortcut, new RunnableWithArgument<Integer>() { + + @Override + public void run(final Integer listId) { + final Intent shortcut = createShortcut(listId.intValue()); + setResult(RESULT_OK, shortcut); + + // finish activity to return the shortcut + finish(); + } + }); + } + + protected Intent createShortcut(int listId) { + final StoredList list = DataStore.getList(listId); + if (list == null) { + return null; + } + // target to be executed by the shortcut + final Intent targetIntent = new Intent(this, CacheListActivity.class); + targetIntent.putExtra(Intents.EXTRA_LIST_ID, list.id); + final ShortcutIconResource iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.cgeo); + + // shortcut to be returned + final Intent intent = new Intent(); + intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, targetIntent); + intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, list.title); + intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); + return intent; + } + +} |
