Skip to content

Commit

Permalink
Added Gravatar Sync Info
Browse files Browse the repository at this point in the history
When the user updates any of the fields, we need some time until the change is propagated to Gravatar. We want to inform the user about that.

Also, the user can dismiss that notification with a done button.
  • Loading branch information
hamorillo committed Feb 13, 2024
1 parent 1732798 commit 70c40d8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class MyProfileFragment extends Fragment implements TextInputDialogFragme
private WPTextView mDisplayName;
private WPTextView mAboutMe;
private Button mLearMoreAtGravatar;
private Button mGravatarSyncButton;
private View mGravatarSyncContainer;

@Inject Dispatcher mDispatcher;
@Inject AccountStore mAccountStore;
Expand Down Expand Up @@ -90,6 +92,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mDisplayName = rootView.findViewById(R.id.display_name);
mAboutMe = rootView.findViewById(R.id.about_me);
mLearMoreAtGravatar = rootView.findViewById(R.id.learn_more_at_gravatar);
mGravatarSyncButton = rootView.findViewById(R.id.gravatar_sync_button);
mGravatarSyncContainer = rootView.findViewById(R.id.gravatar_sync_container);

rootView.findViewById(R.id.first_name_row).setOnClickListener(
createOnClickListener(
Expand Down Expand Up @@ -118,6 +122,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mLearMoreAtGravatar.setOnClickListener(v -> {
ActivityLauncher.openUrlExternal(getActivity(), GRAVATAR_URL);
});
mGravatarSyncButton.setOnClickListener(v -> {
mGravatarSyncContainer.setVisibility(View.GONE);
});

return rootView;
}
Expand Down Expand Up @@ -182,6 +189,7 @@ private void updateMyProfileForLabel(TextView textView) {
payload.params.put(restParamForTextView(textView), textView.getText().toString());
mDispatcher.dispatch(AccountActionBuilder.newPushSettingsAction(payload));
trackSettingsDidChange(restParamForTextView(textView));
mGravatarSyncContainer.setVisibility(View.VISIBLE);
}

private void trackSettingsDidChange(String fieldName) {
Expand Down
48 changes: 46 additions & 2 deletions WordPress/src/main/res/layout/my_profile_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:animateLayoutChanges="true">

<androidx.core.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
Expand Down Expand Up @@ -87,13 +89,14 @@
</androidx.core.widget.NestedScrollView>

<LinearLayout
android:id="@+id/gravatar_info_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/margin_extra_small_large"
android:layout_margin="@dimen/margin_extra_large"
android:background="@drawable/bg_wordpress_gravatar_info"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@+id/gravatar_sync_container"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">

Expand Down Expand Up @@ -121,4 +124,45 @@
app:icon="@drawable/ic_external_white_24dp" />

</LinearLayout>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/gravatar_sync_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_extra_large"
android:background="@drawable/bg_wordpress_gravatar_info"
android:orientation="horizontal"
android:paddingBottom="@dimen/margin_extra_small_large"
android:paddingStart="@dimen/margin_extra_small_large"
android:paddingTop="@dimen/margin_extra_small_large"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:ignore="RtlSymmetry"
tools:visibility="visible">

<org.wordpress.android.widgets.WPTextView
android:id="@+id/gravatar_sync_message"
style="@style/MyProfileLabel"
android:layout_width="0dp"
android:text="@string/gravatar_info_sync_message"
app:layout_constraintEnd_toStartOf="@+id/gravatar_sync_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.google.android.material.button.MaterialButton
android:id="@+id/gravatar_sync_button"
style="@style/OverlayMigrationHelperText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/gravatar_info_sync_done_button"
android:textColor="@color/jetpack_green_50"
android:textStyle="bold"
app:drawableEndCompat="@drawable/ic_external_white_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
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 @@ -2871,6 +2871,8 @@
<string name="checking_purchases">Checking purchases</string>
<string name="gravatar_info_description">"Gravatar keeps your profile information safe and up to date, automatically syncing any updates made here with your Gravatar profile."</string>
<string name="gravatar_info_learn_more_link">Learn more on Gravatar.com</string>
<string name="gravatar_info_sync_message">Updates might take some time to sync with your Gravatar profile.</string>
<string name="gravatar_info_sync_done_button">Done</string>

<!--Account Settings-->
<string name="account_settings">Account Settings</string>
Expand Down

0 comments on commit 70c40d8

Please sign in to comment.