mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-18 11:55:38 -04:00
Created LibkiwixBooks to store and retrieve bookmarks
This commit is contained in:
parent
4fe6d11596
commit
da3241bea0
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Kiwix Android
|
||||
* Copyright (c) 2023 Kiwix <android.kiwix.org>
|
||||
* 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
|
||||
* (at your option) 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.kiwix.kiwixmobile.core.dao
|
||||
|
||||
import io.objectbox.kotlin.query
|
||||
import io.reactivex.Flowable
|
||||
import org.kiwix.kiwixmobile.core.dao.entities.BookmarkEntity_
|
||||
import org.kiwix.kiwixmobile.core.page.adapter.Page
|
||||
import org.kiwix.libkiwix.Manager
|
||||
import javax.inject.Inject
|
||||
|
||||
class LibkiwixBookmarks @Inject constructor(val manager: Manager) : PageDao {
|
||||
fun bookmarks(): Flowable<List<Page>> = box.asFlowable(
|
||||
box.query {
|
||||
order(BookmarkEntity_.bookmarkTitle)
|
||||
}
|
||||
).map { it.map(org.kiwix.kiwixmobile.core.page.bookmark.adapter::BookmarkItem) }
|
||||
override fun pages(): Flowable<List<Page>> = bookmarks()
|
||||
|
||||
override fun deletePages(pagesToDelete: List<Page>) {
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ import io.reactivex.Flowable
|
||||
import io.reactivex.Scheduler
|
||||
import io.reactivex.Single
|
||||
import org.kiwix.kiwixmobile.core.dao.HistoryDao
|
||||
import org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks
|
||||
import org.kiwix.kiwixmobile.core.dao.NewBookDao
|
||||
import org.kiwix.kiwixmobile.core.dao.NewBookmarksDao
|
||||
import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
|
||||
@ -53,7 +54,7 @@ class Repository @Inject internal constructor(
|
||||
@param:IO private val io: Scheduler,
|
||||
@param:MainThread private val mainThread: Scheduler,
|
||||
private val bookDao: NewBookDao,
|
||||
private val bookmarksDao: NewBookmarksDao,
|
||||
private val libkiwixBookmarks: LibkiwixBookmarks,
|
||||
private val historyDao: HistoryDao,
|
||||
private val notesDao: NewNoteDao,
|
||||
private val languageDao: NewLanguagesDao,
|
||||
|
@ -29,6 +29,7 @@ import org.kiwix.kiwixmobile.core.CoreApp
|
||||
import org.kiwix.kiwixmobile.core.StorageObserver
|
||||
import org.kiwix.kiwixmobile.core.dao.FetchDownloadDao
|
||||
import org.kiwix.kiwixmobile.core.dao.HistoryDao
|
||||
import org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks
|
||||
import org.kiwix.kiwixmobile.core.dao.NewBookDao
|
||||
import org.kiwix.kiwixmobile.core.dao.NewBookmarksDao
|
||||
import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
|
||||
@ -95,6 +96,7 @@ interface CoreComponent {
|
||||
fun connectivityManager(): ConnectivityManager
|
||||
fun wifiManager(): WifiManager
|
||||
fun objectBoxToLibkiwixMigrator(): ObjectBoxToLibkiwixMigrator
|
||||
fun libkiwixBookmarks(): LibkiwixBookmarks
|
||||
fun context(): Context
|
||||
fun downloader(): Downloader
|
||||
fun notificationManager(): NotificationManager
|
||||
|
@ -20,11 +20,16 @@ package org.kiwix.kiwixmobile.core.di.modules
|
||||
import android.content.Context
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import org.kiwix.kiwixmobile.core.dao.LibkiwixBookmarks
|
||||
import org.kiwix.libkiwix.JNIKiwix
|
||||
import org.kiwix.libkiwix.Manager
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
class JNIModule {
|
||||
@Provides @Singleton
|
||||
fun providesJNIKiwix(context: Context): JNIKiwix = JNIKiwix(context)
|
||||
|
||||
@Provides @Singleton
|
||||
fun providesLibkiwixBookmarks(manager: Manager): LibkiwixBookmarks = LibkiwixBookmarks(manager)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user