Kate Mobile v109.1版本的 MD5 值为:fcd76ded5f363ecbfac46035a4ed2a23
以下内容为反编译后的 MessageSender.java 源代码,内容仅作参考
package com.perm.kate;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.widget.TextView;
import com.perm.kate.api.Message;
import com.perm.kate.session.Callback;
import com.perm.kate.session.Session;
import com.perm.utils.TimeFix;
import java.util.ArrayList;
import java.util.Iterator;
public class MessageSender {
private Activity activity;
ArrayList attachments;
ArrayList attachments_objects;
private final Callback callback;
private MessageSenderCallback callback3;
private final long chat_id;
private ArrayList forward_messages;
final long group_id;
private final String message_type;
final String payload;
final Integer sticker_id;
final String text;
private final Long user_id;
public interface MessageSenderCallback {
void error(Throwable th, String str, ArrayList arrayList, ArrayList arrayList2);
void ready();
void refreshed();
void start();
}
public MessageSender(Activity activity, String str, Long l, long j, String str2, MessageSenderCallback messageSenderCallback, ArrayList arrayList, ArrayList arrayList2, ArrayList arrayList3, Integer num, long j2, String str3) {
this.attachments = null;
this.attachments_objects = null;
Callback callback = new Callback(this.activity) {
@Override
public void error(Throwable th) {
if (th.getMessage() == null || !th.getMessage().contains("this sticker is not available")) {
super.error(th);
} else {
MessageSender.this.showStickerDisabledAlert();
}
if (MessageSender.this.callback3 != null) {
MessageSenderCallback messageSenderCallback2 = MessageSender.this.callback3;
MessageSender messageSender = MessageSender.this;
messageSenderCallback2.error(th, messageSender.text, messageSender.attachments, messageSender.attachments_objects);
}
MessageSender.this.destroy();
}
@Override
public void ready(Object obj) {
String str4 = (String) obj;
if (MessageSender.this.callback3 != null) {
MessageSender.this.callback3.ready();
}
long parseLong = Long.parseLong(KApplication.session.getMid());
try {
KApplication.db.createOrUpdateMessage(MessageSender.this.recreateMessage(str4), parseLong, false, MessageSender.this.group_id);
} catch (Throwable th) {
th.printStackTrace();
Helper.reportError(th);
}
KApplication.db.setUnreadCountInChat(ThreadIdHelper.makeThreadId(Long.valueOf(MessageSender.this.chat_id), MessageSender.this.user_id), parseLong, 0, MessageSender.this.group_id);
if (MessageSender.this.callback3 != null) {
MessageSender.this.callback3.refreshed();
}
MessageSender.sendMessagesBroadcast();
if (MessageSender.this.activity != null && (MessageSender.this.activity instanceof BaseActivity)) {
((BaseActivity) MessageSender.this.activity).showProgressBar(false);
}
MessageSender.this.destroy();
}
};
this.callback = callback;
this.activity = activity;
this.text = str;
this.user_id = l;
this.chat_id = j;
this.message_type = str2;
this.callback3 = messageSenderCallback;
if (arrayList != null) {
this.attachments = new ArrayList(arrayList);
}
if (arrayList2 != null) {
this.attachments_objects = new ArrayList(arrayList2);
}
if (arrayList3 != null) {
this.forward_messages = new ArrayList(arrayList3);
}
this.sticker_id = num;
this.group_id = j2;
this.payload = str3;
callback.setActivity(this.activity);
}
public void destroy() {
this.callback3 = null;
this.activity = null;
}
public Message recreateMessage(String str) {
Message message = new Message();
message.body = this.text;
message.uid = this.user_id.longValue();
if (this.chat_id != 0) {
message.uid = Long.parseLong(KApplication.session.getMid());
}
message.is_out = true;
message.date = TimeFix.unfix(System.currentTimeMillis() / 1000);
message.mid = Long.parseLong(str);
message.chat_id = Long.valueOf(this.chat_id);
message.important = Boolean.FALSE;
MessageSendQueue.fillAttachments(this.attachments, this.attachments_objects, message, this.sticker_id, this.forward_messages, this.group_id);
return message;
}
public static void sendMessagesBroadcast() {
Intent intent = new Intent();
intent.setAction("com.perm.kate.intent.action.new_messages");
KApplication.current.getApplicationContext().sendBroadcast(intent);
}
public void showStickerDisabledAlert() {
Activity activity = this.activity;
if (activity == null || activity.isFinishing()) {
return;
}
final Activity activity2 = this.activity;
activity2.runOnUiThread(new Runnable() {
@Override
public void run() {
SpannableString spannableString = new SpannableString(activity2.getString(R.string.sticker_disabled));
Linkify.addLinks(spannableString, 1);
AlertDialog.Builder builder = new AlertDialog.Builder(activity2);
builder.setMessage(spannableString);
builder.setPositiveButton(R.string.open, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Helper.openUrlInBrowser("https://m.vk.com/stickers?tab=free", activity2);
}
});
builder.setNegativeButton(R.string.label_cancel, (DialogInterface.OnClickListener) null);
AlertDialog create = builder.create();
create.setCanceledOnTouchOutside(true);
create.show();
((TextView) create.findViewById(16908299)).setMovementMethod(LinkMovementMethod.getInstance());
}
});
}
public void sendMessage(final Session session) {
ArrayList arrayList;
ArrayList arrayList2;
if (this.text.equals("") && (((arrayList = this.attachments) == null || arrayList.size() == 0) && (((arrayList2 = this.forward_messages) == null || arrayList2.size() == 0) && this.sticker_id == null))) {
Activity activity = this.activity;
if (activity != null) {
BaseActivity.displayToast(activity.getString(R.string.message_empty), this.activity);
return;
}
return;
}
MessageSenderCallback messageSenderCallback = this.callback3;
if (messageSenderCallback != null) {
messageSenderCallback.start();
}
new Thread() {
@Override
public void run() {
ArrayList arrayList3 = null;
String[] strArr = {null, null};
if (MessageSender.this.attachments != null) {
arrayList3 = new ArrayList(MessageSender.this.attachments);
strArr = Helper.extractLocationFromAttachments(arrayList3);
Iterator it = arrayList3.iterator();
while (true) {
if (!it.hasNext()) {
break;
}
String str = (String) it.next();
if (str.startsWith("forward_messages")) {
arrayList3.remove(str);
break;
}
}
}
ArrayList arrayList4 = arrayList3;
Session session2 = session;
Long l = MessageSender.this.user_id;
long j = MessageSender.this.chat_id;
MessageSender messageSender = MessageSender.this;
String str2 = messageSender.text;
String str3 = messageSender.message_type;
ArrayList arrayList5 = MessageSender.this.forward_messages;
String str4 = strArr[0];
String str5 = strArr[1];
MessageSender messageSender2 = MessageSender.this;
session2.sendMessage(l, j, str2, null, str3, arrayList4, arrayList5, str4, str5, messageSender2.sticker_id, messageSender2.payload, messageSender2.callback, MessageSender.this.activity);
if (MessageSender.this.group_id == 0) {
MessageThreadFragment.setOffline();
}
}
}.start();
}
}