diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt index 0ca469716..faf9c6113 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt @@ -252,7 +252,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) { val defaultDetailsTab: Int 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) { lastDetailsTab } else { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/BaseFullscreenActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/BaseFullscreenActivity.kt index 786475efe..7c9937ab0 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/BaseFullscreenActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/BaseFullscreenActivity.kt @@ -19,7 +19,7 @@ abstract class BaseFullscreenActivity : with(window) { systemUiController = SystemUiController(this) 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) } else { Color.TRANSPARENT diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/list/fastscroll/FastScroller.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/list/fastscroll/FastScroller.kt index 55479d2d2..0c31b0a1a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/list/fastscroll/FastScroller.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/list/fastscroll/FastScroller.kt @@ -67,7 +67,7 @@ class FastScroller @JvmOverloads constructor( private var hideScrollbar = true private var showBubble = true private var showBubbleAlways = false - private var bubbleSize = BubbleSize.NORMAL + private var bubbleSize = BubbleSize.SMALL private var bubbleImage: Drawable? = null private var handleImage: Drawable? = null private var trackImage: Drawable? = null @@ -91,7 +91,7 @@ class FastScroller @JvmOverloads constructor( if (showBubbleAlways) { 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) showBubbleAlways = getBoolean(R.styleable.FastScrollRecyclerView_showBubbleAlways, showBubbleAlways) 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) binding.bubble.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize) offset = getDimensionPixelOffset(R.styleable.FastScrollRecyclerView_scrollerOffset, offset) @@ -473,7 +473,7 @@ class FastScroller @JvmOverloads constructor( val layoutManager = recyclerView?.layoutManager ?: return val targetPos = getRecyclerViewTargetPosition(y) 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) { @@ -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 @Px get() = resources.getDimension(textSizeId) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/SystemUiController.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/SystemUiController.kt index d5887d12f..0d67e899a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/SystemUiController.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/SystemUiController.kt @@ -33,23 +33,30 @@ sealed class SystemUiController( private class LegacyImpl(window: Window) : SystemUiController(window) { override fun setSystemUiVisible(value: Boolean) { + val flags = window.decorView.systemUiVisibility window.decorView.systemUiVisibility = if (value) { - View.SYSTEM_UI_FLAG_LAYOUT_STABLE or - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + (flags and LEGACY_FLAGS_HIDDEN.inv()) or LEGACY_FLAGS_VISIBLE } else { - 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 + (flags and LEGACY_FLAGS_VISIBLE.inv()) or LEGACY_FLAGS_HIDDEN } } } 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 = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { Api30Impl(window) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Android.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Android.kt index b59e93a20..c4cfacc82 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Android.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Android.kt @@ -37,6 +37,7 @@ import androidx.appcompat.app.AppCompatDialog import androidx.core.app.ActivityOptionsCompat import androidx.core.app.NotificationManagerCompat import androidx.core.content.ContextCompat +import androidx.core.graphics.ColorUtils import androidx.core.os.LocaleListCompat import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment @@ -140,6 +141,9 @@ fun Window.setNavigationBarTransparentCompat(context: Context, elevation: Float, !context.getSystemBoolean("config_navBarNeedsScrim", true) ) { 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 { // Set navbar scrim 70% of navigationBarColor ElevationOverlayProvider(context).compositeOverlayIfNeeded( diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadItemAD.kt b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadItemAD.kt index cfa2a06c5..6e913b492 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadItemAD.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/list/DownloadItemAD.kt @@ -5,9 +5,7 @@ import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.lifecycleScope -import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView import androidx.work.WorkInfo import coil.ImageLoader import coil.request.SuccessResult @@ -62,7 +60,6 @@ fun downloadItemAD( val chaptersAdapter = BaseListAdapter() .addDelegate(ListItemType.CHAPTER_LIST, downloadChapterAD()) - binding.recyclerViewChapters.addItemDecoration(DividerItemDecoration(context, RecyclerView.VERTICAL)) binding.recyclerViewChapters.adapter = chaptersAdapter binding.buttonCancel.setOnClickListener(clickListener) binding.buttonPause.setOnClickListener(clickListener) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/LocalMangaRepository.kt b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/LocalMangaRepository.kt index c23006663..8bdf9a78d 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/LocalMangaRepository.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/LocalMangaRepository.kt @@ -150,9 +150,9 @@ class LocalMangaRepository @Inject constructor( return channelFlow { for (file in files) { launch { - val mangaInput = LocalMangaInput.of(file) + val mangaInput = LocalMangaInput.ofOrNull(file) runCatchingCancellable { - val mangaInfo = mangaInput.getMangaInfo() + val mangaInfo = mangaInput?.getMangaInfo() if (mangaInfo != null && mangaInfo.id == remoteManga.id) { send(mangaInput) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderBottomMenuProvider.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderBottomMenuProvider.kt index d69448ef5..ab1013374 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderBottomMenuProvider.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderBottomMenuProvider.kt @@ -33,7 +33,7 @@ class ReaderBottomMenuProvider( override fun onMenuItemSelected(menuItem: MenuItem): Boolean { return when (menuItem.itemId) { R.id.action_pages_thumbs -> { - ChaptersPagesSheet.show(activity.supportFragmentManager, ChaptersPagesSheet.TAB_PAGES) + ChaptersPagesSheet.show(activity.supportFragmentManager) true } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionFragment.kt index 58ec1eac3..0e9e6721e 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionFragment.kt @@ -48,9 +48,7 @@ class SearchSuggestionFragment : addMenuProvider(SearchSuggestionMenuProvider(binding.root.context, voiceInputLauncher, viewModel)) binding.root.adapter = adapter binding.root.setHasFixedSize(true) - viewModel.suggestion.observe(viewLifecycleOwner) { - adapter.items = it - } + viewModel.suggestion.observe(viewLifecycleOwner, adapter) ItemTouchHelper(SearchSuggestionItemCallback(this)) .attachToRecyclerView(binding.root) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionViewModel.kt index 0aff417cb..d64878802 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionViewModel.kt @@ -73,7 +73,7 @@ class SearchSuggestionViewModel @Inject constructor( } fun clearSearchHistory() { - launchJob { + launchJob(Dispatchers.Default) { repository.clearSearchHistory() setupSuggestion() } @@ -93,7 +93,7 @@ class SearchSuggestionViewModel @Inject constructor( } fun deleteQuery(query: String) { - launchJob { + launchJob(Dispatchers.Default) { repository.deleteSearchQuery(query) setupSuggestion() } diff --git a/app/src/main/res/layout-w600dp-land/activity_details.xml b/app/src/main/res/layout-w600dp-land/activity_details.xml index 70dae8b17..cb96897e4 100644 --- a/app/src/main/res/layout-w600dp-land/activity_details.xml +++ b/app/src/main/res/layout-w600dp-land/activity_details.xml @@ -129,7 +129,7 @@ @android:color/transparent - @android:color/transparent + @color/dim