From 74ea67627caff1e40edb31c610159fbb79585800 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 9 Dec 2019 01:33:52 +0300 Subject: [PATCH] db: upgrade to 21, add markdownMode column --- .../com/keylesspalace/tusky/TuskyApplication.java | 2 +- .../java/com/keylesspalace/tusky/db/AppDatabase.java | 11 +++++++++-- .../java/com/keylesspalace/tusky/db/TootEntity.java | 12 +++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.java b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.java index e8b484ca..6bf82461 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.java +++ b/app/src/main/java/com/keylesspalace/tusky/TuskyApplication.java @@ -72,7 +72,7 @@ public class TuskyApplication extends Application implements HasAndroidInjector AppDatabase.MIGRATION_11_12, AppDatabase.MIGRATION_12_13, AppDatabase.MIGRATION_10_13, AppDatabase.MIGRATION_13_14, AppDatabase.MIGRATION_14_15, AppDatabase.MIGRATION_15_16, AppDatabase.MIGRATION_16_17, AppDatabase.MIGRATION_17_18, AppDatabase.MIGRATION_18_19, - AppDatabase.MIGRATION_19_20) + AppDatabase.MIGRATION_19_20, AppDatabase.MIGRATION_20_21) .build(); accountManager = new AccountManager(appDatabase); serviceLocator = new ServiceLocator() { diff --git a/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java b/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java index d37df70a..caea6066 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java +++ b/app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java @@ -30,7 +30,7 @@ import androidx.annotation.NonNull; @Database(entities = {TootEntity.class, AccountEntity.class, InstanceEntity.class, TimelineStatusEntity.class, TimelineAccountEntity.class, ConversationEntity.class - }, version = 20) + }, version = 21) public abstract class AppDatabase extends RoomDatabase { public abstract TootDao tootDao(); @@ -317,5 +317,12 @@ public abstract class AppDatabase extends RoomDatabase { database.execSQL("ALTER TABLE `ConversationEntity` ADD COLUMN `s_bookmarked` INTEGER NOT NULL DEFAULT 0"); } }; + + public static final Migration MIGRATION_20_21 = new Migration(20, 21) { + @Override + public void migrate(@NonNull SupportSQLiteDatabase database) { + database.execSQL("ALTER TABLE `TootEntity` ADD COLUMN `markdownMode` INTEGER"); + } + }; -} \ No newline at end of file +} diff --git a/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java b/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java index b4b258d5..678b92e4 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java +++ b/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java @@ -65,10 +65,14 @@ public class TootEntity { @Nullable @ColumnInfo(name = "poll") private final NewPoll poll; + + @Nullable + @ColumnInfo(name = "markdownMode") + private final Boolean markdownMode; public TootEntity(int uid, String text, String urls, String descriptions, String contentWarning, String inReplyToId, @Nullable String inReplyToText, @Nullable String inReplyToUsername, - Status.Visibility visibility, @Nullable NewPoll poll) { + Status.Visibility visibility, @Nullable NewPoll poll, @Nullable Boolean markdownMode) { this.uid = uid; this.text = text; this.urls = urls; @@ -79,6 +83,7 @@ public class TootEntity { this.inReplyToUsername = inReplyToUsername; this.visibility = visibility; this.poll = poll; + this.markdownMode = markdownMode; } public String getText() { @@ -123,6 +128,11 @@ public class TootEntity { public NewPoll getPoll() { return poll; } + + @Nullable + public Boolean getMarkdownMode() { + return markdownMode; + } public static final class Converters {