diff --git a/app/build.gradle b/app/build.gradle index e01513624..f383e9df9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -94,9 +94,9 @@ dependencies { implementation 'androidx.core:core-ktx:1.12.0' implementation 'androidx.activity:activity-ktx:1.8.2' implementation 'androidx.fragment:fragment-ktx:1.6.2' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' - implementation 'androidx.lifecycle:lifecycle-service:2.6.2' - implementation 'androidx.lifecycle:lifecycle-process:2.6.2' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0' + implementation 'androidx.lifecycle:lifecycle-service:2.7.0' + implementation 'androidx.lifecycle:lifecycle-process:2.7.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.3.2' @@ -104,7 +104,7 @@ dependencies { implementation 'androidx.preference:preference-ktx:1.2.1' implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha05' implementation 'com.google.android.material:material:1.11.0' - implementation 'androidx.lifecycle:lifecycle-common-java8:2.6.2' + implementation 'androidx.lifecycle:lifecycle-common-java8:2.7.0' implementation 'androidx.work:work-runtime:2.9.0' //noinspection GradleDependency diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListFragment.kt index ed6a4718e..dd421f8a4 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListFragment.kt @@ -5,6 +5,7 @@ import android.view.Menu import android.view.MenuItem import androidx.appcompat.view.ActionMode import androidx.fragment.app.viewModels +import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.os.NetworkManageIntent @@ -54,6 +55,18 @@ class HistoryListFragment : MangaListFragment() { true } + R.id.action_mark_current -> { + MaterialAlertDialogBuilder(context ?: return false) + .setTitle(item.title) + .setMessage(R.string.mark_as_completed_prompt) + .setNegativeButton(android.R.string.cancel, null) + .setPositiveButton(android.R.string.ok) { _, _ -> + viewModel.markAsRead(selectedItems) + mode.finish() + }.show() + true + } + else -> super.onActionItemClicked(controller, mode, item) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt index aec6e8055..62f8ed2a2 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/history/ui/HistoryListViewModel.kt @@ -25,6 +25,7 @@ import org.koitharu.kotatsu.core.util.ext.call import org.koitharu.kotatsu.core.util.ext.onFirst import org.koitharu.kotatsu.download.ui.worker.DownloadWorker import org.koitharu.kotatsu.history.data.HistoryRepository +import org.koitharu.kotatsu.history.domain.MarkAsReadUseCase import org.koitharu.kotatsu.history.domain.model.MangaWithHistory import org.koitharu.kotatsu.list.domain.ListExtraProvider import org.koitharu.kotatsu.list.domain.ListSortOrder @@ -39,6 +40,7 @@ import org.koitharu.kotatsu.list.ui.model.toGridModel import org.koitharu.kotatsu.list.ui.model.toListDetailedModel import org.koitharu.kotatsu.list.ui.model.toListModel import org.koitharu.kotatsu.local.data.LocalMangaRepository +import org.koitharu.kotatsu.parsers.model.Manga import java.time.Instant import javax.inject.Inject @@ -48,6 +50,7 @@ class HistoryListViewModel @Inject constructor( settings: AppSettings, private val extraProvider: ListExtraProvider, private val localMangaRepository: LocalMangaRepository, + private val markAsReadUseCase: MarkAsReadUseCase, networkState: NetworkState, downloadScheduler: DownloadWorker.Scheduler, ) : MangaListViewModel(settings, downloadScheduler) { @@ -121,6 +124,12 @@ class HistoryListViewModel @Inject constructor( } } + fun markAsRead(items: Set) { + launchLoadingJob(Dispatchers.Default) { + markAsReadUseCase(items) + } + } + private suspend fun mapList( list: List, grouped: Boolean, diff --git a/app/src/main/res/menu/mode_history.xml b/app/src/main/res/menu/mode_history.xml index 0f15dd2cb..43d79ff41 100644 --- a/app/src/main/res/menu/mode_history.xml +++ b/app/src/main/res/menu/mode_history.xml @@ -27,4 +27,10 @@ android:title="@string/add_to_favourites" app:showAsAction="ifRoom|withText" /> - \ No newline at end of file + + + diff --git a/build.gradle b/build.gradle index 7a7472950..aa736995a 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.2.0' + classpath 'com.android.tools.build:gradle:8.2.1' classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22' classpath 'com.google.dagger:hilt-android-gradle-plugin:2.50' classpath 'com.google.devtools.ksp:symbol-processing-gradle-plugin:1.9.22-1.0.16'