diff --git a/build.gradle b/build.gradle index 4f10b00ac..4bb9b6560 100644 --- a/build.gradle +++ b/build.gradle @@ -22,8 +22,8 @@ dependencies { compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:support-v4:23.1.1' compile files("$buildDir/native-libs/native-libs.jar") - compile 'com.yahoo.squidb:squidb:2.0.0' compile 'com.android.support:design:23.1.1' + compile 'com.yahoo.squidb:squidb:2.0.0' compile 'com.yahoo.squidb:squidb-annotations:2.0.0' apt 'com.yahoo.squidb:squidb-processor:2.0.0' compile 'com.squareup.okhttp3:okhttp:3.2.0' diff --git a/src/org/kiwix/kiwixmobile/database/KiwixDatabase.java b/src/org/kiwix/kiwixmobile/database/KiwixDatabase.java new file mode 100644 index 000000000..c3339b1d3 --- /dev/null +++ b/src/org/kiwix/kiwixmobile/database/KiwixDatabase.java @@ -0,0 +1,55 @@ +/* + * Copyright 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package org.kiwix.kiwixmobile.database; + +import android.content.Context; +import com.yahoo.squidb.data.SquidDatabase; +import com.yahoo.squidb.data.adapter.SQLiteDatabaseWrapper; +import com.yahoo.squidb.sql.Table; +import org.kiwix.kiwixmobile.database.entity.BookDatabaseEntity; + +public class KiwixDatabase extends SquidDatabase { + + private static final int VERSION = 1; + + public KiwixDatabase(Context context) { + super(context); + } + + @Override public String getName() { + return "kiwix.db"; + } + + @Override + protected Table[] getTables() { + return new Table[] { + BookDatabaseEntity.TABLE + }; + } + + @Override protected boolean onUpgrade(SQLiteDatabaseWrapper db, int oldVersion, int newVersion) { + return false; + } + + @Override + protected int getVersion() { + return VERSION; + } +} diff --git a/src/org/kiwix/kiwixmobile/database/entity/BookDataSource.java b/src/org/kiwix/kiwixmobile/database/entity/BookDataSource.java new file mode 100644 index 000000000..c15188604 --- /dev/null +++ b/src/org/kiwix/kiwixmobile/database/entity/BookDataSource.java @@ -0,0 +1,52 @@ +/* + * Copyright 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package org.kiwix.kiwixmobile.database.entity; + +import com.yahoo.squidb.annotations.TableModelSpec; + +@TableModelSpec(className = "BookDatabaseEntity", tableName = "book") +public class BookDataSource { + + public String bookId; + + public String title; + + public String description; + + public String language; + + public String bookCreator; + + public String publisher; + + public String date; + + public String url; + + public String articleCount; + + public String mediaCount; + + public String size; + + public String favicon; + + public String filePath; +} diff --git a/src/org/kiwix/kiwixmobile/database/entity/LibraryDataSource.java b/src/org/kiwix/kiwixmobile/database/entity/LibraryDataSource.java new file mode 100755 index 000000000..8e1b2a03b --- /dev/null +++ b/src/org/kiwix/kiwixmobile/database/entity/LibraryDataSource.java @@ -0,0 +1,27 @@ +/* + * Copyright 2016 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package org.kiwix.kiwixmobile.database.entity; + +import com.yahoo.squidb.annotations.TableModelSpec; + +@TableModelSpec(className = "LibraryDatabaseEntity", tableName = "library") +public class LibraryDataSource { + public String libraryVersion; +}