Fix card selection colors light+dark mode

This commit is contained in:
Philipp Heckel 2022-04-29 11:29:56 -04:00
parent 4771ccc6c0
commit 699bcf7f06
6 changed files with 33 additions and 30 deletions

View file

@ -11,19 +11,23 @@ class Colors {
const val notificationIcon = R.color.teal
fun itemSelectedBackground(context: Context): Int {
return if (isDarkThemeOn(context)) R.color.gray_dark else R.color.gray_light
return if (isDarkThemeOn(context)) R.color.black_800b else R.color.gray_400
}
fun itemSelectedBackgroundColor(context: Context): Int {
return ContextCompat.getColor(context, itemSelectedBackground(context))
fun cardSelectedBackground(context: Context): Int {
return if (isDarkThemeOn(context)) R.color.black_700b else R.color.gray_500
}
fun cardSelectedBackgroundColor(context: Context): Int {
return ContextCompat.getColor(context, cardSelectedBackground(context))
}
fun statusBarNormal(context: Context): Int {
return if (isDarkThemeOn(context)) R.color.black_light else R.color.teal
return if (isDarkThemeOn(context)) R.color.black_900 else R.color.teal
}
fun statusBarActionMode(context: Context): Int {
return if (isDarkThemeOn(context)) R.color.black_light else R.color.teal_dark
return if (isDarkThemeOn(context)) R.color.black_900 else R.color.teal_dark
}
fun dangerText(context: Context): Int {

View file

@ -6,11 +6,9 @@ import android.content.*
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.drawable.RippleDrawable
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.os.Handler
import android.provider.MediaStore
import android.view.LayoutInflater
import android.view.View
@ -115,7 +113,7 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope:
tagsView.visibility = View.GONE
}
if (selected.contains(notification.id)) {
cardView.setCardBackgroundColor(Colors.itemSelectedBackgroundColor(context))
cardView.setCardBackgroundColor(Colors.cardSelectedBackgroundColor(context))
}
val attachment = notification.attachment
val exists = if (attachment?.contentUri != null) fileExists(context, attachment.contentUri) else false

View file

@ -8,7 +8,7 @@
tools:context=".ui.DetailActivity"
>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
style="@style/SwipeRefreshLayoutWithCards"
style="@style/CardViewBackground"
android:id="@+id/detail_notification_list_container"
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -13,12 +13,12 @@
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">@color/teal_light</item>
<item name="colorAccent">@color/teal_light</item> <!-- checkboxes, text fields -->
<item name="android:colorBackground">@color/black_light</item> <!-- background -->
<item name="android:statusBarColor">@color/black_light</item>
<item name="actionModeBackground">@color/black_light</item>
<item name="android:colorBackground">@color/black_900</item> <!-- background -->
<item name="android:statusBarColor">@color/black_900</item>
<item name="actionModeBackground">@color/black_900</item>
<!-- Action bar background & text color -->
<item name="colorSurface">@color/gray_dark</item>
<item name="colorSurface">@color/black_800b</item>
<item name="colorOnSurface">@color/white</item>
</style>
@ -27,15 +27,15 @@
</style>
<style name="FloatingActionButton" parent="@style/Widget.MaterialComponents.FloatingActionButton">
<item name="tint">@color/black_light</item>
<item name="tint">@color/black_900</item>
<item name="backgroundTint">@color/teal_light</item>
</style>
<style name="CardView" parent="@style/Widget.MaterialComponents.CardView">
<item name="cardBackgroundColor">@color/gray_dark</item>
<item name="cardBackgroundColor">@color/black_800b</item>
</style>
<style name="SwipeRefreshLayoutWithCards">
<item name="android:background">@color/black_light</item>
<style name="CardViewBackground">
<item name="android:background">@color/black_900</item>
</style>
</resources>

View file

@ -1,16 +1,17 @@
<!--?xml version="1.0" encoding="UTF-8"?-->
<resources>
<color name="black">#ff000000</color>
<color name="black_light">#121212</color> <!-- Main dark mode surface color, as per style guide -->
<color name="white">#ffffffff</color>
<color name="black">#ff000000</color>
<color name="black_900">#121212</color> <!-- Main dark mode surface color, as per style guide -->
<color name="black_800b">#1b2023</color> <!-- Action bar & item selection (dark mode); this has a touch of blue! -->
<color name="black_700b">#282F33</color> <!-- Card selection (dark mode); this has a touch of blue! -->
<color name="gray_500">#dddddd</color> <!-- Card selection (light mode) -->
<color name="gray_400">#eeeeee</color> <!-- Item selection (light mode) -->
<color name="white">#ffffffff</color>
<color name="teal">#338574</color> <!-- Primary color (light mode) -->
<color name="teal_light">#65b5a3</color> <!-- Primary color (dark mode) -->
<color name="teal_dark">#2a6e60</color> <!-- Action bar background in action mode (light mode) -->
<color name="red_light">#fe4d2e</color> <!-- Danger text (dark mode) -->
<color name="red_dark">#c30000</color> <!-- Danger text (light mode) -->
<color name="gray_light">#eeeeee</color> <!-- Light theme item selection -->
<color name="gray_dark">#1b2023</color> <!-- Dark mode action bar & item selection -->
<color name="teal">#338574</color> <!-- Primary color (light mode) -->
<color name="teal_light">#65b5a3</color> <!-- Primary color (dark mode) -->
<color name="teal_dark">#2a6e60</color> <!-- Action bar background in action mode (light mode) -->
<color name="red_light">#fe4d2e</color> <!-- Danger text (dark mode) -->
<color name="red_dark">#c30000</color> <!-- Danger text (light mode) -->
</resources>

View file

@ -21,8 +21,8 @@
<item name="cardBackgroundColor">@color/white</item>
</style>
<style name="SwipeRefreshLayoutWithCards">
<item name="android:background">@color/gray_light</item>
<style name="CardViewBackground">
<item name="android:background">@color/gray_400</item>
</style>
<!-- Rounded corners in images, see https://stackoverflow.com/a/61960983/1440785 -->