Search in sources :

Example 1 with SpoilersTextView

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

the class PhotoViewer method createCaptionTextView.

private TextView createCaptionTextView(LinkMovementMethod linkMovementMethod) {
    TextView textView = new SpoilersTextView(activityContext) {

        private boolean handleClicks;

        @Override
        public boolean onTouchEvent(MotionEvent event) {
            if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                handleClicks = needCaptionLayout;
            }
            boolean b = super.onTouchEvent(event);
            return bottomTouchEnabled && b;
        }

        @Override
        public void scrollTo(int x, int y) {
            if (getParent().getParent() == pickerView) {
                super.scrollTo(x, y);
                handleClicks = false;
            }
        }

        @Override
        public boolean performClick() {
            return handleClicks && super.performClick();
        }

        @Override
        public void setPressed(boolean pressed) {
            final boolean needsRefresh = pressed != isPressed();
            super.setPressed(pressed);
            if (needsRefresh) {
                invalidate();
            }
        }
    };
    textView.setMovementMethod(linkMovementMethod);
    ViewHelper.setPadding(textView, 16, 8, 16, 8);
    textView.setLinkTextColor(0xff76c2f1);
    textView.setTextColor(0xffffffff);
    textView.setHighlightColor(0x33ffffff);
    textView.setGravity(Gravity.CENTER_VERTICAL | LayoutHelper.getAbsoluteGravityStart());
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setOnClickListener((v) -> openCaptionEnter());
    return textView;
}
Also used : SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) SpoilersTextView(org.telegram.ui.Components.spoilers.SpoilersTextView) TextView(android.widget.TextView) SpoilersTextView(org.telegram.ui.Components.spoilers.SpoilersTextView) MotionEvent(android.view.MotionEvent)

Aggregations

MotionEvent (android.view.MotionEvent)1 TextView (android.widget.TextView)1 SimpleTextView (org.telegram.ui.ActionBar.SimpleTextView)1 SpoilersTextView (org.telegram.ui.Components.spoilers.SpoilersTextView)1