diff options
author | Winson Chung <winsonc@google.com> | 2015-06-01 18:19:44 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-01 18:19:47 +0000 |
commit | 6920474bac7c212dd384b6ef1134c59b73669942 (patch) | |
tree | 6c60654394a2553dd2b35055461ffeda10ec2933 /packages/SystemUI/src/com | |
parent | a74f385ba08922c09aa812f0d6fd2903a633da01 (diff) | |
parent | ebd77b550be51ccb535b76ac5ba04d37658d2a45 (diff) | |
download | frameworks_base-6920474bac7c212dd384b6ef1134c59b73669942.zip frameworks_base-6920474bac7c212dd384b6ef1134c59b73669942.tar.gz frameworks_base-6920474bac7c212dd384b6ef1134c59b73669942.tar.bz2 |
Merge "Ensuring that we write to disk first." into mnc-dev
Diffstat (limited to 'packages/SystemUI/src/com')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index 7e32c3a..6d02365 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -60,6 +60,7 @@ import android.widget.ImageView; import com.android.systemui.R; import java.io.File; +import java.io.FileOutputStream; import java.io.OutputStream; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -232,6 +233,12 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi // for DATE_TAKEN long dateSeconds = mImageTime / 1000; + // Save + OutputStream out = new FileOutputStream(mImageFilePath); + image.compress(Bitmap.CompressFormat.PNG, 100, out); + out.flush(); + out.close(); + // Save the screenshot to the MediaStore ContentValues values = new ContentValues(); ContentResolver resolver = context.getContentResolver(); @@ -244,8 +251,10 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi values.put(MediaStore.Images.ImageColumns.MIME_TYPE, "image/png"); values.put(MediaStore.Images.ImageColumns.WIDTH, mImageWidth); values.put(MediaStore.Images.ImageColumns.HEIGHT, mImageHeight); + values.put(MediaStore.Images.ImageColumns.SIZE, new File(mImageFilePath).length()); Uri uri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); + // Create a share intent String subjectDate = DateFormat.getDateTimeInstance().format(new Date(mImageTime)); String subject = String.format(SCREENSHOT_SHARE_SUBJECT_TEMPLATE, subjectDate); Intent sharingIntent = new Intent(Intent.ACTION_SEND); @@ -253,16 +262,6 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi sharingIntent.putExtra(Intent.EXTRA_STREAM, uri); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject); - OutputStream out = resolver.openOutputStream(uri); - image.compress(Bitmap.CompressFormat.PNG, 100, out); - out.flush(); - out.close(); - - // Update file size in the database - values.clear(); - values.put(MediaStore.Images.ImageColumns.SIZE, new File(mImageFilePath).length()); - resolver.update(uri, values, null, null); - // Create a share action for the notification final PendingIntent callback = PendingIntent.getBroadcast(context, 0, new Intent(context, GlobalScreenshot.TargetChosenReceiver.class) |