mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-24 08:44:26 +00:00
Show account capabilities
This commit is contained in:
parent
24bc078cf8
commit
b1cc2e50b5
9 changed files with 2576 additions and 13 deletions
2508
app/schemas/eu.faircode.email.DB/206.json
Normal file
2508
app/schemas/eu.faircode.email.DB/206.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -444,6 +444,10 @@ public class POP3Store extends Store {
|
|||
return (t instanceof Exception) || (t instanceof LinkageError);
|
||||
}
|
||||
|
||||
public synchronized Map<String, String> getCapabilities() {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
synchronized void closePort(POP3Folder owner) {
|
||||
if (portOwner == owner) {
|
||||
port = null;
|
||||
|
|
|
@ -19,6 +19,8 @@ package eu.faircode.email;
|
|||
Copyright 2018-2021 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
|
@ -32,6 +34,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -64,8 +67,6 @@ import java.text.NumberFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
|
||||
|
||||
public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHolder> {
|
||||
private Fragment parentFragment;
|
||||
private boolean settings;
|
||||
|
@ -103,6 +104,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
private TextView tvQuota;
|
||||
private TextView tvMaxSize;
|
||||
private TextView tvId;
|
||||
private TextView tvCapabilities;
|
||||
private TextView tvIdentity;
|
||||
private TextView tvDrafts;
|
||||
private TextView tvSent;
|
||||
|
@ -134,6 +136,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
tvQuota = itemView.findViewById(R.id.tvQuota);
|
||||
tvMaxSize = itemView.findViewById(R.id.tvMaxSize);
|
||||
tvId = itemView.findViewById(R.id.tvId);
|
||||
tvCapabilities = itemView.findViewById(R.id.tvCapabilities);
|
||||
tvIdentity = itemView.findViewById(R.id.tvIdentity);
|
||||
tvDrafts = itemView.findViewById(R.id.tvDrafts);
|
||||
tvSent = itemView.findViewById(R.id.tvSent);
|
||||
|
@ -236,7 +239,11 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
tvQuota.setVisibility(View.VISIBLE);
|
||||
|
||||
tvId.setText(account.id + "/" + account.uuid);
|
||||
tvId.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
||||
tvId.setVisibility(settings && BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvCapabilities.setText(account.capabilities);
|
||||
tvCapabilities.setVisibility(
|
||||
settings && !TextUtils.isEmpty(account.capabilities) ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvIdentity.setVisibility(account.identities > 0 || !settings ? View.GONE : View.VISIBLE);
|
||||
tvDrafts.setVisibility(account.drafts != null || !settings ? View.GONE : View.VISIBLE);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package eu.faircode.email;
|
||||
|
||||
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
|
@ -42,8 +44,6 @@ import javax.mail.internet.InternetAddress;
|
|||
import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
|
||||
import io.requery.android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
|
||||
|
||||
/*
|
||||
This file is part of FairEmail.
|
||||
|
||||
|
@ -66,7 +66,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
|
|||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 205,
|
||||
version = 206,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
|
@ -2085,6 +2085,12 @@ public abstract class DB extends RoomDatabase {
|
|||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `answer` ADD COLUMN `external` INTEGER NOT NULL DEFAULT 0");
|
||||
}
|
||||
}).addMigrations(new Migration(205, 206) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `account` ADD COLUMN `capabilities` TEXT");
|
||||
}
|
||||
}).addMigrations(new Migration(998, 999) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
|
|
|
@ -189,10 +189,14 @@ public interface DaoAccount {
|
|||
int setAccountMaxSize(long id, Long max_size);
|
||||
|
||||
@Query("UPDATE account" +
|
||||
" SET capability_idle = :idle, capability_utf8 = :utf8" +
|
||||
" SET capabilities = :capabilities" +
|
||||
", capability_idle = :idle" +
|
||||
", capability_utf8 = :utf8" +
|
||||
" WHERE id = :id" +
|
||||
" AND NOT (capability_idle IS :idle AND capability_utf8 IS :utf8)")
|
||||
int setAccountCapabilities(long id, Boolean idle, Boolean utf8);
|
||||
" AND NOT (capabilities IS :capabilities" +
|
||||
" AND capability_idle IS :idle" +
|
||||
" AND capability_utf8 IS :utf8)")
|
||||
int setAccountCapabilities(long id, String capabilities, Boolean idle, Boolean utf8);
|
||||
|
||||
@Query("UPDATE account SET warning = :warning WHERE id = :id AND NOT (warning IS :warning)")
|
||||
int setAccountWarning(long id, String warning);
|
||||
|
|
|
@ -35,6 +35,7 @@ import androidx.preference.PreferenceManager;
|
|||
import com.sun.mail.gimap.GmailSSLProvider;
|
||||
import com.sun.mail.imap.IMAPFolder;
|
||||
import com.sun.mail.imap.IMAPStore;
|
||||
import com.sun.mail.pop3.POP3Store;
|
||||
import com.sun.mail.smtp.SMTPTransport;
|
||||
import com.sun.mail.util.MailConnectException;
|
||||
import com.sun.mail.util.SocketConnectException;
|
||||
|
@ -721,6 +722,24 @@ public class EmailService implements AutoCloseable {
|
|||
return null;
|
||||
}
|
||||
|
||||
List<String> getCapabilities() throws MessagingException {
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
Store store = getStore();
|
||||
Map<String, String> capabilities;
|
||||
if (store instanceof IMAPStore)
|
||||
capabilities = ((IMAPStore) getStore()).getCapabilities();
|
||||
else if (store instanceof POP3Store)
|
||||
capabilities = ((POP3Store) getStore()).getCapabilities();
|
||||
else
|
||||
capabilities = null;
|
||||
|
||||
if (capabilities != null)
|
||||
result.addAll(capabilities.keySet());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
boolean hasCapability(String capability) throws MessagingException {
|
||||
Store store = getStore();
|
||||
if (store instanceof IMAPStore)
|
||||
|
|
|
@ -150,6 +150,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
|||
public Long last_connected;
|
||||
public Long backoff_until;
|
||||
public Long max_size;
|
||||
public String capabilities;
|
||||
public Boolean capability_idle;
|
||||
public Boolean capability_utf8;
|
||||
|
||||
|
@ -398,6 +399,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
|||
Objects.equals(this.last_connected, other.last_connected) &&
|
||||
Objects.equals(this.backoff_until, other.backoff_until) &&
|
||||
Objects.equals(this.max_size, other.max_size) &&
|
||||
Objects.equals(this.capabilities, other.capabilities) &&
|
||||
Objects.equals(this.capability_idle, other.capability_idle) &&
|
||||
Objects.equals(this.capability_utf8, other.capability_utf8));
|
||||
} else
|
||||
|
|
|
@ -1341,7 +1341,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
final boolean capNotify = iservice.hasCapability("NOTIFY");
|
||||
|
||||
db.account().setAccountState(account.id, "connected");
|
||||
db.account().setAccountCapabilities(account.id, capIdle, capUtf8);
|
||||
db.account().setAccountCapabilities(account.id,
|
||||
TextUtils.join(" ", iservice.getCapabilities()), capIdle, capUtf8);
|
||||
db.account().setAccountError(account.id, null);
|
||||
db.account().setAccountWarning(account.id, null);
|
||||
|
||||
|
|
|
@ -231,14 +231,26 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="id"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvQuota" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvCapabilities"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:text="capabilities"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textSize="10sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/ivState"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvId" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvIdentity"
|
||||
android:layout_width="0dp"
|
||||
|
@ -250,7 +262,7 @@
|
|||
android:textColor="?attr/colorWarning"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvId" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvCapabilities" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvDrafts"
|
||||
|
|
Loading…
Reference in a new issue