NekoX/TMessagesProj/src/main/java/org/telegram/ui/Components/URLSpanBotCommand.java

48 lines
1.3 KiB
Java
Raw Normal View History

2015-10-29 18:10:07 +01:00
/*
2019-01-23 18:03:33 +01:00
* This is the source code of Telegram for Android v. 5.x.x.
2015-10-29 18:10:07 +01:00
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
2019-01-23 18:03:33 +01:00
* Copyright Nikolai Kudashov, 2013-2018.
2015-10-29 18:10:07 +01:00
*/
package org.telegram.ui.Components;
import android.text.TextPaint;
2016-04-22 15:49:00 +02:00
import org.telegram.ui.ActionBar.Theme;
2015-10-29 18:10:07 +01:00
public class URLSpanBotCommand extends URLSpanNoUnderline {
public static boolean enabled = true;
2018-07-30 04:07:02 +02:00
public int currentType;
2019-07-18 15:01:39 +02:00
private TextStyleSpan.TextStyleRun style;
2015-10-29 18:10:07 +01:00
2018-07-30 04:07:02 +02:00
public URLSpanBotCommand(String url, int type) {
2019-07-18 15:01:39 +02:00
this(url, type, null);
}
public URLSpanBotCommand(String url, int type, TextStyleSpan.TextStyleRun run) {
2015-10-29 18:10:07 +01:00
super(url);
2018-07-30 04:07:02 +02:00
currentType = type;
2019-07-18 15:01:39 +02:00
style = run;
2015-10-29 18:10:07 +01:00
}
@Override
2019-07-18 15:01:39 +02:00
public void updateDrawState(TextPaint p) {
super.updateDrawState(p);
2018-07-30 04:07:02 +02:00
if (currentType == 2) {
2019-07-18 15:01:39 +02:00
p.setColor(0xffffffff);
2018-07-30 04:07:02 +02:00
} else if (currentType == 1) {
2019-07-18 15:01:39 +02:00
p.setColor(Theme.getColor(enabled ? Theme.key_chat_messageLinkOut : Theme.key_chat_messageTextOut));
} else {
p.setColor(Theme.getColor(enabled ? Theme.key_chat_messageLinkIn : Theme.key_chat_messageTextIn));
}
if (style != null) {
style.applyStyle(p);
2017-03-31 01:58:05 +02:00
} else {
2019-07-18 15:01:39 +02:00
p.setUnderlineText(false);
2017-03-31 01:58:05 +02:00
}
2015-10-29 18:10:07 +01:00
}
}