summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhalid Zubair <kzubair@cyngn.com>2016-05-18 17:05:16 -0700
committerSteve Kondik <steve@cyngn.com>2016-11-20 02:11:09 -0800
commit379e3bde1c1797b02c3be7eea423e165e173eeeb (patch)
tree61b60e0265d86ea62145c6b3b83b73a90bd64fd4
parentb3bff03623009620f762608633aa1f8faa4a6fa6 (diff)
downloadandroid_packages_apps_Snap-379e3bde1c1797b02c3be7eea423e165e173eeeb.zip
android_packages_apps_Snap-379e3bde1c1797b02c3be7eea423e165e173eeeb.tar.gz
android_packages_apps_Snap-379e3bde1c1797b02c3be7eea423e165e173eeeb.tar.bz2
CropActivity: notify MediaScanner on save complete
MediaScanner should be notified when a file is created or changed. Add an explicit call at the end of the async task writing saving the bitmap. Fixes FEIJ-479 where the cropped file was being shown as a 0 byte file over MTP. Change-Id: I2220654a75f502089f44e1cb24682b73516c43b0
-rw-r--r--src/com/android/camera/crop/CropActivity.java13
-rw-r--r--src/com/android/camera/crop/SaveImage.java2
2 files changed, 13 insertions, 2 deletions
diff --git a/src/com/android/camera/crop/CropActivity.java b/src/com/android/camera/crop/CropActivity.java
index 9c09b9a..45455cc 100644
--- a/src/com/android/camera/crop/CropActivity.java
+++ b/src/com/android/camera/crop/CropActivity.java
@@ -31,6 +31,7 @@ import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -46,6 +47,7 @@ import org.codeaurora.snapcam.R;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -581,6 +583,16 @@ public class CropActivity extends Activity {
}
}
}
+
+ File dest = SaveImage.getLocalFileFromUri(CropActivity.this, mOutUri);
+ if (dest != null) {
+ MediaScannerConnection.scanFile(
+ CropActivity.this,
+ new String[] { dest.toString() },
+ null /* no mimetype, let scanner guess */,
+ null /* no callback */);
+ }
+
return !failure; // True if any of the operations failed
}
@@ -590,7 +602,6 @@ public class CropActivity extends Activity {
Utils.closeSilently(mInStream);
doneBitmapIO(result.booleanValue(), mResultIntent);
}
-
}
private void done() {
diff --git a/src/com/android/camera/crop/SaveImage.java b/src/com/android/camera/crop/SaveImage.java
index f5e89de..1701fb6 100644
--- a/src/com/android/camera/crop/SaveImage.java
+++ b/src/com/android/camera/crop/SaveImage.java
@@ -385,7 +385,7 @@ public class SaveImage {
* @return The file object. Return null if srcUri is invalid or not a local
* file.
*/
- private static File getLocalFileFromUri(Context context, Uri srcUri) {
+ static File getLocalFileFromUri(Context context, Uri srcUri) {
if (srcUri == null) {
Log.e(LOGTAG, "srcUri is null.");
return null;