Skip to content

Commit

Permalink
Merge pull request #24 from pakka-papad/dev
Browse files Browse the repository at this point in the history
Update to 1.2.3
  • Loading branch information
pakka-papad authored Jan 29, 2024
2 parents 9762c01 + bcae2f3 commit 7c0c2c0
Show file tree
Hide file tree
Showing 75 changed files with 858 additions and 611 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/.idea/deploymentTargetDropDown.xml
/.idea/kotlinc.xml
/.idea/misc.xml
/.idea
/buildSrc/build
.DS_Store
/build
Expand Down
14 changes: 12 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
import com.google.protobuf.gradle.builtins
import com.google.protobuf.gradle.generateProtoTasks
import com.google.protobuf.gradle.protobuf
import com.google.protobuf.gradle.protoc
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand All @@ -12,7 +8,7 @@ plugins {
id("dagger.hilt.android.plugin")
id("androidx.navigation.safeargs.kotlin")
id("kotlin-parcelize")
id("com.google.protobuf") version "0.8.19"
id("com.google.protobuf") version "0.9.1"
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
id("dev.shreyaspatil.compose-compiler-report-generator") version "1.1.0"
Expand Down Expand Up @@ -101,14 +97,14 @@ android {
buildFeatures {
compose = true
viewBinding = true
dataBinding = true
buildConfig = true
}

composeOptions {
kotlinCompilerExtensionVersion = Versions.androidxComposeCompiler
}

packagingOptions {
packaging {
resources {
excludes.add("/META-INF/{AL2.0,LGPL2.1}")
}
Expand Down Expand Up @@ -174,10 +170,11 @@ dependencies {
implementation(platform(Libraries.firebaseBom))
implementation(Libraries.firebaseCrashlytics)

implementation(Libraries.exoPlayer)
// implementation(Libraries.exoPlayer)
implementation(Libraries.media3ExoPlayer)
implementation(Libraries.media3Transformer)
implementation(Libraries.exoPlayerUi)
implementation(Libraries.media3Session)
// implementation(Libraries.media3Transformer)
// implementation(Libraries.exoPlayerUi)

implementation(Libraries.coilCompose)
implementation(Libraries.palette)
Expand Down
12 changes: 11 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,14 @@
}
-keep class com.github.pakka_papad.collection.CollectionType

-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }

-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE
2 changes: 1 addition & 1 deletion app/src/debug/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">Debug Zen Music</string>
<string name="app_name">Zen Music - Debug</string>
</resources>
19 changes: 17 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />

<application
android:name=".ZenApp"
Expand All @@ -22,7 +23,7 @@
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:theme="@style/Theme.Zen">
android:theme="@style/Theme.AppSplash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -42,7 +43,14 @@

<service
android:name=".player.ZenPlayer"
android:foregroundServiceType="mediaPlayback" />
android:foregroundServiceType="mediaPlayback"
android:exported="true"
tools:ignore="ExportedService">
<intent-filter>
<action android:name="androidx.media3.session.MediaSessionService" />
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>

<receiver android:name=".widgets.MusicControlWidgetReceiver"
android:exported="true">
Expand All @@ -54,6 +62,13 @@
android:resource="@xml/music_control_widget_info" />
</receiver>

<receiver android:name="androidx.media3.session.MediaButtonReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/assets/changelogs.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,22 @@
]
},
{
"versionCode": 102002,
"versionCode": 10202,
"versionName": "1.2.2",
"date": "6 January, 2024",
"changes": [
"Added sleep timer",
"Updated player screen UI",
"Updated playlist tab UI"
]
},
{
"versionCode": 10203,
"versionName": "1.2.3",
"date": "29 January, 2024",
"changes": [
"Updated logo",
"Added support for playback resumption"
]
}
]
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/src/main/java/com/github/pakka_papad/Constants.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.pakka_papad

object Constants {
const val QUEUE_STATE_FILE = "queue_state.pb"
const val DATABASE_NAME = "zen_app_db"
object Tables {
const val SONG_TABLE = "song_table"
Expand Down
7 changes: 2 additions & 5 deletions app/src/main/java/com/github/pakka_papad/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.pakka_papad

import android.graphics.Color
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
Expand All @@ -21,10 +20,8 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen().apply {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
setKeepOnScreenCondition { preferencesProvider.isOnBoardingComplete.value == null }
} else {
setKeepOnScreenCondition { false }
setKeepOnScreenCondition {
preferencesProvider.isOnBoardingComplete.value == null
}
}
binding = ActivityMainBinding.inflate(layoutInflater)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject
Expand Down Expand Up @@ -178,15 +187,19 @@ class CollectionViewModel @Inject constructor(

fun setQueue(songs: List<Song>?, startPlayingFromIndex: Int = 0) {
if (songs == null) return
queueService.setQueue(songs, startPlayingFromIndex)
playerService.startServiceIfNotRunning(songs, startPlayingFromIndex)
// queueService.setQueue(songs, startPlayingFromIndex)
viewModelScope.launch {
playerService.startServiceIfNotRunning(songs, startPlayingFromIndex)
}
showMessage(messageStore.getString(R.string.playing))
}

fun addToQueue(song: Song) {
if (queue.isEmpty()) {
queueService.setQueue(listOf(song), 0)
playerService.startServiceIfNotRunning(listOf(song), 0)
// queueService.setQueue(listOf(song), 0)
viewModelScope.launch {
playerService.startServiceIfNotRunning(listOf(song), 0)
}
} else {
val result = queueService.append(song)
showMessage(
Expand All @@ -198,8 +211,10 @@ class CollectionViewModel @Inject constructor(

fun addToQueue(songs: List<Song>) {
if (queue.isEmpty()) {
queueService.setQueue(songs, 0)
playerService.startServiceIfNotRunning(songs, 0)
// queueService.setQueue(songs, 0)
viewModelScope.launch {
playerService.startServiceIfNotRunning(songs, 0)
}
} else {
val result = queueService.append(songs)
showMessage(messageStore.getString(if (result) R.string.done else R.string.song_already_in_queue))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.github.pakka_papad.data

import androidx.datastore.core.DataStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.launch
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class QueueStateProvider @Inject constructor(
private val queueState: DataStore<QueueState>,
private val coroutineScope: CoroutineScope,
) {
val state: Flow<QueueState>
get() = queueState.data

fun saveState(queue: List<String>, startIndex: Int, startPosition: Long) {
coroutineScope.launch {
queueState.updateData {
it.copy {
this.locations.apply {
clear()
addAll(queue)
}
this.startIndex = startIndex
this.startPositionMs = startPosition
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.github.pakka_papad.data

import androidx.datastore.core.Serializer
import java.io.InputStream
import java.io.OutputStream

object QueueStateSerializer: Serializer<QueueState> {
override val defaultValue: QueueState
get() = QueueState.getDefaultInstance()

override suspend fun readFrom(input: InputStream): QueueState =
try {
QueueState.parseFrom(input)
} catch (_: Exception) {
defaultValue
}

override suspend fun writeTo(t: QueueState, output: OutputStream) = t.writeTo(output)
}
18 changes: 16 additions & 2 deletions app/src/main/java/com/github/pakka_papad/data/daos/SongDao.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
package com.github.pakka_papad.data.daos

import androidx.room.*
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Transaction
import androidx.room.Update
import com.github.pakka_papad.Constants
import com.github.pakka_papad.data.music.*
import com.github.pakka_papad.data.music.AlbumArtistWithSongCount
import com.github.pakka_papad.data.music.ArtistWithSongCount
import com.github.pakka_papad.data.music.ComposerWithSongCount
import com.github.pakka_papad.data.music.GenreWithSongCount
import com.github.pakka_papad.data.music.LyricistWithSongCount
import com.github.pakka_papad.data.music.Song
import kotlinx.coroutines.flow.Flow

@Dao
Expand Down Expand Up @@ -61,4 +72,7 @@ interface SongDao {

@Query("SELECT * FROM ${Constants.Tables.SONG_TABLE} WHERE favourite = 1")
fun getAllFavourites(): Flow<List<Song>>

@Query("SELECT * FROM ${Constants.Tables.SONG_TABLE} WHERE location IN (:locations)")
suspend fun getSongsFromLocations(locations: List<String>): List<Song>
}
Loading

0 comments on commit 7c0c2c0

Please sign in to comment.