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/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/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" 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..7d01e178 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) { @@ -226,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() + } } } 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/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() 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() {