Automatically remember sign key

pull/159/head
M66B 5 years ago
parent 463c59650c
commit d4f6653047

File diff suppressed because it is too large Load Diff

@ -56,7 +56,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 94,
version = 95,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -931,6 +931,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `message` ADD COLUMN `encrypt` INTEGER");
}
})
.addMigrations(new Migration(94, 95) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `sign_key` INTEGER");
}
})
.build();
}

@ -84,8 +84,8 @@ public interface DaoIdentity {
@Query("UPDATE identity SET last_connected = :last_connected WHERE id = :id")
int setIdentityConnected(long id, long last_connected);
@Query("UPDATE identity SET password = :password WHERE id = :id")
int setIdentityPassword(long id, String password);
@Query("UPDATE identity SET sign_key = :sign_key WHERE id = :id")
int setIdentitySignKey(long id, long sign_key);
@Query("UPDATE identity SET error = :error WHERE id = :id")
int setIdentityError(long id, String error);

@ -92,6 +92,7 @@ public class EntityIdentity {
@NonNull
public Boolean store_sent = false;
public Long sent_folder = null; // obsolete
public Long sign_key = null; // OpenPGP
public Boolean tbd;
public String state;
public String error;

@ -1450,11 +1450,21 @@ public class FragmentCompose extends FragmentBase {
intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
return intent;
} else if (OpenPgpApi.ACTION_GET_KEY.equals(data.getAction())) {
// Get sign key
Intent intent = new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
return intent;
if (identity != null && identity.sign_key != null) {
// Encrypt message
Intent intent = new Intent(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT);
intent.putExtra(OpenPgpApi.EXTRA_KEY_IDS, pgpKeyIds);
intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, identity.sign_key);
intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
return intent;
} else {
// Get sign key
return new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
}
} else if (OpenPgpApi.ACTION_GET_SIGN_KEY_ID.equals(data.getAction())) {
pgpSignKeyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, -1);
if (identity != null)
db.identity().setIdentitySignKey(identity.id, pgpSignKeyId);
// Encrypt message
Intent intent = new Intent(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT);

@ -748,6 +748,7 @@ public class FragmentIdentity extends FragmentBase {
identity.read_receipt = read_receipt;
identity.store_sent = store_sent;
identity.sent_folder = null;
identity.sign_key = null;
identity.error = null;
identity.last_connected = last_connected;

Loading…
Cancel
Save