Skip to content

Commit

Permalink
Add server connectivity to the Android target (#228)
Browse files Browse the repository at this point in the history
- Implement external server connectivity on Android
- Add ENABLE_EXTERNAL_SERVER_MODE option
- Rename DesktopSettings to ServerSettings
- Move desktop startup command to system category
- Various refactors and organisation changes to PlayerService-related files
- Improve loading splash UI
- Add option to disable audio playback when using external server
- Remove spms submodule
- Don't send Discord webhook in PR CI run
  • Loading branch information
toasterofbread authored Jun 25, 2024
1 parent 5e6ed9c commit 8d386c2
Show file tree
Hide file tree
Showing 98 changed files with 3,380 additions and 2,609 deletions.
17 changes: 4 additions & 13 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,9 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Set up Gradle
uses: gradle/gradle-build-action@v3

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- uses: cachix/install-nix-action@v27
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: nicknovitski/nix-develop@v1

- name: Build debug APK
run: ./gradlew androidApp:packageDebug
Expand All @@ -54,7 +45,7 @@ jobs:
uses: discord-actions/message@v2
env:
BUILD_NOTIFICATION_DISCORD_WEBHOOK: ${{ secrets.BUILD_NOTIFICATION_DISCORD_WEBHOOK }}
if: env.BUILD_NOTIFICATION_DISCORD_WEBHOOK != null
if: env.BUILD_NOTIFICATION_DISCORD_WEBHOOK != null && github.event_name != 'pull_request'
with:
webhookUrl: ${{ secrets.BUILD_NOTIFICATION_DISCORD_WEBHOOK }}
message: "${{ github.workflow }} [build](<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>) completed for commit - [${{ env.COMMIT_SHA }}](<${{ github.event.head_commit.url }}>) ${{ github.event.head_commit.message }} - [Downloads](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }})"
9 changes: 4 additions & 5 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ jobs:
with:
submodules: recursive

- name: Set up JDK 17
- name: Set up JDKs
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
java-version: |
22
21
- name: Set up Gradle
uses: gradle/gradle-build-action@v3

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Install desktop-file-utils, appstream
uses: awalsh128/cache-apt-pkgs-action@latest
with:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ jobs:
with:
submodules: recursive

- name: Set up JDK 17
- name: Set up JDKs
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
java-version: |
22
21
- name: Set up Gradle
uses: gradle/gradle-build-action@v3
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "spmp-server"]
path = spmp-server
url = https://github.com/toasterofbread/spmp-server
6 changes: 3 additions & 3 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ android {
versionName = getString("version_string")

applicationId = "com.toasterofbread.spmp"
minSdk = 23
minSdk = (findProperty("android.minSdk") as String).toInt()
targetSdk = (findProperty("android.targetSdk") as String).toInt()

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -122,8 +122,8 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_22
targetCompatibility = JavaVersion.VERSION_22
isCoreLibraryDesugaringEnabled = true
}

Expand Down
3 changes: 3 additions & 0 deletions androidApp/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
-dontwarn org.jaudiotagger.**
-keep class org.jaudiotagger.** { *; }

# Ktor
-dontwarn io.ktor.**

# From proguard-android-optimize.txt

-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
Expand Down
12 changes: 11 additions & 1 deletion androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@
<activity android:name=".ErrorReportActivity" />

<service
android:name=".platform.playerservice.PlatformPlayerService"
android:name=".platform.playerservice.PlatformInternalPlayerService"
android:exported="true"
android:foregroundServiceType="mediaPlayback">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="androidx.media3.session.MediaSessionService" />
</intent-filter>
</service>

<service
android:name=".platform.playerservice.PlatformExternalPlayerService"
android:exported="true"
android:foregroundServiceType="mediaPlayback">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@ class MainActivity: ComponentActivity() {
if (intent.action == Intent.ACTION_VIEW) intent.data
else null

val launch_arguments: ProgramArguments = ProgramArguments()

setContent {
val player_coroutine_scope: CoroutineScope = rememberCoroutineScope()
var player_initialised: Boolean by remember { mutableStateOf(false) }

LaunchedEffect(Unit) {
SpMp.initPlayer(player_coroutine_scope)
SpMp.initPlayer(launch_arguments, player_coroutine_scope)
player_initialised = true
}

if (player_initialised) {
SpMp.App(ProgramArguments(), shortcut_state, open_uri = open_uri?.toString())
SpMp.App(launch_arguments, shortcut_state, open_uri = open_uri?.toString())
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions androidApp/src/main/res/values/strings.xml

This file was deleted.

4 changes: 4 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ repositories {
dependencies {
implementation("com.github.gmazzo.buildconfig:plugin:5.3.5")
}

tasks.withType(JavaCompile::class) {
options.release.set(21)
}
14 changes: 11 additions & 3 deletions buildSrc/src/main/kotlin/plugins/spmp/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ class SpMpDeps(extra: Map<String, Any>) {

val dependencies: Map<String, DependencyInfo> =
mapOf(
"dev.toastbits:spms" to DependencyInfo(
version = "0.4.0-alpha2",
name = "spmp-server",
author = "toasterofbread",
url = "https://github.com/toasterofbread/spmp-server",
license = "GPL-2.0",
license_url = "https://github.com/toasterofbread/spmp-server/blob/6dde651ffc102d604ac7ecd5ac7471b1572fd2e6/LICENSE"
),
"dev.toastbits.composekit" to DependencyInfo(
version = "6788078322",
name = "ComposeKit",
Expand All @@ -32,7 +40,7 @@ class SpMpDeps(extra: Map<String, Any>) {
license_url = "https://github.com/toasterofbread/ComposeKit/blob/136f216e65395660255d3270af9b79c90ae2254c/LICENSE"
),
"dev.toastbits.ytmkt" to DependencyInfo(
version = "0.2.0",
version = "0.2.2",
name = "ytm-kt",
author = "toasterofbread",
url = "https://github.com/toasterofbread/ytm-kt",
Expand Down Expand Up @@ -155,15 +163,15 @@ class SpMpDeps(extra: Map<String, Any>) {
fork_url = "https://github.com/marcoc1712/jaudiotagger"
),
"com.github.teamnewpipe:NewPipeExtractor" to DependencyInfo(
version = "v0.22.7",
version = "v0.24.0",
name = "NewPipe Extractor",
author = "Team NewPipe",
url = "https://github.com/TeamNewPipe/NewPipeExtractor",
license = "GPL-3.0",
license_url = "https://github.com/TeamNewPipe/NewPipeExtractor/blob/ec3e8378c627c682964f104fc2fb06ea5513b6b7/LICENSE"
),
"org.zeromq:jeromq" to DependencyInfo(
version = "0.5.3",
version = "0.6.0",
name = "JeroMQ",
author = "zeromq",
url = "https://github.com/zeromq/jeromq",
Expand Down
Loading

0 comments on commit 8d386c2

Please sign in to comment.