Show/store signature verified

pull/180/head
M66B 5 years ago
parent 913c9ad0d8
commit e9a23ab3e1

File diff suppressed because it is too large Load Diff

@ -215,6 +215,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private int colorUnread;
private int colorRead;
private int colorSubject;
private int colorEncrypt;
private int colorSeparator;
private boolean hasWebView;
@ -973,6 +974,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
EntityMessage.PRIORITIY_HIGH.equals(message.ui_importance)
? View.VISIBLE : View.GONE);
ivSigned.setVisibility(message.signed > 0 ? View.VISIBLE : View.GONE);
if (message.verified)
ivSigned.setColorFilter(colorEncrypt);
else
ivSigned.clearColorFilter();
ivEncrypted.setVisibility(message.encrypted > 0 ? View.VISIBLE : View.GONE);
if (show_recipients && recipients != null && recipients.length > 0)
tvFrom.setText(context.getString(R.string.title_from_to,
@ -4774,7 +4779,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.colorUnread = Helper.resolveColor(context, highlight_unread ? R.attr.colorUnreadHighlight : R.attr.colorUnread);
this.colorRead = Helper.resolveColor(context, R.attr.colorRead);
this.colorSubject = Helper.resolveColor(context, highlight_subject ? R.attr.colorUnreadHighlight : R.attr.colorRead);
this.colorEncrypt = Helper.resolveColor(context, R.attr.colorEncrypt);
this.colorSeparator = Helper.resolveColor(context, R.attr.colorSeparator);
this.hasWebView = Helper.hasWebView(context);
@ -4971,6 +4976,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
same = false;
log("encrypt changed", next.id);
}
if (!Objects.equals(prev.ui_encrypt, next.ui_encrypt)) {
same = false;
log("ui_encrypt changed", next.id);
}
if (!Objects.equals(prev.verified, next.verified)) {
same = false;
log("verified changed", next.id);
}
if (!Objects.equals(prev.preview, next.preview)) {
same = false;
log("preview changed", next.id);

@ -60,7 +60,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 161,
version = 162,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1600,6 +1600,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("UPDATE identity SET encrypt = " + ("pgp".equals(encrypt_method) ? 0 : 1));
prefs.edit().remove("default_encrypt_method").apply();
}
})
.addMigrations(new Migration(161, 162) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `verified` INTEGER NOT NULL DEFAULT 0");
}
});
}

@ -667,6 +667,9 @@ public interface DaoMessage {
@Query("UPDATE message SET ui_encrypt = :ui_encrypt WHERE id = :id")
int setMessageUiEncrypt(long id, Integer ui_encrypt);
@Query("UPDATE message SET verified = :verified WHERE id = :id")
int setMessageVerified(long id, boolean verified);
@Query("UPDATE message SET last_attempt = :last_attempt WHERE id = :id")
int setMessageLastAttempt(long id, long last_attempt);

@ -143,6 +143,8 @@ public class EntityMessage implements Serializable {
public Boolean plain_only = null;
public Integer encrypt = null;
public Integer ui_encrypt = null;
@NonNull
public Boolean verified = false;
public String preview;
@NonNull
public Boolean signature = true;
@ -352,6 +354,7 @@ public class EntityMessage implements Serializable {
Objects.equals(this.plain_only, other.plain_only) &&
Objects.equals(this.encrypt, other.encrypt) &&
Objects.equals(this.ui_encrypt, other.ui_encrypt) &&
this.verified == other.verified &&
Objects.equals(this.preview, other.preview) &&
this.signature.equals(other.signature) &&
Objects.equals(this.sent, other.sent) &&

@ -5422,6 +5422,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
? R.string.title_signature_unconfirmed
: R.string.title_signature_valid);
args.putString("sigresult", text);
if (sresult == RESULT_VALID_KEY_CONFIRMED)
db.message().setMessageVerified(message.id, true);
} else if (sresult == RESULT_KEY_MISSING)
args.putString("sigresult", context.getString(R.string.title_signature_key_missing));
else {
@ -5695,6 +5697,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
args.putBoolean("valid", valid);
if (known)
db.message().setMessageVerified(message.id, true);
} catch (Throwable ex) {
Log.w(ex);
args.putString("reason", ex.getMessage());
@ -5928,6 +5932,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
}
db.message().setMessageVerified(message.id, true);
return null;
}

Loading…
Cancel
Save