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 { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 28
versionCode 4124 versionCode 4126
versionName "${project.version}" versionName "${project.version}"
applicationId getPackageName() applicationId getPackageName()
multiDexEnabled true multiDexEnabled true

View file

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

View file

@ -959,6 +959,13 @@ public class ChatMessagesFragment extends Fragment
private void pickFile() { private void pickFile() {
List<Intent> cameraIntents = new ArrayList<>(); 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); Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = File file =
new File( new File(
@ -969,13 +976,9 @@ public class ChatMessagesFragment extends Fragment
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageToUploadUri); captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageToUploadUri);
cameraIntents.add(captureIntent); cameraIntents.add(captureIntent);
Intent galleryIntent = new Intent(); // Finally allow any kind of file
galleryIntent.setType("image/*"); Intent fileIntent = new Intent(Intent.ACTION_GET_CONTENT);
galleryIntent.setAction(Intent.ACTION_PICK);
Intent fileIntent = new Intent();
fileIntent.setType("*/*"); fileIntent.setType("*/*");
fileIntent.setAction(Intent.ACTION_GET_CONTENT);
cameraIntents.add(fileIntent); cameraIntents.add(fileIntent);
Intent chooserIntent = Intent chooserIntent =