mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
fixing merging issue with develop
This commit is contained in:
parent
01f314a6a1
commit
4b6f4cb0db
@ -28,7 +28,7 @@ object Versions {
|
||||
|
||||
const val com_google_dagger: String = "2.29.1"
|
||||
|
||||
const val com_yahoo_squidb: String = "2.0.0" // available: "3.2.3"
|
||||
const val com_yahoo_squidb: String = "4.0.0-beta.2" // available: "3.2.3"
|
||||
|
||||
const val com_jakewharton: String = "10.2.3"
|
||||
|
||||
|
@ -44,11 +44,11 @@ data class BookmarkEntity(
|
||||
|
||||
private constructor(bookmark: Bookmark, zimFilePath: String?, favicon: String?) : this(
|
||||
0,
|
||||
bookmark.zimId,
|
||||
bookmark.zimName,
|
||||
bookmark.zimId!!,
|
||||
bookmark.zimName!!,
|
||||
zimFilePath,
|
||||
bookmark.bookmarkUrl,
|
||||
bookmark.bookmarkTitle,
|
||||
bookmark.bookmarkUrl!!,
|
||||
bookmark.bookmarkTitle!!,
|
||||
favicon
|
||||
)
|
||||
|
||||
|
@ -30,7 +30,7 @@ data class RecentSearchEntity(
|
||||
|
||||
constructor(recentSearch: RecentSearch) : this(
|
||||
0,
|
||||
recentSearch.searchString,
|
||||
recentSearch.zimID
|
||||
recentSearch.searchString!!,
|
||||
recentSearch.zimID!!
|
||||
)
|
||||
}
|
||||
|
@ -20,8 +20,11 @@ package org.kiwix.kiwixmobile.core.data.local;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.yahoo.squidb.android.AndroidOpenHelper;
|
||||
import com.yahoo.squidb.data.ISQLiteDatabase;
|
||||
import com.yahoo.squidb.data.ISQLiteOpenHelper;
|
||||
import com.yahoo.squidb.data.SquidDatabase;
|
||||
import com.yahoo.squidb.data.adapter.SQLiteDatabaseWrapper;
|
||||
import com.yahoo.squidb.sql.Table;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -63,7 +66,7 @@ public class KiwixDatabase extends SquidDatabase {
|
||||
public KiwixDatabase(Context context, NewBookDao bookDao, NewLanguagesDao languagesDao,
|
||||
NewBookmarksDao bookmarksDao,
|
||||
NewRecentSearchDao recentSearchDao) {
|
||||
super(context);
|
||||
super();
|
||||
this.context = context;
|
||||
this.bookDao = bookDao;
|
||||
this.languagesDao = languagesDao;
|
||||
@ -86,8 +89,14 @@ public class KiwixDatabase extends SquidDatabase {
|
||||
};
|
||||
}
|
||||
|
||||
@NonNull @Override protected ISQLiteOpenHelper createOpenHelper(
|
||||
@NonNull String databaseName,
|
||||
@NonNull OpenHelperDelegate delegate, int version) {
|
||||
return new AndroidOpenHelper(context, getName(), delegate, getVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onUpgrade(SQLiteDatabaseWrapper db, int oldVersion, int newVersion) {
|
||||
protected boolean onUpgrade(ISQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
Log.e("UPGRADE", "oldversion: " + oldVersion + " newVersion: " + newVersion);
|
||||
switch (oldVersion) {
|
||||
case 1:
|
||||
|
@ -58,13 +58,16 @@ public class BookDao {
|
||||
|
||||
public ArrayList<Book> getBooks() {
|
||||
ArrayList<Book> books = new ArrayList<>();
|
||||
try (SquidCursor<BookDatabaseEntity> bookCursor = kiwixDatabase.query(BookDatabaseEntity.class,
|
||||
Query.select())) {
|
||||
try {
|
||||
SquidCursor<BookDatabaseEntity> bookCursor = kiwixDatabase.query(BookDatabaseEntity.class,
|
||||
Query.select());
|
||||
while (bookCursor.moveToNext()) {
|
||||
Book book = new Book();
|
||||
setBookDetails(book, bookCursor);
|
||||
books.add(book);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return filterBookResults(books);
|
||||
}
|
||||
|
@ -42,8 +42,9 @@ public class BookmarksDao {
|
||||
public List<Bookmark> getBookmarks() {
|
||||
ArrayList<Bookmark> bookmarks = new ArrayList<>();
|
||||
Query query = Query.select();
|
||||
try (SquidCursor<Bookmark> squidCursor = kiwixDatabase
|
||||
.query(Bookmark.class, query.orderBy(Bookmark.BOOKMARK_TITLE.asc()))) {
|
||||
try {
|
||||
SquidCursor<Bookmark> squidCursor = kiwixDatabase
|
||||
.query(Bookmark.class, query.orderBy(Bookmark.BOOKMARK_TITLE.asc()));
|
||||
while (squidCursor.moveToNext()) {
|
||||
Bookmark bookmark = new Bookmark();
|
||||
bookmark.setZimId(squidCursor.get(Bookmark.ZIM_ID));
|
||||
@ -52,22 +53,27 @@ public class BookmarksDao {
|
||||
bookmark.setBookmarkUrl(squidCursor.get(Bookmark.BOOKMARK_URL));
|
||||
bookmarks.add(bookmark);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return bookmarks;
|
||||
}
|
||||
|
||||
public void processBookmark(StringOperation operation) {
|
||||
try (SquidCursor<Bookmark> bookmarkCursor = kiwixDatabase.query(Bookmark.class,
|
||||
Query.select(Bookmark.ID, Bookmark.BOOKMARK_URL))) {
|
||||
try {
|
||||
SquidCursor<Bookmark> bookmarkCursor = kiwixDatabase.query(Bookmark.class,
|
||||
Query.select(Bookmark.ROWID, Bookmark.BOOKMARK_URL));
|
||||
while (bookmarkCursor.moveToNext()) {
|
||||
String url = bookmarkCursor.get(Bookmark.BOOKMARK_URL);
|
||||
url = operation.apply(url);
|
||||
if (url != null) {
|
||||
kiwixDatabase.update(Update.table(Bookmark.TABLE)
|
||||
.where(Bookmark.ID.eq(bookmarkCursor.get(Bookmark.ID)))
|
||||
.where(Bookmark.ROWID.eq(bookmarkCursor.get(Bookmark.ROWID)))
|
||||
.set(Bookmark.BOOKMARK_URL, url));
|
||||
}
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,14 +37,17 @@ public class NetworkLanguageDao {
|
||||
|
||||
public ArrayList<Language> getFilteredLanguages() {
|
||||
ArrayList<Language> result = new ArrayList<>();
|
||||
try (SquidCursor<NetworkLanguageDatabaseEntity> languageCursor = mDb.query(
|
||||
NetworkLanguageDatabaseEntity.class,
|
||||
Query.select())) {
|
||||
try {
|
||||
SquidCursor<NetworkLanguageDatabaseEntity> languageCursor = mDb.query(
|
||||
NetworkLanguageDatabaseEntity.class,
|
||||
Query.select());
|
||||
while (languageCursor.moveToNext()) {
|
||||
String languageCode = languageCursor.get(NetworkLanguageDatabaseEntity.LANGUAGE_I_S_O_3);
|
||||
boolean enabled = languageCursor.get(NetworkLanguageDatabaseEntity.ENABLED);
|
||||
result.add(new Language(languageCode, enabled, 0));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -44,11 +44,14 @@ public class RecentSearchDao {
|
||||
*/
|
||||
public List<RecentSearch> getRecentSearches() {
|
||||
List<RecentSearch> result = new ArrayList<>();
|
||||
try (SquidCursor<RecentSearch> searchCursor = mDb.query(
|
||||
RecentSearch.class, Query.select())) {
|
||||
try {
|
||||
SquidCursor<RecentSearch> searchCursor = mDb.query(
|
||||
RecentSearch.class, Query.select());
|
||||
while (searchCursor.moveToNext()) {
|
||||
result.add(new RecentSearch(searchCursor));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
package org.kiwix.kiwixmobile.core.data.local.entity;
|
||||
|
||||
import com.yahoo.squidb.annotations.ColumnSpec;
|
||||
import com.yahoo.squidb.annotations.TableModelSpec;
|
||||
|
||||
/**
|
||||
@ -25,7 +24,6 @@ import com.yahoo.squidb.annotations.TableModelSpec;
|
||||
*/
|
||||
@TableModelSpec(className = "Bookmark", tableName = "Bookmarks")
|
||||
public class BookmarksSpec {
|
||||
@ColumnSpec(constraints = "NOT NULL")
|
||||
public String ZimId;
|
||||
public String ZimName;
|
||||
public String bookmarkUrl;
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
package org.kiwix.kiwixmobile.core.data.local.entity;
|
||||
|
||||
import com.yahoo.squidb.annotations.ColumnSpec;
|
||||
import com.yahoo.squidb.annotations.TableModelSpec;
|
||||
|
||||
/**
|
||||
@ -25,10 +24,6 @@ import com.yahoo.squidb.annotations.TableModelSpec;
|
||||
*/
|
||||
@TableModelSpec(className = "RecentSearch", tableName = "recentSearches")
|
||||
public class RecentSearchSpec {
|
||||
|
||||
@ColumnSpec(constraints = "NOT NULL")
|
||||
public String searchString;
|
||||
|
||||
@ColumnSpec(constraints = "NOT NULL")
|
||||
public String zimID;
|
||||
}
|
||||
|
@ -28,11 +28,9 @@
|
||||
<issue id="Typos">
|
||||
<ignore path="**/values-tr/**.xml" />
|
||||
</issue>
|
||||
|
||||
<issue id="InvalidPackage">
|
||||
<ignore path="**simple-xml-2.7.1.jar" />
|
||||
<ignore path="**/squidb*.jar" />
|
||||
<ignore path="**/org.jacoco.agent-0.8.3-runtime.jar" />
|
||||
<ignore path="**javapoet-1.8.0.jar" />
|
||||
</issue>
|
||||
<issue id="IconLocation">
|
||||
<ignore path="src/main/res/drawable/kiwix_icon_with_title.png" />
|
||||
@ -41,5 +39,4 @@
|
||||
<issue id="ConvertToWebp">
|
||||
<ignore path="src/main/res/drawable/search_widget_preview.png" />
|
||||
</issue>
|
||||
|
||||
</lint>
|
||||
|
Loading…
x
Reference in New Issue
Block a user