Merge "Fixing issue where screenshot intent to file path did not show other screenshots. (Bug: 5333706)" into ics-mr0

This commit is contained in:
Winson Chung
2011-10-18 15:44:01 -07:00
committed by Android (Google) Code Review

View File

@@ -38,6 +38,7 @@ import android.graphics.RectF;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Environment; import android.os.Environment;
import android.os.Process;
import android.os.ServiceManager; import android.os.ServiceManager;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
@@ -54,7 +55,6 @@ import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import com.android.server.wm.WindowManagerService;
import com.android.systemui.R; import com.android.systemui.R;
import java.io.File; import java.io.File;
@@ -68,6 +68,7 @@ import java.util.Date;
class SaveImageInBackgroundData { class SaveImageInBackgroundData {
Context context; Context context;
Bitmap image; Bitmap image;
Uri imageUri;
Runnable finisher; Runnable finisher;
int iconSize; int iconSize;
int result; int result;
@@ -128,9 +129,6 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
(iconHeight - data.iconSize) / 2, data.iconSize, data.iconSize); (iconHeight - data.iconSize) / 2, data.iconSize, data.iconSize);
// Show the intermediate notification // 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; mTickerAddSpace = !mTickerAddSpace;
mNotificationId = nId; mNotificationId = nId;
mNotificationBuilder = new Notification.Builder(context) mNotificationBuilder = new Notification.Builder(context)
@@ -152,6 +150,10 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
protected SaveImageInBackgroundData doInBackground(SaveImageInBackgroundData... params) { protected SaveImageInBackgroundData doInBackground(SaveImageInBackgroundData... params) {
if (params.length != 1) return null; 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; Context context = params[0].context;
Bitmap image = params[0].image; 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()); values.put(MediaStore.Images.ImageColumns.SIZE, new File(mImageFilePath).length());
resolver.update(uri, values, null, null); resolver.update(uri, values, null, null);
params[0].imageUri = uri;
params[0].result = 0; params[0].result = 0;
} catch (Exception e) { } catch (Exception e) {
// IOException/UnsupportedOperationException may be thrown if external storage is not // 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 // Show the final notification to indicate screenshot saved
Resources r = params.context.getResources(); 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 mNotificationBuilder
.setContentTitle(r.getString(R.string.screenshot_saved_title)) .setContentTitle(r.getString(R.string.screenshot_saved_title))
.setContentText(r.getString(R.string.screenshot_saved_text)) .setContentText(r.getString(R.string.screenshot_saved_text))