diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java index 4c17a2699..0d5a0b510 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java @@ -10,20 +10,31 @@ package org.telegram.ui.Cells; import android.content.Context; import android.graphics.drawable.Drawable; +import android.os.Build; +import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityNodeInfo; + +import org.telegram.messenger.R; public class BaseCell extends View { + private CharSequence currentNameMessage; + public BaseCell(Context context) { super(context); + tryInstallAccessibilityDelegate(); } public BaseCell(Context context, AttributeSet attrs) { super(context, attrs); + tryInstallAccessibilityDelegate(); } public BaseCell(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); + tryInstallAccessibilityDelegate(); } protected void setDrawableBounds(Drawable drawable, int x, int y) { @@ -33,4 +44,76 @@ public class BaseCell extends View { protected void setDrawableBounds(Drawable drawable, int x, int y, int w, int h) { drawable.setBounds(x, y, x + w, y + h); } + + @Override + public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(info); + // We called the super implementation to let super classes set + // appropriate info properties. Then we add our properties + // (checkable and checked) which are not supported by a super class. + // Very often you will need to add only the text on the custom view. + CharSequence text = getTextAccessibility(); + if (!TextUtils.isEmpty(text)) { + info.setText(text); + } + } + + @Override + public void onPopulateAccessibilityEvent(AccessibilityEvent event) { + super.onPopulateAccessibilityEvent(event); + // We called the super implementation to populate its text to the + // event. Then we add our text not present in a super class. + // Very often you will need to add only the text on the custom view. + CharSequence text = getTextAccessibility(); + if (!TextUtils.isEmpty(text)) { + event.getText().add(text); + } + } + + public void tryInstallAccessibilityDelegate() { + if (Build.VERSION.SDK_INT < 14) { + return; + } + + setAccessibilityDelegate(new AccessibilityDelegate() { + @Override + public void onInitializeAccessibilityNodeInfo(View host,AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(host,info); + // We called the super implementation to let super classes set + // appropriate info properties. Then we add our properties + // (checkable and checked) which are not supported by a super class. + // Very often you will need to add only the text on the custom view. + CharSequence text = getTextAccessibility(); + if (!TextUtils.isEmpty(text)) { + info.setText(text); + } + } + + @Override + public void onPopulateAccessibilityEvent(View host,AccessibilityEvent event) { + super.onPopulateAccessibilityEvent(host,event); + // We called the super implementation to populate its text to the + // event. Then we add our text not present in a super class. + // Very often you will need to add only the text on the custom view. + CharSequence text = getTextAccessibility(); + if (!TextUtils.isEmpty(text)) { + event.getText().add(text); + } + } + }); + } + + public CharSequence getTextAccessibility() { + if (!TextUtils.isEmpty(currentNameMessage)) { + return currentNameMessage; + }else{ + return getResources().getString(R.string.ContactUnAllocated); + } + } + + public void setTextAccessibility(CharSequence text){ + + currentNameMessage = text; + } + } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index 23a1a1ffe..910c58536 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -642,6 +642,9 @@ public class DialogCell extends BaseCell { CharSequence messageStringFinal = TextUtils.ellipsize(messageString, currentMessagePaint, messageWidth - Utilities.dp(12), TextUtils.TruncateAt.END); messageLayout = new StaticLayout(messageStringFinal, currentMessagePaint, messageWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + //Set string for Accessibility events to speak contact list + setTextAccessibility(nameStringFinal+" "+getResources().getString(R.string.LastMessage)+": "+messageString); + double widthpx = 0; float left = 0; if (Utilities.isRTL) { diff --git a/TMessagesProj/src/main/res/layout/chat_header_layout.xml b/TMessagesProj/src/main/res/layout/chat_header_layout.xml index 8fb0b2f79..72e313630 100644 --- a/TMessagesProj/src/main/res/layout/chat_header_layout.xml +++ b/TMessagesProj/src/main/res/layout/chat_header_layout.xml @@ -8,6 +8,7 @@ \ No newline at end of file diff --git a/TMessagesProj/src/main/res/layout/chat_layout.xml b/TMessagesProj/src/main/res/layout/chat_layout.xml index 6f7cc65f6..d6a909b0b 100644 --- a/TMessagesProj/src/main/res/layout/chat_layout.xml +++ b/TMessagesProj/src/main/res/layout/chat_layout.xml @@ -40,6 +40,7 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/chat_list_view" + android:nextFocusDown="@+id/chat_text_edit" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:clipToPadding="false" @@ -124,22 +125,26 @@ android:src="@drawable/ic_msg_panel_smiles" android:layout_width="48dp" android:layout_height="48dp" + android:nextFocusRight="@+id/chat_text_edit" android:layout_marginTop="2dp" android:paddingTop="1dp" android:scaleType="centerInside" android:paddingLeft="4dp" android:id="@+id/chat_smile_button" + android:contentDescription="@string/Emoticons" android:layout_alignBottom="@+id/chat_text_edit"/> @@ -147,6 +152,7 @@ android:layout_width="48dp" android:layout_height="48dp" android:layout_marginTop="2dp" + android:nextFocusLeft="@+id/chat_text_edit" android:scaleType="centerInside" android:id="@+id/chat_audio_send_button" android:layout_alignParentRight="true" @@ -154,6 +160,7 @@ android:enabled="false" android:src="@drawable/mic_button_states" android:paddingRight="4dp" + android:contentDescription="@string/SendAudio" android:background="@android:color/transparent"/> @@ -68,6 +69,7 @@ android:layout_width="48dp" android:layout_height="48dp" android:src="@drawable/ic_edit" + android:contentDescription="@string/EditName" android:layout_marginTop="4dp"/> \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-es/strings.xml b/TMessagesProj/src/main/res/values-es/strings.xml index 352603dfd..e380f0d02 100644 --- a/TMessagesProj/src/main/res/values-es/strings.xml +++ b/TMessagesProj/src/main/res/values-es/strings.xml @@ -348,6 +348,17 @@ Los mensajes de Telegram]]> están fuertemente]]>cifrados y se pueden autodestruir. Empieza a conversar + + Contacto no asignado + último mensaje + emoticonos + enviar mensaje + grabar audio + enviar audio + avatar + cambiar avatar + editar nombre + CACHE_TAG \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index 3b850b794..d10304bf2 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -348,6 +348,18 @@ Telegram]]> messages are heavily encrypted]]>and can self-destruct Start Messaging + + Contact unallocated + last message + emoticons + send message + record audio + send audio + avatar + change avatar + edit name + CACHE_TAG + \ No newline at end of file