mirror of https://github.com/M66B/FairEmail.git
Get, store and display append limit
This commit is contained in:
parent
960f970771
commit
d12e7a1d92
File diff suppressed because it is too large
Load Diff
|
@ -1529,6 +1529,30 @@ public class IMAPStore extends Store
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized String getCapability(String capability)
|
||||
throws MessagingException {
|
||||
IMAPProtocol p = null;
|
||||
try {
|
||||
p = getStoreProtocol();
|
||||
Map<String, String> caps = p.getCapabilities();
|
||||
if (caps != null)
|
||||
for (String cap : caps.values()) {
|
||||
int eq = cap.indexOf('=');
|
||||
if (eq > 0) {
|
||||
String key = cap.substring(0, eq);
|
||||
String value = cap.substring(eq + 1);
|
||||
if (capability.equals(key))
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (ProtocolException pex) {
|
||||
throw new MessagingException(pex.getMessage(), pex);
|
||||
} finally {
|
||||
releaseStoreProtocol(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user name to be used with the PROXYAUTH command.
|
||||
* The PROXYAUTH user name can also be set using the
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -168,10 +168,23 @@
|
|||
android:singleLine="true"
|
||||
android:text="123/456 MB"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvMaxSize"
|
||||
app:layout_constraintStart_toEndOf="@+id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvLast" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvMaxSize"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="start"
|
||||
android:singleLine="true"
|
||||
android:text="25 MB"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvLast" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvIdentity"
|
||||
android:layout_width="0dp"
|
||||
|
|
Loading…
Reference in New Issue