Translucent Nav Bar now follows app background instead of just being black/white
Cleanup of warnings
This commit is contained in:
parent
72e7b649a2
commit
70ba5cd0e8
@ -232,7 +232,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
|
|
||||||
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
|
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
|
||||||
when (ev?.action) {
|
when (ev?.action) {
|
||||||
MotionEvent.ACTION_UP -> lastTouchUpY = ev?.y
|
MotionEvent.ACTION_UP -> lastTouchUpY = ev.y
|
||||||
}
|
}
|
||||||
return super.dispatchTouchEvent(ev)
|
return super.dispatchTouchEvent(ev)
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ class LibraryController(
|
|||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
val statusScrim = view.findViewById(R.id.status_bar_scrim) as View
|
val statusScrim = view.findViewById(R.id.status_bar_scrim) as View
|
||||||
statusScrim.setOnApplyWindowInsetsListener(HeightTopWindowInsetsListener)
|
statusScrim.setOnApplyWindowInsetsListener(HeightTopWindowInsetsListener)
|
||||||
view.doOnApplyWindowInsets { v, insets, padding ->
|
view.doOnApplyWindowInsets { _, insets, _ ->
|
||||||
view.recycler.updatePaddingRelative(
|
view.recycler.updatePaddingRelative(
|
||||||
bottom = view.recycler.marginBottom + insets.systemWindowInsetBottom,
|
bottom = view.recycler.marginBottom + insets.systemWindowInsetBottom,
|
||||||
top = view.recycler.marginTop + insets.systemWindowInsetTop
|
top = view.recycler.marginTop + insets.systemWindowInsetTop
|
||||||
|
@ -16,6 +16,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import androidx.core.graphics.ColorUtils
|
||||||
import com.bluelinelabs.conductor.*
|
import com.bluelinelabs.conductor.*
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import eu.kanade.tachiyomi.Migrations
|
import eu.kanade.tachiyomi.Migrations
|
||||||
@ -33,8 +34,8 @@ import eu.kanade.tachiyomi.ui.manga.MangaController
|
|||||||
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
|
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
|
||||||
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
||||||
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
||||||
import eu.kanade.tachiyomi.util.NoopWindowInsetsListener
|
|
||||||
import eu.kanade.tachiyomi.util.doOnApplyWindowInsets
|
import eu.kanade.tachiyomi.util.doOnApplyWindowInsets
|
||||||
|
import eu.kanade.tachiyomi.util.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.launchUI
|
import eu.kanade.tachiyomi.util.launchUI
|
||||||
import eu.kanade.tachiyomi.util.marginBottom
|
import eu.kanade.tachiyomi.util.marginBottom
|
||||||
import eu.kanade.tachiyomi.util.marginTop
|
import eu.kanade.tachiyomi.util.marginTop
|
||||||
@ -141,12 +142,6 @@ class MainActivity : BaseActivity() {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/*nav_view.doOnApplyWindowInsets { v, insets, padding ->
|
|
||||||
v.updatePaddingRelative(
|
|
||||||
start = padding.left + insets.systemWindowInsetLeft
|
|
||||||
)
|
|
||||||
}*/
|
|
||||||
|
|
||||||
val container: ViewGroup = findViewById(R.id.controller_container)
|
val container: ViewGroup = findViewById(R.id.controller_container)
|
||||||
|
|
||||||
val content: LinearLayout = findViewById(R.id.main_content)
|
val content: LinearLayout = findViewById(R.id.main_content)
|
||||||
@ -156,13 +151,32 @@ class MainActivity : BaseActivity() {
|
|||||||
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
nav_view.doOnApplyWindowInsets { v, insets, padding ->
|
nav_view.doOnApplyWindowInsets { v, _, _ ->
|
||||||
v.updatePaddingRelative(
|
v.updatePaddingRelative(
|
||||||
bottom = v.marginBottom,
|
bottom = v.marginBottom,
|
||||||
top = v.marginTop
|
top = v.marginTop
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
content.setOnApplyWindowInsetsListener(NoopWindowInsetsListener)
|
content.setOnApplyWindowInsetsListener { v, insets ->
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||||
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M &&
|
||||||
|
(v.rootWindowInsets.systemWindowInsetLeft > 0 ||
|
||||||
|
v.rootWindowInsets.systemWindowInsetRight > 0))
|
||||||
|
window.navigationBarColor = Color.BLACK
|
||||||
|
else window.navigationBarColor = Color.argb(179, 0, 0, 0)
|
||||||
|
} else if (v.rootWindowInsets.systemWindowInsetLeft > 0
|
||||||
|
|| v.rootWindowInsets.systemWindowInsetRight > 0) {
|
||||||
|
window.navigationBarColor =
|
||||||
|
v.context.getResourceColor(android.R.attr.colorBackground)
|
||||||
|
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q
|
||||||
|
|| insets.tappableElementInsets.bottom > 0) {
|
||||||
|
window.navigationBarColor = ColorUtils.setAlphaComponent(
|
||||||
|
v.context.getResourceColor(android.R.attr.colorBackground), 179)
|
||||||
|
} else window.navigationBarColor = getColor(android.R.color.transparent)
|
||||||
|
v.setPadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop,
|
||||||
|
insets.systemWindowInsetRight, 0)
|
||||||
|
insets
|
||||||
|
}
|
||||||
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||||
if (Build.VERSION.SDK_INT >= 26 && currentNightMode == Configuration.UI_MODE_NIGHT_NO) {
|
if (Build.VERSION.SDK_INT >= 26 && currentNightMode == Configuration.UI_MODE_NIGHT_NO) {
|
||||||
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||||
|
@ -174,7 +174,7 @@ class SettingsAboutController : SettingsController() {
|
|||||||
try {
|
try {
|
||||||
val inputDf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'", Locale.US)
|
val inputDf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'", Locale.US)
|
||||||
inputDf.timeZone = TimeZone.getTimeZone("UTC")
|
inputDf.timeZone = TimeZone.getTimeZone("UTC")
|
||||||
val date = inputDf.parse(BuildConfig.BUILD_TIME)
|
val date = inputDf.parse(BuildConfig.BUILD_TIME) ?: return BuildConfig.BUILD_TIME
|
||||||
|
|
||||||
val outputDf = DateFormat.getDateTimeInstance(
|
val outputDf = DateFormat.getDateTimeInstance(
|
||||||
DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault())
|
DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault())
|
||||||
|
@ -136,14 +136,6 @@ inline val View.marginRight: Int
|
|||||||
inline val View.marginLeft: Int
|
inline val View.marginLeft: Int
|
||||||
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.leftMargin ?: 0
|
get() = (layoutParams as? ViewGroup.MarginLayoutParams)?.leftMargin ?: 0
|
||||||
|
|
||||||
object NoopWindowInsetsListener : View.OnApplyWindowInsetsListener {
|
|
||||||
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
|
||||||
v.setPadding(insets.systemWindowInsetLeft,insets.systemWindowInsetTop,insets.systemWindowInsetRight,0)
|
|
||||||
//insets.consumeSystemWindowInsets()
|
|
||||||
return insets
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object RecyclerWindowInsetsListener : View.OnApplyWindowInsetsListener {
|
object RecyclerWindowInsetsListener : View.OnApplyWindowInsetsListener {
|
||||||
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
||||||
v.setPadding(0,0,0,insets.systemWindowInsetBottom)
|
v.setPadding(0,0,0,insets.systemWindowInsetBottom)
|
||||||
|
Loading…
Reference in New Issue
Block a user