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

[Feature/#123] : select by version, force update #126

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ interface FeedClickListener {

fun onKebabBtnClick(feed: Feed)

fun onCommentBtnClick(postAuthorNickname: String)
fun onCommentBtnClick(postAuthorNickname: String, feedId: Long)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions core/ui/src/main/res/layout/item_comment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 9 additions & 5 deletions feature/home/src/main/java/com/teamwable/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(FragmentHomeBinding::i
)
}

override fun onCommentBtnClick(postAuthorNickname: String) {}
override fun onCommentBtnClick(postAuthorNickname: String, feedId: Long) {
navigateToHomeDetailFragment(feedId)
}
}

private fun handleProfileNavigation(id: Long) {
Expand Down Expand Up @@ -226,10 +228,12 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(FragmentHomeBinding::i

private val requestPermission = registerForActivityResult(
ActivityResultContracts.RequestPermission(),
) {
when (it) {
true -> handlePushAlarmPermissionGranted()
false -> handlePushAlarmPermissionDenied()
) { isGranted ->
when {
isGranted -> handlePushAlarmPermissionGranted()
shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS) -> {
handlePushAlarmPermissionDenied()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class HomeDetailFragment : BindingFragment<FragmentHomeDetailBinding>(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)
}
Expand Down
9 changes: 9 additions & 0 deletions feature/main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ class AppUpdateHandler(private val appUpdateManager: AppUpdateManager) {
}

fun startUpdate(appUpdateInfo: AppUpdateInfo, activityResultLauncher: ActivityResultLauncher<IntentSenderRequest>) {
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
}
Comment on lines +31 to +34
Copy link
Collaborator

Choose a reason for hiding this comment

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

์˜ค ์ด ์ฝ”๋“œ๋Š” ๋ญ”๊ฐ€์š”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

๋ฒ„์ „ ์ฝ”๋“œ abc์ผ ๋•Œ ์‹ ๊ทœ ๋ฒ„์ „๊ณผ ๊ธฐ์กด ๋ฒ„์ „์˜ a, b ๋‹ค๋ฅด๋ฉด ๊ฐ•์ œ ์—…๋ฐ์ดํŠธ๋กœ ํŒ๋ณ„ํ•˜๋Š” ๋กœ์ง์ž…๋‹ˆ๋‹ค!
๋ฒ„์ „ ์ฝ”๋“œ๊ฐ€ int ํ˜•ํƒœ๋ผ์„œ ์ด๋ ‡๊ฒŒ ์ฒ˜๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค~!

}
19 changes: 11 additions & 8 deletions feature/main/src/main/java/com/teamwable/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class ProfileFeedListFragment : BindingFragment<FragmentProfileFeedBinding>(Frag
)
}

override fun onCommentBtnClick(postAuthorNickname: String) {}
override fun onCommentBtnClick(postAuthorNickname: String, feedId: Long) {}
}

private fun setAdapter() {
Expand Down