mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-29 04:06:42 +02:00
Image editor: rename image
This commit is contained in:
@@ -25,6 +25,7 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
@@ -124,6 +125,18 @@ public class FragmentDialogEditImage extends FragmentDialogBase {
|
||||
bm.compress(Bitmap.CompressFormat.PNG, ImageHelper.DEFAULT_PNG_COMPRESSION, os);
|
||||
}
|
||||
|
||||
if (attachment.name != null) {
|
||||
int index = attachment.name.lastIndexOf(".");
|
||||
if (index > 0) {
|
||||
String ext = attachment.name.substring(index + 1);
|
||||
if (!TextUtils.isEmpty(ext) && !ext.equalsIgnoreCase("png")) {
|
||||
File old = attachment.getFile(context);
|
||||
attachment.name = attachment.name.substring(0, index) + ".png";
|
||||
old.renameTo(attachment.getFile(context));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
db.attachment().setName(id, attachment.name, "image/png", file.length());
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user