Skip to content

Commit

Permalink
Check if email verified before allowing to update avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamGrzybkowski committed Jan 8, 2025
1 parent eb664ba commit 0e53465
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
39 changes: 28 additions & 11 deletions WordPress/src/main/java/org/wordpress/android/ui/main/MeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import org.wordpress.android.ui.photopicker.MediaPickerLauncher
import org.wordpress.android.ui.photopicker.PhotoPickerActivity
import org.wordpress.android.ui.prefs.AppPrefsWrapper
import org.wordpress.android.ui.utils.UiHelpers
import org.wordpress.android.ui.utils.UiString
import org.wordpress.android.ui.utils.UiString.UiStringText
import org.wordpress.android.util.AppLog
import org.wordpress.android.util.AppLog.T.MAIN
Expand Down Expand Up @@ -202,17 +203,33 @@ class MeFragment : Fragment(R.layout.me_fragment), OnScrollToTopListener {
val showPickerListener = OnClickListener {
AnalyticsTracker.track(ME_GRAVATAR_TAPPED)
if (gravatarQuickEditorFeatureConfig.isEnabled()) {
GravatarQuickEditor.show(
fragment = this@MeFragment,
gravatarQuickEditorParams = GravatarQuickEditorParams {
email = Email(accountStore.account.email)
avatarPickerContentLayout = AvatarPickerContentLayout.Horizontal
},
authenticationMethod = AuthenticationMethod.Bearer(accountStore.accessToken.orEmpty()),
onAvatarSelected = {
loadAvatar(null, true)
},
)
if (accountStore.account.emailVerified) {
GravatarQuickEditor.show(
fragment = this@MeFragment,
gravatarQuickEditorParams = GravatarQuickEditorParams {
email = Email(accountStore.account.email)
avatarPickerContentLayout = AvatarPickerContentLayout.Horizontal
},
authenticationMethod = AuthenticationMethod.Bearer(accountStore.accessToken.orEmpty()),
onAvatarSelected = {
loadAvatar(null, true)
},
)
} else {
view?.let { view ->
sequencer.enqueue(
SnackbarItem(
Info(
view,
UiString.UiStringRes(R.string.avatar_update_email_unverified),
Snackbar.LENGTH_LONG
),
null,
null
)
)
}
}
} else {
showPhotoPickerForGravatar()
}
Expand Down
2 changes: 2 additions & 0 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4972,4 +4972,6 @@ translators: %s: Select control option value e.g: "Auto, 25%". -->
<string name="voice_to_content_generic_error">Post from audio is unavailable at the moment, please try again later.</string>
<string name="gutenberg_native_replace_image" tools:ignore="UnusedResources" a8c-src-lib="gutenberg">Replace image</string>
<string name="default_web_client_id" a8c-src-lib="module:login">placeholder</string>

<string name="avatar_update_email_unverified">To update your avatar, you need to verify your email address first.</string>
</resources>

0 comments on commit 0e53465

Please sign in to comment.