Skip to content

Commit

Permalink
[MOD/#30] 코드 최적화
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Jan 8, 2024
2 parents d688777 + ff021a3 commit c015fef
Show file tree
Hide file tree
Showing 24 changed files with 325 additions and 97 deletions.
13 changes: 9 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">

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

<application
android:name=".MyApp"
Expand All @@ -11,7 +12,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_doorip_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Doorip"
android:theme="@style/splash_delete"
android:usesCleartextTraffic="true"
tools:targetApi="31">

Expand All @@ -32,6 +33,11 @@

<activity
android:name="com.going.presentation.mock.MockActivity"
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.splash.SplashActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
Expand All @@ -42,7 +48,7 @@
</activity>

<activity
android:name="com.going.presentation.auth.LoginActivity"
android:name="com.going.presentation.auth.SignInActivity"
android:exported="false"
android:screenOrientation="portrait" />

Expand All @@ -56,7 +62,6 @@
android:exported="false"
android:screenOrientation="portrait" />


<activity
android:name="com.going.presentation.tendencytest.TendencyTestSplashActivity"
android:exported="false"
Expand All @@ -80,7 +85,7 @@
<activity
android:name="com.going.presentation.tendencytest.result.TendencyTestResultActivity"
android:exported="true"
android:screenOrientation="portrait"/>
android:screenOrientation="portrait" />

</application>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.going.domain.entity.response

data class OngoingListModel(
val title : String,
val startDate : String,
val endDate : String,
val day : Int
val title: String,
val startDate: String,
val endDate: String,
val day: Int
)
3 changes: 2 additions & 1 deletion presentation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.going.presentation.auth

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.activity.viewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.going.presentation.R
import com.going.presentation.databinding.ActivityLoginBinding
import com.going.presentation.databinding.ActivitySigninBinding
import com.going.ui.base.BaseActivity
import com.going.ui.extension.UiState
import com.going.ui.extension.setOnSingleClickListener
Expand All @@ -14,13 +16,14 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach

@AndroidEntryPoint
class LoginActivity : BaseActivity<ActivityLoginBinding>(R.layout.activity_login) {
private val viewModel by viewModels<LoginViewModel>()
class SignInActivity : BaseActivity<ActivitySigninBinding>(R.layout.activity_signin) {
private val viewModel by viewModels<SignInViewModel>()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initKakaoLoginBtnClickListener()
initTermsBtnClickListener()
observeInfo()
}

Expand All @@ -30,6 +33,14 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>(R.layout.activity_login
}
}

private fun initTermsBtnClickListener() {
binding.btnTerms.setOnSingleClickListener {
Intent(Intent.ACTION_VIEW, Uri.parse(TERMS_URL)).apply {
startActivity(this)
}
}
}

private fun observeInfo() {
observeIsAppLoginAvailable()
observePostChangeTokenState()
Expand Down Expand Up @@ -62,4 +73,8 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>(R.layout.activity_login
}
}.launchIn(lifecycleScope)
}

companion object{
const val TERMS_URL = "http://www.naver.com"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import timber.log.Timber
import javax.inject.Inject

@HiltViewModel
class LoginViewModel @Inject constructor(
class SignInViewModel @Inject constructor(
private val loginRepository: LoginRepository,
) : ViewModel() {
private val _postChangeTokenState = MutableStateFlow<UiState<AuthTokenModel>>(UiState.Empty)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.going.presentation.splash

import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkCapabilities

object NetworkManager {
fun checkNetworkState(context: Context): Boolean {
val connectivityManager: ConnectivityManager =
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager

val network = connectivityManager.activeNetwork ?: return false
val actNetwork = connectivityManager.getNetworkCapabilities(network) ?: return false
return when {
actNetwork.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
actNetwork.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
else -> false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.going.presentation.splash

import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import com.going.presentation.R
import com.going.presentation.auth.SignInActivity
import com.going.presentation.databinding.ActivitySplashBinding
import com.going.ui.base.BaseActivity

class SplashActivity : BaseActivity<ActivitySplashBinding>(R.layout.activity_splash) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

checkConnectedNetwork()
}

private fun checkConnectedNetwork() {
if (NetworkManager.checkNetworkState(this)) {
initSplash()
} else {
showNetworkErrorAlertDialog()
}
}

private fun initSplash() {
Handler(Looper.getMainLooper()).postDelayed({
navigateToSignInScreen()
if (false) { // 자동 로그인 판정으로 변경 예정
navigateToMainScreen()
} else {
navigateToSignInScreen()
}
}, 3000)
}

private fun showNetworkErrorAlertDialog() =
AlertDialog.Builder(this)
.setTitle(R.string.notice)
.setMessage(R.string.internet_connect_error)
.setCancelable(false)
.setPositiveButton(
R.string.okay,
) { _, _ ->
finishAffinity()
}
.create()
.show()

private fun navigateToMainScreen() {
// Main이 나오면 구현 예정
finish()
}

private fun navigateToSignInScreen() {
Intent(this, SignInActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(this)
}
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.going.presentation.tripdashboard
import android.os.Bundle
import com.going.presentation.R
import com.going.presentation.databinding.ActivityTripDashBoardBinding
import com.going.presentation.tripdashboard.triplist.OngoingTripFragment
import com.going.ui.base.BaseActivity
import com.google.android.material.tabs.TabLayoutMediator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import com.going.domain.entity.response.CompletedListModel
import com.going.presentation.databinding.ItemDashBoardCompletedBinding
import com.going.ui.extension.ItemDiffCallback

class CompletedAdapter (
private val listener: OnDashBoardSelectedListener) : ListAdapter<CompletedListModel, CompletedViewHolder>(diffUtil) {
class CompletedAdapter(
private val listener: OnDashBoardSelectedListener
) : ListAdapter<CompletedListModel, CompletedViewHolder>(diffUtil) {

interface OnDashBoardSelectedListener {
fun onDashBoardSelectedListener(tripCreate: CompletedListModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import com.going.domain.entity.response.CompletedListModel
import com.going.domain.entity.response.OngoingListModel
import com.going.presentation.R
import com.going.presentation.databinding.FragmentCompletedTripBinding
import com.going.presentation.tripdashboard.TripDashBoardViewModel
import com.going.ui.base.BaseFragment

class CompletedTripFragment : BaseFragment<FragmentCompletedTripBinding>(R.layout.fragment_completed_trip),
CompletedAdapter.OnDashBoardSelectedListener{
class CompletedTripFragment :
BaseFragment<FragmentCompletedTripBinding>(R.layout.fragment_completed_trip),
CompletedAdapter.OnDashBoardSelectedListener {

private val viewModel by activityViewModels<TripDashBoardViewModel>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package com.going.presentation.tripdashboard.triplist

import androidx.recyclerview.widget.RecyclerView
import com.going.domain.entity.response.CompletedListModel
import com.going.domain.entity.response.OngoingListModel
import com.going.presentation.databinding.ItemDashBoardCompletedBinding
import com.going.presentation.databinding.ItemDashBoardOngoingBinding
import com.going.ui.extension.setOnSingleClickListener

class CompletedViewHolder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import com.going.presentation.databinding.ItemDashBoardOngoingBinding
import com.going.ui.extension.ItemDiffCallback

class OngoingAdapter(
private val listener: OnDashBoardSelectedListener) : ListAdapter<OngoingListModel, OngoingViewHolder>(diffUtil) {
private val listener: OnDashBoardSelectedListener
) : ListAdapter<OngoingListModel, OngoingViewHolder>(diffUtil) {

interface OnDashBoardSelectedListener {
fun onDashBoardSelectedListener(tripCreate: OngoingListModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class OngoingViewHolder(
tvDashboardDateStart.text = item.startDate
tvDashboardDateEnd.text = item.endDate

if(item.day <= 0){
if (item.day <= 0) {
layoutDashboardTraveling.visibility = View.VISIBLE
layoutDashboardDayLeft.visibility = View.INVISIBLE
}else{
} else {
tvDashboardDeadlineDay.text = item.day.toString()
}

Expand Down
25 changes: 25 additions & 0 deletions presentation/src/main/res/drawable/ic_warning_mini.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="12dp"
android:height="12dp"
android:viewportWidth="12"
android:viewportHeight="12">
<group>
<clip-path
android:pathData="M0,0h12v12h-12z"/>
<path
android:strokeWidth="1"
android:pathData="M6,11C8.761,11 11,8.761 11,6C11,3.239 8.761,1 6,1C3.239,1 1,3.239 1,6C1,8.761 3.239,11 6,11Z"
android:strokeLineJoin="round"
android:fillColor="#00000000"
android:strokeColor="#9093A8"
android:strokeLineCap="round"/>
<path
android:pathData="M6,3.5C6.276,3.5 6.5,3.724 6.5,4V6C6.5,6.276 6.276,6.5 6,6.5C5.724,6.5 5.5,6.276 5.5,6V4C5.5,3.724 5.724,3.5 6,3.5Z"
android:fillColor="#9093A8"
android:fillType="evenOdd"/>
<path
android:pathData="M5.5,8C5.5,7.724 5.726,7.5 6.002,7.5C6.279,7.5 6.505,7.724 6.505,8C6.505,8.276 6.279,8.5 6.002,8.5C5.726,8.5 5.5,8.276 5.5,8Z"
android:fillColor="#9093A8"
android:fillType="evenOdd"/>
</group>
</vector>
Binary file modified presentation/src/main/res/drawable/img_sign_in_kakao_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions presentation/src/main/res/drawable/text_logo_doorip_red500.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="194dp"
android:height="66dp"
android:viewportWidth="194"
android:viewportHeight="66">
<path
android:pathData="M159.66,17.95V12.4H152.52L152.52,33.65C152.52,33.66 152.52,33.66 152.52,33.66C152.52,33.67 152.52,33.67 152.52,33.68L152.52,66H159.66L159.66,49.38C163.3,52.56 168.06,54.48 173.26,54.48C184.71,54.48 194,45.16 194,33.66C194,22.17 184.71,12.85 173.26,12.85C168.06,12.85 163.3,14.77 159.66,17.95ZM186.81,33.66C186.81,41.18 180.75,47.27 173.26,47.27C165.78,47.27 159.71,41.18 159.71,33.66C159.71,26.15 165.78,20.06 173.26,20.06C180.75,20.06 186.81,26.15 186.81,33.66Z"
android:fillColor="#FF4F17"
android:fillType="evenOdd"/>
<path
android:pathData="M34.34,48.55V53.6H41.48V33.01C41.48,33.01 41.48,33 41.48,33C41.48,33 41.48,32.99 41.48,32.99V0.44L34.34,0.44V17.45C30.7,14.31 25.94,12.4 20.74,12.4C9.28,12.4 0,21.62 0,33C0,44.38 9.28,53.6 20.74,53.6C25.94,53.6 30.7,51.69 34.34,48.55ZM7.19,33C7.19,25.57 13.25,19.54 20.74,19.54C28.22,19.54 34.29,25.57 34.29,33C34.29,40.43 28.22,46.46 20.74,46.46C13.25,46.46 7.19,40.43 7.19,33Z"
android:fillColor="#FF4F17"
android:fillType="evenOdd"/>
<path
android:pathData="M145.1,13.27V53.15H138.09V13.27H145.1ZM141.56,9.39C138.98,9.39 136.91,7.31 136.91,4.7C136.91,2.01 138.98,0 141.56,0C144.14,0 146.28,2.01 146.28,4.7C146.28,7.31 144.14,9.39 141.56,9.39Z"
android:fillColor="#FF4F17"/>
<path
android:pathData="M131.56,12.85V20.14H129.61C124.72,20.73 122.59,24.45 122.64,27.89V53.15H115.51V27.89C115.51,27.89 115.5,23.68 116.48,21.24C117.45,18.84 119.15,16.92 119.15,16.92C121.83,14.05 126.69,12.77 131.56,12.85Z"
android:fillColor="#FF4F17"/>
<path
android:pathData="M78.53,49.47C75.12,52.06 70.85,53.6 66.23,53.6C55.02,53.6 45.93,44.57 45.93,33.44C45.93,22.31 55.02,13.29 66.23,13.29C70.85,13.29 75.12,14.83 78.53,17.42C81.98,14.83 86.3,13.29 90.98,13.29C102.31,13.29 111.49,22.31 111.49,33.44C111.49,44.57 102.31,53.6 90.98,53.6C86.3,53.6 81.98,52.06 78.53,49.47ZM61.72,24.48C62.43,24.8 62.64,25.85 62.19,26.82C61.74,27.79 60.8,28.32 60.09,27.99C59.38,27.67 59.17,26.62 59.62,25.65C60.07,24.68 61.01,24.15 61.72,24.48ZM56.31,26.47C56.76,25.5 56.55,24.45 55.84,24.13C55.13,23.8 54.19,24.33 53.74,25.3C53.29,26.27 53.5,27.32 54.21,27.64C54.92,27.97 55.86,27.44 56.31,26.47ZM55.89,32.15C55.88,31.99 56,31.85 56.16,31.84L63.99,31.22C64.15,31.21 64.29,31.32 64.3,31.48L64.31,31.56C64.49,33.86 62.76,35.88 60.44,36.07C58.12,36.25 56.09,34.53 55.9,32.22L55.89,32.15Z"
android:fillColor="#FF4F17"
android:fillType="evenOdd"/>
</vector>
24 changes: 24 additions & 0 deletions presentation/src/main/res/drawable/text_logo_doorip_white000.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="194dp"
android:height="66dp"
android:viewportWidth="194"
android:viewportHeight="66">
<path
android:pathData="M159.66,17.95V12.4H152.52L152.52,33.65C152.52,33.66 152.52,33.66 152.52,33.66C152.52,33.67 152.52,33.67 152.52,33.68L152.52,66H159.66L159.66,49.38C163.3,52.56 168.06,54.48 173.26,54.48C184.71,54.48 194,45.16 194,33.66C194,22.17 184.71,12.85 173.26,12.85C168.06,12.85 163.3,14.77 159.66,17.95ZM186.81,33.66C186.81,41.18 180.75,47.27 173.26,47.27C165.78,47.27 159.71,41.18 159.71,33.66C159.71,26.15 165.78,20.06 173.26,20.06C180.75,20.06 186.81,26.15 186.81,33.66Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
<path
android:pathData="M34.34,48.55V53.6H41.48V33.01C41.48,33.01 41.48,33 41.48,33C41.48,33 41.48,32.99 41.48,32.99V0.44L34.34,0.44V17.45C30.7,14.31 25.94,12.4 20.74,12.4C9.28,12.4 0,21.62 0,33C0,44.38 9.28,53.6 20.74,53.6C25.94,53.6 30.7,51.69 34.34,48.55ZM7.19,33C7.19,25.57 13.25,19.54 20.74,19.54C28.22,19.54 34.29,25.57 34.29,33C34.29,40.43 28.22,46.46 20.74,46.46C13.25,46.46 7.19,40.43 7.19,33Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
<path
android:pathData="M145.1,13.27V53.15H138.09V13.27H145.1ZM141.56,9.39C138.98,9.39 136.91,7.31 136.91,4.7C136.91,2.01 138.98,0 141.56,0C144.14,0 146.28,2.01 146.28,4.7C146.28,7.31 144.14,9.39 141.56,9.39Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M131.56,12.85V20.14H129.61C124.72,20.73 122.59,24.45 122.64,27.89V53.15H115.51V27.89C115.51,27.89 115.5,23.68 116.48,21.24C117.45,18.84 119.15,16.92 119.15,16.92C121.83,14.05 126.69,12.77 131.56,12.85Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M78.53,49.47C75.12,52.06 70.85,53.6 66.23,53.6C55.02,53.6 45.93,44.57 45.93,33.44C45.93,22.31 55.02,13.29 66.23,13.29C70.85,13.29 75.12,14.83 78.53,17.42C81.98,14.83 86.3,13.29 90.98,13.29C102.31,13.29 111.49,22.31 111.49,33.44C111.49,44.57 102.31,53.6 90.98,53.6C86.3,53.6 81.98,52.06 78.53,49.47ZM61.72,24.48C62.43,24.8 62.64,25.85 62.19,26.82C61.74,27.79 60.8,28.32 60.09,27.99C59.38,27.67 59.17,26.62 59.62,25.65C60.07,24.68 61.01,24.15 61.72,24.48ZM56.31,26.47C56.76,25.5 56.55,24.45 55.84,24.13C55.13,23.8 54.19,24.33 53.74,25.3C53.29,26.27 53.5,27.32 54.21,27.64C54.92,27.97 55.86,27.44 56.31,26.47ZM55.89,32.15C55.88,31.99 56,31.85 56.16,31.84L63.99,31.22C64.15,31.21 64.29,31.32 64.3,31.48L64.31,31.56C64.49,33.86 62.76,35.88 60.44,36.07C58.12,36.25 56.09,34.53 55.9,32.22L55.89,32.15Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</vector>
Loading

0 comments on commit c015fef

Please sign in to comment.