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

Me gravatar menu accessibility #11613

Merged
merged 10 commits into from
Apr 14, 2020
3 changes: 2 additions & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
14.7
-----

* Added user Gravatar to the Me menu in My Site.

14.6
-----
* Block editor: You can now crop, zoom in/out and rotate images that are already inserted in a post.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ private void showGravatarProgressBar(boolean isUpdating) {

private void loadAvatar(String injectFilePath) {
final boolean newAvatarUploaded = injectFilePath != null && !injectFilePath.isEmpty();
final String rawAvatarUrl = mAccountStore.getAccount().getAvatarUrl();
final String avatarUrl = mMeGravatarLoader.constructGravatarUrl(mAccountStore.getAccount().getAvatarUrl());

mMeGravatarLoader.load(
newAvatarUploaded,
rawAvatarUrl,
avatarUrl,
injectFilePath,
mAvatarImageView,
ImageType.AVATAR_WITHOUT_BACKGROUND,
Expand Down Expand Up @@ -297,7 +297,7 @@ public void onResourceReady(@NotNull Drawable resource, @Nullable Object model)
// create a copy since the original bitmap may by automatically recycled
bitmap = bitmap.copy(bitmap.getConfig(), true);
WordPress.getBitmapCache().put(
mMeGravatarLoader.constructGravatarUrl(rawAvatarUrl),
avatarUrl,
bitmap
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.text.Spannable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
Expand All @@ -22,6 +23,7 @@
import androidx.annotation.Nullable;
import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.Toolbar;
import androidx.appcompat.widget.TooltipCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;

Expand Down Expand Up @@ -207,11 +209,11 @@ public void onCreate(Bundle savedInstanceState) {
}

private void refreshMeGravatar() {
String rawGravatarUrl = mMeGravatarLoader.constructGravatarUrl(mAccountStore.getAccount().getAvatarUrl());
String avatarUrl = mMeGravatarLoader.constructGravatarUrl(mAccountStore.getAccount().getAvatarUrl());

mMeGravatarLoader.load(
false,
rawGravatarUrl,
avatarUrl,
null,
mAvatarImageView,
ImageType.USER,
Expand Down Expand Up @@ -378,11 +380,14 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
mToolbar.setTitle(mToolbarTitle);

mToolbar.inflateMenu(R.menu.my_site_menu);
View actionView = mToolbar.getMenu().findItem(R.id.me_item).getActionView();

MenuItem meMenu = mToolbar.getMenu().findItem(R.id.me_item);
View actionView = meMenu.getActionView();
mAvatarImageView = actionView.findViewById(R.id.avatar);
actionView.setOnClickListener(item -> {
ActivityLauncher.viewMeActivityForResult(getActivity());
});

actionView.setOnClickListener(item -> ActivityLauncher.viewMeActivityForResult(getActivity()));

TooltipCompat.setTooltipText(actionView, meMenu.getTitle());

return rootView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ class MeGravatarLoader @Inject constructor(
) {
fun load(
newAvatarUploaded: Boolean,
rawAvatarUrl: String,
avatarUrl: String,
injectFilePath: String?,
imageView: ImageView,
imageType: ImageType,
listener: RequestListener<Drawable>? = null
) {
val avatarUrl = constructGravatarUrl(rawAvatarUrl)

if (newAvatarUploaded) {
// invalidate the specific gravatar entry from the bitmap cache. It will be updated via the injected
// request cache.
Expand Down
8 changes: 4 additions & 4 deletions WordPress/src/main/res/layout/me_action_layout.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="@dimen/menu_width"
android:minWidth="@dimen/me_menu_width"
android:gravity="center"
android:background="?android:attr/actionBarItemBackground">

<ImageView
android:id="@+id/avatar"
android:layout_width="@dimen/avatar_sz_small"
android:layout_height="@dimen/avatar_sz_small"
android:contentDescription="@string/me_section_screen_title"
android:contentDescription="@null"
android:background="@drawable/bg_oval_transparent_stroke_white"
android:padding="@dimen/posts_list_spinner_avatar_padding"
android:src="@drawable/ic_user_white_24dp"/>

</RelativeLayout>
</LinearLayout>
2 changes: 1 addition & 1 deletion WordPress/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<dimen name="category_parent_spinner_row_height">40dp</dimen>

<dimen name="tab_height">48dp</dimen>
<dimen name="menu_width">48dp</dimen>
<dimen name="me_menu_width">64dp</dimen>
<dimen name="toolbar_height">56dp</dimen>
<dimen name="toolbar_content_offset">72dp</dimen>
<dimen name="toolbar_content_offset_end">0dp</dimen>
Expand Down