mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Fixing various warnings
along with some new methods for insets compat (which ill tackle again after m3
This commit is contained in:
parent
c23cd3c9a1
commit
d30e2c41e7
8 changed files with 35 additions and 21 deletions
|
@ -176,7 +176,7 @@ class DownloadCache(
|
|||
* @param manga the manga of the chapter.
|
||||
*/
|
||||
@Synchronized
|
||||
fun addChapter(chapterDirName: String, mangaUniFile: UniFile, manga: Manga) {
|
||||
fun addChapter(chapterDirName: String, manga: Manga) {
|
||||
val id = manga.id ?: return
|
||||
val files = mangaFiles[id]
|
||||
if (files == null) {
|
||||
|
|
|
@ -366,7 +366,7 @@ class DownloadManager(val context: Context) {
|
|||
val oldFolder = mangaDir.findFile(oldName)
|
||||
if (oldFolder?.renameTo(newName) == true) {
|
||||
cache.removeChapters(listOf(oldChapter), manga)
|
||||
cache.addChapter(newName, mangaDir, manga)
|
||||
cache.addChapter(newName, manga)
|
||||
} else {
|
||||
Timber.e("Could not rename downloaded chapter: %s.", oldName)
|
||||
}
|
||||
|
|
|
@ -520,7 +520,7 @@ class Downloader(
|
|||
// Only rename the directory if it's downloaded.
|
||||
if (download.status == Download.State.DOWNLOADED) {
|
||||
tmpDir.renameTo(dirname)
|
||||
cache.addChapter(dirname, mangaDir, download.manga)
|
||||
cache.addChapter(dirname, download.manga)
|
||||
|
||||
DiskUtil.createNoMediaFile(tmpDir, context)
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.view.MenuInflater
|
|||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.WindowInsetsCompat.Type.systemBars
|
||||
import androidx.core.view.updatePaddingRelative
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.jakewharton.rxbinding.support.v7.widget.queryTextChangeEvents
|
||||
|
@ -22,6 +23,8 @@ import eu.kanade.tachiyomi.ui.main.SearchActivity
|
|||
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
|
||||
import eu.kanade.tachiyomi.util.addOrRemoveToFavorites
|
||||
import eu.kanade.tachiyomi.util.system.rootWindowInsetsCompat
|
||||
import eu.kanade.tachiyomi.util.view.activityBinding
|
||||
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.util.view.toolbarHeight
|
||||
|
@ -183,7 +186,7 @@ open class GlobalSearchController(
|
|||
|
||||
binding.recycler.updatePaddingRelative(
|
||||
top = (toolbarHeight ?: 0) +
|
||||
(activity?.window?.decorView?.rootWindowInsets?.systemWindowInsetTop ?: 0)
|
||||
(activityBinding?.root?.rootWindowInsetsCompat?.getInsets(systemBars())?.top ?: 0)
|
||||
)
|
||||
|
||||
// Create recycler and set adapter.
|
||||
|
|
|
@ -12,7 +12,12 @@ import android.webkit.WebChromeClient
|
|||
import android.webkit.WebView
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.graphics.Insets
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsCompat.Type.systemBars
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
|
@ -59,7 +64,7 @@ open class BaseWebViewActivity : BaseActivity<WebviewActivityBinding>() {
|
|||
container.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
|
||||
container.setOnApplyWindowInsetsListener { v, insets ->
|
||||
ViewCompat.setOnApplyWindowInsetsListener(container) { v, insets ->
|
||||
val contextView = window?.decorView?.findViewById<View>(R.id.action_mode_bar)
|
||||
contextView?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
leftMargin = insets.systemWindowInsetLeft
|
||||
|
@ -68,15 +73,15 @@ open class BaseWebViewActivity : BaseActivity<WebviewActivityBinding>() {
|
|||
// Consume any horizontal insets and pad all content in. There's not much we can do
|
||||
// with horizontal insets
|
||||
v.updatePadding(
|
||||
left = insets.systemWindowInsetLeft,
|
||||
right = insets.systemWindowInsetRight
|
||||
left = insets.getInsets(systemBars()).left,
|
||||
right = insets.getInsets(systemBars()).right
|
||||
)
|
||||
insets.replaceSystemWindowInsets(
|
||||
WindowInsetsCompat.Builder(insets).setInsets(systemBars(), Insets.of(
|
||||
0,
|
||||
insets.systemWindowInsetTop,
|
||||
insets.getInsets(systemBars()).top,
|
||||
0,
|
||||
insets.systemWindowInsetBottom
|
||||
)
|
||||
insets.getInsets(systemBars()).bottom
|
||||
)).build()
|
||||
}
|
||||
binding.swipeRefresh.setStyle()
|
||||
binding.swipeRefresh.setOnRefreshListener {
|
||||
|
@ -88,7 +93,7 @@ open class BaseWebViewActivity : BaseActivity<WebviewActivityBinding>() {
|
|||
255
|
||||
)
|
||||
|
||||
content.setOnApplyWindowInsetsListener { v, insets ->
|
||||
ViewCompat.setOnApplyWindowInsetsListener(content) { v, insets ->
|
||||
// if pure white theme on a device that does not support dark status bar
|
||||
/*if (getResourceColor(android.R.attr.statusBarColor) != Color.TRANSPARENT)
|
||||
window.statusBarColor = Color.BLACK
|
||||
|
@ -99,13 +104,13 @@ open class BaseWebViewActivity : BaseActivity<WebviewActivityBinding>() {
|
|||
getResourceColor(R.attr.colorPrimaryVariant)
|
||||
}
|
||||
v.setPadding(
|
||||
insets.systemWindowInsetLeft,
|
||||
insets.systemWindowInsetTop,
|
||||
insets.systemWindowInsetRight,
|
||||
insets.getInsets(systemBars()).left,
|
||||
insets.getInsets(systemBars()).top,
|
||||
insets.getInsets(systemBars()).right,
|
||||
0
|
||||
)
|
||||
if (Build.VERSION.SDK_INT >= 26 && !isInNightMode()) {
|
||||
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||
if (!isInNightMode()) {
|
||||
WindowInsetsControllerCompat(window, content).isAppearanceLightNavigationBars = true
|
||||
}
|
||||
insets
|
||||
}
|
||||
|
@ -127,8 +132,8 @@ open class BaseWebViewActivity : BaseActivity<WebviewActivityBinding>() {
|
|||
}
|
||||
}
|
||||
val marginB = binding.webview.marginBottom
|
||||
binding.swipeRefresh.setOnApplyWindowInsetsListener { v, insets ->
|
||||
val bottomInset = insets.systemWindowInsetBottom
|
||||
ViewCompat.setOnApplyWindowInsetsListener(binding.swipeRefresh) { v, insets ->
|
||||
val bottomInset = insets.getInsets(systemBars()).bottom
|
||||
v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = marginB + bottomInset
|
||||
}
|
||||
|
|
|
@ -108,7 +108,6 @@ object ImageUtil {
|
|||
val midX = image.width / 2
|
||||
val midY = image.height / 2
|
||||
val offsetX = (image.width * 0.01).toInt()
|
||||
val offsetY = (image.height * 0.01).toInt()
|
||||
val topLeftIsDark = isDark(image.getPixel(left, top))
|
||||
val topRightIsDark = isDark(image.getPixel(right, top))
|
||||
val midLeftIsDark = isDark(image.getPixel(left, midY))
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package eu.kanade.tachiyomi.util.system
|
||||
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
|
||||
fun WindowInsets.getBottomGestureInsets(): Int {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) mandatorySystemGestureInsets.bottom
|
||||
|
@ -17,6 +19,9 @@ fun WindowInsets.isBottomTappable() = (
|
|||
|
||||
fun WindowInsets.hasSideInsets() = systemWindowInsetLeft > 0 || systemWindowInsetRight > 0
|
||||
|
||||
val View.rootWindowInsetsCompat
|
||||
get() = rootWindowInsets?.let { WindowInsetsCompat.toWindowInsetsCompat(it) }
|
||||
|
||||
/** returns if device is in landscape with 2/3 button mode */
|
||||
fun WindowInsets.hasSideNavBar() =
|
||||
(systemWindowInsetLeft > 0 || systemWindowInsetRight > 0) && !isBottomTappable() &&
|
||||
|
|
|
@ -6,11 +6,13 @@ import android.util.AttributeSet
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.WindowInsetsCompat.Type.systemBars
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import eu.kanade.tachiyomi.databinding.TabbedBottomSheetBinding
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.rootWindowInsetsCompat
|
||||
import eu.kanade.tachiyomi.util.view.expand
|
||||
import kotlin.math.max
|
||||
|
||||
|
@ -21,7 +23,7 @@ abstract class TabbedBottomSheetDialog(private val activity: Activity) :
|
|||
|
||||
open var offset = -1
|
||||
init {
|
||||
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetTop
|
||||
val height = activity.window.decorView.rootWindowInsetsCompat!!.getInsets(systemBars()).top
|
||||
binding.pager.maxHeight = activity.window.decorView.height - height - 125.dpToPx
|
||||
|
||||
val adapter = TabbedSheetAdapter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue