mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-12 12:03:17 +02:00
Get, store and display append limit
This commit is contained in:
@@ -94,6 +94,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
||||
private TextView tvHost;
|
||||
private TextView tvLast;
|
||||
private TextView tvQuota;
|
||||
private TextView tvMaxSize;
|
||||
private TextView tvIdentity;
|
||||
private TextView tvDrafts;
|
||||
private TextView tvWarning;
|
||||
@@ -119,6 +120,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
||||
tvHost = itemView.findViewById(R.id.tvHost);
|
||||
tvLast = itemView.findViewById(R.id.tvLast);
|
||||
tvQuota = itemView.findViewById(R.id.tvQuota);
|
||||
tvMaxSize = itemView.findViewById(R.id.tvMaxSize);
|
||||
tvIdentity = itemView.findViewById(R.id.tvIdentity);
|
||||
tvDrafts = itemView.findViewById(R.id.tvDrafts);
|
||||
tvWarning = itemView.findViewById(R.id.tvWarning);
|
||||
@@ -196,6 +198,9 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
||||
(account.quota_limit == null ? "-" : Helper.humanReadableByteCount(account.quota_limit))));
|
||||
tvQuota.setVisibility(account.quota_usage != null || account.quota_limit != null ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvMaxSize.setText(account.max_size == null ? null : Helper.humanReadableByteCount(account.max_size));
|
||||
tvMaxSize.setVisibility(account.max_size != null && BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvIdentity.setVisibility(account.identities > 0 || !settings ? View.GONE : View.VISIBLE);
|
||||
tvDrafts.setVisibility(account.drafts || !settings ? View.GONE : View.VISIBLE);
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
|
||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 169,
|
||||
version = 170,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
@@ -1663,6 +1663,13 @@ public abstract class DB extends RoomDatabase {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `identity` ADD COLUMN `max_size` INTEGER");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(169, 170) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `account` ADD COLUMN `max_size` INTEGER");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,9 @@ public interface DaoAccount {
|
||||
@Query("UPDATE account SET partial_fetch = :partial_fetch WHERE id = :id")
|
||||
int setAccountPartialFetch(long id, boolean partial_fetch);
|
||||
|
||||
@Query("UPDATE account SET max_size = :max_size WHERE id = :id")
|
||||
int setAccountMaxSize(long id, Long max_size);
|
||||
|
||||
@Query("UPDATE account SET warning = :warning WHERE id = :id")
|
||||
int setAccountWarning(long id, String warning);
|
||||
|
||||
|
||||
@@ -634,9 +634,17 @@ public class EmailService implements AutoCloseable {
|
||||
return (SMTPTransport) iservice;
|
||||
}
|
||||
|
||||
Long getMaxSize() {
|
||||
// https://tools.ietf.org/html/rfc1870
|
||||
String size = getTransport().getExtensionParameter("SIZE");
|
||||
Long getMaxSize() throws MessagingException {
|
||||
String size;
|
||||
if (iservice instanceof SMTPTransport) {
|
||||
// https://tools.ietf.org/html/rfc1870
|
||||
size = getTransport().getExtensionParameter("SIZE");
|
||||
} else if (iservice instanceof IMAPStore) {
|
||||
// https://tools.ietf.org/html/rfc7889
|
||||
size = ((IMAPStore) iservice).getCapability("APPENDLIMIT");
|
||||
} else
|
||||
return null;
|
||||
|
||||
if (!TextUtils.isEmpty(size) && TextUtils.isDigitsOnly(size)) {
|
||||
long s = Long.parseLong(size);
|
||||
if (s != 0) // Not infinite
|
||||
@@ -644,7 +652,6 @@ public class EmailService implements AutoCloseable {
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
boolean hasCapability(String capability) throws MessagingException {
|
||||
|
||||
@@ -139,6 +139,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
||||
public String warning;
|
||||
public String error;
|
||||
public Long last_connected;
|
||||
public Long max_size;
|
||||
|
||||
boolean isGmail() {
|
||||
return "imap.gmail.com".equalsIgnoreCase(host);
|
||||
@@ -354,7 +355,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
||||
Objects.equals(this.state, other.state) &&
|
||||
Objects.equals(this.warning, other.warning) &&
|
||||
Objects.equals(this.error, other.error) &&
|
||||
Objects.equals(this.last_connected, other.last_connected));
|
||||
Objects.equals(this.last_connected, other.last_connected) &&
|
||||
Objects.equals(this.max_size, other.max_size));
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -984,6 +984,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
db.account().setAccountWarning(account.id, null);
|
||||
EntityLog.log(this, account.name + " connected");
|
||||
|
||||
db.account().setAccountMaxSize(account.id, iservice.getMaxSize());
|
||||
|
||||
// Listen for folder events
|
||||
iservice.getStore().addFolderListener(new FolderAdapter() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user