Improved file picker in chat

This commit is contained in:
Sylvain Berfini 2019-08-19 10:50:38 +02:00
parent c840456ff9
commit 6fe1c4d5f4
4 changed files with 23 additions and 18 deletions

View file

@ -78,7 +78,7 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 4124
versionCode 4126
versionName "${project.version}"
applicationId getPackageName()
multiDexEnabled true

View file

@ -150,13 +150,15 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
@Override
protected void onDestroy() {
if (mInterfaceLoaded) {
mAddress = null;
mStartCall = null;
mAddCall = null;
mTransferCall = null;
mAddContact = null;
mBackToCall = null;
mListener = null;
}
if (mListener != null) mListener = null;
super.onDestroy();
}

View file

@ -959,6 +959,13 @@ public class ChatMessagesFragment extends Fragment
private void pickFile() {
List<Intent> cameraIntents = new ArrayList<>();
// Handles image & video picking
Intent galleryIntent = new Intent(Intent.ACTION_PICK);
galleryIntent.setType("*/*");
galleryIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] {"image/*", "video/*"});
// Allows to capture directly from the camera
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file =
new File(
@ -969,13 +976,9 @@ public class ChatMessagesFragment extends Fragment
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageToUploadUri);
cameraIntents.add(captureIntent);
Intent galleryIntent = new Intent();
galleryIntent.setType("image/*");
galleryIntent.setAction(Intent.ACTION_PICK);
Intent fileIntent = new Intent();
// Finally allow any kind of file
Intent fileIntent = new Intent(Intent.ACTION_GET_CONTENT);
fileIntent.setType("*/*");
fileIntent.setAction(Intent.ACTION_GET_CONTENT);
cameraIntents.add(fileIntent);
Intent chooserIntent =