Skip to content
Open
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
1 change: 1 addition & 0 deletions 조나단-조경석/Week_8/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
75 changes: 75 additions & 0 deletions 조나단-조경석/Week_8/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
kotlin("plugin.serialization") version "2.0.21"
id("kotlin-kapt")
}

android {
namespace = "com.example.myapplication"
compileSdk = 36

defaultConfig {
applicationId = "com.example.myapplication"
minSdk = 24
targetSdk = 36
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}

buildFeatures {
dataBinding = true
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.activity)
implementation(libs.androidx.constraintlayout)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
implementation("androidx.core:core-splashscreen:1.0.1")
implementation("me.relex:circleindicator:2.1.6")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")

// RoomDB
implementation("androidx.room:room-ktx:2.4.1")
implementation("androidx.room:room-runtime:2.4.1")
kapt("androidx.room:room-compiler:2.4.1")

//Retrofit
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation("com.squareup.retrofit2:adapter-rxjava2:2.9.0")

//okHttp
implementation("com.squareup.okhttp3:okhttp:4.9.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.9.0")

//Glide
implementation("com.github.bumptech.glide:glide:4.11.0")
annotationProcessor("com.github.bumptech.glide:compiler:4.11.0")
}
21 changes: 21 additions & 0 deletions 조나단-조경석/Week_8/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.myapplication

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.example.myapplication", appContext.packageName)
}
}
47 changes: 47 additions & 0 deletions 조나단-조경석/Week_8/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@drawable/ic_flo_logo"
android:label="@string/app_name"
android:roundIcon="@drawable/ic_flo_logo"
android:supportsRtl="true"
android:theme="@style/Theme.FLO">
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/MysplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".SongActivity"
android:exported="true">
</activity>

<activity
android:name=".SignUpActivity"
android:exported="true">
</activity>

<activity
android:name=".LoginActivity"
android:exported="true">
</activity>

<service
android:name="com.example.util.MusicService"
android:exported="false" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.example.data

import androidx.room.*
import com.example.model.Album
import com.example.model.Like


@Dao
interface AlbumDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(album: Album)

@Update
fun update(album: Album)

@Delete
fun delete(album: Album)

@Query("SELECT * FROM AlbumTable") // 테이블의 모든 값을 가져와라
fun getAlbums(): List<Album>

@Query("SELECT * FROM AlbumTable WHERE id = :id")
fun getAlbum(id: Int): Album

@Insert
fun likeAlbum(like: Like)

@Query("DELETE FROM LikeTable WHERE userId = :userId AND albumId = :albumId")
fun disLikeAlbum(userId: Int, albumId: Int)

@Query("SELECT id FROM LikeTable WHERE userId = :userId AND albumId = :albumId")
fun isLikedAlbum(userId: Int, albumId: Int): Int?

@Query("SELECT AT.* FROM LikeTable as LT LEFT JOIN AlbumTable as AT ON LT.albumId = AT.id WHERE LT.userId = :userId")
fun getLikedAlbums(userId: Int): List<Album>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.data

import androidx.room.*
import com.example.model.Song

@Dao
interface SongDao {
@Insert
fun insert(song: Song)

@Update
fun update(song: Song)

@Delete
fun delete(song: Song)

@Query("SELECT * FROM SongTable")
fun getSongs(): List<Song>

@Query("SELECT * FROM SongTable WHERE id = :id")
fun getSong(id: Int): Song

@Query("UPDATE SongTable SET isLike= :isLike WHERE id = :id")
fun updateIsLikeById(isLike: Boolean,id: Int)

@Query("SELECT * FROM SongTable WHERE isLike= :isLike")
fun getLikedSongs(isLike: Boolean): List<Song>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.example.data

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.example.model.Album
import com.example.model.Like
import com.example.model.Song
import com.example.model.User

@Database(entities = [Song::class, Album::class, User::class, Like::class], version = 1)
abstract class SongDatabase: RoomDatabase() {
abstract fun albumDao(): AlbumDao
abstract fun songDao(): SongDao
abstract fun userDao(): UserDao

companion object {
private var instance: SongDatabase? = null

@Synchronized
fun getInstance(context: Context): SongDatabase? {
if (instance == null) {
synchronized(SongDatabase::class){
instance = Room.databaseBuilder(
context.applicationContext,
SongDatabase::class.java,
"song-database"//다른 데이터 베이스랑 이름겹치면 꼬임
).allowMainThreadQueries().build()
}
}

return instance
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.data

import androidx.room.*
import com.example.model.User


@Dao
interface UserDao {
@Insert
fun insert(user: User)

@Query("SELECT * FROM UserTable")
fun getUsers(): List<User>

@Query("SELECT * FROM UserTable WHERE email = :email AND password = :password")
fun getUser(email: String, password: String): User?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.model

import androidx.room.Entity
import androidx.room.PrimaryKey

//Album table Entity 예시
@Entity(tableName = "AlbumTable")
data class Album (
@PrimaryKey(autoGenerate = true)
var id: Int = 0,

var title: String = "",
var singer: String = "",
var isLike: Boolean = false,
var coverImg: Int? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.model

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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.model

import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "SongTable")
data class Song (
@PrimaryKey(autoGenerate = false)
var id: Int = 0,

var title: String = "",
var singer: String = "",
var second: Int = 0,
var playTime: Int = 0,
var isPlaying: Boolean = false,
var music: String = "",
var coverImg: Int? = null,
var isLike: Boolean = false,
var albumIdx: Int = 0
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.model

data class TitleItem(
val title: String = "",
val firstAlbum: Int = -1,
val firstTitle: String = "",
val firstSinger: String = "",
val secondAlbum: Int = -1,
val secondTitle: String = "",
val secondSinger: String = "",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.example.model

import androidx.room.Entity
import androidx.room.PrimaryKey
import com.google.gson.annotations.SerializedName

@Entity(tableName = "UserTable")
data class User(
@SerializedName(value = "email")val email: String,
@SerializedName(value = "password")val password: String,
@SerializedName(value = "name")val name: String
) {
@PrimaryKey(autoGenerate = true)
var id: Int = 0
}
Loading