Added account UUID

pull/201/head
M66B 3 years ago
parent 134071850a
commit 9fbb996e69

File diff suppressed because it is too large Load Diff

@ -102,6 +102,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private TextView tvBackoff;
private TextView tvQuota;
private TextView tvMaxSize;
private TextView tvId;
private TextView tvIdentity;
private TextView tvDrafts;
private TextView tvSent;
@ -132,6 +133,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
tvBackoff = itemView.findViewById(R.id.tvBackoff);
tvQuota = itemView.findViewById(R.id.tvQuota);
tvMaxSize = itemView.findViewById(R.id.tvMaxSize);
tvId = itemView.findViewById(R.id.tvId);
tvIdentity = itemView.findViewById(R.id.tvIdentity);
tvDrafts = itemView.findViewById(R.id.tvDrafts);
tvSent = itemView.findViewById(R.id.tvSent);
@ -233,6 +235,9 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
if (tvMaxSize.getVisibility() == View.VISIBLE)
tvQuota.setVisibility(View.VISIBLE);
tvId.setText(account.id + "/" + account.uuid);
tvId.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
tvIdentity.setVisibility(account.identities > 0 || !settings ? View.GONE : View.VISIBLE);
tvDrafts.setVisibility(account.drafts != null || !settings ? View.GONE : View.VISIBLE);
tvSent.setVisibility(account.protocol != EntityAccount.TYPE_IMAP ||

@ -33,6 +33,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import javax.mail.Address;
@ -65,7 +66,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 203,
version = 204,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2058,6 +2059,26 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `last_sync_count` INTEGER");
}
}).addMigrations(new Migration(203, 204) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `uuid` TEXT NOT NULL DEFAULT ''");
Cursor cursor = null;
try {
cursor = db.query("SELECT id FROM account");
while (cursor != null && cursor.moveToNext()) {
long id = cursor.getLong(0);
String uuid = UUID.randomUUID().toString();
Log.i("MMM account=" + id + " uuid=" + uuid);
db.execSQL("UPDATE account SET uuid = ? WHERE id = ?",
new Object[]{uuid, id});
}
} catch (Throwable ex) {
if (cursor != null)
cursor.close();
}
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

@ -42,6 +42,7 @@ import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;
import java.util.Objects;
import java.util.UUID;
@Entity(
tableName = EntityAccount.TABLE_NAME,
@ -62,6 +63,9 @@ public class EntityAccount extends EntityOrder implements Serializable {
@PrimaryKey(autoGenerate = true)
public Long id;
@NonNull
public String uuid = UUID.randomUUID().toString();
@NonNull
@ColumnInfo(name = "pop")
public Integer protocol = TYPE_IMAP;
@ -221,6 +225,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
public JSONObject toJSON() throws JSONException {
JSONObject json = new JSONObject();
json.put("id", id);
json.put("uuid", uuid);
json.put("order", order);
json.put("protocol", protocol);
json.put("host", host);
@ -276,6 +281,9 @@ public class EntityAccount extends EntityOrder implements Serializable {
if (json.has("id"))
account.id = json.getLong("id");
if (json.has("uuid"))
account.uuid = json.getString("uuid");
if (json.has("order"))
account.order = json.getInt("order");
@ -352,7 +360,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
public boolean equals(Object obj) {
if (obj instanceof EntityAccount) {
EntityAccount other = (EntityAccount) obj;
return (Objects.equals(this.order, other.order) &&
return (Objects.equals(this.uuid, other.uuid) &&
Objects.equals(this.order, other.order) &&
this.protocol.equals(other.protocol) &&
this.host.equals(other.host) &&
this.encryption.equals(other.encryption) &&

@ -225,6 +225,20 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBackoff" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvId"
android:layout_width="0dp"
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"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/ivState"
app:layout_constraintTop_toBottomOf="@id/tvQuota" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvIdentity"
android:layout_width="0dp"
@ -236,7 +250,7 @@
android:textColor="?attr/colorWarning"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/vwColor"
app:layout_constraintTop_toBottomOf="@id/tvQuota" />
app:layout_constraintTop_toBottomOf="@id/tvId" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvDrafts"

Loading…
Cancel
Save