-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feat/#10 홈 화면 구현
- Loading branch information
Showing
165 changed files
with
6,157 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
app/src/main/java/com/owori/android/auth/data/AuthProvider.kt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
app/src/main/java/com/owori/android/auth/data/MemberRequest.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.owori.android.core | ||
|
||
|
||
object AppConfig { | ||
const val TAG_DEBUG = "TAG_DEBUG" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
app/src/main/java/com/owori/android/core/BaseDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.owori.android.core | ||
|
||
import android.graphics.Color | ||
import android.graphics.drawable.ColorDrawable | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT | ||
import androidx.fragment.app.DialogFragment | ||
import com.owori.android.databinding.DialogBaseBinding | ||
|
||
class BaseDialogFragment( | ||
private val title: String, | ||
private val contents: String, | ||
private val positiveButtonText: String? = null, | ||
private val cancelButtonText: String? = null, | ||
private val onClickPositiveButton: () -> Unit = {} | ||
) : DialogFragment() { | ||
private var _binding: DialogBaseBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
_binding = DialogBaseBinding.inflate(inflater, container, false) | ||
val view = binding.root | ||
dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) | ||
|
||
with(binding) { | ||
titleTextview.text = title | ||
contentsTextview.text = contents | ||
|
||
positiveButtonText?.let { positiveText.text = it } | ||
cancelButtonText?.let { cancelText.text = it } | ||
|
||
cancelButton.setOnClickListener { | ||
dialog?.dismiss() | ||
} | ||
|
||
positiveButton.setOnClickListener { | ||
onClickPositiveButton() | ||
dialog?.dismiss() | ||
} | ||
} | ||
|
||
return view | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
this@BaseDialogFragment.dialog?.window?.setLayout(WRAP_CONTENT, WRAP_CONTENT) | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.owori.android.core | ||
|
||
object Constants { | ||
const val OWORI_DATE_FORMAT = "yyyy-MM-dd" | ||
} |
36 changes: 33 additions & 3 deletions
36
app/src/main/java/com/owori/android/core/OworiApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,44 @@ | ||
package com.owori.android.core | ||
|
||
import android.annotation.SuppressLint | ||
import android.app.Application | ||
import com.kakao.sdk.common.KakaoSdk | ||
import android.content.Context | ||
import androidx.annotation.StringRes | ||
import androidx.lifecycle.DefaultLifecycleObserver | ||
import androidx.lifecycle.LifecycleOwner | ||
import com.owori.android.R | ||
import com.owori.android.module.NetworkConnectionChecker | ||
import com.kakao.sdk.common.KakaoSdk | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class OworiApplication: Application() { | ||
class OworiApplication : Application(), DefaultLifecycleObserver { | ||
override fun onCreate() { | ||
super.onCreate() | ||
super<Application>.onCreate() | ||
context = applicationContext | ||
networkConnectionChecker = NetworkConnectionChecker(context) | ||
KakaoSdk.init(this, getString(R.string.kakao_login_key)) | ||
} | ||
|
||
override fun onStop(owner: LifecycleOwner) { | ||
networkConnectionChecker.unregister() | ||
super.onStop(owner) | ||
} | ||
|
||
override fun onStart(owner: LifecycleOwner) { | ||
networkConnectionChecker.register() | ||
super.onStart(owner) | ||
} | ||
|
||
companion object { | ||
@SuppressLint("StaticFieldLeak") | ||
private lateinit var context: Context | ||
|
||
fun getString(@StringRes stringResId: Int): String { | ||
return context.getString(stringResId) | ||
} | ||
|
||
private lateinit var networkConnectionChecker: NetworkConnectionChecker | ||
fun isOnline() = networkConnectionChecker.isOnline() | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/owori/android/core/di/NetworkModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.owori.android.core.di | ||
|
||
import com.owori.android.R | ||
import com.owori.android.core.OworiApplication | ||
import com.owori.android.data.api.auth.AuthApi | ||
import com.owori.android.module.HttpRequestInterceptor | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import okhttp3.OkHttpClient | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
import retrofit2.converter.scalars.ScalarsConverterFactory | ||
import javax.inject.Singleton | ||
|
||
/* | ||
* Created by JJJoonngg | ||
*/ | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object NetworkModule { | ||
const val NETWORK_EXCEPTION_OFFLINE_CASE = "network status is offline" | ||
const val NETWORK_EXCEPTION_BODY_IS_NULL = "result body is null" | ||
|
||
@Provides | ||
@Singleton | ||
fun provideOKHttpClient(): OkHttpClient { | ||
return OkHttpClient.Builder() | ||
.addInterceptor(HttpRequestInterceptor()) | ||
.retryOnConnectionFailure(false) | ||
.build() | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit { | ||
return Retrofit.Builder() | ||
.client(okHttpClient) | ||
.baseUrl(OworiApplication.getString(R.string.base_url)) | ||
.addConverterFactory(ScalarsConverterFactory.create()) | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.build() | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun provideAuthApi(retrofit: Retrofit): AuthApi { | ||
return retrofit.buildService() | ||
} | ||
|
||
private inline fun <reified T> Retrofit.buildService(): T { | ||
return this.create(T::class.java) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/owori/android/data/api/auth/AuthApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.owori.android.data.api.auth | ||
|
||
import com.owori.android.data.model.SignUpRequest | ||
import com.owori.android.data.model.SignUpResponse | ||
import com.owori.android.module.DataResult | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
/* | ||
* Created by JJJoonngg | ||
*/ | ||
|
||
interface AuthApi { | ||
@POST("/members/kakao") | ||
fun kakaoLogin(@Body data: SignUpRequest) : DataResult<SignUpResponse> | ||
|
||
@POST("/members/google") | ||
fun googleLogin(@Body data: SignUpRequest) : DataResult<SignUpResponse> | ||
|
||
@POST("/members/apple") | ||
fun appleLogin(@Body data: SignUpRequest) : DataResult<SignUpResponse> | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/com/owori/android/data/model/AuthProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.owori.android.data.model | ||
|
||
enum class AuthProvider { | ||
GOOGLE, KAKAO, APPLE | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/owori/android/data/model/SignUpRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.owori.android.data.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class SignUpRequest( | ||
val token: String, | ||
@SerializedName("auth_provider") | ||
val authProvider: AuthProvider | ||
) |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/owori/android/data/model/SignUpResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.owori.android.data.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class SignUpResponse( | ||
@SerializedName("member_name") | ||
val memberId: String, | ||
@SerializedName("is_service_member") | ||
val isMember: Boolean, | ||
@SerializedName("jwt_token") | ||
val token: SignUpResponseToken, | ||
) { | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/owori/android/data/model/SignUpResponseToken.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.owori.android.data.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class SignUpResponseToken ( | ||
@SerializedName("access_token") | ||
val accessToken: String, | ||
@SerializedName("refresh_token") | ||
val refreshToken: String, | ||
) |
Oops, something went wrong.