mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Update local database migrations
This commit is contained in:
parent
3ca54f0093
commit
37c17f1fd8
@ -80,68 +80,51 @@ public class KiwixDatabase extends SquidDatabase {
|
||||
|
||||
@Override
|
||||
protected boolean onUpgrade(SQLiteDatabaseWrapper db, int oldVersion, int newVersion) {
|
||||
if (newVersion >= 3 && oldVersion < 3) {
|
||||
db.execSQL("DROP TABLE IF EXISTS recents");
|
||||
tryCreateTable(RecentSearch.TABLE);
|
||||
}
|
||||
if (newVersion >= 3 && (oldVersion < 3 || oldVersion == 7 || oldVersion == 6)) {
|
||||
db.execSQL("DROP TABLE IF EXISTS recents");
|
||||
db.execSQL("DROP TABLE IF EXISTS recentsearches");
|
||||
tryCreateTable(RecentSearch.TABLE);
|
||||
}
|
||||
if (newVersion >= 3) {
|
||||
tryCreateTable(RecentSearch.TABLE);
|
||||
}
|
||||
if (newVersion >= 4) {
|
||||
tryCreateTable(Bookmark.TABLE);
|
||||
}
|
||||
if (newVersion >= 5 && oldVersion < 5) {
|
||||
db.execSQL("DROP TABLE IF EXISTS book");
|
||||
tryCreateTable(BookDatabaseEntity.TABLE);
|
||||
}
|
||||
if (newVersion >= 5) {
|
||||
tryCreateTable(BookDatabaseEntity.TABLE);
|
||||
}
|
||||
if (newVersion >= 6 && oldVersion < 6) {
|
||||
db.execSQL("DROP TABLE IF EXISTS Bookmarks");
|
||||
tryCreateTable(Bookmark.TABLE);
|
||||
migrateBookmarksVersion6();
|
||||
}
|
||||
if (newVersion >= 6) {
|
||||
tryCreateTable(Bookmark.TABLE);
|
||||
}
|
||||
if (newVersion >= 9) {
|
||||
db.execSQL("DROP TABLE IF EXISTS book");
|
||||
tryCreateTable(BookDatabaseEntity.TABLE);
|
||||
}
|
||||
if (newVersion >= 10) {
|
||||
tryCreateTable(NetworkLanguageDatabaseEntity.TABLE);
|
||||
}
|
||||
if (newVersion >= 11 && oldVersion < 11) {
|
||||
db.execSQL("DROP TABLE IF EXISTS recentSearches");
|
||||
tryCreateTable(RecentSearch.TABLE);
|
||||
}
|
||||
if (newVersion >= 11) {
|
||||
tryCreateTable(RecentSearch.TABLE);
|
||||
}
|
||||
if (newVersion >= 12) {
|
||||
tryAddColumn(BookDatabaseEntity.REMOTE_URL);
|
||||
}
|
||||
if (newVersion >= 13) {
|
||||
tryAddColumn(BookDatabaseEntity.NAME);
|
||||
tryAddColumn(Bookmark.ZIM_NAME);
|
||||
}
|
||||
if (newVersion >= 14 && oldVersion < 14) {
|
||||
tryDropTable(BookDatabaseEntity.TABLE);
|
||||
tryCreateTable(BookDatabaseEntity.TABLE);
|
||||
}
|
||||
if (newVersion >= 15 && oldVersion < 15) {
|
||||
tryCreateTable(History.TABLE);
|
||||
}
|
||||
if (newVersion >= 16 && oldVersion < 16) {
|
||||
tryAddColumn(Bookmark.ZIM_FILE_PATH);
|
||||
tryAddColumn(Bookmark.FAVICON);
|
||||
migrateBookmarksVersion16();
|
||||
switch (oldVersion) {
|
||||
case 1:
|
||||
case 2:
|
||||
db.execSQL("DROP TABLE IF EXISTS recents");
|
||||
db.execSQL("DROP TABLE IF EXISTS recentsearches");
|
||||
tryCreateTable(RecentSearch.TABLE);
|
||||
case 3:
|
||||
tryCreateTable(Bookmark.TABLE);
|
||||
case 4:
|
||||
db.execSQL("DROP TABLE IF EXISTS book");
|
||||
tryCreateTable(BookDatabaseEntity.TABLE);
|
||||
case 5:
|
||||
db.execSQL("DROP TABLE IF EXISTS Bookmarks");
|
||||
tryCreateTable(Bookmark.TABLE);
|
||||
migrateBookmarksVersion6();
|
||||
case 6:
|
||||
db.execSQL("DROP TABLE IF EXISTS recents");
|
||||
db.execSQL("DROP TABLE IF EXISTS recentsearches");
|
||||
tryCreateTable(RecentSearch.TABLE);
|
||||
case 7:
|
||||
db.execSQL("DROP TABLE IF EXISTS recents");
|
||||
db.execSQL("DROP TABLE IF EXISTS recentsearches");
|
||||
tryCreateTable(RecentSearch.TABLE);
|
||||
case 8:
|
||||
db.execSQL("DROP TABLE IF EXISTS book");
|
||||
tryCreateTable(BookDatabaseEntity.TABLE);
|
||||
case 9:
|
||||
tryCreateTable(NetworkLanguageDatabaseEntity.TABLE);
|
||||
case 10:
|
||||
db.execSQL("DROP TABLE IF EXISTS recentSearches");
|
||||
tryCreateTable(RecentSearch.TABLE);
|
||||
case 11:
|
||||
tryAddColumn(BookDatabaseEntity.REMOTE_URL);
|
||||
case 12:
|
||||
tryAddColumn(BookDatabaseEntity.NAME);
|
||||
tryAddColumn(Bookmark.ZIM_NAME);
|
||||
case 13:
|
||||
tryDropTable(BookDatabaseEntity.TABLE);
|
||||
tryCreateTable(BookDatabaseEntity.TABLE);
|
||||
case 14:
|
||||
tryCreateTable(History.TABLE);
|
||||
case 15:
|
||||
tryAddColumn(Bookmark.ZIM_FILE_PATH);
|
||||
tryAddColumn(Bookmark.FAVICON);
|
||||
migrateBookmarksVersion16();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -3,29 +3,35 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favicon"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="8dp"
|
||||
android:contentDescription="@string/favicon"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@mipmap/kiwix_icon_round" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:alpha="0.87"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/favicon"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Wikipedia - Main Page" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user