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

Fix unlabeled image buttons for accessibility #586

Merged
merged 6 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public TextUnderButton(Context context, int imageResource, int size, Integer pad

mButton = (android.widget.ImageButton) v.findViewById(R.id.imageButton);

if (label != null) mButton.setContentDescription(label);

mButton.setImageResource(imageResource);
mButton.setMaxHeight(size);
mButton.setOnClickListener(clicked);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ private void prepareBackgroundManager() {
getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
}

protected ImageButton mSortButton;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected ImageButton mSearchButton;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected ImageButton mSettingsButton;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected ImageButton mUnwatchedButton;
protected ImageButton mFavoriteButton;
protected ImageButton mLetterButton;
Expand Down Expand Up @@ -390,7 +393,7 @@ public void onResponse(Boolean response) {
}
});

toolBar.addView(new ImageButton(getActivity(), R.drawable.ic_sort, size, new View.OnClickListener() {
mSortButton = new ImageButton(getActivity(), R.drawable.ic_sort, size, new View.OnClickListener() {
@Override
public void onClick(View v) {
//Create sort menu
Expand All @@ -414,7 +417,10 @@ public boolean onMenuItemClick(MenuItem item) {
});
sortMenu.show();
}
}));
});
mSortButton.setContentDescription(getString(R.string.lbl_sort_by));

toolBar.addView(mSortButton);

if (mRowDef.getQueryType() == QueryType.Items) {
mUnwatchedButton = new ImageButton(getActivity(), mGridAdapter.getFilters().isUnwatchedOnly() ? R.drawable.ic_unwatch_red : R.drawable.ic_unwatch, size, new View.OnClickListener() {
Expand All @@ -436,6 +442,7 @@ public void onClick(View v) {

}
});
mUnwatchedButton.setContentDescription(getString(R.string.lbl_unwatched));
toolBar.addView(mUnwatchedButton);
}

Expand All @@ -457,6 +464,7 @@ public void onClick(View v) {

}
});
mFavoriteButton.setContentDescription(getString(R.string.lbl_favorite));
toolBar.addView(mFavoriteButton);

mLetterButton = new ImageButton(getActivity(), R.drawable.ic_jump_letter, size, new View.OnClickListener() {
Expand All @@ -466,24 +474,29 @@ public void onClick(View v) {
mJumplistPopup.show();
}
});
mLetterButton.setContentDescription(getString(R.string.lbl_by_letter));
toolBar.addView(mLetterButton);

toolBar.addView(new ImageButton(getActivity(), R.drawable.ic_search, size, new View.OnClickListener() {
mSearchButton = new ImageButton(getActivity(), R.drawable.ic_search, size, new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), SearchActivity.class);
intent.putExtra("MusicOnly", "music".equals(mFolder.getCollectionType()) || mFolder.getBaseItemType() == BaseItemType.MusicAlbum || mFolder.getBaseItemType() == BaseItemType.MusicArtist);

startActivity(intent);
}
}));
});
mSearchButton.setContentDescription(getString(R.string.lbl_search));
toolBar.addView(mSearchButton);

toolBar.addView(new ImageButton(getActivity(), R.drawable.ic_settings, size, new View.OnClickListener() {
mSettingsButton = new ImageButton(getActivity(), R.drawable.ic_settings, size, new View.OnClickListener() {
@Override
public void onClick(View v) {
mDisplayPrefsPopup.show(mDisplayPrefs, mFolder.getCollectionType());
}
}));
});
mSettingsButton.setContentDescription(getString(R.string.lbl_settings));
toolBar.addView(mSettingsButton);


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,32 @@ public void onCreate(Bundle savedInstanceState) {
mSpinner = findViewById(R.id.spinner);
mSpinner.setVisibility(View.VISIBLE);

findViewById(R.id.filterButton).setOnClickListener(new View.OnClickListener() {
View mFilterButton = findViewById(R.id.filterButton);
mFilterButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFilterOptions();
}
});
mFilterButton.setContentDescription(getString(R.string.lbl_filters));

findViewById(R.id.optionsButton).setOnClickListener(new View.OnClickListener() {
View mOptionsButton = findViewById(R.id.optionsButton);
mOptionsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showOptions();
}
});
mOptionsButton.setContentDescription(getString(R.string.lbl_other_options));

findViewById(R.id.dateButton).setOnClickListener(new View.OnClickListener() {
View mDateButton = findViewById(R.id.dateButton);
mDateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showDatePicker();
}
});
mDateButton.setContentDescription(getString(R.string.lbl_select_date));

mResetButton = findViewById(R.id.resetButton);
mResetButton.setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@ protected void onCreate(Bundle savedInstanceState) {
mSSUpNext = findViewById(R.id.ssUpNext);

mPlayPauseButton = findViewById(R.id.playPauseBtn);
mPlayPauseButton.setContentDescription(getString(R.string.lbl_pause));
mPlayPauseButton.setSecondaryImage(R.drawable.ic_pause);
mPlayPauseButton.setPrimaryImage(R.drawable.ic_play);
TextView helpView = findViewById(R.id.buttonTip);
mPrevButton = findViewById(R.id.prevBtn);
mPrevButton.setContentDescription(getString(R.string.lbl_prev_item));
mPrevButton.setHelpView(helpView);
mPrevButton.setHelpText(getString(R.string.lbl_prev_item));
mPrevButton.setOnClickListener(new View.OnClickListener() {
Expand All @@ -149,6 +151,7 @@ public void onClick(View v) {
});
mPrevButton.setGotFocusListener(mainAreaFocusListener);
mNextButton = findViewById(R.id.nextBtn);
mNextButton.setContentDescription(getString(R.string.lbl_next_item));
mNextButton.setHelpView(helpView);
mNextButton.setHelpText(getString(R.string.lbl_next_item));
mNextButton.setOnClickListener(new View.OnClickListener() {
Expand All @@ -159,6 +162,7 @@ public void onClick(View v) {
});
mNextButton.setGotFocusListener(mainAreaFocusListener);
mRepeatButton = findViewById(R.id.repeatBtn);
mRepeatButton.setContentDescription(getString(R.string.lbl_repeat));
mRepeatButton.setHelpView(helpView);
mRepeatButton.setHelpText(getString(R.string.lbl_repeat));
mRepeatButton.setPrimaryImage(R.drawable.ic_loop);
Expand All @@ -171,6 +175,7 @@ public void onClick(View v) {
}
});
mSaveButton = findViewById(R.id.saveBtn);
mSaveButton.setContentDescription(getString(R.string.lbl_save_as_playlist));
mSaveButton.setHelpView(helpView);
mSaveButton.setHelpText(getString(R.string.lbl_save_as_playlist));
mSaveButton.setOnClickListener(new View.OnClickListener() {
Expand All @@ -181,6 +186,7 @@ public void onClick(View v) {
});
mRepeatButton.setGotFocusListener(mainAreaFocusListener);
mShuffleButton = findViewById(R.id.shuffleBtn);
mShuffleButton.setContentDescription(getString(R.string.lbl_reshuffle_queue));
mShuffleButton.setHelpView(helpView);
mShuffleButton.setHelpText(getString(R.string.lbl_reshuffle_queue));
mShuffleButton.setOnClickListener(new View.OnClickListener() {
Expand All @@ -201,6 +207,7 @@ public void onClick(DialogInterface dialog, int which) {
});
mShuffleButton.setGotFocusListener(mainAreaFocusListener);
mAlbumButton = findViewById(R.id.albumBtn);
mAlbumButton.setContentDescription(getString(R.string.lbl_open_album));
mAlbumButton.setHelpView(helpView);
mAlbumButton.setHelpText(getString(R.string.lbl_open_album));
mAlbumButton.setOnClickListener(new View.OnClickListener() {
Expand All @@ -213,6 +220,7 @@ public void onClick(View v) {
});
mAlbumButton.setGotFocusListener(mainAreaFocusListener);
mArtistButton = findViewById(R.id.artistBtn);
mArtistButton.setContentDescription(getString(R.string.lbl_open_artist));
mArtistButton.setHelpView(helpView);
mArtistButton.setHelpText(getString(R.string.lbl_open_artist));
mArtistButton.setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -424,7 +432,13 @@ private void updateButtons(final boolean playing) {
@Override
public void run() {
mPoster.setKeepScreenOn(playing);
mPlayPauseButton.setState(!playing ? ImageButton.STATE_PRIMARY : ImageButton.STATE_SECONDARY);
if (!playing) {
mPlayPauseButton.setState(ImageButton.STATE_PRIMARY);
mPlayPauseButton.setContentDescription(getString(R.string.lbl_play));
} else {
mPlayPauseButton.setState(ImageButton.STATE_SECONDARY);
mPlayPauseButton.setContentDescription(getString(R.string.lbl_pause));
}
mRepeatButton.setState(MediaManager.isRepeatMode() ? ImageButton.STATE_SECONDARY : ImageButton.STATE_PRIMARY);
mSaveButton.setEnabled(MediaManager.getCurrentAudioQueueSize() > 1);
mPrevButton.setEnabled(MediaManager.hasPrevAudioItem());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import androidx.leanback.widget.ArrayObjectAdapter;
import androidx.leanback.widget.PlaybackControlsRow;

import org.jellyfin.androidtv.R;
import org.jellyfin.androidtv.TvApp;
import org.jellyfin.androidtv.preference.UserPreferences;
import org.jellyfin.androidtv.ui.livetv.TvManager;
import org.jellyfin.androidtv.ui.playback.PlaybackController;
Expand Down Expand Up @@ -63,15 +65,24 @@ private void initActions(Context context) {
fastForwardAction = new PlaybackControlsRow.FastForwardAction(context);
skipNextAction = new PlaybackControlsRow.SkipNextAction(context);
selectAudioAction = new SelectAudioAction(context, this);
selectAudioAction.setLabels(new String[]{context.getString(R.string.lbl_audio_track)});
closedCaptionsAction = new ClosedCaptionsAction(context, this);
closedCaptionsAction.setLabels(new String[]{context.getString(R.string.lbl_subtitle_track)});
adjustAudioDelayAction = new AdjustAudioDelayAction(context, this);
adjustAudioDelayAction.setLabels(new String[]{context.getString(R.string.lbl_audio_delay)});
zoomAction = new ZoomAction(context, this);
zoomAction.setLabels(new String[]{context.getString(R.string.lbl_zoom)});
chapterAction = new ChapterAction(context, this);
chapterAction.setLabels(new String[]{context.getString(R.string.lbl_chapters)});

previousLiveTvChannelAction = new PreviousLiveTvChannelAction(context, this);
previousLiveTvChannelAction.setLabels(new String[]{TvApp.getApplication().getString(R.string.lbl_prev_item)});
channelBarChannelAction = new ChannelBarChannelAction(context, this);
channelBarChannelAction.setLabels(new String[]{TvApp.getApplication().getString(R.string.lbl_other_channels)});
guideAction = new GuideAction(context, this);
guideAction.setLabels(new String[]{TvApp.getApplication().getString(R.string.lbl_live_tv_guide)});
recordAction = new RecordAction(context, this);
recordAction.setLabels(new String[]{TvApp.getApplication().getString(R.string.lbl_record)});
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="lbl_play_all">Play All</string>
<string name="lbl_shuffle_all">Shuffle All</string>
<string name="lbl_play">Play</string>
<string name="lbl_pause">Pause</string>
<string name="lbl_cancel">Cancel</string>
<string name="lbl_cancel_recording">Cancel Recording</string>
<string name="lbl_cancel_series">Cancel Series</string>
Expand Down Expand Up @@ -246,6 +247,8 @@
<string name="lbl_horizontal_stretch">Horizontal Stretch</string>
<string name="lbl_vertical_stretch">Vertical Stretch</string>
<string name="lbl_audio_capabilitites">Audio Capabilities</string>
<string name="lbl_audio_track">Select audio track</string>
<string name="lbl_subtitle_track">Select subtitle track</string>
<string name="msg_audio_warning">This app has the ability to direct stream certain multi-channel audio formats. If your hardware does not support these formats, you may hear no sound when playing certain items. This can be fixed by changing the audio mode to \'downmix\' in the settings.</string>
<string name="msg_external_path">This feature will only work if you have properly set up your library on the server with network paths or path substitution and the client you are using can directly access these locations over the network.</string>
<string name="btn_got_it">Got it</string>
Expand Down