Improved scrolling and other fixes and improvements

This commit is contained in:
AlexandrKozlovskiy 2022-07-11 05:46:56 +03:00
parent 4bb8adbf70
commit b693689b11
10 changed files with 655 additions and 703 deletions

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
.gradle/
build/
obj/
TMessagesProj/.cxx
*.iml
local.properties
TMessagesProj/.cxx/

View file

@ -6340,7 +6340,7 @@ public class MessagesController extends BaseController implements NotificationCe
return array.get(uid);
}
public String getAdminRank(long chatId, long uid) {
public String getAdminRank(long chatId, long uid, boolean accessibility) {
if (chatId == uid) {
return "";
}
@ -6352,7 +6352,11 @@ public class MessagesController extends BaseController implements NotificationCe
if (participant == null) {
return null;
}
return participant.rank != null ? participant.rank : "";
return participant.rank != null ? participant.rank : accessibility? participant instanceof TLRPC.TL_channelParticipantCreator? LocaleController.getString("ChannelCreator",R.string.ChannelCreator): participant instanceof TLRPC.TL_channelParticipantAdmin? LocaleController.getString("ChannelAdmin",R.string.ChannelAdmin): LocaleController.getString("ChatAdmin",R.string.ChatAdmin):"";
}
public String getAdminRank(long chatId, long uid) {
return getAdminRank(chatId, uid, false);
}
public boolean isChannelAdminsLoaded(long chatId) {

View file

@ -80,10 +80,10 @@ public class AvatarPreviewer {
private Layout layout;
private boolean visible;
public void show(ViewGroup parentContainer, Theme.ResourcesProvider resourcesProvider, Data data, Callback callback) {
Objects.requireNonNull(parentContainer);
Objects.requireNonNull(data);
Objects.requireNonNull(callback);
public void show(ViewGroup parentContainer, Data data, boolean accessibility,Callback callback) {
Preconditions.checkNotNull(parentContainer);
Preconditions.checkNotNull(data);
Preconditions.checkNotNull(callback);
final Context context = parentContainer.getContext();
@ -125,12 +125,18 @@ public class AvatarPreviewer {
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
}
if(!accessibility) {
windowManager.addView(layout, layoutParams);
parentContainer.requestDisallowInterceptTouchEvent(true);
visible = true;
}
else layout.showBottomSheet();
}
}
public void show(ViewGroup parentContainer, Data data, Callback callback) {
show(parentContainer,data,false,callback);
}
public void close() {
if (visible) {
this.layout.setShowing(false);

View file

@ -77,6 +77,7 @@ import android.view.ViewGroup;
import android.view.ViewStructure;
import android.view.Window;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeProvider;
import android.view.animation.Interpolator;
@ -88,7 +89,6 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils;
import androidx.core.math.MathUtils;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AccountInstance;
@ -471,13 +471,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
default void didPressUserStatus(ChatMessageCell cell, TLRPC.User user, TLRPC.Document document) {
}
default void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
}
default boolean didLongPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
default boolean didLongPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY,boolean accessibility) {
return false;
}
default boolean didLongPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
return didLongPressUserAvatar(cell,user,touchX,touchY,false);
}
default void didPressHiddenForward(ChatMessageCell cell) {
}
@ -494,10 +495,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
default void didPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
}
default boolean didLongPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
default boolean didLongPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY,boolean accessibility) {
return false;
}
default boolean didLongPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
return didLongPressChannelAvatar(cell,chat,postId,touchX,touchY,false);
}
default void didPressCancelSendButton(ChatMessageCell cell) {
}
@ -593,10 +598,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
default void needShowPremiumBulletin(int type) {
}
default String getAdminRank(long uid) {
return null;
}
default boolean needPlayMessage(ChatMessageCell cell, MessageObject messageObject, boolean muted) {
return false;
}
@ -604,6 +605,13 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
default boolean drawingVideoPlayerContainer() {
return false;
}
default String getAdminRank(long uid,boolean accessibility) {
return null;
}
default String getAdminRank(long uid) {
return getAdminRank(uid,false);
}
default boolean canPerformActions() {
return false;
@ -1836,7 +1844,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
delegate.didPressViaBot(this, currentViaBotUser != null ? currentViaBotUser.username : currentMessageObject.messageOwner.via_bot_name);
}
} else if (currentUser != null) {
delegate.didPressUserAvatar(this, currentUser, event.getX(), event.getY());
delegate.didLongPressUserAvatar(this, currentUser, event.getX(), event.getY());
} else if (currentChat != null) {
int id;
TLRPC.Chat chat = currentChat;
@ -4069,8 +4077,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else if (
drawSideButton != 0 &&
x >= sideStartX - dp(24) && x <= sideStartX + dp(40) &&
y >= sideStartY - dp(24) && y <= sideStartY + dp(38 + (drawSideButton == 3 && commentLayout != null ? 18 : 0) + (drawSideButton2 == SIDE_BUTTON_SPONSORED_MORE ? 38 : 0))
) {
y >= sideStartY - dp(24) && y <= sideStartY + dp(38 + (drawSideButton == 3 && commentLayout != null ? 18 : 0) + (drawSideButton2 == SIDE_BUTTON_SPONSORED_MORE ? 38 : 0))) {
if (currentMessageObject.isSent()) {
if (currentMessageObject.isSponsored()) {
if (y > sideStartY + dp(32) && drawSideButton2 == SIDE_BUTTON_SPONSORED_MORE) {
@ -9403,14 +9410,6 @@ CONTACT_VIEW = -1;
}
if (drawPinnedBottom && drawPinnedTop) {
totalHeight -= AndroidUtilities.dp(2);
} else if (drawPinnedBottom) {
totalHeight -= AndroidUtilities.dp(1);
} else if (drawPinnedTop && pinnedBottom && currentPosition != null && currentPosition.siblingHeights == null) {
totalHeight -= AndroidUtilities.dp(1);
}
if (!mediaBackground) {
if (messageObject.type == MessageObject.TYPE_TEXT) {
totalHeight -= AndroidUtilities.dp(2);
}
if (drawPinnedBottom) {
totalHeight -= AndroidUtilities.dp(1);
@ -15311,6 +15310,7 @@ CONTACT_VIEW = -1;
}
}
}
if(currentFocusedVirtualView==-1) sendAccessibilityEventForVirtualView(-1,AccessibilityEvent.TYPE_ANNOUNCEMENT,(progress*100)+"%");
}
@Override
@ -15331,6 +15331,7 @@ CONTACT_VIEW = -1;
lastLoadingSizeTotal = totalSize;
}
createLoadingProgressLayout(uploadedSize, totalSize);
if(currentFocusedVirtualView==-1) sendAccessibilityEventForVirtualView(-1,AccessibilityEvent.TYPE_ANNOUNCEMENT,(progress*100)+"%");
}
private void createLoadingProgressLayout(TLRPC.Document document) {
@ -19274,7 +19275,6 @@ CONTACT_VIEW = -1;
(int) buttonY,
endX - AndroidUtilities.dp(14),
layoutHeight - AndroidUtilities.dp(h) + 1
);
if (selectorDrawable[1] != null && selectorDrawableMaskType[1] == 2) {
int count = canvas.getSaveCount();
selectorDrawable[1].setBounds(commentButtonRect);
@ -21891,16 +21891,30 @@ CONTACT_VIEW = -1;
public int getLayoutHeight() {
return layoutHeight;
}
private void clear() {
if(!touch) currentFocusedVirtualView=-2; else touch=false;
private void clear(int virtualViewId) {
if(!touch &&virtualViewId==currentFocusedVirtualView) {
//sendAccessibilityEventForVirtualView(currentFocusedVirtualView,AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
currentFocusedVirtualView = -2;
}
else if(touch &&virtualViewId==currentFocusedVirtualView) touch=false;
}
private void clear() {
clear(currentFocusedVirtualView);
}
@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
if (delegate != null && delegate.onAccessibilityAction(action, arguments)) {
return false;
}
if(action==AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) currentFocusedVirtualView=-1;
else if(action==AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) clear();
if(action==AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) {
currentFocusedVirtualView=-1;
sendAccessibilityEventForVirtualView(-1,AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
return true;
}
else if(action==AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) {
clear(-1);
return true;
}
/*else if(action==AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD &&arguments !=null &&arguments.getBoolean(actionInList)) return numberOfNodes<0 ||currentFocusedVirtualView<0?false:getAccessibilityNodeProvider().performAction(currentFocusedVirtualView,action,arguments);
else if(action==AccessibilityNodeInfo.ACTION_SCROLL_FORWARD &&arguments !=null &&arguments.getBoolean(actionInList)) {
if(numberOfNodes<0) return false;
@ -21945,6 +21959,9 @@ private void clear() {
}
}
}
else if(action==R.id.acc_action_user_or_channel &&delegate!=null) {
if(currentUser!=null)delegate.didLongPressUserAvatar(ChatMessageCell.this,currentUser,lastTouchX,lastTouchY,true); else delegate.didLongPressChannelAvatar(ChatMessageCell.this,currentChat,0,lastTouchX,lastTouchY,true);
}
if (isSeekbarCell()) {
if (seekBarAccessibilityDelegate.performAccessibilityActionInternal(action, arguments)) {
return true;
@ -21962,6 +21979,22 @@ private void clear() {
}
}
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
}
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
event.setPackageName(getContext().getPackageName());
event.setSource(ChatMessageCell.this, currentFocusedVirtualView);
event.setEnabled(true);
event.setScrollX(getScrollX());
event.setScrollY(getScrollY());
if(seekBarAccessibilityDelegate!=null &&currentFocusedVirtualView==-1) seekBarAccessibilityDelegate.onInitializeAccessibilityEvent(ChatMessageCell.this,event);
CharSequence accText =getIterableTextForAccessibility();
if(event.getText().size() ==0) event.setContentDescription(accText);
}
@Override
public boolean onHoverEvent(MotionEvent event) {
int x = (int) event.getX();
@ -21978,52 +22011,73 @@ private void clear() {
}
return true;
}
}
if(currentFocusedVirtualView!=-1) {
}
if(currentFocusedVirtualView!=-1) {
currentFocusedVirtualView=-1;
touch=true;
}
} else if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT) {
currentFocusedVirtualView=-2;
sendAccessibilityEventForVirtualView(-1, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
}
return true;
} else if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT) {
currentFocusedVirtualView=-2;
touch = false;
}
touch =false;
currentFocusedVirtualView=-2;
return super.onHoverEvent(event);
}
private boolean isSeekbarCell() {
private boolean isSeekbarCell() {
return currentMessageObject!=null &&(currentMessageObject.isVoice() || currentMessageObject.isRoundVideo() || currentMessageObject.isMusic() && MediaController.getInstance().isPlayingMessage(currentMessageObject));
}
//Getting coordinates for accessibility scrolling.
public int[] getCoords(Boolean back) {
}
//Getting coordinates for accessibility scrolling.
public int[] getCoords(Boolean back,boolean newPos) {
if(accessibilityVirtualViewBounds.size() ==0) return null;
int pos=back?currentFocusedVirtualView-1:currentFocusedVirtualView+1;
if(back &&currentFocusedVirtualView<-1) pos=accessibilityVirtualViewBounds.size()-1;
//if(pos<0 &&back) pos=accessibilityVirtualViewBounds.size()-1;
//else if(pos>=accessibilityVirtualViewBounds.size() &&!back) pos=-1;
if(back &&(currentFocusedVirtualView==-1 ||newPos)) pos=accessibilityVirtualViewBounds.size()-1;
if(pos<0 ||pos>=accessibilityVirtualViewBounds.size()) return null;
int[] loc=new int[2];
getLocationOnScreen(loc);
//whether two lines below ok,to compute coordinates for scrolling?
/*loc[0]-=getPaddingRight()-getPaddingLeft();
loc[1]-=getPaddingBottom()-getPaddingTop();*/
return new int[] {accessibilityVirtualViewBounds.get(pos).left+loc[0],accessibilityVirtualViewBounds.get(pos).top+loc[1]};
}
//To support diferents granularities for talkback. See sources of View class in android sdk sources.
if(accessibilityVirtualViewBounds.get(pos)==null) return null;
return new int[] {accessibilityVirtualViewBounds.get(pos).left+getLeft(),accessibilityVirtualViewBounds.get(pos).top+getTop()};
}
public int[] getCoords(Boolean back) {
return getCoords(back,false);
}
//To support diferents granularities for talkback. See sources of View class in android sdk sources.
public CharSequence getIterableTextForAccessibility() {
final boolean unread = currentMessageObject != null && currentMessageObject.isOut() && !currentMessageObject.scheduled && currentMessageObject.isUnread();
final boolean contentUnread = currentMessageObject != null && currentMessageObject.isContentUnread();
final long fileSize = currentMessageObject != null ? currentMessageObject.loadedFileSize : 0;
if (accessibilityText == null || accessibilityTextUnread != unread || accessibilityTextContentUnread != contentUnread || accessibilityTextFileSize != fileSize) {
SpannableStringBuilder sb = new SpannableStringBuilder();
if (isChat && currentUser != null && !currentMessageObject.isOut()) {
if (isChat && !currentMessageObject.isOut()) {
if(currentUser !=null) {
sb.append(UserObject.getUserName(currentUser));
sb.setSpan(new ProfileSpan(currentUser), 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
else if(currentChat !=null &&currentMessageObject.isFromGroup()) {
sb.append(currentChat.title);
sb.setSpan(new ProfileSpan(currentChat), 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
sb.append('\n');
}
//add information,if something write from channel,but not from user name (it can do,for example,channel creators).
else if(currentUser ==null && currentMessageObject.customName !=null &&currentMessageObject.customName.length()>0) sb.append(currentMessageObject.customName+"\n");
if (drawForwardedName) {
for (int a = 0; a < 2; a++) {
if (forwardedNameLayout[a] != null) {
if (forwardedNameLayout[a] != null &&forwardedNameLayout[a].getText() !=null) {
sb.append(forwardedNameLayout[a].getText());
sb.append(a == 0 ? " " : "\n");
}
}
}
if (documentAttach != null && documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) {
String fileName = FileLoader.getAttachFileName(documentAttach);
if (fileName.indexOf('.') != -1) {
sb.append(LocaleController.formatString(R.string.AccDescrDocumentType, fileName.substring(fileName.lastIndexOf('.') + 1).toUpperCase(Locale.ROOT)));
}
}
if (!TextUtils.isEmpty(currentMessageObject.messageText)) {
sb.append(currentMessageObject.messageText);
}
@ -22040,10 +22094,10 @@ public int[] getCoords(Boolean back) {
sb.append("\n");
sb.append(LocaleController.formatString("AccDescrMusicInfo", R.string.AccDescrMusicInfo, currentMessageObject.getMusicAuthor(), currentMessageObject.getMusicTitle()));
sb.append(", ");
sb.append(LocaleController.formatDuration(currentMessageObject.getDuration()));
sb.append(LocaleController.formatDuration((int) currentMessageObject.getDuration()));
} else if (currentMessageObject.isVoice() || isRoundVideo) {
sb.append(", ");
sb.append(LocaleController.formatDuration(currentMessageObject.getDuration()));
sb.append(LocaleController.formatDuration((int) currentMessageObject.getDuration()));
sb.append(", ");
if (currentMessageObject.isContentUnread()) {
sb.append(LocaleController.getString("AccDescrMsgNotPlayed", R.string.AccDescrMsgNotPlayed));
@ -22073,25 +22127,26 @@ public int[] getCoords(Boolean back) {
}
sb.append(title);
}
if (currentMessageObject.isVoiceTranscriptionOpen()) {
sb.append("\n");
sb.append(currentMessageObject.getVoiceTranscription());
}
//even if we switch on voice transcription,we should announce caption too.
if (currentMessageObject.messageOwner.media != null && !TextUtils.isEmpty(currentMessageObject.caption)) {
sb.append("\n");
sb.append(currentMessageObject.caption);
}
if (documentAttach != null) {
if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) {
sb.append(", ");
sb.append(LocaleController.formatDuration(currentMessageObject.getDuration()));
sb.append(LocaleController.formatDuration((int) currentMessageObject.getDuration()));
}
if (buttonState == 0 || documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) {
sb.append(", ");
sb.append(AndroidUtilities.formatFileSize(documentAttach.size));
}
}
//even if we switch on voice transcription,we should announce caption too.
if (currentMessageObject.messageOwner.media != null && !TextUtils.isEmpty(currentMessageObject.caption)) {
sb.append("\n");
sb.append(currentMessageObject.caption);
}
if (currentMessageObject.isVoiceTranscriptionOpen()) {
sb.append("\n");
sb.append(currentMessageObject.getVoiceTranscription());
}
if (currentMessageObject.isOut()) {
if (currentMessageObject.isSent()) {
sb.append("\n");
@ -22113,23 +22168,28 @@ public int[] getCoords(Boolean back) {
sb.append("\n");
sb.append(LocaleController.getString("AccDescrMsgSendingError", R.string.AccDescrMsgSendingError));
}
} else {
} else if(currentTimeString!=null) {
sb.append("\n");
sb.append(LocaleController.formatString("AccDescrReceivedDate", R.string.AccDescrReceivedDate, LocaleController.getString("TodayAt", R.string.TodayAt) + " " + currentTimeString));
}
if(currentMessageObject.isSponsored()) {
sb.append("\n");
sb.append(LocaleController.getString("Sponsored"));
}
if (getRepliesCount() > 0 && !hasCommentLayout()) {
sb.append("\n");
sb.append(LocaleController.formatPluralString("AccDescrNumberOfReplies", getRepliesCount()));
}
if (currentMessageObject.messageOwner.reactions != null && currentMessageObject.messageOwner.reactions.results != null) {
if (currentMessageObject.messageOwner.reactions.results.size() == 1) {
TLRPC.TL_reactionCount reaction = currentMessageObject.messageOwner.reactions.results.get(0);
TLRPC.ReactionCount reaction = currentMessageObject.messageOwner.reactions.results.get(0);
String emoticon = reaction.reaction instanceof TLRPC.TL_reactionEmoji ? ((TLRPC.TL_reactionEmoji) reaction.reaction).emoticon : "";
if (reaction.count == 1) {
sb.append("\n");
boolean isMe = false;
String userName = "";
if (currentMessageObject.messageOwner.reactions.recent_reactions != null && currentMessageObject.messageOwner.reactions.recent_reactions.size() == 1) {
TLRPC.TL_messagePeerReaction recentReaction = currentMessageObject.messageOwner.reactions.recent_reactions.get(0);
TLRPC.MessagePeerReaction recentReaction = currentMessageObject.messageOwner.reactions.recent_reactions.get(0);
if (recentReaction != null) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(MessageObject.getPeerId(recentReaction.peer_id));
isMe = UserObject.isUserSelf(user);
@ -22139,21 +22199,22 @@ public int[] getCoords(Boolean back) {
}
}
if (isMe) {
sb.append(LocaleController.formatString("AccDescrYouReactedWith", R.string.AccDescrYouReactedWith, reaction.reaction));
sb.append(LocaleController.formatString("AccDescrYouReactedWith", R.string.AccDescrYouReactedWith, emoticon));
} else {
sb.append(LocaleController.formatString("AccDescrReactedWith", R.string.AccDescrReactedWith, userName, reaction.reaction));
sb.append(LocaleController.formatString("AccDescrReactedWith", R.string.AccDescrReactedWith, userName, emoticon));
}
} else if (reaction.count > 1) {
sb.append("\n");
sb.append(LocaleController.formatPluralString("AccDescrNumberOfPeopleReactions", reaction.count, reaction.reaction));
sb.append(LocaleController.formatPluralString("AccDescrNumberOfPeopleReactions", reaction.count, emoticon));
}
} else {
sb.append(LocaleController.getString("Reactions", R.string.Reactions)).append((": "));
final int count = currentMessageObject.messageOwner.reactions.results.size();
for (int i = 0; i < count; ++i) {
TLRPC.TL_reactionCount reactionCount = currentMessageObject.messageOwner.reactions.results.get(i);
TLRPC.ReactionCount reactionCount = currentMessageObject.messageOwner.reactions.results.get(i);
String emoticon = reactionCount.reaction instanceof TLRPC.TL_reactionEmoji ? ((TLRPC.TL_reactionEmoji) reactionCount.reaction).emoticon : "";
if (reactionCount != null) {
sb.append(reactionCount.reaction).append(" ").append(reactionCount.count + "");
sb.append(emoticon).append(" ").append(reactionCount.count + "");
if (i + 1 < count) {
sb.append(", ");
}
@ -22188,7 +22249,12 @@ public int[] getCoords(Boolean back) {
sb.setSpan(underlineSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
//if some info has changed,such as message become read or played,etc,update our variable.
if(accessibilityText==null ||!sb.toString().equals(accessibilityText.toString())) accessibilityText = sb;
//if(accessibilityText==null ||!sb.toString().equals(accessibilityText.toString())) accessibilityText = sb;
accessibilityText = sb;
accessibilityTextUnread = unread;
accessibilityTextContentUnread = contentUnread;
accessibilityTextFileSize = fileSize;
}
return accessibilityText;
}
@ -22205,14 +22271,15 @@ public int[] getCoords(Boolean back) {
AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (am.isTouchExplorationEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
event.setPackageName(getContext().getPackageName());
event.setSource(ChatMessageCell.this, viewId);
if (text != null) {
if (text != null &&text.length()>0) {
event.getText().add(text);
}
if (getParent() != null) {
getParent().requestSendAccessibilityEvent(ChatMessageCell.this, event);
if(eventType ==AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED ||eventType==AccessibilityEvent.TYPE_VIEW_FOCUSED &&numberOfNodes>=0) {
//if numberOfNodes >=0 we have at least one subnode.
event.setItemCount(numberOfNodes+1);
event.setCurrentItemIndex(viewId);
}
sendAccessibilityEventUnchecked(event);
}
}
@ -22458,15 +22525,21 @@ public int[] getCoords(Boolean back) {
public SeekBarWaveform getSeekBarWaveform() {
return seekBarWaveform;
}
private boolean canAddOrUseProfileNode() {
return isChat && !currentMessageObject.isOut() &&(currentUser !=null ||currentChat!=null &&currentMessageObject.isFromGroup());
}
private class ProfileSpan extends ClickableSpan {
private TLRPC.User user;
public ProfileSpan(TLRPC.User user) {
this.user = user;
private Object profile;
public ProfileSpan(Object profile) {
this.profile = profile;
}
@Override
public void onClick(@NonNull View view) {
if (delegate != null) {
delegate.didPressUserAvatar(ChatMessageCell.this, user, 0, 0);
if(profile instanceof TLRPC.User) {
if(((TLRPC.User) profile).id !=0) delegate.didPressUserAvatar(ChatMessageCell.this, (TLRPC.User) profile, lastTouchX, lastTouchY); else delegate.didPressHiddenForward(ChatMessageCell.this);
}
else delegate.didPressChannelAvatar(ChatMessageCell.this,(TLRPC.Chat) profile,0,lastTouchX,lastTouchY);
}
}
}
@ -22498,206 +22571,12 @@ public int[] getCoords(Boolean back) {
if (virtualViewId == HOST_VIEW_ID) {
AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(ChatMessageCell.this);
onInitializeAccessibilityNodeInfo(info);
final boolean unread = currentMessageObject != null && currentMessageObject.isOut() && !currentMessageObject.scheduled && currentMessageObject.isUnread();
final boolean contentUnread = currentMessageObject != null && currentMessageObject.isContentUnread();
final long fileSize = currentMessageObject != null ? currentMessageObject.loadedFileSize : 0;
if (accessibilityText == null || accessibilityTextUnread != unread || accessibilityTextContentUnread != contentUnread || accessibilityTextFileSize != fileSize) {
SpannableStringBuilder sb = new SpannableStringBuilder();
if (isChat && currentUser != null && !currentMessageObject.isOut()) {
sb.append(UserObject.getUserName(currentUser));
sb.setSpan(new ProfileSpan(currentUser), 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sb.append('\n');
}
if (drawForwardedName) {
for (int a = 0; a < 2; a++) {
if (forwardedNameLayout[a] != null && forwardedNameLayout[a].getText() != null) {
sb.append(forwardedNameLayout[a].getText());
sb.append(a == 0 ? " " : "\n");
}
}
}
if (documentAttach != null && documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) {
String fileName = FileLoader.getAttachFileName(documentAttach);
if (fileName.indexOf('.') != -1) {
sb.append(LocaleController.formatString(R.string.AccDescrDocumentType, fileName.substring(fileName.lastIndexOf('.') + 1).toUpperCase(Locale.ROOT)));
}
}
if (!TextUtils.isEmpty(currentMessageObject.messageText)) {
sb.append(currentMessageObject.messageText);
}
if (documentAttach != null && (documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO)) {
if (buttonState == 1 && loadingProgressLayout != null) {
sb.append("\n");
final boolean sending = currentMessageObject.isSending();
final String key = sending ? "AccDescrUploadProgress" : "AccDescrDownloadProgress";
final int resId = sending ? R.string.AccDescrUploadProgress : R.string.AccDescrDownloadProgress;
sb.append(LocaleController.formatString(key, resId, AndroidUtilities.formatFileSize(currentMessageObject.loadedFileSize), AndroidUtilities.formatFileSize(lastLoadingSizeTotal)));
}
}
if (currentMessageObject.isMusic()) {
sb.append("\n");
sb.append(LocaleController.formatString("AccDescrMusicInfo", R.string.AccDescrMusicInfo, currentMessageObject.getMusicAuthor(), currentMessageObject.getMusicTitle()));
sb.append(", ");
sb.append(LocaleController.formatDuration((int) currentMessageObject.getDuration()));
} else if (currentMessageObject.isVoice() || isRoundVideo) {
sb.append(", ");
sb.append(LocaleController.formatDuration((int) currentMessageObject.getDuration()));
sb.append(", ");
if (currentMessageObject.isContentUnread()) {
sb.append(getString("AccDescrMsgNotPlayed", R.string.AccDescrMsgNotPlayed));
} else {
sb.append(getString("AccDescrMsgPlayed", R.string.AccDescrMsgPlayed));
}
}
if (lastPoll != null) {
sb.append(", ");
sb.append(lastPoll.question.text);
sb.append(", ");
String title;
if (pollClosed) {
title = getString("FinalResults", R.string.FinalResults);
} else {
if (lastPoll.quiz) {
if (lastPoll.public_voters) {
title = getString("QuizPoll", R.string.QuizPoll);
} else {
title = getString("AnonymousQuizPoll", R.string.AnonymousQuizPoll);
}
} else if (lastPoll.public_voters) {
title = getString("PublicPoll", R.string.PublicPoll);
} else {
title = getString("AnonymousPoll", R.string.AnonymousPoll);
}
}
sb.append(title);
}
if (documentAttach != null) {
if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) {
sb.append(", ");
sb.append(LocaleController.formatDuration((int) currentMessageObject.getDuration()));
}
if (buttonState == 0 || documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT) {
sb.append(", ");
sb.append(AndroidUtilities.formatFileSize(documentAttach.size));
}
}
if (currentMessageObject.isVoiceTranscriptionOpen()) {
sb.append("\n");
sb.append(currentMessageObject.getVoiceTranscription());
} else {
if (MessageObject.getMedia(currentMessageObject.messageOwner) != null && !TextUtils.isEmpty(currentMessageObject.caption)) {
sb.append("\n");
sb.append(currentMessageObject.caption);
}
}
if (currentMessageObject.isOut()) {
if (currentMessageObject.isSent()) {
sb.append("\n");
if (currentMessageObject.scheduled) {
sb.append(LocaleController.formatString("AccDescrScheduledDate", R.string.AccDescrScheduledDate, currentTimeString));
} else {
sb.append(LocaleController.formatString("AccDescrSentDate", R.string.AccDescrSentDate, getString("TodayAt", R.string.TodayAt) + " " + currentTimeString));
sb.append(", ");
sb.append(currentMessageObject.isUnread() ? getString("AccDescrMsgUnread", R.string.AccDescrMsgUnread) : getString("AccDescrMsgRead", R.string.AccDescrMsgRead));
}
} else if (currentMessageObject.isSending()) {
sb.append("\n");
sb.append(getString("AccDescrMsgSending", R.string.AccDescrMsgSending));
final float sendingProgress = radialProgress.getProgress();
if (sendingProgress > 0f) {
sb.append(Integer.toString(Math.round(sendingProgress * 100))).append("%");
}
} else if (currentMessageObject.isSendError()) {
sb.append("\n");
sb.append(getString("AccDescrMsgSendingError", R.string.AccDescrMsgSendingError));
}
} else {
sb.append("\n");
sb.append(LocaleController.formatString("AccDescrReceivedDate", R.string.AccDescrReceivedDate, getString("TodayAt", R.string.TodayAt) + " " + currentTimeString));
}
if (getRepliesCount() > 0 && !hasCommentLayout()) {
sb.append("\n");
sb.append(LocaleController.formatPluralString("AccDescrNumberOfReplies", getRepliesCount()));
}
if (currentMessageObject.messageOwner.reactions != null && currentMessageObject.messageOwner.reactions.results != null) {
if (currentMessageObject.messageOwner.reactions.results.size() == 1) {
TLRPC.ReactionCount reaction = currentMessageObject.messageOwner.reactions.results.get(0);
String emoticon = reaction.reaction instanceof TLRPC.TL_reactionEmoji ? ((TLRPC.TL_reactionEmoji) reaction.reaction).emoticon : "";
if (reaction.count == 1) {
sb.append("\n");
boolean isMe = false;
String userName = "";
if (currentMessageObject.messageOwner.reactions.recent_reactions != null && currentMessageObject.messageOwner.reactions.recent_reactions.size() == 1) {
TLRPC.MessagePeerReaction recentReaction = currentMessageObject.messageOwner.reactions.recent_reactions.get(0);
if (recentReaction != null) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(MessageObject.getPeerId(recentReaction.peer_id));
isMe = UserObject.isUserSelf(user);
if (user != null) {
userName = UserObject.getFirstName(user);
}
}
}
if (isMe) {
sb.append(LocaleController.formatString("AccDescrYouReactedWith", R.string.AccDescrYouReactedWith, emoticon));
} else {
sb.append(LocaleController.formatString("AccDescrReactedWith", R.string.AccDescrReactedWith, userName, emoticon));
}
} else if (reaction.count > 1) {
sb.append("\n");
sb.append(LocaleController.formatPluralString("AccDescrNumberOfPeopleReactions", reaction.count, emoticon));
}
} else {
sb.append(getString("Reactions", R.string.Reactions)).append((": "));
final int count = currentMessageObject.messageOwner.reactions.results.size();
for (int i = 0; i < count; ++i) {
TLRPC.ReactionCount reactionCount = currentMessageObject.messageOwner.reactions.results.get(i);
String emoticon = reactionCount.reaction instanceof TLRPC.TL_reactionEmoji ? ((TLRPC.TL_reactionEmoji) reactionCount.reaction).emoticon : "";
if (reactionCount != null) {
sb.append(emoticon).append(" ").append(reactionCount.count + "");
if (i + 1 < count) {
sb.append(", ");
}
}
}
sb.append("\n");
}
}
if ((currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) {
sb.append("\n");
sb.append(LocaleController.formatPluralString("AccDescrNumberOfViews", currentMessageObject.messageOwner.views));
}
sb.append("\n");
CharacterStyle[] links = sb.getSpans(0, sb.length(), ClickableSpan.class);
for (CharacterStyle link : links) {
int start = sb.getSpanStart(link);
int end = sb.getSpanEnd(link);
sb.removeSpan(link);
ClickableSpan underlineSpan = new ClickableSpan() {
@Override
public void onClick(View view) {
if (link instanceof ProfileSpan) {
((ProfileSpan) link).onClick(view);
} else if (delegate != null) {
delegate.didPressUrl(ChatMessageCell.this, link, false);
}
}
};
sb.setSpan(underlineSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
accessibilityText = sb;
accessibilityTextUnread = unread;
accessibilityTextContentUnread = contentUnread;
accessibilityTextFileSize = fileSize;
}
if (accessibilityText == null) getIterableTextForAccessibility();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
info.setContentDescription(getIterableTextForAccessibility().toString());
info.setContentDescription(accessibilityText.toString());
} else {
info.setText(getIterableTextForAccessibility());
info.setText(accessibilityText);
}
info.setEnabled(true);
if (Build.VERSION.SDK_INT >= 19) {
AccessibilityNodeInfo.CollectionItemInfo itemInfo = info.getCollectionItemInfo();
@ -22706,35 +22585,35 @@ public int[] getCoords(Boolean back) {
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.acc_action_msg_options, getString("AccActionMessageOptions", R.string.AccActionMessageOptions)));
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.acc_action_msg_options, LocaleController.getString("AccActionMessageOptions", R.string.AccActionMessageOptions)));
int icon = getIconForCurrentState();
CharSequence actionLabel = null;
switch (icon) {
case MediaActionDrawable.ICON_PLAY:
actionLabel = getString("AccActionPlay", R.string.AccActionPlay);
actionLabel = LocaleController.getString("AccActionPlay", R.string.AccActionPlay);
break;
case MediaActionDrawable.ICON_PAUSE:
actionLabel = getString("AccActionPause", R.string.AccActionPause);
actionLabel = LocaleController.getString("AccActionPause", R.string.AccActionPause);
break;
case MediaActionDrawable.ICON_FILE:
actionLabel = getString("AccActionOpenFile", R.string.AccActionOpenFile);
actionLabel = LocaleController.getString("AccActionOpenFile", R.string.AccActionOpenFile);
break;
case MediaActionDrawable.ICON_DOWNLOAD:
actionLabel = getString("AccActionDownload", R.string.AccActionDownload);
actionLabel = LocaleController.getString("AccActionDownload", R.string.AccActionDownload);
break;
case MediaActionDrawable.ICON_CANCEL:
actionLabel = getString("AccActionCancelDownload", R.string.AccActionCancelDownload);
actionLabel = LocaleController.getString("AccActionCancelDownload", R.string.AccActionCancelDownload);
break;
default:
if (currentMessageObject.type == MessageObject.TYPE_PHONE_CALL) {
actionLabel = getString("CallAgain", R.string.CallAgain);
if ((currentMessageObject.type == MessageObject.TYPE_PHONE_CALL) {
actionLabel = LocaleController.getString("CallAgain", R.string.CallAgain);
}
}
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(AccessibilityNodeInfo.ACTION_CLICK, actionLabel));
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(AccessibilityNodeInfo.ACTION_LONG_CLICK, getString("AccActionEnterSelectionMode", R.string.AccActionEnterSelectionMode)));
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(AccessibilityNodeInfo.ACTION_LONG_CLICK, LocaleController.getString("AccActionEnterSelectionMode", R.string.AccActionEnterSelectionMode)));
int smallIcon = getMiniIconForCurrentState();
if (smallIcon == MediaActionDrawable.ICON_DOWNLOAD) {
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.acc_action_small_button, getString("AccActionDownload", R.string.AccActionDownload)));
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.acc_action_small_button, LocaleController.getString("AccActionDownload", R.string.AccActionDownload)));
}
} else {
info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
@ -22744,7 +22623,7 @@ public int[] getCoords(Boolean back) {
seekBarAccessibilityDelegate.onInitializeAccessibilityNodeInfoInternal(info);
}
if (useTranscribeButton && transcribeButton != null) {
if(!isInitializedNodes) {
if (!isInitializedNodes) {
TRANSCRIBE = ++numberOfNodes;
}
info.addChild(ChatMessageCell.this, TRANSCRIBE);
@ -22752,8 +22631,8 @@ public int[] getCoords(Boolean back) {
int i;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
if (isChat && currentUser != null && !currentMessageObject.isOut()) {
if(!isInitializedNodes) {
if (canAddOrUseProfileNode()) {
if (!isInitializedNodes) {
PROFILE = ++numberOfNodes;
}
info.addChild(ChatMessageCell.this, PROFILE);
@ -22761,7 +22640,7 @@ public int[] getCoords(Boolean back) {
if (currentMessageObject.messageText instanceof Spannable) {
Spannable buffer = (Spannable) currentMessageObject.messageText;
CharacterStyle[] links = buffer.getSpans(0, buffer.length(), ClickableSpan.class);
if(!isInitializedNodes &&links.length>0) {
if (!isInitializedNodes && links.length > 0) {
LINK_IDS_START = ++numberOfNodes;
numberOfNodes += links.length;
}
@ -22770,11 +22649,10 @@ public int[] getCoords(Boolean back) {
info.addChild(ChatMessageCell.this, LINK_IDS_START + i);
i++;
}
}
if (currentMessageObject.caption instanceof Spannable && captionLayout != null) {
Spannable buffer = (Spannable) currentMessageObject.caption;
CharacterStyle[] links = buffer.getSpans(0, buffer.length(), ClickableSpan.class);
if(!isInitializedNodes &&links.length>0) {
if (!isInitializedNodes && links.length > 0) {
LINK_CAPTION_IDS_START = ++numberOfNodes;
numberOfNodes += links.length;
}
@ -22785,7 +22663,7 @@ public int[] getCoords(Boolean back) {
}
}
}
if(!isInitializedNodes &&botButtons.size()>0) {
if (!isInitializedNodes && botButtons.size() > 0) {
BOT_BUTTONS_START = ++numberOfNodes;
numberOfNodes += botButtons.size();
}
@ -22795,12 +22673,12 @@ public int[] getCoords(Boolean back) {
i++;
}
if (hintButtonVisible && pollHintX != -1 && currentMessageObject.isPoll()) {
if(!isInitializedNodes) {
if (!isInitializedNodes) {
POLL_HINT = ++numberOfNodes;
}
info.addChild(ChatMessageCell.this, POLL_HINT);
}
if(!isInitializedNodes &&pollButtons.size()>0) {
if (!isInitializedNodes && pollButtons.size() > 0) {
POLL_BUTTONS_START = ++numberOfNodes;
numberOfNodes += pollButtons.size();
}
@ -22810,7 +22688,7 @@ public int[] getCoords(Boolean back) {
i++;
}
if (drawInstantView && !instantButtonRect.isEmpty()) {
if(!isInitializedNodes) {
if (!isInitializedNodes) {
INSTANT_VIEW = ++numberOfNodes;
}
info.addChild(ChatMessageCell.this, INSTANT_VIEW);
@ -22870,11 +22748,20 @@ public int[] getCoords(Boolean back) {
}
info.addChild(ChatMessageCell.this, FORWARD);
}
if (commentLayout != null) {
if (!isInitializedNodes) {
COMMENT = ++numberOfNodes;
}
info.addChild(ChatMessageCell.this, COMMENT);
}
if (drawSelectionBackground || getBackground() != null) {
info.setSelected(true);
}
isInitializedNodes=true;
isInitializedNodes = true;
if (canAddOrUseProfileNode() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && PROFILE < 0) {
String longPressName = currentUser != null ? UserObject.getUserName(currentUser) + (getDelegate() != null && getDelegate().getAdminRank(currentUser.id, true) != null ? " (" + getDelegate().getAdminRank(currentUser.id, true) + ")" : "") : currentChat.title;
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.acc_action_user_or_channel, longPressName));
}
info.setAccessibilityFocused(true);
return info;
} else {
@ -22883,16 +22770,16 @@ public int[] getCoords(Boolean back) {
info.setParent(ChatMessageCell.this);
info.setPackageName(getContext().getPackageName());
if (virtualViewId == PROFILE) {
if (currentUser == null) {
if (!canAddOrUseProfileNode()) {
return null;
}
String content = UserObject.getUserName(currentUser);
String content = currentUser != null ? UserObject.getUserName(currentUser) + (getDelegate() != null && getDelegate().getAdminRank(currentUser.id, true) != null ? " (" + getDelegate().getAdminRank(currentUser.id, true) + ")" : "") : currentChat.title;
info.setText(content);
rect.set((int) nameX, (int) nameY, (int) (nameX + nameWidth), (int) (nameY + (nameLayout != null ? nameLayout.getHeight() : 10)));
info.setClassName("android.widget.TextView");
info.setLongClickable(true);
info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK);
} else if (virtualViewId >= LINK_CAPTION_IDS_START &&LINK_CAPTION_IDS_START>=0) {
} else if (virtualViewId >= LINK_CAPTION_IDS_START && LINK_CAPTION_IDS_START >= 0) {
if (!(currentMessageObject.caption instanceof Spannable) || captionLayout == null) {
return null;
}
@ -22917,9 +22804,8 @@ public int[] getCoords(Boolean back) {
}
info.setClassName("android.widget.TextView");
info.setLongClickable(true);
info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK);
} else if (virtualViewId >= LINK_IDS_START &&LINK_IDS_START>=0) {
} else if (virtualViewId >= LINK_IDS_START && LINK_IDS_START >= 0) {
if (!(currentMessageObject.messageText instanceof Spannable)) {
return null;
}
@ -22942,11 +22828,10 @@ public int[] getCoords(Boolean back) {
break;
}
}
info.setClassName("android.widget.TextView");
info.setLongClickable(true);
info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK);
} else if (virtualViewId >= BOT_BUTTONS_START &&BOT_BUTTONS_START>=0) {
} else if (virtualViewId >= BOT_BUTTONS_START && BOT_BUTTONS_START >= 0) {
int buttonIndex = virtualViewId - BOT_BUTTONS_START;
if (buttonIndex >= botButtons.size()) {
return null;
@ -22964,18 +22849,20 @@ public int[] getCoords(Boolean back) {
addX = backgroundDrawableLeft + AndroidUtilities.dp(mediaBackground ? 1 : 7);
}
rect.offset(addX, layoutHeight);
} else if (virtualViewId >= POLL_BUTTONS_START &&POLL_BUTTONS_START>=0) {
} else if (virtualViewId >= POLL_BUTTONS_START && POLL_BUTTONS_START >= 0) {
int buttonIndex = virtualViewId - POLL_BUTTONS_START;
if (buttonIndex >= pollButtons.size()) {
return null;
}
PollButton button = pollButtons.get(buttonIndex);
StringBuilder sb = new StringBuilder(button.title.getText());
if (!pollVoted) {
if (pollVoted) {
info.setClassName("android.widget.Button");
} else {
info.setSelected(button.chosen);
sb.append(", ").append(button.percent).append("%");
} else {
//Even for closed poll we should add percentage too.
if (pollClosed) sb.append(", ").append(button.percent).append("%");
info.setSelected(button.chosen);
if (lastPoll != null && lastPoll.quiz && (button.chosen || button.correct)) {
sb.append(", ").append(button.correct ? getString("AccDescrQuizCorrectAnswer", R.string.AccDescrQuizCorrectAnswer) : getString("AccDescrQuizIncorrectAnswer", R.string.AccDescrQuizIncorrectAnswer));
}
@ -22993,11 +22880,11 @@ public int[] getCoords(Boolean back) {
if (instantViewLayout != null) {
info.setText(instantViewLayout.getText());
}
info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
instantButtonRect.round(rect);
}
else if (virtualViewId == CONTACT) {
else if (virtualViewId == CONTACT) {
info.setClassName("android.widget.Button");
info.setEnabled(true);
if (titleLayout != null) {
info.setText(titleLayout.getText());
}
@ -23021,7 +22908,6 @@ public int[] getCoords(Boolean back) {
InstantViewButton instantViewButton = contactButtons.get(i);
if (instantViewButton.type == requiredType) {
info.setClassName("android.widget.Button");
info.setEnabled(true);
if (instantViewButton.layout != null) {
info.setText(instantViewButton.layout.getText());
}
@ -23029,14 +22915,16 @@ public int[] getCoords(Boolean back) {
break;
}
}
} else if (virtualViewId == SHARE) {
}
else if (virtualViewId == SHARE) {
info.setClassName("android.widget.ImageButton");
if (isOpenChatByShare(currentMessageObject)) {
info.setContentDescription(getString("AccDescrOpenChat", R.string.AccDescrOpenChat));
} else {
info.setContentDescription(LocaleController.getString("ShareFile", R.string.ShareFile));
} rect.set((int) sideStartX, (int) sideStartY, (int) sideStartX + AndroidUtilities.dp(40), (int) sideStartY + AndroidUtilities.dp(32));
} else if (virtualViewId == REPLY ) {
}
rect.set((int) sideStartX, (int) sideStartY, (int) sideStartX + AndroidUtilities.dp(40), (int) sideStartY + AndroidUtilities.dp(32));
} else if (virtualViewId == REPLY) {
StringBuilder sb = new StringBuilder();
sb.append(getString("Reply", R.string.Reply));
sb.append(", ");
@ -23048,16 +22936,16 @@ public int[] getCoords(Boolean back) {
sb.append(replyTextLayout.getText());
}
info.setContentDescription(sb.toString());
rect.set(replyStartX, replyStartY, replyStartX + Math.max(replyNameWidth, replyTextWidth), replyStartY + (int) replyHeight);
rect.set(replyStartX, replyStartY, replyStartX + Math.max(replyNameWidth, replyTextWidth), replyStartY + AndroidUtilities.dp(35));
} else if (virtualViewId == FORWARD) {
StringBuilder sb = new StringBuilder();
if (forwardedNameLayout[0] != null && forwardedNameLayout[1] != null) {
if (drawForwardedName) {
for (int a = 0; a < 2; a++) {
sb.append(forwardedNameLayout[a].getText());
if (forwardedNameLayout[a] != null && forwardedNameLayout[a].getText() != null) sb.append(forwardedNameLayout[a].getText());
sb.append(a == 0 ? " " : "\n");
}
}
info.setContentDescription(sb.toString());
sb.append("\n");
int x = (int) Math.min(forwardNameX - forwardNameOffsetX[0], forwardNameX - forwardNameOffsetX[1]);
rect.set(x, forwardNameY, x + forwardedNameWidth, forwardNameY + forwardHeight);
} else if (virtualViewId == COMMENT) {
@ -23080,9 +22968,7 @@ public int[] getCoords(Boolean back) {
} else if (virtualViewId == TRANSCRIBE) {
info.setClassName("android.widget.Button");
info.setText(currentMessageObject.isVoiceTranscriptionOpen() ? LocaleController.getString("AccActionCloseTranscription", R.string.AccActionCloseTranscription) : LocaleController.getString("AccActionOpenTranscription", R.string.AccActionOpenTranscription));
if (transcribeButton != null) {
rect.set((int) transcribeX, (int) transcribeY, (int) (transcribeX + transcribeButton.width()), (int) (transcribeY + transcribeButton.height()));
}
rect.set((int) transcribeX, (int) transcribeY, (int) (transcribeX + AndroidUtilities.dp(30)), (int) (transcribeY + AndroidUtilities.dp(30)));
}
info.setEnabled(true);
info.setClickable(true);
@ -23106,14 +22992,20 @@ public int[] getCoords(Boolean back) {
if (virtualViewId == HOST_VIEW_ID &&(arguments ==null ||!arguments.getBoolean(actionInList))) {
performAccessibilityAction(action, arguments);
} else {
if(action== AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) clear();
if(action == AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) {
if(action== AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) {
clear(virtualViewId);
return true;
}
if(action == AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) {
currentFocusedVirtualView=virtualViewId;
sendAccessibilityEventForVirtualView(virtualViewId, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
} else if (action == AccessibilityNodeInfo.ACTION_CLICK) {
if (virtualViewId == PROFILE) {
if (delegate != null) {
delegate.didPressUserAvatar(ChatMessageCell.this, currentUser, 0, 0);
if (currentUser != null) {
if(currentUser.id!=0) delegate.didPressUserAvatar(ChatMessageCell.this, currentUser, lastTouchX, lastTouchY); else delegate.didPressHiddenForward(ChatMessageCell.this);
}
else delegate.didPressChannelAvatar(ChatMessageCell.this,currentChat,0,lastTouchX,lastTouchY);
}
} else if (virtualViewId >= LINK_CAPTION_IDS_START &&LINK_CAPTION_IDS_START>=0) {
ClickableSpan link = getLinkById(virtualViewId, true);
@ -23206,17 +23098,11 @@ if(action == AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) {
}
} else if (action == AccessibilityNodeInfo.ACTION_LONG_CLICK) {
if(virtualViewId==PROFILE) {
delegate.didLongPressUserAvatar(ChatMessageCell.this,currentUser,0,0);
}
else {
ClickableSpan link = getLinkById(virtualViewId, virtualViewId >= LINK_CAPTION_IDS_START);
if (link != null && delegate != null) {
delegate.didPressUrl(ChatMessageCell.this, link, true);
sendAccessibilityEventForVirtualView(virtualViewId, AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
if(currentUser!=null) delegate.didLongPressUserAvatar(ChatMessageCell.this,currentUser,lastTouchX,lastTouchY,true); else delegate.didLongPressChannelAvatar(ChatMessageCell.this,currentChat,0,lastTouchX,lastTouchY,true);
}
else {
ClickableSpan link = getLinkById(virtualViewId, virtualViewId >= LINK_CAPTION_IDS_START);
if (link != null) {
if (link != null && delegate != null) {
delegate.didPressUrl(ChatMessageCell.this, link, true);
sendAccessibilityEventForVirtualView(virtualViewId, AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
}
@ -23240,7 +23126,6 @@ else {
}
return false;
}*/
}
return true;
}
@ -23782,6 +23667,20 @@ else {
changed = true;
}
accessibilityText = null;
isInitializedNodes=false;
numberOfNodes =-1;
PROFILE = -1;
LINK_IDS_START = -1;
LINK_CAPTION_IDS_START = -1;
BOT_BUTTONS_START = -1;
POLL_BUTTONS_START = -1;
INSTANT_VIEW = -1;
SHARE = -1;
REPLY = -1;
COMMENT = -1;
POLL_HINT = -1;
FORWARD = -1;
TRANSCRIBE = -1;
} else if (!edited && lastDrawingEdited && timeLayout != null) {
animateTimeLayout = lastTimeLayout;
animateEditedWidthDiff = timeWidth - lastTimeWidth;

View file

@ -16935,7 +16935,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
forwardingPreviewView.dismiss(true);
return true;
}
return super.dispatchKeyEvent(event);
else if(event.getKeyCode() ==KeyEvent.KEYCODE_CALL &&currentUser!=null) {
if(event.getAction() ==KeyEvent.ACTION_DOWN) {
event.startTracking();
return true;
}
TLRPC.UserFull userFull = getMessagesController().getUserFull(currentUser.id);
if(userFull !=null &&userFull.phone_calls_available &&VoIPService.getSharedInstance() ==null)VoIPHelper.startCall(currentUser, event.getRepeatCount()==1, userInfo != null && userInfo.video_calls_available, getParentActivity(), getMessagesController().getUserFull(currentUser.id), getAccountInstance());
return true;
}
return super.dispatchKeyEvent(event) ;
}
protected Drawable getNewDrawable() {
@ -36401,9 +36411,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
@Override
public String getAdminRank(long uid) {
public String getAdminRank(long uid,boolean accessibility) {
if (ChatObject.isChannel(currentChat) && currentChat.megagroup) {
String rank = getMessagesController().getAdminRank(currentChat.id, uid);
String rank = getMessagesController().getAdminRank(currentChat.id, uid,accessibility);
if (rank != null) {
return rank;
}

View file

@ -2978,7 +2978,7 @@ public class RecyclerListView extends RecyclerView {
if(getLayoutManager() instanceof GridLayoutManagerFixed) {
GridLayoutManagerFixed g=(GridLayoutManagerFixed) getLayoutManager();
int pos=action==AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD? g.findLastVisibleItemPosition(): g.findFirstVisibleItemPosition();
int inc=action==AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD?1:-1;
int inc=action==AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD?1:-1; //We use reverse scrolling,so for backward scrolling we use 1 instead of -1 and -1 instead of 1.
if(findViewHolderForLayoutPosition(pos ) !=null &&findViewHolderForLayoutPosition(pos).itemView instanceof ChatMessageCell) { //It would be very good,if we will get view by position,which invisible on screen,so now it's known issue,because for invisible position we have null,so we will haven't focus on virtual nodes.
ChatMessageCell c=(ChatMessageCell) findViewHolderForLayoutPosition(pos).itemView;
if(arguments==null) arguments = new Bundle();
@ -2986,7 +2986,7 @@ arguments.putBoolean(ChatMessageCell.actionInList,true);
boolean back =action==AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD;
int[] coords = c.getCoords(back);
if(coords!=null) {
scrollBy(coords[0]-getPaddingRight()-getPaddingLeft(),coords[1]-getPaddingBottom()-getPaddingTop());
scrollBy(coords[0],coords[1]);
return true;
}
//if(c.performAccessibilityAction(action,arguments)) return true;
@ -2994,13 +2994,13 @@ pos+=inc;
if(pos>=0 &&pos<getAdapter().getItemCount()) {
if(findViewHolderForLayoutPosition(pos)!=null &&findViewHolderForLayoutPosition(pos).itemView instanceof ChatMessageCell) {
c = (ChatMessageCell) findViewHolderForLayoutPosition(pos).itemView;
coords=c.getCoords(back);
coords=c.getCoords(back,true);
if (coords != null) {
scrollBy(coords[0]-getPaddingRight()-getPaddingLeft(),coords[1]-getPaddingBottom()-getPaddingTop());
scrollBy(-(coords[0]),-(coords[1]));
return true;
}
}
g.scrollToPositionWithOffset(pos,0,false);
scrollToPosition(pos);
return true;
}
if (pos <= 0) scrollToPosition(0);

View file

@ -95,6 +95,11 @@ public abstract class SeekBarAccessibilityDelegate extends View.AccessibilityDel
onInitializeAccessibilityNodeInfoInternal(null, info);
}
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
event.setClassName(SEEK_BAR_CLASS_NAME);
}
protected CharSequence getContentDescription(@Nullable View host) {
return null;
}

View file

@ -5702,7 +5702,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
signInWithGoogleView.setMaxLines(2);
SpannableStringBuilder str = new SpannableStringBuilder("d ");
Drawable dr = ContextCompat.getDrawable(context, R.drawable.googleg_standard_color_18);
Drawable dr = ContextCompat.getDrawable(context, com.google.android.gms.base.R.drawable.googleg_standard_color_18);
dr.setBounds(0, AndroidUtilities.dp(9), AndroidUtilities.dp(18), AndroidUtilities.dp(18 + 9));
str.setSpan(new ImageSpan(dr, ImageSpan.ALIGN_BOTTOM), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
str.setSpan(new ReplacementSpan() {
@ -6042,7 +6042,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
signInWithGoogleView.setMaxLines(2);
SpannableStringBuilder str = new SpannableStringBuilder("d ");
Drawable dr = ContextCompat.getDrawable(context, R.drawable.googleg_standard_color_18);
Drawable dr = ContextCompat.getDrawable(context, com.google.android.gms.base.R.drawable.googleg_standard_color_18);
dr.setBounds(0, AndroidUtilities.dp(9), AndroidUtilities.dp(18), AndroidUtilities.dp(18 + 9));
str.setSpan(new ImageSpan(dr, ImageSpan.ALIGN_BOTTOM), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
str.setSpan(new ReplacementSpan() {

View file

@ -312,6 +312,31 @@ public class VoIPFragment implements VoIPService.StateListener, NotificationCent
return false;
}
final int keyCode = event.getKeyCode();
if(event.getAction() ==KeyEvent.ACTION_DOWN &&keyCode ==KeyEvent.KEYCODE_CALL) event.startTracking();
if(event.getAction() ==KeyEvent.ACTION_UP &&(keyCode ==KeyEvent.KEYCODE_CALL ||keyCode ==KeyEvent.KEYCODE_F1 ||keyCode ==KeyEvent.KEYCODE_MENU) &&VoIPService.getSharedInstance() !=null) {
/*KeyEvent e=new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
Intent i=new Intent(Intent.ACTION_MEDIA_BUTTON);
i.putExtra(Intent.EXTRA_KEY_EVENT,e);
getContext().sendBroadcast(i);*/
//VoIPService.getSharedInstance().onMediaButtonEvent(e);
VoIPService s=VoIPService.getSharedInstance();
if(keyCode ==KeyEvent.KEYCODE_CALL) {
if (s.getCallState() == VoIPService.STATE_WAITING_INCOMING) {
s.acceptIncomingCall();
} else {
s.setMicMute(!s.isMicMute(), false, true);
announceForAccessibility(s.isMicMute() ? LocaleController.getString("AccDescrVoipMicOff", R.string.AccDescrVoipMicOff) : LocaleController.getString("AccDescrVoipMicOn", R.string.AccDescrVoipMicOn));
}
}
else if(keyCode ==KeyEvent.KEYCODE_F1) {
if (s.getCallState() == VoIPService.STATE_WAITING_INCOMING) s.hangUp(); else if (s.getCallState() != VoIPService.STATE_BUSY) s.declineIncomingCall();
//finish();
}
else if(keyCode==KeyEvent.KEYCODE_MENU) {
s.toggleSpeakerphoneOrShowRouteSheet(getContext(), false);
}
return true;
}
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP && !fragment.lockOnScreen) {
fragment.onBackPressed();
return true;

View file

@ -27,6 +27,8 @@
<item name="acc_action_open_forwarded_origin" type="id"/>
<item name="shake_animation" type="id"/>
<item name="acc_action_user_or_channel" type="id"/>
<item name="timeout_callback" type="id"/>
<item name="menu_open_bot" type="id"/>