Java Code Examples for android.widget.TextView#setHighlightColor()

The following examples show how to use android.widget.TextView#setHighlightColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginActivity.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private void d()
{
    z = findViewById(0x7f0a003a);
    B = findViewById(0x7f0a003c);
    r = (Button)findViewById(0x7f0a003f);
    r.setOnClickListener(this);
    s = (Button)findViewById(0x7f0a0040);
    s.setOnClickListener(this);
    C = (TextView)findViewById(0x7f0a003e);
    String s1 = getString(0x7f0d01dd);
    C.setText(Html.fromHtml(getResources().getString(0x7f0d003b)));
    SpannableString spannablestring = new SpannableString(s1);
    spannablestring.setSpan(new d(this), 0, s1.length(), 33);
    C.setHighlightColor(0);
    C.append(spannablestring);
    C.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 2
Source File: AboutActivity.java    From justaline-android with Apache License 2.0 5 votes vote down vote up
private void makeLinkInDescriptionClickable() {

        TextView aboutDescription = findViewById(R.id.about_description_text);
        String aboutText = getString(R.string.about_text);
        String urlText = getString(R.string.about_text_link);

        int start = aboutText.indexOf(urlText);

        SpannableString spannableString = new SpannableString(aboutText);
        UnderlineSpan underlineSpan = new UnderlineSpan(urlText);
        spannableString.setSpan(underlineSpan, start, start + urlText.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        ClickableSpan clickableSpan = new ClickableSpan() {
            @Override
            public void onClick(View textView) {
                openUrl(R.string.jal_url);
            }

            @Override
            public void updateDrawState(TextPaint ds) {
                super.updateDrawState(ds);

                ds.setColor(Color.WHITE);
            }
        };

        spannableString.setSpan(clickableSpan, start, start + urlText.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        aboutDescription.setText(spannableString);
        aboutDescription.setMovementMethod(LinkMovementMethod.getInstance());
        aboutDescription.setHighlightColor(Color.TRANSPARENT);
    }
 
Example 3
Source File: LicensesActivity.java    From justaline-android with Apache License 2.0 5 votes vote down vote up
private void makeLinkInDescriptionClickable(TextView licenseTypeTextView) {

        String apacheLicenseText = getString(R.string.apache_license_type);
        String apacheUrlText = getString(R.string.apache_license_url);

        // Apache Spannables setup
        SpannableString apacheSpannableString = new SpannableString(apacheLicenseText);
        ClickableSpan clickableSpan = new ClickableSpan() {
            @Override
            public void onClick(View textView) {
                openUrl(R.string.apache_license_url);
            }

            @Override
            public void updateDrawState(TextPaint ds) {
                super.updateDrawState(ds);
                ds.setUnderlineText(false);
            }
        };
        int apacheStart = apacheLicenseText.indexOf(apacheUrlText);
        apacheSpannableString
                .setSpan(clickableSpan, apacheStart, apacheStart + apacheUrlText.length(),
                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        licenseTypeTextView.setText(apacheSpannableString);
        licenseTypeTextView.setMovementMethod(LinkMovementMethod.getInstance());
        licenseTypeTextView.setHighlightColor(Color.TRANSPARENT);
    }
 
Example 4
Source File: WordToSpan.java    From Android-WordToSpan with MIT License 5 votes vote down vote up
public WordToSpan into(View textView){
    tv = (TextView) textView;
    tv.setText(ws);
    if(key == null) {
        tv.setMovementMethod(LinkMovementMethod.getInstance());
        tv.setHighlightColor(Color.TRANSPARENT);
    }
    return this;
}
 
Example 5
Source File: AlertsCreator.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static AlertDialog createSupportAlert(BaseFragment fragment) {
    if (fragment == null || fragment.getParentActivity() == null) {
        return null;
    }
    final TextView message = new TextView(fragment.getParentActivity());
    Spannable spanned = new SpannableString(Html.fromHtml(LocaleController.getString("AskAQuestionInfo", R.string.AskAQuestionInfo).replace("\n", "<br>")));
    URLSpan[] spans = spanned.getSpans(0, spanned.length(), URLSpan.class);
    for (int i = 0; i < spans.length; i++) {
        URLSpan span = spans[i];
        int start = spanned.getSpanStart(span);
        int end = spanned.getSpanEnd(span);
        spanned.removeSpan(span);
        span = new URLSpanNoUnderline(span.getURL()) {
            @Override
            public void onClick(View widget) {
                fragment.dismissCurrentDialig();
                super.onClick(widget);
            }
        };
        spanned.setSpan(span, start, end, 0);
    }
    message.setText(spanned);
    message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    message.setLinkTextColor(Theme.getColor(Theme.key_dialogTextLink));
    message.setHighlightColor(Theme.getColor(Theme.key_dialogLinkSelection));
    message.setPadding(AndroidUtilities.dp(23), 0, AndroidUtilities.dp(23), 0);
    message.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
    message.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));

    AlertDialog.Builder builder1 = new AlertDialog.Builder(fragment.getParentActivity());
    builder1.setView(message);
    builder1.setTitle(LocaleController.getString("AskAQuestion", R.string.AskAQuestion));
    builder1.setPositiveButton(LocaleController.getString("AskButton", R.string.AskButton), (dialogInterface, i) -> performAskAQuestion(fragment));
    builder1.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    return builder1.create();
}
 
Example 6
Source File: AlertsCreator.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public static AlertDialog createSupportAlert(BaseFragment fragment) {
    if (fragment == null || fragment.getParentActivity() == null) {
        return null;
    }
    final TextView message = new TextView(fragment.getParentActivity());
    Spannable spanned = new SpannableString(Html.fromHtml(LocaleController.getString("AskAQuestionInfo", R.string.AskAQuestionInfo).replace("\n", "<br>")));
    URLSpan[] spans = spanned.getSpans(0, spanned.length(), URLSpan.class);
    for (int i = 0; i < spans.length; i++) {
        URLSpan span = spans[i];
        int start = spanned.getSpanStart(span);
        int end = spanned.getSpanEnd(span);
        spanned.removeSpan(span);
        span = new URLSpanNoUnderline(span.getURL()) {
            @Override
            public void onClick(View widget) {
                fragment.dismissCurrentDialig();
                super.onClick(widget);
            }
        };
        spanned.setSpan(span, start, end, 0);
    }
    message.setText(spanned);
    message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    message.setLinkTextColor(Theme.getColor(Theme.key_dialogTextLink));
    message.setHighlightColor(Theme.getColor(Theme.key_dialogLinkSelection));
    message.setPadding(AndroidUtilities.dp(23), 0, AndroidUtilities.dp(23), 0);
    message.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
    message.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));

    AlertDialog.Builder builder1 = new AlertDialog.Builder(fragment.getParentActivity());
    builder1.setView(message);
    builder1.setTitle(LocaleController.getString("AskAQuestion", R.string.AskAQuestion));
    builder1.setPositiveButton(LocaleController.getString("AskButton", R.string.AskButton), (dialogInterface, i) -> performAskAQuestion(fragment));
    builder1.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    return builder1.create();
}
 
Example 7
Source File: TextHighlightColorSetter.java    From aircon with MIT License 4 votes vote down vote up
@Override
protected void setAttr(final TextView view, final int color) {
	view.setHighlightColor(color);
}
 
Example 8
Source File: ViewUtil.java    From MDPreference with Apache License 2.0 4 votes vote down vote up
public static void applyTextAppearance(TextView v, int resId){
    if(resId == 0)
        return;

    String fontFamily = null;
    int typefaceIndex = -1;
    int styleIndex = -1;
    int shadowColor = 0;
    float dx = 0, dy = 0, r = 0;

    TypedArray appearance = v.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
    if (appearance != null) {
        int n = appearance.getIndexCount();
        for (int i = 0; i < n; i++) {
            int attr = appearance.getIndex(i);

            if (attr == R.styleable.TextAppearance_android_textColorHighlight) {
                v.setHighlightColor(appearance.getColor(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_textColor) {
                v.setTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textColorHint) {
                v.setHintTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textColorLink) {
                v.setLinkTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textSize) {
                v.setTextSize(TypedValue.COMPLEX_UNIT_PX, appearance.getDimensionPixelSize(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_typeface) {
                typefaceIndex = appearance.getInt(attr, -1);

            } else if (attr == R.styleable.TextAppearance_android_fontFamily) {
                fontFamily = appearance.getString(attr);

            } else if (attr == R.styleable.TextAppearance_tv_fontFamily) {
                fontFamily = appearance.getString(attr);

            } else if (attr == R.styleable.TextAppearance_android_textStyle) {
                styleIndex = appearance.getInt(attr, -1);

            } else if (attr == R.styleable.TextAppearance_android_textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
                    v.setAllCaps(appearance.getBoolean(attr, false));

            } else if (attr == R.styleable.TextAppearance_android_shadowColor) {
                shadowColor = appearance.getInt(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowDx) {
                dx = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowDy) {
                dy = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowRadius) {
                r = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_elegantTextHeight) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setElegantTextHeight(appearance.getBoolean(attr, false));

            } else if (attr == R.styleable.TextAppearance_android_letterSpacing) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setLetterSpacing(appearance.getFloat(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_fontFeatureSettings) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setFontFeatureSettings(appearance.getString(attr));

            }
        }

        appearance.recycle();
    }

    if (shadowColor != 0)
        v.setShadowLayer(r, dx, dy, shadowColor);

    Typeface tf = null;
    if (fontFamily != null) {
        tf = TypefaceUtil.load(v.getContext(), fontFamily, styleIndex);
        if (tf != null)
            v.setTypeface(tf);
    }
    if(tf != null) {
        switch (typefaceIndex) {
            case 1:
                tf = Typeface.SANS_SERIF;
                break;
            case 2:
                tf = Typeface.SERIF;
                break;
            case 3:
                tf = Typeface.MONOSPACE;
                break;
        }
        v.setTypeface(tf, styleIndex);
    }
}
 
Example 9
Source File: SimpleText.java    From SimpleText with Apache License 2.0 4 votes vote down vote up
private void linkify(TextView textView) {
  textView.setHighlightColor(Color.TRANSPARENT);
  textView.setMovementMethod(new LinkTouchMovementMethod(pressedTextColor, pressedBackgroundColor, pressedBackgroundRadius));
}
 
Example 10
Source File: ViewUtil.java    From material with Apache License 2.0 4 votes vote down vote up
public static void applyTextAppearance(TextView v, int resId){
    if(resId == 0)
        return;

    String fontFamily = null;
    int typefaceIndex = -1;
    int styleIndex = -1;
    int shadowColor = 0;
    float dx = 0, dy = 0, r = 0;

    TypedArray appearance = v.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
    if (appearance != null) {
        int n = appearance.getIndexCount();
        for (int i = 0; i < n; i++) {
            int attr = appearance.getIndex(i);

            if (attr == R.styleable.TextAppearance_android_textColorHighlight) {
                v.setHighlightColor(appearance.getColor(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_textColor) {
                v.setTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textColorHint) {
                v.setHintTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textColorLink) {
                v.setLinkTextColor(appearance.getColorStateList(attr));

            } else if (attr == R.styleable.TextAppearance_android_textSize) {
                v.setTextSize(TypedValue.COMPLEX_UNIT_PX, appearance.getDimensionPixelSize(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_typeface) {
                typefaceIndex = appearance.getInt(attr, -1);

            } else if (attr == R.styleable.TextAppearance_android_fontFamily) {
                fontFamily = appearance.getString(attr);

            } else if (attr == R.styleable.TextAppearance_tv_fontFamily) {
                fontFamily = appearance.getString(attr);

            } else if (attr == R.styleable.TextAppearance_android_textStyle) {
                styleIndex = appearance.getInt(attr, -1);

            } else if (attr == R.styleable.TextAppearance_android_textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
                    v.setAllCaps(appearance.getBoolean(attr, false));

            } else if (attr == R.styleable.TextAppearance_android_shadowColor) {
                shadowColor = appearance.getInt(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowDx) {
                dx = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowDy) {
                dy = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_shadowRadius) {
                r = appearance.getFloat(attr, 0);

            } else if (attr == R.styleable.TextAppearance_android_elegantTextHeight) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setElegantTextHeight(appearance.getBoolean(attr, false));

            } else if (attr == R.styleable.TextAppearance_android_letterSpacing) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setLetterSpacing(appearance.getFloat(attr, 0));

            } else if (attr == R.styleable.TextAppearance_android_fontFeatureSettings) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setFontFeatureSettings(appearance.getString(attr));

            }
        }

        appearance.recycle();
    }

    if (shadowColor != 0)
        v.setShadowLayer(r, dx, dy, shadowColor);

    Typeface tf = null;
    if (fontFamily != null) {
        tf = TypefaceUtil.load(v.getContext(), fontFamily, styleIndex);
        if (tf != null)
            v.setTypeface(tf);
    }
    if(tf != null) {
        switch (typefaceIndex) {
            case 1:
                tf = Typeface.SANS_SERIF;
                break;
            case 2:
                tf = Typeface.SERIF;
                break;
            case 3:
                tf = Typeface.MONOSPACE;
                break;
        }
        v.setTypeface(tf, styleIndex);
    }
}
 
Example 11
Source File: UndoView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public UndoView(Context context, boolean top) {
    super(context);
    fromTop = top;

    infoTextView = new TextView(context);
    infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    infoTextView.setTextColor(Theme.getColor(Theme.key_undo_infoColor));
    infoTextView.setLinkTextColor(Theme.getColor(Theme.key_undo_cancelColor));
    infoTextView.setMovementMethod(new LinkMovementMethodMy());
    addView(infoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 45, 13, 0, 0));

    subinfoTextView = new TextView(context);
    subinfoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    subinfoTextView.setTextColor(Theme.getColor(Theme.key_undo_infoColor));
    subinfoTextView.setLinkTextColor(Theme.getColor(Theme.key_undo_cancelColor));
    subinfoTextView.setHighlightColor(0);
    subinfoTextView.setSingleLine(true);
    subinfoTextView.setEllipsize(TextUtils.TruncateAt.END);
    subinfoTextView.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
    addView(subinfoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 58, 27, 8, 0));

    leftImageView = new RLottieImageView(context);
    leftImageView.setScaleType(ImageView.ScaleType.CENTER);
    leftImageView.setLayerColor("info1.**", Theme.getColor(Theme.key_undo_background) | 0xff000000);
    leftImageView.setLayerColor("info2.**", Theme.getColor(Theme.key_undo_background) | 0xff000000);
    leftImageView.setLayerColor("luc12.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc11.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc10.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc9.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc8.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc7.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc6.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc5.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc4.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc3.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc2.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc1.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("Oval.**", Theme.getColor(Theme.key_undo_infoColor));
    addView(leftImageView, LayoutHelper.createFrame(54, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 3, 0, 0, 0));

    undoButton = new LinearLayout(context);
    undoButton.setOrientation(LinearLayout.HORIZONTAL);
    addView(undoButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0, 19, 0));
    undoButton.setOnClickListener(v -> {
        if (!canUndo()) {
            return;
        }
        hide(false, 1);
    });

    undoImageView = new ImageView(context);
    undoImageView.setImageResource(R.drawable.chats_undo);
    undoImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_undo_cancelColor), PorterDuff.Mode.MULTIPLY));
    undoButton.addView(undoImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT));

    undoTextView = new TextView(context);
    undoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    undoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    undoTextView.setTextColor(Theme.getColor(Theme.key_undo_cancelColor));
    undoTextView.setText(LocaleController.getString("Undo", R.string.Undo));
    undoButton.addView(undoTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 6, 0, 0, 0));

    rect = new RectF(AndroidUtilities.dp(15), AndroidUtilities.dp(15), AndroidUtilities.dp(15 + 18), AndroidUtilities.dp(15 + 18));

    progressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    progressPaint.setStyle(Paint.Style.STROKE);
    progressPaint.setStrokeWidth(AndroidUtilities.dp(2));
    progressPaint.setStrokeCap(Paint.Cap.ROUND);
    progressPaint.setColor(Theme.getColor(Theme.key_undo_infoColor));

    textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(AndroidUtilities.dp(12));
    textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textPaint.setColor(Theme.getColor(Theme.key_undo_infoColor));

    setBackgroundDrawable(Theme.createRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_undo_background)));

    setOnTouchListener((v, event) -> true);

    setVisibility(INVISIBLE);
}
 
Example 12
Source File: UndoView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public UndoView(Context context, boolean top) {
    super(context);
    fromTop = top;

    infoTextView = new TextView(context);
    infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    infoTextView.setTextColor(Theme.getColor(Theme.key_undo_infoColor));
    infoTextView.setLinkTextColor(Theme.getColor(Theme.key_undo_cancelColor));
    infoTextView.setMovementMethod(new LinkMovementMethodMy());
    addView(infoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 45, 13, 0, 0));

    subinfoTextView = new TextView(context);
    subinfoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    subinfoTextView.setTextColor(Theme.getColor(Theme.key_undo_infoColor));
    subinfoTextView.setLinkTextColor(Theme.getColor(Theme.key_undo_cancelColor));
    subinfoTextView.setHighlightColor(0);
    subinfoTextView.setSingleLine(true);
    subinfoTextView.setEllipsize(TextUtils.TruncateAt.END);
    subinfoTextView.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
    addView(subinfoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 58, 27, 8, 0));

    leftImageView = new RLottieImageView(context);
    leftImageView.setScaleType(ImageView.ScaleType.CENTER);
    leftImageView.setLayerColor("info1.**", Theme.getColor(Theme.key_undo_background) | 0xff000000);
    leftImageView.setLayerColor("info2.**", Theme.getColor(Theme.key_undo_background) | 0xff000000);
    leftImageView.setLayerColor("luc12.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc11.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc10.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc9.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc8.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc7.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc6.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc5.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc4.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc3.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc2.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("luc1.**", Theme.getColor(Theme.key_undo_infoColor));
    leftImageView.setLayerColor("Oval.**", Theme.getColor(Theme.key_undo_infoColor));
    addView(leftImageView, LayoutHelper.createFrame(54, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 3, 0, 0, 0));

    undoButton = new LinearLayout(context);
    undoButton.setOrientation(LinearLayout.HORIZONTAL);
    addView(undoButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0, 19, 0));
    undoButton.setOnClickListener(v -> {
        if (!canUndo()) {
            return;
        }
        hide(false, 1);
    });

    undoImageView = new ImageView(context);
    undoImageView.setImageResource(R.drawable.chats_undo);
    undoImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_undo_cancelColor), PorterDuff.Mode.MULTIPLY));
    undoButton.addView(undoImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT));

    undoTextView = new TextView(context);
    undoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    undoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    undoTextView.setTextColor(Theme.getColor(Theme.key_undo_cancelColor));
    undoTextView.setText(LocaleController.getString("Undo", R.string.Undo));
    undoButton.addView(undoTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 6, 0, 0, 0));

    rect = new RectF(AndroidUtilities.dp(15), AndroidUtilities.dp(15), AndroidUtilities.dp(15 + 18), AndroidUtilities.dp(15 + 18));

    progressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    progressPaint.setStyle(Paint.Style.STROKE);
    progressPaint.setStrokeWidth(AndroidUtilities.dp(2));
    progressPaint.setStrokeCap(Paint.Cap.ROUND);
    progressPaint.setColor(Theme.getColor(Theme.key_undo_infoColor));

    textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(AndroidUtilities.dp(12));
    textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textPaint.setColor(Theme.getColor(Theme.key_undo_infoColor));

    setBackgroundDrawable(Theme.createRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_undo_background)));

    setOnTouchListener((v, event) -> true);

    setVisibility(INVISIBLE);
}