use of org.telegram.ui.ChatActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class FragmentContextView method checkVisibility.
private void checkVisibility() {
boolean show = false;
if (isLocation) {
if (fragment instanceof DialogsActivity) {
show = LocationController.getLocationsCount() != 0;
} else {
show = LocationController.getInstance(fragment.getCurrentAccount()).isSharingLocation(((ChatActivity) fragment).getDialogId());
}
} else {
if (VoIPService.getSharedInstance() != null && !VoIPService.getSharedInstance().isHangingUp() && VoIPService.getSharedInstance().getCallState() != VoIPService.STATE_WAITING_INCOMING) {
show = true;
} else if (fragment instanceof ChatActivity && fragment.getSendMessagesHelper().getImportingHistory(((ChatActivity) fragment).getDialogId()) != null && !isPlayingVoice()) {
show = true;
} else if (fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && ((ChatActivity) fragment).getGroupCall().shouldShowPanel() && !GroupCallPip.isShowing() && !isPlayingVoice()) {
show = true;
} else {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject != null && messageObject.getId() != 0) {
show = true;
}
}
}
setVisibility(show ? VISIBLE : GONE);
}
use of org.telegram.ui.ChatActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class FragmentContextView method updateAvatars.
private void updateAvatars(boolean animated) {
if (!animated) {
if (avatars.avatarsDarawable.transitionProgressAnimator != null) {
avatars.avatarsDarawable.transitionProgressAnimator.cancel();
avatars.avatarsDarawable.transitionProgressAnimator = null;
}
}
ChatObject.Call call;
TLRPC.User userCall;
if (avatars.avatarsDarawable.transitionProgressAnimator == null) {
int currentAccount;
if (currentStyle == 4) {
if (fragment instanceof ChatActivity) {
ChatActivity chatActivity = (ChatActivity) fragment;
call = chatActivity.getGroupCall();
currentAccount = chatActivity.getCurrentAccount();
} else {
call = null;
currentAccount = account;
}
userCall = null;
} else {
if (VoIPService.getSharedInstance() != null) {
call = VoIPService.getSharedInstance().groupCall;
userCall = fragment instanceof ChatActivity ? null : VoIPService.getSharedInstance().getUser();
currentAccount = VoIPService.getSharedInstance().getAccount();
} else {
call = null;
userCall = null;
currentAccount = account;
}
}
if (call != null) {
for (int a = 0, N = call.sortedParticipants.size(); a < 3; a++) {
if (a < N) {
avatars.setObject(a, currentAccount, call.sortedParticipants.get(a));
} else {
avatars.setObject(a, currentAccount, null);
}
}
} else if (userCall != null) {
avatars.setObject(0, currentAccount, userCall);
for (int a = 1; a < 3; a++) {
avatars.setObject(a, currentAccount, null);
}
} else {
for (int a = 0; a < 3; a++) {
avatars.setObject(a, currentAccount, null);
}
}
avatars.commitTransition(animated);
if (currentStyle == 4 && call != null) {
int N = Math.min(3, call.sortedParticipants.size());
int x = N == 0 ? 10 : (10 + 24 * (N - 1) + 32 + 10);
if (animated) {
int leftMargin = ((LayoutParams) titleTextView.getLayoutParams()).leftMargin;
if (AndroidUtilities.dp(x) != leftMargin) {
float dx = titleTextView.getTranslationX() + leftMargin - AndroidUtilities.dp(x);
titleTextView.setTranslationX(dx);
subtitleTextView.setTranslationX(dx);
titleTextView.animate().translationX(0).setDuration(220).setInterpolator(CubicBezierInterpolator.DEFAULT);
subtitleTextView.animate().translationX(0).setDuration(220).setInterpolator(CubicBezierInterpolator.DEFAULT);
}
} else {
titleTextView.animate().cancel();
subtitleTextView.animate().cancel();
titleTextView.setTranslationX(0);
subtitleTextView.setTranslationX(0);
}
titleTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, Gravity.LEFT | Gravity.TOP, x, 5, call.isScheduled() ? 90 : 36, 0));
subtitleTextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, Gravity.LEFT | Gravity.TOP, x, 25, call.isScheduled() ? 90 : 36, 0));
}
} else {
avatars.updateAfterTransitionEnd();
}
}
use of org.telegram.ui.ChatActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class MessagesController method checkCanOpenChat.
public boolean checkCanOpenChat(Bundle bundle, BaseFragment fragment, MessageObject originalMessage) {
if (bundle == null || fragment == null) {
return true;
}
TLRPC.User user = null;
TLRPC.Chat chat = null;
long userId = bundle.getLong("user_id", 0);
long chatId = bundle.getLong("chat_id", 0);
int messageId = bundle.getInt("message_id", 0);
if (userId != 0) {
user = getUser(userId);
} else if (chatId != 0) {
chat = getChat(chatId);
}
if (user == null && chat == null) {
return true;
}
String reason;
if (chat != null) {
reason = getRestrictionReason(chat.restriction_reason);
} else {
reason = getRestrictionReason(user.restriction_reason);
}
if (reason != null) {
showCantOpenAlert(fragment, reason);
return false;
}
if (messageId != 0 && originalMessage != null && chat != null && chat.access_hash == 0) {
long did = originalMessage.getDialogId();
if (!DialogObject.isEncryptedDialog(did)) {
AlertDialog progressDialog = new AlertDialog(fragment.getParentActivity(), 3);
TLObject req;
if (did < 0) {
chat = getChat(-did);
}
if (did > 0 || !ChatObject.isChannel(chat)) {
TLRPC.TL_messages_getMessages request = new TLRPC.TL_messages_getMessages();
request.id.add(originalMessage.getId());
req = request;
} else {
chat = getChat(-did);
TLRPC.TL_channels_getMessages request = new TLRPC.TL_channels_getMessages();
request.channel = getInputChannel(chat);
request.id.add(originalMessage.getId());
req = request;
}
int reqId = getConnectionsManager().sendRequest(req, (response, error) -> {
if (response != null) {
AndroidUtilities.runOnUIThread(() -> {
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
putUsers(res.users, false);
putChats(res.chats, false);
getMessagesStorage().putUsersAndChats(res.users, res.chats, true, true);
fragment.presentFragment(new ChatActivity(bundle), true);
});
}
});
progressDialog.setOnCancelListener(dialog -> {
getConnectionsManager().cancelRequest(reqId, true);
fragment.setVisibleDialog(null);
});
fragment.setVisibleDialog(progressDialog);
progressDialog.show();
return false;
}
}
return true;
}
use of org.telegram.ui.ChatActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class ReactionsEffectOverlay method show.
public static void show(BaseFragment baseFragment, ReactionsContainerLayout reactionsLayout, ChatMessageCell cell, float x, float y, String reaction, int currentAccount, int animationType) {
if (cell == null || reaction == null || baseFragment == null || baseFragment.getParentActivity() == null) {
return;
}
boolean animationEnabled = MessagesController.getGlobalMainSettings().getBoolean("view_animations", true);
if (!animationEnabled) {
return;
}
if (animationType == ONLY_MOVE_ANIMATION || animationType == LONG_ANIMATION) {
show(baseFragment, null, cell, 0, 0, reaction, currentAccount, SHORT_ANIMATION);
}
ReactionsEffectOverlay reactionsEffectOverlay = new ReactionsEffectOverlay(baseFragment.getParentActivity(), baseFragment, reactionsLayout, cell, x, y, reaction, currentAccount, animationType);
if (animationType == SHORT_ANIMATION) {
currentShortOverlay = reactionsEffectOverlay;
} else {
currentOverlay = reactionsEffectOverlay;
}
boolean useWindow = false;
if (baseFragment instanceof ChatActivity) {
ChatActivity chatActivity = (ChatActivity) baseFragment;
if (chatActivity.scrimPopupWindow != null && chatActivity.scrimPopupWindow.isShowing()) {
useWindow = true;
}
}
reactionsEffectOverlay.useWindow = useWindow;
if (useWindow) {
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.width = lp.height = WindowManager.LayoutParams.MATCH_PARENT;
lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
lp.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
lp.format = PixelFormat.TRANSLUCENT;
reactionsEffectOverlay.windowManager = baseFragment.getParentActivity().getWindowManager();
reactionsEffectOverlay.windowManager.addView(reactionsEffectOverlay.windowView, lp);
} else {
reactionsEffectOverlay.decorView = (FrameLayout) baseFragment.getParentActivity().getWindow().getDecorView();
reactionsEffectOverlay.decorView.addView(reactionsEffectOverlay.windowView);
}
cell.invalidate();
if (cell.getCurrentMessagesGroup() != null && cell.getParent() != null) {
((View) cell.getParent()).invalidate();
}
}
use of org.telegram.ui.ChatActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class SearchViewPager method goToMessage.
public void goToMessage(MessageObject messageObject) {
Bundle args = new Bundle();
long dialogId = messageObject.getDialogId();
if (DialogObject.isEncryptedDialog(dialogId)) {
args.putInt("enc_id", DialogObject.getEncryptedChatId(dialogId));
} else if (DialogObject.isUserDialog(dialogId)) {
args.putLong("user_id", dialogId);
} else {
TLRPC.Chat chat = AccountInstance.getInstance(currentAccount).getMessagesController().getChat(-dialogId);
if (chat != null && chat.migrated_to != null) {
args.putLong("migrated_to", dialogId);
dialogId = -chat.migrated_to.channel_id;
}
args.putLong("chat_id", -dialogId);
}
args.putInt("message_id", messageObject.getId());
parent.presentFragment(new ChatActivity(args));
showActionMode(false);
}
Aggregations