diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 950f967..133d6ba 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,6 +5,11 @@
+
+
+ @style/Theme.UMC_6th
+
+
@style/Theme.UMC_6th
@@ -15,6 +20,11 @@
@style/Theme.UMC_6th
+
+
+ @style/Theme.UMC_6th
+
+
@style/Theme.UMC_6th
@@ -116,30 +126,10 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -176,13 +166,13 @@
@@ -202,7 +192,7 @@
@@ -234,7 +224,7 @@
-
+
{
"associatedIndex": 4
@@ -255,7 +245,7 @@
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true",
- "git-widget-placeholder": "maro/#33",
+ "git-widget-placeholder": "maro/#38",
"last_opened_file_path": "C:/android/MARO_HW1/UMC_6th/app/src/main/java/com/example/umc_6th",
"project.structure.last.edited": "Modules",
"project.structure.proportion": "0.17",
@@ -276,8 +266,8 @@
-
+
@@ -856,7 +846,39 @@
1716779481277
-
+
+
+ 1716879070628
+
+
+
+ 1716879070628
+
+
+
+ 1716879099419
+
+
+
+ 1716879099419
+
+
+
+ 1717575232707
+
+
+
+ 1717575232707
+
+
+
+ 1717579273891
+
+
+
+ 1717579273891
+
+
@@ -881,9 +903,6 @@
-
-
-
@@ -906,6 +925,9 @@
-
+
+
+
+
\ No newline at end of file
diff --git a/UMC_6th/app/src/main/AndroidManifest.xml b/UMC_6th/app/src/main/AndroidManifest.xml
index 13e6aad..9b4930b 100644
--- a/UMC_6th/app/src/main/AndroidManifest.xml
+++ b/UMC_6th/app/src/main/AndroidManifest.xml
@@ -6,6 +6,7 @@
+
-
+
+
+
+
}
diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/AlbumFragment.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/AlbumFragment.kt
index 4018468..15e63bd 100644
--- a/UMC_6th/app/src/main/java/com/example/umc_6th/AlbumFragment.kt
+++ b/UMC_6th/app/src/main/java/com/example/umc_6th/AlbumFragment.kt
@@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.setFragmentResultListener
import com.example.umc_6th.databinding.FragmentAlbumBinding
@@ -15,6 +16,7 @@ class AlbumFragment : Fragment() {
lateinit var binding : FragmentAlbumBinding
private var gson : Gson = Gson()
+ private var isLiked : Boolean = false
private val information = arrayListOf("수록곡","상세정보","영상")
override fun onCreateView(
@@ -24,9 +26,11 @@ class AlbumFragment : Fragment() {
): View? {
binding = inflate(inflater,container,false)
- val albumJson = arguments?.getString("album")
- val album = gson.fromJson(albumJson, Album::class.java)
+ val albumToJson = arguments?.getString("album")
+ val album = gson.fromJson(albumToJson, Album::class.java)
+ isLiked = isLikedAlbum(album.id)
setInit(album)
+ setOnClickListener(album)
binding.albumBackIv.setOnClickListener{
(context as MainActivity).supportFragmentManager.beginTransaction().
@@ -50,30 +54,6 @@ class AlbumFragment : Fragment() {
tab.text = information[position]
}.attach()
-
-// binding.songLalacLayout.setOnClickListener{
-// Toast.makeText(activity,"LILAC",Toast.LENGTH_SHORT).show()
-// }
-//
-// binding.songFluLayout.setOnClickListener {
-// Toast.makeText(activity,"FLU", Toast.LENGTH_SHORT).show()
-// }
-//
-// binding.songCoinLayout.setOnClickListener {
-// Toast.makeText(activity,"Coin", Toast.LENGTH_SHORT).show()
-// }
-//
-// binding.songSpringLayout.setOnClickListener {
-// Toast.makeText(activity,"봄 안녕 봄", Toast.LENGTH_SHORT).show()
-// }
-//
-// binding.songCelebrityLayout.setOnClickListener {
-// Toast.makeText(activity,"Celebrity", Toast.LENGTH_SHORT).show()
-// }
-//
-// binding.songSingLayout.setOnClickListener {
-// Toast.makeText(activity,"돌림노래 (Feat. DEAN)", Toast.LENGTH_SHORT).show()
-// }
return binding.root
}
private fun setInit(album: Album){
@@ -82,4 +62,46 @@ class AlbumFragment : Fragment() {
binding.albumSingerNameTv.text = album.singer.toString()
}
+ private fun getJwt() : Int {
+ val spf = requireActivity().getSharedPreferences("auth", AppCompatActivity.MODE_PRIVATE)
+ return spf.getInt("jwt", 0)
+ }
+
+ private fun likeAlbum(userId : Int, albumId : Int) {
+ val songDB = SongDatabase.getInstance(requireActivity())!!
+ val like = Like(userId, albumId)
+
+ songDB.albumDao().likeAlbum(like)
+ }
+
+ private fun isLikedAlbum(albumId : Int) : Boolean {
+ val songDB = SongDatabase.getInstance(requireActivity())!!
+ val userId = getJwt()
+
+ val likeId : Int? = songDB.albumDao().isLikedAlbum(userId, albumId)
+ return likeId != null
+ }
+
+ private fun disLikeAlbum(albumId : Int) {
+ val songDB = SongDatabase.getInstance(requireActivity())!!
+ val userId = getJwt()
+
+ songDB.albumDao().dislikedAlbum(userId, albumId)
+ }
+
+ private fun setOnClickListener(album : Album) {
+ val userId = getJwt()
+ binding.albumLikeIv.setOnClickListener {
+ if(isLiked) {
+ binding.albumLikeIv.setImageResource(R.drawable.ic_my_like_off)
+ disLikeAlbum(album.id)
+ }
+
+ else {
+ binding.albumLikeIv.setImageResource((R.drawable.ic_my_like_on))
+ likeAlbum(userId, album.id)
+ }
+ }
+
+ }
}
\ No newline at end of file
diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/Like.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/Like.kt
new file mode 100644
index 0000000..54721b2
--- /dev/null
+++ b/UMC_6th/app/src/main/java/com/example/umc_6th/Like.kt
@@ -0,0 +1,12 @@
+package com.example.umc_6th
+
+import androidx.room.Entity
+import androidx.room.PrimaryKey
+
+@Entity(tableName = "LikeTable")
+data class Like(
+ var userId : Int,
+ var albumId : Int
+) {
+ @PrimaryKey(autoGenerate = true) var id : Int = 0
+}
diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/LockerFragment.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/LockerFragment.kt
index e4bfc27..e77715d 100644
--- a/UMC_6th/app/src/main/java/com/example/umc_6th/LockerFragment.kt
+++ b/UMC_6th/app/src/main/java/com/example/umc_6th/LockerFragment.kt
@@ -1,17 +1,19 @@
package com.example.umc_6th
+import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.appcompat.app.AppCompatActivity
import com.example.umc_6th.databinding.FragmentLockerBinding
import com.google.android.material.tabs.TabLayoutMediator
class LockerFragment : Fragment() {
lateinit var binding: FragmentLockerBinding
- private var information = arrayListOf("저장한곡", "음악파일", "저장앨범")
+ private val information = arrayListOf("저장한곡", "음악파일", "저장앨범")
val bottomSheetFragment = BottomSheetFragment()
@@ -37,6 +39,45 @@ class LockerFragment : Fragment() {
bottomSheetFragment.show(requireFragmentManager(),"BottomSheetDialog")
}
+ binding.lockerLoginTv.setOnClickListener {
+ val intent = Intent(requireActivity(), LoginActivity::class.java)
+ startActivity(intent)
+ }
+
return binding.root
}
-}
\ No newline at end of file
+
+ override fun onStart() {
+ super.onStart()
+ initViews()
+ }
+ private fun getJwt() : Int {
+ val spf = requireActivity().getSharedPreferences("auth", AppCompatActivity.MODE_PRIVATE)
+ return spf!!.getInt("jwt", 0)
+ }
+
+ private fun initViews() {
+ val jwt : Int = getJwt()
+ if (jwt == 0) {
+ binding.lockerLoginTv.text="로그인"
+ binding.lockerLoginTv.setOnClickListener {
+ startActivity(Intent(requireActivity(), LoginActivity::class.java))
+ }
+ }
+
+ else {
+ binding.lockerLoginTv.text = "로그아웃"
+ binding.lockerLoginTv.setOnClickListener {
+ logout()
+ startActivity(Intent(requireActivity(), MainActivity::class.java))
+ }
+ }
+ }
+
+ private fun logout() {
+ val spf = activity?.getSharedPreferences("auth", AppCompatActivity.MODE_PRIVATE)
+ val editor = spf!!.edit()
+ editor.remove("jwt")
+ editor.apply()
+ }
+}
diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/LoginActivity.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/LoginActivity.kt
new file mode 100644
index 0000000..e73c11e
--- /dev/null
+++ b/UMC_6th/app/src/main/java/com/example/umc_6th/LoginActivity.kt
@@ -0,0 +1,65 @@
+package com.example.umc_6th
+
+import android.content.Intent
+import android.os.Bundle
+import android.util.Log
+import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
+import com.example.umc_6th.databinding.ActivityLoginBinding
+
+class LoginActivity : AppCompatActivity() {
+
+ lateinit var binding : ActivityLoginBinding
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ binding = ActivityLoginBinding.inflate(layoutInflater)
+ setContentView(binding.root)
+
+ binding.loginSignUpTv.setOnClickListener {
+ val intent = Intent(this, SignUpActivity::class.java)
+ startActivity(intent)
+ }
+
+ binding.loginSignInBtn.setOnClickListener {
+ login()
+ }
+ }
+ private fun login() {
+ if (binding.loginIdEt.text.toString().isEmpty() || binding.loginDirectInputEt.text.toString().isEmpty()) {
+ Toast.makeText(this, "이메일을 입력해주세요", Toast.LENGTH_SHORT).show()
+ return
+ }
+
+ if (binding.loginPasswordEt.text.toString().isEmpty()) {
+ Toast.makeText(this, "비밀번호를 입력해주세요", Toast.LENGTH_SHORT).show()
+ return
+ }
+
+ val email : String = binding.loginIdEt.text.toString() + "@" + binding.loginDirectInputEt.text.toString()
+ val pwd : String = binding.loginPasswordEt.text.toString()
+
+ val songDB = SongDatabase.getInstance(this)!!
+ val user = songDB.userDao().getUser(email, pwd)
+
+ if (user != null) {
+ Log.d("LoginActivity", user.id.toString())
+ saveJwt(user.id)
+ startMainActivity()
+ } else {
+ Toast.makeText(this, "회원 정보가 존재하지 않습니다", Toast.LENGTH_SHORT).show()
+ }
+ }
+
+ private fun saveJwt(jwt : Int) {
+ val spf = getSharedPreferences("auth", MODE_PRIVATE)
+ val editor = spf.edit()
+
+ editor.putInt("jwt", jwt)
+ editor.apply()
+ }
+
+ private fun startMainActivity() {
+ val intent = Intent(this, MainActivity::class.java)
+ startActivity(intent)
+ }
+}
\ No newline at end of file
diff --git a/UMC_6th/app/src/main/java/com/example/umc_6th/LookFragment.kt b/UMC_6th/app/src/main/java/com/example/umc_6th/LookFragment.kt
index 6cff4ae..fd90a41 100644
--- a/UMC_6th/app/src/main/java/com/example/umc_6th/LookFragment.kt
+++ b/UMC_6th/app/src/main/java/com/example/umc_6th/LookFragment.kt
@@ -5,9 +5,37 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.Button
+import android.widget.ScrollView
+import android.widget.TextView
+import androidx.recyclerview.widget.LinearLayoutManager
+import com.example.umc_6th.databinding.FragmentLookBinding
class LookFragment : Fragment() {
+ lateinit var binding: FragmentLookBinding
+ private lateinit var songDB: SongDatabase
+
+ private lateinit var chartBtn : Button
+ private lateinit var videoBtn : Button
+ private lateinit var genreBtn : Button
+ private lateinit var situationBtn : Button
+ private lateinit var audioBtn : Button
+ private lateinit var atmosphereBtn : Button
+
+ private lateinit var buttonList: List