Skip to content

Commit 9beac37

Browse files
Winson ChungAndroid (Google) Code Review
authored andcommitted
Merge "Fixing issue where screenshot intent to file path did not show other screenshots. (Bug: 5333706)" into ics-mr0
2 parents f13313a + 36c9e29 commit 9beac37

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import android.net.Uri;
3939
import android.os.AsyncTask;
4040
import android.os.Environment;
41+
import android.os.Process;
4142
import android.os.ServiceManager;
4243
import android.provider.MediaStore;
4344
import android.util.DisplayMetrics;
@@ -54,7 +55,6 @@
5455
import android.widget.FrameLayout;
5556
import android.widget.ImageView;
5657

57-
import com.android.server.wm.WindowManagerService;
5858
import com.android.systemui.R;
5959

6060
import java.io.File;
@@ -68,6 +68,7 @@
6868
class SaveImageInBackgroundData {
6969
Context context;
7070
Bitmap image;
71+
Uri imageUri;
7172
Runnable finisher;
7273
int iconSize;
7374
int result;
@@ -128,9 +129,6 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
128129
(iconHeight - data.iconSize) / 2, data.iconSize, data.iconSize);
129130

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

153+
// By default, AsyncTask sets the worker thread to have background thread priority, so bump
154+
// it back up so that we save a little quicker.
155+
Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
156+
155157
Context context = params[0].context;
156158
Bitmap image = params[0].image;
157159

@@ -178,6 +180,7 @@ protected SaveImageInBackgroundData doInBackground(SaveImageInBackgroundData...
178180
values.put(MediaStore.Images.ImageColumns.SIZE, new File(mImageFilePath).length());
179181
resolver.update(uri, values, null, null);
180182

183+
params[0].imageUri = uri;
181184
params[0].result = 0;
182185
} catch (Exception e) {
183186
// IOException/UnsupportedOperationException may be thrown if external storage is not
@@ -197,6 +200,11 @@ protected void onPostExecute(SaveImageInBackgroundData params) {
197200
// Show the final notification to indicate screenshot saved
198201
Resources r = params.context.getResources();
199202

203+
// Create the intent to show the screenshot in gallery
204+
mLaunchIntent = new Intent(Intent.ACTION_VIEW);
205+
mLaunchIntent.setDataAndType(params.imageUri, "image/png");
206+
mLaunchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
207+
200208
mNotificationBuilder
201209
.setContentTitle(r.getString(R.string.screenshot_saved_title))
202210
.setContentText(r.getString(R.string.screenshot_saved_text))

0 commit comments

Comments
 (0)