Skip to content

Commit

Permalink
[MERGE] #129 -> develop
Browse files Browse the repository at this point in the history
[REFACTOR/#129] ์ต์Šคํ…์…˜ ๋ถ„๋ฆฌ ๋ฐ ์ „์ฒด์ ์ธ QA ํ›„ ์ˆ˜์ •
  • Loading branch information
chattymin authored Jan 16, 2024
2 parents 33a5bcf + 94a0464 commit 051249b
Show file tree
Hide file tree
Showing 34 changed files with 557 additions and 1,182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import androidx.core.content.ContextCompat
fun Activity.setStatusBarColorFromResource(colorResId: Int) {
val statusBarColor = ContextCompat.getColor(this, colorResId)
window.statusBarColor = statusBarColor
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ val Fragment.viewLifeCycle
get() = viewLifecycleOwner.lifecycle

val Fragment.viewLifeCycleScope
get() = viewLifecycleOwner.lifecycleScope
get() = viewLifecycleOwner.lifecycleScope
25 changes: 25 additions & 0 deletions core-ui/src/main/java/com/going/ui/extension/StringExt.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
package com.going.ui.extension

import android.text.SpannableString
import android.text.Spanned
import android.text.style.BulletSpan
import java.text.BreakIterator

fun String?.isJsonObject(): Boolean = this?.startsWith("{") == true && this.endsWith("}")

fun String?.isJsonArray(): Boolean = this?.startsWith("[") == true && this.endsWith("]")

fun String.getGraphemeLength(): Int {
val breakIterator: BreakIterator = BreakIterator.getCharacterInstance()

breakIterator.setText(this)

var count = 0
while (breakIterator.next() != BreakIterator.DONE) {
count++
}

return count
}

fun String.setBulletPoint(): SpannableString {
val string = SpannableString(this)
string.setSpan(BulletSpan(10), 0, this.length - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)

return string
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.going.domain.entity

data class ProfileMock(
val resultImage: Int,
val profileImage: Int,
val downloadImage: Int,
val profileTitle: String,
val profileSubTitle: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@ package com.going.presentation.dashboard

import android.content.Intent
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels
import com.going.presentation.R
import com.going.presentation.databinding.ActivityTripDashBoardBinding
import com.going.presentation.entertrip.StartTripSplashActivity
import com.going.presentation.onboarding.signin.SignInActivity
import com.going.presentation.setting.SettingActivity
import com.going.presentation.util.initOnBackPressedListener
import com.going.ui.base.BaseActivity
import com.going.ui.extension.setOnSingleClickListener
import com.going.ui.extension.toast
import com.google.android.material.tabs.TabLayoutMediator
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class DashBoardActivity :
BaseActivity<ActivityTripDashBoardBinding>(R.layout.activity_trip_dash_board) {

private var backPressedTime: Long = 0

private val tabTextList = listOf(TAB_ONGOING, TAB_COMPLETED)

private val viewModel by viewModels<DashBoardViewModel>()
Expand Down Expand Up @@ -86,21 +82,6 @@ class DashBoardActivity :
}
}

private fun initOnBackPressedListener() {
val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
if (System.currentTimeMillis() - backPressedTime >= SignInActivity.BACK_INTERVAL) {
backPressedTime = System.currentTimeMillis()
toast(getString(R.string.toast_back_pressed))
} else {
finish()
}
}
}
this.onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}


companion object {
const val TAB_ONGOING = "์ง„ํ–‰์ค‘์ธ ์—ฌํ–‰"
const val TAB_COMPLETED = "์ง€๋‚˜๊ฐ„ ์—ฌํ–‰"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import android.content.Intent
import android.os.Bundle
import com.going.presentation.R
import com.going.presentation.databinding.ActivityStartTripSplashBinding
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity
import com.going.presentation.entertrip.createtrip.choosedate.CreateTripActivity
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity
import com.going.ui.base.BaseActivity
import com.going.ui.extension.setOnSingleClickListener

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class CreateTripActivity :
initStartDateClickListener()
initEndDateClickListener()
initNextBtnClickListener()
initBackBtnClickListener()
}

private fun initBindingViewModel() {
Expand Down Expand Up @@ -172,6 +173,11 @@ class CreateTripActivity :
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(this)
}
}
}

private fun initBackBtnClickListener() {
binding.btnCreateBack.setOnSingleClickListener {
finish()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.going.presentation.entertrip.createtrip.choosedate
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.going.domain.entity.NameState
import java.text.BreakIterator
import com.going.ui.extension.getGraphemeLength

class CreateTripViewModel : ViewModel() {
val name = MutableLiveData<String>()
Expand All @@ -24,11 +24,10 @@ class CreateTripViewModel : ViewModel() {
val isTripAvailable = MutableLiveData(false)
var isCheckTripAvailable = MutableLiveData(false)


fun getMaxNameLen() = MAX_TRIP_LEN

fun checkNameAvailable() {
nameLength.value = getGraphemeLength(name.value)
nameLength.value = name.value?.getGraphemeLength()

isNameAvailable.value = when {
nameLength.value == 0 -> NameState.Empty
Expand All @@ -42,18 +41,6 @@ class CreateTripViewModel : ViewModel() {
(isNameAvailable.value == NameState.Success) && isInfoAvailable

checkTripAvailable()

}

private fun getGraphemeLength(value: String?): Int {
BREAK_ITERATOR.setText(value)

var count = 0
while (BREAK_ITERATOR.next() != BreakIterator.DONE) {
count++
}

return count
}

fun checkStartDateAvailable() {
Expand All @@ -79,11 +66,7 @@ class CreateTripViewModel : ViewModel() {
(isTripAvailable.value == true && isStartDateAvailable.value == true && isEndDateAvailable.value == true)
}


companion object {
val BREAK_ITERATOR: BreakIterator = BreakIterator.getCharacterInstance()
const val MAX_TRIP_LEN = 15
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import android.os.Bundle
import com.going.presentation.R
import com.going.presentation.dashboard.DashBoardActivity
import com.going.presentation.databinding.ActivityFinishTripBinding
import com.going.presentation.entertrip.invitetrip.finish.InviteFinishActivity.Companion.DATE_FORMAT
import com.going.presentation.entertrip.invitetrip.finish.InviteFinishActivity.Companion.D_DAY_FORMAT
import com.going.presentation.entertrip.invitetrip.finish.InviteFinishActivity.Companion.TRIP_FORMAT
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.DAY
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.END
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.START
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.TITLE
import com.going.presentation.entertrip.invitetrip.finish.InviteFinishActivity.Companion.DATE_FORMAT
import com.going.presentation.entertrip.invitetrip.finish.InviteFinishActivity.Companion.D_DAY_FORMAT
import com.going.presentation.entertrip.invitetrip.finish.InviteFinishActivity.Companion.TRIP_FORMAT
import com.going.presentation.util.initOnBackPressedListener
import com.going.ui.base.BaseActivity
import com.going.ui.extension.setOnSingleClickListener
import com.kakao.sdk.auth.Constants.CODE
Expand All @@ -31,7 +32,7 @@ class FinishTripActivity :
initCopyCodetvClickListener()
initSendCodeBtnClickListener()
initEnterTripBtnClickListener()

initOnBackPressedListener()
}

private fun initCopyCodetvClickListener() {
Expand Down Expand Up @@ -78,6 +79,4 @@ class FinishTripActivity :
}
}
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,28 @@ package com.going.presentation.entertrip.createtrip.preference

import android.content.Intent
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.going.domain.entity.PreferenceData
import com.going.presentation.R
import com.going.presentation.databinding.ActivityEnterPreferenceBinding
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.CODE
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.DAY
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.END
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.START
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.TITLE
import com.going.presentation.entertrip.createtrip.finish.FinishTripActivity
import com.going.presentation.entertrip.createtrip.choosedate.CreateTripActivity.Companion.END_DAY
import com.going.presentation.entertrip.createtrip.choosedate.CreateTripActivity.Companion.END_MONTH
import com.going.presentation.entertrip.createtrip.choosedate.CreateTripActivity.Companion.END_YEAR
import com.going.presentation.entertrip.createtrip.choosedate.CreateTripActivity.Companion.NAME
import com.going.presentation.entertrip.createtrip.choosedate.CreateTripActivity.Companion.START_DAY
import com.going.presentation.entertrip.createtrip.choosedate.CreateTripActivity.Companion.START_MONTH
import com.going.presentation.entertrip.createtrip.choosedate.CreateTripActivity.Companion.START_YEAR
import com.going.presentation.entertrip.createtrip.finish.FinishTripActivity
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.CODE
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.DAY
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.END
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.START
import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.TITLE
import com.going.presentation.entertrip.preferencetag.PreferenceTagAdapter
import com.going.presentation.entertrip.preferencetag.PreferenceTagDecoration
import com.going.presentation.onboarding.signin.SignInActivity
import com.going.ui.base.BaseActivity
import com.going.ui.extension.UiState
import com.going.ui.extension.setOnSingleClickListener
Expand All @@ -39,8 +37,6 @@ class EnterPreferenceActivity :
BaseActivity<ActivityEnterPreferenceBinding>(R.layout.activity_enter_preference),
PreferenceTagAdapter.OnPreferenceSelectedListener {

private var backPressedTime: Long = 0

private var _adapter: PreferenceTagAdapter? = null
private val adapter get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) }

Expand All @@ -62,8 +58,6 @@ class EnterPreferenceActivity :
initStartBtnClickListener()
getCreateTripInfo()
observeEnterPreferenceListState()
initOnBackPressedListener()

}

private fun initAdapter() {
Expand All @@ -78,7 +72,7 @@ class EnterPreferenceActivity :
}

private fun initBackClickListener() {
binding.btnPreferenceStart.setOnSingleClickListener {
binding.btnPreferenceBack.setOnSingleClickListener {
finish()
}
}
Expand Down Expand Up @@ -126,7 +120,6 @@ class EnterPreferenceActivity :
is UiState.Loading -> return@onEach

is UiState.Empty -> return@onEach

}
}.launchIn(lifecycleScope)
}
Expand All @@ -137,7 +130,7 @@ class EnterPreferenceActivity :
if (isValid) {
binding.btnPreferenceStart.isEnabled = isValid
binding.btnPreferenceStart.setTextColor(
ContextCompat.getColorStateList(this, R.color.white_000)
ContextCompat.getColorStateList(this, R.color.white_000),
)
}
}
Expand All @@ -159,20 +152,6 @@ class EnterPreferenceActivity :
sendTripInfo()
}

private fun initOnBackPressedListener() {
val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
if (System.currentTimeMillis() - backPressedTime >= SignInActivity.BACK_INTERVAL) {
backPressedTime = System.currentTimeMillis()
toast(getString(R.string.toast_back_pressed))
} else {
finish()
}
}
}
this.onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}

override fun onDestroy() {
super.onDestroy()
_adapter = null
Expand Down
Loading

0 comments on commit 051249b

Please sign in to comment.