Experiment: show infrastructure

This commit is contained in:
M66B
2021-11-09 18:44:54 +01:00
parent 817fa90bb0
commit cee85c78d5
12 changed files with 2759 additions and 4 deletions

View File

@@ -285,6 +285,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean collapse_quotes;
private boolean authentication;
private boolean authentication_indicator;
private boolean infra;
private boolean autoclose_unseen;
private boolean collapse_marked;
@@ -456,6 +457,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private TextView tvNoInternetBody;
private ImageButton ibDownloading;
private Group grpDownloading;
private ImageView ivInfrastructure;
private ImageButton ibTrashBottom;
private ImageButton ibArchiveBottom;
private ImageButton ibMoveBottom;
@@ -834,6 +836,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvNoInternetBody = vsBody.findViewById(R.id.tvNoInternetBody);
ibDownloading = vsBody.findViewById(R.id.ibDownloading);
grpDownloading = vsBody.findViewById(R.id.grpDownloading);
ivInfrastructure = vsBody.findViewById(R.id.ivInfrastructure);
ibTrashBottom = vsBody.findViewById(R.id.ibTrashBottom);
ibArchiveBottom = vsBody.findViewById(R.id.ibArchiveBottom);
ibMoveBottom = vsBody.findViewById(R.id.ibMoveBottom);
@@ -1575,6 +1578,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
pbBody.setVisibility(View.GONE);
grpAction.setVisibility(View.GONE);
clearActions();
ivInfrastructure.setVisibility(View.GONE);
ibTrashBottom.setVisibility(View.GONE);
ibArchiveBottom.setVisibility(View.GONE);
ibMoveBottom.setVisibility(View.GONE);
@@ -1828,6 +1832,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
grpAction.setVisibility(View.GONE);
clearActions();
ivInfrastructure.setVisibility(View.GONE);
ibTrashBottom.setVisibility(View.GONE);
ibArchiveBottom.setVisibility(View.GONE);
ibMoveBottom.setVisibility(View.GONE);
@@ -2866,6 +2871,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void bindExtras(TupleMessageEx message) {
int resid = 0;
if (infra && message.infrastructure != null) {
String resname = "infra_" + message.infrastructure;
resid = context.getResources()
.getIdentifier(resname, "drawable", context.getPackageName());
}
if (resid != 0)
ivInfrastructure.setImageResource(resid);
ivInfrastructure.setVisibility(resid != 0 ? View.VISIBLE : View.GONE);
ibTrashBottom.setVisibility(ibTrash.getVisibility());
ibArchiveBottom.setVisibility(ibArchive.getVisibility());
ibMoveBottom.setVisibility(ibMove.getVisibility());
@@ -5976,6 +5991,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.collapse_quotes = prefs.getBoolean("collapse_quotes", false);
this.authentication = prefs.getBoolean("authentication", true);
this.authentication_indicator = prefs.getBoolean("authentication_indicator", false);
this.infra = prefs.getBoolean("infra", false);
this.language_detection = prefs.getBoolean("language_detection", false);
this.autoclose_unseen = prefs.getBoolean("autoclose_unseen", false);
this.collapse_marked = prefs.getBoolean("collapse_marked", true);
@@ -6113,6 +6129,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
same = false;
log("headers changed", next.id);
}
if (!Objects.equals(prev.infrastructure, next.infrastructure)) {
same = false;
log("infrastructure changed", next.id);
}
if (!Objects.equals(prev.raw, next.raw)) {
same = false;
log("raw changed", next.id);

View File

@@ -2725,6 +2725,7 @@ class Core {
message.list_post = helper.getListPost();
message.unsubscribe = helper.getListUnsubscribe();
message.headers = helper.getHeaders();
message.infrastructure = helper.getInfrastructure();
message.subject = helper.getSubject();
message.size = parts.getBodySize();
message.total = helper.getSize();
@@ -3686,6 +3687,7 @@ class Core {
message.autocrypt = helper.getAutocrypt();
if (download_headers)
message.headers = helper.getHeaders();
message.infrastructure = helper.getInfrastructure();
message.subject = helper.getSubject();
message.size = parts.getBodySize();
message.total = helper.getSize();

View File

@@ -68,7 +68,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 215,
version = 216,
entities = {
EntityIdentity.class,
EntityAccount.class,
@@ -2192,6 +2192,12 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `auto_add` INTEGER");
}
}).addMigrations(new Migration(215, 216) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `infrastructure` TEXT");
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

View File

@@ -160,6 +160,7 @@ public class EntityMessage implements Serializable {
public String unsubscribe;
public String autocrypt;
public String headers;
public String infrastructure;
public Boolean raw;
public String subject;
public Long size;
@@ -546,6 +547,7 @@ public class EntityMessage implements Serializable {
Objects.equals(this.unsubscribe, other.unsubscribe) &&
Objects.equals(this.autocrypt, other.autocrypt) &&
Objects.equals(this.headers, other.headers) &&
Objects.equals(this.infrastructure, other.infrastructure) &&
Objects.equals(this.raw, other.raw) &&
Objects.equals(this.subject, other.subject) &&
Objects.equals(this.size, other.size) &&

View File

@@ -149,6 +149,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swAuthSasl;
private SwitchCompat swIdleDone;
private SwitchCompat swExactAlarms;
private SwitchCompat swInfra;
private SwitchCompat swDupMsgId;
private SwitchCompat swTestIab;
private TextView tvProcessors;
@@ -182,7 +183,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"query_threads", "wal", "checkpoints", "sqlite_cache",
"chunk_size", "use_modseq", "perform_expunge", "uid_expunge",
"auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "idle_done",
"exact_alarms", "dup_msgids", "test_iab"
"exact_alarms", "infra", "dup_msgids", "test_iab"
};
private final static String[] RESET_QUESTIONS = new String[]{
@@ -282,6 +283,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAuthSasl = view.findViewById(R.id.swAuthSasl);
swIdleDone = view.findViewById(R.id.swIdleDone);
swExactAlarms = view.findViewById(R.id.swExactAlarms);
swInfra = view.findViewById(R.id.swInfra);
swDupMsgId = view.findViewById(R.id.swDupMsgId);
swTestIab = view.findViewById(R.id.swTestIab);
tvProcessors = view.findViewById(R.id.tvProcessors);
@@ -894,6 +896,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swInfra.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("infra", checked).apply();
}
});
swDupMsgId.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -1363,6 +1372,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swAuthSasl.setChecked(prefs.getBoolean("auth_sasl", true));
swIdleDone.setChecked(prefs.getBoolean("idle_done", true));
swExactAlarms.setChecked(prefs.getBoolean("exact_alarms", true));
swInfra.setChecked(prefs.getBoolean("infra", false));
swDupMsgId.setChecked(prefs.getBoolean("dup_msgids", false));
swTestIab.setChecked(prefs.getBoolean("test_iab", false));

View File

@@ -1659,6 +1659,20 @@ public class MessageHelper {
return sb.toString();
}
String getInfrastructure() throws MessagingException {
ensureHeaders();
String awsses = imessage.getHeader("X-SES-Outgoing", null);
if (!TextUtils.isEmpty(awsses))
return "awsses";
String sendgrid = imessage.getHeader("X-SG-EID", null);
if (!TextUtils.isEmpty(sendgrid))
return "sendgrid";
return null;
}
String getHash() throws MessagingException {
try {
return Helper.sha1(getHeaders().getBytes());