Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add firebase distribution #56

Merged
merged 5 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Build & distribute'

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v3

- name: "Setup Java"
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'

- name: "Validate gradle wrapper"
uses: gradle/wrapper-validation-action@v1

- name: "Use cached gradle wrapper"
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: "Build"
run: ./gradlew app:assQa

# We need to do this at some point:
# https://github.com/wzieba/Firebase-Distribution-Github-Action/wiki/FIREBASE_TOKEN-migration

- name: "Distribute"
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{ secrets.FIREBASE_APP_ID_ANDROID }}
token: ${{ secrets.FIREBASE_TOKEN_ANDROID }}
groups: testers
file: app/build/outputs/apk/qa/app-qa.apk
releaseNotesFile: app/release-notes.txt
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: "Setup Java"
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'

- name: "Validate gradle wrapper"
Expand Down
65 changes: 57 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlinx-serialization'
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlinx-serialization'
id "com.starter.easylauncher" version "$easy_launcher_version"
id 'com.google.firebase.appdistribution'
}

repositories {
mavenCentral()
Expand All @@ -14,13 +18,44 @@ android {
minSdkVersion 26
//noinspection OldTargetApi
targetSdkVersion 34
versionCode 201
versionName "2.3.7"
versionCode project.getVersionCode()
versionName "2.3.7" + project.getVersionCode()
}

signingConfigs {
firebase {
storeFile file("firebase.jks")
storePassword 'password'
keyAlias 'alias'
keyPassword 'password'
}
}

buildTypes {
release {
debug {
applicationIdSuffix ".debug"
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
qa {
applicationIdSuffix = ".qa"
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

signingConfig signingConfigs.firebase
firebaseAppDistribution {
artifactType = "APK"
groups = "testers"
releaseNotesFile = "app/release-notes.txt"
}
}
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

Expand Down Expand Up @@ -51,9 +86,19 @@ android {
namespace 'com.nielsmasdorp.nederadio'
}

easylauncher {
buildTypes {
qa {
filters = redRibbonFilter()
}
}
}

dependencies {
implementation project(':domain')

implementation platform('com.google.firebase:firebase-bom:32.5.0')

// Google
implementation "com.google.android.material:material:$material_version"

Expand All @@ -76,7 +121,11 @@ dependencies {

// Koin
implementation "io.insert-koin:koin-android:$koin_version"
implementation "io.insert-koin:koin-androidx-compose:$koin_compose_version"
implementation "io.insert-koin:koin-androidx-compose:$koin_version"
implementation "io.ktor:ktor-client-serialization:$ktor_version"
implementation "io.ktor:ktor-client-logging-jvm:$ktor_version"
implementation "io.ktor:ktor-client-content-negotiation:$ktor_version"
implementation "io.ktor:ktor-serialization-kotlinx-json:$ktor_version"

// Ktor
implementation "io.ktor:ktor-client-android:$ktor_version"
Expand Down
29 changes: 29 additions & 0 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "576626084592",
"project_id": "nederadio-4611a",
"storage_bucket": "nederadio-4611a.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:576626084592:android:725f5fa27712251dc85035",
"android_client_info": {
"package_name": "com.nielsmasdorp.nederadio.qa"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyCY8N_LYcO6fYd-993AXN5EQG4mkWC3RlU"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
1 change: 1 addition & 0 deletions app/release-notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- add firebase distribution
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ package com.nielsmasdorp.nederadio.data.network
import android.util.Log
import io.ktor.client.HttpClient
import io.ktor.client.engine.android.Android
import io.ktor.client.features.*
import io.ktor.client.features.json.JsonFeature
import io.ktor.client.features.json.serializer.KotlinxSerializer
import io.ktor.client.features.logging.LogLevel
import io.ktor.client.features.logging.Logger
import io.ktor.client.features.logging.Logging
import io.ktor.client.features.observer.ResponseObserver
import io.ktor.client.request.*
import io.ktor.http.*
import io.ktor.client.plugins.DefaultRequest
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.defaultRequest
import io.ktor.client.plugins.logging.DEFAULT
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logger
import io.ktor.client.plugins.logging.Logging
import io.ktor.client.plugins.observer.ResponseObserver
import io.ktor.client.request.header
import io.ktor.http.ContentType
import io.ktor.http.HttpHeaders
import io.ktor.http.URLProtocol
import io.ktor.serialization.kotlinx.json.json
import kotlinx.serialization.json.Json

private const val TIME_OUT = 60_000
Expand All @@ -28,8 +32,8 @@ val ktorHttpClient = HttpClient(Android) {
}
}

install(JsonFeature) {
serializer = KotlinxSerializer(
install(ContentNegotiation) {
json(
Json {
prettyPrint = true
isLenient = true
Expand All @@ -44,11 +48,7 @@ val ktorHttpClient = HttpClient(Android) {
}

install(Logging) {
logger = object : Logger {
override fun log(message: String) {
Log.v("Logger Ktor =>", message)
}
}
logger = Logger.DEFAULT
level = LogLevel.ALL
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package com.nielsmasdorp.nederadio.data.network

import com.nielsmasdorp.nederadio.data.network.reponse.StreamResponse
import io.ktor.client.*
import io.ktor.client.call.body
import io.ktor.client.request.*

/**
* @author Niels Masdorp (NielsMasdorp)
*/
class StreamApi(private val client: HttpClient) {

suspend fun getStreams(): List<StreamResponse> = client.get("/data.json")
suspend fun getStreams(): List<StreamResponse> = client.get("/data.json").body()
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,18 @@ class ReplaceableForwardingPlayer(

override fun seekForward() = player.seekForward()

@Deprecated("Deprecated in Java")
override fun hasPrevious(): Boolean = player.hasPrevious()

@Deprecated("Deprecated in Java")
override fun hasPreviousWindow(): Boolean = player.hasPreviousWindow()

override fun hasPreviousMediaItem(): Boolean = player.hasPreviousMediaItem()

@Deprecated("Deprecated in Java")
override fun previous() = player.previous()

@Deprecated("Deprecated in Java")
override fun seekToPreviousWindow() = player.seekToPreviousWindow()

override fun seekToPreviousMediaItem() = player.seekToPreviousMediaItem()
Expand All @@ -271,14 +275,18 @@ class ReplaceableForwardingPlayer(

override fun seekToPrevious() = player.seekToPrevious()

@Deprecated("Deprecated in Java")
override fun hasNext(): Boolean = player.hasNext()

@Deprecated("Deprecated in Java")
override fun hasNextWindow(): Boolean = player.hasNextWindow()

override fun hasNextMediaItem(): Boolean = player.hasNextMediaItem()

@Deprecated("Deprecated in Java")
override fun next() = player.next()

@Deprecated("Deprecated in Java")
override fun seekToNextWindow() = player.seekToNextWindow()

override fun seekToNextMediaItem() = player.seekToNextMediaItem()
Expand Down Expand Up @@ -324,16 +332,19 @@ class ReplaceableForwardingPlayer(

override fun getCurrentPeriodIndex(): Int = player.currentPeriodIndex

@Deprecated("Deprecated in Java")
override fun getCurrentWindowIndex(): Int = player.currentWindowIndex

override fun getCurrentMediaItemIndex(): Int = player.currentMediaItemIndex

@Deprecated("Deprecated in Java")
override fun getNextWindowIndex(): Int = player.nextWindowIndex

override fun getNextMediaItemIndex(): Int {
return player.nextMediaItemIndex
}

@Deprecated("Deprecated in Java")
override fun getPreviousWindowIndex(): Int = player.previousWindowIndex

override fun getPreviousMediaItemIndex(): Int = player.previousMediaItemIndex
Expand All @@ -354,16 +365,19 @@ class ReplaceableForwardingPlayer(

override fun getTotalBufferedDuration(): Long = player.totalBufferedDuration

@Deprecated("Deprecated in Java")
override fun isCurrentWindowDynamic(): Boolean = player.isCurrentWindowDynamic

override fun isCurrentMediaItemDynamic(): Boolean = player.isCurrentMediaItemDynamic

@Deprecated("Deprecated in Java")
override fun isCurrentWindowLive(): Boolean = player.isCurrentWindowLive

override fun isCurrentMediaItemLive(): Boolean = player.isCurrentMediaItemLive

override fun getCurrentLiveOffset(): Long = player.currentLiveOffset

@Deprecated("Deprecated in Java")
override fun isCurrentWindowSeekable(): Boolean = player.isCurrentWindowSeekable

override fun isCurrentMediaItemSeekable(): Boolean = player.isCurrentMediaItemSeekable
Expand Down Expand Up @@ -430,6 +444,7 @@ class ReplaceableForwardingPlayer(

override fun isDeviceMuted(): Boolean = player.isDeviceMuted

@Deprecated("Deprecated in Java")
override fun setDeviceVolume(volume: Int) {
player.deviceVolume = volume
}
Expand All @@ -438,18 +453,21 @@ class ReplaceableForwardingPlayer(
player.setDeviceVolume(volume, flags)
}

@Deprecated("Deprecated in Java")
override fun increaseDeviceVolume() = player.increaseDeviceVolume()

override fun increaseDeviceVolume(flags: Int) {
player.increaseDeviceVolume(flags)
}

@Deprecated("Deprecated in Java")
override fun decreaseDeviceVolume() = player.decreaseDeviceVolume()

override fun decreaseDeviceVolume(flags: Int) {
player.decreaseDeviceVolume(flags)
}

@Deprecated("Deprecated in Java")
override fun setDeviceMuted(muted: Boolean) {
player.isDeviceMuted = muted
}
Expand Down Expand Up @@ -488,6 +506,7 @@ class ReplaceableForwardingPlayer(
}
}

@Deprecated("Deprecated in Java")
override fun onLoadingChanged(isLoading: Boolean) {
for (listener in externalListeners) {
listener.onLoadingChanged(isLoading)
Expand All @@ -506,6 +525,7 @@ class ReplaceableForwardingPlayer(
}
}

@Deprecated("Deprecated in Java")
override fun onPlayerStateChanged(playWhenReady: Boolean, playbackState: Int) {
for (listener in externalListeners) {
listener.onPlayerStateChanged(playWhenReady, playbackState)
Expand Down Expand Up @@ -554,6 +574,7 @@ class ReplaceableForwardingPlayer(
}
}

@Deprecated("Deprecated in Java")
override fun onPositionDiscontinuity(reason: Int) {
for (listener in externalListeners) {
listener.onPositionDiscontinuity(reason)
Expand Down Expand Up @@ -648,6 +669,7 @@ class ReplaceableForwardingPlayer(
}
}

@Deprecated("Deprecated in Java")
override fun onCues(cues: MutableList<Cue>) {
for (listener in externalListeners) {
listener.onCues(cues)
Expand Down
Loading
Loading