Accessibility improvements, close #39

This commit is contained in:
Grishka 2022-04-19 17:03:32 +03:00
parent 9276214433
commit 2e1f08a096
19 changed files with 76 additions and 29 deletions

View File

@ -124,7 +124,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{
.setContentText(pn.body)
.setStyle(new Notification.BigTextStyle().bigText(pn.body))
.setSmallIcon(R.drawable.ic_ntf_logo)
.setContentIntent(PendingIntent.getActivity(context, accountID.hashCode() & 0xFFFF, contentIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT))
.setContentIntent(PendingIntent.getActivity(context, accountID.hashCode() & 0xFFFF, contentIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT))
.setWhen(notification==null ? System.currentTimeMillis() : notification.createdAt.toEpochMilli())
.setShowWhen(true)
.setCategory(Notification.CATEGORY_SOCIAL)

View File

@ -331,6 +331,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
if(toolbar==null)
return;
toolbar.setOnClickListener(v->scrollToTop());
toolbar.setNavigationContentDescription(R.string.back);
}
protected int getMainAdapterOffset(){

View File

@ -101,7 +101,7 @@ import me.grishka.appkit.imageloader.ViewImageLoader;
import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
import me.grishka.appkit.utils.V;
public class ComposeFragment extends ToolbarFragment implements OnBackPressedListener, ComposeEditText.SelectionListener{
public class ComposeFragment extends MastodonToolbarFragment implements OnBackPressedListener, ComposeEditText.SelectionListener{
private static final int MEDIA_RESULT=717;
private static final int IMAGE_DESCRIPTION_RESULT=363;
@ -433,7 +433,6 @@ public class ComposeFragment extends ToolbarFragment implements OnBackPressedLis
updateCharCounter(s);
}
});
updateToolbar();
if(replyTo!=null){
replyText.setText(getString(R.string.in_reply_to, replyTo.account.displayName));
ArrayList<String> mentions=new ArrayList<>();
@ -518,7 +517,6 @@ public class ComposeFragment extends ToolbarFragment implements OnBackPressedLis
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
emojiKeyboard.onConfigurationChanged();
updateToolbar();
}
@SuppressLint("NewApi")
@ -556,7 +554,9 @@ public class ComposeFragment extends ToolbarFragment implements OnBackPressedLis
mainEditText.getText().replace(start, mainEditText.getSelectionEnd(), prefix+emoji.shortcode+':');
}
private void updateToolbar(){
@Override
protected void updateToolbar(){
super.updateToolbar();
getToolbar().setNavigationIcon(R.drawable.ic_fluent_dismiss_24_regular);
}

View File

@ -30,7 +30,7 @@ import me.grishka.appkit.imageloader.ViewImageLoader;
import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
import me.grishka.appkit.utils.V;
public class ComposeImageDescriptionFragment extends ToolbarFragment{
public class ComposeImageDescriptionFragment extends MastodonToolbarFragment{
private String accountID, attachmentID;
private EditText edit;
private Button saveButton;

View File

@ -0,0 +1,33 @@
package org.joinmastodon.android.fragments;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
import android.widget.Toolbar;
import org.joinmastodon.android.R;
import androidx.annotation.CallSuper;
import me.grishka.appkit.fragments.ToolbarFragment;
public abstract class MastodonToolbarFragment extends ToolbarFragment{
@Override
public void onViewCreated(View view, Bundle savedInstanceState){
super.onViewCreated(view, savedInstanceState);
updateToolbar();
}
@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
updateToolbar();
}
@CallSuper
protected void updateToolbar(){
Toolbar toolbar=getToolbar();
if(toolbar!=null && toolbar.getNavigationIcon()!=null){
toolbar.setNavigationContentDescription(R.string.back);
}
}
}

View File

@ -24,7 +24,7 @@ import me.grishka.appkit.fragments.BaseRecyclerFragment;
import me.grishka.appkit.fragments.ToolbarFragment;
import me.grishka.appkit.utils.V;
public class NotificationsFragment extends ToolbarFragment implements ScrollableToTop{
public class NotificationsFragment extends MastodonToolbarFragment implements ScrollableToTop{
private TabLayout tabLayout;
private ViewPager2 pager;
@ -123,18 +123,6 @@ public class NotificationsFragment extends ToolbarFragment implements Scrollable
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState){
super.onViewCreated(view, savedInstanceState);
updateToolbar();
}
@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
updateToolbar();
}
@Override
public void scrollToTop(){
getFragmentForPage(pager.getCurrentItem()).scrollToTop();
@ -145,7 +133,9 @@ public class NotificationsFragment extends ToolbarFragment implements Scrollable
allNotificationsFragment.loadData();
}
private void updateToolbar(){
@Override
protected void updateToolbar(){
super.updateToolbar();
getToolbar().setOutlineProvider(null);
}

View File

@ -454,6 +454,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
toolbarSubtitleView.setTranslationY(titleTransY);
}
getToolbar().setOnClickListener(v->scrollToTop());
getToolbar().setNavigationContentDescription(R.string.back);
}
@Override

View File

@ -17,6 +17,7 @@ import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.RadioButton;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
@ -52,7 +53,7 @@ import me.grishka.appkit.utils.BindableViewHolder;
import me.grishka.appkit.utils.V;
import me.grishka.appkit.views.UsableRecyclerView;
public class SettingsFragment extends ToolbarFragment{
public class SettingsFragment extends MastodonToolbarFragment{
private UsableRecyclerView list;
private ArrayList<Item> items=new ArrayList<>();
private ThemeItem themeItem;
@ -511,7 +512,8 @@ public class SettingsFragment extends ToolbarFragment{
private class SubitemHolder{
public TextView text;
public ImageView icon, checkbox;
public ImageView icon;
public RadioButton checkbox;
public SubitemHolder(View view){
text=view.findViewById(R.id.text);
@ -526,11 +528,11 @@ public class SettingsFragment extends ToolbarFragment{
public void bind(int text, int icon, boolean checked){
this.text.setText(text);
this.icon.setImageResource(icon);
checkbox.setSelected(checked);
checkbox.setChecked(checked);
}
public void setChecked(boolean checked){
checkbox.setSelected(checked);
checkbox.setChecked(checked);
}
}
}

View File

@ -183,6 +183,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
searchClear=view.findViewById(R.id.search_clear);
searchProgress=view.findViewById(R.id.search_progress);
searchBack.setEnabled(searchActive);
searchBack.setImportantForAccessibility(searchActive ? View.IMPORTANT_FOR_ACCESSIBILITY_YES : View.IMPORTANT_FOR_ACCESSIBILITY_NO);
searchBack.setOnClickListener(v->exitSearch());
if(searchActive){
searchBack.setImageResource(R.drawable.ic_fluent_arrow_left_24_regular);
@ -221,6 +222,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
searchView.setVisibility(View.VISIBLE);
searchBack.setImageResource(R.drawable.ic_fluent_arrow_left_24_regular);
searchBack.setEnabled(true);
searchBack.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
}
@ -233,6 +235,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
searchEdit.setText("");
searchBack.setImageResource(R.drawable.ic_fluent_search_24_regular);
searchBack.setEnabled(false);
searchBack.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
getActivity().getSystemService(InputMethodManager.class).hideSoftInputFromWindow(searchEdit.getWindowToken(), 0);
}

View File

@ -14,6 +14,7 @@ import android.widget.TextView;
import org.joinmastodon.android.E;
import org.joinmastodon.android.R;
import org.joinmastodon.android.fragments.MastodonToolbarFragment;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.Status;
import org.joinmastodon.android.ui.DividerItemDecoration;
@ -32,7 +33,7 @@ import me.grishka.appkit.utils.SingleViewRecyclerAdapter;
import me.grishka.appkit.utils.V;
import me.grishka.appkit.views.UsableRecyclerView;
public abstract class BaseReportChoiceFragment extends ToolbarFragment{
public abstract class BaseReportChoiceFragment extends MastodonToolbarFragment{
private UsableRecyclerView list;
private MergeRecyclerAdapter adapter;
private Button btn;

View File

@ -17,6 +17,7 @@ import org.joinmastodon.android.E;
import org.joinmastodon.android.R;
import org.joinmastodon.android.api.requests.reports.SendReport;
import org.joinmastodon.android.events.FinishReportFragmentsEvent;
import org.joinmastodon.android.fragments.MastodonToolbarFragment;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.ReportReason;
import org.joinmastodon.android.ui.utils.UiUtils;
@ -30,7 +31,7 @@ import me.grishka.appkit.api.ErrorResponse;
import me.grishka.appkit.fragments.ToolbarFragment;
import me.grishka.appkit.utils.V;
public class ReportCommentFragment extends ToolbarFragment{
public class ReportCommentFragment extends MastodonToolbarFragment{
private String accountID;
private Account reportAccount;
private Button btn;

View File

@ -13,6 +13,7 @@ import android.widget.TextView;
import org.joinmastodon.android.R;
import org.joinmastodon.android.api.requests.accounts.SetAccountFollowed;
import org.joinmastodon.android.fragments.MastodonToolbarFragment;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.Relationship;
import org.joinmastodon.android.model.ReportReason;
@ -29,7 +30,7 @@ import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest;
import me.grishka.appkit.utils.CubicBezierInterpolator;
import me.grishka.appkit.utils.V;
public class ReportDoneFragment extends ToolbarFragment{
public class ReportDoneFragment extends MastodonToolbarFragment{
private String accountID;
private Account reportAccount;
private Button btn;

View File

@ -49,6 +49,7 @@
android:background="?android:selectableItemBackgroundBorderless"
android:tint="?colorSearchHint"
android:elevation="1dp"
android:contentDescription="@string/back"
android:src="@drawable/ic_fluent_search_24_regular"/>
<ImageButton
@ -61,6 +62,7 @@
android:tint="?colorSearchHint"
android:elevation="1dp"
android:visibility="invisible"
android:contentDescription="@string/clear"
android:src="@drawable/ic_fluent_dismiss_24_regular"/>
<ProgressBar

View File

@ -30,6 +30,7 @@
android:layout_width="match_parent"
android:layout_height="229dp"
android:background="#808080"
android:contentDescription="@string/profile_header"
android:scaleType="centerCrop"/>
<View
@ -51,6 +52,7 @@
android:layout_marginStart="16dp"
android:layout_marginTop="-38dp"
android:scaleType="centerCrop"
android:contentDescription="@string/profile_picture"
tools:src="#0f0" />
<LinearLayout

View File

@ -15,6 +15,7 @@
android:button="@drawable/ic_round_checkbox"
android:buttonTint="?android:textColorSecondary"
android:background="@null"
android:focusable="false"
android:clickable="false"/>
<TextView

View File

@ -17,6 +17,7 @@
android:tint="@color/error_500"
android:stateListAnimator="@null"
android:padding="0px"
android:contentDescription="@string/delete"
android:background="@null"/>
<EditText
@ -56,6 +57,7 @@
android:layout_alignBottom="@id/value"
android:layout_marginBottom="-16dp"
android:scaleType="center"
android:contentDescription="@string/reorder"
android:src="@drawable/ic_fluent_re_order_dots_vertical_24_regular"/>
</RelativeLayout>

View File

@ -24,6 +24,7 @@
android:layout_marginEnd="6dp"
android:tint="?android:textColorSecondary"
android:background="?android:selectableItemBackgroundBorderless"
android:contentDescription="@string/clear"
android:src="@drawable/ic_fluent_dismiss_circle_24_filled"/>
</LinearLayout>

View File

@ -27,12 +27,14 @@
android:ellipsize="end"
tools:text="@string/theme_auto"/>
<ImageView
<RadioButton
android:id="@+id/checkbox"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="8dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/ic_round_checkbox"/>
android:focusable="false"
android:clickable="false"
android:button="@drawable/ic_round_checkbox"/>
</LinearLayout>

View File

@ -294,4 +294,8 @@
<string name="show_boosts_from_user">Show boosts from %s</string>
<string name="signup_reason">why do you want to join?</string>
<string name="signup_reason_note">This will help us review your application.</string>
<string name="clear">Clear</string>
<string name="profile_header">Header image</string>
<string name="profile_picture">Profile picture</string>
<string name="reorder">Reorder</string>
</resources>