Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified app/src/debug/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/src/debug/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
</adaptive-icon>
1 change: 1 addition & 0 deletions app/src/debug/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
</adaptive-icon>
Binary file modified app/src/debug/res/mipmap-hdpi/ic_launcher.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/debug/res/mipmap-hdpi/ic_launcher_foreground.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/debug/res/mipmap-hdpi/ic_launcher_round.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/debug/res/mipmap-mdpi/ic_launcher.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/debug/res/mipmap-mdpi/ic_launcher_foreground.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/debug/res/mipmap-mdpi/ic_launcher_round.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/debug/res/mipmap-xhdpi/ic_launcher.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/debug/res/mipmap-xhdpi/ic_launcher_foreground.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/debug/res/mipmap-xhdpi/ic_launcher_round.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/debug/res/mipmap-xxhdpi/ic_launcher.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/debug/res/mipmap-xxhdpi/ic_launcher_foreground.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/debug/res/mipmap-xxhdpi/ic_launcher_round.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
}

val isNavLabelsVisible: Boolean
get() = prefs.getBoolean(KEY_NAV_LABELS, true)
get() = prefs.getBoolean(KEY_NAV_LABELS, false)

val isNavBarPinned: Boolean
get() = prefs.getBoolean(KEY_NAV_PINNED, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.core.content.edit
private const val CATEGORY_ID = "cat_id"
private const val BACKGROUND = "bg"

private const val SOURCE_TYPE = "source_type"
class AppWidgetConfig(
context: Context,
cls: Class<out AppWidgetProvider>,
Expand All @@ -24,6 +25,10 @@ class AppWidgetConfig(
get() = prefs.getBoolean(BACKGROUND, Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
set(value) = prefs.edit { putBoolean(BACKGROUND, value) }

var sourceType : String
get() = prefs.getString(SOURCE_TYPE, "favourites") ?: "favourites"
set(value) = prefs.edit { putString(SOURCE_TYPE, value) }

fun clear() {
prefs.edit { clear() }
}
Expand All @@ -33,6 +38,7 @@ class AppWidgetConfig(
clear()
putLong(CATEGORY_ID, other.categoryId)
putBoolean(BACKGROUND, other.hasBackground)
putString(SOURCE_TYPE, other.sourceType)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ class DetailsActivity :

private fun loadCover(imageUrl: String?) {
viewBinding.imageViewCover.setImageAsync(imageUrl, viewModel.getMangaOrNull())
viewBinding.imageViewBlurBackground?.setImageAsync(imageUrl, viewModel.getMangaOrNull())
}

private fun String.withEstimatedTime(time: ReadingTime?): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.github.landwarderer.futon.widget.shelf

import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import io.github.landwarderer.futon.backups.data.model.HistoryBackup
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
Expand All @@ -11,31 +12,44 @@ import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.plus
import io.github.landwarderer.futon.core.ui.BaseViewModel
import io.github.landwarderer.futon.favourites.domain.FavouritesRepository
import io.github.landwarderer.futon.history.data.HistoryRepository
import io.github.landwarderer.futon.widget.shelf.model.CategoryItem
import javax.inject.Inject

@HiltViewModel
class ShelfConfigViewModel @Inject constructor(
favouritesRepository: FavouritesRepository,
favouritesRepository: FavouritesRepository,
private val historyRepository: HistoryRepository,
) : BaseViewModel() {

private val selectedCategoryId = MutableStateFlow(0L)
private val selectedSourceType = MutableStateFlow("favourites")

val content: StateFlow<List<CategoryItem>> = combine(
favouritesRepository.observeCategories(),
selectedCategoryId,
) { categories, selectedId ->
val list = ArrayList<CategoryItem>(categories.size + 1)
list += CategoryItem(0L, null, selectedId == 0L)
categories.mapTo(list) {
CategoryItem(it.id, it.title, selectedId == it.id)
}
selectedSourceType,
) { categories, selectedId, sourceType ->
val list = ArrayList<CategoryItem>(categories.size + 2)
list += CategoryItem(-1L, "Recent", sourceType == "recent")
list += CategoryItem(0L, null, selectedId == 0L && sourceType == "favorites")
categories.mapTo(list) {
CategoryItem(it.id, it.title, selectedId == it.id && sourceType == "favorites")
}
list
}.stateIn(viewModelScope + Dispatchers.IO, SharingStarted.Eagerly, emptyList())

var checkedId: Long
get() = selectedCategoryId.value
set(value) {
selectedCategoryId.value = value
selectedSourceType.value = "favourites"
}

val sourceType = selectedSourceType

fun selectRecent() {
selectedSourceType.value = "recent"
selectedCategoryId.value = 0L
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import io.github.landwarderer.futon.core.ui.image.TrimTransformation
import io.github.landwarderer.futon.core.util.ext.getDrawableOrThrow
import io.github.landwarderer.futon.core.util.ext.mangaExtra
import io.github.landwarderer.futon.favourites.domain.FavouritesRepository
import io.github.landwarderer.futon.history.data.HistoryRepository
import org.koitharu.kotatsu.parsers.model.Manga
import org.koitharu.kotatsu.parsers.util.replaceWith

class ShelfListFactory(
private val context: Context,
private val favouritesRepository: FavouritesRepository,
private val historyRepository: HistoryRepository,
private val coilLazy: Lazy<ImageLoader>,
private val settings: AppSettings,
widgetId: Int,
Expand All @@ -51,11 +53,16 @@ class ShelfListFactory(
override fun onDataSetChanged() {
val data = if (settings.appPassword.isNullOrEmpty()) {
runBlocking {
val category = config.categoryId
if (category == 0L) {
favouritesRepository.getAllManga()
} else {
favouritesRepository.getManga(category)
when (config.sourceType) {
"recent" -> historyRepository.getList(0, 20)
else -> {
val category = config.categoryId
if (category == 0L) {
favouritesRepository.getAllManga()
} else {
favouritesRepository.getManga(category)
}
}
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ class ShelfWidgetConfigActivity :
return
}
config = AppWidgetConfig(this, ShelfWidgetProvider::class.java, appWidgetId)
viewModel.checkedId = config.categoryId
if (config.sourceType == "recent") {
viewModel.selectRecent()
} else {
viewModel.checkedId = config.categoryId
}
viewBinding.switchBackground.isChecked = config.hasBackground

viewModel.content.observe(this, adapter)
Expand All @@ -73,6 +77,7 @@ class ShelfWidgetConfigActivity :
override fun onClick(v: View) {
when (v.id) {
R.id.button_done -> {
config.sourceType = viewModel.sourceType.value
config.categoryId = viewModel.checkedId
config.hasBackground = viewBinding.switchBackground.isChecked
updateWidget()
Expand All @@ -86,7 +91,11 @@ class ShelfWidgetConfigActivity :
}

override fun onItemClick(item: CategoryItem, view: View) {
viewModel.checkedId = item.id
if (item.id == -1L) {
viewModel.selectRecent()
} else {
viewModel.checkedId = item.id
}
}

private fun updateWidget() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import dagger.Lazy
import dagger.hilt.android.AndroidEntryPoint
import io.github.landwarderer.futon.core.prefs.AppSettings
import io.github.landwarderer.futon.favourites.domain.FavouritesRepository
import io.github.landwarderer.futon.history.data.HistoryRepository
import javax.inject.Inject

@AndroidEntryPoint
Expand All @@ -16,6 +17,9 @@ class ShelfWidgetService : RemoteViewsService() {
@Inject
lateinit var favouritesRepository: FavouritesRepository

@Inject
lateinit var historyRepository: HistoryRepository

@Inject
lateinit var settings: AppSettings

Expand All @@ -27,6 +31,6 @@ class ShelfWidgetService : RemoteViewsService() {
AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID,
)
return ShelfListFactory(applicationContext, favouritesRepository, coilLazy, settings, widgetId)
return ShelfListFactory(applicationContext, favouritesRepository, historyRepository, coilLazy, settings, widgetId)
}
}
Loading
Loading