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

Add accessibility tags #1054

Merged
merged 40 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
76b6a43
adding accessibility id to new conversation button
burtonemily Jul 13, 2022
ff8032d
adding accessibility ids and strings for testing
burtonemily Jul 13, 2022
a86ab3e
updating id tags for new conversation buttons
burtonemily Jul 13, 2022
11c4d28
accessibility tags for create contact test
burtonemily Jul 14, 2022
7b9a6dd
adding ids for message requests, config message, requests banner and …
burtonemily Jul 15, 2022
93373e2
adding more tags to settings page
burtonemily Aug 4, 2022
a1a6983
adding tags to different resolutions for landing page
burtonemily Aug 8, 2022
8ab3841
updating display name in settings to include accessibility id
burtonemily Aug 10, 2022
432ebf0
found some stashed changes which i forgot about
burtonemily Aug 17, 2022
e0bd4e9
more stashed changes
burtonemily Aug 17, 2022
4378bca
adding tags to layout sw400dp
burtonemily Aug 17, 2022
72f1d5d
closed group testing, delete/unsend message testing and selecting con…
burtonemily Aug 23, 2022
ad7ea56
adding tags for message body, selecting contacts for group creation, …
burtonemily Aug 25, 2022
bfc8ba3
added tags for disappearing messages menu option, time selector, cloc…
burtonemily Aug 31, 2022
1939603
add test for block user
burtonemily Sep 2, 2022
dfd7bad
docs: Adding in accessibility ID's for Appium testing
burtonemily Sep 9, 2022
9ee7219
Merge remote-tracking branch 'origin/dev' into accessibility_tags
burtonemily Sep 9, 2022
843fffb
accessibility tags for conversation options, profile picture/settings…
burtonemily Sep 14, 2022
c0dd64a
Add content descriptions for better accessibility
Oct 5, 2022
ae19d4b
Merge branch 'dev' into accessibility-tags
Oct 6, 2022
860d47e
Add more content descriptions
Oct 6, 2022
5a8e189
Add timer icon content description
Oct 7, 2022
ce646eb
Update profile picture content description
Oct 7, 2022
dd07756
Merge branch 'dev' into accessibility_tags
burtonemily Dec 8, 2022
1688205
Merge remote-tracking branch 'origin/master' into accessibility_tags
burtonemily Jan 12, 2023
b8887ed
Adding accessibility ids to new conversation creation screen and to m…
burtonemily Jan 25, 2023
3f64ac3
Merge branch 'dev' into accessibility_tags
burtonemily Jan 25, 2023
7f858b7
fix: content descriptions in their correct places and prevent a crash
burtonemily Jan 25, 2023
ad2d676
Merge branch 'dev' into accessibility_tags
burtonemily Jan 26, 2023
7559cfb
Merge branch 'dev' into accessibility_tags
burtonemily Jan 30, 2023
4e38b75
build: update build number
hjubb Jan 30, 2023
378fb40
Merge branch 'dev'
hjubb Feb 6, 2023
48799db
build: update build number
hjubb Feb 6, 2023
1a0e20f
Merge remote-tracking branch 'origin/master' into accessibility_tags
burtonemily Feb 13, 2023
eeeb91b
Adding back in FrameLayout, making changes as request
burtonemily Feb 14, 2023
612b0c1
Fixed viewPager move
burtonemily Feb 14, 2023
069ef6b
Fixing changes as requested by Jubb
burtonemily Feb 15, 2023
cdbbd6b
Adding content descriptions to mentions list, voice message settings,…
burtonemily Mar 7, 2023
ba71c73
Adds content descriptions to blocked contacts heading in conversation…
burtonemily Mar 29, 2023
48a95c8
Adds content descriptions to empty message request folder and text in…
burtonemily Apr 4, 2023
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
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ dependencies {
testImplementation 'org.robolectric:shadows-multidex:4.4'
}

def canonicalVersionCode = 323
def canonicalVersionName = "1.16.3"
def canonicalVersionCode = 333
def canonicalVersionName = "1.16.5"

def postFixSize = 10
def abiPostFix = ['armeabi-v7a' : 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import androidx.annotation.AttrRes
/**
* Represents an action to be rendered
*/
data class ActionItem(
data class ActionItem @JvmOverloads constructor(
@AttrRes val iconRes: Int,
val title: CharSequence,
val action: Runnable
val action: Runnable,
val contentDescription: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class ContextMenuList(recyclerView: RecyclerView, onItemClick: () -> Unit) {
context.theme.resolveAttribute(model.item.iconRes, typedValue, true)
icon.setImageDrawable(ContextCompat.getDrawable(context, typedValue.resourceId))
}
itemView.contentDescription = model.item.contentDescription
title.text = model.item.title
itemView.setOnClickListener {
model.item.action.run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,9 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
val recipient = viewModel.recipient ?: return
if (!isShowingMentionCandidatesView) {
additionalContentContainer.removeAllViews()
val view = MentionCandidatesView(this)
val view = MentionCandidatesView(this).apply {
contentDescription = context.getString(R.string.AccessibilityId_mentions_list)
}
view.glide = glide
view.onCandidateSelected = { handleMentionSelected(it) }
additionalContentContainer.addView(view)
Expand Down Expand Up @@ -943,7 +945,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
override fun block(deleteThread: Boolean) {
val title = R.string.RecipientPreferenceActivity_block_this_contact_question
val message = R.string.RecipientPreferenceActivity_you_will_no_longer_receive_messages_and_calls_from_this_contact
AlertDialog.Builder(this)
val dialog = AlertDialog.Builder(this)
.setTitle(title)
.setMessage(message)
.setNegativeButton(android.R.string.cancel, null)
Expand All @@ -954,6 +956,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
finish()
}
}.show()
val button = dialog.getButton(DialogInterface.BUTTON_POSITIVE)
button.setContentDescription("Confirm block")
}

override fun copySessionID(sessionId: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,22 +660,32 @@ public void setOnHideListener(@Nullable OnHideListener onHideListener) {

String userPublicKey = TextSecurePreferences.getLocalNumber(getContext());
// Select message
items.add(new ActionItem(R.attr.menu_select_icon, getContext().getResources().getString(R.string.conversation_context__menu_select), () -> handleActionItemClicked(Action.SELECT)));
items.add(new ActionItem(R.attr.menu_select_icon, getContext().getResources().getString(R.string.conversation_context__menu_select), () -> handleActionItemClicked(Action.SELECT),
getContext().getResources().getString(R.string.AccessibilityId_select)));
// Reply
if (!message.isPending() && !message.isFailed()) {
items.add(new ActionItem(R.attr.menu_reply_icon, getContext().getResources().getString(R.string.conversation_context__menu_reply), () -> handleActionItemClicked(Action.REPLY)));
items.add(
new ActionItem(R.attr.menu_reply_icon, getContext().getResources().getString(R.string.conversation_context__menu_reply), () -> handleActionItemClicked(Action.REPLY),
getContext().getResources().getString(R.string.AccessibilityId_reply_message))
);
}
// Copy message text
if (!containsControlMessage && hasText) {
items.add(new ActionItem(R.attr.menu_copy_icon, getContext().getResources().getString(R.string.copy), () -> handleActionItemClicked(Action.COPY_MESSAGE)));
}
// Copy Session ID
if (recipient.isGroupRecipient() && !recipient.isOpenGroupRecipient() && !message.getRecipient().getAddress().toString().equals(userPublicKey)) {
items.add(new ActionItem(R.attr.menu_copy_icon, getContext().getResources().getString(R.string.activity_conversation_menu_copy_session_id), () -> handleActionItemClicked(Action.COPY_SESSION_ID)));
items.add(new ActionItem(
R.attr.menu_copy_icon, getContext().getResources().getString(R.string.activity_conversation_menu_copy_session_id), () -> handleActionItemClicked(Action.COPY_SESSION_ID))
);
}
// Delete message
if (ConversationMenuItemHelper.userCanDeleteSelectedItems(getContext(), message, openGroup, userPublicKey, blindedPublicKey)) {
items.add(new ActionItem(R.attr.menu_trash_icon, getContext().getResources().getString(R.string.delete), () -> handleActionItemClicked(Action.DELETE)));
items.add(new ActionItem(R.attr.menu_trash_icon, getContext().getResources().getString(R.string.delete),
() -> handleActionItemClicked(Action.DELETE),
getContext().getResources().getString(R.string.AccessibilityId_delete_message)
)
);
}
// Ban user
if (ConversationMenuItemHelper.userCanBanSelectedUsers(getContext(), message, openGroup, userPublicKey, blindedPublicKey)) {
Expand All @@ -695,7 +705,9 @@ public void setOnHideListener(@Nullable OnHideListener onHideListener) {
}
// Save media
if (message.isMms() && ((MediaMmsMessageRecord)message).containsMediaSlide()) {
items.add(new ActionItem(R.attr.menu_save_icon, getContext().getResources().getString(R.string.conversation_context_image__save_attachment), () -> handleActionItemClicked(Action.DOWNLOAD)));
items.add(new ActionItem(R.attr.menu_save_icon, getContext().getResources().getString(R.string.conversation_context_image__save_attachment), () -> handleActionItemClicked(Action.DOWNLOAD),
getContext().getResources().getString(R.string.AccessibilityId_save_attachment))
);
}

backgroundView.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate, QuoteViewDelegate, Li
val attachmentButtonsContainerHeight: Int
get() = binding.attachmentsButtonContainer.height

private val attachmentsButton by lazy { InputBarButton(context, R.drawable.ic_plus_24) }
private val microphoneButton by lazy { InputBarButton(context, R.drawable.ic_microphone) }
private val sendButton by lazy { InputBarButton(context, R.drawable.ic_arrow_up, true) }
private val attachmentsButton by lazy { InputBarButton(context, R.drawable.ic_plus_24).apply { contentDescription = context.getString(R.string.AccessibilityId_attachments_button)} }
private val microphoneButton by lazy { InputBarButton(context, R.drawable.ic_microphone).apply { contentDescription = context.getString(R.string.AccessibilityId_microphone_button)} }
private val sendButton by lazy { InputBarButton(context, R.drawable.ic_arrow_up, true).apply { contentDescription = context.getString(R.string.AccessibilityId_send_message_button)} }

// region Lifecycle
constructor(context: Context) : super(context) { initialize() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.ListView
import dagger.hilt.android.AndroidEntryPoint
import network.loki.messenger.R
import org.session.libsession.messaging.mentions.Mention
import org.thoughtcrime.securesms.database.LokiThreadDatabase
import org.thoughtcrime.securesms.mms.GlideRequests
Expand Down Expand Up @@ -41,7 +42,9 @@ class MentionCandidatesView(context: Context, attrs: AttributeSet?, defStyleAttr
override fun getItem(position: Int): Mention { return candidates[position] }

override fun getView(position: Int, cellToBeReused: View?, parent: ViewGroup): View {
val cell = cellToBeReused as MentionCandidateView? ?: MentionCandidateView(context)
val cell = cellToBeReused as MentionCandidateView? ?: MentionCandidateView(context).apply {
contentDescription = context.getString(R.string.AccessibilityId_contact)
}
val mentionCandidate = getItem(position)
cell.glide = glide
cell.candidate = mentionCandidate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.conversation.v2.menus

import android.annotation.SuppressLint
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.graphics.BitmapFactory
import android.graphics.PorterDuff
Expand Down Expand Up @@ -185,7 +186,7 @@ object ConversationMenuHelper {
private fun call(context: Context, thread: Recipient) {

if (!TextSecurePreferences.isCallNotificationsEnabled(context)) {
AlertDialog.Builder(context)
val dialog = AlertDialog.Builder(context)
.setTitle(R.string.ConversationActivity_call_title)
.setMessage(R.string.ConversationActivity_call_prompt)
.setPositiveButton(R.string.activity_settings_title) { _, _ ->
Expand All @@ -194,7 +195,10 @@ object ConversationMenuHelper {
}
.setNeutralButton(R.string.cancel) { d, _ ->
d.dismiss()
}.show()
}.create()
dialog.getButton(DialogInterface.BUTTON_POSITIVE)?.contentDescription = context.getString(R.string.AccessibilityId_settings)
dialog.getButton(DialogInterface.BUTTON_NEGATIVE)?.contentDescription = context.getString(R.string.AccessibilityId_cancel_button)
dialog.show()
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ControlMessageView : LinearLayout {
binding.dateBreakTextView.showDateBreak(message, previous)
binding.iconImageView.visibility = View.GONE
var messageBody: CharSequence = message.getDisplayBody(context)
binding.root.contentDescription= null
when {
message.isExpirationTimerUpdate -> {
binding.iconImageView.setImageDrawable(
Expand All @@ -46,6 +47,7 @@ class ControlMessageView : LinearLayout {
}
message.isMessageRequestResponse -> {
messageBody = context.getString(R.string.message_requests_accepted)
binding.root.contentDescription=context.getString(R.string.AccessibilityId_message_request_config_message)
}
message.isCallLog -> {
val drawable = when {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import android.view.HapticFeedbackConstants
import android.view.MotionEvent
import android.view.View
import android.widget.LinearLayout
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
Expand Down Expand Up @@ -193,7 +196,7 @@ class VisibleMessageView : LinearLayout {
binding.dateBreakTextView.isVisible = showDateBreak
// Message status indicator
if (message.isOutgoing) {
val (iconID, iconColor, textId) = getMessageStatusImage(message)
val (iconID, iconColor, textId, contentDescription) = getMessageStatusImage(message)
if (textId != null) {
binding.messageStatusTextView.setText(textId)

Expand All @@ -208,6 +211,7 @@ class VisibleMessageView : LinearLayout {
}
binding.messageStatusImageView.setImageDrawable(drawable)
}
binding.messageStatusImageView.contentDescription = contentDescription

val lastMessageID = mmsSmsDb.getLastMessageID(message.threadId)
binding.messageStatusTextView.isVisible = (
Expand Down Expand Up @@ -282,17 +286,43 @@ class VisibleMessageView : LinearLayout {
}
}

private fun getMessageStatusImage(message: MessageRecord): Triple<Int?,Int?,Int?> {
data class MessageStatusInfo(@DrawableRes val iconId: Int?,
@ColorInt val iconTint: Int?,
@StringRes val messageText: Int?,
val contentDescription: String?)

private fun getMessageStatusImage(message: MessageRecord): MessageStatusInfo {
return when {
!message.isOutgoing -> Triple(null, null, null)
!message.isOutgoing -> MessageStatusInfo(null,
null,
null,
null)
message.isFailed ->
Triple(R.drawable.ic_delivery_status_failed, resources.getColor(R.color.destructive, context.theme), R.string.delivery_status_failed)
MessageStatusInfo(
R.drawable.ic_delivery_status_failed,
resources.getColor(R.color.destructive, context.theme),
R.string.delivery_status_failed,
null
)
message.isPending ->
Triple(R.drawable.ic_delivery_status_sending, context.getColorFromAttr(R.attr.message_status_color), R.string.delivery_status_sending)
MessageStatusInfo(
R.drawable.ic_delivery_status_sending,
context.getColorFromAttr(R.attr.message_status_color), R.string.delivery_status_sending,
context.getString(R.string.AccessibilityId_message_sent_status_pending)
)
message.isRead ->
Triple(R.drawable.ic_delivery_status_read, context.getColorFromAttr(R.attr.message_status_color), R.string.delivery_status_read)
MessageStatusInfo(
R.drawable.ic_delivery_status_read,
context.getColorFromAttr(R.attr.message_status_color), R.string.delivery_status_read,
null
)
else ->
Triple(R.drawable.ic_delivery_status_sent, context.getColorFromAttr(R.attr.message_status_color), R.string.delivery_status_sent)
MessageStatusInfo(
R.drawable.ic_delivery_status_sent,
context.getColorFromAttr(R.attr.message_status_color),
R.string.delivery_status_sent,
context.getString(R.string.AccessibilityId_message_sent_status_tick)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
Expand All @@ -12,6 +13,7 @@
import android.view.Display;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;

import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
Expand Down Expand Up @@ -162,12 +164,13 @@ private void executePreGrantedPermissionsRequest(PermissionsRequest request) {

@SuppressWarnings("ConstantConditions")
private void executePermissionsRequestWithRationale(PermissionsRequest request) {
RationaleDialog.createFor(permissionObject.getContext(), rationaleDialogMessage, rationalDialogHeader)
.setPositiveButton(R.string.Permissions_continue, (dialog, which) -> executePermissionsRequest(request))
.setNegativeButton(R.string.Permissions_not_now, (dialog, which) -> executeNoPermissionsRequest(request))
.show()
.getWindow()
.setLayout((int)(permissionObject.getWindowWidth() * .75), ViewGroup.LayoutParams.WRAP_CONTENT);
AlertDialog dialog = RationaleDialog.createFor(permissionObject.getContext(), rationaleDialogMessage, rationalDialogHeader)
.setPositiveButton(R.string.Permissions_continue, (d, which) -> executePermissionsRequest(request))
.setNegativeButton(R.string.Permissions_not_now, (d, which) -> executeNoPermissionsRequest(request))
.show();
dialog.getWindow().setLayout((int)(permissionObject.getWindowWidth() * .75), ViewGroup.LayoutParams.WRAP_CONTENT);
Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
positiveButton.setContentDescription("Continue");
}

private void executePermissionsRequest(PermissionsRequest request) {
Expand Down Expand Up @@ -353,12 +356,17 @@ public void run() {
Context context = this.context.get();

if (context != null) {
new AlertDialog.Builder(context, R.style.ThemeOverlay_Session_AlertDialog)
AlertDialog alertDialog = new AlertDialog.Builder(context, R.style.ThemeOverlay_Session_AlertDialog)
.setTitle(R.string.Permissions_permission_required)
.setMessage(message)
.setPositiveButton(R.string.Permissions_continue, (dialog, which) -> context.startActivity(getApplicationSettingsIntent(context)))
.setNegativeButton(android.R.string.cancel, null)
.show();
.create();
Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (positiveButton != null) {
positiveButton.setContentDescription(context.getString(R.string.AccessibilityId_continue));
}
alertDialog.show();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import android.app.AlertDialog;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -179,7 +181,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean val = (boolean) newValue;
if (val) {
// check if we've shown the info dialog and check for microphone permissions
new AlertDialog.Builder(new ContextThemeWrapper(context.requireContext(), R.style.ThemeOverlay_Session_AlertDialog))
AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(context.requireContext(), R.style.ThemeOverlay_Session_AlertDialog))
.setTitle(R.string.dialog_voice_video_title)
.setMessage(R.string.dialog_voice_video_message)
.setPositiveButton(R.string.dialog_link_preview_enable_button_title, (d, w) -> {
Expand All @@ -189,7 +191,9 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {

})
.show();
return false;
Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
positiveButton.setContentDescription("Enable");
return false;
} else {
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout-sw400dp/activity_display_name.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<EditText
style="@style/SessionEditText"
android:id="@+id/displayNameEditText"
android:contentDescription="@string/AccessibilityId_enter_display_name"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_marginLeft="@dimen/very_large_spacing"
Expand All @@ -52,6 +53,7 @@
<Button
style="@style/Widget.Session.Button.Common.ProminentFilled"
android:id="@+id/registerButton"
android:contentDescription="@string/AccessibilityId_continue"
android:layout_width="match_parent"
android:layout_height="@dimen/medium_button_height"
android:layout_marginLeft="@dimen/massive_spacing"
Expand Down
Loading