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:
fidojones 2014-02-06 11:07:25 +01:00
parent 9814a6e927
commit e23e2c0778
7 changed files with 84 additions and 0 deletions

View file

@ -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,51 @@ 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);
}
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;
}
}

View file

@ -638,6 +638,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) {

View file

@ -8,6 +8,7 @@
<org.telegram.ui.Views.BackupImageView
android:layout_height="48dp"
android:layout_width="48dp"
android:contentDescription="@string/Avatar"
android:id="@+id/chat_avatar_image"/>
</RelativeLayout>

View file

@ -129,6 +129,7 @@
android:scaleType="centerInside"
android:paddingLeft="4dp"
android:id="@+id/chat_smile_button"
android:contentDescription="@string/Emoticons"
android:layout_alignBottom="@+id/chat_text_edit"/>
<ImageButton
@ -140,6 +141,7 @@
android:layout_alignParentRight="true"
android:layout_alignBottom="@+id/chat_text_edit"
android:enabled="false"
android:contentDescription="@string/SendMessage"
android:background="@android:color/transparent"/>
<EditText

View file

@ -19,6 +19,7 @@
<ImageButton
android:id="@+id/settings_change_avatar_button"
android:background="@drawable/photo_spinner"
android:contentDescription="@string/ChangeAvatar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
@ -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"/>
</LinearLayout>

View file

@ -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="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!-->
<string name="CacheTag">CACHE_TAG</string>
</resources>

View file

@ -348,6 +348,15 @@
<string name="Page7Message"><![CDATA[<b>Telegram</b>]]> messages are heavily encrypted<![CDATA[<br/>]]>and can self-destruct</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!-->
<string name="CacheTag">CACHE_TAG</string>
</resources>