fix: improve contrast of watch progress on thumbnails

This commit is contained in:
Bnyro 2023-07-24 14:12:11 +02:00
parent 784dbd3edd
commit 3ab5b4de8a
3 changed files with 15 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import android.app.Activity
import android.content.ComponentName
import android.content.Context
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.text.Spanned
import android.util.TypedValue
import androidx.appcompat.app.AppCompatActivity
@ -131,4 +132,9 @@ object ThemeHelper {
return "Libre<span style='color:$hexColor';>Tube</span>"
.parseAsHtml(HtmlCompat.FROM_HTML_MODE_COMPACT)
}
fun isDarkMode(context: Context): Boolean {
val darkModeFlag = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
return darkModeFlag == Configuration.UI_MODE_NIGHT_YES
}
}

View File

@ -1,9 +1,13 @@
package com.github.libretube.ui.extensions
import android.graphics.Color
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.graphics.ColorUtils
import androidx.core.view.updateLayoutParams
import com.github.libretube.db.DatabaseHolder.Database
import com.github.libretube.helpers.ThemeHelper
import com.google.android.material.color.MaterialColors
import kotlinx.coroutines.runBlocking
/**
@ -15,6 +19,10 @@ fun View.setWatchProgressLength(videoId: String, duration: Long) {
updateLayoutParams<ConstraintLayout.LayoutParams> {
matchConstraintPercentWidth = 0f
}
var backgroundColor = MaterialColors.getColor(this, com.google.android.material.R.attr.colorPrimaryDark)
// increase the brightness for better contrast in light mode
if (!ThemeHelper.isDarkMode(context)) backgroundColor = ColorUtils.blendARGB(backgroundColor, Color.WHITE, 0.4f)
setBackgroundColor(backgroundColor)
visibility = View.GONE
val progress = try {

View File

@ -125,7 +125,7 @@
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">4dp</item>
<item name="android:background">?attr/colorPrimaryDark</item>
<item name="android:background">?colorPrimaryDark</item>
<item name="android:visibility">gone</item>
</style>