package cgeo.geocaching.apps.cache.navi;

import cgeo.geocaching.R;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.utils.Log;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;

class GoogleMapsApp extends AbstractPointNavigationApp {

    GoogleMapsApp() {
        super(getString(R.string.cache_menu_map_ext), R.id.cache_app_google_maps, null);
    }

    @Override
    public boolean isInstalled() {
        return true;
    }

    @Override
    public void navigate(Activity activity, Geopoint point) {
        // INFO: q parameter works with Google Maps, but breaks cooperation with all other apps
        try {
            activity.startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("geo:" + point.getLatitude() + "," + point.getLongitude())));
            return;
        } catch (RuntimeException e) {
            // nothing
        }
        Log.i("GoogleMapsApp.navigate: No maps application available.");

        ActivityMixin.showToast(activity, getString(R.string.err_application_no));
    }

}

@@ -58,17 +58,83 @@
 caching.
-R
+Geocache;%0Aimport cgeo.geocaching.R;%0Aimport cgeo.geocaching.Waypoint
 ;%0Aimport
@@ -677,522 +677,1104 @@
     
-// INFO: q parameter works with Google Maps, but breaks cooperation with all other apps%0A        try %7B%0A            activity.startActivity(new Intent(Intent.ACTION_VIEW,%0A                    Uri.parse(%22geo:%22 + point.getLatitude() + %22,%22 + point.getLongitude())));%0A            return;%0A        %7D catch (RuntimeException e) %7B%0A            // nothing%0A        %7D%0A        Log.i(%22GoogleMapsApp.navigate: No maps application available.%22);%0A%0A        ActivityMixin.showToast(activity, getString(R.string.err_application_no));%0A    %7D%0A
+navigate(activity, point, activity.getString(R.string.waypoint));%0A    %7D%0A%0A    private static void navigate(Activity activity, Geopoint point, String label) %7B%0A        try %7B%0A            final String geoLocation = %22geo:%22 + point.getLatitude() + %22,%22 + point.getLongitude();%0A            final String query = point.getLatitude() + %22,%22 + point.getLongitude() + %22(%22 + label + %22)%22;%0A            final String uriString = geoLocation + %22?q=%22 + Uri.encode(query);%0A            activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uriString)));%0A            return;%0A        %7D catch (RuntimeException e) %7B%0A            // nothing%0A        %7D%0A        Log.i(%22GoogleMapsApp.navigate: No maps application available.%22);%0A%0A        ActivityMixin.showToast(activity, getString(R.string.err_application_no));%0A    %7D%0A%0A    @Override%0A    public void navigate(Activity activity, Geocache cache) %7B%0A        navigate(activity, cache.getCoords(), cache.getName());%0A    %7D%0A%0A    @Override%0A    public void navigate(Activity activity, Waypoint waypoint) %7B%0A        navigate(activity, waypoint.getCoords(), waypoint.getName());%0A    %7D
 %0A%7D%0A

fix #3555: No marker on external map