Accessibility improvements

This commit is contained in:
Grishka 2022-04-07 19:46:54 +03:00
parent 4bac1cbc06
commit d82616f871
15 changed files with 78 additions and 10 deletions

View File

@ -1094,6 +1094,11 @@ public class ComposeFragment extends ToolbarFragment implements OnBackPressedLis
finishAutocomplete();
}
@Override
public CharSequence getTitle(){
return getString(R.string.new_post);
}
@Override
public boolean wantsLightStatusBar(){
return !UiUtils.isDarkTheme();

View File

@ -66,6 +66,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
accountID=getArguments().getString("account");
setTitle(R.string.app_name);
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
setRetainInstance(true);

View File

@ -40,7 +40,6 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
@Override
public void onAttach(Activity activity){
super.onAttach(activity);
setTitle(R.string.notifications);
onlyMentions=getArguments().getBoolean("onlyMentions", false);
}

View File

@ -6,6 +6,8 @@ import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
@ -43,6 +45,15 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
private final TextView reply, boost, favorite;
private final ImageView share;
private final View.AccessibilityDelegate buttonAccessibilityDelegate=new View.AccessibilityDelegate(){
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info){
super.onInitializeAccessibilityNodeInfo(host, info);
info.setClassName(Button.class.getName());
info.setText(item.parentFragment.getString(descriptionForId(host.getId())));
}
};
public Holder(Activity activity, ViewGroup parent){
super(activity, R.layout.display_item_footer, parent);
reply=findViewById(R.id.reply);
@ -54,10 +65,18 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
UiUtils.fixCompoundDrawableTintOnAndroid6(boost);
UiUtils.fixCompoundDrawableTintOnAndroid6(favorite);
}
findViewById(R.id.reply_btn).setOnClickListener(this::onReplyClick);
findViewById(R.id.boost_btn).setOnClickListener(this::onBoostClick);
findViewById(R.id.favorite_btn).setOnClickListener(this::onFavoriteClick);
findViewById(R.id.share_btn).setOnClickListener(this::onShareClick);
View reply=findViewById(R.id.reply_btn);
View boost=findViewById(R.id.boost_btn);
View favorite=findViewById(R.id.favorite_btn);
View share=findViewById(R.id.share_btn);
reply.setOnClickListener(this::onReplyClick);
reply.setAccessibilityDelegate(buttonAccessibilityDelegate);
boost.setOnClickListener(this::onBoostClick);
boost.setAccessibilityDelegate(buttonAccessibilityDelegate);
favorite.setOnClickListener(this::onFavoriteClick);
favorite.setAccessibilityDelegate(buttonAccessibilityDelegate);
share.setOnClickListener(this::onShareClick);
share.setAccessibilityDelegate(buttonAccessibilityDelegate);
}
@Override
@ -106,5 +125,17 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
intent.putExtra(Intent.EXTRA_TEXT, item.status.url);
v.getContext().startActivity(Intent.createChooser(intent, v.getContext().getString(R.string.share_toot_title)));
}
private int descriptionForId(int id){
if(id==R.id.reply_btn)
return R.string.button_reply;
if(id==R.id.boost_btn)
return R.string.button_reblog;
if(id==R.id.favorite_btn)
return R.string.button_favorite;
if(id==R.id.share_btn)
return R.string.button_share;
return 0;
}
}
}

View File

@ -126,6 +126,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
visibility.setVisibility(item.hasVisibilityToggle && !item.inset ? View.VISIBLE : View.GONE);
if(item.hasVisibilityToggle){
visibility.setImageResource(item.status.spoilerRevealed ? R.drawable.ic_visibility_off : R.drawable.ic_visibility);
visibility.setContentDescription(item.parentFragment.getString(item.status.spoilerRevealed ? R.string.hide_content : R.string.reveal_content));
}
itemView.setPadding(itemView.getPaddingLeft(), itemView.getPaddingTop(), itemView.getPaddingRight(), item.needBottomPadding ? V.dp(16) : 0);
if(TextUtils.isEmpty(item.extraText)){
@ -136,6 +137,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
}
more.setVisibility(item.inset ? View.GONE : View.VISIBLE);
avatar.setClickable(!item.inset);
avatar.setContentDescription(item.parentFragment.getString(R.string.avatar_description, item.user.acct));
}
@Override

View File

@ -2,6 +2,7 @@ package org.joinmastodon.android.ui.displayitems;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@ -70,6 +71,7 @@ public abstract class ImageStatusDisplayItem extends StatusDisplayItem{
crossfadeDrawable.setCrossfadeAlpha(item.status.spoilerRevealed ? 0f : 1f);
photo.setImageDrawable(null);
photo.setImageDrawable(crossfadeDrawable);
photo.setContentDescription(TextUtils.isEmpty(item.attachment.description) ? item.parentFragment.getString(R.string.media_no_description) : item.attachment.description);
didClear=false;
}

View File

@ -21,6 +21,7 @@ import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import org.joinmastodon.android.R;
import org.joinmastodon.android.model.Attachment;
import java.io.IOException;
@ -90,6 +91,7 @@ public class PhotoViewer implements ZoomPanView.Listener{
wlp.flags=WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
| WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
wlp.format=PixelFormat.TRANSLUCENT;
wlp.setTitle(activity.getString(R.string.media_viewer));
windowView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
wm.addView(windowView, wlp);

View File

@ -1,18 +1,14 @@
package org.joinmastodon.android.ui.views;
import android.content.Context;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import org.joinmastodon.android.R;
import java.util.function.IntConsumer;
import java.util.function.IntPredicate;
import androidx.annotation.IdRes;
import androidx.annotation.Nullable;
public class TabBar extends LinearLayout{
@IdRes

View File

@ -16,6 +16,7 @@
android:background="?android:selectableItemBackgroundBorderless"
android:scaleType="center"
android:tint="?android:textColorSecondary"
android:contentDescription="@string/more_options"
android:src="@drawable/ic_post_more" />
<ImageView

View File

@ -178,6 +178,7 @@
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:contentDescription="@string/add_media"
android:src="@drawable/ic_fluent_image_24_regular"/>
<ImageButton
@ -189,6 +190,7 @@
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:contentDescription="@string/add_poll"
android:src="@drawable/ic_fluent_poll_24_selector"/>
<ImageButton
@ -200,6 +202,7 @@
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:contentDescription="@string/emoji"
android:src="@drawable/ic_fluent_emoji_24_selector"/>
<ImageButton
@ -211,6 +214,7 @@
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:contentDescription="@string/content_warning"
android:src="@drawable/ic_fluent_chat_warning_24_selector"/>
<ImageButton
@ -222,6 +226,7 @@
android:padding="0px"
android:tint="@color/compose_button"
android:tintMode="src_in"
android:contentDescription="@string/post_visibility"
android:src="@drawable/ic_fluent_earth_24_filled"/>
<Space

View File

@ -7,4 +7,5 @@
android:fontFamily="sans-serif-medium"
android:textColor="?android:colorAccent"
android:padding="16dp"
android:accessibilityHeading="true"
tools:text="Visual appearance"/>

View File

@ -34,6 +34,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="12dp"
android:focusable="false"
android:clickable="false"/>
</LinearLayout>

View File

@ -31,6 +31,7 @@
android:tint="@color/fab_icon"
android:scaleType="center"
android:stateListAnimator="@animator/fab_shadow"
android:contentDescription="@string/new_post"
android:src="@drawable/ic_edit_34"/>
</FrameLayout>

View File

@ -19,6 +19,7 @@
android:layout_width="52dp"
android:layout_height="52dp"
android:scaleType="center"
android:contentDescription="@string/home_timeline"
android:background="?android:selectableItemBackgroundBorderless"
android:tint="?android:colorPrimary"
android:src="@drawable/ic_fluent_home_28_selector"/>
@ -33,6 +34,7 @@
android:layout_width="52dp"
android:layout_height="52dp"
android:scaleType="center"
android:contentDescription="@string/search_hint"
android:background="?android:selectableItemBackgroundBorderless"
android:tint="?android:colorPrimary"
android:src="@drawable/ic_fluent_search_28_selector"/>
@ -47,6 +49,7 @@
android:layout_width="52dp"
android:layout_height="52dp"
android:scaleType="center"
android:contentDescription="@string/notifications"
android:background="?android:selectableItemBackgroundBorderless"
android:tint="?android:colorPrimary"
android:src="@drawable/ic_fluent_alert_28_selector"/>
@ -60,6 +63,7 @@
android:id="@+id/tab_profile"
android:layout_width="52dp"
android:layout_height="52dp"
android:contentDescription="@string/my_profile"
android:foreground="@drawable/bg_tab_profile"
android:background="?android:selectableItemBackgroundBorderless">
<ImageView

View File

@ -25,7 +25,7 @@
<string name="time_hours">%dh</string>
<string name="time_days">%dd</string>
<string name="share_toot_title">Share toot</string>
<string name="share_toot_title">Share</string>
<string name="settings">Settings</string>
<string name="publish">Publish</string>
<string name="discard_draft">Discard draft?</string>
@ -267,4 +267,21 @@
<string name="sensitive_content">Sensitive content</string>
<string name="sensitive_content_explain">The author marked this media as sensitive. Tap to reveal.</string>
<string name="media_hidden">Tap to reveal</string>
<string name="avatar_description">Go to %s\'s profile</string>
<string name="more_options">More options</string>
<string name="reveal_content">Reveal content</string>
<string name="hide_content">Hide content</string>
<string name="new_post">New post</string>
<string name="button_reply">Reply</string>
<string name="button_reblog">Reblog</string>
<string name="button_favorite">Favorite</string>
<string name="button_share">Share</string>
<string name="media_no_description">Media without description</string>
<string name="add_media">Add media</string>
<string name="add_poll">Add a poll</string>
<string name="emoji">Emoji</string>
<string name="post_visibility">Post visibility</string>
<string name="home_timeline">Home timeline</string>
<string name="my_profile">My profile</string>
<string name="media_viewer">Media viewer</string>
</resources>