mirror of
https://github.com/DrKLO/Telegram.git
synced 2025-03-13 19:28:14 +01:00
Accessibility changes in contact list to read username and last message, and some content descripiton in layout images
Signed-off-by: fidojones <fidojones@fidojones.com>
This commit is contained in:
parent
9814a6e927
commit
e23e2c0778
7 changed files with 84 additions and 0 deletions
|
@ -10,20 +10,31 @@ package org.telegram.ui.Cells;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||||||
|
|
||||||
|
import org.telegram.messenger.R;
|
||||||
|
|
||||||
public class BaseCell extends View {
|
public class BaseCell extends View {
|
||||||
|
private CharSequence currentNameMessage;
|
||||||
|
|
||||||
public BaseCell(Context context) {
|
public BaseCell(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
tryInstallAccessibilityDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseCell(Context context, AttributeSet attrs) {
|
public BaseCell(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
tryInstallAccessibilityDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseCell(Context context, AttributeSet attrs, int defStyleAttr) {
|
public BaseCell(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
|
tryInstallAccessibilityDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setDrawableBounds(Drawable drawable, int x, int y) {
|
protected void setDrawableBounds(Drawable drawable, int x, int y) {
|
||||||
|
@ -33,4 +44,51 @@ public class BaseCell extends View {
|
||||||
protected void setDrawableBounds(Drawable drawable, int x, int y, int w, int h) {
|
protected void setDrawableBounds(Drawable drawable, int x, int y, int w, int h) {
|
||||||
drawable.setBounds(x, y, x + w, y + h);
|
drawable.setBounds(x, y, x + w, y + h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -638,6 +638,9 @@ public class DialogCell extends BaseCell {
|
||||||
CharSequence messageStringFinal = TextUtils.ellipsize(messageString, currentMessagePaint, messageWidth - Utilities.dp(12), TextUtils.TruncateAt.END);
|
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);
|
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;
|
double widthpx = 0;
|
||||||
float left = 0;
|
float left = 0;
|
||||||
if (Utilities.isRTL) {
|
if (Utilities.isRTL) {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<org.telegram.ui.Views.BackupImageView
|
<org.telegram.ui.Views.BackupImageView
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
|
android:contentDescription="@string/Avatar"
|
||||||
android:id="@+id/chat_avatar_image"/>
|
android:id="@+id/chat_avatar_image"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -129,6 +129,7 @@
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:paddingLeft="4dp"
|
android:paddingLeft="4dp"
|
||||||
android:id="@+id/chat_smile_button"
|
android:id="@+id/chat_smile_button"
|
||||||
|
android:contentDescription="@string/Emoticons"
|
||||||
android:layout_alignBottom="@+id/chat_text_edit"/>
|
android:layout_alignBottom="@+id/chat_text_edit"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
|
@ -140,6 +141,7 @@
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignBottom="@+id/chat_text_edit"
|
android:layout_alignBottom="@+id/chat_text_edit"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
|
android:contentDescription="@string/SendMessage"
|
||||||
android:background="@android:color/transparent"/>
|
android:background="@android:color/transparent"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/settings_change_avatar_button"
|
android:id="@+id/settings_change_avatar_button"
|
||||||
android:background="@drawable/photo_spinner"
|
android:background="@drawable/photo_spinner"
|
||||||
|
android:contentDescription="@string/ChangeAvatar"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"/>
|
android:layout_height="fill_parent"/>
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:src="@drawable/ic_edit"
|
android:src="@drawable/ic_edit"
|
||||||
|
android:contentDescription="@string/EditName"
|
||||||
android:layout_marginTop="4dp"/>
|
android:layout_marginTop="4dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -348,6 +348,15 @@
|
||||||
<string name="Page7Message">Los mensajes de <![CDATA[<b>Telegram</b>]]> están fuertemente<![CDATA[<br/>]]>cifrados y se pueden autodestruir.</string>
|
<string name="Page7Message">Los mensajes de <![CDATA[<b>Telegram</b>]]> están fuertemente<![CDATA[<br/>]]>cifrados y se pueden autodestruir.</string>
|
||||||
<string name="StartMessaging">Empieza a conversar</string>
|
<string name="StartMessaging">Empieza a conversar</string>
|
||||||
|
|
||||||
|
<!--Accessibility strings-->
|
||||||
|
<string name="ContactUnAllocated">Contacto no asignado</string>
|
||||||
|
<string name="LastMessage">último mensaje</string>
|
||||||
|
<string name="Emoticons">emoticonos</string>
|
||||||
|
<string name="SendMessage">enviar mensaje</string>
|
||||||
|
<string name="Avatar">avatar</string>
|
||||||
|
<string name="ChangeAvatar">cambiar avatar</string>
|
||||||
|
<string name="EditName">editar nombre</string>
|
||||||
|
|
||||||
<!--Don't change this! Not for localization!-->
|
<!--Don't change this! Not for localization!-->
|
||||||
<string name="CacheTag">CACHE_TAG</string>
|
<string name="CacheTag">CACHE_TAG</string>
|
||||||
</resources>
|
</resources>
|
|
@ -348,6 +348,15 @@
|
||||||
<string name="Page7Message"><![CDATA[<b>Telegram</b>]]> messages are heavily encrypted<![CDATA[<br/>]]>and can self-destruct</string>
|
<string name="Page7Message"><![CDATA[<b>Telegram</b>]]> messages are heavily encrypted<![CDATA[<br/>]]>and can self-destruct</string>
|
||||||
<string name="StartMessaging">Start Messaging</string>
|
<string name="StartMessaging">Start Messaging</string>
|
||||||
|
|
||||||
|
<!--Accessibility strings-->
|
||||||
|
<string name="ContactUnAllocated">Contact unallocated</string>
|
||||||
|
<string name="LastMessage">last message</string>
|
||||||
|
<string name="Emoticons">emoticons</string>
|
||||||
|
<string name="SendMessage">send message</string>
|
||||||
|
<string name="Avatar">avatar</string>
|
||||||
|
<string name="ChangeAvatar">change avatar</string>
|
||||||
|
<string name="EditName">edit name</string>
|
||||||
|
|
||||||
<!--Don't change this! Not for localization!-->
|
<!--Don't change this! Not for localization!-->
|
||||||
<string name="CacheTag">CACHE_TAG</string>
|
<string name="CacheTag">CACHE_TAG</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Add table
Reference in a new issue