use of org.telegram.ui.Cells.ChatMessageCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChannelAdminLogActivity method createMenu.
private void createMenu(View v) {
MessageObject message = null;
if (v instanceof ChatMessageCell) {
message = ((ChatMessageCell) v).getMessageObject();
} else if (v instanceof ChatActionCell) {
message = ((ChatActionCell) v).getMessageObject();
}
if (message == null) {
return;
}
final int type = getMessageType(message);
selectedObject = message;
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
ArrayList<CharSequence> items = new ArrayList<>();
final ArrayList<Integer> options = new ArrayList<>();
if (selectedObject.type == 0 || selectedObject.caption != null) {
items.add(LocaleController.getString("Copy", R.string.Copy));
options.add(3);
}
if (type == 1) {
if (selectedObject.currentEvent != null && selectedObject.currentEvent.action instanceof TLRPC.TL_channelAdminLogEventActionChangeStickerSet) {
TLRPC.TL_channelAdminLogEventActionChangeStickerSet action = (TLRPC.TL_channelAdminLogEventActionChangeStickerSet) selectedObject.currentEvent.action;
TLRPC.InputStickerSet stickerSet = action.new_stickerset;
if (stickerSet == null || stickerSet instanceof TLRPC.TL_inputStickerSetEmpty) {
stickerSet = action.prev_stickerset;
}
if (stickerSet != null) {
showDialog(new StickersAlert(getParentActivity(), ChannelAdminLogActivity.this, stickerSet, null, null));
return;
}
} else if (selectedObject.currentEvent != null && selectedObject.currentEvent.action instanceof TLRPC.TL_channelAdminLogEventActionChangeHistoryTTL) {
if (ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES)) {
ClearHistoryAlert alert = new ClearHistoryAlert(getParentActivity(), null, currentChat, false, null);
alert.setDelegate(new ClearHistoryAlert.ClearHistoryAlertDelegate() {
@Override
public void onAutoDeleteHistory(int ttl, int action) {
getMessagesController().setDialogHistoryTTL(-currentChat.id, ttl);
TLRPC.ChatFull chatInfo = getMessagesController().getChatFull(currentChat.id);
if (chatInfo != null) {
undoView.showWithAction(-currentChat.id, action, null, chatInfo.ttl_period, null, null);
}
}
});
showDialog(alert);
}
}
} else if (type == 3) {
if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && MessageObject.isNewGifDocument(selectedObject.messageOwner.media.webpage.document)) {
items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
options.add(11);
}
} else if (type == 4) {
if (selectedObject.isVideo()) {
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
options.add(4);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
} else if (selectedObject.isMusic()) {
items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic));
options.add(10);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
} else if (selectedObject.getDocument() != null) {
if (MessageObject.isNewGifDocument(selectedObject.getDocument())) {
items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
options.add(11);
}
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(10);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
} else {
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
options.add(4);
}
} else if (type == 5) {
items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile));
options.add(5);
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(10);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
} else if (type == 10) {
items.add(LocaleController.getString("ApplyThemeFile", R.string.ApplyThemeFile));
options.add(5);
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(10);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
} else if (type == 6) {
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
options.add(7);
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(10);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
} else if (type == 7) {
if (selectedObject.isMask()) {
items.add(LocaleController.getString("AddToMasks", R.string.AddToMasks));
} else {
items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers));
}
options.add(9);
} else if (type == 8) {
long uid = selectedObject.messageOwner.media.user_id;
TLRPC.User user = null;
if (uid != 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid);
}
if (user != null && user.id != UserConfig.getInstance(currentAccount).getClientUserId() && ContactsController.getInstance(currentAccount).contactsDict.get(user.id) == null) {
items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
options.add(15);
}
if (!TextUtils.isEmpty(selectedObject.messageOwner.media.phone_number)) {
items.add(LocaleController.getString("Copy", R.string.Copy));
options.add(16);
items.add(LocaleController.getString("Call", R.string.Call));
options.add(17);
}
}
if (options.isEmpty()) {
return;
}
final CharSequence[] finalItems = items.toArray(new CharSequence[0]);
builder.setItems(finalItems, (dialogInterface, i) -> {
if (selectedObject == null || i < 0 || i >= options.size()) {
return;
}
processSelectedOption(options.get(i));
});
builder.setTitle(LocaleController.getString("Message", R.string.Message));
showDialog(builder.create());
}
use of org.telegram.ui.Cells.ChatMessageCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChannelAdminLogActivity method updateTextureViewPosition.
private void updateTextureViewPosition() {
boolean foundTextureViewMessage = false;
int count = chatListView.getChildCount();
for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a);
if (view instanceof ChatMessageCell) {
ChatMessageCell messageCell = (ChatMessageCell) view;
MessageObject messageObject = messageCell.getMessageObject();
if (roundVideoContainer != null && messageObject.isRoundVideo() && MediaController.getInstance().isPlayingMessage(messageObject)) {
ImageReceiver imageReceiver = messageCell.getPhotoImage();
roundVideoContainer.setTranslationX(imageReceiver.getImageX());
roundVideoContainer.setTranslationY(fragmentView.getPaddingTop() + messageCell.getTop() + imageReceiver.getImageY());
fragmentView.invalidate();
roundVideoContainer.invalidate();
foundTextureViewMessage = true;
break;
}
}
}
if (roundVideoContainer != null) {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (!foundTextureViewMessage) {
roundVideoContainer.setTranslationY(-AndroidUtilities.roundMessageSize - 100);
fragmentView.invalidate();
if (messageObject != null && messageObject.isRoundVideo()) {
if (checkTextureViewPosition || PipRoundVideoView.getInstance() != null) {
MediaController.getInstance().setCurrentVideoVisible(false);
}
}
} else {
MediaController.getInstance().setCurrentVideoVisible(true);
}
}
}
use of org.telegram.ui.Cells.ChatMessageCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatListItemAnimator method animateAddImpl.
public void animateAddImpl(final RecyclerView.ViewHolder holder, int addedItemsHeight) {
final View view = holder.itemView;
final ViewPropertyAnimator animation = view.animate();
mAddAnimations.add(holder);
view.setTranslationY(addedItemsHeight);
holder.itemView.setScaleX(1);
holder.itemView.setScaleY(1);
ChatMessageCell chatMessageCell = holder.itemView instanceof ChatMessageCell ? (ChatMessageCell) holder.itemView : null;
if (!(chatMessageCell != null && chatMessageCell.getTransitionParams().ignoreAlpha)) {
holder.itemView.setAlpha(1);
}
if (chatMessageCell != null && activity.animatingMessageObjects.contains(chatMessageCell.getMessageObject())) {
activity.animatingMessageObjects.remove(chatMessageCell.getMessageObject());
if (activity.getChatActivityEnterView().canShowMessageTransition()) {
if (chatMessageCell.getMessageObject().isVoice()) {
if (Math.abs(view.getTranslationY()) < view.getMeasuredHeight() * 3f) {
VoiceMessageEnterTransition transition = new VoiceMessageEnterTransition(chatMessageCell, activity.getChatActivityEnterView(), recyclerListView, activity.messageEnterTransitionContainer, resourcesProvider);
transition.start();
}
} else {
if (SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW && Math.abs(view.getTranslationY()) < recyclerListView.getMeasuredHeight()) {
TextMessageEnterTransition transition = new TextMessageEnterTransition(chatMessageCell, activity, recyclerListView, activity.messageEnterTransitionContainer, resourcesProvider);
transition.start();
}
}
activity.getChatActivityEnterView().startMessageTransition();
}
}
animation.translationY(0).setDuration(getMoveDuration()).setInterpolator(translationInterpolator).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchAddStarting(holder);
}
@Override
public void onAnimationCancel(Animator animator) {
view.setTranslationY(0);
if (view instanceof ChatMessageCell) {
((ChatMessageCell) view).getTransitionParams().messageEntering = false;
}
}
@Override
public void onAnimationEnd(Animator animator) {
if (view instanceof ChatMessageCell) {
((ChatMessageCell) view).getTransitionParams().messageEntering = false;
}
animation.setListener(null);
if (mAddAnimations.remove(holder)) {
dispatchAddFinished(holder);
dispatchFinishedWhenDone();
}
}
}).start();
}
use of org.telegram.ui.Cells.ChatMessageCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatListItemAnimator method recordPreLayoutInformation.
@NonNull
@Override
public ItemHolderInfo recordPreLayoutInformation(@NonNull RecyclerView.State state, @NonNull RecyclerView.ViewHolder viewHolder, int changeFlags, @NonNull List<Object> payloads) {
ItemHolderInfo info = super.recordPreLayoutInformation(state, viewHolder, changeFlags, payloads);
if (viewHolder.itemView instanceof ChatMessageCell) {
ChatMessageCell chatMessageCell = (ChatMessageCell) viewHolder.itemView;
ItemHolderInfoExtended extended = new ItemHolderInfoExtended();
extended.left = info.left;
extended.top = info.top;
extended.right = info.right;
extended.bottom = info.bottom;
ChatMessageCell.TransitionParams params = chatMessageCell.getTransitionParams();
extended.imageX = params.lastDrawingImageX;
extended.imageY = params.lastDrawingImageY;
extended.imageWidth = params.lastDrawingImageW;
extended.imageHeight = params.lastDrawingImageH;
return extended;
}
return info;
}
use of org.telegram.ui.Cells.ChatMessageCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatListItemAnimator method restoreTransitionParams.
private void restoreTransitionParams(View view) {
view.setAlpha(1f);
view.setScaleX(1f);
view.setScaleY(1f);
view.setTranslationY(0f);
if (view instanceof BotHelpCell) {
BotHelpCell botCell = (BotHelpCell) view;
int top = recyclerListView.getMeasuredHeight() / 2 - view.getMeasuredHeight() / 2;
botCell.setAnimating(false);
if (view.getTop() > top) {
view.setTranslationY(top - view.getTop());
} else {
view.setTranslationY(0);
}
} else if (view instanceof ChatMessageCell) {
((ChatMessageCell) view).getTransitionParams().resetAnimation();
((ChatMessageCell) view).setAnimationOffsetX(0f);
} else {
view.setTranslationX(0f);
}
}
Aggregations