mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
fix: improve contrast of watch progress on thumbnails
This commit is contained in:
parent
784dbd3edd
commit
3ab5b4de8a
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user