fix photo hotes in android 4.4
This commit is contained in:
parent
4ed7f81661
commit
1f96c9c00d
2 changed files with 19 additions and 4 deletions
|
@ -116,7 +116,11 @@ public class AndroidUtils {
|
|||
}
|
||||
|
||||
public static Uri getUriForFile(Context context, File file) {
|
||||
return FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||
return Uri.fromFile(file);
|
||||
} else {
|
||||
return FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file);
|
||||
}
|
||||
}
|
||||
|
||||
public static Spannable replaceCharsWithIcon(String text, Drawable icon, String[] chars) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.audionotes;
|
|||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -828,6 +829,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
public void captureImage(double lat, double lon, final MapActivity mapActivity) {
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
Uri fileUri = AndroidUtils.getUriForFile(mapActivity, getBaseFileName(lat, lon, app, IMG_EXTENSION));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
|
||||
intent.setClipData(ClipData.newRawUri("", fileUri));
|
||||
}
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
// start the image capture Intent
|
||||
|
@ -842,8 +846,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
// ext = THREEGP_EXTENSION;
|
||||
// }
|
||||
Uri fileUri = AndroidUtils.getUriForFile(mapActivity, getBaseFileName(lat, lon, app, ext));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
|
||||
intent.setClipData(ClipData.newRawUri("", fileUri));
|
||||
}
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high
|
||||
// start the video capture Intent
|
||||
mapActivity.startActivityForResult(intent, 205);
|
||||
|
@ -1502,8 +1509,12 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
final File f = getBaseFileName(lat, lon, app, IMG_EXTENSION);
|
||||
lastTakingPhoto = f;
|
||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, AndroidUtils.getUriForFile(mapActivity,f));
|
||||
takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
Uri uri = AndroidUtils.getUriForFile(mapActivity, f);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
|
||||
takePictureIntent.setClipData(ClipData.newRawUri("", uri));
|
||||
}
|
||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
|
||||
takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
try {
|
||||
mapActivity.startActivityForResult(takePictureIntent, 205);
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in a new issue