-
-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added subtitles background opacity option
- Loading branch information
Showing
5 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/src/main/java/org/jellyfin/androidtv/util/ColorUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.jellyfin.androidtv.util | ||
|
||
import android.util.Log | ||
import okhttp3.internal.toHexString | ||
import timber.log.Timber | ||
import kotlin.math.roundToLong | ||
|
||
/** | ||
* Adds an opacity to a Long color. | ||
* Conversion to java.lang.Long is required for usage in VideoManager.java | ||
* @param opacity Opacity as a float in range 0..1 | ||
* @return `this` color with opacity | ||
*/ | ||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") | ||
fun Long.withOpacity(opacity: Float): java.lang.Long { | ||
if (opacity > 1f) { | ||
throw IllegalArgumentException("Opacity must be lower or equal to 1") | ||
} | ||
|
||
val op = ((opacity * 255).roundToLong() shl 24) or 0xFFFFFF | ||
|
||
Timber.d((this and op).toHexString()) | ||
|
||
return (this and op) as java.lang.Long | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters