Skip to content

Commit

Permalink
Merge pull request #33 from enteraname74/develop
Browse files Browse the repository at this point in the history
v0.7.0-Desktop
  • Loading branch information
enteraname74 authored Sep 2, 2024
2 parents 8854302 + e6140ae commit 96c1316
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 9 deletions.
8 changes: 7 additions & 1 deletion desktopApp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/build
.gradle

soulSearchingDatabase.db
soulSearchingDatabase.db

# Flatpak
build-dir
repo
.flatpak-builder
*.flatpak
7 changes: 7 additions & 0 deletions desktopApp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Soul Searching Desktop

Originally an Android application, *Soul Searching* is now also available as a desktop application.
For now, it works for Linux. The best way to use the application is with a flatpak, as it holds all the needed dependencies for the app to work properly.

## Building the application
Use the `packageFlatpakReleaseDistributable` gradle task to build a flatpak of the application.
58 changes: 57 additions & 1 deletion desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,65 @@ compose.desktop {
appCategory = "AudioVideo;Player;"
appRelease = "1"
rpmLicenseType = "GPL-3.0-or-later"
iconFile.set(project.file("src/main/composeResources/drawable/app_icon.png"))
iconFile.set(project.file("src/main/composeResources/drawable/app_icon_bg.png"))
}

}
}
}
tasks {
register<Tar>("packageTarReleaseDistributable") {
group = "compose desktop"
from(named("createReleaseDistributable"))
archiveBaseName = "soulsearching"
archiveClassifier = "linux"
compression = Compression.GZIP
archiveExtension = "tar.gz"

val version = libs.versions.desktop.version.name.get()

archiveFileName = "soulsearching-$version-linux.tar.gz"
}

task("packageFlatpakReleaseDistributable") {
group = "compose desktop"
description = "Builds a flatpak and stores it in the build/flatpak folder."
dependsOn("packageTarReleaseDistributable")

val appId = "io.github.enteraname74.soulsearching"

doLast {
println("packageFlatpakReleaseDistributable -- INFO -- Building manifest")
exec {
commandLine(
"flatpak-builder",
"--user",
"--force-clean",
"build-dir",
"$appId.yml"
)
}
println("packageFlatpakReleaseDistributable -- INFO -- Creating flatpak executable")
exec {
commandLine(
"flatpak",
"build-export",
"repo",
"build-dir"
)
}
val outputDir = file("$buildDir/flatpak")
outputDir.mkdirs()
println("packageFlatpakReleaseDistributable -- Will install flatpak in: $outputDir")
exec {
commandLine(
"flatpak",
"build-bundle",
"repo",
"${outputDir.absolutePath}/$appId.flatpak",
appId
)
}
}
}
}
10 changes: 10 additions & 0 deletions desktopApp/io.github.enteraname74.soulsearching.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Name=Soul Searching
GenericName=Music Player
Exec=SoulSearching
Comment=Music player application.
Icon=io.github.enteraname74.soulsearching
Terminal=false
Type=Application
Categories=Audio;Player;Music;
Keywords=Music;Player;Audio;Songs;Playlist;Albums;Artists;
45 changes: 45 additions & 0 deletions desktopApp/io.github.enteraname74.soulsearching.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
app-id: io.github.enteraname74.soulsearching
runtime: org.freedesktop.Platform
runtime-version: '22.08'
sdk: org.freedesktop.Sdk
command: SoulSearching
build-options:
env:
BUILDCC: gcc
finish-args:
- --share=network
- --share=ipc
- --socket=pulseaudio
- --filesystem=home
- --device=dri
- --socket=x11
modules:
- name: vlc
buildsystem: autotools
config-opts:
- --disable-lua
- --disable-a52
build-commands:
- export BUILDCC=gcc
- ./configure --prefix=/app --disable-lua --disable-a52
- make -j$(nproc)
- make install
sources:
- type: archive
url: https://get.videolan.org/vlc/3.0.20/vlc-3.0.20.tar.xz
sha256: adc7285b4d2721cddf40eb5270cada2aaa10a334cb546fd55a06353447ba29b5


- name: SoulSearching
buildsystem: simple
build-commands:
- install -Dm 644 -t /app/share/applications io.github.enteraname74.soulsearching.desktop
- install -Dm 644 app_icon_bg.png /app/share/icons/hicolor/128x128/apps/io.github.enteraname74.soulsearching.png
- cp -ru * /app
sources:
- type: archive
path: build/distributions/soulsearching-0.7.0-linux.tar.gz
- type: file
path: src/main/composeResources/drawable/app_icon_bg.png
- type: file
path: io.github.enteraname74.soulsearching.desktop
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion desktopApp/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun main() = application {
icon = painterResource(Res.drawable.app_icon),
onPreviewKeyEvent = {
playbackManager.handleKeyEvent(event = it)
true
false
}
) {
MaterialTheme {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ compose = "1.6.2"
compose-ui = "1.5.1"
compose-plugin = "1.6.2"
coroutines-core = "1.8.0"
desktop-version-name = "0.1.0"
desktop-version-name = "0.7.0"
exposed = "0.46.0"
file-kit = "0.8.1"
foundation-desktop = "1.6.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ actual val platformModule: Module = module {
single<SoulSearchingSettings> {
SoulSearchingSettingsImpl(
settings = PreferencesSettings(
delegate = Preferences.userRoot()
delegate = Preferences.userRoot().node("com/github/enteraname74/soulsearching")
)
)
}
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.1.0"
actual val versionName = "0.7.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.jaudiotagger.tag.FieldKey
import org.jaudiotagger.tag.Tag
import org.jetbrains.skia.Image
import java.io.File
import java.net.URLConnection
import java.util.*
import kotlin.collections.ArrayList

Expand All @@ -51,7 +52,7 @@ class MusicFetcherDesktopImpl(
upsertFolderUseCase: UpsertFolderUseCase,
upsertMusicIntoAlbumUseCase: UpsertMusicIntoAlbumUseCase,
upsertMusicIntoArtistUseCase: UpsertMusicIntoArtistUseCase,
): MusicFetcher(
) : MusicFetcher(
isMusicAlreadySavedUseCase = isMusicAlreadySavedUseCase,
getArtistFromNameUseCase = getArtistFromNameUseCase,
getCorrespondingAlbumUseCase = getCorrespondingAlbumUseCase,
Expand Down Expand Up @@ -79,6 +80,33 @@ class MusicFetcherDesktopImpl(
}
}

private fun isMusicFile(file: File): Boolean {
val mimeType: String = URLConnection.guessContentTypeFromName(file.name) ?: return false
val authorizedMimeTypes =
listOf(
"audio/mpeg", // MP3 files
"audio/mp4", // MP4 files with audio (M4A)
"audio/wav", // WAV files
"audio/ogg", // Ogg Vorbis files
"audio/flac", // FLAC files
"audio/aac", // AAC files
"audio/opus", // Opus files
"audio/x-ms-wma", // Windows Media Audio files
"audio/aiff", // AIFF files
"audio/webm", // WebM files with audio
"audio/amr", // AMR files
"audio/vnd.rn-realaudio", // RealAudio files
"audio/midi", // MIDI files
"audio/3gpp", // 3GP files with audio
"audio/x-m4a", // M4A files
"audio/x-xmf", // XMF files
"audio/x-ms-asf", // ASF files with audio
"audio/x-wav", // RAW audio format (often used for WAV)
"audio/eac3" // Enhanced AC-3 files
)
return authorizedMimeTypes.contains(mimeType)
}

/**
* Extract mp3 files from current directory.
*/
Expand All @@ -99,8 +127,7 @@ class MusicFetcherDesktopImpl(
updateProgress(count / files.size, file.parent)
if (file.isHidden || !file.canRead()) {
continue
}
else if (file.name.endsWith(".mp3") || file.name.endsWith(".m4a")) {
} else if (isMusicFile(file = file)) {
try {
val audioFile: AudioFile = AudioFileIO.read(file)
val tag: Tag = audioFile.tag
Expand Down

0 comments on commit 96c1316

Please sign in to comment.