Search in sources :

Example 6 with ProfileActivity

use of org.telegram.ui.ProfileActivity in project Telegram-FOSS by Telegram-FOSS-Team.

the class BackButtonMenu method goToPulledDialog.

public static void goToPulledDialog(BaseFragment fragment, PulledDialog dialog) {
    if (dialog == null) {
        return;
    }
    if (dialog.activity == ChatActivity.class) {
        Bundle bundle = new Bundle();
        if (dialog.chat != null) {
            bundle.putLong("chat_id", dialog.chat.id);
        } else if (dialog.user != null) {
            bundle.putLong("user_id", dialog.user.id);
        }
        bundle.putInt("dialog_folder_id", dialog.folderId);
        bundle.putInt("dialog_filter_id", dialog.filterId);
        fragment.presentFragment(new ChatActivity(bundle), true);
    } else if (dialog.activity == ProfileActivity.class) {
        Bundle bundle = new Bundle();
        bundle.putLong("dialog_id", dialog.dialogId);
        fragment.presentFragment(new ProfileActivity(bundle), true);
    }
}
Also used : ProfileActivity(org.telegram.ui.ProfileActivity) ChatActivity(org.telegram.ui.ChatActivity) Bundle(android.os.Bundle)

Example 7 with ProfileActivity

use of org.telegram.ui.ProfileActivity in project Telegram-FOSS by Telegram-FOSS-Team.

the class SharedMediaLayout method onActionBarItemClick.

public void onActionBarItemClick(View v, int id) {
    if (id == delete) {
        TLRPC.Chat currentChat = null;
        TLRPC.User currentUser = null;
        TLRPC.EncryptedChat currentEncryptedChat = null;
        if (DialogObject.isEncryptedDialog(dialog_id)) {
            currentEncryptedChat = profileActivity.getMessagesController().getEncryptedChat(DialogObject.getEncryptedChatId(dialog_id));
        } else if (DialogObject.isUserDialog(dialog_id)) {
            currentUser = profileActivity.getMessagesController().getUser(dialog_id);
        } else {
            currentChat = profileActivity.getMessagesController().getChat(-dialog_id);
        }
        AlertsCreator.createDeleteMessagesAlert(profileActivity, currentUser, currentChat, currentEncryptedChat, null, mergeDialogId, null, selectedFiles, null, false, 1, () -> {
            showActionMode(false);
            actionBar.closeSearchField();
            cantDeleteMessagesCount = 0;
        }, null, null);
    } else if (id == forward) {
        if (info != null) {
            TLRPC.Chat chat = profileActivity.getMessagesController().getChat(info.id);
            if (profileActivity.getMessagesController().isChatNoForwards(chat)) {
                if (fwdRestrictedHint != null) {
                    fwdRestrictedHint.setText(ChatObject.isChannel(chat) && !chat.megagroup ? LocaleController.getString("ForwardsRestrictedInfoChannel", R.string.ForwardsRestrictedInfoChannel) : LocaleController.getString("ForwardsRestrictedInfoGroup", R.string.ForwardsRestrictedInfoGroup));
                    fwdRestrictedHint.showForView(v, true);
                }
                return;
            }
        }
        if (hasNoforwardsMessage()) {
            if (fwdRestrictedHint != null) {
                fwdRestrictedHint.setText(LocaleController.getString("ForwardsRestrictedInfoBot", R.string.ForwardsRestrictedInfoBot));
                fwdRestrictedHint.showForView(v, true);
            }
            return;
        }
        Bundle args = new Bundle();
        args.putBoolean("onlySelect", true);
        args.putInt("dialogsType", 3);
        DialogsActivity fragment = new DialogsActivity(args);
        fragment.setDelegate((fragment1, dids, message, param) -> {
            ArrayList<MessageObject> fmessages = new ArrayList<>();
            for (int a = 1; a >= 0; a--) {
                ArrayList<Integer> ids = new ArrayList<>();
                for (int b = 0; b < selectedFiles[a].size(); b++) {
                    ids.add(selectedFiles[a].keyAt(b));
                }
                Collections.sort(ids);
                for (Integer id1 : ids) {
                    if (id1 > 0) {
                        fmessages.add(selectedFiles[a].get(id1));
                    }
                }
                selectedFiles[a].clear();
            }
            cantDeleteMessagesCount = 0;
            showActionMode(false);
            if (dids.size() > 1 || dids.get(0) == profileActivity.getUserConfig().getClientUserId() || message != null) {
                updateRowsSelection();
                for (int a = 0; a < dids.size(); a++) {
                    long did = dids.get(a);
                    if (message != null) {
                        profileActivity.getSendMessagesHelper().sendMessage(message.toString(), did, null, null, null, true, null, null, null, true, 0, null);
                    }
                    profileActivity.getSendMessagesHelper().sendMessage(fmessages, did, false, false, true, 0);
                }
                fragment1.finishFragment();
            } else {
                long did = dids.get(0);
                Bundle args1 = new Bundle();
                args1.putBoolean("scrollToTopOnResume", true);
                if (DialogObject.isEncryptedDialog(did)) {
                    args1.putInt("enc_id", DialogObject.getEncryptedChatId(did));
                } else {
                    if (DialogObject.isUserDialog(did)) {
                        args1.putLong("user_id", did);
                    } else {
                        args1.putLong("chat_id", -did);
                    }
                    if (!profileActivity.getMessagesController().checkCanOpenChat(args1, fragment1)) {
                        return;
                    }
                }
                profileActivity.getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
                ChatActivity chatActivity = new ChatActivity(args1);
                fragment1.presentFragment(chatActivity, true);
                chatActivity.showFieldPanelForForward(true, fmessages);
            }
        });
        profileActivity.presentFragment(fragment);
    } else if (id == gotochat) {
        if (selectedFiles[0].size() + selectedFiles[1].size() != 1) {
            return;
        }
        MessageObject messageObject = selectedFiles[selectedFiles[0].size() == 1 ? 0 : 1].valueAt(0);
        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 = profileActivity.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());
        args.putBoolean("need_remove_previous_same_chat_activity", false);
        profileActivity.presentFragment(new ChatActivity(args), false);
    }
}
Also used : Bundle(android.os.Bundle) SharedDocumentCell(org.telegram.ui.Cells.SharedDocumentCell) ProfileActivity(org.telegram.ui.ProfileActivity) NonNull(androidx.annotation.NonNull) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) Drawable(android.graphics.drawable.Drawable) ActionBarMenuSubItem(org.telegram.ui.ActionBar.ActionBarMenuSubItem) DialogsActivity(org.telegram.ui.DialogsActivity) Canvas(android.graphics.Canvas) ForegroundColorSpan(android.text.style.ForegroundColorSpan) ContextCompat(androidx.core.content.ContextCompat) Surface(android.view.Surface) Interpolator(android.view.animation.Interpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) NotificationCenter(org.telegram.messenger.NotificationCenter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerCell(org.telegram.ui.Cells.DividerCell) FileLoader(org.telegram.messenger.FileLoader) ChatActivity(org.telegram.ui.ChatActivity) Visibility(android.transition.Visibility) ContextLinkCell(org.telegram.ui.Cells.ContextLinkCell) ArrayList(java.util.ArrayList) SpannableStringBuilder(android.text.SpannableStringBuilder) Log(com.google.android.exoplayer2.util.Log) TLRPC(org.telegram.tgnet.TLRPC) TransitionValues(android.transition.TransitionValues) CalendarActivity(org.telegram.ui.CalendarActivity) ProfileSearchCell(org.telegram.ui.Cells.ProfileSearchCell) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) UserCell(org.telegram.ui.Cells.UserCell) R(org.telegram.messenger.R) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) TextUtils(android.text.TextUtils) ManageChatUserCell(org.telegram.ui.Cells.ManageChatUserCell) Gravity(android.view.Gravity) SparseBooleanArray(android.util.SparseBooleanArray) UserObject(org.telegram.messenger.UserObject) TypedValue(android.util.TypedValue) GraySectionCell(org.telegram.ui.Cells.GraySectionCell) Configuration(android.content.res.Configuration) ArticleViewer(org.telegram.ui.ArticleViewer) AccessibilityNodeInfoCompat(androidx.core.view.accessibility.AccessibilityNodeInfoCompat) ChatObject(org.telegram.messenger.ChatObject) EditText(android.widget.EditText) ValueAnimator(android.animation.ValueAnimator) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Rect(android.graphics.Rect) LinearLayout(android.widget.LinearLayout) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) WindowManager(android.view.WindowManager) AndroidUtilities(org.telegram.messenger.AndroidUtilities) Animator(android.animation.Animator) TransitionManager(android.transition.TransitionManager) ViewConfiguration(android.view.ViewConfiguration) ApplicationLoader(org.telegram.messenger.ApplicationLoader) SharedPhotoVideoCell(org.telegram.ui.Cells.SharedPhotoVideoCell) MediaController(org.telegram.messenger.MediaController) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TransitionSet(android.transition.TransitionSet) Utilities(org.telegram.messenger.Utilities) SharedMediaSectionCell(org.telegram.ui.Cells.SharedMediaSectionCell) ObjectAnimator(android.animation.ObjectAnimator) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ChatActionCell(org.telegram.ui.Cells.ChatActionCell) PorterDuff(android.graphics.PorterDuff) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ViewGroup(android.view.ViewGroup) SparseArray(android.util.SparseArray) UserConfig(org.telegram.messenger.UserConfig) TextView(android.widget.TextView) SearchAdapterHelper(org.telegram.ui.Adapters.SearchAdapterHelper) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) Context(android.content.Context) Spanned(android.text.Spanned) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) Theme(org.telegram.ui.ActionBar.Theme) LocaleController(org.telegram.messenger.LocaleController) HashMap(java.util.HashMap) ChangeBounds(android.transition.ChangeBounds) SharedPhotoVideoCell2(org.telegram.ui.Cells.SharedPhotoVideoCell2) HashSet(java.util.HashSet) VelocityTracker(android.view.VelocityTracker) PhotoViewer(org.telegram.ui.PhotoViewer) MotionEvent(android.view.MotionEvent) ActionBar(org.telegram.ui.ActionBar.ActionBar) TLObject(org.telegram.tgnet.TLObject) SharedLinkCell(org.telegram.ui.Cells.SharedLinkCell) AnimatorSet(android.animation.AnimatorSet) MessageObject(org.telegram.messenger.MessageObject) SharedConfig(org.telegram.messenger.SharedConfig) MediaDataController(org.telegram.messenger.MediaDataController) Build(android.os.Build) Browser(org.telegram.messenger.browser.Browser) DialogObject(org.telegram.messenger.DialogObject) FileLog(org.telegram.messenger.FileLog) MessagesController(org.telegram.messenger.MessagesController) SharedAudioCell(org.telegram.ui.Cells.SharedAudioCell) MEDIA_PHOTOVIDEO(org.telegram.messenger.MediaDataController.MEDIA_PHOTOVIDEO) Bitmap(android.graphics.Bitmap) ViewTreeObserver(android.view.ViewTreeObserver) Activity(android.app.Activity) ImageReceiver(org.telegram.messenger.ImageReceiver) Collections(java.util.Collections) LoadingCell(org.telegram.ui.Cells.LoadingCell) ChatActivity(org.telegram.ui.ChatActivity) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) DialogsActivity(org.telegram.ui.DialogsActivity) TLRPC(org.telegram.tgnet.TLRPC) MessageObject(org.telegram.messenger.MessageObject)

Example 8 with ProfileActivity

use of org.telegram.ui.ProfileActivity in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatAvatarContainer method openProfile.

private void openProfile(boolean byAvatar) {
    if (byAvatar && (AndroidUtilities.isTablet() || AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y || !avatarImageView.getImageReceiver().hasNotThumb())) {
        byAvatar = false;
    }
    TLRPC.User user = parentFragment.getCurrentUser();
    TLRPC.Chat chat = parentFragment.getCurrentChat();
    ImageReceiver imageReceiver = avatarImageView.getImageReceiver();
    String key = imageReceiver.getImageKey();
    ImageLoader imageLoader = ImageLoader.getInstance();
    if (key != null && !imageLoader.isInMemCache(key, false)) {
        Drawable drawable = imageReceiver.getDrawable();
        if (drawable instanceof BitmapDrawable) {
            imageLoader.putImageToCache((BitmapDrawable) drawable, key, false);
        }
    }
    if (user != null) {
        Bundle args = new Bundle();
        if (UserObject.isUserSelf(user)) {
            args.putLong("dialog_id", parentFragment.getDialogId());
            int[] media = new int[MediaDataController.MEDIA_TYPES_COUNT];
            System.arraycopy(sharedMediaPreloader.getLastMediaCount(), 0, media, 0, media.length);
            MediaActivity fragment = new MediaActivity(args, sharedMediaPreloader);
            fragment.setChatInfo(parentFragment.getCurrentChatInfo());
            parentFragment.presentFragment(fragment);
        } else {
            args.putLong("user_id", user.id);
            args.putBoolean("reportSpam", parentFragment.hasReportSpam());
            if (timeItem != null) {
                args.putLong("dialog_id", parentFragment.getDialogId());
            }
            args.putInt("actionBarColor", getThemedColor(Theme.key_actionBarDefault));
            ProfileActivity fragment = new ProfileActivity(args, sharedMediaPreloader);
            fragment.setUserInfo(parentFragment.getCurrentUserInfo());
            fragment.setPlayProfileAnimation(byAvatar ? 2 : 1);
            parentFragment.presentFragment(fragment);
        }
    } else if (chat != null) {
        Bundle args = new Bundle();
        args.putLong("chat_id", chat.id);
        ProfileActivity fragment = new ProfileActivity(args, sharedMediaPreloader);
        fragment.setChatInfo(parentFragment.getCurrentChatInfo());
        fragment.setPlayProfileAnimation(byAvatar ? 2 : 1);
        parentFragment.presentFragment(fragment);
    }
}
Also used : ImageReceiver(org.telegram.messenger.ImageReceiver) ProfileActivity(org.telegram.ui.ProfileActivity) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageLoader(org.telegram.messenger.ImageLoader) TLRPC(org.telegram.tgnet.TLRPC)

Aggregations

ProfileActivity (org.telegram.ui.ProfileActivity)8 ChatActivity (org.telegram.ui.ChatActivity)7 Bundle (android.os.Bundle)6 TLRPC (org.telegram.tgnet.TLRPC)6 Drawable (android.graphics.drawable.Drawable)4 Context (android.content.Context)3 BitmapDrawable (android.graphics.drawable.BitmapDrawable)3 SpannableStringBuilder (android.text.SpannableStringBuilder)3 View (android.view.View)3 BaseFragment (org.telegram.ui.ActionBar.BaseFragment)3 Animator (android.animation.Animator)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 ValueAnimator (android.animation.ValueAnimator)2 Bitmap (android.graphics.Bitmap)2 Canvas (android.graphics.Canvas)2 PorterDuff (android.graphics.PorterDuff)2 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)2 Rect (android.graphics.Rect)2 Build (android.os.Build)2 Spanned (android.text.Spanned)2