List of usage examples for android.animation AnimatorSet AnimatorSet
public AnimatorSet()
From source file:kr.wdream.ui.ChatActivity.java
public void showAlert(String name, String message) { if (alertView == null || name == null || message == null) { return;/* w w w . j a va2 s.c o m*/ } if (alertView.getTag() != null) { alertView.setTag(null); if (alertViewAnimator != null) { alertViewAnimator.cancel(); alertViewAnimator = null; } alertView.setVisibility(View.VISIBLE); alertViewAnimator = new AnimatorSet(); alertViewAnimator.playTogether(ObjectAnimator.ofFloat(alertView, "translationY", 0)); alertViewAnimator.setDuration(200); alertViewAnimator.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (alertViewAnimator != null && alertViewAnimator.equals(animation)) { alertViewAnimator = null; } } @Override public void onAnimationCancel(Animator animation) { if (alertViewAnimator != null && alertViewAnimator.equals(animation)) { alertViewAnimator = null; } } }); alertViewAnimator.start(); } alertNameTextView.setText(name); alertTextView.setText(Emoji.replaceEmoji(message.replace('\n', ' '), alertTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false)); if (hideAlertViewRunnable != null) { AndroidUtilities.cancelRunOnUIThread(hideAlertViewRunnable); } AndroidUtilities.runOnUIThread(hideAlertViewRunnable = new Runnable() { @Override public void run() { if (hideAlertViewRunnable != this) { return; } if (alertView.getTag() == null) { alertView.setTag(1); if (alertViewAnimator != null) { alertViewAnimator.cancel(); alertViewAnimator = null; } alertViewAnimator = new AnimatorSet(); alertViewAnimator.playTogether( ObjectAnimator.ofFloat(alertView, "translationY", -AndroidUtilities.dp(50))); alertViewAnimator.setDuration(200); alertViewAnimator.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (alertViewAnimator != null && alertViewAnimator.equals(animation)) { alertView.setVisibility(View.GONE); alertViewAnimator = null; } } @Override public void onAnimationCancel(Animator animation) { if (alertViewAnimator != null && alertViewAnimator.equals(animation)) { alertViewAnimator = null; } } }); alertViewAnimator.start(); } } }, 3000); }
From source file:net.bluehack.ui.ChatActivity.java
private void updatePinnedMessageView(boolean animated) { if (pinnedMessageView == null) { return;/*from w w w .j a v a 2 s . c o m*/ } if (info != null) { if (pinnedMessageObject != null && info.pinned_msg_id != pinnedMessageObject.getId()) { pinnedMessageObject = null; } if (info.pinned_msg_id != 0 && pinnedMessageObject == null) { pinnedMessageObject = messagesDict[0].get(info.pinned_msg_id); } } SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); if (info == null || info.pinned_msg_id == 0 || info.pinned_msg_id == preferences.getInt("pin_" + dialog_id, 0) || actionBar != null && actionBar.isActionModeShowed()) { hidePinnedMessageView(animated); } else { if (pinnedMessageObject != null) { if (pinnedMessageView.getTag() != null) { pinnedMessageView.setTag(null); if (pinnedMessageViewAnimator != null) { pinnedMessageViewAnimator.cancel(); pinnedMessageViewAnimator = null; } if (animated) { pinnedMessageView.setVisibility(View.VISIBLE); pinnedMessageViewAnimator = new AnimatorSet(); pinnedMessageViewAnimator .playTogether(ObjectAnimator.ofFloat(pinnedMessageView, "translationY", 0)); pinnedMessageViewAnimator.setDuration(200); pinnedMessageViewAnimator.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (pinnedMessageViewAnimator != null && pinnedMessageViewAnimator.equals(animation)) { pinnedMessageViewAnimator = null; } } @Override public void onAnimationCancel(Animator animation) { if (pinnedMessageViewAnimator != null && pinnedMessageViewAnimator.equals(animation)) { pinnedMessageViewAnimator = null; } } }); pinnedMessageViewAnimator.start(); } else { pinnedMessageView.setTranslationY(0); pinnedMessageView.setVisibility(View.VISIBLE); } } FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) pinnedMessageNameTextView .getLayoutParams(); FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) pinnedMessageTextView .getLayoutParams(); TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(pinnedMessageObject.photoThumbs2, AndroidUtilities.dp(50)); if (photoSize == null) { photoSize = FileLoader.getClosestPhotoSizeWithSize(pinnedMessageObject.photoThumbs, AndroidUtilities.dp(50)); } if (photoSize == null || photoSize instanceof TLRPC.TL_photoSizeEmpty || photoSize.location instanceof TLRPC.TL_fileLocationUnavailable || pinnedMessageObject.type == 13) { pinnedMessageImageView.setImageBitmap(null); pinnedImageLocation = null; pinnedMessageImageView.setVisibility(View.INVISIBLE); layoutParams1.leftMargin = layoutParams2.leftMargin = AndroidUtilities.dp(18); } else { pinnedImageLocation = photoSize.location; pinnedMessageImageView.setImage(pinnedImageLocation, "50_50", (Drawable) null); pinnedMessageImageView.setVisibility(View.VISIBLE); layoutParams1.leftMargin = layoutParams2.leftMargin = AndroidUtilities.dp(55); } pinnedMessageNameTextView.setLayoutParams(layoutParams1); pinnedMessageTextView.setLayoutParams(layoutParams2); pinnedMessageNameTextView .setText(LocaleController.getString("PinnedMessage", R.string.PinnedMessage)); if (pinnedMessageObject.type == 14) { pinnedMessageTextView.setText(String.format("%s - %s", pinnedMessageObject.getMusicAuthor(), pinnedMessageObject.getMusicTitle())); } else if (pinnedMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGame) { pinnedMessageTextView.setText(Emoji.replaceEmoji( pinnedMessageObject.messageOwner.media.game.title, pinnedMessageTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false)); } else if (pinnedMessageObject.messageText != null) { String mess = pinnedMessageObject.messageText.toString(); if (mess.length() > 150) { mess = mess.substring(0, 150); } mess = mess.replace('\n', ' '); pinnedMessageTextView.setText(Emoji.replaceEmoji(mess, pinnedMessageTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false)); } } else { pinnedImageLocation = null; hidePinnedMessageView(animated); if (loadingPinnedMessage != info.pinned_msg_id) { loadingPinnedMessage = info.pinned_msg_id; MessagesQuery.loadPinnedMessage(currentChat.id, info.pinned_msg_id, true); } } } checkListViewPaddings(); }
From source file:kr.wdream.ui.ChatActivity.java
private void hidePinnedMessageView(boolean animated) { if (pinnedMessageView.getTag() == null) { pinnedMessageView.setTag(1);//from www . jav a2 s . c o m if (pinnedMessageViewAnimator != null) { pinnedMessageViewAnimator.cancel(); pinnedMessageViewAnimator = null; } if (animated) { pinnedMessageViewAnimator = new AnimatorSet(); pinnedMessageViewAnimator.playTogether( ObjectAnimator.ofFloat(pinnedMessageView, "translationY", -AndroidUtilities.dp(50))); pinnedMessageViewAnimator.setDuration(200); pinnedMessageViewAnimator.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (pinnedMessageViewAnimator != null && pinnedMessageViewAnimator.equals(animation)) { pinnedMessageView.setVisibility(View.GONE); pinnedMessageViewAnimator = null; } } @Override public void onAnimationCancel(Animator animation) { if (pinnedMessageViewAnimator != null && pinnedMessageViewAnimator.equals(animation)) { pinnedMessageViewAnimator = null; } } }); pinnedMessageViewAnimator.start(); } else { pinnedMessageView.setTranslationY(-AndroidUtilities.dp(50)); pinnedMessageView.setVisibility(View.GONE); } } }
From source file:kr.wdream.ui.ChatActivity.java
private void updatePinnedMessageView(boolean animated) { if (pinnedMessageView == null) { return;/* w ww . j a va2 s.c o m*/ } if (info != null) { if (pinnedMessageObject != null && info.pinned_msg_id != pinnedMessageObject.getId()) { pinnedMessageObject = null; } if (info.pinned_msg_id != 0 && pinnedMessageObject == null) { pinnedMessageObject = messagesDict[0].get(info.pinned_msg_id); } } SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); if (info == null || info.pinned_msg_id == 0 || info.pinned_msg_id == preferences.getInt("pin_" + dialog_id, 0) || actionBar != null && actionBar.isActionModeShowed()) { hidePinnedMessageView(animated); } else { if (pinnedMessageObject != null) { if (pinnedMessageView.getTag() != null) { pinnedMessageView.setTag(null); if (pinnedMessageViewAnimator != null) { pinnedMessageViewAnimator.cancel(); pinnedMessageViewAnimator = null; } if (animated) { pinnedMessageView.setVisibility(View.VISIBLE); pinnedMessageViewAnimator = new AnimatorSet(); pinnedMessageViewAnimator .playTogether(ObjectAnimator.ofFloat(pinnedMessageView, "translationY", 0)); pinnedMessageViewAnimator.setDuration(200); pinnedMessageViewAnimator.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (pinnedMessageViewAnimator != null && pinnedMessageViewAnimator.equals(animation)) { pinnedMessageViewAnimator = null; } } @Override public void onAnimationCancel(Animator animation) { if (pinnedMessageViewAnimator != null && pinnedMessageViewAnimator.equals(animation)) { pinnedMessageViewAnimator = null; } } }); pinnedMessageViewAnimator.start(); } else { pinnedMessageView.setTranslationY(0); pinnedMessageView.setVisibility(View.VISIBLE); } } FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) pinnedMessageNameTextView .getLayoutParams(); FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) pinnedMessageTextView .getLayoutParams(); TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(pinnedMessageObject.photoThumbs2, AndroidUtilities.dp(50)); if (photoSize == null) { photoSize = FileLoader.getClosestPhotoSizeWithSize(pinnedMessageObject.photoThumbs, AndroidUtilities.dp(50)); } if (photoSize == null || photoSize instanceof TLRPC.TL_photoSizeEmpty || photoSize.location instanceof TLRPC.TL_fileLocationUnavailable || pinnedMessageObject.type == 13) { pinnedMessageImageView.setImageBitmap(null); pinnedImageLocation = null; pinnedMessageImageView.setVisibility(View.INVISIBLE); layoutParams1.leftMargin = layoutParams2.leftMargin = AndroidUtilities.dp(18); } else { pinnedImageLocation = photoSize.location; pinnedMessageImageView.setImage(pinnedImageLocation, "50_50", (Drawable) null); pinnedMessageImageView.setVisibility(View.VISIBLE); layoutParams1.leftMargin = layoutParams2.leftMargin = AndroidUtilities.dp(55); } pinnedMessageNameTextView.setLayoutParams(layoutParams1); pinnedMessageTextView.setLayoutParams(layoutParams2); pinnedMessageNameTextView.setText( LocaleController.getString("PinnedMessage", kr.wdream.storyshop.R.string.PinnedMessage)); if (pinnedMessageObject.type == 14) { pinnedMessageTextView.setText(String.format("%s - %s", pinnedMessageObject.getMusicAuthor(), pinnedMessageObject.getMusicTitle())); } else if (pinnedMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGame) { pinnedMessageTextView.setText(Emoji.replaceEmoji( pinnedMessageObject.messageOwner.media.game.title, pinnedMessageTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false)); } else if (pinnedMessageObject.messageText != null) { String mess = pinnedMessageObject.messageText.toString(); if (mess.length() > 150) { mess = mess.substring(0, 150); } mess = mess.replace('\n', ' '); pinnedMessageTextView.setText(Emoji.replaceEmoji(mess, pinnedMessageTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false)); } } else { pinnedImageLocation = null; hidePinnedMessageView(animated); if (loadingPinnedMessage != info.pinned_msg_id) { loadingPinnedMessage = info.pinned_msg_id; MessagesQuery.loadPinnedMessage(currentChat.id, info.pinned_msg_id, true); } } } checkListViewPaddings(); }
From source file:org.telegram.ui.PassportActivity.java
private void showEditDoneProgress(final boolean animateDoneItem, final boolean show) { if (doneItemAnimation != null) { doneItemAnimation.cancel();/*from ww w .j a va 2 s . c o m*/ } if (animateDoneItem && doneItem != null) { doneItemAnimation = new AnimatorSet(); if (show) { progressView.setVisibility(View.VISIBLE); doneItem.setEnabled(false); doneItemAnimation.playTogether(ObjectAnimator.ofFloat(doneItem.getImageView(), View.SCALE_X, 0.1f), ObjectAnimator.ofFloat(doneItem.getImageView(), View.SCALE_Y, 0.1f), ObjectAnimator.ofFloat(doneItem.getImageView(), View.ALPHA, 0.0f), ObjectAnimator.ofFloat(progressView, View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(progressView, View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(progressView, View.ALPHA, 1.0f)); } else { doneItem.getImageView().setVisibility(View.VISIBLE); doneItem.setEnabled(true); doneItemAnimation.playTogether(ObjectAnimator.ofFloat(progressView, View.SCALE_X, 0.1f), ObjectAnimator.ofFloat(progressView, View.SCALE_Y, 0.1f), ObjectAnimator.ofFloat(progressView, View.ALPHA, 0.0f), ObjectAnimator.ofFloat(doneItem.getImageView(), View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(doneItem.getImageView(), View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(doneItem.getImageView(), View.ALPHA, 1.0f)); } doneItemAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (doneItemAnimation != null && doneItemAnimation.equals(animation)) { if (!show) { progressView.setVisibility(View.INVISIBLE); } else { doneItem.getImageView().setVisibility(View.INVISIBLE); } } } @Override public void onAnimationCancel(Animator animation) { if (doneItemAnimation != null && doneItemAnimation.equals(animation)) { doneItemAnimation = null; } } }); doneItemAnimation.setDuration(150); doneItemAnimation.start(); } else if (acceptTextView != null) { doneItemAnimation = new AnimatorSet(); if (show) { progressViewButton.setVisibility(View.VISIBLE); bottomLayout.setEnabled(false); doneItemAnimation.playTogether(ObjectAnimator.ofFloat(acceptTextView, View.SCALE_X, 0.1f), ObjectAnimator.ofFloat(acceptTextView, View.SCALE_Y, 0.1f), ObjectAnimator.ofFloat(acceptTextView, View.ALPHA, 0.0f), ObjectAnimator.ofFloat(progressViewButton, View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(progressViewButton, View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(progressViewButton, View.ALPHA, 1.0f)); } else { acceptTextView.setVisibility(View.VISIBLE); bottomLayout.setEnabled(true); doneItemAnimation.playTogether(ObjectAnimator.ofFloat(progressViewButton, View.SCALE_X, 0.1f), ObjectAnimator.ofFloat(progressViewButton, View.SCALE_Y, 0.1f), ObjectAnimator.ofFloat(progressViewButton, View.ALPHA, 0.0f), ObjectAnimator.ofFloat(acceptTextView, View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(acceptTextView, View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(acceptTextView, View.ALPHA, 1.0f)); } doneItemAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (doneItemAnimation != null && doneItemAnimation.equals(animation)) { if (!show) { progressViewButton.setVisibility(View.INVISIBLE); } else { acceptTextView.setVisibility(View.INVISIBLE); } } } @Override public void onAnimationCancel(Animator animation) { if (doneItemAnimation != null && doneItemAnimation.equals(animation)) { doneItemAnimation = null; } } }); doneItemAnimation.setDuration(150); doneItemAnimation.start(); } }
From source file:kr.wdream.ui.ChatActivity.java
private void updateSpamView() { if (reportSpamView == null) { return;/*from w w w. java 2 s.c o m*/ } SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); boolean show = preferences.getInt("spam3_" + dialog_id, 0) == 2; if (show) { if (messages.isEmpty()) { show = false; } else { int count = messages.size() - 1; for (int a = count; a >= Math.max(count - 50, 0); a--) { MessageObject messageObject = messages.get(a); if (messageObject.isOut()) { show = false; break; } } } } if (!show) { if (reportSpamView.getTag() == null) { reportSpamView.setTag(1); if (reportSpamViewAnimator != null) { reportSpamViewAnimator.cancel(); } reportSpamViewAnimator = new AnimatorSet(); reportSpamViewAnimator.playTogether( ObjectAnimator.ofFloat(reportSpamView, "translationY", -AndroidUtilities.dp(50))); reportSpamViewAnimator.setDuration(200); reportSpamViewAnimator.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (reportSpamViewAnimator != null && reportSpamViewAnimator.equals(animation)) { reportSpamView.setVisibility(View.GONE); reportSpamViewAnimator = null; } } @Override public void onAnimationCancel(Animator animation) { if (reportSpamViewAnimator != null && reportSpamViewAnimator.equals(animation)) { reportSpamViewAnimator = null; } } }); reportSpamViewAnimator.start(); } } else { if (reportSpamView.getTag() != null) { reportSpamView.setTag(null); reportSpamView.setVisibility(View.VISIBLE); if (reportSpamViewAnimator != null) { reportSpamViewAnimator.cancel(); } reportSpamViewAnimator = new AnimatorSet(); reportSpamViewAnimator.playTogether(ObjectAnimator.ofFloat(reportSpamView, "translationY", 0)); reportSpamViewAnimator.setDuration(200); reportSpamViewAnimator.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (reportSpamViewAnimator != null && reportSpamViewAnimator.equals(animation)) { reportSpamViewAnimator = null; } } @Override public void onAnimationCancel(Animator animation) { if (reportSpamViewAnimator != null && reportSpamViewAnimator.equals(animation)) { reportSpamViewAnimator = null; } } }); reportSpamViewAnimator.start(); } } checkListViewPaddings(); }
From source file:org.telegram.ui.PassportActivity.java
public void setPage(int page, boolean animated, Bundle params) { if (page == 3) { doneItem.setVisibility(View.GONE); }//from w w w .j a v a 2s.c om final SlideView outView = views[currentViewNum]; final SlideView newView = views[page]; currentViewNum = page; newView.setParams(params, false); newView.onShow(); if (animated) { newView.setTranslationX(AndroidUtilities.displaySize.x); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.setDuration(300); animatorSet.playTogether( ObjectAnimator.ofFloat(outView, "translationX", -AndroidUtilities.displaySize.x), ObjectAnimator.ofFloat(newView, "translationX", 0)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { newView.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { outView.setVisibility(View.GONE); outView.setX(0); } }); animatorSet.start(); } else { newView.setTranslationX(0); newView.setVisibility(View.VISIBLE); if (outView != newView) { outView.setVisibility(View.GONE); } } }
From source file:net.bluehack.ui.ChatActivity.java
private void createMenu(View v, boolean single) { if (actionBar.isActionModeShowed()) { return;/*from w w w . j a v a 2s . c o m*/ } 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); if (single && message.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { scrollToMessageId(message.messageOwner.reply_to_msg_id, 0, true, 0); return; } selectedObject = null; forwaringMessage = null; for (int a = 1; a >= 0; a--) { selectedMessagesCanCopyIds[a].clear(); selectedMessagesIds[a].clear(); } cantDeleteMessagesCount = 0; actionBar.hideActionMode(); updatePinnedMessageView(true); boolean allowChatActions = true; boolean allowPin = message.getDialogId() != mergeDialogId && message.getId() > 0 && ChatObject.isChannel(currentChat) && currentChat.megagroup && (currentChat.creator || currentChat.editor) && (message.messageOwner.action == null || message.messageOwner.action instanceof TLRPC.TL_messageActionEmpty); boolean allowUnpin = message.getDialogId() != mergeDialogId && info != null && info.pinned_msg_id == message.getId() && (currentChat.creator || currentChat.editor); boolean allowEdit = message.canEditMessage(currentChat) && !chatActivityEnterView.hasAudioToSend() && message.getDialogId() != mergeDialogId; if (currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) < 46 || type == 1 && message.getDialogId() == mergeDialogId || currentEncryptedChat == null && message.getId() < 0 || isBroadcast || currentChat != null && (ChatObject.isNotInChat(currentChat) || ChatObject.isChannel(currentChat) && !currentChat.creator && !currentChat.editor && !currentChat.megagroup)) { allowChatActions = false; } if (single || type < 2 || type == 20) { if (type >= 0) { 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 (type == 0) { items.add(LocaleController.getString("Retry", R.string.Retry)); options.add(0); items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } else if (type == 1) { if (currentChat != null && !isBroadcast) { if (allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } else { if (single && selectedObject.getId() > 0 && allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } } else if (type == 20) { items.add(LocaleController.getString("Retry", R.string.Retry)); options.add(0); items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(3); items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } else { if (currentEncryptedChat == null) { if (allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(3); } 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("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) { TLRPC.User user = MessagesController.getInstance() .getUser(selectedObject.messageOwner.media.user_id); if (user != null && user.id != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(user.id) == null) { items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle)); options.add(15); } if (selectedObject.messageOwner.media.phone_number != null || selectedObject.messageOwner.media.phone_number.length() != 0) { items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(16); items.add(LocaleController.getString("Call", R.string.Call)); options.add(17); } } items.add(LocaleController.getString("Forward", R.string.Forward)); options.add(2); if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } else { if (allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(3); } 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.isVideo() && selectedObject.getDocument() != null) { 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); } else if (type == 7) { items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers)); options.add(9); } items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } if (options.isEmpty()) { return; } final CharSequence[] finalItems = items.toArray(new CharSequence[items.size()]); builder.setItems(finalItems, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int 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()); } return; } final ActionBarMenu actionMode = actionBar.createActionMode(); View item = actionMode.getItem(forward); if (item != null) { item.setVisibility(View.VISIBLE); } item = actionMode.getItem(delete); if (item != null) { item.setVisibility(View.VISIBLE); } if (editDoneItem != null) { editDoneItem.setVisibility(View.GONE); } actionBar.showActionMode(); updatePinnedMessageView(true); AnimatorSet animatorSet = new AnimatorSet(); ArrayList<Animator> animators = new ArrayList<>(); for (int a = 0; a < actionModeViews.size(); a++) { View view = actionModeViews.get(a); AndroidUtilities.clearDrawableAnimation(view); animators.add(ObjectAnimator.ofFloat(view, "scaleY", 0.1f, 1.0f)); } animatorSet.playTogether(animators); animatorSet.setDuration(250); animatorSet.start(); addToSelectedMessages(message); selectedMessagesCountTextView.setNumber(1, false); updateVisibleRows(); }
From source file:kr.wdream.ui.ChatActivity.java
private void createMenu(View v, boolean single) { if (actionBar.isActionModeShowed()) { return;/*from w w w .j a va2 s .co m*/ } 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); if (single && message.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { scrollToMessageId(message.messageOwner.reply_to_msg_id, 0, true, 0); return; } selectedObject = null; forwaringMessage = null; for (int a = 1; a >= 0; a--) { selectedMessagesCanCopyIds[a].clear(); selectedMessagesIds[a].clear(); } cantDeleteMessagesCount = 0; actionBar.hideActionMode(); updatePinnedMessageView(true); boolean allowChatActions = true; boolean allowPin = message.getDialogId() != mergeDialogId && message.getId() > 0 && ChatObject.isChannel(currentChat) && currentChat.megagroup && (currentChat.creator || currentChat.editor) && (message.messageOwner.action == null || message.messageOwner.action instanceof TLRPC.TL_messageActionEmpty); boolean allowUnpin = message.getDialogId() != mergeDialogId && info != null && info.pinned_msg_id == message.getId() && (currentChat.creator || currentChat.editor); boolean allowEdit = message.canEditMessage(currentChat) && !chatActivityEnterView.hasAudioToSend() && message.getDialogId() != mergeDialogId; if (currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) < 46 || type == 1 && message.getDialogId() == mergeDialogId || currentEncryptedChat == null && message.getId() < 0 || isBroadcast || currentChat != null && (ChatObject.isNotInChat(currentChat) || ChatObject.isChannel(currentChat) && !currentChat.creator && !currentChat.editor && !currentChat.megagroup)) { allowChatActions = false; } if (single || type < 2 || type == 20) { if (type >= 0) { 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 (type == 0) { items.add(LocaleController.getString("Retry", kr.wdream.storyshop.R.string.Retry)); options.add(0); items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } else if (type == 1) { if (currentChat != null && !isBroadcast) { if (allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", kr.wdream.storyshop.R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", kr.wdream.storyshop.R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", kr.wdream.storyshop.R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } else { if (single && selectedObject.getId() > 0 && allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } } else if (type == 20) { items.add(LocaleController.getString("Retry", kr.wdream.storyshop.R.string.Retry)); options.add(0); items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(3); items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } else { if (currentEncryptedChat == null) { if (allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(3); } if (type == 3) { if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && MessageObject .isNewGifDocument(selectedObject.messageOwner.media.webpage.document)) { items.add(LocaleController.getString("SaveToGIFs", kr.wdream.storyshop.R.string.SaveToGIFs)); options.add(11); } } else if (type == 4) { if (selectedObject.isVideo()) { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (selectedObject.isMusic()) { items.add(LocaleController.getString("SaveToMusic", kr.wdream.storyshop.R.string.SaveToMusic)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (selectedObject.getDocument() != null) { if (MessageObject.isNewGifDocument(selectedObject.getDocument())) { items.add(LocaleController.getString("SaveToGIFs", kr.wdream.storyshop.R.string.SaveToGIFs)); options.add(11); } items.add(LocaleController.getString("SaveToDownloads", kr.wdream.storyshop.R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); } } else if (type == 5) { items.add(LocaleController.getString("ApplyLocalizationFile", kr.wdream.storyshop.R.string.ApplyLocalizationFile)); options.add(5); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (type == 6) { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(7); items.add(LocaleController.getString("SaveToDownloads", kr.wdream.storyshop.R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (type == 7) { if (selectedObject.isMask()) { items.add(LocaleController.getString("AddToMasks", kr.wdream.storyshop.R.string.AddToMasks)); } else { items.add(LocaleController.getString("AddToStickers", kr.wdream.storyshop.R.string.AddToStickers)); } options.add(9); } else if (type == 8) { TLRPC.User user = MessagesController.getInstance() .getUser(selectedObject.messageOwner.media.user_id); if (user != null && user.id != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(user.id) == null) { items.add(LocaleController.getString("AddContactTitle", kr.wdream.storyshop.R.string.AddContactTitle)); options.add(15); } if (selectedObject.messageOwner.media.phone_number != null || selectedObject.messageOwner.media.phone_number.length() != 0) { items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(16); items.add(LocaleController.getString("Call", kr.wdream.storyshop.R.string.Call)); options.add(17); } } items.add(LocaleController.getString("Forward", kr.wdream.storyshop.R.string.Forward)); options.add(2); if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", kr.wdream.storyshop.R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", kr.wdream.storyshop.R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", kr.wdream.storyshop.R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } else { if (allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(3); } if (type == 4) { if (selectedObject.isVideo()) { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (selectedObject.isMusic()) { items.add(LocaleController.getString("SaveToMusic", kr.wdream.storyshop.R.string.SaveToMusic)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (!selectedObject.isVideo() && selectedObject.getDocument() != null) { items.add(LocaleController.getString("SaveToDownloads", kr.wdream.storyshop.R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); } } else if (type == 5) { items.add(LocaleController.getString("ApplyLocalizationFile", kr.wdream.storyshop.R.string.ApplyLocalizationFile)); options.add(5); } else if (type == 7) { items.add(LocaleController.getString("AddToStickers", kr.wdream.storyshop.R.string.AddToStickers)); options.add(9); } items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } if (options.isEmpty()) { return; } final CharSequence[] finalItems = items.toArray(new CharSequence[items.size()]); builder.setItems(finalItems, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (selectedObject == null || i < 0 || i >= options.size()) { return; } processSelectedOption(options.get(i)); } }); builder.setTitle(LocaleController.getString("Message", kr.wdream.storyshop.R.string.Message)); showDialog(builder.create()); } return; } final ActionBarMenu actionMode = actionBar.createActionMode(); View item = actionMode.getItem(forward); if (item != null) { item.setVisibility(View.VISIBLE); } item = actionMode.getItem(delete); if (item != null) { item.setVisibility(View.VISIBLE); } if (editDoneItem != null) { editDoneItem.setVisibility(View.GONE); } actionBar.showActionMode(); updatePinnedMessageView(true); AnimatorSet animatorSet = new AnimatorSet(); ArrayList<Animator> animators = new ArrayList<>(); for (int a = 0; a < actionModeViews.size(); a++) { View view = actionModeViews.get(a); AndroidUtilities.clearDrawableAnimation(view); animators.add(ObjectAnimator.ofFloat(view, "scaleY", 0.1f, 1.0f)); } animatorSet.playTogether(animators); animatorSet.setDuration(250); animatorSet.start(); addToSelectedMessages(message); selectedMessagesCountTextView.setNumber(1, false); updateVisibleRows(); }
From source file:kr.wdream.ui.ChatActivity.java
private void showEditDoneProgress(final boolean show, boolean animated) { if (editDoneItemAnimation != null) { editDoneItemAnimation.cancel();//ww w .ja v a2 s. c om } if (!animated) { if (show) { editDoneItem.getImageView().setScaleX(0.1f); editDoneItem.getImageView().setScaleY(0.1f); editDoneItem.getImageView().setAlpha(0.0f); editDoneItemProgress.setScaleX(1.0f); editDoneItemProgress.setScaleY(1.0f); editDoneItemProgress.setAlpha(1.0f); editDoneItem.getImageView().setVisibility(View.INVISIBLE); editDoneItemProgress.setVisibility(View.VISIBLE); editDoneItem.setEnabled(false); } else { editDoneItemProgress.setScaleX(0.1f); editDoneItemProgress.setScaleY(0.1f); editDoneItemProgress.setAlpha(0.0f); editDoneItem.getImageView().setScaleX(1.0f); editDoneItem.getImageView().setScaleY(1.0f); editDoneItem.getImageView().setAlpha(1.0f); editDoneItem.getImageView().setVisibility(View.VISIBLE); editDoneItemProgress.setVisibility(View.INVISIBLE); editDoneItem.setEnabled(true); } } else { editDoneItemAnimation = new AnimatorSet(); if (show) { editDoneItemProgress.setVisibility(View.VISIBLE); editDoneItem.setEnabled(false); editDoneItemAnimation.playTogether( ObjectAnimator.ofFloat(editDoneItem.getImageView(), "scaleX", 0.1f), ObjectAnimator.ofFloat(editDoneItem.getImageView(), "scaleY", 0.1f), ObjectAnimator.ofFloat(editDoneItem.getImageView(), "alpha", 0.0f), ObjectAnimator.ofFloat(editDoneItemProgress, "scaleX", 1.0f), ObjectAnimator.ofFloat(editDoneItemProgress, "scaleY", 1.0f), ObjectAnimator.ofFloat(editDoneItemProgress, "alpha", 1.0f)); } else { editDoneItem.getImageView().setVisibility(View.VISIBLE); editDoneItem.setEnabled(true); editDoneItemAnimation.playTogether(ObjectAnimator.ofFloat(editDoneItemProgress, "scaleX", 0.1f), ObjectAnimator.ofFloat(editDoneItemProgress, "scaleY", 0.1f), ObjectAnimator.ofFloat(editDoneItemProgress, "alpha", 0.0f), ObjectAnimator.ofFloat(editDoneItem.getImageView(), "scaleX", 1.0f), ObjectAnimator.ofFloat(editDoneItem.getImageView(), "scaleY", 1.0f), ObjectAnimator.ofFloat(editDoneItem.getImageView(), "alpha", 1.0f)); } editDoneItemAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (editDoneItemAnimation != null && editDoneItemAnimation.equals(animation)) { if (!show) { editDoneItemProgress.setVisibility(View.INVISIBLE); } else { editDoneItem.getImageView().setVisibility(View.INVISIBLE); } } } @Override public void onAnimationCancel(Animator animation) { if (editDoneItemAnimation != null && editDoneItemAnimation.equals(animation)) { editDoneItemAnimation = null; } } }); editDoneItemAnimation.setDuration(150); editDoneItemAnimation.start(); } }