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/week04 xml #5

Open
wants to merge 25 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
21 changes: 20 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.0'
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

android {
namespace 'com.sopt.now'
Expand All @@ -13,8 +16,10 @@ android {
targetSdk 34
versionCode 1
versionName "1.0"
buildConfigField "String", "AUTH_BASE_URL", properties["base.url"]

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

buildTypes {
Expand All @@ -32,16 +37,30 @@ android {
}
buildFeatures {
viewBinding true
apply plugin: 'kotlin-kapt'
buildConfig true
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.core:core-ktx:1.13.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'org.chromium.net:cronet-embedded:119.6045.31'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1'
implementation 'com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0'

// define a BOM and its version
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.10.0"))

// define any required OkHttp artifacts without version
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor")
}
21 changes: 18 additions & 3 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 @@ -11,22 +13,35 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.NOWSOPTAndroid"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".SignUpActivity"
android:name=".activity.HomeActivity"
android:exported="false" />
<activity
android:name=".activity.SignUpActivity"
android:exported="false" />
<activity
android:name=".LoginActivity"
android:name=".activity.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:name=".activity.MainActivity"
android:exported="false" />

<activity
android:name=".activity.ChangePasswordActivity"
android:exported="false" />


</application>

</manifest>
34 changes: 34 additions & 0 deletions app/src/main/java/com/sopt/now/ApiFactory.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.sopt.now

import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
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

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

private 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()
}

inline fun <reified T> create(): T = retrofit.create(T::class.java)
}

object ServicePool {
val authService = ApiFactory.create<AuthService>()
}
32 changes: 32 additions & 0 deletions app/src/main/java/com/sopt/now/AuthService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.sopt.now

import com.sopt.now.dataClass.RequestLogInDto
import com.sopt.now.dataClass.RequestPasswordDto
import com.sopt.now.dataClass.RequestSignUpDto
import com.sopt.now.dataClass.ResponseDto
import com.sopt.now.dataClass.ResponseInfoDto
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.PATCH
import retrofit2.http.POST

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

@POST("member/login")
fun login(@Body request: RequestLogInDto): Call<ResponseDto>

@GET("member/info")
fun info(@Header("memberId") memberId: Int): Call<ResponseInfoDto>

@PATCH("member/password")
fun changePassword(
@Header("memberId") memberId: Int,
@Body request: RequestPasswordDto
): Call<ResponseDto>
}
65 changes: 0 additions & 65 deletions app/src/main/java/com/sopt/now/LoginActivity.kt

This file was deleted.

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

This file was deleted.

Loading