Skip to content

Commit

Permalink
New Animation on Player background
Browse files Browse the repository at this point in the history
  • Loading branch information
Arturo254 committed Sep 21, 2024
1 parent de33f30 commit f1e57c7
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 33 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {
//noinspection OldTargetApi
targetSdk = 34
versionCode = 25
versionName = "1.1.0"
versionName = "1.2.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down Expand Up @@ -122,6 +122,7 @@ dependencies {

implementation(libs.room.runtime)
implementation(libs.accompanist.coil)
implementation(libs.blurry)
ksp(libs.room.compiler)
implementation(libs.room.ktx)

Expand Down
Binary file modified app/foss/release/baselineProfiles/0/app-foss-release.dm
Binary file not shown.
Binary file modified app/foss/release/baselineProfiles/1/app-foss-release.dm
Binary file not shown.
2 changes: 1 addition & 1 deletion app/foss/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"filters": [],
"attributes": [],
"versionCode": 25,
"versionName": "1.1.0",
"versionName": "1.2.0",
"outputFile": "app-foss-release.apk"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ enum class PlayerBackgroundStyle {
val TopSize = stringPreferencesKey("topSize")
val HistoryDuration = floatPreferencesKey("historyDuration")

val SkipOnErrorKey = booleanPreferencesKey("skipOnError")

val PlayerBackgroundStyleKey = stringPreferencesKey("playerBackgroundStyle")
val ShowLyricsKey = booleanPreferencesKey("showLyrics")
val LyricsTextPositionKey = stringPreferencesKey("lyricsTextPosition")
Expand Down
56 changes: 31 additions & 25 deletions app/src/main/java/com/malopieds/innertune/ui/player/Player.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.graphics.drawable.BitmapDrawable
import android.text.format.Formatter
import android.widget.Toast
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateDpAsState
Expand Down Expand Up @@ -1046,33 +1047,38 @@ fun BottomSheetPlayer(
}
}

if (gradientColors.size >= 2 && state.isExpanded) {
Box(
modifier = Modifier
.fillMaxSize()
.background(Brush.verticalGradient(gradientColors)),
)
} else if (playerBackground == PlayerBackgroundStyle.BLUR) {
AsyncImage(
model = mediaMetadata?.thumbnailUrl,
contentDescription = null,
contentScale = ContentScale.FillBounds,
modifier = Modifier
.fillMaxSize()
.blur(200.dp)
.alpha(0.8f)
.background(if (useBlackBackground) Color.Black.copy(alpha = 0.5f) else Color.Transparent)
)

} else if (useBlackBackground && playerBackground == PlayerBackgroundStyle.DEFAULT) {
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Black)
)
}


AnimatedVisibility(
visible = state.isExpanded,
enter = fadeIn(tween(900)),
exit = fadeOut()
) {
if (gradientColors.size >= 2) {
Box(
modifier = Modifier
.fillMaxSize()
.background(Brush.verticalGradient(gradientColors)),
)
} else if (playerBackground == PlayerBackgroundStyle.BLUR) {
AsyncImage(
model = mediaMetadata?.thumbnailUrl,
contentDescription = null,
contentScale = ContentScale.FillBounds,
modifier = Modifier
.fillMaxSize()
.blur(200.dp)
.alpha(0.8f)
.background(if (useBlackBackground) Color.Black.copy(alpha = 0.5f) else Color.Transparent)
)
} else if (useBlackBackground && playerBackground == PlayerBackgroundStyle.DEFAULT) {
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Black)
)
}
}
//
when (LocalConfiguration.current.orientation) {
Configuration.ORIENTATION_LANDSCAPE -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fun HomeScreen(
) {
Button(onClick = {

navController.navigate("auto_playlist/downloads")
navController.navigate("library")
showNoInternetDialog = false
}) {
Text(stringResource(R.string.downloadspage))
Expand Down Expand Up @@ -239,6 +239,7 @@ fun HomeScreen(
}
}


quickPicks?.let { quickPicks ->
NavigationTitle(
title = stringResource(R.string.quick_picks),
Expand Down Expand Up @@ -718,12 +719,16 @@ fun HomeScreen(
}
}



homeFirstAlbumRecommendation?.albums?.let { albums ->
if (albums.recommendationAlbum.isNotEmpty()) {
NavigationTitle(
title = stringResource(R.string.similar_to) + " " + albums.recommendedAlbum.name,
)



LazyRow(
contentPadding =
WindowInsets.systemBars
Expand Down Expand Up @@ -759,13 +764,17 @@ fun HomeScreen(
}
},
).animateItemPlacement(),


)
}
}
}
}
}



homeFirstContinuation?.forEach { homePlaylists ->
if (homePlaylists.playlists.isNotEmpty()) {
homePlaylists.let { playlists ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.malopieds.innertune.ui.screens.settings

import android.os.Build
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image
import androidx.compose.foundation.border
Expand Down Expand Up @@ -286,18 +287,34 @@ fun AppearanceSettings(
title = stringResource(R.string.player),
)


// ...


// ...

val isBlurSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S

EnumListPreference(
title = { Text(stringResource(R.string.player_background_style)) },
icon = { Icon(painterResource(R.drawable.gradient), null) },
selectedValue = playerBackground,
onValueSelected = onPlayerBackgroundChange,
valueText = {
when (it) {
onValueSelected = { newValue ->
if (newValue != PlayerBackgroundStyle.BLUR || isBlurSupported) {
onPlayerBackgroundChange(newValue)
}
},
valueText = { style ->
when (style) {
PlayerBackgroundStyle.DEFAULT -> stringResource(R.string.follow_theme)
PlayerBackgroundStyle.GRADIENT -> stringResource(R.string.gradient)
PlayerBackgroundStyle.BLUR -> stringResource(R.string.blur)
PlayerBackgroundStyle.BLUR -> if (isBlurSupported) {
stringResource(R.string.blur)
} else {
stringResource(R.string.blur_not_supported)
}
}
},
}
)

PreferenceEntry(
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/fast_forward.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M100,645v-330q0,-18 12,-29t28,-11q5,0 11,1t11,5l248,166q9,6 13.5,14.5T428,480q0,10 -4.5,18.5T410,513L162,679q-5,4 -11,5t-11,1q-16,0 -28,-11t-12,-29ZM500,645v-330q0,-18 12,-29t28,-11q5,0 11,1t11,5l248,166q9,6 13.5,14.5T828,480q0,10 -4.5,18.5T810,513L562,679q-5,4 -11,5t-11,1q-16,0 -28,-11t-12,-29ZM180,480ZM580,480ZM180,570 L316,480 180,390v180ZM580,570 L716,480 580,390v180Z"
android:fillColor="#e8eaed"/>
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,5 @@
<string name="not_internet">Sin conexión a Internet</string>
<string name="internet_required">Parece que no tiene conexión a Internet. Por favor, compruebe su red.</string>
<string name="downloadspage">Ir a descargas</string>
<string name="blur_not_supported">Desenfoque no compatible</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,5 @@
<string name="not_internet">Sem conexão com a Internet</string>
<string name="internet_required">Parece que você não tem conexão com a Internet. Verifique sua rede.</string>
<string name="downloadspage">Ir para downloads</string>
<string name="blur_not_supported">Desfoque não suportado</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,5 @@
<string name="not_internet">No Internet Connection</string>
<string name="internet_required">It looks like you have no Internet connection. Please check your network.</string>
<string name="downloadspage">Go to downloads</string>
<string name="blur_not_supported">Blur not supported</string>
</resources>
6 changes: 6 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ ktor = "2.3.12"
ksp = "2.0.0-1.0.24"
squigglyslider = "1.0.0"
accompanistCoil = "0.15.0"
blurry = "4.0.1"
coilCompose = "2.7.0"
coil = "2.7.0"

[libraries]
annotation = { module = "androidx.annotation:annotation", version.ref = "annotation" }
Expand Down Expand Up @@ -82,6 +85,9 @@ junit = { group = "junit", name = "junit", version = "4.13.2" }

timber = { group = "com.jakewharton.timber", name = "timber", version = "5.0.1" }
accompanist-coil = { group = "com.google.accompanist", name = "accompanist-coil", version.ref = "accompanistCoil" }
blurry = { group = "jp.wasabeef", name = "blurry", version.ref = "blurry" }
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coilCompose" }
coil-kt-coil = { group = "io.coil-kt", name = "coil", version.ref = "coil" }

[plugins]
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
Expand Down

0 comments on commit f1e57c7

Please sign in to comment.