Added account option to use date header as received time

pull/168/head
M66B 5 years ago
parent 7ba8068fb3
commit bdf47fe67f

File diff suppressed because it is too large Load Diff

@ -2046,6 +2046,7 @@ class Core {
}
if (message == null) {
Long sent = helper.getSent();
String authentication = helper.getAuthentication();
MessageHelper.MessageParts parts = helper.getMessageParts(context);
@ -2080,8 +2081,8 @@ class Core {
message.size = parts.getBodySize();
message.total = helper.getSize();
message.content = false;
message.received = helper.getReceived();
message.sent = helper.getSent();
message.received = (account.use_date ? (sent == null ? 0 : sent) : helper.getReceived());
message.sent = sent;
message.seen = seen;
message.answered = answered;
message.flagged = flagged;

@ -56,7 +56,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 115,
version = 116,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1117,6 +1117,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("DROP TABLE revision");
}
})
.addMigrations(new Migration(115, 116) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `use_date` INTEGER NOT NULL DEFAULT 0");
}
})
.build();
}

@ -104,6 +104,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
public Boolean partial_fetch = true;
@NonNull
public Boolean ignore_size = false;
@NonNull
public Boolean use_date = false;
public String prefix; // namespace, obsolete
public Long created;

@ -102,6 +102,7 @@ public class FragmentAccount extends FragmentBase {
private EditText etInterval;
private CheckBox cbPartialFetch;
private CheckBox cbIgnoreSize;
private CheckBox cbUseDate;
private Button btnCheck;
private ContentLoadingProgressBar pbCheck;
@ -204,6 +205,7 @@ public class FragmentAccount extends FragmentBase {
etInterval = view.findViewById(R.id.etInterval);
cbPartialFetch = view.findViewById(R.id.cbPartialFetch);
cbIgnoreSize = view.findViewById(R.id.cbIgnoreSize);
cbUseDate = view.findViewById(R.id.cbUseDate);
btnCheck = view.findViewById(R.id.btnCheck);
pbCheck = view.findViewById(R.id.pbCheck);
@ -708,6 +710,7 @@ public class FragmentAccount extends FragmentBase {
args.putString("interval", etInterval.getText().toString());
args.putBoolean("partial_fetch", cbPartialFetch.isChecked());
args.putBoolean("ignore_size", cbIgnoreSize.isChecked());
args.putBoolean("use_date", cbUseDate.isChecked());
args.putSerializable("drafts", drafts);
args.putSerializable("sent", sent);
@ -765,6 +768,7 @@ public class FragmentAccount extends FragmentBase {
String interval = args.getString("interval");
boolean partial_fetch = args.getBoolean("partial_fetch");
boolean ignore_size = args.getBoolean("ignore_size");
boolean use_date = args.getBoolean("use_date");
EntityFolder drafts = (EntityFolder) args.getSerializable("drafts");
EntityFolder sent = (EntityFolder) args.getSerializable("sent");
@ -848,6 +852,8 @@ public class FragmentAccount extends FragmentBase {
return true;
if (!Objects.equals(account.ignore_size, ignore_size))
return true;
if (!Objects.equals(account.use_date, use_date))
return true;
EntityFolder edrafts = db.folder().getFolderByType(account.id, EntityFolder.DRAFTS);
if (!Objects.equals(edrafts == null ? null : edrafts.id, drafts == null ? null : drafts.id))
@ -896,7 +902,8 @@ public class FragmentAccount extends FragmentBase {
account.notify != notify ||
!account.poll_interval.equals(Integer.parseInt(interval)) ||
account.partial_fetch != partial_fetch ||
account.ignore_size != ignore_size);
account.ignore_size != ignore_size ||
account.use_date != use_date);
Log.i("Account check=" + check + " reload=" + reload);
Long last_connected = null;
@ -968,6 +975,7 @@ public class FragmentAccount extends FragmentBase {
account.poll_interval = Integer.parseInt(interval);
account.partial_fetch = partial_fetch;
account.ignore_size = ignore_size;
account.use_date = use_date;
if (!update)
account.created = now;
@ -1244,6 +1252,7 @@ public class FragmentAccount extends FragmentBase {
etInterval.setText(account == null ? "" : Long.toString(account.poll_interval));
cbPartialFetch.setChecked(account == null ? true : account.partial_fetch);
cbIgnoreSize.setChecked(account == null ? true : account.ignore_size);
cbUseDate.setChecked(account == null ? false : account.use_date);
auth = (account == null ? MailService.AUTH_TYPE_PASSWORD : account.auth_type);

@ -493,6 +493,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPartialFetchRemark" />
<CheckBox
android:id="@+id/cbUseDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_use_date"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbIgnoreSize" />
<!-- check -->
<Button
@ -503,7 +512,7 @@
android:tag="disable"
android:text="@string/title_check"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbIgnoreSize" />
app:layout_constraintTop_toBottomOf="@id/cbUseDate" />
<eu.faircode.email.ContentLoadingProgressBar
android:id="@+id/pbCheck"
@ -870,7 +879,7 @@
cbBrowse,tvBrowseHint,
cbAutoSeen,
tvInterval,etInterval,tvIntervalRemark,
cbPartialFetch,tvPartialFetchRemark,cbIgnoreSize" />
cbPartialFetch,tvPartialFetchRemark,cbIgnoreSize,cbUseDate" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpFolders"

@ -452,6 +452,7 @@
<string name="title_keep_alive_interval">Keep-alive/poll interval (minutes)</string>
<string name="title_partial_fetch" translatable="false">Partial fetch</string>
<string name="title_ignore_size" translatable="false">Ignore bodystructure size</string>
<string name="title_use_date">Use date header sent time instead of server received time</string>
<string name="title_related_identity">Add related identity</string>
<string name="title_check">Check</string>
<string name="title_no_name">Name missing</string>

Loading…
Cancel
Save