Skip to content

Commit ad48450

Browse files
author
Niels Masdorp
authored
Merge pull request #39 from NielsMasdorp/feature/android_auto
Implement Android Auto support
2 parents 6506284 + 411b39f commit ad48450

100 files changed

Lines changed: 2154 additions & 395 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: 'Build & test'
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: "Checkout repository"
11+
uses: actions/checkout@v3
12+
13+
- name: "Setup Java"
14+
uses: actions/setup-java@v3
15+
with:
16+
java-version: '11'
17+
distribution: 'adopt'
18+
19+
- name: "Validate gradle wrapper"
20+
uses: gradle/wrapper-validation-action@v1
21+
22+
- name: "Use cached gradle wrapper"
23+
uses: actions/cache@v3
24+
with:
25+
path: |
26+
~/.gradle/caches
27+
~/.gradle/wrapper
28+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
29+
restore-keys: |
30+
${{ runner.os }}-gradle-
31+
32+
- name: "Check for code violations"
33+
run: ./gradlew detekt
34+
35+
- name: "Build, test and lint"
36+
run: ./gradlew app:assDebug test app:lintDebug

README.md

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Stream popular dutch radio stations.
44

5-
This is mostly a pet project created to learn Jetpack Compose and the new Jetpack Media3 API's.
5+
This is mostly a pet project created to learn Jetpack Compose and the new Jetpack Media3 API
66

77
Nederadio is built using all the latest practices in Android development:
88

@@ -13,28 +13,64 @@ Nederadio is built using all the latest practices in Android development:
1313
- Material3
1414
- Material You on Android 12 and higher
1515
- Dark/Light mode
16-
- Cast support
17-
- Live song updates
18-
- Sleep timer
16+
- Cast support including to TVs
17+
- Android Auto support
18+
- Current song information (except when casting or the stream does not support it)
19+
- Sleep timer which slowly fades the volume and stops the stream after a set time
1920

20-
## Screenshots
21+
## In action
22+
23+
### App
24+
25+
https://user-images.githubusercontent.com/5968599/236145601-d423e644-0a26-4b85-84f2-b05d3e9b19aa.mp4
26+
27+
### Android Auto
2128

2229
<p float="left">
23-
<img src="/app/screenshots/screenshot1.png" width="150" />
24-
<img src="/app/screenshots/screenshot2.png" width="150" />
25-
<img src="/app/screenshots/screenshot3.png" width="150" />
26-
<img src="/app/screenshots/screenshot4.png" width="150" />
27-
<img src="/app/screenshots/screenshot5.png" width="150" />
30+
<img src="/app/screenshots/auto_1.png" width="600" />
31+
<img src="/app/screenshots/auto_2.png" width="600" />
2832
</p>
2933

3034
## Change data
3135

32-
You could easily use your own streams in this app, the data set is located in `backend/public/nederadio/data.json`. It is currently served on my own server but you could change the endpoint in `StreamApi` to whatever you like.
36+
You could easily use your own streams in this app, the data set is located in `backend/public/nederadio/data.json`. And it contains a NodeJS app that can run on on your backend of choosing. It is currently served on my own server but you could change the endpoint in `StreamApi` to whatever you like.
37+
38+
## Current issues and future enhancements
39+
40+
* When switching to cast, the same media session is used as when using Exoplayer, which leads to a media notification that does not adhere to the casting guidelines. See https://github.com/androidx/media/issues/39 and https://github.com/androidx/media/issues/264
41+
* Playback resumption seems iffy, need to take a better look. See https://android-developers.googleblog.com/2020/08/playing-nicely-with-media-controls.html and the implementation of `onGetLibraryRoot()` and `onGetChildren` in `StreamService`
42+
* CastPlayer implementation in Media3 does not implement the required API to show live song updates unfortunately. Need to revisit in the future
43+
* Landscape UI not implemented
44+
* Search for Google Assistant/Android Auto not implemented, see: https://developer.android.com/training/cars/media#support_voice
45+
46+
Want to help? Open a PR! Be sure to add Detekt via:
47+
48+
### Detekt
49+
50+
Please add this to `<<your-repo>>/.git/hooks/pre-commit` and make it executable by `chmod +x pre-commit`.
51+
This will make sure Detekt runs and prevents any commits that fail our coding standards.
52+
53+
```
54+
#!/usr/bin/env bash
55+
echo "Running detekt check..."
56+
OUTPUT="/tmp/detekt-$(date +%s)"
57+
./gradlew detekt > $OUTPUT
58+
EXIT_CODE=$?
59+
if [ $EXIT_CODE -ne 0 ]; then
60+
cat $OUTPUT
61+
rm $OUTPUT
62+
echo "***********************************************"
63+
echo " Detekt failed "
64+
echo " Please fix the above issues before committing "
65+
echo "***********************************************"
66+
exit $EXIT_CODE
67+
fi
68+
rm $OUTPUT
69+
```
3370

3471
## Used libraries
3572

3673
* [Koin](https://github.com/InsertKoinIO/koin)
37-
* [Cokoin](https://github.com/burnoo/cokoin)
3874
* [Jetpack Media3](https://github.com/androidx/media)
3975
* [Jetpack Compose](https://developer.android.com/jetpack/compose)
4076
* [Ktor](https://github.com/ktorio/ktor)

app/build.gradle

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ android {
4141
sourceCompatibility JavaVersion.VERSION_1_8
4242
targetCompatibility JavaVersion.VERSION_1_8
4343
}
44+
45+
android {
46+
lintOptions {
47+
baseline file("lint-baseline.xml")
48+
}
49+
}
4450
}
4551

4652
dependencies {
@@ -77,11 +83,11 @@ dependencies {
7783
//kotlin
7884
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinx_coroutines_android_version"
7985
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinx_serialization_version"
86+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-guava:$kotlinx_guava_version"
8087

8188
// Koin
82-
implementation "dev.burnoo:cokoin:$cokoin_version"
83-
implementation "dev.burnoo:cokoin-android-viewmodel:$cokoin_version"
84-
implementation "dev.burnoo:cokoin-android-navigation:$cokoin_version"
89+
implementation "io.insert-koin:koin-android:$koin_version"
90+
implementation "io.insert-koin:koin-androidx-compose:$koin_compose_version"
8591

8692
//Ktor
8793
implementation "io.ktor:ktor-client-android:$ktor_version"

0 commit comments

Comments
 (0)