Skip to content

Commit

Permalink
Merge pull request #39 from enteraname74/develop
Browse files Browse the repository at this point in the history
v0.9.1
  • Loading branch information
enteraname74 authored Oct 26, 2024
2 parents 7c4ef12 + 5ae2948 commit facaed3
Show file tree
Hide file tree
Showing 93 changed files with 463 additions and 495 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ object UiConstants {
* Define the sizes of images in the application.
*/
object ImageSize {
val verySmall: Dp = 12.dp
val small: Dp = 16.dp
val smallPlus: Dp = 24.dp
val medium: Dp = 32.dp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.github.enteraname74.soulsearching.coreui.bottomsheet

import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.displayCutout
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.rememberModalBottomSheetState
Expand Down Expand Up @@ -35,7 +33,6 @@ fun SoulBottomSheetHandler(
containerColor = colors.containerColor,
contentColor = colors.contentColor,
dragHandle = null,
windowInsets = WindowInsets.displayCutout
) {
content(closeWithAnim)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ package com.github.enteraname74.soulsearching.coreui.button
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.LocalMinimumInteractiveComponentEnforcement
import androidx.compose.material3.LocalMinimumInteractiveComponentSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.unit.Dp

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SoulButton(
onClick: () -> Unit,
Expand All @@ -24,7 +23,7 @@ fun SoulButton(
content: @Composable () -> Unit,
) {
CompositionLocalProvider(
LocalMinimumInteractiveComponentEnforcement provides false,
LocalMinimumInteractiveComponentSize provides Dp.Unspecified,
) {
Button(
onClick = onClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.enteraname74.soulsearching.coreui.slider

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ExperimentalMaterial3Api
Expand All @@ -10,6 +11,7 @@ import androidx.compose.material3.SliderDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import com.github.enteraname74.soulsearching.coreui.UiConstants
import com.github.enteraname74.soulsearching.coreui.theme.color.SoulSearchingColorTheme
Expand Down Expand Up @@ -45,13 +47,27 @@ fun SoulSlider(
SliderDefaults.Thumb(
interactionSource = interactionSource,
modifier = Modifier
.size(UiConstants.ImageSize.small)
.padding(
start = 4.dp,
top = 4.dp
top = 2.dp,
),
thumbSize = DpSize(
width = UiConstants.ImageSize.verySmall,
height = UiConstants.ImageSize.verySmall
),
colors = sliderColors
)
},
track = {
SliderDefaults.Track(
sliderState = it,
trackInsideCornerSize = 0.dp,
drawStopIndicator = null,
thumbTrackGapSize = 0.dp,
modifier = Modifier.height(TrackHeight),
colors = sliderColors,
)
}
)
}
}

private val TrackHeight = 3.dp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ object FrStrings : Strings {
when (total) {
0 -> "Aucune musique supprimée"
1 -> "1 musique a été supprimée car elle n'existe plus sur l'appareil"
else -> "$total musiques ont été supprimées car elles n\\'existent plus sur l\\'appareil"
else -> "$total musiques ont été supprimées car elles n'existent plus sur l'appareil"
}

override fun plays(total: Int): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ fun SoulDropdownTextField(
TextField(
interactionSource = interactionSource,
modifier = Modifier
.menuAnchor()
.menuAnchor(
type = MenuAnchorType.PrimaryEditable,
enabled = true
)
.focusRequester(focusRequester),
value = value,
onValueChange = {
Expand Down
3 changes: 1 addition & 2 deletions desktopApp/io.github.enteraname74.soulsearching.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
app-id: io.github.enteraname74.soulsearching
runtime: org.freedesktop.Platform
runtime-version: '23.08'
version: '0.9.0'
sdk: org.freedesktop.Sdk
command: SoulSearching
build-options:
Expand Down Expand Up @@ -39,7 +38,7 @@ modules:
- cp -ru * /app
sources:
- type: archive
path: build/distributions/soulsearching-0.9.0-linux.tar.gz
path: build/distributions/soulsearching-0.9.1-linux.tar.gz
- type: file
path: src/main/composeResources/drawable/app_icon_bg.png
- type: file
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ val domainModule = module {
singleOf(::UpsertArtistUseCase)

// Folder
singleOf(::DeleteAllFoldersUseCase)
singleOf(::DeleteFolderUseCase)
singleOf(::GetAllFoldersUseCase)
singleOf(::GetHiddenFoldersPathUseCase)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sealed interface Cover {

fun isEmpty(): Boolean

data class FileCover(
data class CoverFile(
val initialCoverPath: String? = null,
val fileCoverId: UUID? = null,
): Cover {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ interface FolderRepository {
*/
suspend fun delete(folder: Folder)

suspend fun deleteAll(folders: List<Folder>)

/**
* Retrieves a flow of all Folder.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class GetNumberOfAlbumsWithCoverIdUseCase(
) {
suspend operator fun invoke(coverId: UUID): Int {
val allAlbums = albumRepository.getAll().first()
return allAlbums.count { (it.cover as? Cover.FileCover)?.fileCoverId == coverId }
return allAlbums.count { (it.cover as? Cover.CoverFile)?.fileCoverId == coverId }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class UpdateAlbumCoverUseCase(
val album: Album = albumRepository.getFromId(albumId = albumId).first() ?: return
albumRepository.upsert(
album = album.copy(
cover = Cover.FileCover(fileCoverId = newCoverId),
cover = Cover.CoverFile(fileCoverId = newCoverId),
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class UpdateArtistCoverUseCase(
val artist: Artist = artistRepository.getFromId(artistId = artistId).first() ?: return
artistRepository.upsert(
artist = artist.copy(
cover = Cover.FileCover(fileCoverId = newCoverId),
cover = Cover.CoverFile(fileCoverId = newCoverId),
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class IsCoverUsedUseCase(
private val getNumberOfAlbumsWithCoverIdUseCase: GetNumberOfAlbumsWithCoverIdUseCase,
) {
suspend operator fun invoke(coverId: UUID): Boolean =
musicRepository.getAll().first().any { (it.cover as? Cover.FileCover)?.fileCoverId == coverId }
musicRepository.getAll().first().any { (it.cover as? Cover.CoverFile)?.fileCoverId == coverId }
|| getNumberOfAlbumsWithCoverIdUseCase(coverId = coverId) > 0
|| artistRepository.getAll().first().any { (it.cover as? Cover.FileCover)?.fileCoverId == coverId }
|| playlistRepository.getAll().first().any { (it.cover as? Cover.FileCover)?.fileCoverId == coverId }
|| artistRepository.getAll().first().any { (it.cover as? Cover.CoverFile)?.fileCoverId == coverId }
|| playlistRepository.getAll().first().any { (it.cover as? Cover.CoverFile)?.fileCoverId == coverId }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.github.enteraname74.domain.usecase.folder

import com.github.enteraname74.domain.model.Folder
import com.github.enteraname74.domain.repository.FolderRepository

class DeleteAllFoldersUseCase(
private val folderRepository: FolderRepository
) {
suspend operator fun invoke(folders: List<Folder>) =
folderRepository.deleteAll(folders = folders)
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class UpdateAlbumOfMusicUseCase(
if (newMusicAlbum == null) {
newMusicAlbum = Album(
albumName = newAlbumName,
cover = (legacyMusic.cover as? Cover.FileCover)?.fileCoverId?.let {
Cover.FileCover(fileCoverId = it)
cover = (legacyMusic.cover as? Cover.CoverFile)?.fileCoverId?.let {
Cover.CoverFile(fileCoverId = it)
}
)
albumRepository.upsert(album = newMusicAlbum)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.github.enteraname74.domain.util

object LocalDatabaseVersion {
const val version: Int = 17
const val VERSION: Int = 18
}

This file was deleted.

2 changes: 2 additions & 0 deletions features/filemanager/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ kotlin {
commonMain.dependencies {
implementation(project(":domain"))
implementation(compose.runtime)
implementation(compose.ui)
implementation(libs.components.resources)
implementation(libs.koin.core)
implementation(libs.jaudiotagger)
implementation(libs.coroutines.core)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.github.enteraname74.soulsearching.features.filemanager.cover

import android.media.MediaMetadataRetriever
import androidx.compose.ui.graphics.ImageBitmap
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.decodeToImageBitmap

class CachedCoverManagerAndroidImpl : CachedCoverManager() {
@OptIn(ExperimentalResourceApi::class)
override fun fetchCoverOfMusicFile(musicPath: String): ImageBitmap? =
try {
val mediaMetadataRetriever = MediaMetadataRetriever()
mediaMetadataRetriever.setDataSource(musicPath)
val data: ImageBitmap? = mediaMetadataRetriever.embeddedPicture?.decodeToImageBitmap()
data?.let { cachedImages[musicPath] = it }
data
} catch (e: Exception) {
println("CoverUtilsImpl -- Error while fetching song's cover: ${e.message}")
null
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.github.enteraname74.soulsearching.features.filemanager.cover

import android.content.Context
import com.github.enteraname74.domain.model.Cover
import com.github.enteraname74.domain.model.Music
import com.github.enteraname74.soulsearching.features.filemanager.util.MusicCoverUtils
import java.io.File

internal class CoverFileManagerAndroidImpl(
Expand All @@ -20,14 +17,6 @@ internal class CoverFileManagerAndroidImpl(
return folder
}

override fun getCleanFileCoverForMusic(music: Music): Cover.FileCover {
val albumId = MusicCoverUtils.getAlbumIdFromMusicPath(context, music.path) ?: return Cover.FileCover()
val path = MusicCoverUtils.getMusicFileCoverPath(context, albumId) ?: return Cover.FileCover()
return Cover.FileCover(
initialCoverPath = path,
)
}

companion object {
private const val COVER_FOLDER = "covers"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import org.koin.core.module.Module
import org.koin.dsl.module
import com.github.enteraname74.soulsearching.features.filemanager.cover.CoverFileManager
import com.github.enteraname74.soulsearching.features.filemanager.cover.CoverFileManagerAndroidImpl
import com.github.enteraname74.soulsearching.features.filemanager.cover.CachedCoverManager
import com.github.enteraname74.soulsearching.features.filemanager.cover.CachedCoverManagerAndroidImpl
import com.github.enteraname74.soulsearching.features.filemanager.musicfetching.MusicFetcher
import com.github.enteraname74.soulsearching.features.filemanager.musicfetching.MusicFetcherAndroidImpl
import org.koin.core.module.dsl.singleOf
Expand All @@ -12,4 +14,5 @@ import org.koin.dsl.bind
internal actual val fileManagerPlatformModule: Module = module {
singleOf(::CoverFileManagerAndroidImpl) bind CoverFileManager::class
singleOf(::MusicFetcherAndroidImpl) bind MusicFetcher::class
singleOf(::CachedCoverManagerAndroidImpl) bind CachedCoverManager::class
}
Loading

0 comments on commit facaed3

Please sign in to comment.