Browse Source

Added option to show headers

main
M66B 6 years ago
parent
commit
49f7a61717
11 changed files with 1061 additions and 37 deletions
  1. +7
    -6
      FAQ.md
  2. +905
    -0
      app/schemas/eu.faircode.email.DB/9.json
  3. +8
    -1
      app/src/main/java/eu/faircode/email/DB.java
  4. +3
    -0
      app/src/main/java/eu/faircode/email/DaoMessage.java
  5. +1
    -0
      app/src/main/java/eu/faircode/email/EntityMessage.java
  6. +1
    -0
      app/src/main/java/eu/faircode/email/EntityOperation.java
  7. +62
    -25
      app/src/main/java/eu/faircode/email/FragmentMessage.java
  8. +18
    -1
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java
  9. +48
    -4
      app/src/main/res/layout/fragment_message.xml
  10. +7
    -0
      app/src/main/res/menu/menu_view.xml
  11. +1
    -0
      app/src/main/res/values/strings.xml

+ 7
- 6
FAQ.md View File

@ -28,12 +28,13 @@ Most, if not all, other email apps don't show a notification with the "side effe
The low priority status bar notification shows the number of pending operations, which can be: The low priority status bar notification shows the number of pending operations, which can be:
* SEEN: mark message as seen/unseen in remote folder
* ADD: add message to remote folder
* MOVE: move message to another remote folder
* DELETE: delete message from remote folder
* SEND: send message
* ATTACHMENT download attachment
* seen: mark message as seen/unseen in remote folder
* add: add message to remote folder
* move: move message to another remote folder
* delete: delete message from remote folder
* send: send message
* attachment download attachment
* headers: download message headers
<a name="FAQ4"></a> <a name="FAQ4"></a>
**(4) What is a valid security certificate?** **(4) What is a valid security certificate?**


+ 905
- 0
app/schemas/eu.faircode.email.DB/9.json View File

@ -0,0 +1,905 @@
{
"formatVersion": 1,
"database": {
"version": 9,
"identityHash": "67fade7db3a87ec2ef27dcec483c456f",
"entities": [
{
"tableName": "identity",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT NOT NULL, `email` TEXT NOT NULL, `replyto` TEXT, `account` INTEGER NOT NULL, `host` TEXT NOT NULL, `port` INTEGER NOT NULL, `starttls` INTEGER NOT NULL, `user` TEXT NOT NULL, `password` TEXT NOT NULL, `auth_type` INTEGER NOT NULL, `primary` INTEGER NOT NULL, `synchronize` INTEGER NOT NULL, `store_sent` INTEGER NOT NULL, `state` TEXT, `error` TEXT, FOREIGN KEY(`account`) REFERENCES `account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "email",
"columnName": "email",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "replyto",
"columnName": "replyto",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "account",
"columnName": "account",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "host",
"columnName": "host",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "port",
"columnName": "port",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "starttls",
"columnName": "starttls",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "user",
"columnName": "user",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "password",
"columnName": "password",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "auth_type",
"columnName": "auth_type",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "primary",
"columnName": "primary",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "synchronize",
"columnName": "synchronize",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "store_sent",
"columnName": "store_sent",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "state",
"columnName": "state",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "error",
"columnName": "error",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_identity_account",
"unique": false,
"columnNames": [
"account"
],
"createSql": "CREATE INDEX `index_identity_account` ON `${TABLE_NAME}` (`account`)"
}
],
"foreignKeys": [
{
"table": "account",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"account"
],
"referencedColumns": [
"id"
]
}
]
},
{
"tableName": "account",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT, `host` TEXT NOT NULL, `port` INTEGER NOT NULL, `user` TEXT NOT NULL, `password` TEXT NOT NULL, `auth_type` INTEGER NOT NULL, `primary` INTEGER NOT NULL, `synchronize` INTEGER NOT NULL, `store_sent` INTEGER NOT NULL, `poll_interval` INTEGER NOT NULL, `seen_until` INTEGER, `state` TEXT, `error` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "host",
"columnName": "host",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "port",
"columnName": "port",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "user",
"columnName": "user",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "password",
"columnName": "password",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "auth_type",
"columnName": "auth_type",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "primary",
"columnName": "primary",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "synchronize",
"columnName": "synchronize",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "store_sent",
"columnName": "store_sent",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "poll_interval",
"columnName": "poll_interval",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "seen_until",
"columnName": "seen_until",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "state",
"columnName": "state",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "error",
"columnName": "error",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "folder",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `account` INTEGER, `name` TEXT NOT NULL, `type` TEXT NOT NULL, `synchronize` INTEGER NOT NULL, `after` INTEGER NOT NULL, `state` TEXT, `error` TEXT, FOREIGN KEY(`account`) REFERENCES `account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "account",
"columnName": "account",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "synchronize",
"columnName": "synchronize",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "after",
"columnName": "after",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "state",
"columnName": "state",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "error",
"columnName": "error",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_folder_account_name",
"unique": true,
"columnNames": [
"account",
"name"
],
"createSql": "CREATE UNIQUE INDEX `index_folder_account_name` ON `${TABLE_NAME}` (`account`, `name`)"
},
{
"name": "index_folder_account",
"unique": false,
"columnNames": [
"account"
],
"createSql": "CREATE INDEX `index_folder_account` ON `${TABLE_NAME}` (`account`)"
},
{
"name": "index_folder_name",
"unique": false,
"columnNames": [
"name"
],
"createSql": "CREATE INDEX `index_folder_name` ON `${TABLE_NAME}` (`name`)"
},
{
"name": "index_folder_type",
"unique": false,
"columnNames": [
"type"
],
"createSql": "CREATE INDEX `index_folder_type` ON `${TABLE_NAME}` (`type`)"
}
],
"foreignKeys": [
{
"table": "account",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"account"
],
"referencedColumns": [
"id"
]
}
]
},
{
"tableName": "message",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `account` INTEGER, `folder` INTEGER NOT NULL, `identity` INTEGER, `replying` INTEGER, `uid` INTEGER, `msgid` TEXT, `references` TEXT, `inreplyto` TEXT, `thread` TEXT, `from` TEXT, `to` TEXT, `cc` TEXT, `bcc` TEXT, `reply` TEXT, `headers` TEXT, `subject` TEXT, `sent` INTEGER, `received` INTEGER NOT NULL, `stored` INTEGER NOT NULL, `seen` INTEGER NOT NULL, `ui_seen` INTEGER NOT NULL, `ui_hide` INTEGER NOT NULL, `ui_found` INTEGER NOT NULL, `error` TEXT, FOREIGN KEY(`account`) REFERENCES `account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`folder`) REFERENCES `folder`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`identity`) REFERENCES `identity`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`replying`) REFERENCES `message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "account",
"columnName": "account",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "folder",
"columnName": "folder",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "identity",
"columnName": "identity",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "replying",
"columnName": "replying",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "uid",
"columnName": "uid",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "msgid",
"columnName": "msgid",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "references",
"columnName": "references",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "inreplyto",
"columnName": "inreplyto",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "thread",
"columnName": "thread",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "from",
"columnName": "from",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "to",
"columnName": "to",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "cc",
"columnName": "cc",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "bcc",
"columnName": "bcc",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "reply",
"columnName": "reply",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "headers",
"columnName": "headers",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "subject",
"columnName": "subject",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "sent",
"columnName": "sent",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "received",
"columnName": "received",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "stored",
"columnName": "stored",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "seen",
"columnName": "seen",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "ui_seen",
"columnName": "ui_seen",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "ui_hide",
"columnName": "ui_hide",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "ui_found",
"columnName": "ui_found",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "error",
"columnName": "error",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_message_account",
"unique": false,
"columnNames": [
"account"
],
"createSql": "CREATE INDEX `index_message_account` ON `${TABLE_NAME}` (`account`)"
},
{
"name": "index_message_folder",
"unique": false,
"columnNames": [
"folder"
],
"createSql": "CREATE INDEX `index_message_folder` ON `${TABLE_NAME}` (`folder`)"
},
{
"name": "index_message_identity",
"unique": false,
"columnNames": [
"identity"
],
"createSql": "CREATE INDEX `index_message_identity` ON `${TABLE_NAME}` (`identity`)"
},
{
"name": "index_message_replying",
"unique": false,
"columnNames": [
"replying"
],
"createSql": "CREATE INDEX `index_message_replying` ON `${TABLE_NAME}` (`replying`)"
},
{
"name": "index_message_folder_uid",
"unique": true,
"columnNames": [
"folder",
"uid"
],
"createSql": "CREATE UNIQUE INDEX `index_message_folder_uid` ON `${TABLE_NAME}` (`folder`, `uid`)"
},
{
"name": "index_message_msgid_folder",
"unique": true,
"columnNames": [
"msgid",
"folder"
],
"createSql": "CREATE UNIQUE INDEX `index_message_msgid_folder` ON `${TABLE_NAME}` (`msgid`, `folder`)"
},
{
"name": "index_message_thread",
"unique": false,
"columnNames": [
"thread"
],
"createSql": "CREATE INDEX `index_message_thread` ON `${TABLE_NAME}` (`thread`)"
},
{
"name": "index_message_received",
"unique": false,
"columnNames": [
"received"
],
"createSql": "CREATE INDEX `index_message_received` ON `${TABLE_NAME}` (`received`)"
},
{
"name": "index_message_ui_seen",
"unique": false,
"columnNames": [
"ui_seen"
],
"createSql": "CREATE INDEX `index_message_ui_seen` ON `${TABLE_NAME}` (`ui_seen`)"
},
{
"name": "index_message_ui_hide",
"unique": false,
"columnNames": [
"ui_hide"
],
"createSql": "CREATE INDEX `index_message_ui_hide` ON `${TABLE_NAME}` (`ui_hide`)"
},
{
"name": "index_message_ui_found",
"unique": false,
"columnNames": [
"ui_found"
],
"createSql": "CREATE INDEX `index_message_ui_found` ON `${TABLE_NAME}` (`ui_found`)"
}
],
"foreignKeys": [
{
"table": "account",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"account"
],
"referencedColumns": [
"id"
]
},
{
"table": "folder",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"folder"
],
"referencedColumns": [
"id"
]
},
{
"table": "identity",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"identity"
],
"referencedColumns": [
"id"
]
},
{
"table": "message",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"replying"
],
"referencedColumns": [
"id"
]
}
]
},
{
"tableName": "attachment",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `message` INTEGER NOT NULL, `sequence` INTEGER NOT NULL, `name` TEXT, `type` TEXT NOT NULL, `size` INTEGER, `progress` INTEGER, `available` INTEGER NOT NULL, FOREIGN KEY(`message`) REFERENCES `message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "message",
"columnName": "message",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "sequence",
"columnName": "sequence",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "size",
"columnName": "size",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "progress",
"columnName": "progress",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "available",
"columnName": "available",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_attachment_message",
"unique": false,
"columnNames": [
"message"
],
"createSql": "CREATE INDEX `index_attachment_message` ON `${TABLE_NAME}` (`message`)"
},
{
"name": "index_attachment_message_sequence",
"unique": true,
"columnNames": [
"message",
"sequence"
],
"createSql": "CREATE UNIQUE INDEX `index_attachment_message_sequence` ON `${TABLE_NAME}` (`message`, `sequence`)"
}
],
"foreignKeys": [
{
"table": "message",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"message"
],
"referencedColumns": [
"id"
]
}
]
},
{
"tableName": "operation",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `folder` INTEGER NOT NULL, `message` INTEGER NOT NULL, `name` TEXT NOT NULL, `args` TEXT NOT NULL, `created` INTEGER NOT NULL, FOREIGN KEY(`folder`) REFERENCES `folder`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`message`) REFERENCES `message`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "folder",
"columnName": "folder",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "message",
"columnName": "message",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "args",
"columnName": "args",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "created",
"columnName": "created",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_operation_folder",
"unique": false,
"columnNames": [
"folder"
],
"createSql": "CREATE INDEX `index_operation_folder` ON `${TABLE_NAME}` (`folder`)"
},
{
"name": "index_operation_message",
"unique": false,
"columnNames": [
"message"
],
"createSql": "CREATE INDEX `index_operation_message` ON `${TABLE_NAME}` (`message`)"
}
],
"foreignKeys": [
{
"table": "folder",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"folder"
],
"referencedColumns": [
"id"
]
},
{
"table": "message",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"message"
],
"referencedColumns": [
"id"
]
}
]
},
{
"tableName": "answer",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT NOT NULL, `text` TEXT NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "text",
"columnName": "text",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "log",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `time` INTEGER NOT NULL, `data` TEXT NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "time",
"columnName": "time",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "data",
"columnName": "data",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_log_time",
"unique": false,
"columnNames": [
"time"
],
"createSql": "CREATE INDEX `index_log_time` ON `${TABLE_NAME}` (`time`)"
}
],
"foreignKeys": []
}
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"67fade7db3a87ec2ef27dcec483c456f\")"
]
}
}

+ 8
- 1
app/src/main/java/eu/faircode/email/DB.java View File

@ -45,7 +45,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 8,
version = 9,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -168,6 +168,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("CREATE INDEX `index_message_ui_found` ON `message` (`ui_found`)"); db.execSQL("CREATE INDEX `index_message_ui_found` ON `message` (`ui_found`)");
} }
}) })
.addMigrations(new Migration(8, 9) {
@Override
public void migrate(SupportSQLiteDatabase db) {
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `headers` TEXT");
}
})
.build(); .build();
} }


+ 3
- 0
app/src/main/java/eu/faircode/email/DaoMessage.java View File

@ -167,6 +167,9 @@ public interface DaoMessage {
@Query("UPDATE message SET ui_found = 0 WHERE folder = :folder") @Query("UPDATE message SET ui_found = 0 WHERE folder = :folder")
int resetFound(long folder); int resetFound(long folder);
@Query("UPDATE message SET headers = :headers WHERE id = :id")
int setMessageHeaders(long id, String headers);
@Query("DELETE FROM message WHERE id = :id") @Query("DELETE FROM message WHERE id = :id")
int deleteMessage(long id); int deleteMessage(long id);


+ 1
- 0
app/src/main/java/eu/faircode/email/EntityMessage.java View File

@ -87,6 +87,7 @@ public class EntityMessage implements Serializable {
public Address[] cc; public Address[] cc;
public Address[] bcc; public Address[] bcc;
public Address[] reply; public Address[] reply;
public String headers;
public String subject; public String subject;
public Long sent; // compose = null public Long sent; // compose = null
@NonNull @NonNull


+ 1
- 0
app/src/main/java/eu/faircode/email/EntityOperation.java View File

@ -71,6 +71,7 @@ public class EntityOperation {
public static final String DELETE = "delete"; public static final String DELETE = "delete";
public static final String SEND = "send"; public static final String SEND = "send";
public static final String ATTACHMENT = "attachment"; public static final String ATTACHMENT = "attachment";
public static final String HEADERS = "headers";
private static List<Intent> queue = new ArrayList<>(); private static List<Intent> queue = new ArrayList<>();


+ 62
- 25
app/src/main/java/eu/faircode/email/FragmentMessage.java View File

@ -120,6 +120,8 @@ public class FragmentMessage extends FragmentEx {
private TextView tvReplyTo; private TextView tvReplyTo;
private TextView tvCc; private TextView tvCc;
private TextView tvBcc; private TextView tvBcc;
private TextView tvRawHeaders;
private ProgressBar pbRawHeaders;
private RecyclerView rvAttachment; private RecyclerView rvAttachment;
private TextView tvError; private TextView tvError;
private View vSeparatorBody; private View vSeparatorBody;
@ -132,12 +134,15 @@ public class FragmentMessage extends FragmentEx {
private Group grpHeader; private Group grpHeader;
private Group grpThread; private Group grpThread;
private Group grpAddresses; private Group grpAddresses;
private Group grpRawHeaders;
private Group grpAttachments; private Group grpAttachments;
private Group grpError; private Group grpError;
private Group grpMessage; private Group grpMessage;
private TupleMessageEx message = null; private TupleMessageEx message = null;
private boolean free = false; private boolean free = false;
private boolean addresses = false;
private boolean headers = false;
private AdapterAttachment adapter; private AdapterAttachment adapter;
private OpenPgpServiceConnection openPgpConnection = null; private OpenPgpServiceConnection openPgpConnection = null;
@ -205,6 +210,8 @@ public class FragmentMessage extends FragmentEx {
tvReplyTo = view.findViewById(R.id.tvReplyTo); tvReplyTo = view.findViewById(R.id.tvReplyTo);
tvCc = view.findViewById(R.id.tvCc); tvCc = view.findViewById(R.id.tvCc);
tvBcc = view.findViewById(R.id.tvBcc); tvBcc = view.findViewById(R.id.tvBcc);
tvRawHeaders = view.findViewById(R.id.tvRawHeaders);
pbRawHeaders = view.findViewById(R.id.pbRawHeaders);
rvAttachment = view.findViewById(R.id.rvAttachment); rvAttachment = view.findViewById(R.id.rvAttachment);
tvError = view.findViewById(R.id.tvError); tvError = view.findViewById(R.id.tvError);
vSeparatorBody = view.findViewById(R.id.vSeparatorBody); vSeparatorBody = view.findViewById(R.id.vSeparatorBody);
@ -217,6 +224,7 @@ public class FragmentMessage extends FragmentEx {
grpHeader = view.findViewById(R.id.grpHeader); grpHeader = view.findViewById(R.id.grpHeader);
grpThread = view.findViewById(R.id.grpThread); grpThread = view.findViewById(R.id.grpThread);
grpAddresses = view.findViewById(R.id.grpAddresses); grpAddresses = view.findViewById(R.id.grpAddresses);
grpRawHeaders = view.findViewById(R.id.grpRawHeaders);
grpAttachments = view.findViewById(R.id.grpAttachments); grpAttachments = view.findViewById(R.id.grpAttachments);
grpError = view.findViewById(R.id.grpError); grpError = view.findViewById(R.id.grpError);
grpMessage = view.findViewById(R.id.grpMessage); grpMessage = view.findViewById(R.id.grpMessage);
@ -295,11 +303,10 @@ public class FragmentMessage extends FragmentEx {
grpThread.setVisibility(View.GONE); grpThread.setVisibility(View.GONE);
grpAddresses.setVisibility(View.GONE); grpAddresses.setVisibility(View.GONE);
pbRawHeaders.setVisibility(View.GONE);
grpRawHeaders.setVisibility(View.GONE);
grpAttachments.setVisibility(View.GONE); grpAttachments.setVisibility(View.GONE);
grpError.setVisibility(View.GONE); grpError.setVisibility(View.GONE);
tvCc.setTag(grpAddresses.getVisibility());
tvError.setTag(grpError.getVisibility());
} }
}); });
@ -317,9 +324,10 @@ public class FragmentMessage extends FragmentEx {
RecyclerView.Adapter adapter = rvAttachment.getAdapter(); RecyclerView.Adapter adapter = rvAttachment.getAdapter();
grpThread.setVisibility(View.VISIBLE); grpThread.setVisibility(View.VISIBLE);
grpAddresses.setVisibility((int) tvCc.getTag());
grpAddresses.setVisibility(addresses ? View.VISIBLE : View.GONE);
pbRawHeaders.setVisibility(headers && message.headers == null ? View.VISIBLE : View.GONE);
grpRawHeaders.setVisibility(headers ? View.VISIBLE : View.GONE);
grpAttachments.setVisibility(adapter != null && adapter.getItemCount() > 0 ? View.VISIBLE : View.GONE); grpAttachments.setVisibility(adapter != null && adapter.getItemCount() > 0 ? View.VISIBLE : View.GONE);
grpError.setVisibility((int) tvError.getTag());
return true; return true;
} }
@ -354,6 +362,8 @@ public class FragmentMessage extends FragmentEx {
// Initialize // Initialize
grpHeader.setVisibility(View.GONE); grpHeader.setVisibility(View.GONE);
grpAddresses.setVisibility(View.GONE); grpAddresses.setVisibility(View.GONE);
pbRawHeaders.setVisibility(View.GONE);
grpRawHeaders.setVisibility(View.GONE);
grpAttachments.setVisibility(View.GONE); grpAttachments.setVisibility(View.GONE);
btnImages.setVisibility(View.GONE); btnImages.setVisibility(View.GONE);
grpMessage.setVisibility(View.GONE); grpMessage.setVisibility(View.GONE);
@ -372,9 +382,6 @@ public class FragmentMessage extends FragmentEx {
adapter = new AdapterAttachment(getContext(), getViewLifecycleOwner(), true); adapter = new AdapterAttachment(getContext(), getViewLifecycleOwner(), true);
rvAttachment.setAdapter(adapter); rvAttachment.setAdapter(adapter);
tvCc.setTag(View.GONE);
tvError.setTag(View.GONE);
return view; return view;
} }
@ -389,10 +396,8 @@ public class FragmentMessage extends FragmentEx {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putSerializable("message", message); outState.putSerializable("message", message);
outState.putBoolean("free", free); outState.putBoolean("free", free);
if (free) {
outState.putInt("tag_cc", (int) tvCc.getTag());
outState.putInt("tag_error", (int) tvError.getTag());
}
outState.putBoolean("headers", headers);
outState.putBoolean("addresses", addresses);
} }
@Override @Override
@ -413,13 +418,13 @@ public class FragmentMessage extends FragmentEx {
tvCc.setText(MessageHelper.getFormattedAddresses(message.cc, true)); tvCc.setText(MessageHelper.getFormattedAddresses(message.cc, true));
tvBcc.setText(MessageHelper.getFormattedAddresses(message.bcc, true)); tvBcc.setText(MessageHelper.getFormattedAddresses(message.bcc, true));
tvRawHeaders.setText(message.headers);
tvError.setText(message.error); tvError.setText(message.error);
} else { } else {
free = savedInstanceState.getBoolean("free"); free = savedInstanceState.getBoolean("free");
if (free) {
tvCc.setTag(savedInstanceState.getInt("tag_cc"));
tvError.setTag(savedInstanceState.getInt("tag_error"));
}
headers = savedInstanceState.getBoolean("headers");
addresses = savedInstanceState.getBoolean("addresses");
} }
if (tvBody.getTag() == null) { if (tvBody.getTag() == null) {
@ -449,14 +454,11 @@ public class FragmentMessage extends FragmentEx {
grpHeader.setVisibility(free ? View.GONE : View.VISIBLE); grpHeader.setVisibility(free ? View.GONE : View.VISIBLE);
vSeparatorBody.setVisibility(free ? View.GONE : View.VISIBLE); vSeparatorBody.setVisibility(free ? View.GONE : View.VISIBLE);
if (free) {
grpThread.setVisibility(View.GONE);
grpAddresses.setVisibility((int) tvCc.getTag());
grpError.setVisibility((int) tvError.getTag());
} else {
grpThread.setVisibility(!free ? View.VISIBLE : View.GONE);
grpError.setVisibility(free || message.error == null ? View.GONE : View.VISIBLE);
}
grpAddresses.setVisibility(!free && addresses ? View.VISIBLE : View.GONE);
grpThread.setVisibility(free ? View.GONE : View.VISIBLE);
pbRawHeaders.setVisibility(!free && headers && message.headers == null ? View.VISIBLE : View.GONE);
grpRawHeaders.setVisibility(free || !headers ? View.GONE : View.VISIBLE);
grpError.setVisibility(message.error == null ? View.GONE : View.VISIBLE);
final DB db = DB.getInstance(getContext()); final DB db = DB.getInstance(getContext());
@ -475,6 +477,10 @@ public class FragmentMessage extends FragmentEx {
FragmentMessage.this.message = message; FragmentMessage.this.message = message;
setSeen(); setSeen();
// Headers can be downloaded
tvRawHeaders.setText(message.headers);
pbRawHeaders.setVisibility(!free && headers && message.headers == null ? View.VISIBLE : View.GONE);
// Message count can be changed // Message count can be changed
getActivity().invalidateOptionsMenu(); getActivity().invalidateOptionsMenu();
@ -565,6 +571,9 @@ public class FragmentMessage extends FragmentEx {
menu.findItem(R.id.menu_addresses).setVisible(!free); menu.findItem(R.id.menu_addresses).setVisible(!free);
menu.findItem(R.id.menu_thread).setVisible(message.count > 1); menu.findItem(R.id.menu_thread).setVisible(message.count > 1);
menu.findItem(R.id.menu_forward).setVisible(!inOutbox); menu.findItem(R.id.menu_forward).setVisible(!inOutbox);
menu.findItem(R.id.menu_show_headers).setChecked(headers);
menu.findItem(R.id.menu_show_headers).setEnabled(message.uid != null);
menu.findItem(R.id.menu_show_headers).setVisible(!free);
menu.findItem(R.id.menu_reply_all).setVisible(message.cc != null && !inOutbox); menu.findItem(R.id.menu_reply_all).setVisible(message.cc != null && !inOutbox);
menu.findItem(R.id.menu_decrypt).setVisible(!inOutbox); menu.findItem(R.id.menu_decrypt).setVisible(!inOutbox);
} }
@ -587,6 +596,9 @@ public class FragmentMessage extends FragmentEx {
case R.id.menu_show_html: case R.id.menu_show_html:
onMenuShowHtml(); onMenuShowHtml();
return true; return true;
case R.id.menu_show_headers:
onMenuShowHeaders();
return true;
case R.id.menu_answer: case R.id.menu_answer:
onMenuAnswer(); onMenuAnswer();
return true; return true;
@ -599,7 +611,8 @@ public class FragmentMessage extends FragmentEx {
} }
private void onMenuAddresses() { private void onMenuAddresses() {
grpAddresses.setVisibility(grpAddresses.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);
addresses = !addresses;
grpAddresses.setVisibility(addresses ? View.VISIBLE : View.GONE);
} }
private void onMenuThread() { private void onMenuThread() {
@ -628,6 +641,30 @@ public class FragmentMessage extends FragmentEx {
.putExtra("reference", message.id)); .putExtra("reference", message.id));
} }
private void onMenuShowHeaders() {
headers = !headers;
getActivity().invalidateOptionsMenu();
pbRawHeaders.setVisibility(headers && message.headers == null ? View.VISIBLE : View.GONE);
grpRawHeaders.setVisibility(headers ? View.VISIBLE : View.GONE);
if (headers && message.headers == null) {
Bundle args = new Bundle();
args.putLong("id", message.id);
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) throws Throwable {
Long id = args.getLong("id");
DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id);
EntityOperation.queue(db, message, EntityOperation.HEADERS);
EntityOperation.process(context);
return null;
}
}.load(this, args);
}
}
private void onMenuShowHtml() { private void onMenuShowHtml() {
new SimpleTask<String>() { new SimpleTask<String>() {
@Override @Override


+ 18
- 1
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -66,6 +66,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -80,6 +81,7 @@ import javax.mail.Flags;
import javax.mail.Folder; import javax.mail.Folder;
import javax.mail.FolderClosedException; import javax.mail.FolderClosedException;
import javax.mail.FolderNotFoundException; import javax.mail.FolderNotFoundException;
import javax.mail.Header;
import javax.mail.Message; import javax.mail.Message;
import javax.mail.MessageRemovedException; import javax.mail.MessageRemovedException;
import javax.mail.MessagingException; import javax.mail.MessagingException;
@ -841,7 +843,8 @@ public class ServiceSynchronize extends LifecycleService {
if (message.uid == null && if (message.uid == null &&
(EntityOperation.SEEN.equals(op.name) || (EntityOperation.SEEN.equals(op.name) ||
EntityOperation.DELETE.equals(op.name) || EntityOperation.DELETE.equals(op.name) ||
EntityOperation.MOVE.equals(op.name)))
EntityOperation.MOVE.equals(op.name) ||
EntityOperation.HEADERS.equals(op.name)))
throw new IllegalArgumentException(op.name + " without uid"); throw new IllegalArgumentException(op.name + " without uid");
JSONArray jargs = new JSONArray(op.args); JSONArray jargs = new JSONArray(op.args);
@ -864,6 +867,9 @@ public class ServiceSynchronize extends LifecycleService {
else if (EntityOperation.ATTACHMENT.equals(op.name)) else if (EntityOperation.ATTACHMENT.equals(op.name))
doAttachment(folder, op, ifolder, message, jargs, db); doAttachment(folder, op, ifolder, message, jargs, db);
else if (EntityOperation.HEADERS.equals(op.name))
doHeaders(folder, ifolder, message, db);
else else
throw new MessagingException("Unknown operation name=" + op.name); throw new MessagingException("Unknown operation name=" + op.name);
@ -1124,6 +1130,17 @@ public class ServiceSynchronize extends LifecycleService {
} }
} }
private void doHeaders(EntityFolder folder, IMAPFolder ifolder, EntityMessage message, DB db) throws MessagingException {
Message imessage = ifolder.getMessageByUID(message.uid);
Enumeration<Header> headers = imessage.getAllHeaders();
StringBuilder sb = new StringBuilder();
while (headers.hasMoreElements()) {
Header header = headers.nextElement();
sb.append(header.getName()).append(": ").append(header.getValue()).append("\n");
}
db.message().setMessageHeaders(message.id, sb.toString());
}
private void synchronizeFolders(EntityAccount account, IMAPStore istore, ServiceState state) throws MessagingException { private void synchronizeFolders(EntityAccount account, IMAPStore istore, ServiceState state) throws MessagingException {
try { try {
Log.v(Helper.TAG, "Start sync folders"); Log.v(Helper.TAG, "Start sync folders");


+ 48
- 4
app/src/main/res/layout/fragment_message.xml View File

@ -185,8 +185,9 @@
app:layout_constraintStart_toEndOf="@id/tvBccTitle" app:layout_constraintStart_toEndOf="@id/tvBccTitle"
app:layout_constraintTop_toBottomOf="@id/tvCc" /> app:layout_constraintTop_toBottomOf="@id/tvCc" />
<View <View
android:id="@+id/vSeparatorAttachments"
android:id="@+id/vSeparatorRawHeaders"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:layout_marginTop="3dp" android:layout_marginTop="3dp"
@ -194,6 +195,44 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBcc" /> app:layout_constraintTop_toBottomOf="@id/tvBcc" />
<TextView
android:id="@+id/tvRawHeaders"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:layout_marginStart="6dp"
android:layout_marginTop="3dp"
android:fontFamily="monospace"
android:freezesText="true"
android:maxHeight="120sp"
android:text="H1\nH2\nH3\nH4\nH5\nH6\nH7\nH8\nH9\n"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textIsSelectable="true"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorRawHeaders" />
<ProgressBar
android:id="@+id/pbRawHeaders"
style="@style/Base.Widget.AppCompat.ProgressBar"
android:layout_width="24dp"
android:layout_height="24dp"
android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="@id/tvRawHeaders"
app:layout_constraintEnd_toEndOf="@id/tvRawHeaders"
app:layout_constraintStart_toStartOf="@id/tvRawHeaders"
app:layout_constraintTop_toTopOf="@id/tvRawHeaders" />
<View
android:id="@+id/vSeparatorAttachments"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="3dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRawHeaders" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvAttachment" android:id="@+id/rvAttachment"
android:layout_width="0dp" android:layout_width="0dp"
@ -283,11 +322,10 @@
style="@style/Base.Widget.AppCompat.ProgressBar" style="@style/Base.Widget.AppCompat.ProgressBar"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginStart="12dp"
android:indeterminate="true" android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="@id/scroll" app:layout_constraintBottom_toBottomOf="@id/scroll"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="@id/scroll"
app:layout_constraintStart_toStartOf="@id/scroll"
app:layout_constraintTop_toTopOf="@id/scroll" /> app:layout_constraintTop_toTopOf="@id/scroll" />
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
@ -345,6 +383,12 @@
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids="vSeparatorAddress,tvReplyToTitle,tvReplyTo,tvCcTitle,tvCc,tvBccTitle,tvBcc" /> app:constraint_referenced_ids="vSeparatorAddress,tvReplyToTitle,tvReplyTo,tvCcTitle,tvCc,tvBccTitle,tvBcc" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpRawHeaders"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="vSeparatorRawHeaders,tvRawHeaders" />
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
android:id="@+id/grpAttachments" android:id="@+id/grpAttachments"
android:layout_width="0dp" android:layout_width="0dp"


+ 7
- 0
app/src/main/res/menu/menu_view.xml View File

@ -26,6 +26,13 @@
android:title="@string/title_reply_all" android:title="@string/title_reply_all"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_show_headers"
android:checkable="true"
android:icon="@drawable/baseline_visibility_24"
android:title="@string/title_show_headers"
app:showAsAction="never" />
<item <item
android:id="@+id/menu_show_html" android:id="@+id/menu_show_html"
android:icon="@drawable/baseline_visibility_24" android:icon="@drawable/baseline_visibility_24"


+ 1
- 0
app/src/main/res/values/strings.xml View File

@ -143,6 +143,7 @@
<string name="title_unseen">Mark unread</string> <string name="title_unseen">Mark unread</string>
<string name="title_forward">Forward</string> <string name="title_forward">Forward</string>
<string name="title_reply_all">Reply to all</string> <string name="title_reply_all">Reply to all</string>
<string name="title_show_headers">Show headers</string>
<string name="title_show_html">Show original</string> <string name="title_show_html">Show original</string>
<string name="title_trash">Trash</string> <string name="title_trash">Trash</string>


Loading…
Cancel
Save