Merge pull request #1288 from tuskyapp/poll-description

Minimal screen reader support for polls
main
Konrad Pozniak 6 years ago committed by GitHub
commit 0473f71f9a
  1. 76
      app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java
  2. 1
      app/src/main/res/values-ca/strings.xml
  3. 3
      app/src/main/res/values-cs/strings.xml
  4. 4
      app/src/main/res/values-eo/strings.xml
  5. 1
      app/src/main/res/values-es/strings.xml
  6. 3
      app/src/main/res/values-fr/strings.xml
  7. 3
      app/src/main/res/values-it/strings.xml
  8. 3
      app/src/main/res/values-nl/strings.xml
  9. 3
      app/src/main/res/values-no-rNB/strings.xml
  10. 1
      app/src/main/res/values-oc/strings.xml
  11. 1
      app/src/main/res/values-pt-rBR/strings.xml
  12. 4
      app/src/main/res/values-ru/strings.xml
  13. 1
      app/src/main/res/values-sl/strings.xml
  14. 3
      app/src/main/res/values-sv/strings.xml
  15. 4
      app/src/main/res/values-zh-rCN/strings.xml
  16. 4
      app/src/main/res/values-zh-rHK/strings.xml
  17. 4
      app/src/main/res/values-zh-rMO/strings.xml
  18. 4
      app/src/main/res/values-zh-rSG/strings.xml
  19. 4
      app/src/main/res/values-zh-rTW/strings.xml
  20. 6
      app/src/main/res/values/donottranslate.xml
  21. 5
      app/src/main/res/values/strings.xml

@ -129,7 +129,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
contentWarningButton = itemView.findViewById(R.id.status_content_warning_button);
avatarInset = itemView.findViewById(R.id.status_avatar_inset);
pollResults = new TextView[] {
pollResults = new TextView[]{
itemView.findViewById(R.id.status_poll_option_result_0),
itemView.findViewById(R.id.status_poll_option_result_1),
itemView.findViewById(R.id.status_poll_option_result_2),
@ -704,7 +704,8 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
getMediaDescription(context, status),
getVisibilityDescription(context, status.getVisibility()),
getFavsText(context, status.getFavouritesCount()),
getReblogsText(context, status.getReblogsCount())
getReblogsText(context, status.getReblogsCount()),
getPollDescription(context, status)
);
itemView.setContentDescription(description);
}
@ -753,7 +754,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
}
private CharSequence getVisibilityDescription(Context context, Status.Visibility visibility) {
if(visibility == null) {
if (visibility == null) {
return "";
}
int resource;
@ -776,6 +777,30 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
return context.getString(resource);
}
private CharSequence getPollDescription(Context context,
@NonNull StatusViewData.Concrete status) {
Poll poll = status.getPoll();
if (poll == null) {
return "";
} else {
CharSequence[] args = new CharSequence[5];
List<PollOption> options = poll.getOptions();
for (int i = 0; i < args.length; i++) {
if (i < options.size()) {
int percent = options.get(i).getPercent(poll.getVotesCount());
args[i] = HtmlUtils.fromHtml(context.getString(
R.string.poll_option_format,
percent,
options.get(i).getTitle()));
} else {
args[i] = "";
}
}
args[4] = getPollInfoText(System.currentTimeMillis(), poll, context);
return context.getString(R.string.description_poll, args);
}
}
protected CharSequence getFavsText(Context context, int count) {
if (count > 0) {
String countString = numberFormat.format(count);
@ -795,14 +820,14 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
}
protected void setupPoll(Poll poll, List<Emoji> emojis, StatusActionListener listener) {
if(poll == null) {
for(TextView pollResult: pollResults) {
if (poll == null) {
for (TextView pollResult : pollResults) {
pollResult.setVisibility(View.GONE);
}
pollDescription.setVisibility(View.GONE);
pollRadioGroup.setVisibility(View.GONE);
for(CheckBox checkBox: pollCheckboxOptions) {
for (CheckBox checkBox : pollCheckboxOptions) {
checkBox.setVisibility(View.GONE);
}
@ -814,38 +839,35 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
Context context = pollDescription.getContext();
if(expired || poll.getVoted()) {
if (expired || poll.getVoted()) {
// no voting possible
setupPollResult(poll, emojis);
setupPollResult(poll, emojis);
} else {
// voting possible
setupPollVoting(poll, emojis, listener);
}
pollDescription.setVisibility(View.VISIBLE);
pollDescription.setText(getPollInfoText(timestamp, poll, context));
}
}
String votes = numberFormat.format(poll.getVotesCount());
String votesText = context.getResources().getQuantityString(R.plurals.poll_info_votes, poll.getVotesCount(), votes);
CharSequence pollDurationInfo;
if(expired) {
pollDurationInfo = context.getString(R.string.poll_info_closed);
private CharSequence getPollInfoText(long timestamp, Poll poll, Context context) {
String votes = numberFormat.format(poll.getVotesCount());
String votesText = context.getResources().getQuantityString(R.plurals.poll_info_votes, poll.getVotesCount(), votes);
CharSequence pollDurationInfo;
if (poll.getExpired()) {
pollDurationInfo = context.getString(R.string.poll_info_closed);
} else {
if (useAbsoluteTime) {
pollDurationInfo = context.getString(R.string.poll_info_time_absolute, getAbsoluteTime(poll.getExpiresAt()));
} else {
if(useAbsoluteTime) {
pollDurationInfo = context.getString(R.string.poll_info_time_absolute, getAbsoluteTime(poll.getExpiresAt()));
} else {
String pollDuration = DateUtils.formatPollDuration(pollDescription.getContext(), poll.getExpiresAt().getTime(), timestamp);
pollDurationInfo = context.getString(R.string.poll_info_time_relative, pollDuration);
}
String pollDuration = DateUtils.formatPollDuration(pollDescription.getContext(), poll.getExpiresAt().getTime(), timestamp);
pollDurationInfo = context.getString(R.string.poll_info_time_relative, pollDuration);
}
String pollInfo = pollDescription.getContext().getString(R.string.poll_info_format, votesText, pollDurationInfo);
pollDescription.setText(pollInfo);
}
return pollDescription.getContext().getString(R.string.poll_info_format, votesText, pollDurationInfo);
}
private void setupPollResult(Poll poll, List<Emoji> emojis) {

@ -482,7 +482,6 @@
<string name="pin_action">Fixar</string>
<string name="description_status_reblogged">Respost</string>
<string name="description_status"> .<!-- Nom públic, advertència\?, contingut\?, data relativa, respost per\?, respost\?, favorits\?, nom usuari, mèdia\?; visibilitat, número de favorits\?, número de respostes\?--> %1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s </string>
<string name="compose_preview_image_description">Accions per a la imatge %s</string>

@ -374,9 +374,6 @@
</string>
<string name="description_visiblity_direct"> Přímý
</string>
<string name="description_status"> <!-- Zobrazované jméno, varování?, obsah?, relativní datum, znovusdíleno kým?, znovusdíleno?, oblíbeno?, uživatelské jméno, média?; viditelnost, počet oblíbení?, počet boostů?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="hint_list_name">Název seznamu</string>
<string name="edit_hashtag_title">Upravit hashtag</string>
<string name="edit_hashtag_hint">Hashtag bez #</string>

@ -366,9 +366,7 @@
<string name="description_visiblity_private"> Sekvantoj
</string>
<string name="description_visiblity_direct"> Rekta </string>
<string name="description_status"> <!-- Display name, cw?, content?, relative date, reposted by?, reposted?, favorited?, username, media?; visibility, fav number?, reblog number?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="hint_list_name">Nomo de la listo</string>
<string name="action_delete_and_redraft">Forigi kaj reskribi</string>
<string name="dialog_redraft_toot_warning">Ĉu forigi kaj reskribi ĉi-tiun mesaĝon\?</string>

@ -424,7 +424,6 @@
<string name="action_open_reblogger">Abrir autor del impulso</string>
<string name="action_open_reblogged_by">Mostrar impulsos</string>
<string name="description_status"> <!-- Display name, cw\?, content\?, relative date, reposted by\?, reposted\?, favorited\?, username, media\?; visibility, fav number\?, reblog number\?--> %1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s </string>
<string name="poll_option_format"> <!-- 15% vote for this! --> &lt;b&gt;%1$d%%&lt;/b&gt; %2$s</string>

@ -372,9 +372,6 @@
</string>
<string name="description_visiblity_direct"> Direct
</string>
<string name="description_status"> <!-- Nom public, avertissement?, contenu?, date relative, reblogué par?, reblogué?, mis en favoris?, username, media?; visibilité, nombre de fav?, nombre de reblogs?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="hint_list_name">Nom de la liste</string>
<string name="edit_hashtag_title">Modifier les hashtags</string>
<string name="edit_hashtag_hint">Hastags sans #</string>

@ -366,9 +366,6 @@
</string>
<string name="description_visiblity_direct"> Diretti
</string>
<string name="description_status"> <!-- Nome visualizzato, cw?, contenuto?, data relativa, ripostato da?, ripostato?, apprezzato?, nome utente, media?; visibilità, numero di mi piace?, numero di riblog?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="hint_list_name">Nome della lista</string>
<string name="download_media">Scarica media</string>
<string name="downloading_media">Scaricando media</string>

@ -346,9 +346,6 @@
</string>
<string name="description_visiblity_direct"> Direct
</string>
<string name="description_status"> <!-- Display name, cw?, content?, relative date, reposted by?, reposted?, favorited?, username, media?; visibility, fav number?, reblog number?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="download_media">Media downloaden</string>
<string name="downloading_media">Media aan het downloaden</string>

@ -218,9 +218,6 @@
<string name="pref_title_http_proxy_server">Serveradresse</string>
<string name="pref_title_http_proxy_port">Serverport</string>
<string name="description_status"> <!-- Display name, cw\?, content\?, relative date, reposted by\?, reposted\?, favorited\?, username, media\?; visibility, fav number\?, reblog number\?--> %1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s </string>
<string name="pref_default_media_sensitivity">Marker alltid media som sensitivt</string>
<string name="pref_publishing">Publisering (synkronisert med server)</string>
<string name="pref_failed_to_sync">Synkronisering av innstillinger feilet</string>

@ -373,7 +373,6 @@
<string name="description_visiblity_unlisted">Pas listat</string>
<string name="description_visiblity_private">Seguidors</string>
<string name="description_visiblity_direct">Dirècte</string>
<string name="description_status"> <!-- Nom d’afichatge, cw\?, contengut\?, data relativa, repartejat per\?, repartajat\?, aimat\?, nom d’utilizaire, mèdia\?; visibilitat, nombre de fav\?, nombre de partatge\?--> %1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s </string>
<string name="hint_list_name">Nom de la lista</string>

@ -386,7 +386,6 @@
<string name="description_status_favourited">Favoritado</string>
<string name="description_visiblity_unlisted">Não-listado</string>
<string name="description_visiblity_direct">Direta</string>
<string name="description_status"> <!-- Display name, cw\?, content\?, relative date, reposted by\?, reposted\?, favorited\?, username, media\?; visibility, fav number\?, reblog number\?--> %1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s </string>
<string name="hint_list_name">Nome da lista</string>

@ -465,10 +465,6 @@
<string name="description_visiblity_direct">
Для упомянутых
</string>
<string name="description_status">
<!-- Display name, cw?, content?, relative date, reposted by?, reposted?, favorited?, username, media?; visibility, fav number?, reblog number?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="hint_list_name">Название списка</string>

@ -394,7 +394,6 @@
<string name="description_visiblity_unlisted">Ni prikazano</string>
<string name="description_visiblity_private">Sledilci</string>
<string name="description_visiblity_direct">Neposredno</string>
<string name="description_status"> <!-- Display name, cw\?, content\?, relative date, reposted by\?, reposted\?, favorited\?, username, media\?; visibility, fav number\?, reblog number\?-->%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s </string>
<string name="hint_list_name">Ime seznama</string>

@ -366,9 +366,6 @@
</string>
<string name="description_visiblity_direct"> Direkt
</string>
<string name="description_status"> <!-- Display name, cw?, content?, relative date, reposted by?, reposted?, favorited?, username, media?; visibility, fav number?, reblog number?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="hint_list_name">Listnamn</string>
<string name="download_media">Ladda ned media</string>
<string name="downloading_media">Laddar ned media</string>

@ -447,10 +447,6 @@
<string name="description_visiblity_direct">
私信
</string>
<string name="description_status">
<!-- Display name, cw?, content?, relative date, reposted by?, reposted?, favorited?, username, media?; visibility, fav number?, reblog number?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="hint_list_name">列表名</string>

@ -447,10 +447,6 @@
<string name="description_visiblity_direct">
私信
</string>
<string name="description_status">
<!-- Display name, cw?, content?, relative date, reposted by?, reposted?, favorited?, username, media?; visibility, fav number?, reblog number?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="hint_list_name">列表名</string>

@ -447,10 +447,6 @@
<string name="description_visiblity_direct">
私信
</string>
<string name="description_status">
<!-- Display name, cw?, content?, relative date, reposted by?, reposted?, favorited?, username, media?; visibility, fav number?, reblog number?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="hint_list_name">列表名</string>

@ -447,10 +447,6 @@
<string name="description_visiblity_direct">
私信
</string>
<string name="description_status">
<!-- Display name, cw?, content?, relative date, reposted by?, reposted?, favorited?, username, media?; visibility, fav number?, reblog number?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="hint_list_name">列表名</string>

@ -447,10 +447,6 @@
<string name="description_visiblity_direct">
私信
</string>
<string name="description_status">
<!-- Display name, cw?, content?, relative date, reposted by?, reposted?, favorited?, username, media?; visibility, fav number?, reblog number?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
<string name="hint_list_name">列表名</string>

@ -99,4 +99,10 @@
<item>ja</item>
</string-array>
<string name="description_status" translatable="false">
<!-- Display name, cw?, content?, poll? relative date, reposted by?, reposted?, favorited?, username, media?; visibility, fav number?, reblog number?-->
%1$s; %2$s; %3$s, %13$s %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
</string>
</resources>

@ -450,9 +450,8 @@
<string name="description_visiblity_direct">
Direct
</string>
<string name="description_status">
<!-- Display name, cw?, content?, relative date, reposted by?, reposted?, favorited?, username, media?; visibility, fav number?, reblog number?-->
%1$s; %2$s; %3$s, %4$s, %5$s; %6$s, %7$s, %8$s, %9$s; %10$s, %11$s, %12$s
<string name="description_poll">
Poll with choices: %s, %s, %s, %s; %s
</string>
<string name="hint_list_name">List name</string>

Loading…
Cancel
Save