From acabe9217bec62170dc85eb2dd44cedc94943c34 Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Mon, 30 Aug 2021 20:19:52 -0600 Subject: [PATCH] ui: use colorOnSurface Use colorOnSurface for the first time ever. I decided to pick a color that was as non-intrusive as possible that was still differentiateable, and I think it looks like a net improvement. It will probably be tweaked a bit in the future as I expand it to other elevated views. --- .../java/org/oxycblt/auxio/MainActivity.kt | 33 +++++++++++++------ app/src/main/res/layout/fragment_home.xml | 2 +- app/src/main/res/layout/fragment_search.xml | 2 +- app/src/main/res/values/colors.xml | 18 +++++++++- app/src/main/res/values/styles_core.xml | 6 ++-- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/MainActivity.kt b/app/src/main/java/org/oxycblt/auxio/MainActivity.kt index 038dfae4a..6c76ba584 100644 --- a/app/src/main/java/org/oxycblt/auxio/MainActivity.kt +++ b/app/src/main/java/org/oxycblt/auxio/MainActivity.kt @@ -33,7 +33,6 @@ import org.oxycblt.auxio.databinding.ActivityMainBinding import org.oxycblt.auxio.playback.PlaybackViewModel import org.oxycblt.auxio.playback.system.PlaybackService import org.oxycblt.auxio.settings.SettingsManager -import org.oxycblt.auxio.util.applyEdge import org.oxycblt.auxio.util.isNight import org.oxycblt.auxio.util.logD @@ -54,12 +53,6 @@ class MainActivity : AppCompatActivity() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { applyEdgeToEdgeWindow(binding) - - // If there are left/right insets [signalling that we are in phone landscape mode], - // we will always apply them. - binding.applyEdge { bars -> - binding.root.updatePadding(left = bars.left, right = bars.right) - } } else { binding.root.fitsSystemWindows = true } @@ -126,15 +119,35 @@ class MainActivity : AppCompatActivity() { WindowInsets.Type.systemBars(), insets.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars()) ) - .build() + .build().also { + val bars = it.getInsets(WindowInsets.Type.systemBars()) + + // If left/right insets are present [implying phone landscape mode], + // make sure that we apply them. + binding.root.updatePadding( + left = bars.left, + right = bars.right + ) + } } } else { // Do old edge-to-edge otherwise. logD("Doing legacy edge-to-edge.") @Suppress("DEPRECATION") - binding.root.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or - View.SYSTEM_UI_FLAG_LAYOUT_STABLE + binding.root.apply { + systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + + setOnApplyWindowInsetsListener { v, insets -> + updatePadding( + left = insets.systemWindowInsetLeft, + right = insets.systemWindowInsetRight + ) + + insets + } + } } } diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 8b67313d7..0a9894b7d 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -21,7 +21,7 @@ android:elevation="@dimen/elevation_normal" android:focusable="true"> - + #fffafafa - #ff151515 + #ff121212 #ff000000 + + #606060 + #CDCDCD + + @color/surface_day #cbcbcb #202020 diff --git a/app/src/main/res/values/styles_core.xml b/app/src/main/res/values/styles_core.xml index d87234f73..13a850385 100644 --- a/app/src/main/res/values/styles_core.xml +++ b/app/src/main/res/values/styles_core.xml @@ -9,13 +9,10 @@