Skip to content

Commit

Permalink
Fix: Check if email verified before allowing to update avatar (#21568)
Browse files Browse the repository at this point in the history
* Check if email verified before allowing to update avatar

* Move the avatar_update_email_unverified string to Gravatar section
  • Loading branch information
AdamGrzybkowski authored Jan 8, 2025
1 parent eb664ba commit dd12e2f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
43 changes: 30 additions & 13 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 @@ -201,20 +202,36 @@ 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) {
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)
},
)
} else {
showPhotoPickerForGravatar()
}
} else {
showPhotoPickerForGravatar()
view?.let { view ->
sequencer.enqueue(
SnackbarItem(
Info(
view,
UiString.UiStringRes(R.string.avatar_update_email_unverified),
Snackbar.LENGTH_LONG
),
null,
null
)
)
}
}
}
avatarContainer.setOnClickListener(showPickerListener)
Expand Down
1 change: 1 addition & 0 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3054,6 +3054,7 @@
<string name="error_locating_image">Error locating the cropped image</string>
<string name="error_refreshing_gravatar">Error reloading your Gravatar</string>
<string name="error_updating_gravatar">Error updating your Gravatar</string>
<string name="avatar_update_email_unverified">To update your avatar, you need to verify your email address first.</string>

<!-- Editor -->
<string name="discard">Discard</string>
Expand Down

0 comments on commit dd12e2f

Please sign in to comment.