From 3281a93dc363857c69b8c054905a6c286fcaff1d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 31 Aug 2020 17:42:03 +0200 Subject: [PATCH] use content description for play/pause button in audio player --- .../siacs/conversations/ui/service/AudioPlayer.java | 11 ++++++++++- src/main/res/values/strings.xml | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java b/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java index 61f7b3e29..e1dc10e82 100644 --- a/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java +++ b/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java @@ -112,17 +112,21 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti } viewHolder.playPause.setAlpha(viewHolder.darkBackground ? 0.7f : 0.57f); viewHolder.playPause.setOnClickListener(this); + final Context context = viewHolder.playPause.getContext(); if (message == currentlyPlayingMessage) { if (AudioPlayer.player != null && AudioPlayer.player.isPlaying()) { viewHolder.playPause.setImageResource(viewHolder.darkBackground ? R.drawable.ic_pause_white_36dp : R.drawable.ic_pause_black_36dp); + viewHolder.playPause.setContentDescription(context.getString(R.string.pause_audio)); viewHolder.progress.setEnabled(true); } else { + viewHolder.playPause.setContentDescription(context.getString(R.string.play_audio)); viewHolder.playPause.setImageResource(viewHolder.darkBackground ? R.drawable.ic_play_arrow_white_36dp : R.drawable.ic_play_arrow_black_36dp); viewHolder.progress.setEnabled(false); } return true; } else { viewHolder.playPause.setImageResource(viewHolder.darkBackground ? R.drawable.ic_play_arrow_white_36dp : R.drawable.ic_play_arrow_black_36dp); + viewHolder.playPause.setContentDescription(context.getString(R.string.play_audio)); viewHolder.runtime.setText(formatTime(message.getFileParams().runtime)); viewHolder.progress.setProgress(0); viewHolder.progress.setEnabled(false); @@ -156,7 +160,8 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti } } - private boolean playPauseCurrent(ViewHolder viewHolder) { + private boolean playPauseCurrent(final ViewHolder viewHolder) { + final Context context = viewHolder.playPause.getContext(); viewHolder.playPause.setAlpha(viewHolder.darkBackground ? 0.7f : 0.57f); if (player.isPlaying()) { viewHolder.progress.setEnabled(false); @@ -164,6 +169,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti messageAdapter.flagScreenOff(); releaseProximityWakeLock(); viewHolder.playPause.setImageResource(viewHolder.darkBackground ? R.drawable.ic_play_arrow_white_36dp : R.drawable.ic_play_arrow_black_36dp); + viewHolder.playPause.setContentDescription(context.getString(R.string.play_audio)); } else { viewHolder.progress.setEnabled(true); player.start(); @@ -171,6 +177,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti acquireProximityWakeLock(); this.stopRefresher(true); viewHolder.playPause.setImageResource(viewHolder.darkBackground ? R.drawable.ic_pause_white_36dp : R.drawable.ic_pause_black_36dp); + viewHolder.playPause.setContentDescription(context.getString(R.string.pause_audio)); } return false; } @@ -194,6 +201,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti acquireProximityWakeLock(); viewHolder.progress.setEnabled(true); viewHolder.playPause.setImageResource(viewHolder.darkBackground ? R.drawable.ic_pause_white_36dp : R.drawable.ic_pause_black_36dp); + viewHolder.playPause.setContentDescription(viewHolder.playPause.getContext().getString(R.string.pause_audio)); sensorManager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_NORMAL); return true; } catch (Exception e) { @@ -248,6 +256,7 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti } final ViewHolder viewHolder = ViewHolder.get(audioPlayer); final Message message = (Message) audioPlayer.getTag(); + viewHolder.playPause.setContentDescription(viewHolder.playPause.getContext().getString(R.string.play_audio)); viewHolder.playPause.setImageResource(viewHolder.darkBackground ? R.drawable.ic_play_arrow_white_36dp : R.drawable.ic_play_arrow_black_36dp); if (message != null) { viewHolder.runtime.setText(formatTime(message.getFileParams().runtime)); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 7e4851d8b..25896e77c 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -935,6 +935,8 @@ Not encrypted Exit Record voice mail + Play audio + Pause audio View %1$d Participant View %1$d Participants