mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-01 06:38:29 +02:00
Get attachment URI with name
This commit is contained in:
@@ -23,9 +23,11 @@ import static androidx.room.ForeignKey.CASCADE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.ForeignKey;
|
||||
@@ -153,6 +155,14 @@ public class EntityAttachment {
|
||||
return (encryption != null);
|
||||
}
|
||||
|
||||
Uri getUri(Context context) {
|
||||
File file = getFile(context);
|
||||
if (TextUtils.isEmpty(name))
|
||||
return FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
|
||||
else
|
||||
return FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file, name);
|
||||
}
|
||||
|
||||
File getFile(Context context) {
|
||||
return getFile(context, id, name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user