Fixed inline attachments

This commit is contained in:
M66B 2019-01-06 12:18:17 +00:00
parent 9154945de9
commit 7cc1f076f4
6 changed files with 17 additions and 7 deletions

View File

@ -103,7 +103,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
}
private void bindTo(EntityAttachment attachment) {
ivDelete.setVisibility(readonly ? View.GONE : attachment.isInline() ? View.INVISIBLE : View.VISIBLE);
ivDelete.setVisibility(readonly ? View.GONE : View.VISIBLE);
tvName.setText(attachment.name);
if (attachment.size != null)

View File

@ -68,6 +68,11 @@ public interface DaoAttachment {
" WHERE id = :id")
void setDownloaded(long id, Integer size);
@Query("UPDATE attachment" +
" SET cid = :cid" +
" WHERE id = :id")
void setCid(long id, String cid);
@Insert
long insertAttachment(EntityAttachment attachment);

View File

@ -112,7 +112,6 @@ public class EntityAttachment {
InputStream is = null;
OutputStream os = null;
try {
this.progress = null;
db.attachment().setProgress(this.id, null);
is = this.part.getInputStream();
@ -130,15 +129,11 @@ public class EntityAttachment {
}
// Store attachment data
this.size = size;
this.progress = null;
this.available = true;
db.attachment().setDownloaded(this.id, size);
Log.i("Downloaded attachment size=" + this.size);
} catch (IOException ex) {
// Reset progress on failure
this.progress = null;
db.attachment().setProgress(this.id, null);
throw ex;
} finally {
@ -160,6 +155,9 @@ public class EntityAttachment {
this.sequence.equals(other.sequence) &&
(this.name == null ? other.name == null : this.name.equals(other.name)) &&
this.type.equals(other.type) &&
(this.disposition == null ? other.disposition == null : this.disposition.equals(other.disposition)) &&
(this.cid == null ? other.cid == null : this.cid.equals(other.cid)) &&
(this.encryption == null ? other.encryption == null : this.encryption.equals(other.encryption)) &&
(this.size == null ? other.size == null : this.size.equals(other.size)) &&
(this.progress == null ? other.progress == null : this.progress.equals(other.progress)) &&
this.available.equals(other.available));

View File

@ -1180,8 +1180,10 @@ public class FragmentCompose extends FragmentEx {
db.attachment().setProgress(attachment.id, size * 100 / attachment.size);
}
if (image)
if (image) {
attachment.cid = "<" + BuildConfig.APPLICATION_ID + "." + attachment.id + ">";
db.attachment().setCid(attachment.id, attachment.cid);
}
db.attachment().setDownloaded(attachment.id, size);
} finally {

View File

@ -616,6 +616,7 @@ public class MessageHelper {
}
if (content instanceof InputStream || content instanceof String) {
// https://www.iana.org/assignments/cont-disp/cont-disp.xhtml
String disposition;
try {
disposition = part.getDisposition();

View File

@ -183,6 +183,7 @@
<string name="title_identity_delete">Ștergeți definitiv această identitate?</string>
<string name="title_pop">POP nu este acceptat</string>
<string name="title_identity_sent_hint">În cele mai multe cazuri mesajele trimise se stochează automat în dosarul corespunzător</string>
<string name="title_edit_html">Editează ca HTML</string>
<string name="title_synchronize_now">Sincronizează acum</string>
<string name="title_delete_local">Șterge mesajul local</string>
<string name="title_empty_trash">Golire coș de gunoi</string>
@ -233,6 +234,8 @@
<string name="title_show_headers">Arată antetul</string>
<string name="title_manage_keywords">Gestionare cuvinte cheie</string>
<string name="title_add_keyword">Adăugă cuvânt cheie</string>
<string name="title_download_all">Descarcă tot</string>
<string name="title_save_all">Salvează tot</string>
<string name="title_show_html">Arată originalul</string>
<string name="title_trash">Gunoi</string>
<string name="title_delete">Şterge</string>
@ -250,6 +253,7 @@
<string name="title_no_contacts">Selectorul de contacte nu este disponibil</string>
<string name="title_no_internet">Nu există conexiune la internet</string>
<string name="title_attachment_saved">Atașament salvat</string>
<string name="title_attachments_saved">Atașamente salvate</string>
<string name="title_attachment_unavailable">Unele fișiere atașate nu sunt descărcate și nu vor fi adăugate, continuați?</string>
<string name="title_image_unavailable">Unele imagini nu sunt descărcate și nu vor fi adăugate, continuați?</string>
<string name="title_ask_delete">Ștergeți definitiv mesajul?</string>