mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
feat: add a christmas background
This commit is contained in:
parent
df7bc61004
commit
295cffb6d6
@ -79,6 +79,9 @@
|
|||||||
<data android:scheme="spotube" />
|
<data android:scheme="spotube" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="es.antonborri.home_widget.action.LAUNCH" />
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- AudioService Config -->
|
<!-- AudioService Config -->
|
||||||
|
@ -12,22 +12,31 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.glance.GlanceId
|
import androidx.glance.GlanceId
|
||||||
import androidx.glance.GlanceModifier
|
import androidx.glance.GlanceModifier
|
||||||
import androidx.glance.GlanceTheme
|
import androidx.glance.GlanceTheme
|
||||||
|
import androidx.glance.Image
|
||||||
import androidx.glance.ImageProvider
|
import androidx.glance.ImageProvider
|
||||||
import androidx.glance.LocalSize
|
import androidx.glance.LocalSize
|
||||||
import androidx.glance.action.ActionParameters
|
import androidx.glance.action.ActionParameters
|
||||||
import androidx.glance.action.actionParametersOf
|
import androidx.glance.action.actionParametersOf
|
||||||
|
import androidx.glance.action.clickable
|
||||||
|
import androidx.glance.background
|
||||||
import androidx.glance.appwidget.GlanceAppWidget
|
import androidx.glance.appwidget.GlanceAppWidget
|
||||||
import androidx.glance.appwidget.SizeMode
|
import androidx.glance.appwidget.SizeMode
|
||||||
import androidx.glance.appwidget.action.ActionCallback
|
import androidx.glance.appwidget.action.ActionCallback
|
||||||
import androidx.glance.appwidget.action.actionRunCallback
|
import androidx.glance.appwidget.action.actionRunCallback
|
||||||
|
import androidx.glance.appwidget.background
|
||||||
import androidx.glance.appwidget.components.CircleIconButton
|
import androidx.glance.appwidget.components.CircleIconButton
|
||||||
import androidx.glance.appwidget.components.Scaffold
|
import androidx.glance.appwidget.components.Scaffold
|
||||||
|
import androidx.glance.appwidget.cornerRadius
|
||||||
import androidx.glance.appwidget.provideContent
|
import androidx.glance.appwidget.provideContent
|
||||||
|
import androidx.glance.background
|
||||||
import androidx.glance.currentState
|
import androidx.glance.currentState
|
||||||
import androidx.glance.layout.Alignment
|
import androidx.glance.layout.Alignment
|
||||||
|
import androidx.glance.layout.Box
|
||||||
import androidx.glance.layout.Column
|
import androidx.glance.layout.Column
|
||||||
|
import androidx.glance.layout.ContentScale
|
||||||
import androidx.glance.layout.Row
|
import androidx.glance.layout.Row
|
||||||
import androidx.glance.layout.Spacer
|
import androidx.glance.layout.Spacer
|
||||||
|
import androidx.glance.layout.fillMaxSize
|
||||||
import androidx.glance.layout.fillMaxWidth
|
import androidx.glance.layout.fillMaxWidth
|
||||||
import androidx.glance.layout.padding
|
import androidx.glance.layout.padding
|
||||||
import androidx.glance.layout.size
|
import androidx.glance.layout.size
|
||||||
@ -36,7 +45,10 @@ import androidx.glance.preview.Preview
|
|||||||
import androidx.glance.state.GlanceStateDefinition
|
import androidx.glance.state.GlanceStateDefinition
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import es.antonborri.home_widget.HomeWidgetBackgroundIntent
|
import es.antonborri.home_widget.HomeWidgetBackgroundIntent
|
||||||
|
import es.antonborri.home_widget.actionStartActivity
|
||||||
|
import oss.krtirtho.spotube.MainActivity
|
||||||
import oss.krtirtho.spotube.glance.models.Track
|
import oss.krtirtho.spotube.glance.models.Track
|
||||||
|
import oss.krtirtho.spotube.glance.widgets.FlutterAssetImageProvider
|
||||||
import oss.krtirtho.spotube.glance.widgets.TrackDetailsView
|
import oss.krtirtho.spotube.glance.widgets.TrackDetailsView
|
||||||
import oss.krtirtho.spotube.glance.widgets.TrackProgress
|
import oss.krtirtho.spotube.glance.widgets.TrackProgress
|
||||||
|
|
||||||
@ -83,23 +95,51 @@ class HomePlayerWidget : GlanceAppWidget() {
|
|||||||
val isPlaying = prefs.getBoolean("isPlaying", false)
|
val isPlaying = prefs.getBoolean("isPlaying", false)
|
||||||
val playbackServerAddress = prefs.getString("playbackServerAddress", null) ?: ""
|
val playbackServerAddress = prefs.getString("playbackServerAddress", null) ?: ""
|
||||||
|
|
||||||
Log.e("HomePlayerWidget", "Active track String: $activeTrackStr")
|
|
||||||
var activeTrack: Track? = null
|
var activeTrack: Track? = null
|
||||||
if (activeTrackStr != null) {
|
if (activeTrackStr != null) {
|
||||||
activeTrack = gson.fromJson(activeTrackStr, Track::class.java)
|
activeTrack = gson.fromJson(activeTrackStr, Track::class.java)
|
||||||
}
|
}
|
||||||
Log.e("HomePlayerWidget", "Active track: $activeTrack")
|
|
||||||
|
|
||||||
|
|
||||||
val playIcon = Icon.createWithResource(context, android.R.drawable.ic_media_play);
|
val playIcon = Icon.createWithResource(context, R.drawable.ic_media_play);
|
||||||
val pauseIcon = Icon.createWithResource(context, android.R.drawable.ic_media_pause);
|
val pauseIcon = Icon.createWithResource(context, R.drawable.ic_media_pause);
|
||||||
val previousIcon = Icon.createWithResource(context, android.R.drawable.ic_media_previous);
|
val previousIcon = Icon.createWithResource(context, R.drawable.ic_media_previous);
|
||||||
val nextIcon = Icon.createWithResource(context, android.R.drawable.ic_media_next);
|
val nextIcon = Icon.createWithResource(context, R.drawable.ic_media_next);
|
||||||
|
|
||||||
GlanceTheme {
|
GlanceTheme {
|
||||||
Scaffold {
|
Box(
|
||||||
|
modifier = GlanceModifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.cornerRadius(8.dp)
|
||||||
|
.background(
|
||||||
|
color = GlanceTheme.colors.surface.getColor(context)
|
||||||
|
)
|
||||||
|
.clickable {
|
||||||
|
actionStartActivity<MainActivity>(context)
|
||||||
|
}
|
||||||
|
,
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
provider = FlutterAssetImageProvider(
|
||||||
|
context,
|
||||||
|
"assets/backgrounds/xmas-effect.png"
|
||||||
|
),
|
||||||
|
contentDescription = "Background",
|
||||||
|
modifier = GlanceModifier
|
||||||
|
.fillMaxSize(),
|
||||||
|
contentScale = ContentScale.Crop
|
||||||
|
)
|
||||||
|
Box(
|
||||||
|
modifier = GlanceModifier
|
||||||
|
.background(
|
||||||
|
color =
|
||||||
|
GlanceTheme.colors.surface.getColor(context)
|
||||||
|
.copy(alpha = 0.5f),
|
||||||
|
)
|
||||||
|
.fillMaxSize(),
|
||||||
|
) {}
|
||||||
Column(
|
Column(
|
||||||
modifier = GlanceModifier.padding(top = 10.dp)
|
modifier = GlanceModifier.padding(top = 10.dp, start = 10.dp, end = 10.dp)
|
||||||
) {
|
) {
|
||||||
Row(verticalAlignment = Alignment.Vertical.CenterVertically) {
|
Row(verticalAlignment = Alignment.Vertical.CenterVertically) {
|
||||||
TrackDetailsView(activeTrack)
|
TrackDetailsView(activeTrack)
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package oss.krtirtho.spotube.glance.widgets
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
|
import androidx.glance.ImageProvider
|
||||||
|
|
||||||
|
@Suppress("FunctionName")
|
||||||
|
fun FlutterAssetImageProvider(context: Context, path: String): ImageProvider {
|
||||||
|
var inputStream = context.assets.open("flutter_assets/$path")
|
||||||
|
|
||||||
|
return ImageProvider(
|
||||||
|
BitmapFactory.decodeStream(inputStream)
|
||||||
|
)
|
||||||
|
}
|
BIN
assets/backgrounds/xmas-effect.png
Normal file
BIN
assets/backgrounds/xmas-effect.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
@ -163,6 +163,7 @@ flutter:
|
|||||||
- assets/
|
- assets/
|
||||||
- assets/tutorial/
|
- assets/tutorial/
|
||||||
- assets/logos/
|
- assets/logos/
|
||||||
|
- assets/backgrounds/
|
||||||
- LICENSE
|
- LICENSE
|
||||||
|
|
||||||
flutter_gen:
|
flutter_gen:
|
||||||
|
Loading…
Reference in New Issue
Block a user