Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 095f79f3 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Gallery2: fix app crash when there is no map app"

parents f8e3352e f6b2aac9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -426,6 +426,9 @@
    <string name="remember_location_prompt" msgid="724592331305808098">"为您的照片和视频标明拍摄地点。\n\n其他应用在查看您保存的照片和视频时将可以使用这些信息。"</string>
    <string name="remember_location_no" msgid="7541394381714894896">"不用了"</string>
    <string name="remember_location_yes" msgid="862884269285964180">"好"</string>
    <!-- The message is shown in toast when click showOnMap Menu and there is no map app -->
    <string name="map_activity_not_found_err">没有地图应用显示地理位置信息</string>

    <string name="menu_camera" msgid="3476709832879398998">"相机"</string>
    <string name="menu_search" msgid="7580008232297437190">"搜索"</string>
    <string name="tab_photos" msgid="9110813680630313419">"照片"</string>
+3 −0
Original line number Diff line number Diff line
@@ -1104,6 +1104,9 @@ CHAR LIMIT = NONE] -->
    <!-- Positive answer for first run dialog asking if the user wants to remember photo locations [CHAR LIMIT = 20] -->
    <string name="remember_location_yes">Yes</string>

    <!-- The message is shown in toast when click showOnMap Menu and there is no map app -->
    <string name="map_activity_not_found_err">There is no map app for show location.</string>

    <!-- Menu item to launch the camera app [CHAR LIMIT=25] -->
    <string name="menu_camera">Camera</string>
    <!-- Menu item to search for photos [CHAR LIMIT=25] -->
+18 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.gallery3d.util;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
@@ -35,6 +36,7 @@ import android.provider.MediaStore;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
import android.widget.Toast;

import com.android.gallery3d.R;
import com.android.gallery3d.app.GalleryActivity;
@@ -275,7 +277,7 @@ public class GalleryUtils {
        return String.format(Locale.ENGLISH, format, latitude, longitude);
    }

    public static void showOnMap(Context context, double latitude, double longitude) {
    public static void showOnMap(final Context context, double latitude, double longitude) {
        try {
            // We don't use "geo:latitude,longitude" because it only centers
            // the MapView to the specified location, but we need a marker
@@ -292,8 +294,21 @@ public class GalleryUtils {
            // Use the "geo intent" if no GMM is installed
            Log.e(TAG, "GMM activity not found!", e);
            String url = formatLatitudeLongitude("geo:%f,%f", latitude, longitude);
            try {
                Intent mapsIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                context.startActivity(mapsIntent);
            } catch (ActivityNotFoundException ex) {
                Log.e(TAG, "Map view activity not found! url = " + url, ex);
                ((Activity)context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(context,
                                context.getString(R.string.map_activity_not_found_err),
                                Toast.LENGTH_SHORT).show();
                    }
                });

            }
        }
    }