fix crash with unsupported msg
This commit is contained in:
@@ -302,37 +302,40 @@ public class DNRInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean onClickMsg(Context context, MsgAction action, Msg msg) {
|
public static boolean onClickMsg(Context context, MsgAction action, Msg msg) {
|
||||||
var text = ((MsgFromUser) msg).f();
|
|
||||||
var peerId = msg.v1();
|
var peerId = msg.v1();
|
||||||
var fullMsg = ((MsgFromUser) msg).j2(); // text + reply
|
|
||||||
var reply = fullMsg.substring(text.length() + 1);
|
|
||||||
|
|
||||||
if (action == MsgAction.valueOf("READTO")) {
|
if (action == MsgAction.valueOf("READTO")) {
|
||||||
DNRModule.hookReadStartMsgTo(msg);
|
DNRModule.hookReadStartMsgTo(msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isTextExist = !text.isEmpty() && !text.equals(" ");
|
if (msg instanceof MsgFromUser){
|
||||||
var isReplyExist = !reply.isEmpty() && !reply.equals(" ");
|
var text = ((MsgFromUser) msg).f();
|
||||||
|
var fullMsg = ((MsgFromUser) msg).j2(); // text + reply
|
||||||
|
var reply = fullMsg.substring(text.length() + 1);
|
||||||
|
|
||||||
|
var isTextExist = !text.isEmpty() && !text.equals(" ");
|
||||||
|
var isReplyExist = !reply.isEmpty() && !reply.equals(" ");
|
||||||
|
|
||||||
|
|
||||||
if (isReplyExist) {
|
if (isReplyExist) {
|
||||||
reply = decryptMessage(reply, peerId);
|
reply = decryptMessage(reply, peerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTextExist) {
|
if (isTextExist) {
|
||||||
text = decryptMessage(text, peerId);
|
text = decryptMessage(text, peerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == MsgAction.valueOf("TRANSLATE")) {
|
if (action == MsgAction.valueOf("TRANSLATE")) {
|
||||||
if (isTextExist && isReplyExist) {
|
if (isTextExist && isReplyExist) {
|
||||||
Translate.showTranslatedText(context, text + "\n\n" + getString("translator_reply") + "\n" + reply);
|
Translate.showTranslatedText(context, text + "\n\n" + getString("translator_reply") + "\n" + reply);
|
||||||
} else if (isReplyExist) {
|
} else if (isReplyExist) {
|
||||||
Translate.showTranslatedText(context, getString("translator_reply") + "\n" + reply);
|
Translate.showTranslatedText(context, getString("translator_reply") + "\n" + reply);
|
||||||
} else if (isTextExist) {
|
} else if (isTextExist) {
|
||||||
Translate.showTranslatedText(context, text);
|
Translate.showTranslatedText(context, text);
|
||||||
} else {
|
} else {
|
||||||
sendToast(getString("translator_no_text"));
|
sendToast(getString("translator_no_text"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user