commit c0b1731e017323c81e399e8f5bab63f8b0576e41 Author: ocean <503259349@qq.com> Date: Tue Apr 16 18:14:11 2024 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2ff426 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties +.idea/.gitignore +.idea/compiler.xml +.idea/deploymentTargetDropDown.xml +.idea/gradle.xml +.idea/kotlinc.xml +.idea/migrations.xml +.idea/misc.xml +.idea/vcs.xml diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..de4cae1 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,68 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") + id("kotlin-kapt") +} + +android { + namespace = "com.player.musicoo" + compileSdk = 34 + + defaultConfig { + applicationId = "com.player.musicoo" + minSdk = 24 + targetSdk = 34 + versionCode = 1 + versionName = "1.0.1" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + + setProperty("archivesBaseName", "Musicoo_${defaultConfig.versionName}(${defaultConfig.versionCode})") + } + + buildTypes { + release { + isMinifyEnabled = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + + buildFeatures { + viewBinding = true + buildConfig = true + } +} + +dependencies { + + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("com.google.android.material:material:1.11.0") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("androidx.media3:media3-session:1.3.1") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + implementation("com.github.bumptech.glide:glide:4.16.0") + implementation("androidx.room:room-ktx:2.6.1") + implementation("androidx.room:room-runtime:2.6.1") + //noinspection KaptUsageInsteadOfKsp + kapt("androidx.room:room-compiler:2.6.1") + implementation("com.geyifeng.immersionbar:immersionbar:3.2.2") + implementation("com.geyifeng.immersionbar:immersionbar-ktx:3.2.2") + implementation("com.github.lihangleo2:ShadowLayout:3.4.0") + + implementation("androidx.media3:media3-exoplayer:1.3.1") + implementation("androidx.media3:media3-ui:1.3.1") + implementation("androidx.media3:media3-common:1.3.1") +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/player/musicoo/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/player/musicoo/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..1bb5a7b --- /dev/null +++ b/app/src/androidTest/java/com/player/musicoo/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.player.musicoo + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.player.musicoo", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..d08809e --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/assets/Real human voice pic/Breathe.png b/app/src/main/assets/Real human voice pic/Breathe.png new file mode 100644 index 0000000..8458f7f Binary files /dev/null and b/app/src/main/assets/Real human voice pic/Breathe.png differ diff --git a/app/src/main/assets/Real human voice pic/Shh Shh.png b/app/src/main/assets/Real human voice pic/Shh Shh.png new file mode 100644 index 0000000..5df2d3d Binary files /dev/null and b/app/src/main/assets/Real human voice pic/Shh Shh.png differ diff --git a/app/src/main/assets/Real human voice pic/Shhh….png b/app/src/main/assets/Real human voice pic/Shhh….png new file mode 100644 index 0000000..df02ebb Binary files /dev/null and b/app/src/main/assets/Real human voice pic/Shhh….png differ diff --git a/app/src/main/assets/Real human voice/Breathe.mp3 b/app/src/main/assets/Real human voice/Breathe.mp3 new file mode 100644 index 0000000..cdb6010 Binary files /dev/null and b/app/src/main/assets/Real human voice/Breathe.mp3 differ diff --git a/app/src/main/assets/Real human voice/Shh Shh.mp3 b/app/src/main/assets/Real human voice/Shh Shh.mp3 new file mode 100644 index 0000000..f67edb5 Binary files /dev/null and b/app/src/main/assets/Real human voice/Shh Shh.mp3 differ diff --git a/app/src/main/assets/Real human voice/Shhh….mp3 b/app/src/main/assets/Real human voice/Shhh….mp3 new file mode 100644 index 0000000..2857e39 Binary files /dev/null and b/app/src/main/assets/Real human voice/Shhh….mp3 differ diff --git a/app/src/main/assets/Sounds of appliances pic/Fireplace.png b/app/src/main/assets/Sounds of appliances pic/Fireplace.png new file mode 100644 index 0000000..fec4f47 Binary files /dev/null and b/app/src/main/assets/Sounds of appliances pic/Fireplace.png differ diff --git a/app/src/main/assets/Sounds of appliances pic/Mountain stream.png b/app/src/main/assets/Sounds of appliances pic/Mountain stream.png new file mode 100644 index 0000000..a132282 Binary files /dev/null and b/app/src/main/assets/Sounds of appliances pic/Mountain stream.png differ diff --git a/app/src/main/assets/Sounds of appliances pic/TV.png b/app/src/main/assets/Sounds of appliances pic/TV.png new file mode 100644 index 0000000..9d31ae9 Binary files /dev/null and b/app/src/main/assets/Sounds of appliances pic/TV.png differ diff --git a/app/src/main/assets/Sounds of appliances pic/Water droplet.png b/app/src/main/assets/Sounds of appliances pic/Water droplet.png new file mode 100644 index 0000000..1b91249 Binary files /dev/null and b/app/src/main/assets/Sounds of appliances pic/Water droplet.png differ diff --git a/app/src/main/assets/Sounds of appliances/Fireplace.mp3 b/app/src/main/assets/Sounds of appliances/Fireplace.mp3 new file mode 100644 index 0000000..33b60da Binary files /dev/null and b/app/src/main/assets/Sounds of appliances/Fireplace.mp3 differ diff --git a/app/src/main/assets/Sounds of appliances/Mountain stream.mp3 b/app/src/main/assets/Sounds of appliances/Mountain stream.mp3 new file mode 100644 index 0000000..70a42b3 Binary files /dev/null and b/app/src/main/assets/Sounds of appliances/Mountain stream.mp3 differ diff --git a/app/src/main/assets/Sounds of appliances/TV.mp3 b/app/src/main/assets/Sounds of appliances/TV.mp3 new file mode 100644 index 0000000..39c928f Binary files /dev/null and b/app/src/main/assets/Sounds of appliances/TV.mp3 differ diff --git a/app/src/main/assets/Sounds of appliances/Water droplet.mp3 b/app/src/main/assets/Sounds of appliances/Water droplet.mp3 new file mode 100644 index 0000000..220a717 Binary files /dev/null and b/app/src/main/assets/Sounds of appliances/Water droplet.mp3 differ diff --git a/app/src/main/assets/Sounds of nature pic/Beach.png b/app/src/main/assets/Sounds of nature pic/Beach.png new file mode 100644 index 0000000..ad39f7a Binary files /dev/null and b/app/src/main/assets/Sounds of nature pic/Beach.png differ diff --git a/app/src/main/assets/Sounds of nature pic/Call of Seagulls.png b/app/src/main/assets/Sounds of nature pic/Call of Seagulls.png new file mode 100644 index 0000000..9f395ce Binary files /dev/null and b/app/src/main/assets/Sounds of nature pic/Call of Seagulls.png differ diff --git a/app/src/main/assets/Sounds of nature pic/Chirping of Birds.png b/app/src/main/assets/Sounds of nature pic/Chirping of Birds.png new file mode 100644 index 0000000..5fde5bc Binary files /dev/null and b/app/src/main/assets/Sounds of nature pic/Chirping of Birds.png differ diff --git a/app/src/main/assets/Sounds of nature pic/Cicada Chirping.png b/app/src/main/assets/Sounds of nature pic/Cicada Chirping.png new file mode 100644 index 0000000..5ffa52f Binary files /dev/null and b/app/src/main/assets/Sounds of nature pic/Cicada Chirping.png differ diff --git a/app/src/main/assets/Sounds of nature pic/Howling Wind.png b/app/src/main/assets/Sounds of nature pic/Howling Wind.png new file mode 100644 index 0000000..f410a0c Binary files /dev/null and b/app/src/main/assets/Sounds of nature pic/Howling Wind.png differ diff --git a/app/src/main/assets/Sounds of nature pic/Nocturnal Insects.png b/app/src/main/assets/Sounds of nature pic/Nocturnal Insects.png new file mode 100644 index 0000000..0628ea0 Binary files /dev/null and b/app/src/main/assets/Sounds of nature pic/Nocturnal Insects.png differ diff --git a/app/src/main/assets/Sounds of nature pic/Seawater Surging.png b/app/src/main/assets/Sounds of nature pic/Seawater Surging.png new file mode 100644 index 0000000..6e6842f Binary files /dev/null and b/app/src/main/assets/Sounds of nature pic/Seawater Surging.png differ diff --git a/app/src/main/assets/Sounds of nature pic/Summer Insects.png b/app/src/main/assets/Sounds of nature pic/Summer Insects.png new file mode 100644 index 0000000..0691a7f Binary files /dev/null and b/app/src/main/assets/Sounds of nature pic/Summer Insects.png differ diff --git a/app/src/main/assets/Sounds of nature pic/waterfall.png b/app/src/main/assets/Sounds of nature pic/waterfall.png new file mode 100644 index 0000000..2f5dba8 Binary files /dev/null and b/app/src/main/assets/Sounds of nature pic/waterfall.png differ diff --git a/app/src/main/assets/Sounds of nature/Beach.mp3 b/app/src/main/assets/Sounds of nature/Beach.mp3 new file mode 100644 index 0000000..5b8fd05 Binary files /dev/null and b/app/src/main/assets/Sounds of nature/Beach.mp3 differ diff --git a/app/src/main/assets/Sounds of nature/Call of Seagulls.mp3 b/app/src/main/assets/Sounds of nature/Call of Seagulls.mp3 new file mode 100644 index 0000000..6d8a496 Binary files /dev/null and b/app/src/main/assets/Sounds of nature/Call of Seagulls.mp3 differ diff --git a/app/src/main/assets/Sounds of nature/Chirping of Birds.mp3 b/app/src/main/assets/Sounds of nature/Chirping of Birds.mp3 new file mode 100644 index 0000000..ce2bcee Binary files /dev/null and b/app/src/main/assets/Sounds of nature/Chirping of Birds.mp3 differ diff --git a/app/src/main/assets/Sounds of nature/Cicada Chirping.mp3 b/app/src/main/assets/Sounds of nature/Cicada Chirping.mp3 new file mode 100644 index 0000000..6f761d8 Binary files /dev/null and b/app/src/main/assets/Sounds of nature/Cicada Chirping.mp3 differ diff --git a/app/src/main/assets/Sounds of nature/Howling Wind.mp3 b/app/src/main/assets/Sounds of nature/Howling Wind.mp3 new file mode 100644 index 0000000..101f086 Binary files /dev/null and b/app/src/main/assets/Sounds of nature/Howling Wind.mp3 differ diff --git a/app/src/main/assets/Sounds of nature/Nocturnal Insects.mp3 b/app/src/main/assets/Sounds of nature/Nocturnal Insects.mp3 new file mode 100644 index 0000000..7f4bdb6 Binary files /dev/null and b/app/src/main/assets/Sounds of nature/Nocturnal Insects.mp3 differ diff --git a/app/src/main/assets/Sounds of nature/Seawater Surging.mp3 b/app/src/main/assets/Sounds of nature/Seawater Surging.mp3 new file mode 100644 index 0000000..8542f97 Binary files /dev/null and b/app/src/main/assets/Sounds of nature/Seawater Surging.mp3 differ diff --git a/app/src/main/assets/Sounds of nature/Summer Insects.mp3 b/app/src/main/assets/Sounds of nature/Summer Insects.mp3 new file mode 100644 index 0000000..6a6042e Binary files /dev/null and b/app/src/main/assets/Sounds of nature/Summer Insects.mp3 differ diff --git a/app/src/main/assets/Sounds of nature/waterfall.mp3 b/app/src/main/assets/Sounds of nature/waterfall.mp3 new file mode 100644 index 0000000..eb0d096 Binary files /dev/null and b/app/src/main/assets/Sounds of nature/waterfall.mp3 differ diff --git a/app/src/main/assets/resources.json b/app/src/main/assets/resources.json new file mode 100644 index 0000000..bbc2846 --- /dev/null +++ b/app/src/main/assets/resources.json @@ -0,0 +1,99 @@ +{ + "categories": [ + { + "name": "Real human voice", + "audios": [ + { + "name": "Breathe", + "file": "Real human voice/Breathe.mp3", + "image": "Real human voice pic/Breathe.png" + }, + { + "name": "Shh Shh", + "file": "Real human voice/Shh Shh.mp3", + "image": "Real human voice pic/Shh Shh.png" + }, + { + "name": "Shhh...", + "file": "Real human voice/Shhh….mp3", + "image": "Real human voice pic/Shhh….png" + } + ] + }, + { + "name": "Sounds of appliances", + "audios": [ + { + "name": "Fireplace", + "file": "Sounds of appliances/Fireplace.mp3", + "image": "Sounds of appliances pic/Fireplace.png" + }, + { + "name": "Mountain stream", + "file": "Sounds of appliances/Mountain stream.mp3", + "image": "Sounds of appliances pic/Mountain stream.png" + }, + { + "name": "TV", + "file": "Sounds of appliances/TV.mp3", + "image": "Sounds of appliances pic/TV.png" + }, + { + "name": "Water droplet", + "file": "Sounds of appliances/Water droplet.mp3", + "image": "Sounds of appliances pic/Water droplet.png" + } + ] + }, + { + "name": "Sounds of nature", + "audios": [ + { + "name": "Beach", + "file": "Sounds of nature/Beach.mp3", + "image": "Sounds of nature pic/Beach.png" + }, + { + "name": "Call of Seagulls", + "file": "Sounds of nature/Call of Seagulls.mp3", + "image": "Sounds of nature pic/Call of Seagulls.png" + }, + { + "name": "Chirping of Birds", + "file": "Sounds of nature/Chirping of Birds.mp3", + "image": "Sounds of nature pic/Chirping of Birds.png" + }, + { + "name": "Cicada Chirping", + "file": "Sounds of nature/Cicada Chirping.mp3", + "image": "Sounds of nature pic/Cicada Chirping.png" + }, + { + "name": "Howling Wind", + "file": "Sounds of nature/Howling Wind.mp3", + "image": "Sounds of nature pic/Howling Wind.png" + }, + { + "name": "Nocturnal Insects", + "file": "Sounds of nature/Nocturnal Insects.mp3", + "image": "Sounds of nature pic/Nocturnal Insects.png" + }, + { + "name": "Seawater Surging", + "file": "Sounds of nature/Seawater Surging.mp3", + "image": "Sounds of nature pic/Seawater Surging.png" + }, + { + "name": "Summer Insects", + "file": "Sounds of nature/Summer Insects.mp3", + "image": "Sounds of nature pic/Summer Insects.png" + }, + { + "name": "waterfall", + "file": "Sounds of nature/waterfall.mp3", + "image": "Sounds of nature pic/waterfall.png" + } + ] + } + ] +} diff --git a/app/src/main/java/com/player/musicoo/App.kt b/app/src/main/java/com/player/musicoo/App.kt new file mode 100644 index 0000000..d527563 --- /dev/null +++ b/app/src/main/java/com/player/musicoo/App.kt @@ -0,0 +1,111 @@ +package com.player.musicoo + +import android.app.Application +import android.content.Context +import android.util.Log +import com.player.musicoo.bean.Audio +import com.player.musicoo.bean.CurrentPlayingAudio +import com.player.musicoo.bean.ResourcesList +import com.player.musicoo.database.AppDatabase +import com.player.musicoo.database.CurrentAudioDatabase +import com.player.musicoo.database.CurrentAudioManager +import com.player.musicoo.database.DatabaseManager +import com.player.musicoo.media.MediaControllerManager +import com.player.musicoo.util.parseResources +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import java.io.BufferedReader +import java.io.InputStreamReader + +class App : Application() { + companion object { + lateinit var app: App + private set + lateinit var currentAudioManager: CurrentAudioManager + private set + lateinit var databaseManager: DatabaseManager + private set + var currentPlayingAudio: CurrentPlayingAudio? = null + private set + lateinit var importList: List