set content description for all avatars
This commit is contained in:
		
							parent
							
								
									3c0773c6e7
								
							
						
					
					
						commit
						c48499253b
					
				@ -615,6 +615,11 @@ public class Account extends AbstractEntity implements AvatarService.Avatarable
 | 
				
			|||||||
        return UIHelper.getColorForName(jid.asBareJid().toString());
 | 
					        return UIHelper.getColorForName(jid.asBareJid().toString());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getAvatarName() {
 | 
				
			||||||
 | 
					        throw new IllegalStateException("This method should not be called");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public enum State {
 | 
					    public enum State {
 | 
				
			||||||
        DISABLED(false, false),
 | 
					        DISABLED(false, false),
 | 
				
			||||||
        OFFLINE(false),
 | 
					        OFFLINE(false),
 | 
				
			||||||
 | 
				
			|||||||
@ -248,4 +248,9 @@ public class Bookmark extends Element implements ListItem {
 | 
				
			|||||||
	public int getAvatarBackgroundColor() {
 | 
						public int getAvatarBackgroundColor() {
 | 
				
			||||||
		return UIHelper.getColorForName(jid != null ? jid.asBareJid().toString() : getDisplayName());
 | 
							return UIHelper.getColorForName(jid != null ? jid.asBareJid().toString() : getDisplayName());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public String getAvatarName() {
 | 
				
			||||||
 | 
							return getDisplayName();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -558,6 +558,11 @@ public class Contact implements ListItem, Blockable {
 | 
				
			|||||||
		return UIHelper.getColorForName(jid != null ? jid.asBareJid().toString() : getDisplayName());
 | 
							return UIHelper.getColorForName(jid != null ? jid.asBareJid().toString() : getDisplayName());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public String getAvatarName() {
 | 
				
			||||||
 | 
							return getDisplayName();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public boolean hasAvatarOrPresenceName() {
 | 
						public boolean hasAvatarOrPresenceName() {
 | 
				
			||||||
		return (avatar != null && avatar.getFilename() != null) || presenceName != null;
 | 
							return (avatar != null && avatar.getFilename() != null) || presenceName != null;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -1066,6 +1066,11 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
 | 
				
			|||||||
        return UIHelper.getColorForName(getName().toString());
 | 
					        return UIHelper.getColorForName(getName().toString());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getAvatarName() {
 | 
				
			||||||
 | 
					        return getName().toString();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public interface OnMessageFound {
 | 
					    public interface OnMessageFound {
 | 
				
			||||||
        void onMessageFound(final Message message);
 | 
					        void onMessageFound(final Message message);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -684,6 +684,11 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public String getAvatarName() {
 | 
				
			||||||
 | 
							return UIHelper.getMessageDisplayName(this);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public boolean isOOb() {
 | 
						public boolean isOOb() {
 | 
				
			||||||
		return oob;
 | 
							return oob;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -900,5 +900,10 @@ public class MucOptions {
 | 
				
			|||||||
            final String seed = realJid != null ? realJid.asBareJid().toString() : null;
 | 
					            final String seed = realJid != null ? realJid.asBareJid().toString() : null;
 | 
				
			||||||
            return UIHelper.getColorForName(seed == null ? getName() : seed);
 | 
					            return UIHelper.getColorForName(seed == null ? getName() : seed);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public String getAvatarName() {
 | 
				
			||||||
 | 
					            return getConversation().getName().toString();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -79,6 +79,11 @@ public class RawBlockable implements ListItem, Blockable {
 | 
				
			|||||||
        return  UIHelper.getColorForName(jid.toEscapedString());
 | 
					        return  UIHelper.getColorForName(jid.toEscapedString());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getAvatarName() {
 | 
				
			||||||
 | 
					        return getDisplayName();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int compareTo(ListItem o) {
 | 
					    public int compareTo(ListItem o) {
 | 
				
			||||||
        return this.getDisplayName().compareToIgnoreCase(
 | 
					        return this.getDisplayName().compareToIgnoreCase(
 | 
				
			||||||
 | 
				
			|||||||
@ -55,6 +55,11 @@ public class Room implements AvatarService.Avatarable, Comparable<Room> {
 | 
				
			|||||||
        return UIHelper.getColorForName(room != null ? room.asBareJid().toEscapedString() : name);
 | 
					        return UIHelper.getColorForName(room != null ? room.asBareJid().toEscapedString() : name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getAvatarName() {
 | 
				
			||||||
 | 
					        return name;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean equals(Object o) {
 | 
					    public boolean equals(Object o) {
 | 
				
			||||||
        if (this == o) return true;
 | 
					        if (this == o) return true;
 | 
				
			||||||
 | 
				
			|||||||
@ -685,5 +685,6 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	public interface Avatarable {
 | 
						public interface Avatarable {
 | 
				
			||||||
		@ColorInt int getAvatarBackgroundColor();
 | 
							@ColorInt int getAvatarBackgroundColor();
 | 
				
			||||||
 | 
							String getAvatarName();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
package eu.siacs.conversations.ui.util;
 | 
					package eu.siacs.conversations.ui.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.content.Context;
 | 
				
			||||||
import android.content.res.Resources;
 | 
					import android.content.res.Resources;
 | 
				
			||||||
import android.graphics.Bitmap;
 | 
					import android.graphics.Bitmap;
 | 
				
			||||||
import android.graphics.drawable.BitmapDrawable;
 | 
					import android.graphics.drawable.BitmapDrawable;
 | 
				
			||||||
@ -11,11 +12,10 @@ import android.widget.ImageView;
 | 
				
			|||||||
import java.lang.ref.WeakReference;
 | 
					import java.lang.ref.WeakReference;
 | 
				
			||||||
import java.util.concurrent.RejectedExecutionException;
 | 
					import java.util.concurrent.RejectedExecutionException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import eu.siacs.conversations.R;
 | 
				
			||||||
import eu.siacs.conversations.entities.Account;
 | 
					import eu.siacs.conversations.entities.Account;
 | 
				
			||||||
import eu.siacs.conversations.services.AvatarService;
 | 
					import eu.siacs.conversations.services.AvatarService;
 | 
				
			||||||
import eu.siacs.conversations.ui.XmppActivity;
 | 
					import eu.siacs.conversations.ui.XmppActivity;
 | 
				
			||||||
import eu.siacs.conversations.ui.adapter.AccountAdapter;
 | 
					 | 
				
			||||||
import eu.siacs.conversations.utils.UIHelper;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class AvatarWorkerTask extends AsyncTask<AvatarService.Avatarable, Void, Bitmap> {
 | 
					public class AvatarWorkerTask extends AsyncTask<AvatarService.Avatarable, Void, Bitmap> {
 | 
				
			||||||
    private final WeakReference<ImageView> imageViewReference;
 | 
					    private final WeakReference<ImageView> imageViewReference;
 | 
				
			||||||
@ -80,6 +80,7 @@ public class AvatarWorkerTask extends AsyncTask<AvatarService.Avatarable, Void,
 | 
				
			|||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            final Bitmap bm = activity.avatarService().get(avatarable, (int) activity.getResources().getDimension(size), true);
 | 
					            final Bitmap bm = activity.avatarService().get(avatarable, (int) activity.getResources().getDimension(size), true);
 | 
				
			||||||
 | 
					            setContentDescription(avatarable, imageView);
 | 
				
			||||||
            if (bm != null) {
 | 
					            if (bm != null) {
 | 
				
			||||||
                cancelPotentialWork(avatarable, imageView);
 | 
					                cancelPotentialWork(avatarable, imageView);
 | 
				
			||||||
                imageView.setImageBitmap(bm);
 | 
					                imageView.setImageBitmap(bm);
 | 
				
			||||||
@ -98,6 +99,15 @@ public class AvatarWorkerTask extends AsyncTask<AvatarService.Avatarable, Void,
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static void setContentDescription(final AvatarService.Avatarable avatarable, final ImageView imageView) {
 | 
				
			||||||
 | 
					        final Context context = imageView.getContext();
 | 
				
			||||||
 | 
					        if (avatarable instanceof Account) {
 | 
				
			||||||
 | 
					            imageView.setContentDescription(context.getString(R.string.your_avatar));
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            imageView.setContentDescription(context.getString(R.string.avatar_for_x, avatarable.getAvatarName()));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static class AsyncDrawable extends BitmapDrawable {
 | 
					    static class AsyncDrawable extends BitmapDrawable {
 | 
				
			||||||
        private final WeakReference<AvatarWorkerTask> avatarWorkerTaskReference;
 | 
					        private final WeakReference<AvatarWorkerTask> avatarWorkerTaskReference;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -929,6 +929,8 @@
 | 
				
			|||||||
    <string name="could_not_correct_message">Could not correct message</string>
 | 
					    <string name="could_not_correct_message">Could not correct message</string>
 | 
				
			||||||
    <string name="search_all_conversations">All conversations</string>
 | 
					    <string name="search_all_conversations">All conversations</string>
 | 
				
			||||||
    <string name="search_this_conversation">This conversation</string>
 | 
					    <string name="search_this_conversation">This conversation</string>
 | 
				
			||||||
 | 
					    <string name="your_avatar">Your avatar</string>
 | 
				
			||||||
 | 
					    <string name="avatar_for_x">Avatar for %s</string>
 | 
				
			||||||
    <plurals name="view_users">
 | 
					    <plurals name="view_users">
 | 
				
			||||||
        <item quantity="one">View %1$d Participant</item>
 | 
					        <item quantity="one">View %1$d Participant</item>
 | 
				
			||||||
        <item quantity="other">View %1$d Participants</item>
 | 
					        <item quantity="other">View %1$d Participants</item>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user