msg downloader: update
- decrypt replies & forward messages - fix html bug
This commit is contained in:
@@ -16,6 +16,7 @@ import static ru.vtosters.lite.encryption.EncryptProvider.decryptMessage;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getString;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.Preferences.getDownloadsDir;
|
||||
|
||||
@@ -170,10 +171,11 @@ public class DNRInjector {
|
||||
}
|
||||
|
||||
if (action == DialogAction.DOWNLOAD) {
|
||||
File out = new File(Environment.getExternalStoragePublicDirectory(getDownloadsDir().getName()), peerId + "-dialog.html");
|
||||
File out = new File(Environment.getExternalStoragePublicDirectory(getDownloadsDir().getName()), "dialog-" + peerId + ".html");
|
||||
try {
|
||||
new MessagesDownloader().downloadDialog(peerId, new MessagesDownloader.HtmlDialogDownloaderFormatProvider(), out);
|
||||
} catch (Exception e) {
|
||||
sendToast(getString("download_dl_error"));
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
@@ -297,13 +299,13 @@ public class DNRInjector {
|
||||
|
||||
if (action == MsgAction.valueOf("TRANSLATE")) {
|
||||
if (isTextExist && isReplyExist) {
|
||||
Translate.showTranslatedText(context, text + "\n\n" + AndroidUtils.getString("translator_reply") + "\n" + reply);
|
||||
Translate.showTranslatedText(context, text + "\n\n" + getString("translator_reply") + "\n" + reply);
|
||||
} else if (isReplyExist) {
|
||||
Translate.showTranslatedText(context, AndroidUtils.getString("translator_reply") + "\n" + reply);
|
||||
Translate.showTranslatedText(context, getString("translator_reply") + "\n" + reply);
|
||||
} else if (isTextExist) {
|
||||
Translate.showTranslatedText(context, text);
|
||||
} else {
|
||||
sendToast(AndroidUtils.getString("translator_no_text"));
|
||||
sendToast(getString("translator_no_text"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +333,7 @@ public class DNRInjector {
|
||||
|
||||
thread.start();
|
||||
|
||||
sendToast(AndroidUtils.getString("pin_dialog") + " " + (needToBePinned ? AndroidUtils.getString("dialog_pinned") : AndroidUtils.getString("dialog_unpinned")));
|
||||
sendToast(getString("pin_dialog") + " " + getString(needToBePinned ? "dialog_pinned" : "dialog_unpinned"));
|
||||
}
|
||||
|
||||
public static void setDnr(Dialog dialog, boolean value) {
|
||||
|
||||
@@ -184,6 +184,7 @@ public class MessagesDownloader{
|
||||
" background: white;\n" +
|
||||
" margin: 16px;\n" +
|
||||
" box-shadow: 0 4px 8px 0 rgba(0,0,0,0.07);\n" +
|
||||
" word-wrap: break-word;\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
".vtex-milk-msgcont br {\n" +
|
||||
@@ -295,7 +296,8 @@ public class MessagesDownloader{
|
||||
private String provideReply(JSONObject replyMessage) throws JSONException {
|
||||
var messageId = replyMessage.getInt("id");
|
||||
var userId = replyMessage.getInt("from_id");
|
||||
var text = mentionsReplace(replyMessage.getString("text"));
|
||||
var peerId = replyMessage.getInt("peer_id");
|
||||
var text = mentionsReplace(decryptMessage(replyMessage.getString("text"), peerId));
|
||||
var fwdMessages = replyMessage.optJSONArray("fwd_messages");
|
||||
|
||||
var user = usersArray.get(userId);
|
||||
@@ -352,7 +354,8 @@ public class MessagesDownloader{
|
||||
var fwdsHtml = (fwdsMsg.size() > 0) ? provideForwardMessages(fwdsMsg) : ""; // recursion XD :>
|
||||
|
||||
var userId = fwd_message.getInt("from_id");
|
||||
var text = mentionsReplace(fwd_message.getString("text"));
|
||||
var peerId = fwd_message.getInt("peer_id");
|
||||
var text = mentionsReplace(decryptMessage(fwd_message.getString("text"), peerId));
|
||||
|
||||
var userLink = ((userId < 0) ? "club" : "id") + Math.abs(userId);
|
||||
|
||||
|
||||
@@ -6185,4 +6185,5 @@
|
||||
<string name="whitelisted_filters_groups_title">Вайтлист фильтров</string>
|
||||
|
||||
<string name="download_dl">Скачать диалог</string>
|
||||
<string name="download_dl_error">Произошла ошибка при попытке скачать диалог</string>
|
||||
</resources>
|
||||
@@ -6323,4 +6323,5 @@ May look like a fake leaving the online"</string>
|
||||
<string name="whitelisted_filters_groups_title">Filters whitelist</string>
|
||||
|
||||
<string name="download_dl">Download dialog</string>
|
||||
<string name="download_dl_error">An error occurred while trying to download the dialog</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user