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

Commit 9beac371 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Fixing issue where screenshot intent to file path did not show other...

Merge "Fixing issue where screenshot intent to file path did not show other screenshots. (Bug: 5333706)" into ics-mr0
parents f13313a0 36c9e29c
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.graphics.RectF;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Process;
import android.os.ServiceManager;
import android.provider.MediaStore;
import android.util.DisplayMetrics;
@@ -54,7 +55,6 @@ import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.android.server.wm.WindowManagerService;
import com.android.systemui.R;

import java.io.File;
@@ -68,6 +68,7 @@ import java.util.Date;
class SaveImageInBackgroundData {
    Context context;
    Bitmap image;
    Uri imageUri;
    Runnable finisher;
    int iconSize;
    int result;
@@ -128,9 +129,6 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
                (iconHeight - data.iconSize) / 2, data.iconSize, data.iconSize);

        // Show the intermediate notification
        mLaunchIntent = new Intent(Intent.ACTION_VIEW);
        mLaunchIntent.setDataAndType(Uri.fromFile(new File(mImageFilePath)), "image/png");
        mLaunchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mTickerAddSpace = !mTickerAddSpace;
        mNotificationId = nId;
        mNotificationBuilder = new Notification.Builder(context)
@@ -152,6 +150,10 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
    protected SaveImageInBackgroundData doInBackground(SaveImageInBackgroundData... params) {
        if (params.length != 1) return null;

        // By default, AsyncTask sets the worker thread to have background thread priority, so bump
        // it back up so that we save a little quicker.
        Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);

        Context context = params[0].context;
        Bitmap image = params[0].image;

@@ -178,6 +180,7 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
            values.put(MediaStore.Images.ImageColumns.SIZE, new File(mImageFilePath).length());
            resolver.update(uri, values, null, null);

            params[0].imageUri = uri;
            params[0].result = 0;
        } catch (Exception e) {
            // IOException/UnsupportedOperationException may be thrown if external storage is not
@@ -197,6 +200,11 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
            // Show the final notification to indicate screenshot saved
            Resources r = params.context.getResources();

            // Create the intent to show the screenshot in gallery
            mLaunchIntent = new Intent(Intent.ACTION_VIEW);
            mLaunchIntent.setDataAndType(params.imageUri, "image/png");
            mLaunchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            mNotificationBuilder
                .setContentTitle(r.getString(R.string.screenshot_saved_title))
                .setContentText(r.getString(R.string.screenshot_saved_text))