From cf050bedb1bd2237515ea6b1f4f1b707f96fe8f9 Mon Sep 17 00:00:00 2001 From: Sohyun Date: Tue, 26 Nov 2024 12:29:39 +0900 Subject: [PATCH 1/4] #123 [FEAT] : home feed comment btn click event --- .../java/com/teamwable/ui/shareAdapter/FeedClickListener.kt | 2 +- .../main/java/com/teamwable/ui/shareAdapter/FeedViewHolder.kt | 2 +- feature/home/src/main/java/com/teamwable/home/HomeFragment.kt | 4 +++- .../main/java/com/teamwable/homedetail/HomeDetailFragment.kt | 2 +- .../teamwable/profile/profiletabs/ProfileFeedListFragment.kt | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/ui/src/main/java/com/teamwable/ui/shareAdapter/FeedClickListener.kt b/core/ui/src/main/java/com/teamwable/ui/shareAdapter/FeedClickListener.kt index c914355f..270b4f85 100644 --- a/core/ui/src/main/java/com/teamwable/ui/shareAdapter/FeedClickListener.kt +++ b/core/ui/src/main/java/com/teamwable/ui/shareAdapter/FeedClickListener.kt @@ -15,5 +15,5 @@ interface FeedClickListener { fun onKebabBtnClick(feed: Feed) - fun onCommentBtnClick(postAuthorNickname: String) + fun onCommentBtnClick(postAuthorNickname: String, feedId: Long) } diff --git a/core/ui/src/main/java/com/teamwable/ui/shareAdapter/FeedViewHolder.kt b/core/ui/src/main/java/com/teamwable/ui/shareAdapter/FeedViewHolder.kt index 21e27aca..62113794 100644 --- a/core/ui/src/main/java/com/teamwable/ui/shareAdapter/FeedViewHolder.kt +++ b/core/ui/src/main/java/com/teamwable/ui/shareAdapter/FeedViewHolder.kt @@ -25,7 +25,7 @@ class FeedViewHolder private constructor( setupClickListener(binding.ivFeedProfileImg, binding.tvFeedNickname) { feedClickListener.onPostAuthorProfileClick(item.postAuthorId) } setupClickListener(binding.ivFeedImg) { feedClickListener.onFeedImageClick(item.image) } setupClickListener(binding.btnFeedMore) { feedClickListener.onKebabBtnClick(item) } - setupClickListener(binding.btnFeedComment) { feedClickListener.onCommentBtnClick(item.postAuthorNickname) } + setupClickListener(binding.btnFeedComment) { feedClickListener.onCommentBtnClick(item.postAuthorNickname, item.feedId) } } private fun setupClickListener(vararg views: View, action: () -> Unit) { diff --git a/feature/home/src/main/java/com/teamwable/home/HomeFragment.kt b/feature/home/src/main/java/com/teamwable/home/HomeFragment.kt index 79761425..09abbf2b 100644 --- a/feature/home/src/main/java/com/teamwable/home/HomeFragment.kt +++ b/feature/home/src/main/java/com/teamwable/home/HomeFragment.kt @@ -134,7 +134,9 @@ class HomeFragment : BindingFragment(FragmentHomeBinding::i ) } - override fun onCommentBtnClick(postAuthorNickname: String) {} + override fun onCommentBtnClick(postAuthorNickname: String, feedId: Long) { + navigateToHomeDetailFragment(feedId) + } } private fun handleProfileNavigation(id: Long) { diff --git a/feature/home/src/main/java/com/teamwable/homedetail/HomeDetailFragment.kt b/feature/home/src/main/java/com/teamwable/homedetail/HomeDetailFragment.kt index 7004c747..a64a7fe7 100644 --- a/feature/home/src/main/java/com/teamwable/homedetail/HomeDetailFragment.kt +++ b/feature/home/src/main/java/com/teamwable/homedetail/HomeDetailFragment.kt @@ -234,7 +234,7 @@ class HomeDetailFragment : BindingFragment(FragmentHo ) } - override fun onCommentBtnClick(postAuthorNickname: String) { + override fun onCommentBtnClick(postAuthorNickname: String, feedId: Long) { handleCommentBtnClick(postAuthorNickname, CommentType.PARENT) viewModel.setParentCommentIds(PARENT_COMMENT_DEFAULT, PARENT_COMMENT_DEFAULT) } diff --git a/feature/profile/src/main/java/com/teamwable/profile/profiletabs/ProfileFeedListFragment.kt b/feature/profile/src/main/java/com/teamwable/profile/profiletabs/ProfileFeedListFragment.kt index fe7710fe..81c141f0 100644 --- a/feature/profile/src/main/java/com/teamwable/profile/profiletabs/ProfileFeedListFragment.kt +++ b/feature/profile/src/main/java/com/teamwable/profile/profiletabs/ProfileFeedListFragment.kt @@ -120,7 +120,7 @@ class ProfileFeedListFragment : BindingFragment(Frag ) } - override fun onCommentBtnClick(postAuthorNickname: String) {} + override fun onCommentBtnClick(postAuthorNickname: String, feedId: Long) {} } private fun setAdapter() { From 5d3a6beb89770d438ddaadb818e3e86d99baa0ec Mon Sep 17 00:00:00 2001 From: Sohyun Date: Tue, 26 Nov 2024 15:47:21 +0900 Subject: [PATCH 2/4] #123 [FEAT] : set up comment link --- core/ui/src/main/res/layout/item_comment.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/core/ui/src/main/res/layout/item_comment.xml b/core/ui/src/main/res/layout/item_comment.xml index 00c5f94c..614f256e 100644 --- a/core/ui/src/main/res/layout/item_comment.xml +++ b/core/ui/src/main/res/layout/item_comment.xml @@ -84,6 +84,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="4dp" + android:autoLink="web" android:textAppearance="@style/TextAppearance.Wable.Body4" android:textColor="@color/gray_800" app:layout_constraintEnd_toEndOf="@id/guideline_end" From cdf20df29d41e1ea230f9597feb872742afea390 Mon Sep 17 00:00:00 2001 From: Sohyun Date: Tue, 26 Nov 2024 16:34:21 +0900 Subject: [PATCH 3/4] =?UTF-8?q?#123=20[FEAT]=20:=20=EA=B0=95=EC=A0=9C,=20?= =?UTF-8?q?=EC=84=A0=ED=83=9D=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20?= =?UTF-8?q?=EB=B6=84=EA=B8=B0=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/teamwable/ui/extensions/ContextExt.kt | 9 +++++++-- feature/main/build.gradle.kts | 9 +++++++++ .../com/teamwable/main/AppUpdateHandler.kt | 9 ++++++++- .../java/com/teamwable/main/MainActivity.kt | 19 +++++++++++-------- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/core/ui/src/main/java/com/teamwable/ui/extensions/ContextExt.kt b/core/ui/src/main/java/com/teamwable/ui/extensions/ContextExt.kt index e3bbe762..6dd1ee1d 100644 --- a/core/ui/src/main/java/com/teamwable/ui/extensions/ContextExt.kt +++ b/core/ui/src/main/java/com/teamwable/ui/extensions/ContextExt.kt @@ -146,7 +146,12 @@ fun Context.showAlertDialog( dialog.dismiss() onPositiveClick() } - .setNegativeButton(negativeButtonText) { dialog, _ -> dialog.dismiss() } + val isFlexibleUpdate = negativeButtonText.isNotEmpty() + if (isFlexibleUpdate) builder.setNegativeButton(negativeButtonText) { dialog, _ -> dialog.dismiss() } - builder.create().show() + builder.create().apply { + setCancelable(isFlexibleUpdate) + setCanceledOnTouchOutside(isFlexibleUpdate) + show() + } } diff --git a/feature/main/build.gradle.kts b/feature/main/build.gradle.kts index 4ef7000f..5dc07b02 100644 --- a/feature/main/build.gradle.kts +++ b/feature/main/build.gradle.kts @@ -5,6 +5,15 @@ plugins { } android { namespace = "com.teamwable.main" + + defaultConfig { + val versionCode = libs.versions.versionCode.get().toInt() + buildConfigField("Integer", "VERSION_CODE", "$versionCode") + } + + buildFeatures.apply { + buildConfig = true + } } dependencies { diff --git a/feature/main/src/main/java/com/teamwable/main/AppUpdateHandler.kt b/feature/main/src/main/java/com/teamwable/main/AppUpdateHandler.kt index cc69081f..faecccf6 100644 --- a/feature/main/src/main/java/com/teamwable/main/AppUpdateHandler.kt +++ b/feature/main/src/main/java/com/teamwable/main/AppUpdateHandler.kt @@ -19,10 +19,17 @@ class AppUpdateHandler(private val appUpdateManager: AppUpdateManager) { } fun startUpdate(appUpdateInfo: AppUpdateInfo, activityResultLauncher: ActivityResultLauncher) { + val appUpdateType = if (checkIsImmediate(appUpdateInfo)) AppUpdateType.IMMEDIATE else AppUpdateType.FLEXIBLE appUpdateManager.startUpdateFlowForResult( appUpdateInfo, activityResultLauncher, - AppUpdateOptions.newBuilder(AppUpdateType.FLEXIBLE).build(), + AppUpdateOptions.newBuilder(appUpdateType).build(), ) } + + fun checkIsImmediate(appUpdateInfo: AppUpdateInfo): Boolean { + val isFirstCodeDifferent = (BuildConfig.VERSION_CODE / 100) != (appUpdateInfo.availableVersionCode() / 100) + val isSecondCodeDifferent = ((BuildConfig.VERSION_CODE % 100) / 10) != ((appUpdateInfo.availableVersionCode() % 100) / 10) + return isFirstCodeDifferent || isSecondCodeDifferent + } } diff --git a/feature/main/src/main/java/com/teamwable/main/MainActivity.kt b/feature/main/src/main/java/com/teamwable/main/MainActivity.kt index 6bfedccf..5de52a36 100644 --- a/feature/main/src/main/java/com/teamwable/main/MainActivity.kt +++ b/feature/main/src/main/java/com/teamwable/main/MainActivity.kt @@ -60,7 +60,7 @@ class MainActivity : AppCompatActivity(), Navigation { if (state.installStatus() == InstallStatus.DOWNLOADED) { Timber.i("Download Complete") lifecycleScope.launch { - delay(5000) + delay(1000) appUpdateManager.completeUpdate() } } @@ -88,13 +88,16 @@ class MainActivity : AppCompatActivity(), Navigation { } } - private fun showUpdateDialog(appUpdateInfo: AppUpdateInfo) = showAlertDialog( - title = getString(R.string.label_in_app_update_title), - message = getString(R.string.label_in_app_update_content), - positiveButtonText = getString(R.string.label_in_app_update_yes), - negativeButtonText = getString(R.string.label_in_app_update_next), - onPositiveClick = { appUpdateHelper.startUpdate(appUpdateInfo, activityResultLauncher) }, - ) + private fun showUpdateDialog(appUpdateInfo: AppUpdateInfo) { + val negativeText = if (appUpdateHelper.checkIsImmediate(appUpdateInfo)) "" else getString(R.string.label_in_app_update_next) + showAlertDialog( + title = getString(R.string.label_in_app_update_title), + message = getString(R.string.label_in_app_update_content), + positiveButtonText = getString(R.string.label_in_app_update_yes), + negativeButtonText = negativeText, + onPositiveClick = { appUpdateHelper.startUpdate(appUpdateInfo, activityResultLauncher) }, + ) + } private fun initView() { setBottomNavigation() From 462bf30650150e26b9099cbab90c1d7c166e80e6 Mon Sep 17 00:00:00 2001 From: Sohyun Date: Tue, 26 Nov 2024 16:38:17 +0900 Subject: [PATCH 4/4] #123 [FIX] : fix fcm denied logic --- .../src/main/java/com/teamwable/home/HomeFragment.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/feature/home/src/main/java/com/teamwable/home/HomeFragment.kt b/feature/home/src/main/java/com/teamwable/home/HomeFragment.kt index 09abbf2b..7d01e178 100644 --- a/feature/home/src/main/java/com/teamwable/home/HomeFragment.kt +++ b/feature/home/src/main/java/com/teamwable/home/HomeFragment.kt @@ -228,10 +228,12 @@ class HomeFragment : BindingFragment(FragmentHomeBinding::i private val requestPermission = registerForActivityResult( ActivityResultContracts.RequestPermission(), - ) { - when (it) { - true -> handlePushAlarmPermissionGranted() - false -> handlePushAlarmPermissionDenied() + ) { isGranted -> + when { + isGranted -> handlePushAlarmPermissionGranted() + shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS) -> { + handlePushAlarmPermissionDenied() + } } }