master
Koitharu 2 years ago
parent 227fe86cf9
commit ed5b1306b8
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -252,7 +252,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
val defaultDetailsTab: Int val defaultDetailsTab: Int
get() = if (isPagesTabEnabled) { get() = if (isPagesTabEnabled) {
val raw = prefs.getString(KEY_DETAILS_TAB, null)?.toIntOrNull() ?: 0 val raw = prefs.getString(KEY_DETAILS_TAB, null)?.toIntOrNull() ?: -1
if (raw == -1) { if (raw == -1) {
lastDetailsTab lastDetailsTab
} else { } else {

@ -19,7 +19,7 @@ abstract class BaseFullscreenActivity<B : ViewBinding> :
with(window) { with(window) {
systemUiController = SystemUiController(this) systemUiController = SystemUiController(this)
statusBarColor = Color.TRANSPARENT statusBarColor = Color.TRANSPARENT
navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) {
ContextCompat.getColor(this@BaseFullscreenActivity, R.color.dim) ContextCompat.getColor(this@BaseFullscreenActivity, R.color.dim)
} else { } else {
Color.TRANSPARENT Color.TRANSPARENT

@ -67,7 +67,7 @@ class FastScroller @JvmOverloads constructor(
private var hideScrollbar = true private var hideScrollbar = true
private var showBubble = true private var showBubble = true
private var showBubbleAlways = false private var showBubbleAlways = false
private var bubbleSize = BubbleSize.NORMAL private var bubbleSize = BubbleSize.SMALL
private var bubbleImage: Drawable? = null private var bubbleImage: Drawable? = null
private var handleImage: Drawable? = null private var handleImage: Drawable? = null
private var trackImage: Drawable? = null private var trackImage: Drawable? = null
@ -91,7 +91,7 @@ class FastScroller @JvmOverloads constructor(
if (showBubbleAlways) { if (showBubbleAlways) {
val targetPos = getRecyclerViewTargetPosition(y) val targetPos = getRecyclerViewTargetPosition(y)
sectionIndexer?.let { binding.bubble.text = it.getSectionText(recyclerView.context, targetPos) } sectionIndexer?.let { bindBubble(it.getSectionText(recyclerView.context, targetPos)) }
} }
} }
} }
@ -145,7 +145,7 @@ class FastScroller @JvmOverloads constructor(
showBubble = getBoolean(R.styleable.FastScrollRecyclerView_showBubble, showBubble) showBubble = getBoolean(R.styleable.FastScrollRecyclerView_showBubble, showBubble)
showBubbleAlways = getBoolean(R.styleable.FastScrollRecyclerView_showBubbleAlways, showBubbleAlways) showBubbleAlways = getBoolean(R.styleable.FastScrollRecyclerView_showBubbleAlways, showBubbleAlways)
showTrack = getBoolean(R.styleable.FastScrollRecyclerView_showTrack, showTrack) showTrack = getBoolean(R.styleable.FastScrollRecyclerView_showTrack, showTrack)
bubbleSize = getBubbleSize(R.styleable.FastScrollRecyclerView_bubbleSize, BubbleSize.NORMAL) bubbleSize = getBubbleSize(R.styleable.FastScrollRecyclerView_bubbleSize, bubbleSize)
val textSize = getDimension(R.styleable.FastScrollRecyclerView_bubbleTextSize, bubbleSize.textSize) val textSize = getDimension(R.styleable.FastScrollRecyclerView_bubbleTextSize, bubbleSize.textSize)
binding.bubble.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize) binding.bubble.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
offset = getDimensionPixelOffset(R.styleable.FastScrollRecyclerView_scrollerOffset, offset) offset = getDimensionPixelOffset(R.styleable.FastScrollRecyclerView_scrollerOffset, offset)
@ -473,7 +473,7 @@ class FastScroller @JvmOverloads constructor(
val layoutManager = recyclerView?.layoutManager ?: return val layoutManager = recyclerView?.layoutManager ?: return
val targetPos = getRecyclerViewTargetPosition(y) val targetPos = getRecyclerViewTargetPosition(y)
layoutManager.scrollToPosition(targetPos) layoutManager.scrollToPosition(targetPos)
if (showBubble) sectionIndexer?.let { binding.bubble.text = it.getSectionText(context, targetPos) } if (showBubble) sectionIndexer?.let { bindBubble(it.getSectionText(context, targetPos)) }
} }
private fun setViewPositions(y: Float) { private fun setViewPositions(y: Float) {
@ -535,6 +535,11 @@ class FastScroller @JvmOverloads constructor(
} }
} }
private fun bindBubble(text: CharSequence?) {
binding.bubble.text = text
binding.bubble.alpha = if (text.isNullOrEmpty()) 0f else 1f
}
private val BubbleSize.textSize private val BubbleSize.textSize
@Px get() = resources.getDimension(textSizeId) @Px get() = resources.getDimension(textSizeId)

@ -33,23 +33,30 @@ sealed class SystemUiController(
private class LegacyImpl(window: Window) : SystemUiController(window) { private class LegacyImpl(window: Window) : SystemUiController(window) {
override fun setSystemUiVisible(value: Boolean) { override fun setSystemUiVisible(value: Boolean) {
val flags = window.decorView.systemUiVisibility
window.decorView.systemUiVisibility = if (value) { window.decorView.systemUiVisibility = if (value) {
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or (flags and LEGACY_FLAGS_HIDDEN.inv()) or LEGACY_FLAGS_VISIBLE
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
} else { } else {
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or (flags and LEGACY_FLAGS_VISIBLE.inv()) or LEGACY_FLAGS_HIDDEN
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
} }
} }
} }
companion object { companion object {
@Suppress("DEPRECATION")
private const val LEGACY_FLAGS_VISIBLE = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
@Suppress("DEPRECATION")
private const val LEGACY_FLAGS_HIDDEN = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
operator fun invoke(window: Window): SystemUiController = operator fun invoke(window: Window): SystemUiController =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
Api30Impl(window) Api30Impl(window)

@ -37,6 +37,7 @@ import androidx.appcompat.app.AppCompatDialog
import androidx.core.app.ActivityOptionsCompat import androidx.core.app.ActivityOptionsCompat
import androidx.core.app.NotificationManagerCompat import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils
import androidx.core.os.LocaleListCompat import androidx.core.os.LocaleListCompat
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
@ -140,6 +141,9 @@ fun Window.setNavigationBarTransparentCompat(context: Context, elevation: Float,
!context.getSystemBoolean("config_navBarNeedsScrim", true) !context.getSystemBoolean("config_navBarNeedsScrim", true)
) { ) {
Color.TRANSPARENT Color.TRANSPARENT
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) {
val baseColor = context.getThemeColor(android.R.attr.navigationBarColor)
ColorUtils.setAlphaComponent(baseColor, (Color.alpha(baseColor) * alphaFactor).toInt())
} else { } else {
// Set navbar scrim 70% of navigationBarColor // Set navbar scrim 70% of navigationBarColor
ElevationOverlayProvider(context).compositeOverlayIfNeeded( ElevationOverlayProvider(context).compositeOverlayIfNeeded(

@ -5,9 +5,7 @@ import androidx.core.view.isGone
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.work.WorkInfo import androidx.work.WorkInfo
import coil.ImageLoader import coil.ImageLoader
import coil.request.SuccessResult import coil.request.SuccessResult
@ -62,7 +60,6 @@ fun downloadItemAD(
val chaptersAdapter = BaseListAdapter<DownloadChapter>() val chaptersAdapter = BaseListAdapter<DownloadChapter>()
.addDelegate(ListItemType.CHAPTER_LIST, downloadChapterAD()) .addDelegate(ListItemType.CHAPTER_LIST, downloadChapterAD())
binding.recyclerViewChapters.addItemDecoration(DividerItemDecoration(context, RecyclerView.VERTICAL))
binding.recyclerViewChapters.adapter = chaptersAdapter binding.recyclerViewChapters.adapter = chaptersAdapter
binding.buttonCancel.setOnClickListener(clickListener) binding.buttonCancel.setOnClickListener(clickListener)
binding.buttonPause.setOnClickListener(clickListener) binding.buttonPause.setOnClickListener(clickListener)

@ -150,9 +150,9 @@ class LocalMangaRepository @Inject constructor(
return channelFlow { return channelFlow {
for (file in files) { for (file in files) {
launch { launch {
val mangaInput = LocalMangaInput.of(file) val mangaInput = LocalMangaInput.ofOrNull(file)
runCatchingCancellable { runCatchingCancellable {
val mangaInfo = mangaInput.getMangaInfo() val mangaInfo = mangaInput?.getMangaInfo()
if (mangaInfo != null && mangaInfo.id == remoteManga.id) { if (mangaInfo != null && mangaInfo.id == remoteManga.id) {
send(mangaInput) send(mangaInput)
} }

@ -33,7 +33,7 @@ class ReaderBottomMenuProvider(
override fun onMenuItemSelected(menuItem: MenuItem): Boolean { override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
return when (menuItem.itemId) { return when (menuItem.itemId) {
R.id.action_pages_thumbs -> { R.id.action_pages_thumbs -> {
ChaptersPagesSheet.show(activity.supportFragmentManager, ChaptersPagesSheet.TAB_PAGES) ChaptersPagesSheet.show(activity.supportFragmentManager)
true true
} }

@ -48,9 +48,7 @@ class SearchSuggestionFragment :
addMenuProvider(SearchSuggestionMenuProvider(binding.root.context, voiceInputLauncher, viewModel)) addMenuProvider(SearchSuggestionMenuProvider(binding.root.context, voiceInputLauncher, viewModel))
binding.root.adapter = adapter binding.root.adapter = adapter
binding.root.setHasFixedSize(true) binding.root.setHasFixedSize(true)
viewModel.suggestion.observe(viewLifecycleOwner) { viewModel.suggestion.observe(viewLifecycleOwner, adapter)
adapter.items = it
}
ItemTouchHelper(SearchSuggestionItemCallback(this)) ItemTouchHelper(SearchSuggestionItemCallback(this))
.attachToRecyclerView(binding.root) .attachToRecyclerView(binding.root)
} }

@ -73,7 +73,7 @@ class SearchSuggestionViewModel @Inject constructor(
} }
fun clearSearchHistory() { fun clearSearchHistory() {
launchJob { launchJob(Dispatchers.Default) {
repository.clearSearchHistory() repository.clearSearchHistory()
setupSuggestion() setupSuggestion()
} }
@ -93,7 +93,7 @@ class SearchSuggestionViewModel @Inject constructor(
} }
fun deleteQuery(query: String) { fun deleteQuery(query: String) {
launchJob { launchJob(Dispatchers.Default) {
repository.deleteSearchQuery(query) repository.deleteSearchQuery(query)
setupSuggestion() setupSuggestion()
} }

@ -129,7 +129,7 @@
<TextView <TextView
android:id="@+id/textView_state" android:id="@+id/textView_state"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
@ -141,11 +141,11 @@
android:textColor="?colorTertiary" android:textColor="?colorTertiary"
android:textStyle="bold" android:textStyle="bold"
app:drawableTint="?colorTertiary" app:drawableTint="?colorTertiary"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/imageView_state" app:layout_constraintStart_toEndOf="@id/imageView_state"
app:layout_constraintTop_toBottomOf="@id/textView_subtitle" app:layout_constraintTop_toBottomOf="@id/textView_subtitle"
app:layout_constraintWidth_default="wrap"
tools:text="@string/state_ongoing" /> tools:text="@string/state_ongoing" />
<RatingBar <RatingBar

@ -123,7 +123,7 @@
<TextView <TextView
android:id="@+id/textView_state" android:id="@+id/textView_state"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
@ -135,11 +135,11 @@
android:textColor="?colorTertiary" android:textColor="?colorTertiary"
android:textStyle="bold" android:textStyle="bold"
app:drawableTint="?colorTertiary" app:drawableTint="?colorTertiary"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/imageView_state" app:layout_constraintStart_toEndOf="@id/imageView_state"
app:layout_constraintTop_toBottomOf="@id/textView_subtitle" app:layout_constraintTop_toBottomOf="@id/textView_subtitle"
app:layout_constraintWidth_default="wrap"
tools:text="@string/state_ongoing" /> tools:text="@string/state_ongoing" />
<RatingBar <RatingBar

@ -80,20 +80,20 @@
<TextView <TextView
android:id="@+id/textView_subtitle" android:id="@+id/textView_subtitle"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_normal" android:layout_marginStart="@dimen/margin_normal"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:singleLine="true" android:singleLine="true"
android:textAppearance="?attr/textAppearanceBodySmall" android:textAppearance="?attr/textAppearanceBodySmall"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/imageView_visible" app:layout_constraintEnd_toStartOf="@id/imageView_visible"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/imageView_cover3" app:layout_constraintStart_toEndOf="@id/imageView_cover3"
app:layout_constraintTop_toBottomOf="@id/textView_title" app:layout_constraintTop_toBottomOf="@id/textView_title"
app:layout_constraintVertical_chainStyle="packed" app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintWidth_default="wrap"
tools:text="@tools:sample/lorem[1]" /> tools:text="@tools:sample/lorem[1]" />
<ImageView <ImageView

@ -80,13 +80,14 @@
<TextView <TextView
android:id="@+id/textView_subtitle" android:id="@+id/textView_subtitle"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_normal" android:layout_marginStart="@dimen/margin_normal"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:singleLine="true" android:singleLine="true"
android:textAppearance="?attr/textAppearanceBodySmall" android:textAppearance="?attr/textAppearanceBodySmall"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/imageView_tracker" app:layout_constraintEnd_toStartOf="@id/imageView_tracker"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
@ -94,7 +95,6 @@
app:layout_constraintStart_toEndOf="@id/imageView_cover3" app:layout_constraintStart_toEndOf="@id/imageView_cover3"
app:layout_constraintTop_toBottomOf="@id/textView_title" app:layout_constraintTop_toBottomOf="@id/textView_title"
app:layout_constraintVertical_chainStyle="packed" app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintWidth_default="wrap"
tools:text="@tools:sample/lorem[1]" /> tools:text="@tools:sample/lorem[1]" />
<ImageView <ImageView

@ -3,7 +3,7 @@
<style name="Base.V23.Kotatsu" parent="Base.Theme.Kotatsu"> <style name="Base.V23.Kotatsu" parent="Base.Theme.Kotatsu">
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item> <item name="android:navigationBarColor">@color/dim</item>
</style> </style>
<style name="Theme.Kotatsu" parent="Base.V23.Kotatsu" /> <style name="Theme.Kotatsu" parent="Base.V23.Kotatsu" />

@ -3,6 +3,7 @@
<style name="Base.V27.Kotatsu" parent="Base.V23.Kotatsu"> <style name="Base.V27.Kotatsu" parent="Base.V23.Kotatsu">
<item name="android:windowLightNavigationBar">@bool/light_navigation_bar</item> <item name="android:windowLightNavigationBar">@bool/light_navigation_bar</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style> </style>
<style name="Theme.Kotatsu" parent="Base.V27.Kotatsu" /> <style name="Theme.Kotatsu" parent="Base.V27.Kotatsu" />

Loading…
Cancel
Save