Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/week xml 07 #14

Open
wants to merge 17 commits into
base: develop-xml
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@ dependencies {
// define any required OkHttp artifacts without version
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")

implementation 'com.google.android.gms:play-services-location:21.2.0'
}
17 changes: 8 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?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.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
android:allowBackup="true"
Expand All @@ -12,24 +14,21 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.NOWSOPTAndroid"
tools:targetApi="31"
android:usesCleartextTraffic="true">
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".LoginActivity"
android:name=".presentation.Login.LoginActivity"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<activity
android:name=".MainActivity"
android:exported="false"></activity>
android:name=".presentation.MainActivity"
android:exported="false" />
<activity
android:name=".SignUpActivity"
android:name=".presentation.SignUpActivity"
android:exported="false" />
</application>

Expand Down
40 changes: 0 additions & 40 deletions app/src/main/java/com/sopt/now/LoginViewModel.kt

This file was deleted.

42 changes: 0 additions & 42 deletions app/src/main/java/com/sopt/now/SignUpViewModel.kt

This file was deleted.

121 changes: 121 additions & 0 deletions app/src/main/java/com/sopt/now/Test.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//package com.sopt.now
//
//import android.content.pm.PackageManager
//import android.location.Location
//import android.os.Bundle
//import android.os.PersistableBundle
//import android.widget.Toast
//import androidx.activity.result.ActivityResultLauncher
//import androidx.activity.result.contract.ActivityResultContracts
//import androidx.appcompat.app.AlertDialog
//import androidx.appcompat.app.AppCompatActivity
//import androidx.core.app.ActivityCompat
//import androidx.core.content.ContextCompat
//import com.google.android.gms.location.FusedLocationProviderClient
//import com.google.android.gms.location.LocationServices
//import com.sopt.now.databinding.ActivityLoginBinding
//import com.sopt.now.databinding.ActivityTestBinding
//
////class TestActivity : AppCompatActivity(){
//// private lateinit var binding: ActivityTestBinding
////
//// override fun onCreate(savedInstanceState: Bundle?) {
//// super.onCreate(savedInstanceState)
//// binding = ActivityTestBinding.inflate(layoutInflater)
//// setContentView(binding.root)
//// }
////}
//
//class TestActivity : AppCompatActivity() {
//
// private lateinit var binding: ActivityTestBinding
// private lateinit var fusedLocationClient: FusedLocationProviderClient
// private lateinit var requestPermissionLauncher: ActivityResultLauncher<String>
//
// override fun onCreate(savedInstanceState: Bundle?) {
// super.onCreate(savedInstanceState)
// binding = ActivityTestBinding.inflate(layoutInflater)
// setContentView(binding.root)
//
// // μœ„μΉ˜ 제곡자 μ΄ˆκΈ°ν™”
// fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
//
// // κΆŒν•œ μš”μ²­ 런처 μ΄ˆκΈ°ν™”
// requestPermissionLauncher =
// registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted: Boolean ->
// if (isGranted) {
// // κΆŒν•œμ΄ ν—ˆμš©λœ 경우 μœ„μΉ˜ 정보 κ°€μ Έμ˜€κΈ°
// getLastKnownLocation()
// } else {
// // κΆŒν•œμ΄ κ±°λΆ€λœ 경우 처리
// showPermissionDeniedMessage()
// }
// }
//
// binding.getLocationButton.setOnClickListener {
// checkPermissionAndRequestLocation()
// }
// }
//
// private fun checkPermissionAndRequestLocation() {
// when {
// ContextCompat.checkSelfPermission(
// this,
// android.Manifest.permission.ACCESS_FINE_LOCATION
// ) == PackageManager.PERMISSION_GRANTED -> {
// // κΆŒν•œμ΄ 이미 ν—ˆμš©λœ 경우
// getLastKnownLocation()
// }
//
// ActivityCompat.shouldShowRequestPermissionRationale(
// this,
// android.Manifest.permission.ACCESS_FINE_LOCATION
// ) -> {
// // κΆŒν•œ μš”μ²­ 이유 μ„€λͺ…이 ν•„μš”ν•œ 경우
// showRationaleDialog()
// }
//
// else -> {
// // κΆŒν•œ μš”μ²­
// requestPermissionLauncher.launch(android.Manifest.permission.ACCESS_FINE_LOCATION)
// }
// }
// }
//
// private fun getLastKnownLocation() {
// if (ActivityCompat.checkSelfPermission(
// this,
// android.Manifest.permission.ACCESS_FINE_LOCATION
// ) == PackageManager.PERMISSION_GRANTED
// ) {
// fusedLocationClient.lastLocation
// .addOnSuccessListener { location: Location? ->
// // μœ„μΉ˜ 정보λ₯Ό μ„±κ³΅μ μœΌλ‘œ κ°€μ Έμ˜¨ 경우
// if (location != null) {
// binding.locationTextView.text =
// "μœ„λ„: ${location.latitude}, 경도: ${location.longitude}"
// } else {
// binding.locationTextView.text = "μœ„μΉ˜ 정보λ₯Ό κ°€μ Έμ˜¬ 수 μ—†μŠ΅λ‹ˆλ‹€."
// }
// }
// }
// }
//
// private fun showRationaleDialog() {
// // κΆŒν•œ μš”μ²­ 이유λ₯Ό μ‚¬μš©μžμ—κ²Œ μ„€λͺ…ν•˜λŠ” λ‹€μ΄μ–Όλ‘œκ·Έ 등을 ν‘œμ‹œ
// // μ˜ˆμ‹œ: AlertDialogλ₯Ό μ‚¬μš©ν•˜μ—¬ κΆŒν•œ μš”μ²­ 이유 μ„€λͺ…
// AlertDialog.Builder(this)
// .setTitle("κΆŒν•œ ν•„μš”")
// .setMessage("μœ„μΉ˜ 정보λ₯Ό κ°€μ Έμ˜€λ €λ©΄ μœ„μΉ˜ μ ‘κ·Ό κΆŒν•œμ΄ ν•„μš”ν•©λ‹ˆλ‹€.")
// .setPositiveButton("확인") { _, _ ->
// requestPermissionLauncher.launch(android.Manifest.permission.ACCESS_FINE_LOCATION)
// }
// .setNegativeButton("μ·¨μ†Œ", null)
// .show()
// }
//
// private fun showPermissionDeniedMessage() {
// // κΆŒν•œ κ±°λΆ€ μ‹œ μ‚¬μš©μžμ—κ²Œ ν‘œμ‹œν•  λ©”μ‹œμ§€
// Toast.makeText(this, "κΆŒν•œμ΄ κ±°λΆ€λ˜μ—ˆμŠ΅λ‹ˆλ‹€. μœ„μΉ˜ 정보λ₯Ό κ°€μ Έμ˜¬ 수 μ—†μŠ΅λ‹ˆλ‹€.", Toast.LENGTH_SHORT).show()
// }
//}
32 changes: 32 additions & 0 deletions app/src/main/java/com/sopt/now/data/AuthRepoImpl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.sopt.now.data

import com.sopt.now.data.api.AuthService
import com.sopt.now.data.dto.LoginDto.RequestLogInDto
import com.sopt.now.data.dto.SignUp.RequestSignUpDto
import com.sopt.now.domain.AuthRepository
import com.sopt.now.domain.model.AuthEntity
import retrofit2.Response

class AuthRepoImpl(
private val authService: AuthService,
) : AuthRepository {
override suspend fun logIn(authData: AuthEntity): Result<Response<Unit>> = runCatching {
authService.logIn(
request = RequestLogInDto(
authenticationId = authData.id,
password = authData.pw
)
)
}

override suspend fun signUp(authData: AuthEntity): Result<Response<Unit>> = runCatching {
authService.signUp(
RequestSignUpDto(
authenticationId = authData.id,
password = authData.pw,
nickname = authData.name ?: "",
phone = authData.phone ?: ""
)
)
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package com.sopt.now.api
package com.sopt.now.data.api

import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.sopt.now.BuildConfig
import com.sopt.now.compose.BuildConfig
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit

object ApiFactory {
private const val BASE_URL: String = BuildConfig.AUTH_BASE_URL

val loggingInterceptor = HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
}

val client = OkHttpClient.Builder()
.addInterceptor(loggingInterceptor)
.build()

val retrofit: Retrofit by lazy {
Retrofit.Builder()
.client(client)
.baseUrl(BASE_URL)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
package com.sopt.now.api
package com.sopt.now.data.api

import com.sopt.now.dto.LoginDto.RequestLogInDto
import com.sopt.now.dto.SignUp.RequestSignUpDto
import com.sopt.now.dto.LoginDto.ResponseLogInDto
import com.sopt.now.dto.SignUp.ResponseSignUpDto
import com.sopt.now.dto.ResponseUserProfile
import com.sopt.now.data.dto.LoginDto.RequestLogInDto
import com.sopt.now.data.dto.SignUp.RequestSignUpDto
import com.sopt.now.data.dto.LoginDto.ResponseLogInDto
import com.sopt.now.data.dto.SignUp.ResponseSignUpDto
import com.sopt.now.data.dto.ResponseUserProfile
import retrofit2.Call
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST

interface AuthService {
@POST("member/join")
fun signUp(
suspend fun signUp(
@Body request: RequestSignUpDto,
): Call<ResponseSignUpDto>
): Response<Unit>

@POST("member/login")
fun logIn(
suspend fun logIn(
@Body request: RequestLogInDto,
): Call<ResponseLogInDto>
): Response<Unit>

@GET("member/info")
fun getUserInfo(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.dto.LoginDto
package com.sopt.now.data.dto.LoginDto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.dto.LoginDto
package com.sopt.now.data.dto.LoginDto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.sopt.now.dto
package com.sopt.now.data.dto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ResponseUserProfile(
data class ResponseUserProfile( //응닡 ꡬ쑰
@SerialName("code")
val code: Int,
@SerialName("message")
Expand All @@ -13,7 +13,7 @@ data class ResponseUserProfile(
val data: UserData,
) {
@Serializable
data class UserData(
data class UserData( //JSON μ‘λ‹΅μ˜ data ꡬ쑰
@SerialName("authenticationId")
val authenticationId: String,
@SerialName("nickname")
Expand Down
Loading