diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2014-05-31 08:13:12 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2014-05-31 08:13:12 +0200 |
| commit | 2bc6c925216b2b2b8cd921cd7996b4cb8657bac4 (patch) | |
| tree | 3e05c4521d5457293a6a8f9de3e1e69a660f86b3 /main/src/cgeo/geocaching/Geocache.java | |
| parent | 72de884a71bed85880f074bc212d56be3a9b5134 (diff) | |
| parent | 2b2a2e19e1793ae79f80c8e520fb36a56e576e29 (diff) | |
| download | cgeo-2bc6c925216b2b2b8cd921cd7996b4cb8657bac4.zip cgeo-2bc6c925216b2b2b8cd921cd7996b4cb8657bac4.tar.gz cgeo-2bc6c925216b2b2b8cd921cd7996b4cb8657bac4.tar.bz2 | |
Merge pull request #3901 from schwabe/internal_webview
Internal webview
Diffstat (limited to 'main/src/cgeo/geocaching/Geocache.java')
| -rw-r--r-- | main/src/cgeo/geocaching/Geocache.java | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index 0840d6f..6084762 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -1,7 +1,9 @@ package cgeo.geocaching; +import android.os.Parcelable; import cgeo.geocaching.DataStore.StorageLocation; import cgeo.geocaching.activity.ActivityMixin; +import cgeo.geocaching.activity.SimpleWebviewActivity; import cgeo.geocaching.connector.ConnectorFactory; import cgeo.geocaching.connector.IConnector; import cgeo.geocaching.connector.ILoggingManager; @@ -493,11 +495,27 @@ public class Geocache implements ICache, IWaypoint { } public void openInBrowser(Activity fromActivity) { - fromActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getBrowserCacheUrl()))); + Intent viewIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getUrl())); + + // Check if cgeo is the default, show the chooser to let the user choose a browser + if (viewIntent.resolveActivity(fromActivity.getPackageManager()).getPackageName().equals(fromActivity.getPackageName())) { + Intent chooser = Intent.createChooser(viewIntent, fromActivity.getString(R.string.cache_menu_browser)); + + Intent internalBrowser = new Intent(fromActivity, SimpleWebviewActivity.class); + internalBrowser.setData(Uri.parse(getUrl())); + + chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Parcelable[] {internalBrowser}); + + + fromActivity.startActivity(chooser); + } + else + fromActivity.startActivity(viewIntent); } + private String getCacheUrl() { - return getConnector().getCacheBrowserUrl(this); + return getConnector().getCacheUrl(this); } private String getBrowserCacheUrl() { @@ -718,16 +736,16 @@ public class Geocache implements ICache, IWaypoint { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, subject.toString()); - intent.putExtra(Intent.EXTRA_TEXT, getBrowserUrl()); + intent.putExtra(Intent.EXTRA_TEXT, getUrl()); return intent; } - public String getBrowserUrl() { - return getConnector().getCacheBrowserUrl(this); + public String getUrl() { + return getConnector().getCacheUrl(this); } - public String getCgeoUrl() { return getConnector().getCgeoCacheUrl(this); } + public String getCgeoUrl() { return getConnector().getCacheUrl(this); } public boolean supportsGCVote() { return StringUtils.startsWithIgnoreCase(geocode, "GC"); |
