Skip to content

Commit

Permalink
Merge pull request #35 from enteraname74/develop
Browse files Browse the repository at this point in the history
v0.8.1
  • Loading branch information
enteraname74 authored Sep 29, 2024
2 parents 931505d + c2b2a95 commit 50df84b
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ local.properties
.idea/
database.db

.kotlin

desktopApp/*.log
4 changes: 2 additions & 2 deletions desktopApp/io.github.enteraname74.soulsearching.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
app-id: io.github.enteraname74.soulsearching
runtime: org.freedesktop.Platform
runtime-version: '23.08'
version: '0.8.0'
version: '0.8.1'
sdk: org.freedesktop.Sdk
command: SoulSearching
build-options:
Expand Down Expand Up @@ -39,7 +39,7 @@ modules:
- cp -ru * /app
sources:
- type: archive
path: build/distributions/soulsearching-0.8.0-linux.tar.gz
path: build/distributions/soulsearching-0.8.1-linux.tar.gz
- type: file
path: src/main/composeResources/drawable/app_icon_bg.png
- type: file
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
accompanist = "0.28.0"
accompanist-system-ui-controller = "0.30.1"
agp = "8.5.2"
android-version-name = "0.8.0"
android-version-code = "18"
android-version-name = "0.8.1"
android-version-code = "19"
android-target-sdk = "34"
android-compile-sdk = "34"
android-min-sdk = "26"
Expand All @@ -14,7 +14,7 @@ annotation = "1.8.2"
appcompat = "1.7.0"
compose = "1.6.11"
coroutines-core = "1.9.0"
desktop-version-name = "0.8.0"
desktop-version-name = "0.8.1"
exposed = "0.53.0"
file-kit = "0.8.1"
gradle = "8.5.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class SoulSearchingNotification(
get() = _notification


private val activityPendingIntent: PendingIntent = PendingIntent.getActivity(
protected val activityPendingIntent: PendingIntent = PendingIntent.getActivity(
context,
1,
Intent(context, MainActivity::class.java).apply {
Expand All @@ -42,7 +42,7 @@ abstract class SoulSearchingNotification(
PendingIntent.FLAG_IMMUTABLE
)

private val deleteNotificationIntent: PendingIntent = PendingIntent.getBroadcast(
protected val deleteNotificationIntent: PendingIntent = PendingIntent.getBroadcast(
context,
5,
Intent(context, DeletedNotificationIntentReceiver::class.java),
Expand All @@ -54,7 +54,8 @@ abstract class SoulSearchingNotification(
* It will show the information of the current played song if there is one.
*/
@SuppressLint("UnspecifiedRegisterReceiverFlag")
fun init(currentMusic: Music?) {
open fun init(currentMusic: Music?) {
println("INIT NOTIFICATION WITH MUSIC: $currentMusic")
notificationBuilder
.setSmallIcon(R.drawable.ic_saxophone_svg)
.setContentTitle(currentMusic?.name.orEmpty())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package com.github.enteraname74.soulsearching.model.notification.impl

import android.app.Notification
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.support.v4.media.session.MediaSessionCompat
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.core.app.NotificationCompat
import com.github.enteraname74.domain.model.Music
import com.github.enteraname74.soulsearching.feature.player.domain.model.PlaybackManager
import com.github.soulsearching.R
import com.github.enteraname74.soulsearching.model.notification.SoulSearchingNotification
import com.github.enteraname74.soulsearching.model.notification.receivers.NextMusicNotificationReceiver
import com.github.enteraname74.soulsearching.model.notification.receivers.PausePlayNotificationReceiver
import com.github.enteraname74.soulsearching.model.notification.receivers.PreviousMusicNotificationReceiver
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

/**
* Specification of a SoulSearchingNotification for devices below Android 13.
Expand All @@ -19,7 +26,8 @@ class SoulSearchingNotificationBelowAndroid13(
) : SoulSearchingNotification(
context,
mediaSessionToken
) {
), KoinComponent {
private val playbackManager: PlaybackManager by inject()

private val previousMusicIntent: PendingIntent = PendingIntent.getBroadcast(
context,
Expand All @@ -42,15 +50,21 @@ class SoulSearchingNotificationBelowAndroid13(
PendingIntent.FLAG_IMMUTABLE
)

override fun update(isPlaying: Boolean) {
private fun buildNotification(
isPlaying: Boolean,
): Notification {
val pausePlayIcon = if (isPlaying) {
R.drawable.ic_pause
} else {
R.drawable.ic_play_arrow
}

notificationBuilder
return notificationBuilder
.clearActions()
.setContentIntent(activityPendingIntent)
.setDeleteIntent(deleteNotificationIntent)
.setSmallIcon(R.drawable.ic_saxophone_svg)
.setSilent(true)
.addAction(R.drawable.ic_skip_previous,"previous",previousMusicIntent)
.addAction(pausePlayIcon,"pausePlay",pausePlayIntent)
.addAction(R.drawable.ic_skip_next,"next",nextMusicIntent)
Expand All @@ -59,8 +73,21 @@ class SoulSearchingNotificationBelowAndroid13(
.setShowActionsInCompactView(0,1,2)
.setMediaSession(mediaSessionToken)
)
_notification = notificationBuilder.build()
.setLargeIcon(playbackManager.currentMusicCover?.asAndroidBitmap())
.setContentTitle(playbackManager.currentMusic?.name.orEmpty())
.setContentText(playbackManager.currentMusic?.artist.orEmpty())
.apply {
priority = NotificationCompat.PRIORITY_LOW
}
.build()
}

override fun init(currentMusic: Music?) {
_notification = buildNotification(isPlaying = playbackManager.isPlaying)
}

override fun update(isPlaying: Boolean) {
_notification = buildNotification(isPlaying = isPlaying)
notificationManager.notify(CHANNEL_ID, _notification)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ import android.os.IBinder
import android.support.v4.media.session.MediaSessionCompat
import android.util.Log
import androidx.core.app.ServiceCompat
import com.github.enteraname74.soulsearching.feature.player.domain.model.PlaybackManager
import com.github.enteraname74.soulsearching.model.notification.SoulSearchingNotification
import com.github.enteraname74.soulsearching.model.notification.SoulSearchingNotificationBuilder
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

/**
* Service used for the playback.
*/
class PlayerService : Service() {
class PlayerService : Service(), KoinComponent {
private val playbackManager by inject<PlaybackManager>()

private var musicNotification: SoulSearchingNotification? = null

private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
Expand All @@ -44,7 +49,7 @@ class PlayerService : Service() {
applicationContext.registerReceiver(
broadcastReceiver,
IntentFilter(SERVICE_BROADCAST),
Context.RECEIVER_NOT_EXPORTED
RECEIVER_NOT_EXPORTED
)
} else {
applicationContext.registerReceiver(
Expand All @@ -58,7 +63,9 @@ class PlayerService : Service() {
context = this,
mediaSessionToken = token
)
musicNotification!!.init(null)
musicNotification?.init(
currentMusic = playbackManager.currentMusic,
)
ServiceCompat.startForeground(
this,
SoulSearchingNotification.CHANNEL_ID,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.github.enteraname74.soulsearching

import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.modifier.ModifierLocal
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.transitions.CrossfadeTransition
import com.github.enteraname74.domain.model.getFromCoverId
Expand Down Expand Up @@ -125,16 +132,24 @@ fun SoulSearchingApplication(
}
}

Navigator(MainPageScreen()) { navigator ->
generalNavigator = navigator

CrossfadeTransition(
navigator = navigator,
animationSpec = tween(UiConstants.AnimationDuration.normal)
) { screen ->
screen.Content()
Box(
modifier = Modifier
.padding(paddingValues = WindowInsets.navigationBars.asPaddingValues())
) {
Navigator(
screen = MainPageScreen()
) { navigator ->
generalNavigator = navigator

CrossfadeTransition(
navigator = navigator,
animationSpec = tween(UiConstants.AnimationDuration.normal)
) { screen ->
screen.Content()
}
}
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ package com.github.enteraname74.soulsearching.feature.player.presentation
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.swipeable
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -179,6 +182,7 @@ fun PlayerDraggableView(
.background(
color = animatedBackgroundColor
)
.padding(paddingValues = WindowInsets.navigationBars.asPaddingValues())
.clickableIf(enabled = playerViewManager.currentValue == BottomSheetStates.MINIMISED) {
coroutineScope.launch {
playerViewManager.animateTo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -98,6 +97,7 @@ private fun SettingsStatisticsState.elements(index: Int): List<ListenedElement>
1 -> mostListenedArtists
2 -> artistsWithMostSongs
3 -> mostListenedAlbums
4 -> mostListenedPlaylists
else -> mostListenedMusics
}

Expand All @@ -108,6 +108,7 @@ private fun SettingsStatisticsState.title(index: Int): String =
1 -> strings.mostPlayedArtists
2 -> strings.artistsWithMostSongs
3 -> strings.mostPlayedAlbums
4 -> strings.mostPlayedPlaylists
else -> strings.mostPlayedSongs
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.github.enteraname74.soulsearching.domain

actual object AppVersion {
actual val versionName = "0.8.0"
actual val versionName = "0.8.1"
}

0 comments on commit 50df84b

Please sign in to comment.