don’t query packages before attaching something

This commit is contained in:
Daniel Gultsch 2022-02-22 16:23:51 +01:00
parent 2cc49e5ba6
commit 6fb465f91a
2 changed files with 7 additions and 12 deletions

View file

@ -1147,19 +1147,13 @@ public class FileBackend {
}
public Uri getTakePhotoUri() {
final String filename = String.format("IMG_%s.%s", IMAGE_DATE_FORMAT.format(new Date()),"jpg");
File file;
if (Config.ONLY_INTERNAL_STORAGE) {
file =
new File(
mXmppConnectionService.getCacheDir().getAbsolutePath(),
"Camera/IMG_" + IMAGE_DATE_FORMAT.format(new Date()) + ".jpg");
final File dcimCache = new File(mXmppConnectionService.getCacheDir(), "Camera");
file = new File(dcimCache, filename);
} else {
file =
new File(
getTakePhotoPath()
+ "IMG_"
+ IMAGE_DATE_FORMAT.format(new Date())
+ ".jpg");
file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), filename);
}
file.getParentFile().mkdirs();
return getUriForFile(mXmppConnectionService, file);

View file

@ -6,6 +6,7 @@ import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -1744,7 +1745,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
if (context == null) {
return;
}
if (intent.resolveActivity(context.getPackageManager()) != null) {
try {
if (chooser) {
startActivityForResult(
Intent.createChooser(intent, getString(R.string.perform_action_with)),
@ -1752,7 +1753,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} else {
startActivityForResult(intent, attachmentChoice);
}
} else {
} catch (final ActivityNotFoundException e) {
Toast.makeText(context, R.string.no_application_found, Toast.LENGTH_LONG).show();
}
}