diff --git "a/UMC_6th/.idea/shelf/Uncommitted_changes_before_Checkout_at_5_1_24,_6_28\342\200\257PM_[Changes]/shelved.patch" "b/UMC_6th/.idea/shelf/Uncommitted_changes_before_Checkout_at_5_1_24,_6_28\342\200\257PM_[Changes]/shelved.patch"
new file mode 100644
index 0000000..634edc4
--- /dev/null
+++ "b/UMC_6th/.idea/shelf/Uncommitted_changes_before_Checkout_at_5_1_24,_6_28\342\200\257PM_[Changes]/shelved.patch"
@@ -0,0 +1,15 @@
+Index: .idea/misc.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>\n\n \n \n \n \n \n \n \n
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/.idea/misc.xml b/.idea/misc.xml
+--- a/.idea/misc.xml (revision 9b0e4dfd39a0d809871cce76e037daca604882d8)
++++ b/.idea/misc.xml (date 1714555718657)
+@@ -1,4 +1,3 @@
+-
+
+
+
diff --git a/UMC_6th/.idea/shelf/Uncommitted_changes_before_Checkout_at_5_1_24__6_28PM__Changes_.xml b/UMC_6th/.idea/shelf/Uncommitted_changes_before_Checkout_at_5_1_24__6_28PM__Changes_.xml
new file mode 100644
index 0000000..670425e
--- /dev/null
+++ b/UMC_6th/.idea/shelf/Uncommitted_changes_before_Checkout_at_5_1_24__6_28PM__Changes_.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/UMC_6th/app/build.gradle.kts b/UMC_6th/app/build.gradle.kts
index cf9919f..bdb847a 100644
--- a/UMC_6th/app/build.gradle.kts
+++ b/UMC_6th/app/build.gradle.kts
@@ -7,9 +7,9 @@ android {
namespace = "com.example.umc_6th"
compileSdk = 34
-
buildFeatures{
viewBinding = true
+ dataBinding = true
}
defaultConfig {
applicationId = "com.example.umc_6th"
diff --git a/UMC_6th/app/src/main/AndroidManifest.xml b/UMC_6th/app/src/main/AndroidManifest.xml
index eee2f74..0801937 100644
--- a/UMC_6th/app/src/main/AndroidManifest.xml
+++ b/UMC_6th/app/src/main/AndroidManifest.xml
@@ -12,15 +12,17 @@
android:supportsRtl="true"
android:theme="@style/Theme.UMC_6th"
tools:targetApi="31">
+
+ android:exported="true"
+ android:theme="@style/SplashTheme">
-
+
diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/MainActivity.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/MainActivity.kt
index d361b55..0b1295e 100644
--- a/UMC_6th/app/src/main/java/com/example/umc_6th/MainActivity.kt
+++ b/UMC_6th/app/src/main/java/com/example/umc_6th/MainActivity.kt
@@ -13,42 +13,44 @@ class MainActivity : AppCompatActivity() {
lateinit var binding: ActivityMainBinding
lateinit var activityResultLauncher: ActivityResultLauncher
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- setTheme(R.style.Theme_UMC_6th)
+ setTheme(R.style.SplashTheme)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
- val song = Song(binding.mainMiniplayerTitleTv.text.toString(),binding.mainMiniplayerSingerTv.text.toString())
-
- binding.mainPlayerCl.setOnClickListener{
- //startActivity(Intent(this,SongActivity::class.java))
- val intent = Intent(this,SongActivity::class.java)
- intent.putExtra("title",song.title)
- intent.putExtra("singer",song.singer)
- startActivity(intent)
- }
-
initBottomNavigation()
- Log.d("Song",song.title+song.singer)
-
-// activityResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
-// if (result.resultCode == RESULT_OK) {
-// val data = result.data
-// if (data != null) {
-// val message = data.getStringExtra("message")
-// Log.d("message", message!!)
-// Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
-// }
-// }
-// }
+ val song = Song(
+ binding.mainMiniplayerTitleTv.text.toString(),
+ binding.mainMiniplayerSingerTv.text.toString(),
+ 0,
+ 60,
+ false
+ )
+
+ activityResultLauncher =
+ registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
+ if (result.resultCode == RESULT_OK) {
+ val data = result.data
+ if (data != null) {
+ val message = data.getStringExtra("message")
+ Log.d("message", message!!)
+ Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
+ }
+ }
+ }
- binding.mainPlayerCl.setOnClickListener{
- val intent = Intent(this,SongActivity::class.java)
-// intent.putExtra("title",song.title)
-// intent.putExtra("singer",song.singer)
- startActivity(intent)
+ binding.mainPlayerCl.setOnClickListener {
+ val intent = Intent(this, SongActivity::class.java)
+ intent.putExtra("title", song.title)
+ intent.putExtra("singer", song.singer)
+ intent.putExtra("second", song.second)
+ intent.putExtra("playTime", song.playTime)
+ intent.putExtra("isPlaying", song.isPlaying)
+// startActivity(intent)
+ activityResultLauncher.launch(intent)
}
}
diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/Song.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/Song.kt
index 00b2ab9..faf7ffd 100644
--- a/UMC_6th/app/src/main/java/com/example/umc_6th/Song.kt
+++ b/UMC_6th/app/src/main/java/com/example/umc_6th/Song.kt
@@ -2,5 +2,8 @@ package com.example.umc_6th
data class Song(
val title : String = "",
- val singer : String = ""
+ val singer : String = "",
+ var second : Int = 0,
+ var playTime : Int = 60,
+ var isPlaying : Boolean = false
)
diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/SongActivity.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/SongActivity.kt
index 232ec71..abcc18b 100644
--- a/UMC_6th/app/src/main/java/com/example/umc_6th/SongActivity.kt
+++ b/UMC_6th/app/src/main/java/com/example/umc_6th/SongActivity.kt
@@ -2,6 +2,7 @@ package com.example.umc_6th
import android.content.Intent
import android.os.Bundle
+import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.example.umc_6th.databinding.ActivitySongBinding
@@ -10,12 +11,17 @@ import java.util.Timer
class SongActivity : AppCompatActivity() {
lateinit var binding: ActivitySongBinding
+ lateinit var song: Song
+ lateinit var timer : Timer
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySongBinding.inflate(layoutInflater) // binding 초기화
setContentView(binding.root)
+ initSong()
+ setPlayer(song)
+
var title : String? = null
var singer : String? = null
@@ -26,28 +32,97 @@ class SongActivity : AppCompatActivity() {
binding.songSingerNameTv.text = singer
}
- binding.songDownIb.setOnClickListener{
- val intent = Intent(this, MainActivity::class.java)
- intent.putExtra("message", title + " _ " + singer)
- setResult(RESULT_OK, intent)
- finish()
- }
+// binding.songDownIb.setOnClickListener{
+// val intent = Intent(this, MainActivity::class.java)
+// intent.putExtra("message", title + " _ " + singer)
+// setResult(RESULT_OK, intent)
+// finish()
+// }
+
binding.songMiniplayerIv.setOnClickListener{
- setPlayerStatus(false)
+ setPlayerStatus(true)
}
binding.songPauseIv.setOnClickListener{
- setPlayerStatus(true)
+ setPlayerStatus(false)
}
}
+ private fun initSong(){
+ if(intent.hasExtra("title") && intent.hasExtra("singer")){
+ song = Song(
+ intent.getStringExtra("title")!!,
+ intent.getStringExtra("singer")!!,
+ intent.getIntExtra("second",0),
+ intent.getIntExtra("playTime",0),
+ intent.getBooleanExtra("isPlaying",false)
+ )
+ }
+ startTimer()
+ }
+
+ private fun setPlayer(song: Song){
+ binding.songMusicTitleTv.text = intent.getStringExtra("title")!!
+ binding.songSingerNameTv.text = intent.getStringExtra("singer")!!
+ binding.songStartTimeTv.text = String.format("%02d:%02d",song.second / 60,song.second % 60)
+ binding.songEndTimeTv.text = String.format("%02d:%02d",song.playTime / 60,song.playTime % 60)
+ binding.songProgressSb.progress = (song.second * 1000 / song.playTime)
+
+ setPlayerStatus(song.isPlaying)
+ }
+
fun setPlayerStatus(isPlaying : Boolean){
+ song.isPlaying = isPlaying
+ timer.isPlaying = isPlaying
+
if(isPlaying){
- binding.songMiniplayerIv.visibility= View.VISIBLE
+ binding.songMiniplayerIv.visibility= View.GONE
+ binding.songPauseIv.visibility = View.VISIBLE
+ } else{
+ binding.songMiniplayerIv.visibility=View.VISIBLE
binding.songPauseIv.visibility = View.GONE
}
- else{
- binding.songMiniplayerIv.visibility=View.GONE
- binding.songPauseIv.visibility = View.VISIBLE
+ }
+
+ private fun startTimer(){
+ timer = Timer(song.playTime , song.isPlaying)
+ timer.start()
+ }
+ inner class Timer(private val playTime : Int, var isPlaying: Boolean = true) : Thread(){
+
+ private var second : Int = 0
+ private var mills : Float = 0f
+
+ override fun run() {
+ super.run()
+ try {
+ while (true) {
+ if (second >= playTime) {
+ break
+ }
+
+ while (!isPlaying) {
+ sleep(200)
+ }
+
+ if (isPlaying) {
+ sleep(50)
+ mills += 50
+
+ runOnUiThread {
+ binding.songProgressSb.progress = ((mills / playTime) * 100).toInt()
+ }
+ if (mills % 1000 == 0F) {
+ runOnUiThread {
+ binding.songStartTimeTv.text =
+ String.format("%02d:%02d", second / 60, second % 60)
+ }
+ second++
+ }
+ }
+ }
+ } catch (e: InterruptedException) {
+ Log.d("Song","쓰레드가 죽었습니다. ${e.message}")
+ }
}
}
}
\ No newline at end of file
diff --git a/UMC_6th/app/src/main/res/drawable/splash.xml b/UMC_6th/app/src/main/res/drawable/splash.xml
index ace8a7d..fa90863 100644
--- a/UMC_6th/app/src/main/res/drawable/splash.xml
+++ b/UMC_6th/app/src/main/res/drawable/splash.xml
@@ -2,7 +2,9 @@
-
-
+
\ No newline at end of file
diff --git a/UMC_6th/app/src/main/res/layout/activity_song.xml b/UMC_6th/app/src/main/res/layout/activity_song.xml
index 8021bb9..6b7ff24 100644
--- a/UMC_6th/app/src/main/res/layout/activity_song.xml
+++ b/UMC_6th/app/src/main/res/layout/activity_song.xml
@@ -149,7 +149,7 @@
diff --git a/UMC_6th/app/src/main/res/values/themes.xml b/UMC_6th/app/src/main/res/values/themes.xml
index e28d846..afa26ba 100644
--- a/UMC_6th/app/src/main/res/values/themes.xml
+++ b/UMC_6th/app/src/main/res/values/themes.xml
@@ -4,6 +4,9 @@
-
+
\ No newline at end of file