Search in sources :

Example 1 with EditTextBoldCursor

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

the class ChangeUsernameActivity method createView.

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("Username", R.string.Username));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                saveName();
            }
        }
    });
    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56), LocaleController.getString("Done", R.string.Done));
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    if (user == null) {
        user = UserConfig.getInstance(currentAccount).getCurrentUser();
    }
    fragmentView = new LinearLayout(context);
    LinearLayout linearLayout = (LinearLayout) fragmentView;
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    fragmentView.setOnTouchListener((v, event) -> true);
    firstNameField = new EditTextBoldCursor(context);
    firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    firstNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    firstNameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    firstNameField.setBackgroundDrawable(Theme.createEditTextDrawable(context, false));
    firstNameField.setMaxLines(1);
    firstNameField.setLines(1);
    firstNameField.setPadding(0, 0, 0, 0);
    firstNameField.setSingleLine(true);
    firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    firstNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    firstNameField.setHint(LocaleController.getString("UsernamePlaceholder", R.string.UsernamePlaceholder));
    firstNameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    firstNameField.setCursorSize(AndroidUtilities.dp(20));
    firstNameField.setCursorWidth(1.5f);
    firstNameField.setOnEditorActionListener((textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
            doneButton.performClick();
            return true;
        }
        return false;
    });
    firstNameField.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            if (ignoreCheck) {
                return;
            }
            checkUserName(firstNameField.getText().toString(), false);
        }

        @Override
        public void afterTextChanged(Editable editable) {
            String name = firstNameField.getText().toString();
            if (name.startsWith("@")) {
                name = name.substring(1);
            }
            if (name.length() > 0) {
                String url = "https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/" + name;
                String text = LocaleController.formatString("UsernameHelpLink", R.string.UsernameHelpLink, url);
                int index = text.indexOf(url);
                SpannableStringBuilder textSpan = new SpannableStringBuilder(text);
                if (index >= 0) {
                    textSpan.setSpan(new LinkSpan(url), index, index + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
                helpTextView.setText(TextUtils.concat(infoText, "\n\n", textSpan));
            } else {
                helpTextView.setText(infoText);
            }
        }
    });
    linearLayout.addView(firstNameField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));
    checkTextView = new TextView(context);
    checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    linearLayout.addView(checkTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 12, 24, 0));
    helpTextView = new TextView(context);
    helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    helpTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText8));
    helpTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    helpTextView.setText(infoText = AndroidUtilities.replaceTags(LocaleController.getString("UsernameHelp", R.string.UsernameHelp)));
    helpTextView.setLinkTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkText));
    helpTextView.setHighlightColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkSelection));
    helpTextView.setMovementMethod(new LinkMovementMethodMy());
    linearLayout.addView(helpTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 10, 24, 0));
    checkTextView.setVisibility(View.GONE);
    if (user != null && user.username != null && user.username.length() > 0) {
        ignoreCheck = true;
        firstNameField.setText(user.username);
        firstNameField.setSelection(firstNameField.length());
        ignoreCheck = false;
    }
    return fragmentView;
}
Also used : ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) TextPaint(android.text.TextPaint) TLRPC(org.telegram.tgnet.TLRPC) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) ActionBar(org.telegram.ui.ActionBar.ActionBar) LinearLayout(android.widget.LinearLayout) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 2 with EditTextBoldCursor

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

the class ChangeNameActivity method createView.

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                if (firstNameField.getText().length() != 0) {
                    saveName();
                    finishFragment();
                }
            }
        }
    });
    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56), LocaleController.getString("Done", R.string.Done));
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    if (user == null) {
        user = UserConfig.getInstance(currentAccount).getCurrentUser();
    }
    LinearLayout linearLayout = new LinearLayout(context);
    fragmentView = linearLayout;
    fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
    fragmentView.setOnTouchListener((v, event) -> true);
    firstNameField = new EditTextBoldCursor(context);
    firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    firstNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    firstNameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    firstNameField.setBackgroundDrawable(Theme.createEditTextDrawable(context, false));
    firstNameField.setMaxLines(1);
    firstNameField.setLines(1);
    firstNameField.setSingleLine(true);
    firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
    firstNameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    firstNameField.setCursorSize(AndroidUtilities.dp(20));
    firstNameField.setCursorWidth(1.5f);
    linearLayout.addView(firstNameField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));
    firstNameField.setOnEditorActionListener((textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_NEXT) {
            lastNameField.requestFocus();
            lastNameField.setSelection(lastNameField.length());
            return true;
        }
        return false;
    });
    lastNameField = new EditTextBoldCursor(context);
    lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    lastNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    lastNameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    lastNameField.setBackgroundDrawable(Theme.createEditTextDrawable(context, false));
    lastNameField.setMaxLines(1);
    lastNameField.setLines(1);
    lastNameField.setSingleLine(true);
    lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    lastNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    lastNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
    lastNameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    lastNameField.setCursorSize(AndroidUtilities.dp(20));
    lastNameField.setCursorWidth(1.5f);
    linearLayout.addView(lastNameField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 16, 24, 0));
    lastNameField.setOnEditorActionListener((textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_DONE) {
            doneButton.performClick();
            return true;
        }
        return false;
    });
    if (user != null) {
        firstNameField.setText(user.first_name);
        firstNameField.setSelection(firstNameField.length());
        lastNameField.setText(user.last_name);
    }
    return fragmentView;
}
Also used : ViewGroup(android.view.ViewGroup) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) ActionBar(org.telegram.ui.ActionBar.ActionBar) TLRPC(org.telegram.tgnet.TLRPC) LinearLayout(android.widget.LinearLayout)

Example 3 with EditTextBoldCursor

use of org.telegram.ui.Components.EditTextBoldCursor 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)

Example 4 with EditTextBoldCursor

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

the class ThemeSetUrlActivity method createView.

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    if (creatingNewTheme) {
        actionBar.setTitle(LocaleController.getString("NewThemeTitle", R.string.NewThemeTitle));
    } else {
        actionBar.setTitle(LocaleController.getString("EditThemeTitle", R.string.EditThemeTitle));
    }
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                saveTheme();
            }
        }
    });
    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItem(done_button, LocaleController.getString("Done", R.string.Done).toUpperCase());
    fragmentView = new LinearLayout(context);
    fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
    LinearLayout linearLayout = (LinearLayout) fragmentView;
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    fragmentView.setOnTouchListener((v, event) -> true);
    linearLayoutTypeContainer = new LinearLayout(context);
    linearLayoutTypeContainer.setOrientation(LinearLayout.VERTICAL);
    linearLayoutTypeContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    linearLayout.addView(linearLayoutTypeContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    headerCell = new HeaderCell(context, 23);
    headerCell.setText(LocaleController.getString("Info", R.string.Info));
    linearLayoutTypeContainer.addView(headerCell);
    nameField = new EditTextBoldCursor(context);
    nameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    nameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    nameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    nameField.setMaxLines(1);
    nameField.setLines(1);
    nameField.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    nameField.setBackgroundDrawable(null);
    nameField.setPadding(0, 0, 0, 0);
    nameField.setSingleLine(true);
    InputFilter[] inputFilters = new InputFilter[1];
    inputFilters[0] = new InputFilter.LengthFilter(128);
    nameField.setFilters(inputFilters);
    nameField.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    nameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    nameField.setHint(LocaleController.getString("ThemeNamePlaceholder", R.string.ThemeNamePlaceholder));
    nameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    nameField.setCursorSize(AndroidUtilities.dp(20));
    nameField.setCursorWidth(1.5f);
    linearLayoutTypeContainer.addView(nameField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50, 23, 0, 23, 0));
    nameField.setOnEditorActionListener((textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_DONE) {
            AndroidUtilities.hideKeyboard(nameField);
            return true;
        }
        return false;
    });
    divider = new View(context) {

        @Override
        protected void onDraw(Canvas canvas) {
            canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 1, Theme.dividerPaint);
        }
    };
    linearLayoutTypeContainer.addView(divider, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
    LinearLayout linkContainer = new LinearLayout(context);
    linkContainer.setOrientation(LinearLayout.HORIZONTAL);
    linearLayoutTypeContainer.addView(linkContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50, 23, 0, 23, 0));
    editText = new EditTextBoldCursor(context);
    editText.setText(getMessagesController().linkPrefix + "/addtheme/");
    editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    editText.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    editText.setMaxLines(1);
    editText.setLines(1);
    editText.setEnabled(false);
    editText.setBackgroundDrawable(null);
    editText.setPadding(0, 0, 0, 0);
    editText.setSingleLine(true);
    editText.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    linkContainer.addView(editText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 50));
    linkField = new EditTextBoldCursor(context);
    linkField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    linkField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    linkField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    linkField.setMaxLines(1);
    linkField.setLines(1);
    linkField.setBackgroundDrawable(null);
    linkField.setPadding(0, 0, 0, 0);
    linkField.setSingleLine(true);
    linkField.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    linkField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    linkField.setHint(LocaleController.getString("SetUrlPlaceholder", R.string.SetUrlPlaceholder));
    linkField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    linkField.setCursorSize(AndroidUtilities.dp(20));
    linkField.setCursorWidth(1.5f);
    linkContainer.addView(linkField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 50));
    linkField.setOnEditorActionListener((textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
            doneButton.performClick();
            return true;
        }
        return false;
    });
    linkField.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            if (ignoreCheck) {
                return;
            }
            checkUrl(linkField.getText().toString(), false);
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (creatingNewTheme) {
                return;
            }
            if (linkField.length() > 0) {
                String url = "https://" + getMessagesController().linkPrefix + "/addtheme/" + linkField.getText();
                String text = LocaleController.formatString("ThemeHelpLink", R.string.ThemeHelpLink, url);
                int index = text.indexOf(url);
                SpannableStringBuilder textSpan = new SpannableStringBuilder(text);
                if (index >= 0) {
                    textSpan.setSpan(new LinkSpan(url), index, index + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
                helpInfoCell.setText(TextUtils.concat(infoText, "\n\n", textSpan));
            } else {
                helpInfoCell.setText(infoText);
            }
        }
    });
    if (creatingNewTheme) {
        linkField.setOnFocusChangeListener((v, hasFocus) -> {
            if (hasFocus) {
                helpInfoCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("ThemeCreateHelp2", R.string.ThemeCreateHelp2)));
            } else {
                helpInfoCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("ThemeCreateHelp", R.string.ThemeCreateHelp)));
            }
        });
    }
    checkInfoCell = new TextInfoPrivacyCell(context);
    checkInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
    checkInfoCell.setVisibility(View.GONE);
    checkInfoCell.setBottomPadding(0);
    linearLayout.addView(checkInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    helpInfoCell = new TextInfoPrivacyCell(context);
    helpInfoCell.getTextView().setMovementMethod(new LinkMovementMethodMy());
    helpInfoCell.getTextView().setHighlightColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkSelection));
    if (creatingNewTheme) {
        helpInfoCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("ThemeCreateHelp", R.string.ThemeCreateHelp)));
    } else {
        helpInfoCell.setText(infoText = AndroidUtilities.replaceTags(LocaleController.getString("ThemeSetUrlHelp", R.string.ThemeSetUrlHelp)));
    }
    linearLayout.addView(helpInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    if (creatingNewTheme) {
        helpInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
        messagesCell = new ThemePreviewMessagesCell(context, parentLayout, 1);
        linearLayout.addView(messagesCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        createCell = new TextSettingsCell(context);
        createCell.setBackgroundDrawable(Theme.getSelectorDrawable(true));
        createCell.setText(LocaleController.getString("UseDifferentTheme", R.string.UseDifferentTheme), false);
        linearLayout.addView(createCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        createCell.setOnClickListener(v -> {
            if (getParentActivity() == null) {
                return;
            }
            BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity(), false);
            builder.setApplyBottomPadding(false);
            LinearLayout container = new LinearLayout(context);
            container.setOrientation(LinearLayout.VERTICAL);
            TextView titleView = new TextView(context);
            titleView.setText(LocaleController.getString("ChooseTheme", R.string.ChooseTheme));
            titleView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
            titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
            titleView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
            container.addView(titleView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 22, 12, 22, 4));
            titleView.setOnTouchListener((v2, event) -> true);
            builder.setCustomView(container);
            ArrayList<Theme.ThemeInfo> themes = new ArrayList<>();
            for (int a = 0, N = Theme.themes.size(); a < N; a++) {
                Theme.ThemeInfo themeInfo = Theme.themes.get(a);
                if (themeInfo.info != null && themeInfo.info.document == null) {
                    continue;
                }
                themes.add(themeInfo);
            }
            ThemesHorizontalListCell cell = new ThemesHorizontalListCell(context, ThemeActivity.THEME_TYPE_OTHER, themes, new ArrayList<>()) {

                @Override
                protected void updateRows() {
                    builder.getDismissRunnable().run();
                }
            };
            container.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 148, 0, 7, 0, 1));
            cell.scrollToCurrentTheme(fragmentView.getMeasuredWidth(), false);
            showDialog(builder.create());
        });
        createInfoCell = new TextInfoPrivacyCell(context);
        createInfoCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("UseDifferentThemeInfo", R.string.UseDifferentThemeInfo)));
        createInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
        linearLayout.addView(createInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
    } else {
        helpInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
    }
    if (info != null) {
        ignoreCheck = true;
        nameField.setText(info.title);
        nameField.setSelection(nameField.length());
        linkField.setText(info.slug);
        linkField.setSelection(linkField.length());
        ignoreCheck = false;
    }
    return fragmentView;
}
Also used : HeaderCell(org.telegram.ui.Cells.HeaderCell) SpannableStringBuilder(android.text.SpannableStringBuilder) ArrayList(java.util.ArrayList) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) ActionBar(org.telegram.ui.ActionBar.ActionBar) InputFilter(android.text.InputFilter) ThemePreviewMessagesCell(org.telegram.ui.Cells.ThemePreviewMessagesCell) Canvas(android.graphics.Canvas) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) ThemesHorizontalListCell(org.telegram.ui.Cells.ThemesHorizontalListCell) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) View(android.view.View) TextView(android.widget.TextView) TextPaint(android.text.TextPaint) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) Theme(org.telegram.ui.ActionBar.Theme) BottomSheet(org.telegram.ui.ActionBar.BottomSheet) LinearLayout(android.widget.LinearLayout) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 5 with EditTextBoldCursor

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

the class LocationActivity method createView.

@Override
public View createView(Context context) {
    searchWas = false;
    searching = false;
    searchInProgress = false;
    if (adapter != null) {
        adapter.destroy();
    }
    if (searchAdapter != null) {
        searchAdapter.destroy();
    }
    if (chatLocation != null) {
        userLocation = new Location("network");
        userLocation.setLatitude(chatLocation.geo_point.lat);
        userLocation.setLongitude(chatLocation.geo_point._long);
    } else if (messageObject != null) {
        userLocation = new Location("network");
        userLocation.setLatitude(messageObject.messageOwner.media.geo.lat);
        userLocation.setLongitude(messageObject.messageOwner.media.geo._long);
    }
    locationDenied = Build.VERSION.SDK_INT >= 23 && getParentActivity() != null && getParentActivity().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED;
    actionBar.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
    actionBar.setTitleColor(Theme.getColor(Theme.key_dialogTextBlack));
    actionBar.setItemsColor(Theme.getColor(Theme.key_dialogTextBlack), false);
    actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_dialogButtonSelector), false);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    if (AndroidUtilities.isTablet()) {
        actionBar.setOccupyStatusBar(false);
    }
    actionBar.setAddToContainer(false);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {

        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == open_in) {
                try {
                    double lat = messageObject.messageOwner.media.geo.lat;
                    double lon = messageObject.messageOwner.media.geo._long;
                    getParentActivity().startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:" + lat + "," + lon + "?q=" + lat + "," + lon)));
                } catch (Exception e) {
                    FileLog.e(e);
                }
            } else if (id == share_live_location) {
                openShareLiveLocation(0);
            }
        }
    });
    ActionBarMenu menu = actionBar.createMenu();
    if (chatLocation != null) {
        actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
    } else if (messageObject != null) {
        if (messageObject.isLiveLocation()) {
            actionBar.setTitle(LocaleController.getString("AttachLiveLocation", R.string.AttachLiveLocation));
        } else {
            if (messageObject.messageOwner.media.title != null && messageObject.messageOwner.media.title.length() > 0) {
                actionBar.setTitle(LocaleController.getString("SharedPlace", R.string.SharedPlace));
            } else {
                actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
            }
            otherItem = menu.addItem(0, R.drawable.ic_ab_other);
            otherItem.addSubItem(open_in, R.drawable.msg_openin, LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
            if (!getLocationController().isSharingLocation(dialogId)) {
                otherItem.addSubItem(share_live_location, R.drawable.menu_location, LocaleController.getString("SendLiveLocationMenu", R.string.SendLiveLocationMenu));
            }
            otherItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
        }
    } else {
        actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation));
        if (locationType != LOCATION_TYPE_GROUP) {
            overlayView = new MapOverlayView(context);
            searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {

                @Override
                public void onSearchExpand() {
                    searching = true;
                }

                @Override
                public void onSearchCollapse() {
                    searching = false;
                    searchWas = false;
                    searchAdapter.searchDelayed(null, null);
                    updateEmptyView();
                }

                @Override
                public void onTextChanged(EditText editText) {
                    if (searchAdapter == null) {
                        return;
                    }
                    String text = editText.getText().toString();
                    if (text.length() != 0) {
                        searchWas = true;
                        searchItem.setShowSearchProgress(true);
                        if (otherItem != null) {
                            otherItem.setVisibility(View.GONE);
                        }
                        listView.setVisibility(View.GONE);
                        mapViewClip.setVisibility(View.GONE);
                        if (searchListView.getAdapter() != searchAdapter) {
                            searchListView.setAdapter(searchAdapter);
                        }
                        searchListView.setVisibility(View.VISIBLE);
                        searchInProgress = searchAdapter.getItemCount() == 0;
                    } else {
                        if (otherItem != null) {
                            otherItem.setVisibility(View.VISIBLE);
                        }
                        listView.setVisibility(View.VISIBLE);
                        mapViewClip.setVisibility(View.VISIBLE);
                        searchListView.setAdapter(null);
                        searchListView.setVisibility(View.GONE);
                    }
                    updateEmptyView();
                    searchAdapter.searchDelayed(text, userLocation);
                }
            });
            searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
            searchItem.setContentDescription(LocaleController.getString("Search", R.string.Search));
            EditTextBoldCursor editText = searchItem.getSearchField();
            editText.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
            editText.setCursorColor(Theme.getColor(Theme.key_dialogTextBlack));
            editText.setHintTextColor(Theme.getColor(Theme.key_chat_messagePanelHint));
        }
    }
    fragmentView = new FrameLayout(context) {

        private boolean first = true;

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            if (changed) {
                fixLayoutInternal(first);
                first = false;
            } else {
                updateClipView(true);
            }
        }

        @Override
        protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
            boolean result = super.drawChild(canvas, child, drawingTime);
            if (child == actionBar && parentLayout != null) {
                parentLayout.drawHeaderShadow(canvas, actionBar.getMeasuredHeight());
            }
            return result;
        }
    };
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    fragmentView.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
    shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow_round).mutate();
    shadowDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogBackground), PorterDuff.Mode.MULTIPLY));
    Rect padding = new Rect();
    shadowDrawable.getPadding(padding);
    FrameLayout.LayoutParams layoutParams;
    if (locationType == LOCATION_TYPE_SEND || locationType == LOCATION_TYPE_SEND_WITH_LIVE) {
        layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, AndroidUtilities.dp(21) + padding.top);
    } else {
        layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, AndroidUtilities.dp(6) + padding.top);
    }
    layoutParams.gravity = Gravity.LEFT | Gravity.BOTTOM;
    mapViewClip = new FrameLayout(context) {

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            if (overlayView != null) {
                overlayView.updatePositions();
            }
        }
    };
    mapViewClip.setBackgroundDrawable(new MapPlaceholderDrawable());
    if (messageObject == null && (locationType == LOCATION_TYPE_SEND || locationType == LOCATION_TYPE_SEND_WITH_LIVE)) {
        searchAreaButton = new SearchButton(context);
        searchAreaButton.setTranslationX(-AndroidUtilities.dp(80));
        Drawable drawable = Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(40), Theme.getColor(Theme.key_location_actionBackground), Theme.getColor(Theme.key_location_actionPressedBackground));
        if (Build.VERSION.SDK_INT < 21) {
            Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.places_btn).mutate();
            shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
            CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, AndroidUtilities.dp(2), AndroidUtilities.dp(2));
            combinedDrawable.setFullsize(true);
            drawable = combinedDrawable;
        } else {
            StateListAnimator animator = new StateListAnimator();
            animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(searchAreaButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
            animator.addState(new int[] {}, ObjectAnimator.ofFloat(searchAreaButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
            searchAreaButton.setStateListAnimator(animator);
            searchAreaButton.setOutlineProvider(new ViewOutlineProvider() {

                @SuppressLint("NewApi")
                @Override
                public void getOutline(View view, Outline outline) {
                    outline.setRoundRect(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight(), view.getMeasuredHeight() / 2);
                }
            });
        }
        searchAreaButton.setBackgroundDrawable(drawable);
        searchAreaButton.setTextColor(Theme.getColor(Theme.key_location_actionActiveIcon));
        searchAreaButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
        searchAreaButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
        searchAreaButton.setText(LocaleController.getString("PlacesInThisArea", R.string.PlacesInThisArea));
        searchAreaButton.setGravity(Gravity.CENTER);
        searchAreaButton.setPadding(AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20), 0);
        mapViewClip.addView(searchAreaButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, Build.VERSION.SDK_INT >= 21 ? 40 : 44, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 80, 12, 80, 0));
        searchAreaButton.setOnClickListener(v -> {
            showSearchPlacesButton(false);
            adapter.searchPlacesWithQuery(null, userLocation, true, true);
            searchedForCustomLocations = true;
            showResults();
        });
    }
    mapTypeButton = new ActionBarMenuItem(context, null, 0, Theme.getColor(Theme.key_location_actionIcon));
    mapTypeButton.setClickable(true);
    mapTypeButton.setSubMenuOpenSide(2);
    mapTypeButton.setAdditionalXOffset(AndroidUtilities.dp(10));
    mapTypeButton.setAdditionalYOffset(-AndroidUtilities.dp(10));
    mapTypeButton.addSubItem(map_list_menu_osm, R.drawable.msg_map, "Standard OSM");
    mapTypeButton.addSubItem(map_list_menu_wiki, R.drawable.msg_map, "Wikimedia");
    mapTypeButton.addSubItem(map_list_menu_cartodark, R.drawable.msg_map, "Carto Dark");
    mapTypeButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
    Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(40), Theme.getColor(Theme.key_location_actionBackground), Theme.getColor(Theme.key_location_actionPressedBackground));
    if (Build.VERSION.SDK_INT < 21) {
        Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
        combinedDrawable.setIconSize(AndroidUtilities.dp(40), AndroidUtilities.dp(40));
        drawable = combinedDrawable;
    } else {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(mapTypeButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator.ofFloat(mapTypeButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
        mapTypeButton.setStateListAnimator(animator);
        mapTypeButton.setOutlineProvider(new ViewOutlineProvider() {

            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(40), AndroidUtilities.dp(40));
            }
        });
    }
    mapTypeButton.setBackgroundDrawable(drawable);
    mapTypeButton.setIcon(R.drawable.location_type);
    mapViewClip.addView(mapTypeButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 40 : 44, Build.VERSION.SDK_INT >= 21 ? 40 : 44, Gravity.RIGHT | Gravity.TOP, 0, 12, 12, 0));
    mapTypeButton.setOnClickListener(v -> mapTypeButton.toggleSubMenu());
    mapTypeButton.setDelegate(id -> {
        if (mapView == null) {
            return;
        }
        if (id == map_list_menu_osm) {
            attributionOverlay.setText(Html.fromHtml("© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"));
            mapView.setTileSource(TileSourceFactory.MAPNIK);
        } else if (id == map_list_menu_wiki) {
            // Create a custom tile source
            ITileSource tileSource = new XYTileSource("Wikimedia", 0, 19, 256, ".png", new String[] { "https://maps.wikimedia.org/osm-intl/" }, "© OpenStreetMap contributors");
            attributionOverlay.setText(Html.fromHtml("© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"));
            mapView.setTileSource(tileSource);
        } else if (id == map_list_menu_cartodark) {
            // Create a custom tile source
            ITileSource tileSource = new XYTileSource("Carto Dark", 0, 20, 256, ".png", new String[] { "https://cartodb-basemaps-a.global.ssl.fastly.net/dark_all/", "https://cartodb-basemaps-b.global.ssl.fastly.net/dark_all/", "https://cartodb-basemaps-c.global.ssl.fastly.net/dark_all/", "https://cartodb-basemaps-d.global.ssl.fastly.net/dark_all/" }, "© OpenStreetMap contributors, © CARTO");
            attributionOverlay.setText(Html.fromHtml("© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors, © <a href=\"https://carto.com/attributions\">CARTO</a>"));
            mapView.setTileSource(tileSource);
        }
    });
    mapViewClip.addView(getAttributionOverlay(context), LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, LocaleController.isRTL ? 0 : 4, 0, LocaleController.isRTL ? 4 : 0, 20));
    locationButton = new ImageView(context);
    drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(40), Theme.getColor(Theme.key_location_actionBackground), Theme.getColor(Theme.key_location_actionPressedBackground));
    if (Build.VERSION.SDK_INT < 21) {
        Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
        combinedDrawable.setIconSize(AndroidUtilities.dp(40), AndroidUtilities.dp(40));
        drawable = combinedDrawable;
    } else {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(locationButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator.ofFloat(locationButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
        locationButton.setStateListAnimator(animator);
        locationButton.setOutlineProvider(new ViewOutlineProvider() {

            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(40), AndroidUtilities.dp(40));
            }
        });
    }
    locationButton.setBackgroundDrawable(drawable);
    locationButton.setImageResource(R.drawable.location_current);
    locationButton.setScaleType(ImageView.ScaleType.CENTER);
    locationButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionActiveIcon), PorterDuff.Mode.MULTIPLY));
    locationButton.setTag(Theme.key_location_actionActiveIcon);
    locationButton.setContentDescription(LocaleController.getString("AccDescrMyLocation", R.string.AccDescrMyLocation));
    FrameLayout.LayoutParams layoutParams1 = LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 40 : 44, Build.VERSION.SDK_INT >= 21 ? 40 : 44, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 12, 12);
    layoutParams1.bottomMargin += layoutParams.height - padding.top;
    mapViewClip.addView(locationButton, layoutParams1);
    locationButton.setOnClickListener(v -> {
        if (Build.VERSION.SDK_INT >= 23) {
            Activity activity = getParentActivity();
            if (activity != null) {
                if (activity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                    showPermissionAlert(false);
                    return;
                }
            }
        }
        if (!checkGpsEnabled()) {
            return;
        }
        if (messageObject != null || chatLocation != null) {
            if (myLocation != null && mapView != null) {
                final IMapController controller = mapView.getController();
                controller.animateTo(new GeoPoint(myLocation.getLatitude(), myLocation.getLongitude()), mapView.getMaxZoomLevel() - 2, null);
            }
        } else {
            if (myLocation != null && mapView != null) {
                locationButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionActiveIcon), PorterDuff.Mode.MULTIPLY));
                locationButton.setTag(Theme.key_location_actionActiveIcon);
                adapter.setCustomLocation(null);
                userLocationMoved = false;
                showSearchPlacesButton(false);
                final IMapController controller = mapView.getController();
                controller.animateTo(new GeoPoint(myLocation.getLatitude(), myLocation.getLongitude()));
                if (searchedForCustomLocations) {
                    if (myLocation != null) {
                        adapter.searchPlacesWithQuery(null, myLocation, true, true);
                    }
                    searchedForCustomLocations = false;
                    showResults();
                }
            }
        }
        removeInfoView();
    });
    proximityButton = new ImageView(context);
    drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(40), Theme.getColor(Theme.key_location_actionBackground), Theme.getColor(Theme.key_location_actionPressedBackground));
    if (Build.VERSION.SDK_INT < 21) {
        Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
        shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
        CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
        combinedDrawable.setIconSize(AndroidUtilities.dp(40), AndroidUtilities.dp(40));
        drawable = combinedDrawable;
    } else {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(proximityButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator.ofFloat(proximityButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
        proximityButton.setStateListAnimator(animator);
        proximityButton.setOutlineProvider(new ViewOutlineProvider() {

            @SuppressLint("NewApi")
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, AndroidUtilities.dp(40), AndroidUtilities.dp(40));
            }
        });
    }
    proximityButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionIcon), PorterDuff.Mode.MULTIPLY));
    proximityButton.setBackgroundDrawable(drawable);
    proximityButton.setScaleType(ImageView.ScaleType.CENTER);
    proximityButton.setContentDescription(LocaleController.getString("AccDescrLocationNotify", R.string.AccDescrLocationNotify));
    mapViewClip.addView(proximityButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 40 : 44, Build.VERSION.SDK_INT >= 21 ? 40 : 44, Gravity.RIGHT | Gravity.TOP, 0, 12 + 50, 12, 0));
    proximityButton.setOnClickListener(v -> {
        if (getParentActivity() == null || myLocation == null || !checkGpsEnabled() || mapView == null) {
            return;
        }
        if (hintView != null) {
            hintView.hide();
        }
        SharedPreferences preferences = MessagesController.getGlobalMainSettings();
        preferences.edit().putInt("proximityhint", 3).commit();
        LocationController.SharingLocationInfo info = getLocationController().getSharingLocationInfo(dialogId);
        if (canUndo) {
            undoView[0].hide(true, 1);
        }
        if (info != null && info.proximityMeters > 0) {
            proximityButton.setImageResource(R.drawable.msg_location_alert);
            if (proximityCircle != null) {
                mapView.getOverlayManager().remove(proximityCircle);
                proximityCircle = null;
            }
            canUndo = true;
            getUndoView().showWithAction(0, UndoView.ACTION_PROXIMITY_REMOVED, 0, null, () -> {
                getLocationController().setProximityLocation(dialogId, 0, true);
                canUndo = false;
            }, () -> {
                proximityButton.setImageResource(R.drawable.msg_location_alert2);
                createCircle(info.proximityMeters);
                canUndo = false;
            });
            return;
        }
        openProximityAlert();
    });
    TLRPC.Chat chat = null;
    if (DialogObject.isChatDialog(dialogId)) {
        chat = getMessagesController().getChat(-dialogId);
    }
    if (messageObject == null || !messageObject.isLiveLocation() || messageObject.isExpiredLiveLocation(getConnectionsManager().getCurrentTime()) || ChatObject.isChannel(chat) && !chat.megagroup) {
        proximityButton.setVisibility(View.GONE);
        proximityButton.setImageResource(R.drawable.msg_location_alert);
    } else {
        LocationController.SharingLocationInfo myInfo = getLocationController().getSharingLocationInfo(dialogId);
        if (myInfo != null && myInfo.proximityMeters > 0) {
            proximityButton.setImageResource(R.drawable.msg_location_alert2);
        } else {
            if (DialogObject.isUserDialog(dialogId) && messageObject.getFromChatId() == getUserConfig().getClientUserId()) {
                proximityButton.setVisibility(View.INVISIBLE);
                proximityButton.setAlpha(0.0f);
                proximityButton.setScaleX(0.4f);
                proximityButton.setScaleY(0.4f);
            }
            proximityButton.setImageResource(R.drawable.msg_location_alert);
        }
    }
    hintView = new HintView(context, 6, true);
    hintView.setVisibility(View.INVISIBLE);
    hintView.setShowingDuration(4000);
    mapViewClip.addView(hintView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 10, 0, 10, 0));
    emptyView = new LinearLayout(context);
    emptyView.setOrientation(LinearLayout.VERTICAL);
    emptyView.setGravity(Gravity.CENTER_HORIZONTAL);
    emptyView.setPadding(0, AndroidUtilities.dp(60 + 100), 0, 0);
    emptyView.setVisibility(View.GONE);
    frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    emptyView.setOnTouchListener((v, event) -> true);
    emptyImageView = new ImageView(context);
    emptyImageView.setImageResource(R.drawable.location_empty);
    emptyImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogEmptyImage), PorterDuff.Mode.MULTIPLY));
    emptyView.addView(emptyImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
    emptyTitleTextView = new TextView(context);
    emptyTitleTextView.setTextColor(Theme.getColor(Theme.key_dialogEmptyText));
    emptyTitleTextView.setGravity(Gravity.CENTER);
    emptyTitleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    emptyTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
    emptyTitleTextView.setText(LocaleController.getString("NoPlacesFound", R.string.NoPlacesFound));
    emptyView.addView(emptyTitleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 11, 0, 0));
    emptySubtitleTextView = new TextView(context);
    emptySubtitleTextView.setTextColor(Theme.getColor(Theme.key_dialogEmptyText));
    emptySubtitleTextView.setGravity(Gravity.CENTER);
    emptySubtitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    emptySubtitleTextView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), 0);
    emptyView.addView(emptySubtitleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 6, 0, 0));
    listView = new RecyclerListView(context);
    listView.setAdapter(adapter = new LocationActivityAdapter(context, locationType, dialogId, false, null) {

        @Override
        protected void onDirectionClick() {
            if (Build.VERSION.SDK_INT >= 23) {
                Activity activity = getParentActivity();
                if (activity != null) {
                    if (activity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                        showPermissionAlert(true);
                        return;
                    }
                }
            }
            if (myLocation != null) {
                try {
                    Intent intent;
                    if (messageObject != null) {
                        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(Locale.US, "http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", myLocation.getLatitude(), myLocation.getLongitude(), messageObject.messageOwner.media.geo.lat, messageObject.messageOwner.media.geo._long)));
                    } else {
                        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(Locale.US, "http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", myLocation.getLatitude(), myLocation.getLongitude(), chatLocation.geo_point.lat, chatLocation.geo_point._long)));
                    }
                    getParentActivity().startActivity(intent);
                } catch (Exception e) {
                    FileLog.e(e);
                }
            }
        }
    });
    adapter.setMyLocationDenied(locationDenied);
    adapter.setUpdateRunnable(() -> updateClipView(false));
    listView.setVerticalScrollBarEnabled(false);
    listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
    listView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            scrolling = newState != RecyclerView.SCROLL_STATE_IDLE;
            if (!scrolling && forceUpdate != null) {
                forceUpdate = null;
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            updateClipView(false);
            if (forceUpdate != null) {
                yOffset += dy;
            }
        }
    });
    ((DefaultItemAnimator) listView.getItemAnimator()).setDelayAnimations(false);
    listView.setOnItemClickListener((view, position) -> {
        if (locationType == LOCATION_TYPE_GROUP) {
            if (position == 1) {
                TLRPC.TL_messageMediaVenue venue = (TLRPC.TL_messageMediaVenue) adapter.getItem(position);
                if (venue == null) {
                    return;
                }
                if (dialogId == 0) {
                    delegate.didSelectLocation(venue, LOCATION_TYPE_GROUP, true, 0);
                    finishFragment();
                } else {
                    final AlertDialog[] progressDialog = new AlertDialog[] { new AlertDialog(getParentActivity(), 3) };
                    TLRPC.TL_channels_editLocation req = new TLRPC.TL_channels_editLocation();
                    req.address = venue.address;
                    req.channel = getMessagesController().getInputChannel(-dialogId);
                    req.geo_point = new TLRPC.TL_inputGeoPoint();
                    req.geo_point.lat = venue.geo.lat;
                    req.geo_point._long = venue.geo._long;
                    int requestId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                        try {
                            progressDialog[0].dismiss();
                        } catch (Throwable ignore) {
                        }
                        progressDialog[0] = null;
                        delegate.didSelectLocation(venue, LOCATION_TYPE_GROUP, true, 0);
                        finishFragment();
                    }));
                    progressDialog[0].setOnCancelListener(dialog -> getConnectionsManager().cancelRequest(requestId, true));
                    showDialog(progressDialog[0]);
                }
            }
        } else if (locationType == LOCATION_TYPE_GROUP_VIEW) {
            if (mapView != null) {
                final IMapController controller = mapView.getController();
                controller.animateTo(new GeoPoint(chatLocation.geo_point.lat, chatLocation.geo_point._long), mapView.getMaxZoomLevel() - 2, null);
            }
        } else if (position == 1 && messageObject != null && (!messageObject.isLiveLocation() || locationType == LOCATION_TYPE_LIVE_VIEW)) {
            if (mapView != null) {
                final IMapController controller = mapView.getController();
                controller.animateTo(new GeoPoint(messageObject.messageOwner.media.geo.lat, messageObject.messageOwner.media.geo._long), mapView.getMaxZoomLevel() - 2, null);
            }
        } else if (position == 1 && locationType != 2) {
            if (delegate != null && userLocation != null) {
                if (lastPressedMarkerView != null) {
                    lastPressedMarkerView.callOnClick();
                } else {
                    TLRPC.TL_messageMediaGeo location = new TLRPC.TL_messageMediaGeo();
                    location.geo = new TLRPC.TL_geoPoint();
                    location.geo.lat = AndroidUtilities.fixLocationCoord(userLocation.getLatitude());
                    location.geo._long = AndroidUtilities.fixLocationCoord(userLocation.getLongitude());
                    if (parentFragment != null && parentFragment.isInScheduleMode()) {
                        AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), parentFragment.getDialogId(), (notify, scheduleDate) -> {
                            delegate.didSelectLocation(location, locationType, notify, scheduleDate);
                            finishFragment();
                        });
                    } else {
                        delegate.didSelectLocation(location, locationType, true, 0);
                        finishFragment();
                    }
                }
            }
        } else if (position == 2 && locationType == 1 || position == 1 && locationType == 2 || position == 3 && locationType == 3) {
            if (getLocationController().isSharingLocation(dialogId)) {
                getLocationController().removeSharingLocation(dialogId);
                finishFragment();
            } else {
                openShareLiveLocation(0);
            }
        } else {
            Object object = adapter.getItem(position);
            if (object instanceof TLRPC.TL_messageMediaVenue) {
                if (parentFragment != null && parentFragment.isInScheduleMode()) {
                    AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), parentFragment.getDialogId(), (notify, scheduleDate) -> {
                        delegate.didSelectLocation((TLRPC.TL_messageMediaVenue) object, locationType, notify, scheduleDate);
                        finishFragment();
                    });
                } else {
                    delegate.didSelectLocation((TLRPC.TL_messageMediaVenue) object, locationType, true, 0);
                    finishFragment();
                }
            } else if (object instanceof LiveLocation) {
                LiveLocation liveLocation = (LiveLocation) object;
                final IMapController controller = mapView.getController();
                controller.animateTo(liveLocation.marker.getPosition(), mapView.getMaxZoomLevel() - 2, null);
            }
        }
    });
    adapter.setDelegate(dialogId, this::updatePlacesMarkers);
    adapter.setOverScrollHeight(overScrollHeight);
    frameLayout.addView(mapViewClip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
    mapView = new MapView(context) {

        @Override
        public boolean dispatchTouchEvent(MotionEvent ev) {
            MotionEvent eventToRecycle = null;
            if (yOffset != 0) {
                ev = eventToRecycle = MotionEvent.obtain(ev);
                eventToRecycle.offsetLocation(0, -yOffset / 2);
            }
            boolean result = super.dispatchTouchEvent(ev);
            if (eventToRecycle != null) {
                eventToRecycle.recycle();
            }
            return result;
        }

        @Override
        public boolean onTouchEvent(MotionEvent ev) {
            if (messageObject == null && chatLocation == null) {
                if (ev.getAction() == MotionEvent.ACTION_DOWN) {
                    if (animatorSet != null) {
                        animatorSet.cancel();
                    }
                    animatorSet = new AnimatorSet();
                    animatorSet.setDuration(200);
                    animatorSet.playTogether(ObjectAnimator.ofFloat(markerImageView, View.TRANSLATION_Y, markerTop - AndroidUtilities.dp(10)));
                    animatorSet.start();
                } else if (ev.getAction() == MotionEvent.ACTION_UP) {
                    if (animatorSet != null) {
                        animatorSet.cancel();
                    }
                    yOffset = 0;
                    animatorSet = new AnimatorSet();
                    animatorSet.setDuration(200);
                    animatorSet.playTogether(ObjectAnimator.ofFloat(markerImageView, View.TRANSLATION_Y, markerTop));
                    animatorSet.start();
                    adapter.fetchLocationAddress();
                }
                if (ev.getAction() == MotionEvent.ACTION_MOVE) {
                    if (!userLocationMoved) {
                        locationButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionIcon), PorterDuff.Mode.MULTIPLY));
                        locationButton.setTag(Theme.key_location_actionIcon);
                        userLocationMoved = true;
                    }
                    if (mapView != null) {
                        if (userLocation != null) {
                            userLocation.setLatitude(mapView.getMapCenter().getLatitude());
                            userLocation.setLongitude(mapView.getMapCenter().getLongitude());
                        }
                    }
                    adapter.setCustomLocation(userLocation);
                }
            }
            return super.onTouchEvent(ev);
        }

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            AndroidUtilities.runOnUIThread(() -> {
                if (moveToBounds != null) {
                    mapView.zoomToBoundingBox(moveToBounds, false, AndroidUtilities.dp(80 + 33));
                    moveToBounds = null;
                }
            });
        }
    };
    AndroidUtilities.runOnUIThread(() -> {
        if (mapView != null && getParentActivity() != null) {
            mapView.setPadding(AndroidUtilities.dp(70), 0, AndroidUtilities.dp(70), AndroidUtilities.dp(10));
            onMapInit();
            mapsInitialized = true;
            if (isActiveThemeDark()) {
            /*currentMapStyleDark = true;
                    MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(ApplicationLoader.applicationContext, R.raw.mapstyle_night);
                    googleMap.setMapStyle(style);
                    */
            // TODO Dark?
            }
            if (onResumeCalled) {
                mapView.onResume();
            }
        }
    });
    if (messageObject == null && chatLocation == null) {
        if (chat != null && locationType == LOCATION_TYPE_GROUP && dialogId != 0) {
            FrameLayout frameLayout1 = new FrameLayout(context);
            frameLayout1.setBackgroundResource(R.drawable.livepin);
            mapViewClip.addView(frameLayout1, LayoutHelper.createFrame(62, 76, Gravity.TOP | Gravity.CENTER_HORIZONTAL));
            BackupImageView backupImageView = new BackupImageView(context);
            backupImageView.setRoundRadius(AndroidUtilities.dp(26));
            backupImageView.setForUserOrChat(chat, new AvatarDrawable(chat));
            frameLayout1.addView(backupImageView, LayoutHelper.createFrame(52, 52, Gravity.LEFT | Gravity.TOP, 5, 5, 0, 0));
            markerImageView = frameLayout1;
            markerImageView.setTag(1);
        }
        if (markerImageView == null) {
            ImageView imageView = new ImageView(context);
            imageView.setImageResource(R.drawable.map_pin2);
            mapViewClip.addView(imageView, LayoutHelper.createFrame(28, 48, Gravity.TOP | Gravity.CENTER_HORIZONTAL));
            markerImageView = imageView;
        }
        searchListView = new RecyclerListView(context);
        searchListView.setVisibility(View.GONE);
        searchListView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
        searchAdapter = new LocationActivitySearchAdapter(context) {

            @Override
            public void notifyDataSetChanged() {
                if (searchItem != null) {
                    searchItem.setShowSearchProgress(searchAdapter.isSearching());
                }
                if (emptySubtitleTextView != null) {
                    emptySubtitleTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("NoPlacesFoundInfo", R.string.NoPlacesFoundInfo, searchAdapter.getLastSearchString())));
                }
                super.notifyDataSetChanged();
            }
        };
        searchAdapter.setDelegate(0, places -> {
            searchInProgress = false;
            updateEmptyView();
        });
        frameLayout.addView(searchListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
        searchListView.setOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                if (newState == RecyclerView.SCROLL_STATE_DRAGGING && searching && searchWas) {
                    AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
                }
            }
        });
        searchListView.setOnItemClickListener((view, position) -> {
            TLRPC.TL_messageMediaVenue object = searchAdapter.getItem(position);
            if (object != null && delegate != null) {
                if (parentFragment != null && parentFragment.isInScheduleMode()) {
                    AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), parentFragment.getDialogId(), (notify, scheduleDate) -> {
                        delegate.didSelectLocation(object, locationType, notify, scheduleDate);
                        finishFragment();
                    });
                } else {
                    delegate.didSelectLocation(object, locationType, true, 0);
                    finishFragment();
                }
            }
        });
    } else if (messageObject != null && !messageObject.isLiveLocation() || chatLocation != null) {
        if (chatLocation != null) {
            adapter.setChatLocation(chatLocation);
        } else if (messageObject != null) {
            adapter.setMessageObject(messageObject);
        }
    }
    if (messageObject != null && locationType == LOCATION_TYPE_LIVE_VIEW) {
        adapter.setMessageObject(messageObject);
    }
    for (int a = 0; a < 2; a++) {
        undoView[a] = new UndoView(context);
        undoView[a].setAdditionalTranslationY(AndroidUtilities.dp(10));
        if (Build.VERSION.SDK_INT >= 21) {
            undoView[a].setTranslationZ(AndroidUtilities.dp(5));
        }
        mapViewClip.addView(undoView[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
    }
    shadow = new View(context) {

        private RectF rect = new RectF();

        @Override
        protected void onDraw(Canvas canvas) {
            shadowDrawable.setBounds(-padding.left, 0, getMeasuredWidth() + padding.right, getMeasuredHeight());
            shadowDrawable.draw(canvas);
            if (locationType == LOCATION_TYPE_SEND || locationType == LOCATION_TYPE_SEND_WITH_LIVE) {
                int w = AndroidUtilities.dp(36);
                int y = padding.top + AndroidUtilities.dp(10);
                rect.set((getMeasuredWidth() - w) / 2, y, (getMeasuredWidth() + w) / 2, y + AndroidUtilities.dp(4));
                int color = Theme.getColor(Theme.key_sheet_scrollUp);
                int alpha = Color.alpha(color);
                Theme.dialogs_onlineCirclePaint.setColor(color);
                canvas.drawRoundRect(rect, AndroidUtilities.dp(2), AndroidUtilities.dp(2), Theme.dialogs_onlineCirclePaint);
            }
        }
    };
    if (Build.VERSION.SDK_INT >= 21) {
        shadow.setTranslationZ(AndroidUtilities.dp(6));
    }
    mapViewClip.addView(shadow, layoutParams);
    if (messageObject == null && chatLocation == null && initialLocation != null) {
        userLocationMoved = true;
        locationButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_location_actionIcon), PorterDuff.Mode.MULTIPLY));
        locationButton.setTag(Theme.key_location_actionIcon);
    }
    frameLayout.addView(actionBar);
    updateEmptyView();
    return fragmentView;
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) Arrays(java.util.Arrays) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) LocationController(org.telegram.messenger.LocationController) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) Manifest(android.Manifest) StateListAnimator(android.animation.StateListAnimator) ITileSource(org.osmdroid.tileprovider.tilesource.ITileSource) Shader(android.graphics.Shader) Canvas(android.graphics.Canvas) XYTileSource(org.osmdroid.tileprovider.tilesource.XYTileSource) Configuration(org.osmdroid.config.Configuration) LocationActivitySearchAdapter(org.telegram.ui.Adapters.LocationActivitySearchAdapter) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) ScrollEvent(org.osmdroid.events.ScrollEvent) UndoView(org.telegram.ui.Components.UndoView) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Polygon(org.osmdroid.views.overlay.Polygon) NotificationCenter(org.telegram.messenger.NotificationCenter) Outline(android.graphics.Outline) LocationActivityAdapter(org.telegram.ui.Adapters.LocationActivityAdapter) Html(android.text.Html) HintView(org.telegram.ui.Components.HintView) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) FileLoader(org.telegram.messenger.FileLoader) ZoomEvent(org.osmdroid.events.ZoomEvent) BitmapFactory(android.graphics.BitmapFactory) AlertsCreator(org.telegram.ui.Components.AlertsCreator) ArrayList(java.util.ArrayList) TileSourceFactory(org.osmdroid.tileprovider.tilesource.TileSourceFactory) TLRPC(org.telegram.tgnet.TLRPC) Toast(android.widget.Toast) BuildConfig(org.telegram.messenger.BuildConfig) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) R(org.telegram.messenger.R) TextUtils(android.text.TextUtils) SharingLiveLocationCell(org.telegram.ui.Cells.SharingLiveLocationCell) MapView(org.osmdroid.views.MapView) File(java.io.File) Gravity(android.view.Gravity) UserObject(org.telegram.messenger.UserObject) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) LocationCell(org.telegram.ui.Cells.LocationCell) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) EditText(android.widget.EditText) ValueAnimator(android.animation.ValueAnimator) IMyLocationProvider(org.osmdroid.views.overlay.mylocation.IMyLocationProvider) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Rect(android.graphics.Rect) MyLocationNewOverlay(org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay) LinearLayout(android.widget.LinearLayout) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) PackageManager(android.content.pm.PackageManager) AndroidUtilities(org.telegram.messenger.AndroidUtilities) CubicBezierInterpolator(org.telegram.ui.Components.CubicBezierInterpolator) Animator(android.animation.Animator) LinkMovementMethod(android.text.method.LinkMovementMethod) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) ApplicationLoader(org.telegram.messenger.ApplicationLoader) SendLocationCell(org.telegram.ui.Cells.SendLocationCell) Locale(java.util.Locale) View(android.view.View) IMapController(org.osmdroid.api.IMapController) RecyclerView(androidx.recyclerview.widget.RecyclerView) Matrix(android.graphics.Matrix) RectF(android.graphics.RectF) BitmapShader(android.graphics.BitmapShader) LocationLoadingCell(org.telegram.ui.Cells.LocationLoadingCell) IGeoPoint(org.osmdroid.api.IGeoPoint) GpsMyLocationProvider(org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider) LocationPoweredCell(org.telegram.ui.Cells.LocationPoweredCell) ObjectAnimator(android.animation.ObjectAnimator) ImageLocation(org.telegram.messenger.ImageLocation) Marker(org.osmdroid.views.overlay.Marker) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) BitmapDrawable(android.graphics.drawable.BitmapDrawable) PorterDuff(android.graphics.PorterDuff) MapPlaceholderDrawable(org.telegram.ui.Components.MapPlaceholderDrawable) ViewGroup(android.view.ViewGroup) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) List(java.util.List) TextView(android.widget.TextView) Location(android.location.Location) ProximitySheet(org.telegram.ui.Components.ProximitySheet) LocationManager(android.location.LocationManager) Context(android.content.Context) Theme(org.telegram.ui.ActionBar.Theme) ViewOutlineProvider(android.view.ViewOutlineProvider) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) HashMap(java.util.HashMap) HeaderCell(org.telegram.ui.Cells.HeaderCell) GeoPoint(org.osmdroid.util.GeoPoint) SuppressLint(android.annotation.SuppressLint) LocationDirectionCell(org.telegram.ui.Cells.LocationDirectionCell) MapListener(org.osmdroid.events.MapListener) MotionEvent(android.view.MotionEvent) ActionBar(org.telegram.ui.ActionBar.ActionBar) AnimatorSet(android.animation.AnimatorSet) MessageObject(org.telegram.messenger.MessageObject) Build(android.os.Build) Projection(org.osmdroid.views.Projection) LongSparseArray(androidx.collection.LongSparseArray) DialogObject(org.telegram.messenger.DialogObject) BackupImageView(org.telegram.ui.Components.BackupImageView) Point(android.graphics.Point) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileLog(org.telegram.messenger.FileLog) BoundingBox(org.osmdroid.util.BoundingBox) MessagesController(org.telegram.messenger.MessagesController) Color(android.graphics.Color) Bitmap(android.graphics.Bitmap) OvershootInterpolator(android.view.animation.OvershootInterpolator) Activity(android.app.Activity) RecyclerListView(org.telegram.ui.Components.RecyclerListView) LocationActivitySearchAdapter(org.telegram.ui.Adapters.LocationActivitySearchAdapter) Activity(android.app.Activity) LocationController(org.telegram.messenger.LocationController) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MapPlaceholderDrawable(org.telegram.ui.Components.MapPlaceholderDrawable) TLRPC(org.telegram.tgnet.TLRPC) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) IGeoPoint(org.osmdroid.api.IGeoPoint) GeoPoint(org.osmdroid.util.GeoPoint) BackupImageView(org.telegram.ui.Components.BackupImageView) MapView(org.osmdroid.views.MapView) IMapController(org.osmdroid.api.IMapController) TextView(android.widget.TextView) ImageView(android.widget.ImageView) BackupImageView(org.telegram.ui.Components.BackupImageView) ActionBar(org.telegram.ui.ActionBar.ActionBar) EditText(android.widget.EditText) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) Rect(android.graphics.Rect) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) MapPlaceholderDrawable(org.telegram.ui.Components.MapPlaceholderDrawable) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) ITileSource(org.osmdroid.tileprovider.tilesource.ITileSource) UserObject(org.telegram.messenger.UserObject) ChatObject(org.telegram.messenger.ChatObject) MessageObject(org.telegram.messenger.MessageObject) DialogObject(org.telegram.messenger.DialogObject) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) StateListAnimator(android.animation.StateListAnimator) LocationActivityAdapter(org.telegram.ui.Adapters.LocationActivityAdapter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) AnimatorSet(android.animation.AnimatorSet) RecyclerListView(org.telegram.ui.Components.RecyclerListView) XYTileSource(org.osmdroid.tileprovider.tilesource.XYTileSource) UndoView(org.telegram.ui.Components.UndoView) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) SharedPreferences(android.content.SharedPreferences) Intent(android.content.Intent) Outline(android.graphics.Outline) ImageView(android.widget.ImageView) UndoView(org.telegram.ui.Components.UndoView) HintView(org.telegram.ui.Components.HintView) MapView(org.osmdroid.views.MapView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ViewOutlineProvider(android.view.ViewOutlineProvider) Paint(android.graphics.Paint) IGeoPoint(org.osmdroid.api.IGeoPoint) GeoPoint(org.osmdroid.util.GeoPoint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) HintView(org.telegram.ui.Components.HintView) MotionEvent(android.view.MotionEvent) RectF(android.graphics.RectF) FrameLayout(android.widget.FrameLayout) SuppressLint(android.annotation.SuppressLint) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayout(android.widget.LinearLayout) ImageLocation(org.telegram.messenger.ImageLocation) Location(android.location.Location)

Aggregations

EditTextBoldCursor (org.telegram.ui.Components.EditTextBoldCursor)37 View (android.view.View)27 TextView (android.widget.TextView)26 ActionBar (org.telegram.ui.ActionBar.ActionBar)26 FrameLayout (android.widget.FrameLayout)25 LinearLayout (android.widget.LinearLayout)25 Editable (android.text.Editable)24 TextWatcher (android.text.TextWatcher)24 ViewGroup (android.view.ViewGroup)23 TLRPC (org.telegram.tgnet.TLRPC)23 ActionBarMenu (org.telegram.ui.ActionBar.ActionBarMenu)21 Paint (android.graphics.Paint)20 Canvas (android.graphics.Canvas)19 ImageView (android.widget.ImageView)19 SuppressLint (android.annotation.SuppressLint)18 ScrollView (android.widget.ScrollView)18 TextPaint (android.text.TextPaint)17 ArrayList (java.util.ArrayList)17 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)15 AlertDialog (org.telegram.ui.ActionBar.AlertDialog)15