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

[REFACTOR/#129] 익스텐션 분리 및 전체적인 QA 후 수정 #136

Merged
merged 21 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a30d3ae
[refactor/#129] 이모지 글자 포함 글자 수 세는 함수 extention으로 변경
chattymin Jan 15, 2024
cffdd58
[refactor/#129] 온보딩 확장함수 적용
chattymin Jan 15, 2024
ba0927d
[refactor/#129] 온보딩 확장함수 적용
chattymin Jan 15, 2024
ee1ce81
Merge branch 'develop' into refactor/#129-convert-extention
chattymin Jan 15, 2024
6391aed
[refactor/#129] profile spacer 추가
chattymin Jan 15, 2024
f12dfa0
[fix/#129] profile 재검사에서 뒤로 갈 경우 화면이 꺼지지 않던 기능 수정
chattymin Jan 15, 2024
b0f09db
[fix/#129] 뒤로가기 위치 수정
chattymin Jan 15, 2024
e6c9133
[fix/#129] 이미지 수정
chattymin Jan 15, 2024
c4469e2
[fix/#129] intent 수정 및 미사용 아이콘 삭제
chattymin Jan 15, 2024
f7af051
[fix/#129] setting 프로필 -> 여행 프로필 string 변경
chattymin Jan 16, 2024
02819f9
[fix/#129] 완료 버튼 클릭시 대시보드로 이동
chattymin Jan 16, 2024
c697b73
[fix/#129] 설정 회원탈퇴버튼 bottom margin 수정 및 아이콘 위치 수정
chattymin Jan 16, 2024
692e5c6
[refactor/#129] 이미지 다운로드 기능 확장함수로 분리
chattymin Jan 16, 2024
4ade603
[refactor/#129] 이미지 다운로드 확장함수 적용 및 리스트 분리
chattymin Jan 16, 2024
d290035
[refactor/#129] OnBackPressedListener 익스텐션 분리
chattymin Jan 16, 2024
f6cb684
[refactor/#129] OnBackPressedListener 익스텐션 적용
chattymin Jan 16, 2024
288fc74
[refactor/#129] statusBar color 설정
chattymin Jan 16, 2024
fa96dee
Merge branch 'develop' into refactor/#129-convert-extention
chattymin Jan 16, 2024
a83bd4f
[ADD/#129] 뒤로가기 버튼 추가 및 기능 연결
chattymin Jan 16, 2024
989802b
[ADD/#129] 뒤로가기 버튼 추가 및 기능 연결
chattymin Jan 16, 2024
94a0464
[FEAT/#129] BulletPoit 익스텐션 분리~
chattymin Jan 16, 2024
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
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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아~~~주 깔~~~~~~~꼼해졌ㄴ네요~~~~~~~~~~~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정 감샤합니다 꾸벅


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