正在查看: Delta Chat v1.58.3 应用的 NotificationCenter.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Delta Chat v1.58.3 应用的 NotificationCenter.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.thoughtcrime.securesms.notifications;
import android.app.NotificationChannel;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.app.RemoteInput;
import androidx.core.app.TaskStackBuilder;
import com.b44t.messenger.DcChat;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcMsg;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.ConversationActivity;
import org.thoughtcrime.securesms.ConversationListActivity;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
import org.thoughtcrime.securesms.mms.GlideApp;
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.BitmapUtil;
import org.thoughtcrime.securesms.util.IntentUtils;
import org.thoughtcrime.securesms.util.JsonUtils;
import org.thoughtcrime.securesms.util.Pair;
import org.thoughtcrime.securesms.util.Prefs;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil$$ExternalSyntheticApiModelOutline0;
public class NotificationCenter {
public static final String CH_GENERIC = "ch_generic";
private static final String CH_GRP_MSG = "chgrp_msg";
public static final String CH_MSG_PREFIX = "ch_msg";
public static final String CH_MSG_VERSION = "5";
public static final String CH_PERMANENT = "dc_foreground_notification_ch";
private static final String GRP_MSG = "grp_msg";
public static final int ID_FETCH = 4;
public static final int ID_GENERIC = 3;
public static final int ID_MSG_OFFSET = 0;
public static final int ID_MSG_SUMMARY = 2;
public static final int ID_PERMANENT = 1;
private static final long MIN_AUDIBLE_PERIOD_MILLIS = TimeUnit.SECONDS.toMillis(2);
private static final String TAG = "NotificationCenter";
private final ApplicationContext context;
private volatile ChatData visibleChat = null;
private volatile Pair<Integer, Integer> visibleWebxdc = null;
private volatile long lastAudibleNotification = 0;
private final HashMap<Integer, HashMap<Integer, ArrayList<String>>> inboxes = new HashMap<>();
public NotificationCenter(Context context) {
this.context = ApplicationContext.getInstance(context);
}
private Uri effectiveSound(ChatData chatData) {
if (chatData == null) {
chatData = new ChatData(0, 0);
}
Uri chatRingtone = Prefs.getChatRingtone(this.context, chatData.accountId, chatData.chatId);
if (chatRingtone != null) {
return chatRingtone;
}
Uri notificationRingtone = Prefs.getNotificationRingtone(this.context);
if (TextUtils.isEmpty(notificationRingtone.toString())) {
return null;
}
return notificationRingtone;
}
private boolean effectiveVibrate(ChatData chatData) {
if (chatData == null) {
chatData = new ChatData(0, 0);
}
Prefs.VibrateState chatVibrate = Prefs.getChatVibrate(this.context, chatData.accountId, chatData.chatId);
if (chatVibrate == Prefs.VibrateState.ENABLED) {
return true;
}
if (chatVibrate == Prefs.VibrateState.DISABLED) {
return false;
}
return Prefs.isNotificationVibrateEnabled(this.context);
}
private boolean requiresIndependentChannel(ChatData chatData) {
if (chatData == null) {
chatData = new ChatData(0, 0);
}
return (Prefs.getChatRingtone(this.context, chatData.accountId, chatData.chatId) == null && Prefs.getChatVibrate(this.context, chatData.accountId, chatData.chatId) == Prefs.VibrateState.DEFAULT) ? false : true;
}
private int getLedArgb(String str) {
try {
return Color.parseColor(str);
} catch (Exception unused) {
return Color.rgb(255, 255, 255);
}
}
private PendingIntent getOpenChatlistIntent(int i) {
Intent intent = new Intent((Context) this.context, (Class<?>) ConversationListActivity.class);
intent.putExtra("account_id", i);
intent.putExtra(ConversationListActivity.CLEAR_NOTIFICATIONS, true);
intent.setData(Uri.parse("custom://" + i));
return PendingIntent.getActivity(this.context, 0, intent, 134217728 | IntentUtils.FLAG_MUTABLE());
}
private PendingIntent getOpenChatIntent(ChatData chatData) {
Intent intent = new Intent((Context) this.context, (Class<?>) ConversationActivity.class);
intent.putExtra("account_id", chatData.accountId);
intent.putExtra("chat_id", chatData.chatId);
intent.setData(Uri.parse("custom://" + chatData.accountId + "." + chatData.chatId));
return TaskStackBuilder.create(this.context).addNextIntentWithParentStack(intent).getPendingIntent(0, 134217728 | IntentUtils.FLAG_MUTABLE());
}
private PendingIntent getRemoteReplyIntent(ChatData chatData, int i) {
Intent intent = new Intent(RemoteReplyReceiver.REPLY_ACTION);
intent.setClass(this.context, RemoteReplyReceiver.class);
intent.setData(Uri.parse("custom://" + chatData.accountId + "." + chatData.chatId));
intent.putExtra("account_id", chatData.accountId);
intent.putExtra("chat_id", chatData.chatId);
intent.putExtra("msg_id", i);
intent.setPackage(this.context.getPackageName());
return PendingIntent.getBroadcast(this.context, 0, intent, 134217728 | IntentUtils.FLAG_MUTABLE());
}
private PendingIntent getMarkAsReadIntent(ChatData chatData, int i, boolean z) {
Intent intent = new Intent(z ? MarkReadReceiver.MARK_NOTICED_ACTION : MarkReadReceiver.CANCEL_ACTION);
intent.setClass(this.context, MarkReadReceiver.class);
intent.setData(Uri.parse("custom://" + chatData.accountId + "." + chatData.chatId));
intent.putExtra("account_id", chatData.accountId);
intent.putExtra("chat_id", chatData.chatId);
intent.putExtra("msg_id", i);
intent.setPackage(this.context.getPackageName());
return PendingIntent.getBroadcast(this.context, 0, intent, 134217728 | IntentUtils.FLAG_MUTABLE());
}
private boolean notificationChannelsSupported() {
return Build.VERSION.SDK_INT >= 26;
}
private String computeChannelId(String str, boolean z, Uri uri, ChatData chatData) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
messageDigest.update(str.getBytes());
messageDigest.update(z ? (byte) 1 : (byte) 0);
messageDigest.update((uri != null ? uri.toString() : "").getBytes());
String str2 = "ch_msg5_" + String.format("%X", new BigInteger(1, messageDigest.digest())).substring(0, 16);
if (chatData == null) {
return str2;
}
return str2 + String.format(".%d.%d", Integer.valueOf(chatData.accountId), Integer.valueOf(chatData.chatId));
} catch (Exception e) {
Log.e(TAG, e.toString());
return CH_MSG_PREFIX;
}
}
private ChatData parseNotificationChannelChat(String str) {
try {
int lastIndexOf = str.lastIndexOf(".");
if (lastIndexOf <= 0) {
return null;
}
int parseInt = Integer.parseInt(str.substring(lastIndexOf + 1));
String substring = str.substring(0, lastIndexOf);
int lastIndexOf2 = substring.lastIndexOf(".");
if (lastIndexOf2 > 0) {
return new ChatData(Integer.parseInt(substring.substring(lastIndexOf2 + 1)), parseInt);
}
return null;
} catch (Exception unused) {
return null;
}
}
private String getNotificationChannelGroup(NotificationManagerCompat notificationManagerCompat) {
if (notificationChannelsSupported() && notificationManagerCompat.getNotificationChannelGroup(CH_GRP_MSG) == null) {
ViewUtil$$ExternalSyntheticApiModelOutline0.m$3();
notificationManagerCompat.createNotificationChannelGroup(ViewUtil$$ExternalSyntheticApiModelOutline0.m(CH_GRP_MSG, this.context.getString(R.string.pref_chats)));
}
return CH_GRP_MSG;
}
private String getNotificationChannel(NotificationManagerCompat notificationManagerCompat, ChatData chatData, DcChat dcChat) {
String notificationLedColor;
boolean effectiveVibrate;
Uri effectiveSound;
boolean requiresIndependentChannel;
String computeChannelId;
String id;
ChatData chatData2 = chatData;
boolean notificationChannelsSupported = notificationChannelsSupported();
String str = CH_MSG_PREFIX;
if (!notificationChannelsSupported) {
return CH_MSG_PREFIX;
}
try {
notificationLedColor = Prefs.getNotificationLedColor(this.context);
effectiveVibrate = effectiveVibrate(chatData2);
effectiveSound = effectiveSound(chatData2);
requiresIndependentChannel = requiresIndependentChannel(chatData2);
if (!requiresIndependentChannel) {
chatData2 = null;
}
computeChannelId = computeChannelId(notificationLedColor, effectiveVibrate, effectiveSound, chatData2);
} catch (Exception e) {
e = e;
}
try {
String string = this.context.getString(R.string.def);
if (requiresIndependentChannel) {
string = dcChat.getName();
}
List notificationChannels = notificationManagerCompat.getNotificationChannels();
boolean z = false;
for (int i = 0; i < notificationChannels.size(); i++) {
id = ViewUtil$$ExternalSyntheticApiModelOutline0.m(notificationChannels.get(i)).getId();
if (id.startsWith(CH_MSG_PREFIX)) {
if (id.equals(computeChannelId)) {
ViewUtil$$ExternalSyntheticApiModelOutline0.m(notificationChannels.get(i)).setName(string);
z = true;
} else {
ChatData parseNotificationChannelChat = parseNotificationChannelChat(id);
if (!id.equals(computeChannelId(notificationLedColor, effectiveVibrate(parseNotificationChannelChat), effectiveSound(parseNotificationChannelChat), parseNotificationChannelChat))) {
notificationManagerCompat.deleteNotificationChannel(id);
}
}
}
}
if (!z) {
ViewUtil$$ExternalSyntheticApiModelOutline0.m$2();
NotificationChannel m = ViewUtil$$ExternalSyntheticApiModelOutline0.m(computeChannelId, string, 4);
m.setDescription("Informs about new messages.");
m.setGroup(getNotificationChannelGroup(notificationManagerCompat));
m.enableVibration(effectiveVibrate);
m.setShowBadge(true);
if (!notificationLedColor.equals("none")) {
m.enableLights(true);
m.setLightColor(getLedArgb(notificationLedColor));
} else {
m.enableLights(false);
}
if (effectiveSound != null && !TextUtils.isEmpty(effectiveSound.toString())) {
m.setSound(effectiveSound, new AudioAttributes.Builder().setContentType(0).setUsage(8).build());
} else {
m.setSound(null, null);
}
notificationManagerCompat.createNotificationChannel(m);
}
return computeChannelId;
} catch (Exception e2) {
e = e2;
str = computeChannelId;
Log.e(TAG, "Error in getNotificationChannel()", e);
return str;
}
}
public void notifyMessage(final int i, final int i2, final int i3) {
Util.runOnAnyBackgroundThread(new Runnable() {
@Override
public final void run() {
NotificationCenter.this.m1530x34fcaaa4(i, i2, i3);
}
});
}
void m1530x34fcaaa4(int i, int i2, int i3) {
String str;
String str2;
DcContext account = ApplicationContext.dcAccounts.getAccount(i);
DcChat chat = account.getChat(i2);
DcMsg msg = account.getMsg(i3);
NotificationPrivacyPreference notificationPrivacy = Prefs.getNotificationPrivacy(this.context);
String summarytext = notificationPrivacy.isDisplayMessage() ? msg.getSummarytext(2000) : this.context.getString(R.string.notify_new_message);
if (chat.isMultiUser() && notificationPrivacy.isDisplayContact()) {
summarytext = msg.getSenderName(account.getContact(msg.getFromId())) + ": " + summarytext;
}
if (chat.isMultiUser() || !notificationPrivacy.isDisplayContact()) {
str = summarytext;
} else {
String str3 = msg.getSenderName(account.getContact(msg.getFromId())) + ": " + summarytext;
if (msg.getOverrideSenderName() == null) {
str2 = str3;
str = summarytext;
DcMsg quotedMsg = msg.getQuotedMsg();
maybeAddNotification(i, chat, i3, str, str2, true, (chat.isMultiUser() || quotedMsg == null || !quotedMsg.isOutgoing()) ? false : true);
}
str = str3;
}
str2 = str;
DcMsg quotedMsg2 = msg.getQuotedMsg();
maybeAddNotification(i, chat, i3, str, str2, true, (chat.isMultiUser() || quotedMsg2 == null || !quotedMsg2.isOutgoing()) ? false : true);
}
public void notifyReaction(final int i, final int i2, final int i3, final String str) {
Util.runOnAnyBackgroundThread(new Runnable() {
@Override
public final void run() {
NotificationCenter.this.m1531xe1be6f53(i, i3, i2, str);
}
});
}
void m1531xe1be6f53(int i, int i2, int i3, String str) {
DcContext account = ApplicationContext.dcAccounts.getAccount(i);
DcMsg msg = account.getMsg(i2);
NotificationPrivacyPreference notificationPrivacy = Prefs.getNotificationPrivacy(this.context);
if (notificationPrivacy.isDisplayContact() && notificationPrivacy.isDisplayMessage()) {
String string = this.context.getString(R.string.reaction_by_other, new Object[]{account.getContact(i3).getDisplayName(), str, msg.getSummarytext(2000)});
DcChat chat = account.getChat(msg.getChatId());
maybeAddNotification(i, chat, i2, string, string, false, chat.isMultiUser());
}
}
public void notifyWebxdc(final int i, int i2, final int i3, final String str) {
Util.runOnAnyBackgroundThread(new Runnable() {
@Override
public final void run() {
NotificationCenter.this.m1532xa3d010ce(i, i3, str);
}
});
}
void m1532xa3d010ce(int i, int i2, String str) {
NotificationPrivacyPreference notificationPrivacy = Prefs.getNotificationPrivacy(this.context);
if (notificationPrivacy.isDisplayContact() && notificationPrivacy.isDisplayMessage()) {
DcContext account = ApplicationContext.dcAccounts.getAccount(i);
DcMsg msg = account.getMsg(i2);
DcMsg parent = (msg.getType() == 80 || msg.getParent() == null) ? msg : msg.getParent();
if (Util.equals(this.visibleWebxdc, new Pair(Integer.valueOf(i), Integer.valueOf(parent.getId())))) {
return;
}
String optString = JsonUtils.optString(parent.getWebxdcInfo(), "name");
if (!optString.isEmpty()) {
str = optString + ": " + str;
}
String str2 = str;
DcChat chat = account.getChat(msg.getChatId());
maybeAddNotification(i, chat, i2, str2, str2, false, chat.isMultiUser());
}
}
private void maybeAddNotification(int i, DcChat dcChat, int i2, String str, String str2, boolean z, boolean z2) {
Drawable asDrawable;
int dimensionPixelSize;
Bitmap createFromDrawable;
int color;
DcContext account = ApplicationContext.dcAccounts.getAccount(i);
int id = dcChat.getId();
ChatData chatData = new ChatData(i, id);
boolean z3 = z2 && account.isMentionsEnabled();
if (account.isMuted()) {
return;
}
if (z3 || !dcChat.isMuted()) {
NotificationManagerCompat from = NotificationManagerCompat.from(this.context);
if (Build.VERSION.SDK_INT < 33 || from.areNotificationsEnabled()) {
if (Util.equals(this.visibleChat, chatData)) {
if (z && Prefs.isInChatNotifications(this.context)) {
InChatSounds.getInstance(this.context).playIncomingSound();
return;
}
return;
}
NotificationPrivacyPreference notificationPrivacy = Prefs.getNotificationPrivacy(this.context);
long currentTimeMillis = System.currentTimeMillis();
boolean z4 = currentTimeMillis - this.lastAudibleNotification > MIN_AUDIBLE_PERIOD_MILLIS;
if (z4) {
this.lastAudibleNotification = currentTimeMillis;
}
String notificationChannel = getNotificationChannel(from, chatData, dcChat);
NotificationCompat.Builder contentIntent = new NotificationCompat.Builder(this.context, notificationChannel).setSmallIcon(R.drawable.icon_notification).setColor(this.context.getResources().getColor(R.color.delta_primary)).setPriority(Prefs.getNotificationPriority(this.context)).setCategory("msg").setOnlyAlertOnce(!z4).setContentText(str).setDeleteIntent(getMarkAsReadIntent(chatData, i2, false)).setContentIntent(getOpenChatIntent(chatData));
if (Build.VERSION.SDK_INT >= 24) {
contentIntent.setGroup("grp_msg." + i);
}
String config = account.getConfig(DcHelper.CONFIG_PRIVATE_TAG);
if (config.isEmpty() && ApplicationContext.dcAccounts.getAll().length > 1) {
config = account.getName();
}
if (notificationPrivacy.isDisplayContact()) {
contentIntent.setContentTitle(dcChat.getName());
if (!TextUtils.isEmpty(config)) {
contentIntent.setSubText(config);
}
}
contentIntent.setTicker(str2);
if (!notificationChannelsSupported()) {
if (z4) {
Uri effectiveSound = effectiveSound(chatData);
if (effectiveSound != null && !TextUtils.isEmpty(effectiveSound.toString())) {
contentIntent.setSound(effectiveSound);
}
if (effectiveVibrate(chatData)) {
contentIntent.setDefaults(2);
}
}
String notificationLedColor = Prefs.getNotificationLedColor(this.context);
if (!notificationLedColor.equals("none")) {
contentIntent.setLights(getLedArgb(notificationLedColor), 500, 2000);
}
}
Recipient recipient = new Recipient((Context) this.context, dcChat);
if (notificationPrivacy.isDisplayContact()) {
try {
ContactPhoto contactPhoto = recipient.getContactPhoto(this.context);
if (contactPhoto != null) {
asDrawable = (Drawable) GlideApp.with(this.context.getApplicationContext()).m1516load((Object) contactPhoto).diskCacheStrategy(DiskCacheStrategy.NONE).circleCrop().submit(this.context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width), this.context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height)).get();
} else {
asDrawable = recipient.getFallbackContactPhoto().asDrawable(this.context, recipient.getFallbackAvatarColor());
}
if (asDrawable != null && (createFromDrawable = BitmapUtil.createFromDrawable(asDrawable, (dimensionPixelSize = this.context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size)), dimensionPixelSize)) != null) {
contentIntent.setLargeIcon(createFromDrawable);
}
} catch (Exception e) {
Log.w(TAG, e);
}
}
if (notificationPrivacy.isDisplayContact() && notificationPrivacy.isDisplayMessage()) {
try {
PendingIntent remoteReplyIntent = getRemoteReplyIntent(chatData, i2);
NotificationCompat.Action action = new NotificationCompat.Action(R.drawable.check, this.context.getString(R.string.mark_as_read_short), getMarkAsReadIntent(chatData, i2, true));
if (Build.VERSION.SDK_INT >= 24) {
contentIntent.addAction(new NotificationCompat.Action.Builder(R.drawable.ic_reply_white_36dp, this.context.getString(R.string.notify_reply_button), remoteReplyIntent).addRemoteInput(new RemoteInput.Builder(RemoteReplyReceiver.EXTRA_REMOTE_REPLY).setLabel(this.context.getString(R.string.notify_reply_button)).build()).build());
}
NotificationCompat.Action build = new NotificationCompat.Action.Builder(R.drawable.ic_reply, this.context.getString(R.string.notify_reply_button), remoteReplyIntent).addRemoteInput(new RemoteInput.Builder(RemoteReplyReceiver.EXTRA_REMOTE_REPLY).setLabel(this.context.getString(R.string.notify_reply_button)).build()).build();
contentIntent.addAction(action);
contentIntent.extend(new NotificationCompat.WearableExtender().addAction(action).addAction(build));
} catch (Exception e2) {
Log.w(TAG, e2);
}
}
if (notificationPrivacy.isDisplayContact() && notificationPrivacy.isDisplayMessage()) {
try {
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
synchronized (this.inboxes) {
HashMap<Integer, ArrayList<String>> hashMap = this.inboxes.get(Integer.valueOf(i));
if (hashMap == null) {
hashMap = new HashMap<>();
this.inboxes.put(Integer.valueOf(i), hashMap);
}
ArrayList<String> arrayList = hashMap.get(Integer.valueOf(id));
if (arrayList == null) {
arrayList = new ArrayList<>();
hashMap.put(Integer.valueOf(id), arrayList);
}
arrayList.add(str);
for (int i3 = 0; i3 < arrayList.size(); i3++) {
inboxStyle.addLine(arrayList.get(i3));
}
}
contentIntent.setStyle(inboxStyle);
} catch (Exception e3) {
Log.w(TAG, e3);
}
}
int freshMsgCount = account.getFreshMsgCount(id);
contentIntent.setContentInfo(String.valueOf(freshMsgCount));
contentIntent.setNumber(freshMsgCount);
try {
from.notify(String.valueOf(i), id, contentIntent.build());
} catch (Exception e4) {
Log.e(TAG, "cannot add notification", e4);
}
if (Build.VERSION.SDK_INT >= 24) {
try {
NotificationCompat.Builder smallIcon = new NotificationCompat.Builder(this.context, notificationChannel).setGroup("grp_msg." + i).setGroupSummary(true).setSmallIcon(R.drawable.icon_notification);
color = this.context.getResources().getColor(R.color.delta_primary, null);
NotificationCompat.Builder contentIntent2 = smallIcon.setColor(color).setCategory("msg").setContentTitle("Delta Chat").setContentText("New messages").setContentIntent(getOpenChatlistIntent(i));
if (notificationPrivacy.isDisplayContact() && !TextUtils.isEmpty(config)) {
contentIntent2.setSubText(config);
}
from.notify(String.valueOf(i), 2, contentIntent2.build());
} catch (Exception e5) {
Log.e(TAG, "cannot add notification summary", e5);
}
}
}
}
}
public void removeNotifications(int i, int i2) {
boolean isEmpty;
synchronized (this.inboxes) {
HashMap<Integer, ArrayList<String>> hashMap = this.inboxes.get(Integer.valueOf(i));
if (hashMap == null) {
hashMap = new HashMap<>();
}
hashMap.remove(Integer.valueOf(i2));
isEmpty = hashMap.isEmpty();
}
try {
NotificationManagerCompat from = NotificationManagerCompat.from(this.context);
String valueOf = String.valueOf(i);
from.cancel(valueOf, i2);
if (isEmpty) {
from.cancel(valueOf, 2);
}
} catch (Exception e) {
Log.w(TAG, e);
}
}
public void removeAllNotifications(int i) {
NotificationManagerCompat from = NotificationManagerCompat.from(this.context);
String valueOf = String.valueOf(i);
synchronized (this.inboxes) {
HashMap<Integer, ArrayList<String>> hashMap = this.inboxes.get(Integer.valueOf(i));
from.cancel(valueOf, 2);
if (hashMap != null) {
Iterator<Integer> it = hashMap.keySet().iterator();
while (it.hasNext()) {
from.cancel(valueOf, it.next().intValue());
}
hashMap.clear();
}
}
}
public void updateVisibleChat(final int i, final int i2) {
Util.runOnAnyBackgroundThread(new Runnable() {
@Override
public final void run() {
NotificationCenter.this.m1533x5a41d14a(i, i2);
}
});
}
void m1533x5a41d14a(int i, int i2) {
if (i == 0 || i2 == 0) {
this.visibleChat = null;
} else {
this.visibleChat = new ChatData(i, i2);
removeNotifications(i, i2);
}
}
public void clearVisibleChat() {
this.visibleChat = null;
}
public void updateVisibleWebxdc(int i, int i2) {
if (i != 0 && i2 != 0) {
this.visibleWebxdc = new Pair<>(Integer.valueOf(i), Integer.valueOf(i2));
} else {
this.visibleWebxdc = null;
}
}
public void clearVisibleWebxdc() {
this.visibleWebxdc = null;
}
public void maybePlaySendSound(DcChat dcChat) {
if (!Prefs.isInChatNotifications(this.context) || dcChat.isMuted()) {
return;
}
InChatSounds.getInstance(this.context).playSendSound();
}
private static class ChatData {
public final int accountId;
public final int chatId;
public ChatData(int i, int i2) {
this.accountId = i;
this.chatId = i2;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
ChatData chatData = (ChatData) obj;
return this.accountId == chatData.accountId && this.chatId == chatData.chatId;
}
}
}