properly index take photo uris from file provider
This commit is contained in:
parent
b6e7def9db
commit
f4a883848c
|
@ -432,14 +432,12 @@ public class FileBackend {
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getTakePhotoPath() {
|
||||||
|
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)+"/Camera/";
|
||||||
|
}
|
||||||
|
|
||||||
public Uri getTakePhotoUri() {
|
public Uri getTakePhotoUri() {
|
||||||
StringBuilder pathBuilder = new StringBuilder();
|
File file = new File(getTakePhotoPath()+"IMG_" + this.imageDateFormat.format(new Date()) + ".jpg");
|
||||||
pathBuilder.append(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM));
|
|
||||||
pathBuilder.append('/');
|
|
||||||
pathBuilder.append("Camera");
|
|
||||||
pathBuilder.append('/');
|
|
||||||
pathBuilder.append("IMG_" + this.imageDateFormat.format(new Date()) + ".jpg");
|
|
||||||
File file = new File(pathBuilder.toString());
|
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
return FileProvider.getUriForFile(mXmppConnectionService, "eu.siacs.conversations.files", file);
|
return FileProvider.getUriForFile(mXmppConnectionService, "eu.siacs.conversations.files", file);
|
||||||
|
@ -448,6 +446,15 @@ public class FileBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Uri getIndexableTakePhotoUri(Uri original) {
|
||||||
|
if ("file".equals(original.getScheme())) {
|
||||||
|
return original;
|
||||||
|
} else {
|
||||||
|
List<String> segments = original.getPathSegments();
|
||||||
|
return Uri.parse("file://"+getTakePhotoPath()+segments.get(segments.size() - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Avatar getPepAvatar(Uri image, int size, Bitmap.CompressFormat format) {
|
public Avatar getPepAvatar(Uri image, int size, Bitmap.CompressFormat format) {
|
||||||
try {
|
try {
|
||||||
Avatar avatar = new Avatar();
|
Avatar avatar = new Avatar();
|
||||||
|
|
|
@ -1411,7 +1411,7 @@ public class ConversationActivity extends XmppActivity
|
||||||
mPendingImageUris.clear();
|
mPendingImageUris.clear();
|
||||||
}
|
}
|
||||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||||
intent.setData(uri);
|
intent.setData(FileBackend.getIndexableTakePhotoUri(uri));
|
||||||
sendBroadcast(intent);
|
sendBroadcast(intent);
|
||||||
} else {
|
} else {
|
||||||
mPendingImageUris.clear();
|
mPendingImageUris.clear();
|
||||||
|
|
Loading…
Reference in New Issue