Persist showing images / full message

pull/199/head
M66B 4 years ago
parent be84c22d18
commit b04a4848c6

File diff suppressed because it is too large Load Diff

@ -2029,12 +2029,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
continue;
int at = from.indexOf('@');
String domain = (at < 0 ? from : from.substring(at));
if (prefs.getBoolean(from + ".show_full", false) ||
if (message.show_full ||
prefs.getBoolean(from + ".show_full", false) ||
prefs.getBoolean(domain + ".show_full", false)) {
properties.setValue("full", message.id, true);
properties.setValue("full_asked", message.id, true);
}
if (prefs.getBoolean(from + ".show_images", false) ||
if (message.show_images ||
prefs.getBoolean(from + ".show_images", false) ||
prefs.getBoolean(domain + ".show_images", false)) {
properties.setValue("images", message.id, true);
properties.setValue("images_asked", message.id, true);
@ -3809,10 +3811,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
properties.setValue(full ? "full" : "images", message.id, !current);
if (full)
onShowFullConfirmed(message);
else
onShowImagesConfirmed(message);
onShowConfirmed(message, full, !current);
return;
}
@ -3917,10 +3917,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
editor.apply();
if (full)
onShowFullConfirmed(message);
else
onShowImagesConfirmed(message);
onShowConfirmed(message, full, true);
}
})
.setNegativeButton(android.R.string.cancel, null)
@ -3947,17 +3944,48 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
});
}
private void onShowFullConfirmed(final TupleMessageEx message) {
properties.setSize(message.id, null);
properties.setHeight(message.id, null);
properties.setPosition(message.id, null);
private void onShowConfirmed(final TupleMessageEx message, boolean full, boolean value) {
if (full)
message.show_full = value;
else
message.show_images = value;
setupTools(message, false, false);
bindBody(message, false);
}
if (full) {
properties.setSize(message.id, null);
properties.setHeight(message.id, null);
properties.setPosition(message.id, null);
setupTools(message, false, false);
}
private void onShowImagesConfirmed(TupleMessageEx message) {
bindBody(message, false);
Bundle args = new Bundle();
args.putLong("id", message.id);
args.putBoolean("full", full);
args.putBoolean("value", value);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
boolean full = args.getBoolean("full");
boolean value = args.getBoolean("value");
DB db = DB.getInstance(context);
if (full)
db.message().setMessageShowFull(id, value);
else
db.message().setMessageShowImages(id, value);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}.execute(context, owner, args, "message:full");
}
private void onActionOpenFull(final TupleMessageEx message) {
@ -5756,6 +5784,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
same = false;
log("ui_unsnoozed changed", next.id);
}
// show_images
// show_full
if (!Objects.equals(prev.color, next.color)) {
same = false;
log("color changed", next.id);

@ -65,7 +65,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 197,
version = 198,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2021,6 +2021,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `answer` ADD COLUMN `last_applied` INTEGER");
}
}).addMigrations(new Migration(197, 198) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `show_images` INTEGER NOT NULL DEFAULT 0");
db.execSQL("ALTER TABLE `message` ADD COLUMN `show_full` INTEGER NOT NULL DEFAULT 0");
}
}).addMigrations(new Migration(198, 199) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);

@ -790,6 +790,12 @@ public interface DaoMessage {
@Query("UPDATE message SET ui_unsnoozed = :unsnoozed WHERE id = :id AND NOT (ui_unsnoozed IS :unsnoozed)")
int setMessageUnsnoozed(long id, boolean unsnoozed);
@Query("UPDATE message SET show_images = :show_images WHERE id = :id AND NOT (show_images IS :show_images)")
int setMessageShowImages(long id, boolean show_images);
@Query("UPDATE message SET show_full = :show_full WHERE id = :id AND NOT (show_full IS :show_full)")
int setMessageShowFull(long id, boolean show_full);
@Query("UPDATE message SET notifying = 0 WHERE NOT (notifying IS 0)")
int clearNotifyingMessages();

@ -220,6 +220,10 @@ public class EntityMessage implements Serializable {
public Long ui_snoozed;
@NonNull
public Boolean ui_unsnoozed = false;
@NonNull
public Boolean show_images = false;
@NonNull
public Boolean show_full = false;
public Integer color;
public Integer revision; // compose
public Integer revisions; // compose
@ -552,6 +556,8 @@ public class EntityMessage implements Serializable {
Objects.equals(this.ui_busy, other.ui_busy) &&
Objects.equals(this.ui_snoozed, other.ui_snoozed) &&
this.ui_unsnoozed.equals(other.ui_unsnoozed) &&
this.show_images.equals(other.show_images) &&
this.show_full.equals(other.show_full) &&
Objects.equals(this.color, other.color) &&
Objects.equals(this.revision, other.revision) &&
Objects.equals(this.revisions, other.revisions) &&

Loading…
Cancel
Save