db: upgrade to 21, add markdownMode column

main
Alibek Omarov 5 years ago
parent 793c21eb85
commit 74ea67627c
  1. 2
      app/src/main/java/com/keylesspalace/tusky/TuskyApplication.java
  2. 11
      app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java
  3. 12
      app/src/main/java/com/keylesspalace/tusky/db/TootEntity.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_11_12, AppDatabase.MIGRATION_12_13, AppDatabase.MIGRATION_10_13,
AppDatabase.MIGRATION_13_14, AppDatabase.MIGRATION_14_15, AppDatabase.MIGRATION_15_16, 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_16_17, AppDatabase.MIGRATION_17_18, AppDatabase.MIGRATION_18_19,
AppDatabase.MIGRATION_19_20) AppDatabase.MIGRATION_19_20, AppDatabase.MIGRATION_20_21)
.build(); .build();
accountManager = new AccountManager(appDatabase); accountManager = new AccountManager(appDatabase);
serviceLocator = new ServiceLocator() { serviceLocator = new ServiceLocator() {

@ -30,7 +30,7 @@ import androidx.annotation.NonNull;
@Database(entities = {TootEntity.class, AccountEntity.class, InstanceEntity.class, TimelineStatusEntity.class, @Database(entities = {TootEntity.class, AccountEntity.class, InstanceEntity.class, TimelineStatusEntity.class,
TimelineAccountEntity.class, ConversationEntity.class TimelineAccountEntity.class, ConversationEntity.class
}, version = 20) }, version = 21)
public abstract class AppDatabase extends RoomDatabase { public abstract class AppDatabase extends RoomDatabase {
public abstract TootDao tootDao(); 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"); 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");
}
};
} }

@ -65,10 +65,14 @@ public class TootEntity {
@Nullable @Nullable
@ColumnInfo(name = "poll") @ColumnInfo(name = "poll")
private final NewPoll 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, public TootEntity(int uid, String text, String urls, String descriptions, String contentWarning, String inReplyToId,
@Nullable String inReplyToText, @Nullable String inReplyToUsername, @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.uid = uid;
this.text = text; this.text = text;
this.urls = urls; this.urls = urls;
@ -79,6 +83,7 @@ public class TootEntity {
this.inReplyToUsername = inReplyToUsername; this.inReplyToUsername = inReplyToUsername;
this.visibility = visibility; this.visibility = visibility;
this.poll = poll; this.poll = poll;
this.markdownMode = markdownMode;
} }
public String getText() { public String getText() {
@ -123,6 +128,11 @@ public class TootEntity {
public NewPoll getPoll() { public NewPoll getPoll() {
return poll; return poll;
} }
@Nullable
public Boolean getMarkdownMode() {
return markdownMode;
}
public static final class Converters { public static final class Converters {

Loading…
Cancel
Save