mirror of https://github.com/M66B/FairEmail.git
Added settings to limit number of POP3 messages
This commit is contained in:
parent
7708165e8e
commit
ad0d326cde
File diff suppressed because it is too large
Load Diff
|
@ -1462,11 +1462,15 @@ class Core {
|
|||
List<String> existing = db.message().getMsgIds(folder.id);
|
||||
Log.i(folder.name + " POP existing=" + existing.size());
|
||||
|
||||
int count = 0;
|
||||
for (Message imessage : imessages)
|
||||
try {
|
||||
if (!state.isRunning())
|
||||
return;
|
||||
|
||||
if (account.max_messages != null && ++count > account.max_messages)
|
||||
break;
|
||||
|
||||
MessageHelper helper = new MessageHelper((MimeMessage) imessage);
|
||||
|
||||
String msgid;
|
||||
|
@ -1609,7 +1613,6 @@ class Core {
|
|||
|
||||
if (message.received > account.created)
|
||||
updateContactInfo(context, folder, message);
|
||||
|
||||
} catch (Throwable ex) {
|
||||
db.folder().setFolderError(folder.id, Log.formatThrowable(ex));
|
||||
} finally {
|
||||
|
|
|
@ -60,7 +60,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
|
|||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 145,
|
||||
version = 146,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
|
@ -1394,6 +1394,13 @@ public abstract class DB extends RoomDatabase {
|
|||
db.execSQL("ALTER TABLE `folder` ADD COLUMN `poll_factor` INTEGER NOT NULL DEFAULT 1");
|
||||
db.execSQL("ALTER TABLE `folder` ADD COLUMN `poll_count` INTEGER NOT NULL DEFAULT 0");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(145, 146) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `account` ADD COLUMN `max_messages` INTEGER");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
|||
public Boolean leave_on_server = true;
|
||||
@NonNull
|
||||
public Boolean leave_on_device = false;
|
||||
public Integer max_messages; // POP3
|
||||
@NonNull
|
||||
public Boolean auto_seen = true;
|
||||
public Character separator;
|
||||
|
|
|
@ -82,6 +82,7 @@ public class FragmentPop extends FragmentBase {
|
|||
private CheckBox cbPrimary;
|
||||
private CheckBox cbLeaveServer;
|
||||
private CheckBox cbLeaveDevice;
|
||||
private EditText etMax;
|
||||
private EditText etInterval;
|
||||
|
||||
private Button btnSave;
|
||||
|
@ -135,6 +136,7 @@ public class FragmentPop extends FragmentBase {
|
|||
tvNotifyPro = view.findViewById(R.id.tvNotifyPro);
|
||||
cbLeaveServer = view.findViewById(R.id.cbLeaveServer);
|
||||
cbLeaveDevice = view.findViewById(R.id.cbLeaveDevice);
|
||||
etMax = view.findViewById(R.id.etMax);
|
||||
etInterval = view.findViewById(R.id.etInterval);
|
||||
|
||||
btnSave = view.findViewById(R.id.btnSave);
|
||||
|
@ -240,6 +242,7 @@ public class FragmentPop extends FragmentBase {
|
|||
args.putBoolean("notify", cbNotify.isChecked());
|
||||
args.putBoolean("leave_server", cbLeaveServer.isChecked());
|
||||
args.putBoolean("leave_device", cbLeaveDevice.isChecked());
|
||||
args.putString("max", etMax.getText().toString());
|
||||
args.putString("interval", etInterval.getText().toString());
|
||||
|
||||
new SimpleTask<Boolean>() {
|
||||
|
@ -279,6 +282,7 @@ public class FragmentPop extends FragmentBase {
|
|||
boolean notify = args.getBoolean("notify");
|
||||
boolean leave_server = args.getBoolean("leave_server");
|
||||
boolean leave_device = args.getBoolean("leave_device");
|
||||
String max = args.getString("max");
|
||||
String interval = args.getString("interval");
|
||||
|
||||
boolean pro = ActivityBilling.isPro(context);
|
||||
|
@ -369,6 +373,7 @@ public class FragmentPop extends FragmentBase {
|
|||
account.notify = notify;
|
||||
account.leave_on_server = leave_server;
|
||||
account.leave_on_device = leave_device;
|
||||
account.max_messages = (TextUtils.isEmpty(max) ? null : Integer.parseInt(max));
|
||||
account.poll_interval = Integer.parseInt(interval);
|
||||
|
||||
if (!update)
|
||||
|
@ -528,6 +533,7 @@ public class FragmentPop extends FragmentBase {
|
|||
cbPrimary.setChecked(account == null ? false : account.primary);
|
||||
cbLeaveServer.setChecked(account == null ? true : account.leave_on_server);
|
||||
cbLeaveDevice.setChecked(account == null ? false : account.leave_on_device);
|
||||
etMax.setText(account == null || account.max_messages == null ? null : Integer.toString(account.max_messages));
|
||||
etInterval.setText(account == null ? "" : Long.toString(account.poll_interval));
|
||||
|
||||
new SimpleTask<EntityAccount>() {
|
||||
|
|
|
@ -40,6 +40,9 @@ public class TupleAccountState extends EntityAccount {
|
|||
Objects.equals(this.realm, other.realm) &&
|
||||
Objects.equals(this.fingerprint, other.fingerprint) &&
|
||||
this.notify.equals(other.notify) &&
|
||||
this.leave_on_server == other.leave_on_server &&
|
||||
this.leave_on_device == other.leave_on_device &&
|
||||
Objects.equals(this.max_messages, other.max_messages) &&
|
||||
this.poll_interval.equals(other.poll_interval) &&
|
||||
this.partial_fetch.equals(other.partial_fetch) &&
|
||||
this.ignore_size.equals(other.ignore_size) &&
|
||||
|
|
|
@ -317,6 +317,27 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbLeaveServer" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvMax"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:labelFor="@+id/etMax"
|
||||
android:text="@string/title_max_messages"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbLeaveDevice" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etMax"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
android:maxLength="9"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvMax" />
|
||||
|
||||
<!-- keep alive -->
|
||||
|
||||
<TextView
|
||||
|
@ -327,7 +348,7 @@
|
|||
android:text="@string/title_keep_alive_interval"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbLeaveDevice" />
|
||||
app:layout_constraintTop_toBottomOf="@id/etMax" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etInterval"
|
||||
|
|
|
@ -532,6 +532,7 @@
|
|||
<string name="title_primary_identity">Primary (default identity)</string>
|
||||
<string name="title_leave_on_server">Leave messages on server</string>
|
||||
<string name="title_leave_on_device">Leave messages on device</string>
|
||||
<string name="title_max_messages">Maximum number of messages to download (blank for all)</string>
|
||||
<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>
|
||||
|
|
Loading…
Reference in New Issue