feat: use higher resolution method to get image from camera shortcut
This commit is contained in:
@@ -245,6 +245,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
private ContentType contentType;
|
private ContentType contentType;
|
||||||
private MastodonLanguage.LanguageResolver languageResolver;
|
private MastodonLanguage.LanguageResolver languageResolver;
|
||||||
|
|
||||||
|
private Uri photoUri;
|
||||||
|
|
||||||
private int navigationBarColorBefore;
|
private int navigationBarColorBefore;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1451,11 +1453,11 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(requestCode==CAMERA_PIC_REQUEST_CODE && resultCode==Activity.RESULT_OK){
|
if(requestCode==CAMERA_PIC_REQUEST_CODE && resultCode==Activity.RESULT_OK){
|
||||||
Bitmap image = (Bitmap) data.getExtras().get("data");
|
// Bitmap image = (Bitmap) data.getExtras().get("data");
|
||||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
// ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||||
image.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
|
// image.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
|
||||||
String path = MediaStore.Images.Media.insertImage(getContext().getContentResolver(), image, null, null);
|
// String path = MediaStore.Images.Media.insertImage(getContext().getContentResolver(), image, null, null);
|
||||||
addMediaAttachment(Uri.parse(path), null);
|
addMediaAttachment(photoUri), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1467,7 +1469,11 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||||||
|
|
||||||
private void openCamera(){
|
private void openCamera(){
|
||||||
if (getContext().checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
|
if (getContext().checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
File photoFile = createImageFile(); // This method creates a file to store the image
|
||||||
|
photoUri = FileProvider.getUriForFile(getContext(), "org.joinmastodon.android.moshinda.fileprovider", photoFile);
|
||||||
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
|
||||||
|
|
||||||
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST_CODE);
|
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST_CODE);
|
||||||
} else {
|
} else {
|
||||||
getActivity().requestPermissions(new String[] { Manifest.permission.CAMERA }, CAMERA_PERMISSION_CODE);
|
getActivity().requestPermissions(new String[] { Manifest.permission.CAMERA }, CAMERA_PERMISSION_CODE);
|
||||||
|
|||||||
Reference in New Issue
Block a user