diff options
author | Winson Chung <winsonc@google.com> | 2011-10-18 13:48:38 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-10-18 13:58:40 -0700 |
commit | 36c9e29cc6554fc1fe34565b93c2280f6a6b4cf9 (patch) | |
tree | 9ff2ada0ab87b69b656762e283c465e699150903 /packages/SystemUI/src/com/android/systemui/screenshot | |
parent | 87bc53de2adf479ad5a5e226bf3d8fd31af6dc21 (diff) | |
download | frameworks_base-36c9e29cc6554fc1fe34565b93c2280f6a6b4cf9.zip frameworks_base-36c9e29cc6554fc1fe34565b93c2280f6a6b4cf9.tar.gz frameworks_base-36c9e29cc6554fc1fe34565b93c2280f6a6b4cf9.tar.bz2 |
Fixing issue where screenshot intent to file path did not show other screenshots. (Bug: 5333706)
- Upping the priority of the saving background thread
Change-Id: I274991261f46eece3773ca1f84d2a1cb7b6f4e7b
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/screenshot')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index 181cc98..301ae73 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -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)) |