From 592d9f4f4120e684a2b1ebc8988c24044270421b Mon Sep 17 00:00:00 2001 From: crownjoe Date: Tue, 16 Jan 2024 18:08:46 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[FEAT/#100]=20datepicker=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../choosedate/BottomSheetDateContentFragment.kt | 8 +++++++- .../createtrip/choosedate/CreateTripViewModel.kt | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/BottomSheetDateContentFragment.kt b/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/BottomSheetDateContentFragment.kt index 54beb199..691831b8 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/BottomSheetDateContentFragment.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/BottomSheetDateContentFragment.kt @@ -53,11 +53,16 @@ class BottomSheetDateContentFragment(val viewModel: CreateTripViewModel, val isS calendar.set(Calendar.DAY_OF_MONTH, viewModel.endDay.value ?: 0) val endDate = calendar.time - if (startDate.before(endDate)) { + if (startDate.before(endDate) || startDate.equals(endDate)) { dismiss() } else { + viewModel.startYear.value = null + viewModel.endYear.value = null + viewModel.checkStartDateAvailable() + viewModel.checkEndDateAvailable() binding.viewBlank.visibility = View.VISIBLE binding.tvErrorToast.visibility = View.VISIBLE + Handler(Looper.getMainLooper()).postDelayed({ binding.tvErrorToast.visibility = View.INVISIBLE }, 2000) @@ -67,4 +72,5 @@ class BottomSheetDateContentFragment(val viewModel: CreateTripViewModel, val isS } } } + } diff --git a/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/CreateTripViewModel.kt b/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/CreateTripViewModel.kt index 946aa323..04c0bb36 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/CreateTripViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/CreateTripViewModel.kt @@ -71,6 +71,7 @@ class CreateTripViewModel : ViewModel() { checkTripAvailable() } else { isEndDateAvailable.value = false + } } From de929d1cc50e93103466880a77391102f2f6b5af Mon Sep 17 00:00:00 2001 From: crownjoe Date: Tue, 16 Jan 2024 20:54:40 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[FEAT/#100]=20datepicker=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BottomSheetDateContentFragment.kt | 20 +++++++++++++--- .../choosedate/CreateTripViewModel.kt | 2 ++ .../main/res/layout/activity_create_trip.xml | 24 ++++++++++++------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/BottomSheetDateContentFragment.kt b/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/BottomSheetDateContentFragment.kt index 691831b8..9d2edfb2 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/BottomSheetDateContentFragment.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/BottomSheetDateContentFragment.kt @@ -20,9 +20,18 @@ class BottomSheetDateContentFragment(val viewModel: CreateTripViewModel, val isS override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + + destroyToast() initFinishBtnClickListener() } + + private fun destroyToast() { + dialog?.setOnDismissListener { + binding.tvErrorToast.visibility = View.GONE + } + } + private fun sendDateInfo() { if (isStart) { viewModel.startYear.value = binding.dpCreateTripDate.year @@ -41,6 +50,7 @@ class BottomSheetDateContentFragment(val viewModel: CreateTripViewModel, val isS binding.btnCreateTripFinish.setOnSingleClickListener { sendDateInfo() if (viewModel.isStartDateAvailable.value == true && viewModel.isEndDateAvailable.value == true) { + val calendar = Calendar.getInstance() calendar.set(Calendar.YEAR, viewModel.startYear.value ?: 0) @@ -54,17 +64,19 @@ class BottomSheetDateContentFragment(val viewModel: CreateTripViewModel, val isS val endDate = calendar.time if (startDate.before(endDate) || startDate.equals(endDate)) { + viewModel.checkStartDateAvailable() + viewModel.checkEndDateAvailable() dismiss() } else { viewModel.startYear.value = null viewModel.endYear.value = null viewModel.checkStartDateAvailable() viewModel.checkEndDateAvailable() + binding.viewBlank.visibility = View.VISIBLE binding.tvErrorToast.visibility = View.VISIBLE - Handler(Looper.getMainLooper()).postDelayed({ - binding.tvErrorToast.visibility = View.INVISIBLE + binding.tvErrorToast.visibility = View.GONE }, 2000) } } else { @@ -72,5 +84,7 @@ class BottomSheetDateContentFragment(val viewModel: CreateTripViewModel, val isS } } } - } + + + diff --git a/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/CreateTripViewModel.kt b/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/CreateTripViewModel.kt index 04c0bb36..594f428e 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/CreateTripViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/createtrip/choosedate/CreateTripViewModel.kt @@ -62,6 +62,7 @@ class CreateTripViewModel : ViewModel() { checkTripAvailable() } else { isStartDateAvailable.value = false + checkTripAvailable() } } @@ -71,6 +72,7 @@ class CreateTripViewModel : ViewModel() { checkTripAvailable() } else { isEndDateAvailable.value = false + checkTripAvailable() } } diff --git a/presentation/src/main/res/layout/activity_create_trip.xml b/presentation/src/main/res/layout/activity_create_trip.xml index 8eae386f..2d6b3cea 100644 --- a/presentation/src/main/res/layout/activity_create_trip.xml +++ b/presentation/src/main/res/layout/activity_create_trip.xml @@ -18,7 +18,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white_000" - tools:context=".entertrip.createtrip.choosedate.CreateTripActivity"> + tools:context=".entertrip.invitetrip.invitecode.CreateTripActivity"> + + + app:layout_constraintBottom_toBottomOf="@id/btn_create_back" + app:layout_constraintStart_toEndOf="@id/btn_create_back" + app:layout_constraintTop_toTopOf="@id/btn_create_back" /> @@ -89,7 +98,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" - android:layout_marginEnd="4dp" android:text="@{@string/counter(viewModel.nameLength, viewModel.MAX_TRIP_LEN)}" android:textColor="@color/gray_200" app:layout_constraintEnd_toEndOf="@id/et_create_trip_name" From 7c08967bfc70052d41ccd9a917feac394b0ca5e4 Mon Sep 17 00:00:00 2001 From: crownjoe Date: Wed, 17 Jan 2024 00:11:25 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[FEAT/#100]=20=EC=B9=B4=EC=B9=B4=EC=98=A4?= =?UTF-8?q?=ED=86=A1=20=EA=B3=B5=EC=9C=A0=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 1 + app/src/main/AndroidManifest.xml | 15 +++- buildSrc/src/main/kotlin/Dependencies.kt | 1 + presentation/build.gradle.kts | 1 + .../createtrip/finish/FinishTripActivity.kt | 69 ++++++++++++++++--- .../preference/EnterPreferenceActivity.kt | 4 +- .../invitecode/EnterTripActivity.kt | 2 +- presentation/src/main/res/values/strings.xml | 5 ++ 8 files changed, 83 insertions(+), 15 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4a9e40b0..d78124ca 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -105,5 +105,6 @@ dependencies { KakaoDependencies.run { implementation(user) + implementation(share) } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e747582f..69c09434 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -88,7 +88,7 @@ + android:exported="true" + android:screenOrientation="portrait"> + + + + + + + + (R.layout.activity_finish_trip) { private var inviteCode: String = "" - + private var title: String = "" override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -45,7 +51,47 @@ class FinishTripActivity : private fun initSendCodeBtnClickListener() { binding.btnFinishTripSendCode.setOnSingleClickListener { - // TODO : 카카오톡으로 초대코드 보내기 + startKakaoInvite(this) + } + } + + private fun startKakaoInvite(context: Context) { + if (ShareClient.instance.isKakaoTalkSharingAvailable(context)) { + ShareClient.instance.shareCustom( + context, + TEMPLATE_ID.toLong(), + hashMapOf( + "KEY" to inviteCode, + "NAME" to title + ) + ) { sharingResult, error -> + if (error != null) { + Timber.tag(TAG_SHARE).e(error, getString(R.string.invite_error_kakao)) + } else if (sharingResult != null) { + startActivity(sharingResult.intent) + } + } + } else { + val sharerUrl = + WebSharerClient.instance.makeCustomUrl( + TEMPLATE_ID.toLong(), + hashMapOf( + "KEY" to inviteCode, + "NAME" to title + ) + ) + try { + KakaoCustomTabsClient.openWithDefault(context, sharerUrl) + return + } catch (error: UnsupportedOperationException) { + Timber.tag(TAG_SHARE).e(error, getString(R.string.invite_error_browser)) + } + try { + KakaoCustomTabsClient.open(context, sharerUrl) + return + } catch (error: ActivityNotFoundException) { + Timber.tag(TAG_SHARE).e(error, getString(R.string.invite_error_browser)) + } } } @@ -61,15 +107,15 @@ class FinishTripActivity : private fun getTripInfo() { if (intent != null) { - val title = intent.getStringExtra(TITLE) + title = intent.getStringExtra(TITLE) ?: "" val start = intent.getStringExtra(START) val end = intent.getStringExtra(END) - val code = intent.getStringExtra(CODE) + inviteCode = intent.getStringExtra(INVITE_CODE) ?: "" val day = intent.getIntExtra(DAY, 0) binding.tvFinishTripName.text = title binding.tvFinishTripDay.text = String.format(DATE_FORMAT, start, end) - binding.tvInviteCode.text = code + binding.tvInviteCode.text = inviteCode if (day > 0) { binding.tvFinishTripDayLeft.text = String.format(D_DAY_FORMAT, day) @@ -79,5 +125,10 @@ class FinishTripActivity : } } + companion object { + const val TAG_SHARE = "recommendInvite" + const val TEMPLATE_ID = 102829 + } + } diff --git a/presentation/src/main/java/com/going/presentation/entertrip/createtrip/preference/EnterPreferenceActivity.kt b/presentation/src/main/java/com/going/presentation/entertrip/createtrip/preference/EnterPreferenceActivity.kt index ccab259e..3e9d340b 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/createtrip/preference/EnterPreferenceActivity.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/createtrip/preference/EnterPreferenceActivity.kt @@ -10,7 +10,6 @@ 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 @@ -23,6 +22,7 @@ import com.going.presentation.entertrip.createtrip.choosedate.CreateTripActivity 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.invitetrip.invitecode.EnterTripActivity.Companion.INVITE_CODE import com.going.presentation.entertrip.preferencetag.PreferenceTagAdapter import com.going.presentation.entertrip.preferencetag.PreferenceTagDecoration import com.going.presentation.onboarding.signin.SignInActivity @@ -113,7 +113,7 @@ class EnterPreferenceActivity : putExtra(TITLE, state.data.title) putExtra(START, state.data.startDate) putExtra(END, state.data.endDate) - putExtra(CODE, state.data.code) + putExtra(INVITE_CODE, state.data.code) putExtra(DAY, state.data.day) addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) startActivity(this) diff --git a/presentation/src/main/java/com/going/presentation/entertrip/invitetrip/invitecode/EnterTripActivity.kt b/presentation/src/main/java/com/going/presentation/entertrip/invitetrip/invitecode/EnterTripActivity.kt index 3646836a..a0344138 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/invitetrip/invitecode/EnterTripActivity.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/invitetrip/invitecode/EnterTripActivity.kt @@ -120,7 +120,7 @@ class EnterTripActivity : BaseActivity(R.layout.activi const val TITLE = "title" const val START = "start" const val END = "end" - const val CODE = "code" + const val INVITE_CODE = "code" const val DAY = "day" } } diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index aee39e65..b2d93f8f 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -198,4 +198,9 @@ 알차게 여유롭게 + + 카카오톡 초대코드 오류 + 브라우저 오류 + + From 6f5ca4f7f6e2d440fa4677e0f89f21ed0c23d7a2 Mon Sep 17 00:00:00 2001 From: crownjoe Date: Wed, 17 Jan 2024 00:29:18 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[FEAT/#100]=20=EC=BB=A8=ED=94=8C=EB=A6=AD?= =?UTF-8?q?=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 69c09434..310c0ae4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -88,7 +88,7 @@