-
Notifications
You must be signed in to change notification settings - Fork 1
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/#63] : profile push alarm #64
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a70d61a
#63 [ADD] : okhttp dependency add
Eonji-sw 42f6ba6
#63 [ADD] : google, fcm dependency add
Eonji-sw bedef06
#63 [ADD] : fcm dependency add
Eonji-sw 644d562
#63 [FEAT] : memberInfoEditModel ๊ตฌํ
Eonji-sw c7a6746
#63 [FEAT] : profile patchProfileUriEdit ๊ตฌํ
Eonji-sw e582451
#63 [MOD] : fragment navigateToAppSettings ์ถ๊ฐ
Eonji-sw ab7ddc1
#63 [FEAT] : profile patchUserProfileUri ๊ตฌํ
Eonji-sw 22a2b15
#63 [FEAT] : profile patchProfileUriEdit ๊ตฌํ
Eonji-sw 36a0051
#63 [FEAT] : profile patchUserProfile ๊ตฌํ
Eonji-sw 7129f3a
#63 [FEAT] : profile ํธ์ฌ ์๋ฆผ ๋ก์ง ๊ตฌํ
Eonji-sw 00aef0c
#63 [UI] : push notification -> push alarm ์ด๋ฆ ๋ณ๊ฒฝ
Eonji-sw 8058564
#63 [MOD] : push notification -> push alarm ์ด๋ฆ ๋ณ๊ฒฝ
Eonji-sw 6dd3775
#63 [MOD] : openUri ํ์ฅํจ์ ์์ฑ
Eonji-sw dd4474e
#63 [MOD] : openUri ํ์ฅํจ์ ์ ์ฉ
Eonji-sw 56ebcc4
#63 [MOD] : navigateToAppSettings ํ์ฅํจ์ ๋ณ๊ฒฝ
Eonji-sw 26014b1
Merge remote-tracking branch 'origin/develop' into feature/#63-profilโฆ
Eonji-sw 8596e51
#63 [MOD] : patchProfileUriEdit ๋ฐ์ดํฐํ file -> string ๋ณ๊ฒฝ
Eonji-sw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
core/model/src/main/java/com/teamwable/model/profile/MemberInfoEditModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.teamwable.model.profile | ||
|
||
data class MemberInfoEditModel( | ||
val nickname: String? = "", | ||
val isAlarmAllowed: Boolean? = false, | ||
val memberIntro: String? = "", | ||
val isPushAlarmAllowed: Boolean? = false, | ||
val fcmToken: String? = "", | ||
val memberLckYears: Int = 0, | ||
val memberFanTeam: String? = "", | ||
val memberDefaultProfileImage: String? = "" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
feature/profile/src/main/java/com/teamwable/profile/hamburger/PushAlarmFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package com.teamwable.profile.hamburger | ||
|
||
import android.Manifest | ||
import android.content.pm.PackageManager | ||
import android.os.Build | ||
import androidx.core.app.NotificationManagerCompat | ||
import androidx.core.content.ContextCompat | ||
import androidx.fragment.app.viewModels | ||
import androidx.lifecycle.flowWithLifecycle | ||
import androidx.navigation.fragment.findNavController | ||
import com.google.android.gms.tasks.OnCompleteListener | ||
import com.google.firebase.messaging.FirebaseMessaging | ||
import com.teamwable.model.profile.MemberInfoEditModel | ||
import com.teamwable.profile.R | ||
import com.teamwable.profile.databinding.FragmentPushAlarmBinding | ||
import com.teamwable.ui.base.BindingFragment | ||
import com.teamwable.ui.extensions.navigateToAppSettings | ||
import com.teamwable.ui.extensions.stringOf | ||
import com.teamwable.ui.extensions.viewLifeCycle | ||
import com.teamwable.ui.extensions.viewLifeCycleScope | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.flow.launchIn | ||
import kotlinx.coroutines.flow.onEach | ||
import timber.log.Timber | ||
|
||
@AndroidEntryPoint | ||
class PushAlarmFragment : BindingFragment<FragmentPushAlarmBinding>(FragmentPushAlarmBinding::inflate) { | ||
private val viewModel by viewModels<ProfileHamburgerViewModel>() | ||
|
||
override fun initView() { | ||
setAppbarText() | ||
setPushAlarmText() | ||
|
||
initPushAlarmSettingClickListener() | ||
initBackBtnClickListener() | ||
|
||
setupUserPushAlarmInfoObserve() | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
refreshPushAlarmPermission() | ||
} | ||
|
||
private fun refreshPushAlarmPermission() { | ||
setPushAlarmText() | ||
when (checkPushAlarmAllowed()) { | ||
true -> handlePushAlarmPermissionGranted() | ||
false -> handlePushAlarmPermissionDenied() | ||
} | ||
} | ||
|
||
private fun handlePushAlarmPermissionGranted() { | ||
FirebaseMessaging.getInstance().token.addOnCompleteListener( | ||
OnCompleteListener { task -> | ||
if (task.isSuccessful) { | ||
viewModel.patchUserProfileUri( | ||
MemberInfoEditModel( | ||
isPushAlarmAllowed = true, | ||
fcmToken = task.result | ||
) | ||
) | ||
Timber.tag("fcm").d("fcm token: $task.result") | ||
} else { | ||
Timber.d(task.exception) | ||
return@OnCompleteListener | ||
} | ||
} | ||
) | ||
} | ||
|
||
private fun handlePushAlarmPermissionDenied() { | ||
viewModel.patchUserProfileUri(MemberInfoEditModel(isPushAlarmAllowed = false)) | ||
} | ||
|
||
private fun setupUserPushAlarmInfoObserve() { | ||
viewModel.pushAlarmAllowedState.flowWithLifecycle(viewLifeCycle).onEach { | ||
viewModel.saveIsPushAlarmAllowed(it) | ||
}.launchIn(viewLifeCycleScope) | ||
} | ||
|
||
private fun initPushAlarmSettingClickListener() { | ||
binding.tvPushAlarmContent.setOnClickListener { | ||
requireContext().navigateToAppSettings() | ||
} | ||
binding.btnPushAlarmMore.setOnClickListener { | ||
requireContext().navigateToAppSettings() | ||
} | ||
} | ||
|
||
|
||
private fun setPushAlarmText() { | ||
binding.tvPushAlarmContent.text = | ||
if (checkPushAlarmAllowed()) getString(R.string.tv_push_alarm_content_on) | ||
else getString(R.string.tv_push_alarm_content_off) | ||
} | ||
|
||
private fun checkPushAlarmAllowed(): Boolean { | ||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
ContextCompat.checkSelfPermission( | ||
requireContext(), | ||
Manifest.permission.POST_NOTIFICATIONS | ||
) == PackageManager.PERMISSION_GRANTED | ||
} else { | ||
NotificationManagerCompat.from(requireContext()).areNotificationsEnabled() | ||
} | ||
} | ||
|
||
private fun setAppbarText() { | ||
binding.viewPushAlarmAppbar.tvProfileAppbarTitle.text = stringOf(R.string.appbar_push_alarm_title) | ||
} | ||
|
||
private fun initBackBtnClickListener() { | ||
binding.viewPushAlarmAppbar.btnProfileAppbarBack.setOnClickListener { | ||
findNavController().popBackStack() | ||
} | ||
} | ||
} |
24 changes: 0 additions & 24 deletions
24
feature/profile/src/main/java/com/teamwable/profile/hamburger/PushNotificationFragment.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p1 : ์ด ํจ์ resume๋ง๊ณ initview์ ๋ฃ์ด์ฃผ์ธ์ฅ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๊ทธ๋ ๊ฒ ํ๋๋ ์๋ฉ๋๋น..,,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ข ๋ ์ข์ ์ฝ๋ ๊ณ ๋ฏผ ์ข ํด๋ด ใ .ใ