Experiment: show infrastructure

pull/194/merge
M66B 4 years ago
parent 817fa90bb0
commit cee85c78d5

File diff suppressed because it is too large Load Diff

@ -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);

@ -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();

@ -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) {

@ -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) &&

@ -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));

@ -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());

@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="40dp"
android:height="40dp"
android:viewportWidth="40"
android:viewportHeight="40">
<path
android:pathData="M0,0h40v40h-40z"
android:strokeWidth="1"
android:fillType="evenOdd"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:startY="40"
android:startX="0"
android:endY="0"
android:endX="40"
android:type="linear">
<item android:offset="0" android:color="#FFBD0816"/>
<item android:offset="1" android:color="#FFFF5252"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="M27.882,30.4264C27.882,29.6125 27.268,28.9975 26.453,28.9975C25.639,28.9975 25.025,29.6125 25.025,30.4264C25.025,31.2403 25.639,31.8542 26.453,31.8542C27.268,31.8542 27.882,31.2403 27.882,30.4264L27.882,30.4264ZM20,30.1404C19.173,30.1404 18.5,30.7813 18.5,31.5693C18.5,32.3582 19.173,33.0001 20,33.0001C20.827,33.0001 21.5,32.3582 21.5,31.5693C21.5,30.7813 20.827,30.1404 20,30.1404L20,30.1404ZM13.485,28.9975C12.67,28.9975 12.056,29.6125 12.056,30.4264C12.056,31.2403 12.67,31.8542 13.485,31.8542C14.299,31.8542 14.913,31.2403 14.913,30.4264C14.913,29.6125 14.299,28.9975 13.485,28.9975L13.485,28.9975ZM13.959,21.0614L26.041,21.0614L21.785,17.8907L20.317,19.0996C20.225,19.1756 20.111,19.2136 19.999,19.2136C19.887,19.2136 19.774,19.1756 19.682,19.0996L18.214,17.8917L13.959,21.0614ZM12.95,13.5582L12.95,20.5654L17.419,17.2368L12.95,13.5582ZM26.155,12.9993L13.844,12.9993L19.999,18.0657L26.155,12.9993ZM27.05,20.5654L27.05,13.5582L22.58,17.2368L27.05,20.5654ZM28.882,30.4264C28.882,31.7882 27.816,32.8541 26.453,32.8541C25.091,32.8541 24.025,31.7882 24.025,30.4264C24.025,29.2365 24.839,28.2726 25.953,28.0476L25.953,26.0609L20.5,26.0609L20.5,29.1905C21.64,29.4155 22.5,30.3964 22.5,31.5693C22.5,32.9091 21.379,34 20,34C18.621,34 17.5,32.9091 17.5,31.5693C17.5,30.3964 18.361,29.4155 19.5,29.1905L19.5,26.0609L13.985,26.0609L13.985,28.0476C15.099,28.2726 15.913,29.2365 15.913,30.4264C15.913,31.7882 14.847,32.8541 13.485,32.8541C12.122,32.8541 11.056,31.7882 11.056,30.4264C11.056,29.2365 11.87,28.2726 12.985,28.0476L12.985,25.5609C12.985,25.2839 13.208,25.061 13.485,25.061L19.5,25.061L19.5,22.0613L12.45,22.0613C12.174,22.0613 11.95,21.8373 11.95,21.5613L11.95,12.4993C11.95,12.2233 12.174,11.9994 12.45,11.9994L27.55,11.9994C27.826,11.9994 28.05,12.2233 28.05,12.4993L28.05,21.5613C28.05,21.8373 27.826,22.0613 27.55,22.0613L20.5,22.0613L20.5,25.061L26.453,25.061C26.73,25.061 26.953,25.2839 26.953,25.5609L26.953,28.0476C28.068,28.2726 28.882,29.2365 28.882,30.4264L28.882,30.4264ZM34,19.9985C34,22.7362 33.034,25.8299 31.417,28.2736L30.583,27.7217C32.074,25.4689 33,22.5102 33,19.9985C33,12.8313 27.169,6.9999 20.001,6.9999C12.832,6.9999 7,12.8313 7,19.9985C7,22.5042 7.926,25.4639 9.417,27.7227L8.583,28.2736C6.966,25.8239 6,22.7302 6,19.9985C6,12.2803 12.28,6 19.999,6C27.719,6 34,12.2803 34,19.9985L34,19.9985Z"
android:strokeWidth="1"
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
</vector>

@ -0,0 +1,33 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="64dp"
android:height="64dp"
android:viewportWidth="64"
android:viewportHeight="64">
<path
android:pathData="M0,21.25h21.374v21.374H0z"
android:fillColor="#fff"/>
<path
android:pathData="M0,21.25h21.374v21.374H0z"
android:fillColor="#99e1f4"/>
<path
android:pathData="M21.374,42.626h21.25v21.25h-21.25z"
android:fillColor="#fff"/>
<path
android:pathData="M21.374,42.626h21.25v21.25h-21.25z"
android:fillColor="#99e1f4"/>
<path
android:pathData="M0,63.877h21.374L21.374,64L0,64zM0,42.627h21.374v21.25L0,63.877z"
android:fillColor="#1a82e2"/>
<path
android:pathData="M21.374,0h21.25v21.25h-21.25zM42.626,21.374L64,21.374v21.25L42.626,42.624z"
android:fillColor="#00b3e3"/>
<path
android:pathData="M21.374,42.626h21.25V21.25h-21.25z"
android:fillColor="#009dd9"/>
<path
android:pathData="M42.626,0H64v21.25H42.626z"
android:fillColor="#1a82e2"/>
<path
android:pathData="M42.626,21.25H64v0.123H42.626z"
android:fillColor="#1a82e2"/>
</vector>

@ -888,6 +888,17 @@
app:layout_constraintTop_toBottomOf="@id/swIdleDone"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swInfra"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_infra"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swExactAlarms"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDupMsgId"
android:layout_width="0dp"
@ -896,7 +907,7 @@
android:text="@string/title_advanced_dup_msgid"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swExactAlarms"
app:layout_constraintTop_toBottomOf="@id/swInfra"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -114,6 +114,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBody" />
<ImageView
android:id="@+id/ivInfrastructure"
android:layout_width="36dp"
android:layout_height="36dp"
android:padding="6dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/wvBody"
app:srcCompat="@drawable/infra_awsses" />
<ImageButton
android:id="@+id/ibTrashBottom"
android:layout_width="36dp"
@ -123,7 +132,7 @@
android:contentDescription="@string/title_trash"
android:padding="6dp"
android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toEndOf="@id/ivInfrastructure"
app:layout_constraintTop_toBottomOf="@id/wvBody"
app:srcCompat="@drawable/twotone_delete_24"
app:tint="?attr/colorAccent" />

@ -678,6 +678,7 @@
<string name="title_advanced_auth_sasl" translatable="false">SASL</string>
<string name="title_advanced_idle_done" translatable="false">IDLE/DONE</string>
<string name="title_advanced_exact_alarms" translatable="false">Use exact timers</string>
<string name="title_advanced_infra" translatable="false">Show infrastructure</string>
<string name="title_advanced_dup_msgid" translatable="false">Duplicates by message ID</string>
<string name="title_advanced_test_iab" translatable="false">Test IAB</string>
<string name="title_advanced_processors" translatable="false">Processors: %1$d</string>

Loading…
Cancel
Save