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