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
16 changes: 13 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlinKapt)
alias(libs.plugins.google.gms.google.services)
}

android {
Expand Down Expand Up @@ -64,6 +63,17 @@ dependencies {
implementation("androidx.room:room-runtime:2.8.3")
kapt("androidx.room:room-compiler:2.8.3")

implementation (platform("com.google.firebase:firebase-bom:34.5.0"))
implementation ("com.google.firebase:firebase-database-ktx:21.0.0")
//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")

}
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

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

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -25,6 +27,8 @@
<activity
android:name=".SongActivity"
android:exported="true" />
<activity android:name=".LoginActivity" android:exported="true"/>
<activity android:name=".SignupActivity" android:exported="true"/>
</application>

</manifest>
17 changes: 17 additions & 0 deletions app/src/main/java/com/keder/flo/AuthResponse.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.keder.flo

import com.google.gson.annotations.SerializedName


data class AuthResponse(
@SerializedName("isSuccess") val isSuccess: Boolean,
@SerializedName("code") val code: String,
@SerializedName("message") val message: String,
@SerializedName("result") val result: Result?

)

data class Result(
@SerializedName("userIdx") val userIdx: Int,
@SerializedName("jwt") val jwt: String
)
14 changes: 14 additions & 0 deletions app/src/main/java/com/keder/flo/AuthRetrofitInterface.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.keder.flo

import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.POST

interface AuthRetrofitInterface {
@POST("/users")
fun signUp(@Body user: User): Call<AuthResponse>

@POST("/users/login")
fun login(@Body user: User): Call<AuthResponse>

}
83 changes: 68 additions & 15 deletions app/src/main/java/com/keder/flo/SignupActivity.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.keder.flo

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.keder.flo.User
import com.keder.flo.databinding.ActivitySignupBinding
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

class SignupActivity : AppCompatActivity() {
private lateinit var binding : ActivitySignupBinding

class SignUpActivity : AppCompatActivity(){

lateinit var binding: ActivitySignupBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -17,31 +23,78 @@ class SignupActivity : AppCompatActivity() {

binding.signupSignupBtn.setOnClickListener {
signUp()
finish()
}
}

private fun getUser() : User{
val email : String = binding.signupIdEt.text.toString() + "@" + binding.signupInputIdEt.text.toString()
val pwd : String = binding.signupPasswordEt.text.toString()
private fun getUser(): User {
val email: String =
binding.signupIdEt.text.toString() + "@" + binding.signupInputIdEt.text.toString()
val name: String = binding.signUpNameEt.text.toString()
val pwd: String = binding.signupPasswordEt.text.toString()

return User(email, pwd)
return User(email, pwd, name)
}

private fun signUp(){
if(binding.signupIdEt.text.toString().isEmpty() || binding.signupInputIdEt.text.toString().isEmpty()){
// private fun signUp() {
// if (binding.signUpIdEt.text.toString().isEmpty() || binding.signUpDirectInputEt.text.toString().isEmpty()) {
// Toast.makeText(this, "์ด๋ฉ”์ผ ํ˜•์‹์ด ์ž˜๋ชป๋˜์—ˆ์Šต๋‹ˆ๋‹ค.", Toast.LENGTH_SHORT).show()
// return
// }
//
// if (binding.signUpPasswordEt.text.toString() != binding.signUpPasswordCheckEt.text.toString()) {
// Toast.makeText(this, "๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.", Toast.LENGTH_SHORT).show()
// return
// }
//
// val userDB = SongDatabase.getInstance(this)!!
// userDB.userDao().insert(getUser())
//
// val users = userDB.userDao().getUsers()
//
// Log.d("SIGNUPACT", users.toString())
// }

private fun signUp() {
if (binding.signupIdEt.text.toString()
.isEmpty() || binding.signupInputIdEt.text.toString().isEmpty()
) {
Toast.makeText(this, "์ด๋ฉ”์ผ ํ˜•์‹์ด ์ž˜๋ชป๋˜์—ˆ์Šต๋‹ˆ๋‹ค.", Toast.LENGTH_SHORT).show()
return
}
if(binding.signupPasswordEt.text.toString() != binding.signupPwCheckEt.text.toString()){

if (binding.signupPasswordEt.text.toString() != binding.signupPwCheckEt.text.toString()) {
Toast.makeText(this, "๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.", Toast.LENGTH_SHORT).show()
return
}

val userDB = SongDatabase.getInstance(this)!!
userDB.userDao().insert(getUser())
val authService = getRetrofit().create(AuthRetrofitInterface::class.java)
authService.signUp(getUser()).enqueue(object: Callback<AuthResponse>{
override fun onResponse(
call: Call<AuthResponse?>,
response: Response<AuthResponse?>
) {
Log.d("SIGNUP/SUCCESS", "Hello, FLO")
val resp: AuthResponse = response.body()!!
when(resp.code){
"COMMON201" -> finish()
"AUTH400_1" -> {
binding.signUpEmailErrorTv.visibility = View.VISIBLE
binding.signUpEmailErrorTv.text = resp.message
}
}
}

val user = userDB.userDao().getUsers()
Log.d("SIGNUPACT", user.toString())
override fun onFailure(
call: Call<AuthResponse?>,
t: Throwable
) {
Log.d("SIGNUP/FAILURE", "Hello, FLO")
}

})


Log.d("SIGNUP-ACT/ASYNC", "Hello, FLO")
}

}
14 changes: 14 additions & 0 deletions app/src/main/java/com/keder/flo/User.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.keder.flo

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

@Entity(tableName = "UserTable")
data class User(
@SerializedName(value="email") var email : String,
@SerializedName(value="pasword") var password : String,
@SerializedName(value="name") var name : String,
){
@PrimaryKey(autoGenerate = true) var id : Int = 0
}
39 changes: 38 additions & 1 deletion app/src/main/res/layout/activity_signup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,43 @@
app:layout_constraintEnd_toEndOf="@id/signup_input_id_et"
app:layout_constraintTop_toTopOf="@id/signup_input_id_et"/>


<TextView
android:id="@+id/sign_up_email_error_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/design_default_color_error"
android:textSize="14sp"
android:textStyle="bold"
android:layout_marginTop="10dp"
android:layout_marginStart="20dp"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/signup_id_underline_v"/>

<EditText
android:id="@+id/sign_up_name_et"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="20dp"
android:background="@null"
android:hint="์ด๋ฆ„"
android:inputType="textPersonName"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/sign_up_email_error_tv" />

<View
android:id="@+id/sign_up_name_underscore_view"
android:layout_width="150dp"
android:layout_height="1px"
android:layout_marginTop="15dp"
android:background="#a8a8a8"
app:layout_constraintStart_toStartOf="@+id/signup_password_et"
app:layout_constraintTop_toBottomOf="@+id/sign_up_name_et"/>

<EditText
android:id="@+id/signup_password_et"
android:layout_width="0dp"
Expand All @@ -102,7 +139,7 @@
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/signup_address_underline_v"/>
app:layout_constraintTop_toBottomOf="@id/sign_up_name_underscore_view"/>

<View
android:id="@+id/signup_pw_underline_v"
Expand Down