Search in sources :

Example 1 with BaseFragment

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

the class AlertsCreator method createDeleteMessagesAlert.

public static void createDeleteMessagesAlert(BaseFragment fragment, TLRPC.User user, TLRPC.Chat chat, TLRPC.EncryptedChat encryptedChat, TLRPC.ChatFull chatInfo, long mergeDialogId, MessageObject selectedMessage, SparseArray<MessageObject>[] selectedMessages, MessageObject.GroupedMessages selectedGroup, boolean scheduled, int loadParticipant, Runnable onDelete, Runnable hideDim, Theme.ResourcesProvider resourcesProvider) {
    if (fragment == null || user == null && chat == null && encryptedChat == null) {
        return;
    }
    Activity activity = fragment.getParentActivity();
    if (activity == null) {
        return;
    }
    int currentAccount = fragment.getCurrentAccount();
    AlertDialog.Builder builder = new AlertDialog.Builder(activity, resourcesProvider);
    builder.setDimEnabled(hideDim == null);
    int count;
    if (selectedGroup != null) {
        count = selectedGroup.messages.size();
    } else if (selectedMessage != null) {
        count = 1;
    } else {
        count = selectedMessages[0].size() + selectedMessages[1].size();
    }
    long dialogId;
    if (encryptedChat != null) {
        dialogId = DialogObject.makeEncryptedDialogId(encryptedChat.id);
    } else if (user != null) {
        dialogId = user.id;
    } else {
        dialogId = -chat.id;
    }
    int currentDate = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
    boolean hasNonDiceMessages = false;
    if (selectedMessage != null) {
        hasNonDiceMessages = !selectedMessage.isDice() || Math.abs(currentDate - selectedMessage.messageOwner.date) > 24 * 60 * 60;
    } else {
        for (int a = 0; a < 2; a++) {
            for (int b = 0; b < selectedMessages[a].size(); b++) {
                MessageObject msg = selectedMessages[a].valueAt(b);
                if (!msg.isDice() || Math.abs(currentDate - msg.messageOwner.date) > 24 * 60 * 60) {
                    hasNonDiceMessages = true;
                    break;
                }
            }
        }
    }
    final boolean[] checks = new boolean[3];
    final boolean[] deleteForAll = new boolean[1];
    TLRPC.User actionUser = null;
    TLRPC.Chat actionChat = null;
    boolean canRevokeInbox = user != null && MessagesController.getInstance(currentAccount).canRevokePmInbox;
    int revokeTimeLimit;
    if (user != null) {
        revokeTimeLimit = MessagesController.getInstance(currentAccount).revokeTimePmLimit;
    } else {
        revokeTimeLimit = MessagesController.getInstance(currentAccount).revokeTimeLimit;
    }
    boolean hasDeleteForAllCheck = false;
    boolean hasNotOut = false;
    int myMessagesCount = 0;
    boolean canDeleteInbox = encryptedChat == null && user != null && canRevokeInbox && revokeTimeLimit == 0x7fffffff;
    if (chat != null && chat.megagroup && !scheduled) {
        boolean canBan = ChatObject.canBlockUsers(chat);
        if (selectedMessage != null) {
            if (selectedMessage.messageOwner.action == null || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionEmpty || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatDeleteUser || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByLink || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatAddUser) {
                if (selectedMessage.messageOwner.from_id.user_id != 0) {
                    actionUser = MessagesController.getInstance(currentAccount).getUser(selectedMessage.messageOwner.from_id.user_id);
                } else if (selectedMessage.messageOwner.from_id.channel_id != 0) {
                    actionChat = MessagesController.getInstance(currentAccount).getChat(selectedMessage.messageOwner.from_id.channel_id);
                } else if (selectedMessage.messageOwner.from_id.chat_id != 0) {
                    actionChat = MessagesController.getInstance(currentAccount).getChat(selectedMessage.messageOwner.from_id.chat_id);
                }
            }
            boolean hasOutgoing = !selectedMessage.isSendError() && selectedMessage.getDialogId() == mergeDialogId && (selectedMessage.messageOwner.action == null || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionEmpty) && selectedMessage.isOut() && (currentDate - selectedMessage.messageOwner.date) <= revokeTimeLimit;
            if (hasOutgoing) {
                myMessagesCount++;
            }
        } else {
            long from_id = -1;
            for (int a = 1; a >= 0; a--) {
                long channelId = 0;
                for (int b = 0; b < selectedMessages[a].size(); b++) {
                    MessageObject msg = selectedMessages[a].valueAt(b);
                    if (from_id == -1) {
                        from_id = msg.getFromChatId();
                    }
                    if (from_id < 0 || from_id != msg.getSenderId()) {
                        from_id = -2;
                        break;
                    }
                }
                if (from_id == -2) {
                    break;
                }
            }
            for (int a = 1; a >= 0; a--) {
                for (int b = 0; b < selectedMessages[a].size(); b++) {
                    MessageObject msg = selectedMessages[a].valueAt(b);
                    if (a == 1) {
                        if (msg.isOut() && msg.messageOwner.action == null) {
                            if ((currentDate - msg.messageOwner.date) <= revokeTimeLimit) {
                                myMessagesCount++;
                            }
                        }
                    }
                }
            }
            if (from_id != -1) {
                actionUser = MessagesController.getInstance(currentAccount).getUser(from_id);
            }
        }
        if ((actionUser != null && actionUser.id != UserConfig.getInstance(currentAccount).getClientUserId()) || (actionChat != null && !ChatObject.hasAdminRights(actionChat))) {
            if (loadParticipant == 1 && !chat.creator && actionUser != null) {
                final AlertDialog[] progressDialog = new AlertDialog[] { new AlertDialog(activity, 3) };
                TLRPC.TL_channels_getParticipant req = new TLRPC.TL_channels_getParticipant();
                req.channel = MessagesController.getInputChannel(chat);
                req.participant = MessagesController.getInputPeer(actionUser);
                int requestId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                    try {
                        progressDialog[0].dismiss();
                    } catch (Throwable ignore) {
                    }
                    progressDialog[0] = null;
                    int loadType = 2;
                    if (response != null) {
                        TLRPC.TL_channels_channelParticipant participant = (TLRPC.TL_channels_channelParticipant) response;
                        if (!(participant.participant instanceof TLRPC.TL_channelParticipantAdmin || participant.participant instanceof TLRPC.TL_channelParticipantCreator)) {
                            loadType = 0;
                        }
                    } else if (error != null && "USER_NOT_PARTICIPANT".equals(error.text)) {
                        loadType = 0;
                    }
                    createDeleteMessagesAlert(fragment, user, chat, encryptedChat, chatInfo, mergeDialogId, selectedMessage, selectedMessages, selectedGroup, scheduled, loadType, onDelete, hideDim, resourcesProvider);
                }));
                AndroidUtilities.runOnUIThread(() -> {
                    if (progressDialog[0] == null) {
                        return;
                    }
                    progressDialog[0].setOnCancelListener(dialog -> ConnectionsManager.getInstance(currentAccount).cancelRequest(requestId, true));
                    fragment.showDialog(progressDialog[0]);
                }, 1000);
                return;
            }
            FrameLayout frameLayout = new FrameLayout(activity);
            int num = 0;
            String name = actionUser != null ? ContactsController.formatName(actionUser.first_name, actionUser.last_name) : actionChat.title;
            for (int a = 0; a < 3; a++) {
                if ((loadParticipant == 2 || !canBan) && a == 0) {
                    continue;
                }
                CheckBoxCell cell = new CheckBoxCell(activity, 1, resourcesProvider);
                cell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
                cell.setTag(a);
                if (a == 0) {
                    cell.setText(LocaleController.getString("DeleteBanUser", R.string.DeleteBanUser), "", false, false);
                } else if (a == 1) {
                    cell.setText(LocaleController.getString("DeleteReportSpam", R.string.DeleteReportSpam), "", false, false);
                } else {
                    cell.setText(LocaleController.formatString("DeleteAllFrom", R.string.DeleteAllFrom, name), "", false, false);
                }
                cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
                frameLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 0, 48 * num, 0, 0));
                cell.setOnClickListener(v -> {
                    if (!v.isEnabled()) {
                        return;
                    }
                    CheckBoxCell cell13 = (CheckBoxCell) v;
                    Integer num1 = (Integer) cell13.getTag();
                    checks[num1] = !checks[num1];
                    cell13.setChecked(checks[num1], true);
                });
                num++;
            }
            builder.setView(frameLayout);
        } else if (!hasNotOut && myMessagesCount > 0 && hasNonDiceMessages) {
            hasDeleteForAllCheck = true;
            FrameLayout frameLayout = new FrameLayout(activity);
            CheckBoxCell cell = new CheckBoxCell(activity, 1, resourcesProvider);
            cell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
            if (chat != null && hasNotOut) {
                cell.setText(LocaleController.getString("DeleteForAll", R.string.DeleteForAll), "", false, false);
            } else {
                cell.setText(LocaleController.getString("DeleteMessagesOption", R.string.DeleteMessagesOption), "", false, false);
            }
            cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
            frameLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 0));
            cell.setOnClickListener(v -> {
                CheckBoxCell cell12 = (CheckBoxCell) v;
                deleteForAll[0] = !deleteForAll[0];
                cell12.setChecked(deleteForAll[0], true);
            });
            builder.setView(frameLayout);
            builder.setCustomViewOffset(9);
        } else {
            actionUser = null;
        }
    } else if (!scheduled && !ChatObject.isChannel(chat) && encryptedChat == null) {
        if (user != null && user.id != UserConfig.getInstance(currentAccount).getClientUserId() && (!user.bot || user.support) || chat != null) {
            if (selectedMessage != null) {
                boolean hasOutgoing = !selectedMessage.isSendError() && (selectedMessage.messageOwner.action == null || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionEmpty || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionPhoneCall || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionGeoProximityReached || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionSetChatTheme) && (selectedMessage.isOut() || canRevokeInbox || ChatObject.hasAdminRights(chat)) && (currentDate - selectedMessage.messageOwner.date) <= revokeTimeLimit;
                if (hasOutgoing) {
                    myMessagesCount++;
                }
                hasNotOut = !selectedMessage.isOut();
            } else {
                for (int a = 1; a >= 0; a--) {
                    for (int b = 0; b < selectedMessages[a].size(); b++) {
                        MessageObject msg = selectedMessages[a].valueAt(b);
                        if (!(msg.messageOwner.action == null || msg.messageOwner.action instanceof TLRPC.TL_messageActionEmpty || msg.messageOwner.action instanceof TLRPC.TL_messageActionPhoneCall || msg.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage || msg.messageOwner.action instanceof TLRPC.TL_messageActionGeoProximityReached)) {
                            continue;
                        }
                        if ((msg.isOut() || canRevokeInbox) || chat != null && ChatObject.canBlockUsers(chat)) {
                            if ((currentDate - msg.messageOwner.date) <= revokeTimeLimit) {
                                myMessagesCount++;
                                if (!hasNotOut && !msg.isOut()) {
                                    hasNotOut = true;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (myMessagesCount > 0 && hasNonDiceMessages && (user == null || !UserObject.isDeleted(user))) {
            hasDeleteForAllCheck = true;
            FrameLayout frameLayout = new FrameLayout(activity);
            CheckBoxCell cell = new CheckBoxCell(activity, 1, resourcesProvider);
            cell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
            if (canDeleteInbox) {
                cell.setText(LocaleController.formatString("DeleteMessagesOptionAlso", R.string.DeleteMessagesOptionAlso, UserObject.getFirstName(user)), "", false, false);
            } else if (chat != null && (hasNotOut || myMessagesCount == count)) {
                cell.setText(LocaleController.getString("DeleteForAll", R.string.DeleteForAll), "", false, false);
            } else {
                cell.setText(LocaleController.getString("DeleteMessagesOption", R.string.DeleteMessagesOption), "", false, false);
            }
            cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
            frameLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 0));
            cell.setOnClickListener(v -> {
                CheckBoxCell cell1 = (CheckBoxCell) v;
                deleteForAll[0] = !deleteForAll[0];
                cell1.setChecked(deleteForAll[0], true);
            });
            builder.setView(frameLayout);
            builder.setCustomViewOffset(9);
        }
    }
    final TLRPC.User userFinal = actionUser;
    final TLRPC.Chat chatFinal = actionChat;
    builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
        ArrayList<Integer> ids = null;
        if (selectedMessage != null) {
            ids = new ArrayList<>();
            ArrayList<Long> random_ids = null;
            if (selectedGroup != null) {
                for (int a = 0; a < selectedGroup.messages.size(); a++) {
                    MessageObject messageObject = selectedGroup.messages.get(a);
                    ids.add(messageObject.getId());
                    if (encryptedChat != null && messageObject.messageOwner.random_id != 0 && messageObject.type != 10) {
                        if (random_ids == null) {
                            random_ids = new ArrayList<>();
                        }
                        random_ids.add(messageObject.messageOwner.random_id);
                    }
                }
            } else {
                ids.add(selectedMessage.getId());
                if (encryptedChat != null && selectedMessage.messageOwner.random_id != 0 && selectedMessage.type != 10) {
                    random_ids = new ArrayList<>();
                    random_ids.add(selectedMessage.messageOwner.random_id);
                }
            }
            MessagesController.getInstance(currentAccount).deleteMessages(ids, random_ids, encryptedChat, dialogId, deleteForAll[0], scheduled);
        } else {
            for (int a = 1; a >= 0; a--) {
                ids = new ArrayList<>();
                for (int b = 0; b < selectedMessages[a].size(); b++) {
                    ids.add(selectedMessages[a].keyAt(b));
                }
                ArrayList<Long> random_ids = null;
                long channelId = 0;
                if (!ids.isEmpty()) {
                    MessageObject msg = selectedMessages[a].get(ids.get(0));
                    if (msg.messageOwner.peer_id.channel_id != 0) {
                        channelId = msg.messageOwner.peer_id.channel_id;
                    }
                }
                if (encryptedChat != null) {
                    random_ids = new ArrayList<>();
                    for (int b = 0; b < selectedMessages[a].size(); b++) {
                        MessageObject msg = selectedMessages[a].valueAt(b);
                        if (msg.messageOwner.random_id != 0 && msg.type != 10) {
                            random_ids.add(msg.messageOwner.random_id);
                        }
                    }
                }
                MessagesController.getInstance(currentAccount).deleteMessages(ids, random_ids, encryptedChat, dialogId, deleteForAll[0], scheduled);
                selectedMessages[a].clear();
            }
        }
        if (userFinal != null || chatFinal != null) {
            if (checks[0]) {
                MessagesController.getInstance(currentAccount).deleteParticipantFromChat(chat.id, userFinal, chatFinal, chatInfo, false, false);
            }
            if (checks[1]) {
                TLRPC.TL_channels_reportSpam req = new TLRPC.TL_channels_reportSpam();
                req.channel = MessagesController.getInputChannel(chat);
                if (userFinal != null) {
                    req.participant = MessagesController.getInputPeer(userFinal);
                } else {
                    req.participant = MessagesController.getInputPeer(chatFinal);
                }
                req.id = ids;
                ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
                });
            }
            if (checks[2]) {
                MessagesController.getInstance(currentAccount).deleteUserChannelHistory(chat, userFinal, chatFinal, 0);
            }
        }
        if (onDelete != null) {
            onDelete.run();
        }
    });
    if (count == 1) {
        builder.setTitle(LocaleController.getString("DeleteSingleMessagesTitle", R.string.DeleteSingleMessagesTitle));
    } else {
        builder.setTitle(LocaleController.formatString("DeleteMessagesTitle", R.string.DeleteMessagesTitle, LocaleController.formatPluralString("messages", count)));
    }
    if (chat != null && hasNotOut) {
        if (hasDeleteForAllCheck && myMessagesCount != count) {
            builder.setMessage(LocaleController.formatString("DeleteMessagesTextGroupPart", R.string.DeleteMessagesTextGroupPart, LocaleController.formatPluralString("messages", myMessagesCount)));
        } else if (count == 1) {
            builder.setMessage(LocaleController.getString("AreYouSureDeleteSingleMessage", R.string.AreYouSureDeleteSingleMessage));
        } else {
            builder.setMessage(LocaleController.getString("AreYouSureDeleteFewMessages", R.string.AreYouSureDeleteFewMessages));
        }
    } else if (hasDeleteForAllCheck && !canDeleteInbox && myMessagesCount != count) {
        if (chat != null) {
            builder.setMessage(LocaleController.formatString("DeleteMessagesTextGroup", R.string.DeleteMessagesTextGroup, LocaleController.formatPluralString("messages", myMessagesCount)));
        } else {
            builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("DeleteMessagesText", R.string.DeleteMessagesText, LocaleController.formatPluralString("messages", myMessagesCount), UserObject.getFirstName(user))));
        }
    } else {
        if (chat != null && chat.megagroup && !scheduled) {
            if (count == 1) {
                builder.setMessage(LocaleController.getString("AreYouSureDeleteSingleMessageMega", R.string.AreYouSureDeleteSingleMessageMega));
            } else {
                builder.setMessage(LocaleController.getString("AreYouSureDeleteFewMessagesMega", R.string.AreYouSureDeleteFewMessagesMega));
            }
        } else {
            if (count == 1) {
                builder.setMessage(LocaleController.getString("AreYouSureDeleteSingleMessage", R.string.AreYouSureDeleteSingleMessage));
            } else {
                builder.setMessage(LocaleController.getString("AreYouSureDeleteFewMessages", R.string.AreYouSureDeleteFewMessages));
            }
        }
    }
    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    builder.setOnPreDismissListener(di -> {
        if (hideDim != null) {
            hideDim.run();
        }
    });
    AlertDialog dialog = builder.create();
    fragment.showDialog(dialog);
    TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
    if (button != null) {
        button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
    }
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) Arrays(java.util.Arrays) Bundle(android.os.Bundle) SvgHelper(org.telegram.messenger.SvgHelper) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) Drawable(android.graphics.drawable.Drawable) Manifest(android.Manifest) NotificationsController(org.telegram.messenger.NotificationsController) CacheControlActivity(org.telegram.ui.CacheControlActivity) NotificationCenter(org.telegram.messenger.NotificationCenter) Outline(android.graphics.Outline) HapticFeedbackConstants(android.view.HapticFeedbackConstants) CountDownLatch(java.util.concurrent.CountDownLatch) LaunchActivity(org.telegram.ui.LaunchActivity) Html(android.text.Html) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) InputFilter(android.text.InputFilter) TextWatcher(android.text.TextWatcher) ChatActivity(org.telegram.ui.ChatActivity) Dialog(android.app.Dialog) Editable(android.text.Editable) ArrayList(java.util.ArrayList) SpannableStringBuilder(android.text.SpannableStringBuilder) ThemePreviewActivity(org.telegram.ui.ThemePreviewActivity) Calendar(java.util.Calendar) TLRPC(org.telegram.tgnet.TLRPC) GradientDrawable(android.graphics.drawable.GradientDrawable) Toast(android.widget.Toast) Settings(android.provider.Settings) NotificationsCustomSettingsActivity(org.telegram.ui.NotificationsCustomSettingsActivity) URLSpan(android.text.style.URLSpan) SpannableString(android.text.SpannableString) R(org.telegram.messenger.R) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) TextUtils(android.text.TextUtils) Gravity(android.view.Gravity) UserObject(org.telegram.messenger.UserObject) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) ContactsController(org.telegram.messenger.ContactsController) MessagesStorage(org.telegram.messenger.MessagesStorage) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) VoIPHelper(org.telegram.ui.Components.voip.VoIPHelper) EditText(android.widget.EditText) ProfileNotificationsActivity(org.telegram.ui.ProfileNotificationsActivity) RequiresApi(androidx.annotation.RequiresApi) Rect(android.graphics.Rect) LinearLayout(android.widget.LinearLayout) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) PackageManager(android.content.pm.PackageManager) Spannable(android.text.Spannable) WindowManager(android.view.WindowManager) AccountInstance(org.telegram.messenger.AccountInstance) AndroidUtilities(org.telegram.messenger.AndroidUtilities) LanguageSelectActivity(org.telegram.ui.LanguageSelectActivity) CheckBoxCell(org.telegram.ui.Cells.CheckBoxCell) ApplicationLoader(org.telegram.messenger.ApplicationLoader) Locale(java.util.Locale) View(android.view.View) Button(android.widget.Button) TextColorCell(org.telegram.ui.Cells.TextColorCell) Utilities(org.telegram.messenger.Utilities) TooManyCommunitiesActivity(org.telegram.ui.TooManyCommunitiesActivity) InputType(android.text.InputType) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) BitmapDrawable(android.graphics.drawable.BitmapDrawable) PorterDuff(android.graphics.PorterDuff) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) SparseArray(android.util.SparseArray) UserConfig(org.telegram.messenger.UserConfig) List(java.util.List) TextView(android.widget.TextView) SecretChatHelper(org.telegram.messenger.SecretChatHelper) EditorInfo(android.view.inputmethod.EditorInfo) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) Context(android.content.Context) IDN(java.net.IDN) Spanned(android.text.Spanned) KeyEvent(android.view.KeyEvent) Theme(org.telegram.ui.ActionBar.Theme) ViewOutlineProvider(android.view.ViewOutlineProvider) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) HashMap(java.util.HashMap) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) TLObject(org.telegram.tgnet.TLObject) MessageObject(org.telegram.messenger.MessageObject) SharedConfig(org.telegram.messenger.SharedConfig) BuildVars(org.telegram.messenger.BuildVars) NotificationsSettingsActivity(org.telegram.ui.NotificationsSettingsActivity) Build(android.os.Build) SerializedData(org.telegram.tgnet.SerializedData) DialogInterface(android.content.DialogInterface) Browser(org.telegram.messenger.browser.Browser) LoginActivity(org.telegram.ui.LoginActivity) DialogObject(org.telegram.messenger.DialogObject) FileLog(org.telegram.messenger.FileLog) AccountSelectCell(org.telegram.ui.Cells.AccountSelectCell) MessagesController(org.telegram.messenger.MessagesController) Color(android.graphics.Color) Base64(android.util.Base64) RadioColorCell(org.telegram.ui.Cells.RadioColorCell) Vibrator(android.os.Vibrator) Activity(android.app.Activity) SpannableStringBuilder(android.text.SpannableStringBuilder) CacheControlActivity(org.telegram.ui.CacheControlActivity) LaunchActivity(org.telegram.ui.LaunchActivity) ChatActivity(org.telegram.ui.ChatActivity) ThemePreviewActivity(org.telegram.ui.ThemePreviewActivity) NotificationsCustomSettingsActivity(org.telegram.ui.NotificationsCustomSettingsActivity) ProfileNotificationsActivity(org.telegram.ui.ProfileNotificationsActivity) LanguageSelectActivity(org.telegram.ui.LanguageSelectActivity) TooManyCommunitiesActivity(org.telegram.ui.TooManyCommunitiesActivity) NotificationsSettingsActivity(org.telegram.ui.NotificationsSettingsActivity) LoginActivity(org.telegram.ui.LoginActivity) Activity(android.app.Activity) SpannableString(android.text.SpannableString) TLRPC(org.telegram.tgnet.TLRPC) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) CheckBoxCell(org.telegram.ui.Cells.CheckBoxCell) FrameLayout(android.widget.FrameLayout) MessageObject(org.telegram.messenger.MessageObject)

Example 2 with BaseFragment

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

the class AlertsCreator method createClearOrDeleteDialogAlert.

public static void createClearOrDeleteDialogAlert(BaseFragment fragment, boolean clear, boolean admin, boolean second, TLRPC.Chat chat, TLRPC.User user, boolean secret, boolean checkDeleteForAll, MessagesStorage.BooleanCallback onProcessRunnable, Theme.ResourcesProvider resourcesProvider) {
    if (fragment == null || fragment.getParentActivity() == null || chat == null && user == null) {
        return;
    }
    int account = fragment.getCurrentAccount();
    Context context = fragment.getParentActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(context, resourcesProvider);
    long selfUserId = UserConfig.getInstance(account).getClientUserId();
    CheckBoxCell[] cell = new CheckBoxCell[1];
    TextView messageTextView = new TextView(context);
    messageTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    messageTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    boolean clearingCache = ChatObject.isChannel(chat) && !TextUtils.isEmpty(chat.username);
    FrameLayout frameLayout = new FrameLayout(context) {

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            if (cell[0] != null) {
                setMeasuredDimension(getMeasuredWidth(), getMeasuredHeight() + cell[0].getMeasuredHeight() + AndroidUtilities.dp(7));
            }
        }
    };
    builder.setView(frameLayout);
    AvatarDrawable avatarDrawable = new AvatarDrawable();
    avatarDrawable.setTextSize(AndroidUtilities.dp(12));
    BackupImageView imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(20));
    frameLayout.addView(imageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 22, 5, 22, 0));
    TextView textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    if (clear) {
        if (clearingCache) {
            textView.setText(LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache));
        } else {
            textView.setText(LocaleController.getString("ClearHistory", R.string.ClearHistory));
        }
    } else {
        if (admin) {
            if (ChatObject.isChannel(chat)) {
                if (chat.megagroup) {
                    textView.setText(LocaleController.getString("DeleteMegaMenu", R.string.DeleteMegaMenu));
                } else {
                    textView.setText(LocaleController.getString("ChannelDeleteMenu", R.string.ChannelDeleteMenu));
                }
            } else {
                textView.setText(LocaleController.getString("DeleteMegaMenu", R.string.DeleteMegaMenu));
            }
        } else {
            if (chat != null) {
                if (ChatObject.isChannel(chat)) {
                    if (chat.megagroup) {
                        textView.setText(LocaleController.getString("LeaveMegaMenu", R.string.LeaveMegaMenu));
                    } else {
                        textView.setText(LocaleController.getString("LeaveChannelMenu", R.string.LeaveChannelMenu));
                    }
                } else {
                    textView.setText(LocaleController.getString("LeaveMegaMenu", R.string.LeaveMegaMenu));
                }
            } else {
                textView.setText(LocaleController.getString("DeleteChatUser", R.string.DeleteChatUser));
            }
        }
    }
    frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 21 : 76), 11, (LocaleController.isRTL ? 76 : 21), 0));
    frameLayout.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 57, 24, 9));
    boolean canRevokeInbox = user != null && !user.bot && user.id != selfUserId && MessagesController.getInstance(account).canRevokePmInbox;
    int revokeTimeLimit;
    if (user != null) {
        revokeTimeLimit = MessagesController.getInstance(account).revokeTimePmLimit;
    } else {
        revokeTimeLimit = MessagesController.getInstance(account).revokeTimeLimit;
    }
    boolean canDeleteInbox = !secret && user != null && canRevokeInbox && revokeTimeLimit == 0x7fffffff;
    final boolean[] deleteForAll = new boolean[1];
    boolean deleteChatForAll = false;
    if (!second && (secret && !clear || canDeleteInbox) && !UserObject.isDeleted(user) || (deleteChatForAll = checkDeleteForAll && !clear && chat != null && chat.creator)) {
        cell[0] = new CheckBoxCell(context, 1, resourcesProvider);
        cell[0].setBackgroundDrawable(Theme.getSelectorDrawable(false));
        if (deleteChatForAll) {
            if (ChatObject.isChannel(chat) && !chat.megagroup) {
                cell[0].setText(LocaleController.getString("DeleteChannelForAll", R.string.DeleteChannelForAll), "", false, false);
            } else {
                cell[0].setText(LocaleController.getString("DeleteGroupForAll", R.string.DeleteGroupForAll), "", false, false);
            }
        } else if (clear) {
            cell[0].setText(LocaleController.formatString("ClearHistoryOptionAlso", R.string.ClearHistoryOptionAlso, UserObject.getFirstName(user)), "", false, false);
        } else {
            cell[0].setText(LocaleController.formatString("DeleteMessagesOptionAlso", R.string.DeleteMessagesOptionAlso, UserObject.getFirstName(user)), "", false, false);
        }
        cell[0].setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
        frameLayout.addView(cell[0], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 0));
        cell[0].setOnClickListener(v -> {
            CheckBoxCell cell1 = (CheckBoxCell) v;
            deleteForAll[0] = !deleteForAll[0];
            cell1.setChecked(deleteForAll[0], true);
        });
    }
    if (user != null) {
        if (UserObject.isReplyUser(user)) {
            avatarDrawable.setSmallSize(true);
            avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_REPLIES);
            imageView.setImage(null, null, avatarDrawable, user);
        } else if (user.id == selfUserId) {
            avatarDrawable.setSmallSize(true);
            avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
            imageView.setImage(null, null, avatarDrawable, user);
        } else {
            avatarDrawable.setSmallSize(false);
            avatarDrawable.setInfo(user);
            imageView.setForUserOrChat(user, avatarDrawable);
        }
    } else {
        avatarDrawable.setInfo(chat);
        imageView.setForUserOrChat(chat, avatarDrawable);
    }
    if (second) {
        if (UserObject.isUserSelf(user)) {
            messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("DeleteAllMessagesSavedAlert", R.string.DeleteAllMessagesSavedAlert)));
        } else {
            messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("DeleteAllMessagesAlert", R.string.DeleteAllMessagesAlert)));
        }
    } else {
        if (clear) {
            if (user != null) {
                if (secret) {
                    messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureClearHistoryWithSecretUser", R.string.AreYouSureClearHistoryWithSecretUser, UserObject.getUserName(user))));
                } else {
                    if (user.id == selfUserId) {
                        messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("AreYouSureClearHistorySavedMessages", R.string.AreYouSureClearHistorySavedMessages)));
                    } else {
                        messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureClearHistoryWithUser", R.string.AreYouSureClearHistoryWithUser, UserObject.getUserName(user))));
                    }
                }
            } else {
                if (!ChatObject.isChannel(chat) || chat.megagroup && TextUtils.isEmpty(chat.username)) {
                    messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureClearHistoryWithChat", R.string.AreYouSureClearHistoryWithChat, chat.title)));
                } else if (chat.megagroup) {
                    messageTextView.setText(LocaleController.getString("AreYouSureClearHistoryGroup", R.string.AreYouSureClearHistoryGroup));
                } else {
                    messageTextView.setText(LocaleController.getString("AreYouSureClearHistoryChannel", R.string.AreYouSureClearHistoryChannel));
                }
            }
        } else {
            if (admin) {
                if (ChatObject.isChannel(chat)) {
                    if (chat.megagroup) {
                        messageTextView.setText(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
                    } else {
                        messageTextView.setText(LocaleController.getString("AreYouSureDeleteAndExitChannel", R.string.AreYouSureDeleteAndExitChannel));
                    }
                } else {
                    messageTextView.setText(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
                }
            } else {
                if (user != null) {
                    if (secret) {
                        messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureDeleteThisChatWithSecretUser", R.string.AreYouSureDeleteThisChatWithSecretUser, UserObject.getUserName(user))));
                    } else {
                        if (user.id == selfUserId) {
                            messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("AreYouSureDeleteThisChatSavedMessages", R.string.AreYouSureDeleteThisChatSavedMessages)));
                        } else {
                            if (user.bot && !user.support) {
                                messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureDeleteThisChatWithBot", R.string.AreYouSureDeleteThisChatWithBot, UserObject.getUserName(user))));
                            } else {
                                messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureDeleteThisChatWithUser", R.string.AreYouSureDeleteThisChatWithUser, UserObject.getUserName(user))));
                            }
                        }
                    }
                } else if (ChatObject.isChannel(chat)) {
                    if (chat.megagroup) {
                        messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("MegaLeaveAlertWithName", R.string.MegaLeaveAlertWithName, chat.title)));
                    } else {
                        messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("ChannelLeaveAlertWithName", R.string.ChannelLeaveAlertWithName, chat.title)));
                    }
                } else {
                    messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureDeleteAndExitName", R.string.AreYouSureDeleteAndExitName, chat.title)));
                }
            }
        }
    }
    String actionText;
    if (second) {
        actionText = LocaleController.getString("DeleteAll", R.string.DeleteAll);
    } else {
        if (clear) {
            if (clearingCache) {
                actionText = LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache);
            } else {
                actionText = LocaleController.getString("ClearHistory", R.string.ClearHistory);
            }
        } else {
            if (admin) {
                if (ChatObject.isChannel(chat)) {
                    if (chat.megagroup) {
                        actionText = LocaleController.getString("DeleteMega", R.string.DeleteMega);
                    } else {
                        actionText = LocaleController.getString("ChannelDelete", R.string.ChannelDelete);
                    }
                } else {
                    actionText = LocaleController.getString("DeleteMega", R.string.DeleteMega);
                }
            } else {
                if (ChatObject.isChannel(chat)) {
                    if (chat.megagroup) {
                        actionText = LocaleController.getString("LeaveMegaMenu", R.string.LeaveMegaMenu);
                    } else {
                        actionText = LocaleController.getString("LeaveChannelMenu", R.string.LeaveChannelMenu);
                    }
                } else {
                    actionText = LocaleController.getString("DeleteChatUser", R.string.DeleteChatUser);
                }
            }
        }
    }
    builder.setPositiveButton(actionText, (dialogInterface, i) -> {
        if (!clearingCache && !second && !secret) {
            if (UserObject.isUserSelf(user)) {
                createClearOrDeleteDialogAlert(fragment, clear, admin, true, chat, user, false, checkDeleteForAll, onProcessRunnable, resourcesProvider);
                return;
            } else if (user != null && deleteForAll[0]) {
                MessagesStorage.getInstance(fragment.getCurrentAccount()).getMessagesCount(user.id, (count) -> {
                    if (count >= 50) {
                        createClearOrDeleteDialogAlert(fragment, clear, admin, true, chat, user, false, checkDeleteForAll, onProcessRunnable, resourcesProvider);
                    } else {
                        if (onProcessRunnable != null) {
                            onProcessRunnable.run(deleteForAll[0]);
                        }
                    }
                });
                return;
            }
        }
        if (onProcessRunnable != null) {
            onProcessRunnable.run(second || deleteForAll[0]);
        }
    });
    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    AlertDialog alertDialog = builder.create();
    fragment.showDialog(alertDialog);
    TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
    if (button != null) {
        button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
    }
}
Also used : Context(android.content.Context) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) Arrays(java.util.Arrays) Bundle(android.os.Bundle) SvgHelper(org.telegram.messenger.SvgHelper) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) Drawable(android.graphics.drawable.Drawable) Manifest(android.Manifest) NotificationsController(org.telegram.messenger.NotificationsController) CacheControlActivity(org.telegram.ui.CacheControlActivity) NotificationCenter(org.telegram.messenger.NotificationCenter) Outline(android.graphics.Outline) HapticFeedbackConstants(android.view.HapticFeedbackConstants) CountDownLatch(java.util.concurrent.CountDownLatch) LaunchActivity(org.telegram.ui.LaunchActivity) Html(android.text.Html) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) InputFilter(android.text.InputFilter) TextWatcher(android.text.TextWatcher) ChatActivity(org.telegram.ui.ChatActivity) Dialog(android.app.Dialog) Editable(android.text.Editable) ArrayList(java.util.ArrayList) SpannableStringBuilder(android.text.SpannableStringBuilder) ThemePreviewActivity(org.telegram.ui.ThemePreviewActivity) Calendar(java.util.Calendar) TLRPC(org.telegram.tgnet.TLRPC) GradientDrawable(android.graphics.drawable.GradientDrawable) Toast(android.widget.Toast) Settings(android.provider.Settings) NotificationsCustomSettingsActivity(org.telegram.ui.NotificationsCustomSettingsActivity) URLSpan(android.text.style.URLSpan) SpannableString(android.text.SpannableString) R(org.telegram.messenger.R) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) TextUtils(android.text.TextUtils) Gravity(android.view.Gravity) UserObject(org.telegram.messenger.UserObject) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) ContactsController(org.telegram.messenger.ContactsController) MessagesStorage(org.telegram.messenger.MessagesStorage) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) VoIPHelper(org.telegram.ui.Components.voip.VoIPHelper) EditText(android.widget.EditText) ProfileNotificationsActivity(org.telegram.ui.ProfileNotificationsActivity) RequiresApi(androidx.annotation.RequiresApi) Rect(android.graphics.Rect) LinearLayout(android.widget.LinearLayout) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) PackageManager(android.content.pm.PackageManager) Spannable(android.text.Spannable) WindowManager(android.view.WindowManager) AccountInstance(org.telegram.messenger.AccountInstance) AndroidUtilities(org.telegram.messenger.AndroidUtilities) LanguageSelectActivity(org.telegram.ui.LanguageSelectActivity) CheckBoxCell(org.telegram.ui.Cells.CheckBoxCell) ApplicationLoader(org.telegram.messenger.ApplicationLoader) Locale(java.util.Locale) View(android.view.View) Button(android.widget.Button) TextColorCell(org.telegram.ui.Cells.TextColorCell) Utilities(org.telegram.messenger.Utilities) TooManyCommunitiesActivity(org.telegram.ui.TooManyCommunitiesActivity) InputType(android.text.InputType) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) BitmapDrawable(android.graphics.drawable.BitmapDrawable) PorterDuff(android.graphics.PorterDuff) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) SparseArray(android.util.SparseArray) UserConfig(org.telegram.messenger.UserConfig) List(java.util.List) TextView(android.widget.TextView) SecretChatHelper(org.telegram.messenger.SecretChatHelper) EditorInfo(android.view.inputmethod.EditorInfo) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) Context(android.content.Context) IDN(java.net.IDN) Spanned(android.text.Spanned) KeyEvent(android.view.KeyEvent) Theme(org.telegram.ui.ActionBar.Theme) ViewOutlineProvider(android.view.ViewOutlineProvider) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) HashMap(java.util.HashMap) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) TLObject(org.telegram.tgnet.TLObject) MessageObject(org.telegram.messenger.MessageObject) SharedConfig(org.telegram.messenger.SharedConfig) BuildVars(org.telegram.messenger.BuildVars) NotificationsSettingsActivity(org.telegram.ui.NotificationsSettingsActivity) Build(android.os.Build) SerializedData(org.telegram.tgnet.SerializedData) DialogInterface(android.content.DialogInterface) Browser(org.telegram.messenger.browser.Browser) LoginActivity(org.telegram.ui.LoginActivity) DialogObject(org.telegram.messenger.DialogObject) FileLog(org.telegram.messenger.FileLog) AccountSelectCell(org.telegram.ui.Cells.AccountSelectCell) MessagesController(org.telegram.messenger.MessagesController) Color(android.graphics.Color) Base64(android.util.Base64) RadioColorCell(org.telegram.ui.Cells.RadioColorCell) Vibrator(android.os.Vibrator) Activity(android.app.Activity) SpannableStringBuilder(android.text.SpannableStringBuilder) SpannableString(android.text.SpannableString) SuppressLint(android.annotation.SuppressLint) CheckBoxCell(org.telegram.ui.Cells.CheckBoxCell) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView)

Example 3 with BaseFragment

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

the class BackButtonMenu method getStackedHistoryDialogs.

public static ArrayList<PulledDialog> getStackedHistoryDialogs(BaseFragment thisFragment, long ignoreDialogId) {
    ArrayList<PulledDialog> dialogs = new ArrayList<>();
    if (thisFragment == null)
        return dialogs;
    final ActionBarLayout parentLayout = thisFragment.getParentLayout();
    if (parentLayout == null)
        return dialogs;
    ArrayList<BaseFragment> fragmentsStack = parentLayout.fragmentsStack;
    ArrayList<PulledDialog> pulledDialogs = parentLayout.pulledDialogs;
    if (fragmentsStack != null) {
        final int count = fragmentsStack.size();
        for (int i = 0; i < count; ++i) {
            BaseFragment fragment = fragmentsStack.get(i);
            Class activity;
            TLRPC.Chat chat;
            TLRPC.User user = null;
            long dialogId;
            int folderId, filterId;
            if (fragment instanceof ChatActivity) {
                activity = ChatActivity.class;
                ChatActivity chatActivity = (ChatActivity) fragment;
                if (chatActivity.getChatMode() != 0 || chatActivity.isReport()) {
                    continue;
                }
                chat = chatActivity.getCurrentChat();
                user = chatActivity.getCurrentUser();
                dialogId = chatActivity.getDialogId();
                folderId = chatActivity.getDialogFolderId();
                filterId = chatActivity.getDialogFilterId();
            } else if (fragment instanceof ProfileActivity) {
                activity = ProfileActivity.class;
                ProfileActivity profileActivity = (ProfileActivity) fragment;
                chat = profileActivity.getCurrentChat();
                try {
                    user = profileActivity.getUserInfo().user;
                } catch (Exception ignore) {
                }
                dialogId = profileActivity.getDialogId();
                folderId = 0;
                filterId = 0;
            } else {
                continue;
            }
            if (dialogId != ignoreDialogId && !(ignoreDialogId == 0 && UserObject.isUserSelf(user))) {
                boolean alreadyAddedDialog = false;
                for (int d = 0; d < dialogs.size(); ++d) {
                    if (dialogs.get(d).dialogId == dialogId) {
                        alreadyAddedDialog = true;
                        break;
                    }
                }
                if (!alreadyAddedDialog) {
                    PulledDialog pDialog = new PulledDialog();
                    pDialog.activity = activity;
                    pDialog.stackIndex = i;
                    pDialog.chat = chat;
                    pDialog.user = user;
                    pDialog.dialogId = dialogId;
                    pDialog.folderId = folderId;
                    pDialog.filterId = filterId;
                    if (pDialog.chat != null || pDialog.user != null) {
                        dialogs.add(pDialog);
                    }
                }
            }
        }
    }
    if (pulledDialogs != null) {
        for (PulledDialog pulledDialog : pulledDialogs) {
            if (pulledDialog.dialogId == ignoreDialogId) {
                continue;
            }
            boolean alreadyAddedDialog = false;
            for (int d = 0; d < dialogs.size(); ++d) {
                if (dialogs.get(d).dialogId == pulledDialog.dialogId) {
                    alreadyAddedDialog = true;
                    break;
                }
            }
            if (!alreadyAddedDialog) {
                dialogs.add(pulledDialog);
            }
        }
    }
    Collections.sort(dialogs, (d1, d2) -> d2.stackIndex - d1.stackIndex);
    return dialogs;
}
Also used : ProfileActivity(org.telegram.ui.ProfileActivity) ChatActivity(org.telegram.ui.ChatActivity) ArrayList(java.util.ArrayList) ActionBarLayout(org.telegram.ui.ActionBar.ActionBarLayout) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) TLRPC(org.telegram.tgnet.TLRPC)

Example 4 with BaseFragment

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

the class BackButtonMenu method show.

public static ActionBarPopupWindow show(BaseFragment thisFragment, View backButton, long currentDialogId) {
    if (thisFragment == null) {
        return null;
    }
    final ActionBarLayout parentLayout = thisFragment.getParentLayout();
    final Context context = thisFragment.getParentActivity();
    final View fragmentView = thisFragment.getFragmentView();
    if (parentLayout == null || context == null || fragmentView == null) {
        return null;
    }
    ArrayList<PulledDialog> dialogs = getStackedHistoryDialogs(thisFragment, currentDialogId);
    if (dialogs.size() <= 0) {
        return null;
    }
    ActionBarPopupWindow.ActionBarPopupWindowLayout layout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(context);
    android.graphics.Rect backgroundPaddings = new Rect();
    Drawable shadowDrawable = thisFragment.getParentActivity().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
    shadowDrawable.getPadding(backgroundPaddings);
    layout.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
    AtomicReference<ActionBarPopupWindow> scrimPopupWindowRef = new AtomicReference<>();
    for (int i = 0; i < dialogs.size(); ++i) {
        final PulledDialog pDialog = dialogs.get(i);
        final TLRPC.Chat chat = pDialog.chat;
        final TLRPC.User user = pDialog.user;
        FrameLayout cell = new FrameLayout(context);
        cell.setMinimumWidth(AndroidUtilities.dp(200));
        BackupImageView imageView = new BackupImageView(context);
        imageView.setRoundRadius(AndroidUtilities.dp(32));
        cell.addView(imageView, LayoutHelper.createFrameRelatively(32, 32, Gravity.START | Gravity.CENTER_VERTICAL, 13, 0, 0, 0));
        TextView titleView = new TextView(context);
        titleView.setLines(1);
        titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
        titleView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
        titleView.setEllipsize(TextUtils.TruncateAt.END);
        cell.addView(titleView, LayoutHelper.createFrameRelatively(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 59, 0, 12, 0));
        AvatarDrawable avatarDrawable = new AvatarDrawable();
        avatarDrawable.setSmallSize(true);
        if (chat != null) {
            avatarDrawable.setInfo(chat);
            imageView.setImage(ImageLocation.getForChat(chat, ImageLocation.TYPE_SMALL), "50_50", avatarDrawable, chat);
            titleView.setText(chat.title);
        } else if (user != null) {
            String name;
            if (pDialog.activity == ChatActivity.class && UserObject.isUserSelf(user)) {
                name = LocaleController.getString("SavedMessages", R.string.SavedMessages);
                avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
                imageView.setImageDrawable(avatarDrawable);
            } else if (UserObject.isReplyUser(user)) {
                name = LocaleController.getString("RepliesTitle", R.string.RepliesTitle);
                avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_REPLIES);
                imageView.setImageDrawable(avatarDrawable);
            } else if (UserObject.isDeleted(user)) {
                name = LocaleController.getString("HiddenName", R.string.HiddenName);
                avatarDrawable.setInfo(user);
                imageView.setImage(ImageLocation.getForUser(user, ImageLocation.TYPE_SMALL), "50_50", avatarDrawable, user);
            } else {
                name = UserObject.getUserName(user);
                avatarDrawable.setInfo(user);
                imageView.setImage(ImageLocation.getForUser(user, ImageLocation.TYPE_SMALL), "50_50", avatarDrawable, user);
            }
            titleView.setText(name);
        }
        cell.setBackground(Theme.getSelectorDrawable(Theme.getColor(Theme.key_listSelector), false));
        cell.setOnClickListener(e2 -> {
            if (scrimPopupWindowRef.get() != null) {
                scrimPopupWindowRef.getAndSet(null).dismiss();
            }
            if (pDialog.stackIndex >= 0) {
                Long nextFragmentDialogId = null;
                if (parentLayout == null || parentLayout.fragmentsStack == null || pDialog.stackIndex >= parentLayout.fragmentsStack.size()) {
                    nextFragmentDialogId = null;
                } else {
                    BaseFragment nextFragment = parentLayout.fragmentsStack.get(pDialog.stackIndex);
                    if (nextFragment instanceof ChatActivity) {
                        nextFragmentDialogId = ((ChatActivity) nextFragment).getDialogId();
                    } else if (nextFragment instanceof ProfileActivity) {
                        nextFragmentDialogId = ((ProfileActivity) nextFragment).getDialogId();
                    }
                }
                if (nextFragmentDialogId != null && nextFragmentDialogId != pDialog.dialogId) {
                    for (int j = parentLayout.fragmentsStack.size() - 2; j > pDialog.stackIndex; --j) {
                        parentLayout.removeFragmentFromStack(j);
                    }
                } else {
                    if (parentLayout != null && parentLayout.fragmentsStack != null) {
                        for (int j = parentLayout.fragmentsStack.size() - 2; j > pDialog.stackIndex; --j) {
                            if (j >= 0 && j < parentLayout.fragmentsStack.size()) {
                                parentLayout.removeFragmentFromStack(j);
                            }
                        }
                        if (pDialog.stackIndex < parentLayout.fragmentsStack.size()) {
                            parentLayout.showFragment(pDialog.stackIndex);
                            parentLayout.closeLastFragment(true);
                            return;
                        }
                    }
                }
            }
            goToPulledDialog(thisFragment, pDialog);
        });
        layout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
    }
    ActionBarPopupWindow scrimPopupWindow = new ActionBarPopupWindow(layout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT);
    scrimPopupWindowRef.set(scrimPopupWindow);
    scrimPopupWindow.setPauseNotifications(true);
    scrimPopupWindow.setDismissAnimationDuration(220);
    scrimPopupWindow.setOutsideTouchable(true);
    scrimPopupWindow.setClippingEnabled(true);
    scrimPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
    scrimPopupWindow.setFocusable(true);
    layout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
    scrimPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
    scrimPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
    scrimPopupWindow.getContentView().setFocusableInTouchMode(true);
    layout.setFitItems(true);
    int popupX = AndroidUtilities.dp(8) - backgroundPaddings.left;
    if (AndroidUtilities.isTablet()) {
        int[] location = new int[2];
        fragmentView.getLocationInWindow(location);
        popupX += location[0];
    }
    int popupY = (int) (backButton.getBottom() - backgroundPaddings.top - AndroidUtilities.dp(8));
    scrimPopupWindow.showAtLocation(fragmentView, Gravity.LEFT | Gravity.TOP, popupX, popupY);
    try {
        fragmentView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
    } catch (Exception ignore) {
    }
    return scrimPopupWindow;
}
Also used : Rect(android.graphics.Rect) ChatActivity(org.telegram.ui.ChatActivity) ActionBarLayout(org.telegram.ui.ActionBar.ActionBarLayout) TLRPC(org.telegram.tgnet.TLRPC) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) TextView(android.widget.TextView) Context(android.content.Context) Rect(android.graphics.Rect) ProfileActivity(org.telegram.ui.ProfileActivity) Drawable(android.graphics.drawable.Drawable) AtomicReference(java.util.concurrent.atomic.AtomicReference) View(android.view.View) TextView(android.widget.TextView) FrameLayout(android.widget.FrameLayout)

Example 5 with BaseFragment

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

the class ArticleViewer method setParentActivity.

public void setParentActivity(Activity activity, BaseFragment fragment) {
    parentFragment = fragment;
    currentAccount = UserConfig.selectedAccount;
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagePlayingDidReset);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagePlayingDidStart);
    if (parentActivity == activity) {
        updatePaintColors();
        refreshThemeColors();
        return;
    }
    parentActivity = activity;
    SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("articles", Activity.MODE_PRIVATE);
    selectedFont = sharedPreferences.getInt("font_type", 0);
    createPaint(false);
    backgroundPaint = new Paint();
    layerShadowDrawable = activity.getResources().getDrawable(R.drawable.layer_shadow);
    slideDotDrawable = activity.getResources().getDrawable(R.drawable.slide_dot_small);
    slideDotBigDrawable = activity.getResources().getDrawable(R.drawable.slide_dot_big);
    scrimPaint = new Paint();
    windowView = new WindowView(activity);
    windowView.setWillNotDraw(false);
    windowView.setClipChildren(true);
    windowView.setFocusable(false);
    containerView = new FrameLayout(activity) {

        @Override
        protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
            if (windowView.movingPage) {
                int width = getMeasuredWidth();
                int translationX = (int) listView[0].getTranslationX();
                int clipLeft = 0;
                int clipRight = width;
                if (child == listView[1]) {
                    clipRight = translationX;
                } else if (child == listView[0]) {
                    clipLeft = translationX;
                }
                final int restoreCount = canvas.save();
                canvas.clipRect(clipLeft, 0, clipRight, getHeight());
                final boolean result = super.drawChild(canvas, child, drawingTime);
                canvas.restoreToCount(restoreCount);
                if (translationX != 0) {
                    if (child == listView[0]) {
                        final float alpha = Math.max(0, Math.min((width - translationX) / (float) AndroidUtilities.dp(20), 1.0f));
                        layerShadowDrawable.setBounds(translationX - layerShadowDrawable.getIntrinsicWidth(), child.getTop(), translationX, child.getBottom());
                        layerShadowDrawable.setAlpha((int) (0xff * alpha));
                        layerShadowDrawable.draw(canvas);
                    } else if (child == listView[1]) {
                        float opacity = Math.min(0.8f, (width - translationX) / (float) width);
                        if (opacity < 0) {
                            opacity = 0;
                        }
                        scrimPaint.setColor((int) (((0x99000000 & 0xff000000) >>> 24) * opacity) << 24);
                        canvas.drawRect(clipLeft, 0, clipRight, getHeight(), scrimPaint);
                    }
                }
                return result;
            } else {
                return super.drawChild(canvas, child, drawingTime);
            }
        }
    };
    windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
    // containerView.setFitsSystemWindows(true);
    if (Build.VERSION.SDK_INT >= 21) {
        windowView.setFitsSystemWindows(true);
        containerView.setOnApplyWindowInsetsListener((v, insets) -> {
            if (Build.VERSION.SDK_INT >= 30) {
                return WindowInsets.CONSUMED;
            } else {
                return insets.consumeSystemWindowInsets();
            }
        });
    }
    fullscreenVideoContainer = new FrameLayout(activity);
    fullscreenVideoContainer.setBackgroundColor(0xff000000);
    fullscreenVideoContainer.setVisibility(View.INVISIBLE);
    windowView.addView(fullscreenVideoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    fullscreenAspectRatioView = new AspectRatioFrameLayout(activity);
    fullscreenAspectRatioView.setVisibility(View.GONE);
    fullscreenVideoContainer.addView(fullscreenAspectRatioView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER));
    fullscreenTextureView = new TextureView(activity);
    listView = new RecyclerListView[2];
    adapter = new WebpageAdapter[2];
    layoutManager = new LinearLayoutManager[2];
    for (int i = 0; i < listView.length; i++) {
        WebpageAdapter webpageAdapter = adapter[i] = new WebpageAdapter(parentActivity);
        listView[i] = new RecyclerListView(activity) {

            @Override
            protected void onLayout(boolean changed, int l, int t, int r, int b) {
                super.onLayout(changed, l, t, r, b);
                int count = getChildCount();
                for (int a = 0; a < count; a++) {
                    View child = getChildAt(a);
                    if (child.getTag() instanceof Integer) {
                        Integer tag = (Integer) child.getTag();
                        if (tag == 90) {
                            int bottom = child.getBottom();
                            if (bottom < getMeasuredHeight()) {
                                int height = getMeasuredHeight();
                                child.layout(0, height - child.getMeasuredHeight(), child.getMeasuredWidth(), height);
                                break;
                            }
                        }
                    }
                }
            }

            @Override
            public boolean onInterceptTouchEvent(MotionEvent e) {
                if (pressedLinkOwnerLayout != null && pressedLink == null && (popupWindow == null || !popupWindow.isShowing()) && (e.getAction() == MotionEvent.ACTION_UP || e.getAction() == MotionEvent.ACTION_CANCEL)) {
                    pressedLink = null;
                    pressedLinkOwnerLayout = null;
                    pressedLinkOwnerView = null;
                } else if (pressedLinkOwnerLayout != null && pressedLink != null && e.getAction() == MotionEvent.ACTION_UP) {
                    checkLayoutForLinks(webpageAdapter, e, pressedLinkOwnerView, pressedLinkOwnerLayout, 0, 0);
                }
                return super.onInterceptTouchEvent(e);
            }

            @Override
            public boolean onTouchEvent(MotionEvent e) {
                if (pressedLinkOwnerLayout != null && pressedLink == null && (popupWindow == null || !popupWindow.isShowing()) && (e.getAction() == MotionEvent.ACTION_UP || e.getAction() == MotionEvent.ACTION_CANCEL)) {
                    pressedLink = null;
                    pressedLinkOwnerLayout = null;
                    pressedLinkOwnerView = null;
                }
                return super.onTouchEvent(e);
            }

            @Override
            public void setTranslationX(float translationX) {
                super.setTranslationX(translationX);
                if (windowView.movingPage) {
                    containerView.invalidate();
                    float progress = translationX / getMeasuredWidth();
                    setCurrentHeaderHeight((int) (windowView.startMovingHeaderHeight + (AndroidUtilities.dp(56) - windowView.startMovingHeaderHeight) * progress));
                }
            }
        };
        ((DefaultItemAnimator) listView[i].getItemAnimator()).setDelayAnimations(false);
        listView[i].setLayoutManager(layoutManager[i] = new LinearLayoutManager(parentActivity, LinearLayoutManager.VERTICAL, false));
        listView[i].setAdapter(webpageAdapter);
        listView[i].setClipToPadding(false);
        listView[i].setVisibility(i == 0 ? View.VISIBLE : View.GONE);
        listView[i].setPadding(0, AndroidUtilities.dp(56), 0, 0);
        listView[i].setTopGlowOffset(AndroidUtilities.dp(56));
        containerView.addView(listView[i], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
        listView[i].setOnItemLongClickListener((view, position) -> {
            if (view instanceof BlockRelatedArticlesCell) {
                BlockRelatedArticlesCell cell = (BlockRelatedArticlesCell) view;
                showCopyPopup(cell.currentBlock.parent.articles.get(cell.currentBlock.num).url);
                return true;
            }
            return false;
        });
        listView[i].setOnItemClickListener((view, position, x, y) -> {
            if (textSelectionHelper != null) {
                if (textSelectionHelper.isSelectionMode()) {
                    textSelectionHelper.clear();
                    return;
                }
                textSelectionHelper.clear();
            }
            if (view instanceof ReportCell && webpageAdapter.currentPage != null) {
                ReportCell cell = (ReportCell) view;
                if (previewsReqId != 0 || cell.hasViews && x < view.getMeasuredWidth() / 2) {
                    return;
                }
                TLObject object = MessagesController.getInstance(currentAccount).getUserOrChat("previews");
                if (object instanceof TLRPC.TL_user) {
                    openPreviewsChat((TLRPC.User) object, webpageAdapter.currentPage.id);
                } else {
                    final int currentAccount = UserConfig.selectedAccount;
                    final long pageId = webpageAdapter.currentPage.id;
                    showProgressView(true, true);
                    TLRPC.TL_contacts_resolveUsername req = new TLRPC.TL_contacts_resolveUsername();
                    req.username = "previews";
                    previewsReqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                        if (previewsReqId == 0) {
                            return;
                        }
                        previewsReqId = 0;
                        showProgressView(true, false);
                        if (response != null) {
                            TLRPC.TL_contacts_resolvedPeer res = (TLRPC.TL_contacts_resolvedPeer) response;
                            MessagesController.getInstance(currentAccount).putUsers(res.users, false);
                            MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, false, true);
                            if (!res.users.isEmpty()) {
                                openPreviewsChat(res.users.get(0), pageId);
                            }
                        }
                    }));
                }
            } else if (position >= 0 && position < webpageAdapter.localBlocks.size()) {
                TLRPC.PageBlock pageBlock = webpageAdapter.localBlocks.get(position);
                TLRPC.PageBlock originalBlock = pageBlock;
                pageBlock = getLastNonListPageBlock(pageBlock);
                if (pageBlock instanceof TL_pageBlockDetailsChild) {
                    TL_pageBlockDetailsChild detailsChild = (TL_pageBlockDetailsChild) pageBlock;
                    pageBlock = detailsChild.block;
                }
                if (pageBlock instanceof TLRPC.TL_pageBlockChannel) {
                    TLRPC.TL_pageBlockChannel pageBlockChannel = (TLRPC.TL_pageBlockChannel) pageBlock;
                    MessagesController.getInstance(currentAccount).openByUserName(pageBlockChannel.channel.username, parentFragment, 2);
                    close(false, true);
                } else if (pageBlock instanceof TL_pageBlockRelatedArticlesChild) {
                    TL_pageBlockRelatedArticlesChild pageBlockRelatedArticlesChild = (TL_pageBlockRelatedArticlesChild) pageBlock;
                    openWebpageUrl(pageBlockRelatedArticlesChild.parent.articles.get(pageBlockRelatedArticlesChild.num).url, null);
                } else if (pageBlock instanceof TLRPC.TL_pageBlockDetails) {
                    view = getLastNonListCell(view);
                    if (!(view instanceof BlockDetailsCell)) {
                        return;
                    }
                    pressedLinkOwnerLayout = null;
                    pressedLinkOwnerView = null;
                    int index = webpageAdapter.blocks.indexOf(originalBlock);
                    if (index < 0) {
                        return;
                    }
                    TLRPC.TL_pageBlockDetails pageBlockDetails = (TLRPC.TL_pageBlockDetails) pageBlock;
                    pageBlockDetails.open = !pageBlockDetails.open;
                    int oldCount = webpageAdapter.getItemCount();
                    webpageAdapter.updateRows();
                    int newCount = webpageAdapter.getItemCount();
                    int changeCount = Math.abs(newCount - oldCount);
                    BlockDetailsCell cell = (BlockDetailsCell) view;
                    cell.arrow.setAnimationProgressAnimated(pageBlockDetails.open ? 0.0f : 1.0f);
                    cell.invalidate();
                    if (changeCount != 0) {
                        if (pageBlockDetails.open) {
                            webpageAdapter.notifyItemRangeInserted(position + 1, changeCount);
                        } else {
                            webpageAdapter.notifyItemRangeRemoved(position + 1, changeCount);
                        }
                    }
                }
            }
        });
        listView[i].setOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
                if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                    textSelectionHelper.stopScrolling();
                }
            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                if (recyclerView.getChildCount() == 0) {
                    return;
                }
                textSelectionHelper.onParentScrolled();
                headerView.invalidate();
                checkScroll(dy);
            }
        });
    }
    headerPaint.setColor(0xff000000);
    statusBarPaint.setColor(0xff000000);
    headerProgressPaint.setColor(0xff242426);
    headerView = new FrameLayout(activity) {

        @Override
        protected void onDraw(Canvas canvas) {
            int width = getMeasuredWidth();
            int height = getMeasuredHeight();
            canvas.drawRect(0, 0, width, height, headerPaint);
            if (layoutManager == null) {
                return;
            }
            int first = layoutManager[0].findFirstVisibleItemPosition();
            int last = layoutManager[0].findLastVisibleItemPosition();
            int count = layoutManager[0].getItemCount();
            View view;
            if (last >= count - 2) {
                view = layoutManager[0].findViewByPosition(count - 2);
            } else {
                view = layoutManager[0].findViewByPosition(first);
            }
            if (view == null) {
                return;
            }
            float itemProgress = width / (float) (count - 1);
            int childCount = layoutManager[0].getChildCount();
            float viewHeight = view.getMeasuredHeight();
            float viewProgress;
            if (last >= count - 2) {
                viewProgress = (count - 2 - first) * itemProgress * (listView[0].getMeasuredHeight() - view.getTop()) / viewHeight;
            } else {
                viewProgress = itemProgress * (1.0f - (Math.min(0, view.getTop() - listView[0].getPaddingTop()) + viewHeight) / viewHeight);
            }
            float progress = first * itemProgress + viewProgress;
            canvas.drawRect(0, 0, progress, height, headerProgressPaint);
        }
    };
    headerView.setWillNotDraw(false);
    containerView.addView(headerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 56));
    headerView.setOnClickListener(v -> listView[0].smoothScrollToPosition(0));
    titleTextView = new SimpleTextView(activity);
    titleTextView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    titleTextView.setTextSize(20);
    titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    titleTextView.setTextColor(0xffb3b3b3);
    titleTextView.setPivotX(0.0f);
    titleTextView.setPivotY(AndroidUtilities.dp(28));
    headerView.addView(titleTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 56, Gravity.LEFT | Gravity.TOP, 72, 0, 48 * 2, 0));
    lineProgressView = new LineProgressView(activity);
    lineProgressView.setProgressColor(0xffffffff);
    lineProgressView.setPivotX(0.0f);
    lineProgressView.setPivotY(AndroidUtilities.dp(2));
    headerView.addView(lineProgressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 2, Gravity.LEFT | Gravity.BOTTOM, 0, 0, 0, 1));
    lineProgressTickRunnable = () -> {
        float progressLeft = 0.7f - lineProgressView.getCurrentProgress();
        if (progressLeft > 0.0f) {
            float tick;
            if (progressLeft < 0.25f) {
                tick = 0.01f;
            } else {
                tick = 0.02f;
            }
            lineProgressView.setProgress(lineProgressView.getCurrentProgress() + tick, true);
            AndroidUtilities.runOnUIThread(lineProgressTickRunnable, 100);
        }
    };
    menuContainer = new FrameLayout(activity);
    headerView.addView(menuContainer, LayoutHelper.createFrame(48, 56, Gravity.TOP | Gravity.RIGHT));
    searchShadow = new View(activity);
    searchShadow.setBackgroundResource(R.drawable.header_shadow);
    searchShadow.setAlpha(0.0f);
    containerView.addView(searchShadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.LEFT | Gravity.TOP, 0, 56, 0, 0));
    searchContainer = new FrameLayout(parentActivity);
    searchContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    searchContainer.setVisibility(View.INVISIBLE);
    if (Build.VERSION.SDK_INT < 21) {
        searchContainer.setAlpha(0.0f);
    }
    headerView.addView(searchContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 56));
    searchField = new EditTextBoldCursor(parentActivity) {

        @Override
        public boolean onTouchEvent(MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                if (!AndroidUtilities.showKeyboard(this)) {
                    clearFocus();
                    requestFocus();
                }
            }
            return super.onTouchEvent(event);
        }
    };
    searchField.setCursorWidth(1.5f);
    searchField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    searchField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    searchField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    searchField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    searchField.setSingleLine(true);
    searchField.setHint(LocaleController.getString("Search", R.string.Search));
    searchField.setBackgroundResource(0);
    searchField.setPadding(0, 0, 0, 0);
    int inputType = searchField.getInputType() | EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
    searchField.setInputType(inputType);
    if (Build.VERSION.SDK_INT < 23) {
        searchField.setCustomSelectionActionModeCallback(new ActionMode.Callback() {

            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public void onDestroyActionMode(ActionMode mode) {
            }

            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                return false;
            }
        });
    }
    searchField.setOnEditorActionListener((v, actionId, event) -> {
        if (event != null && (event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
            AndroidUtilities.hideKeyboard(searchField);
        }
        return false;
    });
    searchField.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (ignoreOnTextChange) {
                ignoreOnTextChange = false;
                return;
            }
            processSearch(s.toString().toLowerCase());
            if (clearButton != null) {
                if (TextUtils.isEmpty(s)) {
                    if (clearButton.getTag() != null) {
                        clearButton.setTag(null);
                        clearButton.clearAnimation();
                        if (animateClear) {
                            clearButton.animate().setInterpolator(new DecelerateInterpolator()).alpha(0.0f).setDuration(180).scaleY(0.0f).scaleX(0.0f).rotation(45).withEndAction(() -> clearButton.setVisibility(View.INVISIBLE)).start();
                        } else {
                            clearButton.setAlpha(0.0f);
                            clearButton.setRotation(45);
                            clearButton.setScaleX(0.0f);
                            clearButton.setScaleY(0.0f);
                            clearButton.setVisibility(View.INVISIBLE);
                            animateClear = true;
                        }
                    }
                } else {
                    if (clearButton.getTag() == null) {
                        clearButton.setTag(1);
                        clearButton.clearAnimation();
                        clearButton.setVisibility(View.VISIBLE);
                        if (animateClear) {
                            clearButton.animate().setInterpolator(new DecelerateInterpolator()).alpha(1.0f).setDuration(180).scaleY(1.0f).scaleX(1.0f).rotation(0).start();
                        } else {
                            clearButton.setAlpha(1.0f);
                            clearButton.setRotation(0);
                            clearButton.setScaleX(1.0f);
                            clearButton.setScaleY(1.0f);
                            animateClear = true;
                        }
                    }
                }
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    searchField.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN | EditorInfo.IME_ACTION_SEARCH);
    searchField.setTextIsSelectable(false);
    searchContainer.addView(searchField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.CENTER_VERTICAL, 72, 0, 48, 0));
    clearButton = new ImageView(parentActivity) {

        @Override
        protected void onDetachedFromWindow() {
            super.onDetachedFromWindow();
            clearAnimation();
            if (getTag() == null) {
                clearButton.setVisibility(INVISIBLE);
                clearButton.setAlpha(0.0f);
                clearButton.setRotation(45);
                clearButton.setScaleX(0.0f);
                clearButton.setScaleY(0.0f);
            } else {
                clearButton.setAlpha(1.0f);
                clearButton.setRotation(0);
                clearButton.setScaleX(1.0f);
                clearButton.setScaleY(1.0f);
            }
        }
    };
    clearButton.setImageDrawable(new CloseProgressDrawable2());
    clearButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText), PorterDuff.Mode.MULTIPLY));
    clearButton.setScaleType(ImageView.ScaleType.CENTER);
    clearButton.setAlpha(0.0f);
    clearButton.setRotation(45);
    clearButton.setScaleX(0.0f);
    clearButton.setScaleY(0.0f);
    clearButton.setOnClickListener(v -> {
        if (searchField.length() != 0) {
            searchField.setText("");
        }
        searchField.requestFocus();
        AndroidUtilities.showKeyboard(searchField);
    });
    clearButton.setContentDescription(LocaleController.getString("ClearButton", R.string.ClearButton));
    searchContainer.addView(clearButton, LayoutHelper.createFrame(48, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT));
    backButton = new ImageView(activity);
    backButton.setScaleType(ImageView.ScaleType.CENTER);
    backDrawable = new BackDrawable(false);
    backDrawable.setAnimationTime(200.0f);
    backDrawable.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    backDrawable.setRotatedColor(0xffb3b3b3);
    backDrawable.setRotation(1.0f, false);
    backButton.setImageDrawable(backDrawable);
    backButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR));
    headerView.addView(backButton, LayoutHelper.createFrame(54, 56));
    backButton.setOnClickListener(v -> {
        /*if (collapsed) {
                uncollapse();
            } else {
                collapse();
            }*/
        if (searchContainer.getTag() != null) {
            showSearch(false);
        } else {
            close(true, true);
        }
    });
    backButton.setContentDescription(LocaleController.getString("AccDescrGoBack", R.string.AccDescrGoBack));
    menuButton = new ActionBarMenuItem(parentActivity, null, Theme.ACTION_BAR_WHITE_SELECTOR_COLOR, 0xffb3b3b3) {

        @Override
        public void toggleSubMenu() {
            super.toggleSubMenu();
            listView[0].stopScroll();
            checkScrollAnimated();
        }
    };
    menuButton.setLayoutInScreen(true);
    menuButton.setDuplicateParentStateEnabled(false);
    menuButton.setClickable(true);
    menuButton.setIcon(R.drawable.ic_ab_other);
    menuButton.addSubItem(search_item, R.drawable.msg_search, LocaleController.getString("Search", R.string.Search));
    menuButton.addSubItem(share_item, R.drawable.msg_share, LocaleController.getString("ShareFile", R.string.ShareFile));
    menuButton.addSubItem(open_item, R.drawable.msg_openin, LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
    menuButton.addSubItem(settings_item, R.drawable.menu_settings, LocaleController.getString("Settings", R.string.Settings));
    menuButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR));
    menuButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
    menuContainer.addView(menuButton, LayoutHelper.createFrame(48, 56));
    progressView = new ContextProgressView(activity, 2);
    progressView.setVisibility(View.GONE);
    menuContainer.addView(progressView, LayoutHelper.createFrame(48, 56));
    menuButton.setOnClickListener(v -> menuButton.toggleSubMenu());
    menuButton.setDelegate(id -> {
        if (adapter[0].currentPage == null || parentActivity == null) {
            return;
        }
        if (id == search_item) {
            showSearch(true);
        } else if (id == share_item) {
            showDialog(new ShareAlert(parentActivity, null, adapter[0].currentPage.url, false, adapter[0].currentPage.url, false));
        } else if (id == open_item) {
            String webPageUrl;
            if (!TextUtils.isEmpty(adapter[0].currentPage.cached_page.url)) {
                webPageUrl = adapter[0].currentPage.cached_page.url;
            } else {
                webPageUrl = adapter[0].currentPage.url;
            }
            Browser.openUrl(parentActivity, webPageUrl, true, false);
        } else if (id == settings_item) {
            BottomSheet.Builder builder = new BottomSheet.Builder(parentActivity);
            builder.setApplyTopPadding(false);
            LinearLayout settingsContainer = new LinearLayout(parentActivity);
            settingsContainer.setPadding(0, 0, 0, AndroidUtilities.dp(4));
            settingsContainer.setOrientation(LinearLayout.VERTICAL);
            HeaderCell headerCell = new HeaderCell(parentActivity);
            headerCell.setText(LocaleController.getString("FontSize", R.string.FontSize));
            settingsContainer.addView(headerCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 3, 1, 3, 0));
            TextSizeCell sizeCell = new TextSizeCell(parentActivity);
            settingsContainer.addView(sizeCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 3, 0, 3, 0));
            headerCell = new HeaderCell(parentActivity);
            headerCell.setText(LocaleController.getString("FontType", R.string.FontType));
            settingsContainer.addView(headerCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 3, 4, 3, 2));
            for (int a = 0; a < 2; a++) {
                fontCells[a] = new FontCell(parentActivity);
                switch(a) {
                    case 0:
                        fontCells[a].setTextAndTypeface(LocaleController.getString("Default", R.string.Default), Typeface.DEFAULT);
                        break;
                    case 1:
                        fontCells[a].setTextAndTypeface("Serif", Typeface.SERIF);
                        break;
                }
                fontCells[a].select(a == selectedFont, false);
                fontCells[a].setTag(a);
                fontCells[a].setOnClickListener(v -> {
                    int num = (Integer) v.getTag();
                    selectedFont = num;
                    for (int a1 = 0; a1 < 2; a1++) {
                        fontCells[a1].select(a1 == num, true);
                    }
                    updatePaintFonts();
                    for (int i = 0; i < listView.length; i++) {
                        adapter[i].notifyDataSetChanged();
                    }
                });
                settingsContainer.addView(fontCells[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50));
            }
            builder.setCustomView(settingsContainer);
            showDialog(linkSheet = builder.create());
        }
    });
    searchPanel = new FrameLayout(parentActivity) {

        @Override
        public void onDraw(Canvas canvas) {
            int bottom = Theme.chat_composeShadowDrawable.getIntrinsicHeight();
            Theme.chat_composeShadowDrawable.setBounds(0, 0, getMeasuredWidth(), bottom);
            Theme.chat_composeShadowDrawable.draw(canvas);
            canvas.drawRect(0, bottom, getMeasuredWidth(), getMeasuredHeight(), Theme.chat_composeBackgroundPaint);
        }
    };
    searchPanel.setOnTouchListener((v, event) -> true);
    searchPanel.setWillNotDraw(false);
    searchPanel.setVisibility(View.INVISIBLE);
    searchPanel.setFocusable(true);
    searchPanel.setFocusableInTouchMode(true);
    searchPanel.setClickable(true);
    searchPanel.setPadding(0, AndroidUtilities.dp(3), 0, 0);
    containerView.addView(searchPanel, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.BOTTOM));
    searchUpButton = new ImageView(parentActivity);
    searchUpButton.setScaleType(ImageView.ScaleType.CENTER);
    searchUpButton.setImageResource(R.drawable.msg_go_up);
    searchUpButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText), PorterDuff.Mode.MULTIPLY));
    searchUpButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_actionBarActionModeDefaultSelector), 1));
    searchPanel.addView(searchUpButton, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP, 0, 0, 48, 0));
    searchUpButton.setOnClickListener(view -> scrollToSearchIndex(currentSearchIndex - 1));
    searchUpButton.setContentDescription(LocaleController.getString("AccDescrSearchNext", R.string.AccDescrSearchNext));
    searchDownButton = new ImageView(parentActivity);
    searchDownButton.setScaleType(ImageView.ScaleType.CENTER);
    searchDownButton.setImageResource(R.drawable.msg_go_down);
    searchDownButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText), PorterDuff.Mode.MULTIPLY));
    searchDownButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_actionBarActionModeDefaultSelector), 1));
    searchPanel.addView(searchDownButton, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP, 0, 0, 0, 0));
    searchDownButton.setOnClickListener(view -> scrollToSearchIndex(currentSearchIndex + 1));
    searchDownButton.setContentDescription(LocaleController.getString("AccDescrSearchPrev", R.string.AccDescrSearchPrev));
    searchCountText = new SimpleTextView(parentActivity);
    searchCountText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    searchCountText.setTextSize(15);
    searchCountText.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    searchCountText.setGravity(Gravity.LEFT);
    searchPanel.addView(searchCountText, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 18, 0, 108, 0));
    windowLayoutParams = new WindowManager.LayoutParams();
    windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
    windowLayoutParams.format = PixelFormat.TRANSLUCENT;
    windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    windowLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW - 1;
    windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
    windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
    if (Build.VERSION.SDK_INT >= 21) {
        windowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
        if (Build.VERSION.SDK_INT >= 28) {
            windowLayoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
        }
    }
    textSelectionHelper = new TextSelectionHelper.ArticleTextSelectionHelper();
    textSelectionHelper.setParentView(listView[0]);
    if (MessagesController.getGlobalMainSettings().getBoolean("translate_button", false)) {
        textSelectionHelper.setOnTranslate((text, fromLang, toLang, onAlertDismiss) -> {
            TranslateAlert.showAlert(parentActivity, parentFragment, fromLang, toLang, text, false, null, onAlertDismiss);
        });
    }
    textSelectionHelper.layoutManager = layoutManager[0];
    textSelectionHelper.setCallback(new TextSelectionHelper.Callback() {

        @Override
        public void onStateChanged(boolean isSelected) {
            if (isSelected) {
                showSearch(false);
            }
        }

        @Override
        public void onTextCopied() {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
                BulletinFactory.of(containerView, null).createCopyBulletin(LocaleController.getString("TextCopied", R.string.TextCopied)).show();
            }
        }
    });
    containerView.addView(textSelectionHelper.getOverlayView(activity));
    pinchToZoomHelper = new PinchToZoomHelper(containerView, windowView);
    pinchToZoomHelper.setClipBoundsListener(new PinchToZoomHelper.ClipBoundsListener() {

        @Override
        public void getClipTopBottom(float[] topBottom) {
            topBottom[0] = currentHeaderHeight;
            topBottom[1] = listView[0].getMeasuredHeight();
        }
    });
    pinchToZoomHelper.setCallback(new PinchToZoomHelper.Callback() {

        @Override
        public void onZoomStarted(MessageObject messageObject) {
            if (listView[0] != null) {
                listView[0].cancelClickRunnables(true);
            }
        }
    });
    updatePaintColors();
}
Also used : POSITION_FLAG_RIGHT(org.telegram.messenger.MessageObject.POSITION_FLAG_RIGHT) JavascriptInterface(android.webkit.JavascriptInterface) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) ColorDrawable(android.graphics.drawable.ColorDrawable) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) Drawable(android.graphics.drawable.Drawable) Property(android.util.Property) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) MediaActionDrawable(org.telegram.ui.Components.MediaActionDrawable) HorizontalScrollView(android.widget.HorizontalScrollView) Keep(androidx.annotation.Keep) CookieManager(android.webkit.CookieManager) RadioButton(org.telegram.ui.Components.RadioButton) Canvas(android.graphics.Canvas) TargetApi(android.annotation.TargetApi) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) AnimationProperties(org.telegram.ui.Components.AnimationProperties) MetricAffectingSpan(android.text.style.MetricAffectingSpan) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) NotificationCenter(org.telegram.messenger.NotificationCenter) TextPaintSpan(org.telegram.ui.Components.TextPaintSpan) HapticFeedbackConstants(android.view.HapticFeedbackConstants) StaticLayoutEx(org.telegram.ui.Components.StaticLayoutEx) Layout(android.text.Layout) TextPaint(android.text.TextPaint) TextPaintMarkSpan(org.telegram.ui.Components.TextPaintMarkSpan) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TextWatcher(android.text.TextWatcher) FileLoader(org.telegram.messenger.FileLoader) ViewPager(androidx.viewpager.widget.ViewPager) Dialog(android.app.Dialog) AlertsCreator(org.telegram.ui.Components.AlertsCreator) Editable(android.text.Editable) ArrayList(java.util.ArrayList) SpannableStringBuilder(android.text.SpannableStringBuilder) DisplayCutout(android.view.DisplayCutout) WebSettings(android.webkit.WebSettings) TLRPC(org.telegram.tgnet.TLRPC) Toast(android.widget.Toast) Menu(android.view.Menu) WebChromeClient(android.webkit.WebChromeClient) AspectRatioFrameLayout(com.google.android.exoplayer2.ui.AspectRatioFrameLayout) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) URLSpan(android.text.style.URLSpan) R(org.telegram.messenger.R) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) TextUtils(android.text.TextUtils) POSITION_FLAG_TOP(org.telegram.messenger.MessageObject.POSITION_FLAG_TOP) File(java.io.File) Gravity(android.view.Gravity) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) MessagesStorage(org.telegram.messenger.MessagesStorage) ValueAnimator(android.animation.ValueAnimator) Rect(android.graphics.Rect) ActionMode(android.view.ActionMode) LinearLayout(android.widget.LinearLayout) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) AnimatedArrowDrawable(org.telegram.ui.Components.AnimatedArrowDrawable) RadialProgress2(org.telegram.ui.Components.RadialProgress2) URLDecoder(java.net.URLDecoder) Spannable(android.text.Spannable) WindowManager(android.view.WindowManager) AndroidUtilities(org.telegram.messenger.AndroidUtilities) CubicBezierInterpolator(org.telegram.ui.Components.CubicBezierInterpolator) Animator(android.animation.Animator) POSITION_FLAG_BOTTOM(org.telegram.messenger.MessageObject.POSITION_FLAG_BOTTOM) TypefaceSpan(org.telegram.ui.Components.TypefaceSpan) WebFile(org.telegram.messenger.WebFile) ViewConfiguration(android.view.ViewConfiguration) JSONObject(org.json.JSONObject) ApplicationLoader(org.telegram.messenger.ApplicationLoader) Locale(java.util.Locale) WebViewClient(android.webkit.WebViewClient) MediaController(org.telegram.messenger.MediaController) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) WebView(android.webkit.WebView) DataSetObserver(android.database.DataSetObserver) POSITION_FLAG_LEFT(org.telegram.messenger.MessageObject.POSITION_FLAG_LEFT) RectF(android.graphics.RectF) ImageLoader(org.telegram.messenger.ImageLoader) IntEvaluator(android.animation.IntEvaluator) ContextProgressView(org.telegram.ui.Components.ContextProgressView) Utilities(org.telegram.messenger.Utilities) ObjectAnimator(android.animation.ObjectAnimator) GridLayoutManagerFixed(androidx.recyclerview.widget.GridLayoutManagerFixed) ImageLocation(org.telegram.messenger.ImageLocation) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) ViewAnimationUtils(android.view.ViewAnimationUtils) TextPaintImageReceiverSpan(org.telegram.ui.Components.TextPaintImageReceiverSpan) PorterDuff(android.graphics.PorterDuff) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) TableLayout(org.telegram.ui.Components.TableLayout) ViewGroup(android.view.ViewGroup) ShareAlert(org.telegram.ui.Components.ShareAlert) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) SparseArray(android.util.SparseArray) UserConfig(org.telegram.messenger.UserConfig) List(java.util.List) TextView(android.widget.TextView) WebPlayerView(org.telegram.ui.Components.WebPlayerView) WindowInsets(android.view.WindowInsets) LinkPath(org.telegram.ui.Components.LinkPath) EditorInfo(android.view.inputmethod.EditorInfo) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ActionBarPopupWindow(org.telegram.ui.ActionBar.ActionBarPopupWindow) Typeface(android.graphics.Typeface) Context(android.content.Context) StaticLayout(android.text.StaticLayout) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) TextSelectionHelper(org.telegram.ui.Cells.TextSelectionHelper) Spanned(android.text.Spanned) KeyEvent(android.view.KeyEvent) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) Theme(org.telegram.ui.ActionBar.Theme) TextPaintWebpageUrlSpan(org.telegram.ui.Components.TextPaintWebpageUrlSpan) PagerAdapter(androidx.viewpager.widget.PagerAdapter) BulletinFactory(org.telegram.ui.Components.BulletinFactory) TextPaintUrlSpan(org.telegram.ui.Components.TextPaintUrlSpan) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) HashMap(java.util.HashMap) HeaderCell(org.telegram.ui.Cells.HeaderCell) TranslateAlert(org.telegram.ui.Components.TranslateAlert) PixelFormat(android.graphics.PixelFormat) MenuItem(android.view.MenuItem) SeekBar(org.telegram.ui.Components.SeekBar) VelocityTracker(android.view.VelocityTracker) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) ActionBar(org.telegram.ui.ActionBar.ActionBar) TLObject(org.telegram.tgnet.TLObject) AnimatorSet(android.animation.AnimatorSet) MessageObject(org.telegram.messenger.MessageObject) SharedConfig(org.telegram.messenger.SharedConfig) Build(android.os.Build) AnchorSpan(org.telegram.ui.Components.AnchorSpan) SeekBarView(org.telegram.ui.Components.SeekBarView) DownloadController(org.telegram.messenger.DownloadController) Browser(org.telegram.messenger.browser.Browser) LongSparseArray(androidx.collection.LongSparseArray) LayoutHelper(org.telegram.ui.Components.LayoutHelper) TextureView(android.view.TextureView) FileLog(org.telegram.messenger.FileLog) LineProgressView(org.telegram.ui.Components.LineProgressView) MessagesController(org.telegram.messenger.MessagesController) Color(android.graphics.Color) SoundEffectConstants(android.view.SoundEffectConstants) CloseProgressDrawable2(org.telegram.ui.Components.CloseProgressDrawable2) Activity(android.app.Activity) ImageReceiver(org.telegram.messenger.ImageReceiver) Collections(java.util.Collections) RecyclerListView(org.telegram.ui.Components.RecyclerListView) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) SpannableStringBuilder(android.text.SpannableStringBuilder) HeaderCell(org.telegram.ui.Cells.HeaderCell) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) CloseProgressDrawable2(org.telegram.ui.Components.CloseProgressDrawable2) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) TLRPC(org.telegram.tgnet.TLRPC) ImageView(android.widget.ImageView) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) Canvas(android.graphics.Canvas) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) ActionMode(android.view.ActionMode) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) ContextProgressView(org.telegram.ui.Components.ContextProgressView) ShareAlert(org.telegram.ui.Components.ShareAlert) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RecyclerListView(org.telegram.ui.Components.RecyclerListView) WindowManager(android.view.WindowManager) AspectRatioFrameLayout(com.google.android.exoplayer2.ui.AspectRatioFrameLayout) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextureView(android.view.TextureView) Menu(android.view.Menu) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) SharedPreferences(android.content.SharedPreferences) TextSelectionHelper(org.telegram.ui.Cells.TextSelectionHelper) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) WebView(android.webkit.WebView) ContextProgressView(org.telegram.ui.Components.ContextProgressView) TextView(android.widget.TextView) WebPlayerView(org.telegram.ui.Components.WebPlayerView) SeekBarView(org.telegram.ui.Components.SeekBarView) TextureView(android.view.TextureView) LineProgressView(org.telegram.ui.Components.LineProgressView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent) TLObject(org.telegram.tgnet.TLObject) FrameLayout(android.widget.FrameLayout) AspectRatioFrameLayout(com.google.android.exoplayer2.ui.AspectRatioFrameLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) LineProgressView(org.telegram.ui.Components.LineProgressView) MessageObject(org.telegram.messenger.MessageObject) LinearLayout(android.widget.LinearLayout)

Aggregations

BaseFragment (org.telegram.ui.ActionBar.BaseFragment)46 Paint (android.graphics.Paint)25 Bundle (android.os.Bundle)18 TLRPC (org.telegram.tgnet.TLRPC)18 FrameLayout (android.widget.FrameLayout)17 ArrayList (java.util.ArrayList)17 SuppressLint (android.annotation.SuppressLint)16 View (android.view.View)15 TextView (android.widget.TextView)15 Animator (android.animation.Animator)14 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)14 ObjectAnimator (android.animation.ObjectAnimator)14 SharedPreferences (android.content.SharedPreferences)14 Canvas (android.graphics.Canvas)14 RecyclerView (androidx.recyclerview.widget.RecyclerView)14 Context (android.content.Context)13 Intent (android.content.Intent)13 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)13 TLObject (org.telegram.tgnet.TLObject)13 AlertDialog (org.telegram.ui.ActionBar.AlertDialog)13