正在查看: Plus 12 v10.13.1.1 应用的 NotificationsController.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Plus 12 v10.13.1.1 应用的 NotificationsController.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.telegram.messenger;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.ImageDecoder;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.PostProcessor;
import android.graphics.Rect;
import android.graphics.Shader;
import android.media.AudioManager;
import android.media.SoundPool;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import android.os.SystemClock;
import android.provider.Settings;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Pair;
import android.util.SparseArray;
import androidx.collection.LongSparseArray;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.app.Person;
import androidx.core.graphics.drawable.IconCompat;
import j$.util.Comparator;
import j$.util.function.Consumer;
import j$.util.function.ToLongFunction;
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import org.telegram.messenger.NotificationsController;
import org.telegram.messenger.support.LongSparseIntArray;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.PlusSettings;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.spoilers.SpoilerEffect;
import org.telegram.ui.PopupNotificationActivity;
import org.telegram.ui.Stories.recorder.StoryEntry;
public class NotificationsController extends BaseController {
public static final String EXTRA_VOICE_REPLY = "extra_voice_reply";
private static volatile NotificationsController[] Instance = null;
public static String OTHER_NOTIFICATIONS_CHANNEL = null;
public static final int SETTING_MUTE_2_DAYS = 2;
public static final int SETTING_MUTE_8_HOURS = 1;
public static final int SETTING_MUTE_CUSTOM = 5;
public static final int SETTING_MUTE_FOREVER = 3;
public static final int SETTING_MUTE_HOUR = 0;
public static final int SETTING_MUTE_UNMUTE = 4;
public static final int SETTING_SOUND_OFF = 1;
public static final int SETTING_SOUND_ON = 0;
public static final int TYPE_CHANNEL = 2;
public static final int TYPE_GROUP = 0;
public static final int TYPE_PRIVATE = 1;
public static final int TYPE_REACTIONS_MESSAGES = 4;
public static final int TYPE_REACTIONS_STORIES = 5;
public static final int TYPE_STORIES = 3;
public static AudioManager audioManager;
private static final Object[] lockObjects;
private static NotificationManagerCompat notificationManager;
private static final LongSparseArray<String> sharedPrefCachedKeys;
private static NotificationManager systemNotificationManager;
private AlarmManager alarmManager;
private boolean channelGroupsCreated;
private Runnable checkStoryPushesRunnable;
private final ArrayList<MessageObject> delayedPushMessages;
public NotificationsSettingsFacade dialogsNotificationsFacade;
private final LongSparseArray<MessageObject> fcmRandomMessagesDict;
private Boolean groupsCreated;
private boolean inChatSoundEnabled;
private int lastBadgeCount;
private int lastButtonId;
public long lastNotificationChannelCreateTime;
private int lastOnlineFromOtherDevice;
private long lastSoundOutPlay;
private long lastSoundPlay;
private final LongSparseArray<Integer> lastWearNotifiedMessageId;
private String launcherClassName;
private SpoilerEffect mediaSpoilerEffect;
private Runnable notificationDelayRunnable;
private PowerManager.WakeLock notificationDelayWakelock;
private String notificationGroup;
private int notificationId;
private boolean notifyCheck;
private long openedDialogId;
private final HashSet<Long> openedInBubbleDialogs;
private long openedTopicId;
private int personalCount;
public final ArrayList<MessageObject> popupMessages;
public ArrayList<MessageObject> popupReplyMessages;
private final LongSparseArray<Integer> pushDialogs;
private final LongSparseArray<Integer> pushDialogsOverrideMention;
private final ArrayList<MessageObject> pushMessages;
private final LongSparseArray<SparseArray<MessageObject>> pushMessagesDict;
public boolean showBadgeMessages;
public boolean showBadgeMuted;
public boolean showBadgeNumber;
private final LongSparseArray<Point> smartNotificationsDialogs;
private int soundIn;
private boolean soundInLoaded;
private int soundOut;
private boolean soundOutLoaded;
private SoundPool soundPool;
private int soundRecord;
private boolean soundRecordLoaded;
public char[] spoilerChars;
private final ArrayList<StoryNotification> storyPushMessages;
private final LongSparseArray<StoryNotification> storyPushMessagesDict;
private int[] totalCount;
private int total_unread_count;
private final LongSparseArray<Integer> wearNotificationsIds;
private static final DispatchQueue notificationsQueue = new DispatchQueue("notificationsQueue");
public static long globalSecretChatId = DialogObject.makeEncryptedDialogId(1);
public static String getGlobalNotificationsKey(int type) {
return type == 0 ? "EnableGroup2" : type == 1 ? "EnableAll2" : "EnableChannel2";
}
public static void lambda$updateServerNotificationsSettings$47(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$updateServerNotificationsSettings$48(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$updateServerNotificationsSettings$49(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public void processReadStories() {
}
static {
notificationManager = null;
systemNotificationManager = null;
if (Build.VERSION.SDK_INT >= 26 && ApplicationLoader.applicationContext != null) {
notificationManager = NotificationManagerCompat.from(ApplicationLoader.applicationContext);
systemNotificationManager = (NotificationManager) ApplicationLoader.applicationContext.getSystemService("notification");
checkOtherNotificationsChannel();
}
audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService("audio");
Instance = new NotificationsController[UserConfig.MAX_ACCOUNT_COUNT];
lockObjects = new Object[UserConfig.MAX_ACCOUNT_COUNT];
for (int i = 0; i < UserConfig.MAX_ACCOUNT_COUNT; i++) {
lockObjects[i] = new Object();
}
sharedPrefCachedKeys = new LongSparseArray<>();
}
public static NotificationsController getInstance(int num) {
NotificationsController notificationsController = Instance[num];
if (notificationsController == null) {
synchronized (lockObjects[num]) {
notificationsController = Instance[num];
if (notificationsController == null) {
NotificationsController[] notificationsControllerArr = Instance;
NotificationsController notificationsController2 = new NotificationsController(num);
notificationsControllerArr[num] = notificationsController2;
notificationsController = notificationsController2;
}
}
}
return notificationsController;
}
public NotificationsController(int instance) {
super(instance);
this.pushMessages = new ArrayList<>();
this.delayedPushMessages = new ArrayList<>();
this.pushMessagesDict = new LongSparseArray<>();
this.fcmRandomMessagesDict = new LongSparseArray<>();
this.smartNotificationsDialogs = new LongSparseArray<>();
this.pushDialogs = new LongSparseArray<>();
this.wearNotificationsIds = new LongSparseArray<>();
this.lastWearNotifiedMessageId = new LongSparseArray<>();
this.pushDialogsOverrideMention = new LongSparseArray<>();
this.popupMessages = new ArrayList<>();
this.popupReplyMessages = new ArrayList<>();
this.openedInBubbleDialogs = new HashSet<>();
this.storyPushMessages = new ArrayList<>();
this.storyPushMessagesDict = new LongSparseArray<>();
this.openedDialogId = 0L;
this.openedTopicId = 0L;
this.lastButtonId = 5000;
this.total_unread_count = 0;
this.personalCount = 0;
this.notifyCheck = false;
this.lastOnlineFromOtherDevice = 0;
this.lastBadgeCount = -1;
this.mediaSpoilerEffect = new SpoilerEffect();
this.totalCount = new int[UserConfig.MAX_ACCOUNT_COUNT];
this.spoilerChars = new char[]{10252, 10338, 10385, 10280};
this.checkStoryPushesRunnable = new Runnable() {
@Override
public final void run() {
NotificationsController.this.checkStoryPushes();
}
};
this.notificationId = ((BaseController) this).currentAccount + 1;
StringBuilder sb = new StringBuilder();
sb.append("messages");
int i = ((BaseController) this).currentAccount;
sb.append(i == 0 ? BuildConfig.APP_CENTER_HASH : Integer.valueOf(i));
this.notificationGroup = sb.toString();
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
this.inChatSoundEnabled = notificationsSettings.getBoolean("EnableInChatSound", true);
this.showBadgeNumber = notificationsSettings.getBoolean("badgeNumber", true);
this.showBadgeMuted = notificationsSettings.getBoolean("badgeNumberMuted", false);
this.showBadgeMessages = notificationsSettings.getBoolean("badgeNumberMessages", true);
notificationManager = NotificationManagerCompat.from(ApplicationLoader.applicationContext);
systemNotificationManager = (NotificationManager) ApplicationLoader.applicationContext.getSystemService("notification");
try {
audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService("audio");
} catch (Exception e) {
FileLog.e(e);
}
try {
this.alarmManager = (AlarmManager) ApplicationLoader.applicationContext.getSystemService("alarm");
} catch (Exception e2) {
FileLog.e(e2);
}
try {
PowerManager.WakeLock newWakeLock = ((PowerManager) ApplicationLoader.applicationContext.getSystemService("power")).newWakeLock(1, "telegram:notification_delay_lock");
this.notificationDelayWakelock = newWakeLock;
newWakeLock.setReferenceCounted(false);
} catch (Exception e3) {
FileLog.e(e3);
}
this.notificationDelayRunnable = new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$new$0();
}
};
this.dialogsNotificationsFacade = new NotificationsSettingsFacade(((BaseController) this).currentAccount);
}
public void lambda$new$0() {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("delay reached");
}
if (!this.delayedPushMessages.isEmpty()) {
showOrUpdateNotification(true);
this.delayedPushMessages.clear();
}
try {
if (this.notificationDelayWakelock.isHeld()) {
this.notificationDelayWakelock.release();
}
} catch (Exception e) {
FileLog.e(e);
}
}
public static void checkOtherNotificationsChannel() {
SharedPreferences sharedPreferences;
if (Build.VERSION.SDK_INT < 26) {
return;
}
if (OTHER_NOTIFICATIONS_CHANNEL == null) {
sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", 0);
OTHER_NOTIFICATIONS_CHANNEL = sharedPreferences.getString("OtherKey", "Other3");
} else {
sharedPreferences = null;
}
NotificationChannel notificationChannel = systemNotificationManager.getNotificationChannel(OTHER_NOTIFICATIONS_CHANNEL);
if (notificationChannel != null && notificationChannel.getImportance() == 0) {
try {
systemNotificationManager.deleteNotificationChannel(OTHER_NOTIFICATIONS_CHANNEL);
} catch (Exception e) {
FileLog.e(e);
}
OTHER_NOTIFICATIONS_CHANNEL = null;
notificationChannel = null;
}
if (OTHER_NOTIFICATIONS_CHANNEL == null) {
if (sharedPreferences == null) {
sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", 0);
}
OTHER_NOTIFICATIONS_CHANNEL = "Other" + Utilities.random.nextLong();
sharedPreferences.edit().putString("OtherKey", OTHER_NOTIFICATIONS_CHANNEL).commit();
}
if (notificationChannel == null) {
NotificationChannel notificationChannel2 = new NotificationChannel(OTHER_NOTIFICATIONS_CHANNEL, "Internal notifications", 3);
notificationChannel2.enableLights(false);
notificationChannel2.enableVibration(false);
notificationChannel2.setSound(null, null);
try {
systemNotificationManager.createNotificationChannel(notificationChannel2);
} catch (Exception e2) {
FileLog.e(e2);
}
}
}
public static String getSharedPrefKey(long dialog_id, long topicId) {
return getSharedPrefKey(dialog_id, topicId, false);
}
public static String getSharedPrefKey(long dialog_id, long topicId, boolean backgroundThread) {
String valueOf;
if (backgroundThread) {
return topicId != 0 ? String.format(Locale.US, "%d_%d", Long.valueOf(dialog_id), Long.valueOf(topicId)) : String.valueOf(dialog_id);
}
long j = (topicId << 12) + dialog_id;
LongSparseArray<String> longSparseArray = sharedPrefCachedKeys;
int indexOfKey = longSparseArray.indexOfKey(j);
if (indexOfKey >= 0) {
return (String) longSparseArray.valueAt(indexOfKey);
}
if (topicId != 0) {
valueOf = String.format(Locale.US, "%d_%d", Long.valueOf(dialog_id), Long.valueOf(topicId));
} else {
valueOf = String.valueOf(dialog_id);
}
longSparseArray.put(j, valueOf);
return valueOf;
}
public void muteUntil(long did, long topicId, int selectedTimeInSeconds) {
if (did != 0) {
SharedPreferences.Editor edit = MessagesController.getNotificationsSettings(((BaseController) this).currentAccount).edit();
boolean z = topicId != 0;
boolean isGlobalNotificationsEnabled = getInstance(((BaseController) this).currentAccount).isGlobalNotificationsEnabled(did, false, false);
String sharedPrefKey = getSharedPrefKey(did, topicId);
long j = 1;
if (selectedTimeInSeconds != Integer.MAX_VALUE) {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + sharedPrefKey, 3);
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY_UNTIL + sharedPrefKey, getConnectionsManager().getCurrentTime() + selectedTimeInSeconds);
j = 1 | (((long) selectedTimeInSeconds) << 32);
} else if (!isGlobalNotificationsEnabled && !z) {
edit.remove(NotificationsSettingsFacade.PROPERTY_NOTIFY + sharedPrefKey);
j = 0L;
} else {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + sharedPrefKey, 2);
}
edit.apply();
if (topicId == 0) {
getInstance(((BaseController) this).currentAccount).removeNotificationsForDialog(did);
MessagesStorage.getInstance(((BaseController) this).currentAccount).setDialogFlags(did, j);
TLRPC.Dialog dialog = (TLRPC.Dialog) MessagesController.getInstance(((BaseController) this).currentAccount).dialogs_dict.get(did);
if (dialog != null) {
TLRPC.TL_peerNotifySettings tL_peerNotifySettings = new TLRPC.TL_peerNotifySettings();
dialog.notify_settings = tL_peerNotifySettings;
if (selectedTimeInSeconds != Integer.MAX_VALUE || isGlobalNotificationsEnabled) {
tL_peerNotifySettings.mute_until = selectedTimeInSeconds;
}
}
}
getInstance(((BaseController) this).currentAccount).updateServerNotificationsSettings(did, topicId);
}
}
public void cleanup() {
this.popupMessages.clear();
this.popupReplyMessages.clear();
this.channelGroupsCreated = false;
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$cleanup$1();
}
});
}
public void lambda$cleanup$1() {
this.openedDialogId = 0L;
this.openedTopicId = 0L;
this.total_unread_count = 0;
this.personalCount = 0;
this.pushMessages.clear();
this.pushMessagesDict.clear();
this.fcmRandomMessagesDict.clear();
this.pushDialogs.clear();
this.wearNotificationsIds.clear();
this.lastWearNotifiedMessageId.clear();
this.openedInBubbleDialogs.clear();
this.delayedPushMessages.clear();
this.notifyCheck = false;
this.lastBadgeCount = 0;
try {
if (this.notificationDelayWakelock.isHeld()) {
this.notificationDelayWakelock.release();
}
} catch (Exception e) {
FileLog.e(e);
}
dismissNotification();
setBadge(getTotalAllUnreadCount());
SharedPreferences.Editor edit = getAccountInstance().getNotificationsSettings().edit();
edit.clear();
edit.commit();
if (Build.VERSION.SDK_INT >= 26) {
try {
systemNotificationManager.deleteNotificationChannelGroup("channels" + ((BaseController) this).currentAccount);
systemNotificationManager.deleteNotificationChannelGroup("groups" + ((BaseController) this).currentAccount);
systemNotificationManager.deleteNotificationChannelGroup("private" + ((BaseController) this).currentAccount);
systemNotificationManager.deleteNotificationChannelGroup("stories" + ((BaseController) this).currentAccount);
systemNotificationManager.deleteNotificationChannelGroup("other" + ((BaseController) this).currentAccount);
String str = ((BaseController) this).currentAccount + "channel";
List<NotificationChannel> notificationChannels = systemNotificationManager.getNotificationChannels();
int size = notificationChannels.size();
for (int i = 0; i < size; i++) {
String id = notificationChannels.get(i).getId();
if (id.startsWith(str)) {
try {
systemNotificationManager.deleteNotificationChannel(id);
} catch (Exception e2) {
FileLog.e(e2);
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("delete channel cleanup " + id);
}
}
}
} catch (Throwable th) {
FileLog.e(th);
}
}
}
public void setInChatSoundEnabled(boolean value) {
this.inChatSoundEnabled = value;
}
public void setOpenedDialogId(final long dialog_id, final long topicId) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$setOpenedDialogId$2(dialog_id, topicId);
}
});
}
public void lambda$setOpenedDialogId$2(long j, long j2) {
this.openedDialogId = j;
this.openedTopicId = j2;
}
public void setOpenedInBubble(final long dialogId, final boolean opened) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$setOpenedInBubble$3(opened, dialogId);
}
});
}
public void lambda$setOpenedInBubble$3(boolean z, long j) {
if (z) {
this.openedInBubbleDialogs.add(Long.valueOf(j));
} else {
this.openedInBubbleDialogs.remove(Long.valueOf(j));
}
}
public void setLastOnlineFromOtherDevice(final int time) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$setLastOnlineFromOtherDevice$4(time);
}
});
}
public void lambda$setLastOnlineFromOtherDevice$4(int i) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("set last online from other device = " + i);
}
this.lastOnlineFromOtherDevice = i;
}
public void removeNotificationsForDialog(long did) {
processReadMessages(null, did, 0, Integer.MAX_VALUE, false);
LongSparseIntArray longSparseIntArray = new LongSparseIntArray();
longSparseIntArray.put(did, 0);
processDialogsUpdateRead(longSparseIntArray);
}
public boolean hasMessagesToReply() {
for (int i = 0; i < this.pushMessages.size(); i++) {
MessageObject messageObject = this.pushMessages.get(i);
long dialogId = messageObject.getDialogId();
if (!messageObject.isReactionPush) {
TLRPC.Message message = messageObject.messageOwner;
if ((!message.mentioned || !(message.action instanceof TLRPC.TL_messageActionPinMessage)) && !DialogObject.isEncryptedDialog(dialogId) && (messageObject.messageOwner.peer_id.channel_id == 0 || messageObject.isSupergroup())) {
return true;
}
}
}
return false;
}
public void forceShowPopupForReply() {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$forceShowPopupForReply$6();
}
});
}
public void lambda$forceShowPopupForReply$6() {
final ArrayList arrayList = new ArrayList();
for (int i = 0; i < this.pushMessages.size(); i++) {
MessageObject messageObject = this.pushMessages.get(i);
long dialogId = messageObject.getDialogId();
TLRPC.Message message = messageObject.messageOwner;
if ((!message.mentioned || !(message.action instanceof TLRPC.TL_messageActionPinMessage)) && !DialogObject.isEncryptedDialog(dialogId) && (messageObject.messageOwner.peer_id.channel_id == 0 || messageObject.isSupergroup())) {
arrayList.add(0, messageObject);
}
}
if (arrayList.isEmpty() || AndroidUtilities.needShowPasscode() || SharedConfig.isWaitingForPasscodeEnter) {
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$forceShowPopupForReply$5(arrayList);
}
});
}
public void lambda$forceShowPopupForReply$5(ArrayList arrayList) {
this.popupReplyMessages = arrayList;
Intent intent = new Intent(ApplicationLoader.applicationContext, (Class<?>) PopupNotificationActivity.class);
intent.putExtra("force", true);
intent.putExtra("currentAccount", ((BaseController) this).currentAccount);
intent.setFlags(268763140);
ApplicationLoader.applicationContext.startActivity(intent);
ApplicationLoader.applicationContext.sendBroadcast(new Intent("android.intent.action.CLOSE_SYSTEM_DIALOGS"));
}
public void removeDeletedMessagesFromNotifications(final LongSparseArray<ArrayList<Integer>> deletedMessages, final boolean isReactions) {
final ArrayList arrayList = new ArrayList(0);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$removeDeletedMessagesFromNotifications$9(deletedMessages, isReactions, arrayList);
}
});
}
public void lambda$removeDeletedMessagesFromNotifications$9(LongSparseArray longSparseArray, boolean z, final ArrayList arrayList) {
long j;
Integer num;
LongSparseArray longSparseArray2 = longSparseArray;
int i = this.total_unread_count;
getAccountInstance().getNotificationsSettings();
int i2 = 0;
while (i2 < longSparseArray.size()) {
long keyAt = longSparseArray2.keyAt(i2);
SparseArray sparseArray = (SparseArray) this.pushMessagesDict.get(keyAt);
if (sparseArray != null) {
ArrayList arrayList2 = (ArrayList) longSparseArray2.get(keyAt);
int size = arrayList2.size();
int i3 = 0;
while (i3 < size) {
int intValue = ((Integer) arrayList2.get(i3)).intValue();
MessageObject messageObject = (MessageObject) sparseArray.get(intValue);
if (messageObject == null || messageObject.isStoryReactionPush || (z && !messageObject.isReactionPush)) {
j = keyAt;
} else {
j = keyAt;
long dialogId = messageObject.getDialogId();
Integer num2 = (Integer) this.pushDialogs.get(dialogId);
if (num2 == null) {
num2 = 0;
}
Integer valueOf = Integer.valueOf(num2.intValue() - 1);
if (valueOf.intValue() <= 0) {
this.smartNotificationsDialogs.remove(dialogId);
num = 0;
} else {
num = valueOf;
}
if (!num.equals(num2)) {
if (getMessagesController().isForum(dialogId)) {
int i4 = this.total_unread_count - (num2.intValue() > 0 ? 1 : 0);
this.total_unread_count = i4;
this.total_unread_count = i4 + (num.intValue() > 0 ? 1 : 0);
} else {
int intValue2 = this.total_unread_count - num2.intValue();
this.total_unread_count = intValue2;
this.total_unread_count = intValue2 + num.intValue();
}
this.pushDialogs.put(dialogId, num);
}
if (num.intValue() == 0) {
this.pushDialogs.remove(dialogId);
this.pushDialogsOverrideMention.remove(dialogId);
}
sparseArray.remove(intValue);
this.delayedPushMessages.remove(messageObject);
this.pushMessages.remove(messageObject);
if (isPersonalMessage(messageObject)) {
this.personalCount--;
}
arrayList.add(messageObject);
}
i3++;
keyAt = j;
}
long j2 = keyAt;
if (sparseArray.size() == 0) {
this.pushMessagesDict.remove(j2);
}
}
i2++;
longSparseArray2 = longSparseArray;
}
if (!arrayList.isEmpty()) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$removeDeletedMessagesFromNotifications$7(arrayList);
}
});
}
if (i != this.total_unread_count) {
if (!this.notifyCheck) {
this.delayedPushMessages.clear();
showOrUpdateNotification(this.notifyCheck);
} else {
scheduleNotificationDelay(this.lastOnlineFromOtherDevice > getConnectionsManager().getCurrentTime());
}
final int size2 = this.pushDialogs.size();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$removeDeletedMessagesFromNotifications$8(size2);
}
});
}
this.notifyCheck = false;
if (this.showBadgeNumber) {
setBadge(getTotalAllUnreadCount());
}
}
public void lambda$removeDeletedMessagesFromNotifications$7(ArrayList arrayList) {
int size = arrayList.size();
for (int i = 0; i < size; i++) {
this.popupMessages.remove(arrayList.get(i));
}
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.pushMessagesUpdated, new Object[0]);
}
public void lambda$removeDeletedMessagesFromNotifications$8(int i) {
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.notificationsCountUpdated, Integer.valueOf(((BaseController) this).currentAccount));
getNotificationCenter().lambda$postNotificationNameOnUIThread$1(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(i));
}
public void removeDeletedHisoryFromNotifications(final LongSparseIntArray deletedMessages) {
final ArrayList arrayList = new ArrayList(0);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$removeDeletedHisoryFromNotifications$12(deletedMessages, arrayList);
}
});
}
public void lambda$removeDeletedHisoryFromNotifications$12(LongSparseIntArray longSparseIntArray, final ArrayList arrayList) {
Integer num;
int i = this.total_unread_count;
getAccountInstance().getNotificationsSettings();
Integer num2 = 0;
int i2 = 0;
while (true) {
if (i2 >= longSparseIntArray.size()) {
break;
}
long keyAt = longSparseIntArray.keyAt(i2);
long j = -keyAt;
long j2 = longSparseIntArray.get(keyAt);
Integer num3 = (Integer) this.pushDialogs.get(j);
if (num3 == null) {
num3 = num2;
}
Integer num4 = num3;
int i3 = 0;
while (i3 < this.pushMessages.size()) {
MessageObject messageObject = this.pushMessages.get(i3);
if (messageObject.getDialogId() == j) {
num = num2;
if (messageObject.getId() <= j2) {
SparseArray sparseArray = (SparseArray) this.pushMessagesDict.get(j);
if (sparseArray != null) {
sparseArray.remove(messageObject.getId());
if (sparseArray.size() == 0) {
this.pushMessagesDict.remove(j);
}
}
this.delayedPushMessages.remove(messageObject);
this.pushMessages.remove(messageObject);
i3--;
if (isPersonalMessage(messageObject)) {
this.personalCount--;
}
arrayList.add(messageObject);
num4 = Integer.valueOf(num4.intValue() - 1);
}
} else {
num = num2;
}
i3++;
num2 = num;
}
Integer num5 = num2;
if (num4.intValue() <= 0) {
this.smartNotificationsDialogs.remove(j);
num4 = num5;
}
if (!num4.equals(num3)) {
if (getMessagesController().isForum(j)) {
int i4 = this.total_unread_count - (num3.intValue() > 0 ? 1 : 0);
this.total_unread_count = i4;
this.total_unread_count = i4 + (num4.intValue() <= 0 ? 0 : 1);
} else {
int intValue = this.total_unread_count - num3.intValue();
this.total_unread_count = intValue;
this.total_unread_count = intValue + num4.intValue();
}
this.pushDialogs.put(j, num4);
}
if (num4.intValue() == 0) {
this.pushDialogs.remove(j);
this.pushDialogsOverrideMention.remove(j);
}
i2++;
num2 = num5;
}
if (arrayList.isEmpty()) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$removeDeletedHisoryFromNotifications$10(arrayList);
}
});
}
if (i != this.total_unread_count) {
if (!this.notifyCheck) {
this.delayedPushMessages.clear();
showOrUpdateNotification(this.notifyCheck);
} else {
scheduleNotificationDelay(this.lastOnlineFromOtherDevice > getConnectionsManager().getCurrentTime());
}
final int size = this.pushDialogs.size();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$removeDeletedHisoryFromNotifications$11(size);
}
});
}
this.notifyCheck = false;
if (this.showBadgeNumber) {
setBadge(getTotalAllUnreadCount());
}
}
public void lambda$removeDeletedHisoryFromNotifications$10(ArrayList arrayList) {
int size = arrayList.size();
for (int i = 0; i < size; i++) {
this.popupMessages.remove(arrayList.get(i));
}
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.pushMessagesUpdated, new Object[0]);
}
public void lambda$removeDeletedHisoryFromNotifications$11(int i) {
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.notificationsCountUpdated, Integer.valueOf(((BaseController) this).currentAccount));
getNotificationCenter().lambda$postNotificationNameOnUIThread$1(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(i));
}
public void processSeenStoryReactions(long dialogId, final int storyId) {
if (dialogId != getUserConfig().getClientUserId()) {
return;
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processSeenStoryReactions$13(storyId);
}
});
}
public void lambda$processSeenStoryReactions$13(int i) {
int i2 = 0;
boolean z = false;
while (i2 < this.pushMessages.size()) {
MessageObject messageObject = this.pushMessages.get(i2);
if (messageObject.isStoryReactionPush && Math.abs(messageObject.getId()) == i) {
this.pushMessages.remove(i2);
SparseArray sparseArray = (SparseArray) this.pushMessagesDict.get(messageObject.getDialogId());
if (sparseArray != null) {
sparseArray.remove(messageObject.getId());
}
if (sparseArray != null && sparseArray.size() <= 0) {
this.pushMessagesDict.remove(messageObject.getDialogId());
}
ArrayList<Integer> arrayList = new ArrayList<>();
arrayList.add(Integer.valueOf(messageObject.getId()));
getMessagesStorage().deletePushMessages(messageObject.getDialogId(), arrayList);
i2--;
z = true;
}
i2++;
}
if (z) {
showOrUpdateNotification(false);
}
}
public void processDeleteStory(final long dialogId, final int storyId) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processDeleteStory$14(dialogId, storyId);
}
});
}
public void lambda$processDeleteStory$14(long r4, int r6) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.lambda$processDeleteStory$14(long, int):void");
}
public void processReadStories(final long dialogId, int maxId) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processReadStories$15(dialogId);
}
});
}
public void lambda$processReadStories$15(long j) {
boolean z;
StoryNotification storyNotification = (StoryNotification) this.storyPushMessagesDict.get(j);
if (storyNotification != null) {
this.storyPushMessagesDict.remove(j);
this.storyPushMessages.remove(storyNotification);
z = true;
getMessagesStorage().deleteStoryPushMessage(j);
} else {
z = false;
}
if (z) {
showOrUpdateNotification(false);
updateStoryPushesRunnable();
}
}
public void processIgnoreStories() {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processIgnoreStories$16();
}
});
}
public void lambda$processIgnoreStories$16() {
boolean z = !this.storyPushMessages.isEmpty();
this.storyPushMessages.clear();
this.storyPushMessagesDict.clear();
getMessagesStorage().deleteAllStoryPushMessages();
if (z) {
showOrUpdateNotification(false);
}
}
public void processIgnoreStoryReactions() {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processIgnoreStoryReactions$17();
}
});
}
public void lambda$processIgnoreStoryReactions$17() {
int i = 0;
boolean z = false;
while (i < this.pushMessages.size()) {
MessageObject messageObject = this.pushMessages.get(i);
if (messageObject != null && messageObject.isStoryReactionPush) {
this.pushMessages.remove(i);
i--;
SparseArray sparseArray = (SparseArray) this.pushMessagesDict.get(messageObject.getDialogId());
if (sparseArray != null) {
sparseArray.remove(messageObject.getId());
}
if (sparseArray != null && sparseArray.size() <= 0) {
this.pushMessagesDict.remove(messageObject.getDialogId());
}
z = true;
}
i++;
}
getMessagesStorage().deleteAllStoryReactionPushMessages();
if (z) {
showOrUpdateNotification(false);
}
}
public void processIgnoreStories(final long dialogId) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processIgnoreStories$18(dialogId);
}
});
}
public void lambda$processIgnoreStories$18(long j) {
boolean z = !this.storyPushMessages.isEmpty();
this.storyPushMessages.clear();
this.storyPushMessagesDict.clear();
getMessagesStorage().deleteStoryPushMessage(j);
if (z) {
showOrUpdateNotification(false);
}
}
public void processReadMessages(final LongSparseIntArray inbox, final long dialogId, final int maxDate, final int maxId, final boolean isPopup) {
final ArrayList arrayList = new ArrayList(0);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processReadMessages$20(inbox, arrayList, dialogId, maxId, maxDate, isPopup);
}
});
}
public void lambda$processReadMessages$20(org.telegram.messenger.support.LongSparseIntArray r19, final java.util.ArrayList r20, long r21, int r23, int r24, boolean r25) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.lambda$processReadMessages$20(org.telegram.messenger.support.LongSparseIntArray, java.util.ArrayList, long, int, int, boolean):void");
}
public void lambda$processReadMessages$19(ArrayList arrayList) {
int size = arrayList.size();
for (int i = 0; i < size; i++) {
this.popupMessages.remove(arrayList.get(i));
}
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.pushMessagesUpdated, new Object[0]);
}
private int addToPopupMessages(java.util.ArrayList<org.telegram.messenger.MessageObject> r4, org.telegram.messenger.MessageObject r5, long r6, boolean r8, android.content.SharedPreferences r9) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.addToPopupMessages(java.util.ArrayList, org.telegram.messenger.MessageObject, long, boolean, android.content.SharedPreferences):int");
}
public void processEditedMessages(final LongSparseArray<ArrayList<MessageObject>> editedMessages) {
if (editedMessages.size() == 0) {
return;
}
new ArrayList(0);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processEditedMessages$21(editedMessages);
}
});
}
public void lambda$processEditedMessages$21(LongSparseArray longSparseArray) {
int size = longSparseArray.size();
boolean z = false;
for (int i = 0; i < size; i++) {
longSparseArray.keyAt(i);
ArrayList arrayList = (ArrayList) longSparseArray.valueAt(i);
int size2 = arrayList.size();
for (int i2 = 0; i2 < size2; i2++) {
MessageObject messageObject = (MessageObject) arrayList.get(i2);
long j = 0;
if (messageObject.isStoryReactionPush) {
j = messageObject.getDialogId();
} else {
long j2 = messageObject.messageOwner.peer_id.channel_id;
if (j2 != 0) {
j = -j2;
}
}
SparseArray sparseArray = (SparseArray) this.pushMessagesDict.get(j);
if (sparseArray == null) {
break;
}
MessageObject messageObject2 = (MessageObject) sparseArray.get(messageObject.getId());
if (messageObject2 != null && (messageObject2.isReactionPush || messageObject2.isStoryReactionPush)) {
messageObject2 = null;
}
if (messageObject2 != null) {
sparseArray.put(messageObject.getId(), messageObject);
int indexOf = this.pushMessages.indexOf(messageObject2);
if (indexOf >= 0) {
this.pushMessages.set(indexOf, messageObject);
}
int indexOf2 = this.delayedPushMessages.indexOf(messageObject2);
if (indexOf2 >= 0) {
this.delayedPushMessages.set(indexOf2, messageObject);
}
z = true;
}
}
}
if (z) {
showOrUpdateNotification(false);
}
}
public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast, final boolean isFcm, final CountDownLatch countDownLatch) {
if (!messageObjects.isEmpty()) {
final ArrayList arrayList = new ArrayList(0);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processNewMessages$25(messageObjects, arrayList, isFcm, isLast, countDownLatch);
}
});
} else if (countDownLatch != null) {
countDownLatch.countDown();
}
}
public void lambda$processNewMessages$25(java.util.ArrayList r44, final java.util.ArrayList r45, boolean r46, boolean r47, java.util.concurrent.CountDownLatch r48) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.lambda$processNewMessages$25(java.util.ArrayList, java.util.ArrayList, boolean, boolean, java.util.concurrent.CountDownLatch):void");
}
public static long lambda$processNewMessages$22(StoryNotification storyNotification) {
if (storyNotification == null) {
return 0L;
}
return storyNotification.date;
}
public void lambda$processNewMessages$23(ArrayList arrayList, int i) {
this.popupMessages.addAll(0, arrayList);
if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) {
if (i == 3 || ((i == 1 && ApplicationLoader.isScreenOn) || (i == 2 && !ApplicationLoader.isScreenOn))) {
Intent intent = new Intent(ApplicationLoader.applicationContext, (Class<?>) PopupNotificationActivity.class);
intent.setFlags(268763140);
try {
ApplicationLoader.applicationContext.startActivity(intent);
} catch (Throwable unused) {
}
}
}
}
public void lambda$processNewMessages$24(int i) {
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.notificationsCountUpdated, Integer.valueOf(((BaseController) this).currentAccount));
getNotificationCenter().lambda$postNotificationNameOnUIThread$1(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(i));
}
private void appendMessage(MessageObject messageObject) {
for (int i = 0; i < this.pushMessages.size(); i++) {
if (this.pushMessages.get(i).getId() == messageObject.getId() && this.pushMessages.get(i).getDialogId() == messageObject.getDialogId() && this.pushMessages.get(i).isStoryPush == messageObject.isStoryPush) {
return;
}
}
this.pushMessages.add(0, messageObject);
}
public int getTotalUnreadCount() {
return this.total_unread_count;
}
public int getAccountUnreadCount(int account) {
return this.totalCount[account];
}
public void processDialogsUpdateRead(final LongSparseIntArray dialogsToUpdate) {
final ArrayList arrayList = new ArrayList();
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processDialogsUpdateRead$28(dialogsToUpdate, arrayList);
}
});
}
public void lambda$processDialogsUpdateRead$28(org.telegram.messenger.support.LongSparseIntArray r21, final java.util.ArrayList r22) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.lambda$processDialogsUpdateRead$28(org.telegram.messenger.support.LongSparseIntArray, java.util.ArrayList):void");
}
public void lambda$processDialogsUpdateRead$26(ArrayList arrayList) {
int size = arrayList.size();
for (int i = 0; i < size; i++) {
this.popupMessages.remove(arrayList.get(i));
}
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.pushMessagesUpdated, new Object[0]);
}
public void lambda$processDialogsUpdateRead$27(int i) {
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.notificationsCountUpdated, Integer.valueOf(((BaseController) this).currentAccount));
getNotificationCenter().lambda$postNotificationNameOnUIThread$1(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(i));
}
public void processLoadedUnreadMessages(final LongSparseArray<Integer> dialogs, final ArrayList<TLRPC.Message> messages, final ArrayList<MessageObject> push, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<TLRPC.EncryptedChat> encryptedChats, final Collection<StoryNotification> storyPushes) {
getMessagesController().putUsers(users, true);
getMessagesController().putChats(chats, true);
getMessagesController().putEncryptedChats(encryptedChats, true);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processLoadedUnreadMessages$31(messages, dialogs, push, storyPushes);
}
});
}
public void lambda$processLoadedUnreadMessages$31(ArrayList arrayList, LongSparseArray longSparseArray, ArrayList arrayList2, Collection collection) {
long j;
long j2;
long j3;
boolean z;
long j4;
boolean z2;
TLRPC.MessageFwdHeader messageFwdHeader;
SharedPreferences sharedPreferences;
MessageObject messageObject;
long j5;
SparseArray sparseArray;
TLRPC.Message message;
int i;
boolean z3;
TLRPC.Message message2;
SparseArray sparseArray2;
ArrayList arrayList3 = arrayList;
this.pushDialogs.clear();
this.pushMessages.clear();
this.pushMessagesDict.clear();
this.storyPushMessages.clear();
this.storyPushMessagesDict.clear();
boolean z4 = false;
this.total_unread_count = 0;
this.personalCount = 0;
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
LongSparseArray longSparseArray2 = new LongSparseArray();
if (arrayList3 != null) {
int i2 = 0;
while (i2 < arrayList.size()) {
TLRPC.Message message3 = (TLRPC.Message) arrayList3.get(i2);
if (message3 != null && ((messageFwdHeader = message3.fwd_from) == null || !messageFwdHeader.imported)) {
TLRPC.MessageAction messageAction = message3.action;
if (!(messageAction instanceof TLRPC.TL_messageActionSetMessagesTTL) && (!message3.silent || (!(messageAction instanceof TLRPC.TL_messageActionContactSignUp) && !(messageAction instanceof TLRPC.TL_messageActionUserJoined)))) {
long j6 = message3.peer_id.channel_id;
long j7 = j6 != 0 ? -j6 : 0L;
SparseArray sparseArray3 = (SparseArray) this.pushMessagesDict.get(j7);
if (sparseArray3 == null || sparseArray3.indexOfKey(message3.id) < 0) {
MessageObject messageObject2 = new MessageObject(((BaseController) this).currentAccount, message3, z4, z4);
if (isPersonalMessage(messageObject2)) {
this.personalCount++;
}
sharedPreferences = notificationsSettings;
long dialogId = messageObject2.getDialogId();
long topicId = MessageObject.getTopicId(((BaseController) this).currentAccount, messageObject2.messageOwner, getMessagesController().isForum(messageObject2));
long fromChatId = messageObject2.messageOwner.mentioned ? messageObject2.getFromChatId() : dialogId;
int indexOfKey = longSparseArray2.indexOfKey(fromChatId);
if (indexOfKey >= 0 && topicId == 0) {
z3 = ((Boolean) longSparseArray2.valueAt(indexOfKey)).booleanValue();
messageObject = messageObject2;
j5 = j7;
message = message3;
sparseArray = sparseArray3;
i = i2;
} else {
messageObject = messageObject2;
j5 = j7;
sparseArray = sparseArray3;
message = message3;
i = i2;
int notifyOverride = getNotifyOverride(sharedPreferences, fromChatId, topicId, dialogId);
if (notifyOverride == -1) {
z3 = isGlobalNotificationsEnabled(fromChatId, messageObject.isReactionPush, messageObject.isStoryReactionPush);
} else {
z3 = notifyOverride != 2;
}
longSparseArray2.put(fromChatId, Boolean.valueOf(z3));
}
if (z3 && (fromChatId != this.openedDialogId || !ApplicationLoader.isScreenOn)) {
if (sparseArray == null) {
sparseArray2 = new SparseArray();
this.pushMessagesDict.put(j5, sparseArray2);
message2 = message;
} else {
message2 = message;
sparseArray2 = sparseArray;
}
sparseArray2.put(message2.id, messageObject);
appendMessage(messageObject);
if (dialogId != fromChatId) {
Integer num = (Integer) this.pushDialogsOverrideMention.get(dialogId);
this.pushDialogsOverrideMention.put(dialogId, Integer.valueOf(num == null ? 1 : num.intValue() + 1));
}
}
i2 = i + 1;
arrayList3 = arrayList;
notificationsSettings = sharedPreferences;
z4 = false;
}
}
}
i = i2;
sharedPreferences = notificationsSettings;
i2 = i + 1;
arrayList3 = arrayList;
notificationsSettings = sharedPreferences;
z4 = false;
}
}
SharedPreferences sharedPreferences2 = notificationsSettings;
for (int i3 = 0; i3 < longSparseArray.size(); i3++) {
long keyAt = longSparseArray.keyAt(i3);
int indexOfKey2 = longSparseArray2.indexOfKey(keyAt);
if (indexOfKey2 >= 0) {
z2 = ((Boolean) longSparseArray2.valueAt(indexOfKey2)).booleanValue();
} else {
int notifyOverride2 = getNotifyOverride(sharedPreferences2, keyAt, 0L, keyAt);
if (notifyOverride2 == -1) {
z2 = isGlobalNotificationsEnabled(keyAt, false, false);
} else {
z2 = notifyOverride2 != 2;
}
longSparseArray2.put(keyAt, Boolean.valueOf(z2));
}
if (z2) {
int intValue = ((Integer) longSparseArray.valueAt(i3)).intValue();
this.pushDialogs.put(keyAt, Integer.valueOf(intValue));
if (getMessagesController().isForum(keyAt)) {
this.total_unread_count += intValue > 0 ? 1 : 0;
} else {
this.total_unread_count += intValue;
}
}
}
if (arrayList2 != null) {
for (int i4 = 0; i4 < arrayList2.size(); i4++) {
MessageObject messageObject3 = (MessageObject) arrayList2.get(i4);
int id = messageObject3.getId();
if (this.pushMessagesDict.indexOfKey(id) < 0) {
if (isPersonalMessage(messageObject3)) {
this.personalCount++;
}
long dialogId2 = messageObject3.getDialogId();
long topicId2 = MessageObject.getTopicId(((BaseController) this).currentAccount, messageObject3.messageOwner, getMessagesController().isForum(messageObject3));
TLRPC.Message message4 = messageObject3.messageOwner;
long j8 = message4.random_id;
long fromChatId2 = message4.mentioned ? messageObject3.getFromChatId() : dialogId2;
int indexOfKey3 = longSparseArray2.indexOfKey(fromChatId2);
if (indexOfKey3 >= 0 && topicId2 == 0) {
z = ((Boolean) longSparseArray2.valueAt(indexOfKey3)).booleanValue();
j = j8;
j2 = dialogId2;
j3 = fromChatId2;
} else {
long j9 = fromChatId2;
j = j8;
j2 = dialogId2;
int notifyOverride3 = getNotifyOverride(sharedPreferences2, j9, topicId2, dialogId2);
if (notifyOverride3 == -1) {
j3 = j9;
z = isGlobalNotificationsEnabled(j3, messageObject3.isReactionPush, messageObject3.isStoryReactionPush);
} else {
j3 = j9;
z = notifyOverride3 != 2;
}
longSparseArray2.put(j3, Boolean.valueOf(z));
}
if (z && (j3 != this.openedDialogId || !ApplicationLoader.isScreenOn)) {
if (id != 0) {
if (messageObject3.isStoryReactionPush) {
j4 = messageObject3.getDialogId();
} else {
long j10 = messageObject3.messageOwner.peer_id.channel_id;
j4 = j10 != 0 ? -j10 : 0L;
}
SparseArray sparseArray4 = (SparseArray) this.pushMessagesDict.get(j4);
if (sparseArray4 == null) {
sparseArray4 = new SparseArray();
this.pushMessagesDict.put(j4, sparseArray4);
}
sparseArray4.put(id, messageObject3);
} else {
long j11 = j;
if (j11 != 0) {
this.fcmRandomMessagesDict.put(j11, messageObject3);
}
}
appendMessage(messageObject3);
long j12 = j2;
if (j12 != j3) {
Integer num2 = (Integer) this.pushDialogsOverrideMention.get(j12);
this.pushDialogsOverrideMention.put(j12, Integer.valueOf(num2 == null ? 1 : num2.intValue() + 1));
}
Integer num3 = (Integer) this.pushDialogs.get(j3);
int intValue2 = num3 != null ? num3.intValue() + 1 : 1;
if (getMessagesController().isForum(j3)) {
if (num3 != null) {
this.total_unread_count -= num3.intValue() > 0 ? 1 : 0;
}
this.total_unread_count += intValue2 > 0 ? 1 : 0;
} else {
if (num3 != null) {
this.total_unread_count -= num3.intValue();
}
this.total_unread_count += intValue2;
}
this.pushDialogs.put(j3, Integer.valueOf(intValue2));
}
}
}
}
if (collection != null) {
Iterator it = collection.iterator();
while (it.hasNext()) {
StoryNotification storyNotification = (StoryNotification) it.next();
long j13 = storyNotification.dialogId;
StoryNotification storyNotification2 = (StoryNotification) this.storyPushMessagesDict.get(j13);
if (storyNotification2 != null) {
storyNotification2.dateByIds.putAll(storyNotification.dateByIds);
} else {
this.storyPushMessages.add(storyNotification);
this.storyPushMessagesDict.put(j13, storyNotification);
}
}
Collections.sort(this.storyPushMessages, Comparator.-CC.comparingLong(new ToLongFunction() {
public final long applyAsLong(Object obj) {
long j14;
j14 = ((NotificationsController.StoryNotification) obj).date;
return j14;
}
}));
}
final int size = this.pushDialogs.size();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processLoadedUnreadMessages$30(size);
}
});
showOrUpdateNotification(SystemClock.elapsedRealtime() / 1000 < 60);
if (this.showBadgeNumber) {
setBadge(getTotalAllUnreadCount());
}
}
public void lambda$processLoadedUnreadMessages$30(int i) {
if (this.total_unread_count == 0) {
this.popupMessages.clear();
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.pushMessagesUpdated, new Object[0]);
}
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.notificationsCountUpdated, Integer.valueOf(((BaseController) this).currentAccount));
getNotificationCenter().lambda$postNotificationNameOnUIThread$1(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(i));
}
private int getTotalAllUnreadCount() {
int size;
int i = 0;
for (int i2 = 0; i2 < UserConfig.MAX_ACCOUNT_COUNT; i2++) {
if (UserConfig.getInstance(i2).isClientActivated()) {
this.totalCount[i2] = i > 0 ? -i : 0;
NotificationsController notificationsController = getInstance(i2);
if (notificationsController.showBadgeNumber) {
if (notificationsController.showBadgeMessages) {
if (notificationsController.showBadgeMuted) {
try {
ArrayList arrayList = new ArrayList(MessagesController.getInstance(i2).allDialogs);
int size2 = arrayList.size();
for (int i3 = 0; i3 < size2; i3++) {
TLRPC.Dialog dialog = (TLRPC.Dialog) arrayList.get(i3);
if ((dialog == null || !DialogObject.isChatDialog(dialog.id) || !ChatObject.isNotInChat(getMessagesController().getChat(Long.valueOf(-dialog.id)))) && dialog != null) {
i += MessagesController.getInstance(i2).getDialogUnreadCount(dialog);
}
}
} catch (Exception e) {
FileLog.e(e);
}
} else {
size = notificationsController.total_unread_count;
}
} else if (notificationsController.showBadgeMuted) {
try {
int size3 = MessagesController.getInstance(i2).allDialogs.size();
for (int i4 = 0; i4 < size3; i4++) {
TLRPC.Dialog dialog2 = (TLRPC.Dialog) MessagesController.getInstance(i2).allDialogs.get(i4);
if ((!DialogObject.isChatDialog(dialog2.id) || !ChatObject.isNotInChat(getMessagesController().getChat(Long.valueOf(-dialog2.id)))) && MessagesController.getInstance(i2).getDialogUnreadCount(dialog2) != 0) {
i++;
}
}
} catch (Exception e2) {
FileLog.e(e2, false);
}
} else {
size = notificationsController.pushDialogs.size();
}
i += size;
}
int[] iArr = this.totalCount;
iArr[i2] = iArr[i2] + i;
}
}
return i;
}
public void lambda$updateBadge$32() {
setBadge(getTotalAllUnreadCount());
}
public void updateBadge() {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$updateBadge$32();
}
});
}
private void setBadge(int count) {
if (this.lastBadgeCount == count) {
return;
}
this.lastBadgeCount = count;
NotificationBadge.applyCount(count);
}
private java.lang.String getShortStringForMessage(org.telegram.messenger.MessageObject r26, java.lang.String[] r27, boolean[] r28) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.getShortStringForMessage(org.telegram.messenger.MessageObject, java.lang.String[], boolean[]):java.lang.String");
}
private String replaceSpoilers(MessageObject messageObject) {
TLRPC.Message message;
String str;
if (messageObject == null || (message = messageObject.messageOwner) == null || (str = message.message) == null || message.entities == null) {
return null;
}
StringBuilder sb = new StringBuilder(str);
for (int i = 0; i < messageObject.messageOwner.entities.size(); i++) {
if (messageObject.messageOwner.entities.get(i) instanceof TLRPC.TL_messageEntitySpoiler) {
TLRPC.TL_messageEntitySpoiler tL_messageEntitySpoiler = (TLRPC.TL_messageEntitySpoiler) messageObject.messageOwner.entities.get(i);
for (int i2 = 0; i2 < tL_messageEntitySpoiler.length; i2++) {
int i3 = tL_messageEntitySpoiler.offset + i2;
char[] cArr = this.spoilerChars;
sb.setCharAt(i3, cArr[i2 % cArr.length]);
}
}
}
return sb.toString();
}
private java.lang.String getStringForMessage(org.telegram.messenger.MessageObject r29, boolean r30, boolean[] r31, boolean[] r32) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.getStringForMessage(org.telegram.messenger.MessageObject, boolean, boolean[], boolean[]):java.lang.String");
}
private void scheduleNotificationRepeat() {
try {
Intent intent = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationRepeat.class);
intent.putExtra("currentAccount", ((BaseController) this).currentAccount);
PendingIntent service = PendingIntent.getService(ApplicationLoader.applicationContext, 0, intent, 33554432);
if (getAccountInstance().getNotificationsSettings().getInt("repeat_messages", 60) > 0 && this.personalCount > 0) {
this.alarmManager.set(2, SystemClock.elapsedRealtime() + (r1 * 60 * 1000), service);
} else {
this.alarmManager.cancel(service);
}
} catch (Exception e) {
FileLog.e(e);
}
}
private boolean isPersonalMessage(MessageObject messageObject) {
TLRPC.MessageAction messageAction;
TLRPC.Message message = messageObject.messageOwner;
TLRPC.Peer peer = message.peer_id;
return (peer != null && peer.chat_id == 0 && peer.channel_id == 0 && ((messageAction = message.action) == null || (messageAction instanceof TLRPC.TL_messageActionEmpty))) || messageObject.isStoryReactionPush;
}
private int getNotifyOverride(SharedPreferences preferences, long dialog_id, long topicId, long original_id) {
if (AndroidUtilities.playingAGame) {
return 2;
}
if (!PlusSettings.showHiddenDialogsNotifications) {
ArrayList arrayList = getMessagesController().hiddenDialogs;
if (PlusSettings.showHiddenDialogsMentionsNotifications) {
original_id = dialog_id;
}
if (arrayList.contains(Long.valueOf(original_id))) {
return 2;
}
}
int property = this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_NOTIFY, dialog_id, topicId, -1);
if (property != 3 || this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_NOTIFY_UNTIL, dialog_id, topicId, 0) < getConnectionsManager().getCurrentTime()) {
return property;
}
return 2;
}
public void lambda$showNotifications$33() {
showOrUpdateNotification(false);
}
public void showNotifications() {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$showNotifications$33();
}
});
}
public void hideNotifications() {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$hideNotifications$34();
}
});
}
public void lambda$hideNotifications$34() {
notificationManager.cancel(this.notificationId);
this.lastWearNotifiedMessageId.clear();
for (int i = 0; i < this.wearNotificationsIds.size(); i++) {
notificationManager.cancel(((Integer) this.wearNotificationsIds.valueAt(i)).intValue());
}
this.wearNotificationsIds.clear();
}
private void dismissNotification() {
try {
notificationManager.cancel(this.notificationId);
this.pushMessages.clear();
this.pushMessagesDict.clear();
this.lastWearNotifiedMessageId.clear();
for (int i = 0; i < this.wearNotificationsIds.size(); i++) {
if (!this.openedInBubbleDialogs.contains(Long.valueOf(this.wearNotificationsIds.keyAt(i)))) {
notificationManager.cancel(((Integer) this.wearNotificationsIds.valueAt(i)).intValue());
}
}
this.wearNotificationsIds.clear();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.lambda$dismissNotification$35();
}
});
} catch (Exception e) {
FileLog.e(e);
}
}
public static void lambda$dismissNotification$35() {
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.pushMessagesUpdated, new Object[0]);
}
private void playInChatSound() {
if (!this.inChatSoundEnabled || MediaController.getInstance().isRecordingAudio()) {
return;
}
try {
if (audioManager.getRingerMode() == 0) {
return;
}
} catch (Exception e) {
FileLog.e(e);
}
try {
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
long j = this.openedDialogId;
if (getNotifyOverride(notificationsSettings, j, this.openedTopicId, j) == 2) {
return;
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$playInChatSound$37();
}
});
} catch (Exception e2) {
FileLog.e(e2);
}
}
public void lambda$playInChatSound$37() {
if (Math.abs(SystemClock.elapsedRealtime() - this.lastSoundPlay) <= 500) {
return;
}
try {
if (this.soundPool == null) {
SoundPool soundPool = new SoundPool(3, 1, 0);
this.soundPool = soundPool;
soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
@Override
public final void onLoadComplete(SoundPool soundPool2, int i, int i2) {
NotificationsController.lambda$playInChatSound$36(soundPool2, i, i2);
}
});
}
if (this.soundIn == 0 && !this.soundInLoaded) {
this.soundInLoaded = true;
this.soundIn = this.soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_in, 1);
}
int i = this.soundIn;
if (i != 0) {
try {
this.soundPool.play(i, 1.0f, 1.0f, 1, 0, 1.0f);
} catch (Exception e) {
FileLog.e(e);
}
}
} catch (Exception e2) {
FileLog.e(e2);
}
}
public static void lambda$playInChatSound$36(SoundPool soundPool, int i, int i2) {
if (i2 == 0) {
try {
soundPool.play(i, 1.0f, 1.0f, 1, 0, 1.0f);
} catch (Exception e) {
FileLog.e(e);
}
}
}
private void scheduleNotificationDelay(boolean onlineReason) {
try {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("delay notification start, onlineReason = " + onlineReason);
}
this.notificationDelayWakelock.acquire(10000L);
DispatchQueue dispatchQueue = notificationsQueue;
dispatchQueue.cancelRunnable(this.notificationDelayRunnable);
dispatchQueue.postRunnable(this.notificationDelayRunnable, onlineReason ? 3000 : 1000);
} catch (Exception e) {
FileLog.e(e);
showOrUpdateNotification(this.notifyCheck);
}
}
public void repeatNotificationMaybe() {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$repeatNotificationMaybe$38();
}
});
}
public void lambda$repeatNotificationMaybe$38() {
int i = Calendar.getInstance().get(11);
if (i >= 11 && i <= 22) {
notificationManager.cancel(this.notificationId);
showOrUpdateNotification(true);
} else {
scheduleNotificationRepeat();
}
}
private boolean isEmptyVibration(long[] pattern) {
if (pattern == null || pattern.length == 0) {
return false;
}
for (long j : pattern) {
if (j != 0) {
return false;
}
}
return true;
}
public void deleteNotificationChannel(long dialogId, long topicId) {
deleteNotificationChannel(dialogId, topicId, -1);
}
public void lambda$deleteNotificationChannel$39(long dialogId, long topicId, int what) {
if (Build.VERSION.SDK_INT < 26) {
return;
}
try {
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
SharedPreferences.Editor edit = notificationsSettings.edit();
if (what == 0 || what == -1) {
String str = "org.telegram.key" + dialogId;
if (topicId != 0) {
str = str + ".topic" + topicId;
}
String string = notificationsSettings.getString(str, null);
if (string != null) {
edit.remove(str).remove(str + "_s");
try {
systemNotificationManager.deleteNotificationChannel(string);
} catch (Exception e) {
FileLog.e(e);
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("delete channel internal " + string);
}
}
}
if (what == 1 || what == -1) {
String str2 = "org.telegram.keyia" + dialogId;
String string2 = notificationsSettings.getString(str2, null);
if (string2 != null) {
edit.remove(str2).remove(str2 + "_s");
try {
systemNotificationManager.deleteNotificationChannel(string2);
} catch (Exception e2) {
FileLog.e(e2);
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("delete channel internal " + string2);
}
}
}
edit.commit();
} catch (Exception e3) {
FileLog.e(e3);
}
}
public void deleteNotificationChannel(final long dialogId, final long topicId, final int what) {
if (Build.VERSION.SDK_INT < 26) {
return;
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$deleteNotificationChannel$39(dialogId, topicId, what);
}
});
}
public void deleteNotificationChannelGlobal(int type) {
deleteNotificationChannelGlobal(type, -1);
}
public void lambda$deleteNotificationChannelGlobal$40(int type, int what) {
String str;
String str2;
String str3;
if (Build.VERSION.SDK_INT < 26) {
return;
}
try {
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
SharedPreferences.Editor edit = notificationsSettings.edit();
if (what == 0 || what == -1) {
if (type == 2) {
str = "channels";
} else if (type == 0) {
str = "groups";
} else if (type == 3) {
str = "stories";
} else {
if (type != 4 && type != 5) {
str = "private";
}
str = "reactions";
}
String string = notificationsSettings.getString(str, null);
if (string != null) {
edit.remove(str).remove(str + "_s");
try {
systemNotificationManager.deleteNotificationChannel(string);
} catch (Exception e) {
FileLog.e(e);
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("delete channel global internal " + string);
}
}
}
if (what == 1 || what == -1) {
if (type == 2) {
str2 = "channels_ia";
} else if (type == 0) {
str2 = "groups_ia";
} else if (type == 3) {
str2 = "stories_ia";
} else {
if (type != 4 && type != 5) {
str2 = "private_ia";
}
str2 = "reactions_ia";
}
String string2 = notificationsSettings.getString(str2, null);
if (string2 != null) {
edit.remove(str2).remove(str2 + "_s");
try {
systemNotificationManager.deleteNotificationChannel(string2);
} catch (Exception e2) {
FileLog.e(e2);
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("delete channel global internal " + string2);
}
}
}
if (type == 2) {
str3 = "overwrite_channel";
} else if (type == 0) {
str3 = "overwrite_group";
} else if (type == 3) {
str3 = "overwrite_stories";
} else {
if (type != 4 && type != 5) {
str3 = "overwrite_private";
}
str3 = "overwrite_reactions";
}
edit.remove(str3);
edit.commit();
} catch (Exception e3) {
FileLog.e(e3);
}
}
public void deleteNotificationChannelGlobal(final int type, final int what) {
if (Build.VERSION.SDK_INT < 26) {
return;
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$deleteNotificationChannelGlobal$40(type, what);
}
});
}
public void deleteAllNotificationChannels() {
if (Build.VERSION.SDK_INT < 26) {
return;
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$deleteAllNotificationChannels$41();
}
});
}
public void lambda$deleteAllNotificationChannels$41() {
try {
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
Map<String, ?> all = notificationsSettings.getAll();
SharedPreferences.Editor edit = notificationsSettings.edit();
for (Map.Entry<String, ?> entry : all.entrySet()) {
String key = entry.getKey();
if (key.startsWith("org.telegram.key")) {
if (!key.endsWith("_s")) {
String str = (String) entry.getValue();
systemNotificationManager.deleteNotificationChannel(str);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("delete all channel " + str);
}
}
edit.remove(key);
}
}
edit.commit();
} catch (Exception e) {
FileLog.e(e);
}
}
private boolean unsupportedNotificationShortcut() {
return Build.VERSION.SDK_INT < 29 || !SharedConfig.chatBubbles;
}
@android.annotation.SuppressLint({"RestrictedApi"})
private java.lang.String createNotificationShortcut(androidx.core.app.NotificationCompat.Builder r18, long r19, java.lang.String r21, org.telegram.tgnet.TLRPC.User r22, org.telegram.tgnet.TLRPC.Chat r23, androidx.core.app.Person r24, boolean r25) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.createNotificationShortcut(androidx.core.app.NotificationCompat$Builder, long, java.lang.String, org.telegram.tgnet.TLRPC$User, org.telegram.tgnet.TLRPC$Chat, androidx.core.app.Person, boolean):java.lang.String");
}
@TargetApi(26)
public void ensureGroupsCreated() {
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
if (this.groupsCreated == null) {
this.groupsCreated = Boolean.valueOf(notificationsSettings.getBoolean("groupsCreated5", false));
}
if (!this.groupsCreated.booleanValue()) {
try {
String str = ((BaseController) this).currentAccount + "channel";
List<NotificationChannel> notificationChannels = systemNotificationManager.getNotificationChannels();
int size = notificationChannels.size();
SharedPreferences.Editor editor = null;
for (int i = 0; i < size; i++) {
NotificationChannel notificationChannel = notificationChannels.get(i);
String id = notificationChannel.getId();
if (id.startsWith(str)) {
int importance = notificationChannel.getImportance();
if (importance != 4 && importance != 5 && !id.contains("_ia_")) {
if (id.contains("_channels_")) {
if (editor == null) {
editor = getAccountInstance().getNotificationsSettings().edit();
}
editor.remove("priority_channel").remove("vibrate_channel").remove("ChannelSoundPath").remove("ChannelSound");
} else if (id.contains("_reactions_")) {
if (editor == null) {
editor = getAccountInstance().getNotificationsSettings().edit();
}
editor.remove("priority_react").remove("vibrate_react").remove("ReactionSoundPath").remove("ReactionSound");
} else if (id.contains("_groups_")) {
if (editor == null) {
editor = getAccountInstance().getNotificationsSettings().edit();
}
editor.remove("priority_group").remove("vibrate_group").remove("GroupSoundPath").remove("GroupSound");
} else if (id.contains("_private_")) {
if (editor == null) {
editor = getAccountInstance().getNotificationsSettings().edit();
}
editor.remove("priority_messages");
editor.remove("priority_group").remove("vibrate_messages").remove("GlobalSoundPath").remove("GlobalSound");
} else {
long longValue = Utilities.parseLong(id.substring(9, id.indexOf(95, 9))).longValue();
if (longValue != 0) {
if (editor == null) {
editor = getAccountInstance().getNotificationsSettings().edit();
}
editor.remove("priority_" + longValue).remove("vibrate_" + longValue).remove("sound_path_" + longValue).remove("sound_" + longValue);
}
}
}
systemNotificationManager.deleteNotificationChannel(id);
}
}
if (editor != null) {
editor.commit();
}
} catch (Exception e) {
FileLog.e(e);
}
notificationsSettings.edit().putBoolean("groupsCreated5", true).commit();
this.groupsCreated = Boolean.TRUE;
}
if (this.channelGroupsCreated) {
return;
}
List<NotificationChannelGroup> notificationChannelGroups = systemNotificationManager.getNotificationChannelGroups();
String str2 = "channels" + ((BaseController) this).currentAccount;
String str3 = "groups" + ((BaseController) this).currentAccount;
String str4 = "private" + ((BaseController) this).currentAccount;
String str5 = "stories" + ((BaseController) this).currentAccount;
String str6 = "reactions" + ((BaseController) this).currentAccount;
String str7 = "other" + ((BaseController) this).currentAccount;
int size2 = notificationChannelGroups.size();
String str8 = str7;
String str9 = str6;
String str10 = str5;
String str11 = str4;
for (int i2 = 0; i2 < size2; i2++) {
String id2 = notificationChannelGroups.get(i2).getId();
if (str2 != null && str2.equals(id2)) {
str2 = null;
} else if (str3 != null && str3.equals(id2)) {
str3 = null;
} else if (str10 != null && str10.equals(id2)) {
str10 = null;
} else if (str9 != null && str9.equals(id2)) {
str9 = null;
} else if (str11 != null && str11.equals(id2)) {
str11 = null;
} else if (str8 != null && str8.equals(id2)) {
str8 = null;
}
if (str2 == null && str10 == null && str9 == null && str3 == null && str11 == null && str8 == null) {
break;
}
}
if (str2 != null || str3 != null || str9 != null || str10 != null || str11 != null || str8 != null) {
TLRPC.User user = getMessagesController().getUser(Long.valueOf(getUserConfig().getClientUserId()));
if (user == null) {
getUserConfig().getCurrentUser();
}
String str12 = user != null ? " (" + ContactsController.formatName(user.first_name, user.last_name) + ")" : BuildConfig.APP_CENTER_HASH;
ArrayList arrayList = new ArrayList();
if (str2 != null) {
arrayList.add(new NotificationChannelGroup(str2, LocaleController.getString("NotificationsChannels", R.string.NotificationsChannels) + str12));
}
if (str3 != null) {
arrayList.add(new NotificationChannelGroup(str3, LocaleController.getString("NotificationsGroups", R.string.NotificationsGroups) + str12));
}
if (str10 != null) {
arrayList.add(new NotificationChannelGroup(str10, LocaleController.getString(R.string.NotificationsStories) + str12));
}
if (str9 != null) {
arrayList.add(new NotificationChannelGroup(str9, LocaleController.getString(R.string.NotificationsReactions) + str12));
}
if (str11 != null) {
arrayList.add(new NotificationChannelGroup(str11, LocaleController.getString("NotificationsPrivateChats", R.string.NotificationsPrivateChats) + str12));
}
if (str8 != null) {
arrayList.add(new NotificationChannelGroup(str8, LocaleController.getString("NotificationsOther", R.string.NotificationsOther) + str12));
}
systemNotificationManager.createNotificationChannelGroups(arrayList);
}
this.channelGroupsCreated = true;
}
@android.annotation.TargetApi(26)
private java.lang.String validateChannelId(long r31, long r33, java.lang.String r35, long[] r36, int r37, android.net.Uri r38, int r39, boolean r40, boolean r41, boolean r42, int r43) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.validateChannelId(long, long, java.lang.String, long[], int, android.net.Uri, int, boolean, boolean, boolean, int):java.lang.String");
}
private void showOrUpdateNotification(boolean r56) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.showOrUpdateNotification(boolean):void");
}
private boolean isSilentMessage(MessageObject messageObject) {
return messageObject.messageOwner.silent || messageObject.isReactionPush;
}
@SuppressLint({"NewApi"})
private void setNotificationChannel(Notification mainNotification, NotificationCompat.Builder builder, boolean useSummaryNotification) {
if (useSummaryNotification) {
builder.setChannelId(OTHER_NOTIFICATIONS_CHANNEL);
} else {
builder.setChannelId(mainNotification.getChannelId());
}
}
public void resetNotificationSound(NotificationCompat.Builder notificationBuilder, long dialogId, long topicId, String chatName, long[] vibrationPattern, int ledColor, Uri sound, int importance, boolean isDefault, boolean isInApp, boolean isSilent, int chatType) {
Uri uri = Settings.System.DEFAULT_RINGTONE_URI;
if (uri == null || sound == null || TextUtils.equals(uri.toString(), sound.toString())) {
return;
}
SharedPreferences.Editor edit = getAccountInstance().getNotificationsSettings().edit();
String uri2 = uri.toString();
String string = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone);
if (isDefault) {
if (chatType == 2) {
edit.putString("ChannelSound", string);
} else if (chatType == 0) {
edit.putString("GroupSound", string);
} else if (chatType == 1) {
edit.putString("GlobalSound", string);
} else if (chatType == 3) {
edit.putString("StoriesSound", string);
} else if (chatType == 4 || chatType == 5) {
edit.putString("ReactionSound", string);
}
if (chatType == 2) {
edit.putString("ChannelSoundPath", uri2);
} else if (chatType == 0) {
edit.putString("GroupSoundPath", uri2);
} else if (chatType == 1) {
edit.putString("GlobalSoundPath", uri2);
} else if (chatType == 3) {
edit.putString("StoriesSoundPath", uri2);
} else if (chatType == 4 || chatType == 5) {
edit.putString("ReactionSound", uri2);
}
getNotificationsController().lambda$deleteNotificationChannelGlobal$40(chatType, -1);
} else {
edit.putString("sound_" + getSharedPrefKey(dialogId, topicId), string);
edit.putString("sound_path_" + getSharedPrefKey(dialogId, topicId), uri2);
lambda$deleteNotificationChannel$39(dialogId, topicId, -1);
}
edit.commit();
notificationBuilder.setChannelId(validateChannelId(dialogId, topicId, chatName, vibrationPattern, ledColor, Settings.System.DEFAULT_RINGTONE_URI, importance, isDefault, isInApp, isSilent, chatType));
notificationManager.notify(this.notificationId, notificationBuilder.build());
}
@android.annotation.SuppressLint({"InlinedApi"})
private void showExtraNotifications(androidx.core.app.NotificationCompat.Builder r82, java.lang.String r83, long r84, long r86, java.lang.String r88, long[] r89, int r90, android.net.Uri r91, int r92, boolean r93, boolean r94, boolean r95, int r96, android.app.Notification r97) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.showExtraNotifications(androidx.core.app.NotificationCompat$Builder, java.lang.String, long, long, java.lang.String, long[], int, android.net.Uri, int, boolean, boolean, boolean, int, android.app.Notification):void");
}
public class C1NotificationHolder {
public TLRPC.Chat chat;
public long dialogId;
public int id;
public String name;
public NotificationCompat.Builder notification;
public boolean story;
public long topicId;
public TLRPC.User user;
public final String val$chatName;
public final int val$chatType;
public final int val$importance;
public final boolean val$isDefault;
public final boolean val$isInApp;
public final boolean val$isSilent;
public final long val$lastTopicId;
public final int val$ledColor;
public final Uri val$sound;
public final long[] val$vibrationPattern;
public C1NotificationHolder(int i, long li, boolean story, long topicId, String n, TLRPC.User u, TLRPC.Chat c, NotificationCompat.Builder builder, final long val$lastTopicId, final String val$chatName, final long[] val$vibrationPattern, final int val$ledColor, final Uri val$sound, final int val$importance, final boolean val$isDefault, final boolean val$isInApp, final boolean val$isSilent, final int val$chatType) {
this.val$lastTopicId = val$lastTopicId;
this.val$chatName = val$chatName;
this.val$vibrationPattern = val$vibrationPattern;
this.val$ledColor = val$ledColor;
this.val$sound = val$sound;
this.val$importance = val$importance;
this.val$isDefault = val$isDefault;
this.val$isInApp = val$isInApp;
this.val$isSilent = val$isSilent;
this.val$chatType = val$chatType;
this.id = i;
this.name = n;
this.user = u;
this.chat = c;
this.notification = builder;
this.dialogId = li;
this.story = story;
this.topicId = topicId;
}
public void call() {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("show dialog notification with id " + this.id + " " + this.dialogId + " user=" + this.user + " chat=" + this.chat);
}
try {
NotificationsController.notificationManager.notify(this.id, this.notification.build());
} catch (SecurityException e) {
FileLog.e(e);
NotificationsController.this.resetNotificationSound(this.notification, this.dialogId, this.val$lastTopicId, this.val$chatName, this.val$vibrationPattern, this.val$ledColor, this.val$sound, this.val$importance, this.val$isDefault, this.val$isInApp, this.val$isSilent, this.val$chatType);
}
}
}
public static void lambda$showExtraNotifications$42(Uri uri, File file) {
try {
ApplicationLoader.applicationContext.revokeUriPermission(uri, 1);
} catch (Exception e) {
FileLog.e(e);
}
if (file != null) {
try {
file.delete();
} catch (Exception e2) {
FileLog.e(e2);
}
}
}
private String cutLastName(String name) {
if (name == null) {
return null;
}
int indexOf = name.indexOf(32);
if (indexOf < 0) {
return name;
}
StringBuilder sb = new StringBuilder();
sb.append(name.substring(0, indexOf));
sb.append(name.endsWith("…") ? "…" : BuildConfig.APP_CENTER_HASH);
return sb.toString();
}
private Pair<Integer, Boolean> parseStoryPushes(ArrayList<String> names, ArrayList<Object> avatars) {
int i;
String str;
TLRPC.FileLocation fileLocation;
int min = Math.min(3, this.storyPushMessages.size());
boolean z = false;
int i2 = 0;
while (i < min) {
StoryNotification storyNotification = this.storyPushMessages.get(i);
i2 += storyNotification.dateByIds.size();
z |= storyNotification.hidden;
TLRPC.User user = getMessagesController().getUser(Long.valueOf(storyNotification.dialogId));
if (user == null && (user = getMessagesStorage().getUserSync(storyNotification.dialogId)) != null) {
getMessagesController().putUser(user, true);
}
Object obj = null;
if (user != null) {
str = UserObject.getUserName(user);
TLRPC.UserProfilePhoto userProfilePhoto = user.photo;
if (userProfilePhoto != null && (fileLocation = userProfilePhoto.photo_small) != null && fileLocation.volume_id != 0 && fileLocation.local_id != 0) {
File pathToAttach = getFileLoader().getPathToAttach(user.photo.photo_small, true);
if (!pathToAttach.exists()) {
pathToAttach = user.photo.photo_big != null ? getFileLoader().getPathToAttach(user.photo.photo_big, true) : null;
if (pathToAttach != null && !pathToAttach.exists()) {
pathToAttach = null;
}
}
if (pathToAttach != null) {
obj = pathToAttach;
}
}
} else {
str = storyNotification.localName;
i = str == null ? i + 1 : 0;
}
if (str.length() > 50) {
str = str.substring(0, 25) + "…";
}
names.add(str);
if (obj == null && user != null) {
avatars.add(user);
} else if (obj != null) {
avatars.add(obj);
}
}
if (z) {
avatars.clear();
}
return new Pair<>(Integer.valueOf(i2), Boolean.valueOf(z));
}
public static Person.Builder loadRoundAvatar(File avatar, Person.Builder personBuilder) {
if (avatar != null && Build.VERSION.SDK_INT >= 28) {
try {
personBuilder.setIcon(IconCompat.createWithBitmap(ImageDecoder.decodeBitmap(ImageDecoder.createSource(avatar), new ImageDecoder.OnHeaderDecodedListener() {
@Override
public final void onHeaderDecoded(ImageDecoder imageDecoder, ImageDecoder.ImageInfo imageInfo, ImageDecoder.Source source) {
NotificationsController.lambda$loadRoundAvatar$44(imageDecoder, imageInfo, source);
}
})));
} catch (Throwable unused) {
}
}
return personBuilder;
}
public static void lambda$loadRoundAvatar$44(ImageDecoder imageDecoder, ImageDecoder.ImageInfo imageInfo, ImageDecoder.Source source) {
imageDecoder.setPostProcessor(new PostProcessor() {
@Override
public final int onPostProcess(Canvas canvas) {
int lambda$loadRoundAvatar$43;
lambda$loadRoundAvatar$43 = NotificationsController.lambda$loadRoundAvatar$43(canvas);
return lambda$loadRoundAvatar$43;
}
});
}
public static int lambda$loadRoundAvatar$43(Canvas canvas) {
Path path = new Path();
path.setFillType(Path.FillType.INVERSE_EVEN_ODD);
int width = canvas.getWidth();
float f = width / 2;
path.addRoundRect(0.0f, 0.0f, width, canvas.getHeight(), f, f, Path.Direction.CW);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(0);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
canvas.drawPath(path, paint);
return -3;
}
public static Bitmap loadMultipleAvatars(ArrayList<Object> avatars) {
int i;
Bitmap bitmap;
Paint paint;
float f;
int i2;
float size;
float size2;
float f2;
float f3;
float f4;
float f5;
Object obj;
TextPaint textPaint;
ArrayList<Object> arrayList = avatars;
if (Build.VERSION.SDK_INT < 28 || arrayList == null || avatars.size() == 0) {
return null;
}
int dp = AndroidUtilities.dp(64.0f);
Bitmap createBitmap = Bitmap.createBitmap(dp, dp, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
Matrix matrix = new Matrix();
Paint paint2 = new Paint(3);
Paint paint3 = new Paint(1);
Rect rect = new Rect();
paint3.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
float f6 = 1.0f;
float f7 = avatars.size() == 1 ? 1.0f : avatars.size() == 2 ? 0.65f : 0.5f;
int i3 = 0;
TextPaint textPaint2 = null;
while (i3 < avatars.size()) {
float f8 = dp;
float f9 = (f6 - f7) * f8;
try {
size = (f9 / avatars.size()) * ((avatars.size() - 1) - i3);
size2 = i3 * (f9 / avatars.size());
f2 = f8 * f7;
f3 = f2 / 2.0f;
i = dp;
f4 = size + f3;
f = f7;
f5 = size2 + f3;
bitmap = createBitmap;
try {
canvas.drawCircle(f4, f5, AndroidUtilities.dp(2.0f) + f3, paint3);
obj = arrayList.get(i3);
paint = paint3;
try {
} catch (Throwable unused) {
i2 = i3;
i3 = i2 + 1;
arrayList = avatars;
dp = i;
f7 = f;
createBitmap = bitmap;
paint3 = paint;
f6 = 1.0f;
}
} catch (Throwable unused2) {
paint = paint3;
}
} catch (Throwable unused3) {
i = dp;
bitmap = createBitmap;
paint = paint3;
f = f7;
}
if (obj instanceof File) {
try {
String absolutePath = ((File) arrayList.get(i3)).getAbsolutePath();
BitmapFactory.Options options = new BitmapFactory.Options();
try {
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(absolutePath, options);
int i4 = (int) f2;
options.inSampleSize = StoryEntry.calculateInSampleSize(options, i4, i4);
options.inJustDecodeBounds = false;
options.inDither = true;
Bitmap decodeFile = BitmapFactory.decodeFile(absolutePath, options);
Shader.TileMode tileMode = Shader.TileMode.CLAMP;
BitmapShader bitmapShader = new BitmapShader(decodeFile, tileMode, tileMode);
matrix.reset();
matrix.postScale(f2 / decodeFile.getWidth(), f2 / decodeFile.getHeight());
matrix.postTranslate(size, size2);
bitmapShader.setLocalMatrix(matrix);
paint2.setShader(bitmapShader);
canvas.drawCircle(f4, f5, f3, paint2);
decodeFile.recycle();
} catch (Throwable unused4) {
i2 = i3;
i3 = i2 + 1;
arrayList = avatars;
dp = i;
f7 = f;
createBitmap = bitmap;
paint3 = paint;
f6 = 1.0f;
}
} catch (Throwable unused5) {
i2 = i3;
i3 = i2 + 1;
arrayList = avatars;
dp = i;
f7 = f;
createBitmap = bitmap;
paint3 = paint;
f6 = 1.0f;
}
} else if (obj instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) obj;
int[] iArr = new int[2];
i2 = i3;
textPaint = textPaint2;
try {
iArr[0] = Theme.getColor(Theme.keys_avatar_background[AvatarDrawable.getColorIndex(user.id)]);
iArr[1] = Theme.getColor(Theme.keys_avatar_background2[AvatarDrawable.getColorIndex(user.id)]);
float f10 = size2 + f2;
try {
float[] fArr = new float[2];
fArr[0] = 0.0f;
try {
fArr[1] = 1.0f;
paint2.setShader(new LinearGradient(size, size2, size, f10, iArr, fArr, Shader.TileMode.CLAMP));
canvas.drawCircle(f4, f5, f3, paint2);
if (textPaint == null) {
try {
TextPaint textPaint3 = new TextPaint(1);
try {
textPaint3.setTypeface(AndroidUtilities.bold());
textPaint3.setTextSize(f8 * 0.25f);
textPaint3.setColor(-1);
textPaint2 = textPaint3;
} catch (Throwable unused6) {
textPaint2 = textPaint3;
i3 = i2 + 1;
arrayList = avatars;
dp = i;
f7 = f;
createBitmap = bitmap;
paint3 = paint;
f6 = 1.0f;
}
} catch (Throwable unused7) {
textPaint2 = textPaint;
i3 = i2 + 1;
arrayList = avatars;
dp = i;
f7 = f;
createBitmap = bitmap;
paint3 = paint;
f6 = 1.0f;
}
} else {
textPaint2 = textPaint;
}
try {
StringBuilder sb = new StringBuilder();
AvatarDrawable.getAvatarSymbols(user.first_name, user.last_name, null, sb);
String sb2 = sb.toString();
try {
textPaint2.getTextBounds(sb2, 0, sb2.length(), rect);
canvas.drawText(sb2, (f4 - (rect.width() / 2.0f)) - rect.left, (f5 - (rect.height() / 2.0f)) - rect.top, textPaint2);
} catch (Throwable unused8) {
}
} catch (Throwable unused9) {
i3 = i2 + 1;
arrayList = avatars;
dp = i;
f7 = f;
createBitmap = bitmap;
paint3 = paint;
f6 = 1.0f;
}
} catch (Throwable unused10) {
}
} catch (Throwable unused11) {
}
} catch (Throwable unused12) {
}
i3 = i2 + 1;
arrayList = avatars;
dp = i;
f7 = f;
createBitmap = bitmap;
paint3 = paint;
f6 = 1.0f;
}
i2 = i3;
textPaint = textPaint2;
textPaint2 = textPaint;
i3 = i2 + 1;
arrayList = avatars;
dp = i;
f7 = f;
createBitmap = bitmap;
paint3 = paint;
f6 = 1.0f;
}
return createBitmap;
}
public void playOutChatSound() {
if (!this.inChatSoundEnabled || MediaController.getInstance().isRecordingAudio()) {
return;
}
try {
if (audioManager.getRingerMode() == 0) {
return;
}
} catch (Exception e) {
FileLog.e(e);
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$playOutChatSound$46();
}
});
}
public void lambda$playOutChatSound$46() {
try {
if (Math.abs(SystemClock.elapsedRealtime() - this.lastSoundOutPlay) <= 100) {
return;
}
this.lastSoundOutPlay = SystemClock.elapsedRealtime();
if (this.soundPool == null) {
SoundPool soundPool = new SoundPool(3, 1, 0);
this.soundPool = soundPool;
soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
@Override
public final void onLoadComplete(SoundPool soundPool2, int i, int i2) {
NotificationsController.lambda$playOutChatSound$45(soundPool2, i, i2);
}
});
}
if (this.soundOut == 0 && !this.soundOutLoaded) {
this.soundOutLoaded = true;
this.soundOut = this.soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_out, 1);
}
int i = this.soundOut;
if (i != 0) {
try {
this.soundPool.play(i, 1.0f, 1.0f, 1, 0, 1.0f);
} catch (Exception e) {
FileLog.e(e);
}
}
} catch (Exception e2) {
FileLog.e(e2);
}
}
public static void lambda$playOutChatSound$45(SoundPool soundPool, int i, int i2) {
if (i2 == 0) {
try {
soundPool.play(i, 1.0f, 1.0f, 1, 0, 1.0f);
} catch (Exception e) {
FileLog.e(e);
}
}
}
public void clearDialogNotificationsSettings(long did, long topicId) {
SharedPreferences.Editor edit = getAccountInstance().getNotificationsSettings().edit();
String sharedPrefKey = getSharedPrefKey(did, topicId);
edit.remove(NotificationsSettingsFacade.PROPERTY_NOTIFY + sharedPrefKey).remove(NotificationsSettingsFacade.PROPERTY_CUSTOM + sharedPrefKey);
getMessagesStorage().setDialogFlags(did, 0L);
TLRPC.Dialog dialog = (TLRPC.Dialog) getMessagesController().dialogs_dict.get(did);
if (dialog != null) {
dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
}
edit.commit();
getNotificationsController().updateServerNotificationsSettings(did, topicId, true);
}
public void setDialogNotificationsSettings(long dialog_id, long topicId, int setting) {
SharedPreferences.Editor edit = getAccountInstance().getNotificationsSettings().edit();
TLRPC.Dialog dialog = (TLRPC.Dialog) MessagesController.getInstance(UserConfig.selectedAccount).dialogs_dict.get(dialog_id);
if (setting == 4) {
if (isGlobalNotificationsEnabled(dialog_id, false, false)) {
edit.remove(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(dialog_id, topicId));
} else {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(dialog_id, topicId), 0);
}
getMessagesStorage().setDialogFlags(dialog_id, 0L);
if (dialog != null) {
dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
}
} else {
int currentTime = ConnectionsManager.getInstance(UserConfig.selectedAccount).getCurrentTime();
if (setting == 0) {
currentTime += 3600;
} else if (setting == 1) {
currentTime += 28800;
} else if (setting == 2) {
currentTime += 172800;
} else if (setting == 3) {
currentTime = Integer.MAX_VALUE;
}
long j = 1;
if (setting == 3) {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(dialog_id, topicId), 2);
} else {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(dialog_id, topicId), 3);
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY_UNTIL + getSharedPrefKey(dialog_id, topicId), currentTime);
j = 1 | (((long) currentTime) << 32);
}
getInstance(UserConfig.selectedAccount).removeNotificationsForDialog(dialog_id);
MessagesStorage.getInstance(UserConfig.selectedAccount).setDialogFlags(dialog_id, j);
if (dialog != null) {
TLRPC.TL_peerNotifySettings tL_peerNotifySettings = new TLRPC.TL_peerNotifySettings();
dialog.notify_settings = tL_peerNotifySettings;
tL_peerNotifySettings.mute_until = currentTime;
}
}
edit.commit();
updateServerNotificationsSettings(dialog_id, topicId);
}
public void updateServerNotificationsSettings(long dialog_id, long topicId) {
updateServerNotificationsSettings(dialog_id, topicId, true);
}
public void updateServerNotificationsSettings(long dialogId, long topicId, boolean post) {
if (post) {
getNotificationCenter().lambda$postNotificationNameOnUIThread$1(NotificationCenter.notificationsSettingsUpdated, new Object[0]);
}
if (DialogObject.isEncryptedDialog(dialogId)) {
return;
}
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
TLRPC.TL_account_updateNotifySettings tL_account_updateNotifySettings = new TLRPC.TL_account_updateNotifySettings();
tL_account_updateNotifySettings.settings = new TLRPC.TL_inputPeerNotifySettings();
String sharedPrefKey = getSharedPrefKey(dialogId, topicId);
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings = tL_account_updateNotifySettings.settings;
tL_inputPeerNotifySettings.flags |= 1;
tL_inputPeerNotifySettings.show_previews = notificationsSettings.getBoolean(NotificationsSettingsFacade.PROPERTY_CONTENT_PREVIEW + sharedPrefKey, true);
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings2 = tL_account_updateNotifySettings.settings;
tL_inputPeerNotifySettings2.flags = tL_inputPeerNotifySettings2.flags | 2;
tL_inputPeerNotifySettings2.silent = notificationsSettings.getBoolean(NotificationsSettingsFacade.PROPERTY_SILENT + sharedPrefKey, false);
if (notificationsSettings.contains(NotificationsSettingsFacade.PROPERTY_STORIES_NOTIFY + sharedPrefKey)) {
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings3 = tL_account_updateNotifySettings.settings;
tL_inputPeerNotifySettings3.flags |= 64;
tL_inputPeerNotifySettings3.stories_muted = !notificationsSettings.getBoolean(NotificationsSettingsFacade.PROPERTY_STORIES_NOTIFY + sharedPrefKey, true);
}
int i = notificationsSettings.getInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(dialogId, topicId), -1);
if (i != -1) {
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings4 = tL_account_updateNotifySettings.settings;
tL_inputPeerNotifySettings4.flags |= 4;
if (i == 3) {
tL_inputPeerNotifySettings4.mute_until = notificationsSettings.getInt(NotificationsSettingsFacade.PROPERTY_NOTIFY_UNTIL + getSharedPrefKey(dialogId, topicId), 0);
} else {
tL_inputPeerNotifySettings4.mute_until = i == 2 ? Integer.MAX_VALUE : 0;
}
}
long j = notificationsSettings.getLong("sound_document_id_" + getSharedPrefKey(dialogId, topicId), 0L);
String string = notificationsSettings.getString("sound_path_" + getSharedPrefKey(dialogId, topicId), null);
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings5 = tL_account_updateNotifySettings.settings;
tL_inputPeerNotifySettings5.flags = tL_inputPeerNotifySettings5.flags | 8;
if (j != 0) {
TLRPC.TL_notificationSoundRingtone tL_notificationSoundRingtone = new TLRPC.TL_notificationSoundRingtone();
tL_notificationSoundRingtone.id = j;
tL_account_updateNotifySettings.settings.sound = tL_notificationSoundRingtone;
} else if (string != null) {
if (string.equalsIgnoreCase("NoSound")) {
tL_account_updateNotifySettings.settings.sound = new TLRPC.TL_notificationSoundNone();
} else {
TLRPC.TL_notificationSoundLocal tL_notificationSoundLocal = new TLRPC.TL_notificationSoundLocal();
tL_notificationSoundLocal.title = notificationsSettings.getString("sound_" + getSharedPrefKey(dialogId, topicId), null);
tL_notificationSoundLocal.data = string;
tL_account_updateNotifySettings.settings.sound = tL_notificationSoundLocal;
}
} else {
tL_inputPeerNotifySettings5.sound = new TLRPC.TL_notificationSoundDefault();
}
if (topicId != 0 && dialogId != getUserConfig().getClientUserId()) {
TLRPC.TL_inputNotifyForumTopic tL_inputNotifyForumTopic = new TLRPC.TL_inputNotifyForumTopic();
tL_inputNotifyForumTopic.peer = getMessagesController().getInputPeer(dialogId);
tL_inputNotifyForumTopic.top_msg_id = (int) topicId;
tL_account_updateNotifySettings.peer = tL_inputNotifyForumTopic;
} else {
TLRPC.TL_inputNotifyPeer tL_inputNotifyPeer = new TLRPC.TL_inputNotifyPeer();
tL_account_updateNotifySettings.peer = tL_inputNotifyPeer;
tL_inputNotifyPeer.peer = getMessagesController().getInputPeer(dialogId);
}
getConnectionsManager().sendRequest(tL_account_updateNotifySettings, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
NotificationsController.lambda$updateServerNotificationsSettings$47(tLObject, tL_error);
}
});
}
public void updateServerNotificationsSettings(int type) {
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
if (type == 4 || type == 5) {
TLRPC.TL_account_setReactionsNotifySettings tL_account_setReactionsNotifySettings = new TLRPC.TL_account_setReactionsNotifySettings();
tL_account_setReactionsNotifySettings.settings = new TLRPC.TL_reactionsNotifySettings();
if (notificationsSettings.getBoolean("EnableReactionsMessages", true)) {
tL_account_setReactionsNotifySettings.settings.flags |= 1;
if (notificationsSettings.getBoolean("EnableReactionsMessagesContacts", false)) {
tL_account_setReactionsNotifySettings.settings.messages_notify_from = new TLRPC.TL_reactionNotificationsFromContacts();
} else {
tL_account_setReactionsNotifySettings.settings.messages_notify_from = new TLRPC.TL_reactionNotificationsFromAll();
}
}
if (notificationsSettings.getBoolean("EnableReactionsStories", true)) {
tL_account_setReactionsNotifySettings.settings.flags |= 2;
if (notificationsSettings.getBoolean("EnableReactionsStoriesContacts", false)) {
tL_account_setReactionsNotifySettings.settings.stories_notify_from = new TLRPC.TL_reactionNotificationsFromContacts();
} else {
tL_account_setReactionsNotifySettings.settings.stories_notify_from = new TLRPC.TL_reactionNotificationsFromAll();
}
}
tL_account_setReactionsNotifySettings.settings.show_previews = notificationsSettings.getBoolean("EnableReactionsPreview", true);
tL_account_setReactionsNotifySettings.settings.sound = getInputSound(notificationsSettings, "ReactionSound", "ReactionSoundDocId", "ReactionSoundPath");
getConnectionsManager().sendRequest(tL_account_setReactionsNotifySettings, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
NotificationsController.lambda$updateServerNotificationsSettings$48(tLObject, tL_error);
}
});
return;
}
TLRPC.TL_account_updateNotifySettings tL_account_updateNotifySettings = new TLRPC.TL_account_updateNotifySettings();
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings = new TLRPC.TL_inputPeerNotifySettings();
tL_account_updateNotifySettings.settings = tL_inputPeerNotifySettings;
tL_inputPeerNotifySettings.flags = 5;
if (type == 0) {
tL_account_updateNotifySettings.peer = new TLRPC.TL_inputNotifyChats();
tL_account_updateNotifySettings.settings.mute_until = notificationsSettings.getInt("EnableGroup2", 0);
tL_account_updateNotifySettings.settings.show_previews = notificationsSettings.getBoolean("EnablePreviewGroup", true);
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings2 = tL_account_updateNotifySettings.settings;
tL_inputPeerNotifySettings2.flags |= 8;
tL_inputPeerNotifySettings2.sound = getInputSound(notificationsSettings, "GroupSound", "GroupSoundDocId", "GroupSoundPath");
} else if (type == 1 || type == 3) {
tL_account_updateNotifySettings.peer = new TLRPC.TL_inputNotifyUsers();
tL_account_updateNotifySettings.settings.mute_until = notificationsSettings.getInt("EnableAll2", 0);
tL_account_updateNotifySettings.settings.show_previews = notificationsSettings.getBoolean("EnablePreviewAll", true);
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings3 = tL_account_updateNotifySettings.settings;
tL_inputPeerNotifySettings3.flags |= 128;
tL_inputPeerNotifySettings3.stories_hide_sender = notificationsSettings.getBoolean("EnableHideStoriesSenders", false);
if (notificationsSettings.contains("EnableAllStories")) {
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings4 = tL_account_updateNotifySettings.settings;
tL_inputPeerNotifySettings4.flags |= 64;
tL_inputPeerNotifySettings4.stories_muted = !notificationsSettings.getBoolean("EnableAllStories", true);
}
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings5 = tL_account_updateNotifySettings.settings;
tL_inputPeerNotifySettings5.flags |= 8;
tL_inputPeerNotifySettings5.sound = getInputSound(notificationsSettings, "GlobalSound", "GlobalSoundDocId", "GlobalSoundPath");
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings6 = tL_account_updateNotifySettings.settings;
tL_inputPeerNotifySettings6.flags |= 256;
tL_inputPeerNotifySettings6.stories_sound = getInputSound(notificationsSettings, "StoriesSound", "StoriesSoundDocId", "StoriesSoundPath");
} else {
tL_account_updateNotifySettings.peer = new TLRPC.TL_inputNotifyBroadcasts();
tL_account_updateNotifySettings.settings.mute_until = notificationsSettings.getInt("EnableChannel2", 0);
tL_account_updateNotifySettings.settings.show_previews = notificationsSettings.getBoolean("EnablePreviewChannel", true);
TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings7 = tL_account_updateNotifySettings.settings;
tL_inputPeerNotifySettings7.flags |= 8;
tL_inputPeerNotifySettings7.sound = getInputSound(notificationsSettings, "ChannelSound", "ChannelSoundDocId", "ChannelSoundPath");
}
getConnectionsManager().sendRequest(tL_account_updateNotifySettings, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
NotificationsController.lambda$updateServerNotificationsSettings$49(tLObject, tL_error);
}
});
}
private TLRPC.NotificationSound getInputSound(SharedPreferences preferences, String namePref, String docPref, String pathPref) {
long j = preferences.getLong(docPref, 0L);
String string = preferences.getString(pathPref, "NoSound");
if (j != 0) {
TLRPC.TL_notificationSoundRingtone tL_notificationSoundRingtone = new TLRPC.TL_notificationSoundRingtone();
tL_notificationSoundRingtone.id = j;
return tL_notificationSoundRingtone;
}
if (string != null) {
if (string.equalsIgnoreCase("NoSound")) {
return new TLRPC.TL_notificationSoundNone();
}
TLRPC.TL_notificationSoundLocal tL_notificationSoundLocal = new TLRPC.TL_notificationSoundLocal();
tL_notificationSoundLocal.title = preferences.getString(namePref, null);
tL_notificationSoundLocal.data = string;
return tL_notificationSoundLocal;
}
return new TLRPC.TL_notificationSoundDefault();
}
public boolean isGlobalNotificationsEnabled(long dialogId, boolean isReaction, boolean isStoryReaction) {
return isGlobalNotificationsEnabled(dialogId, null, isReaction, isStoryReaction);
}
public boolean isGlobalNotificationsEnabled(long r3, java.lang.Boolean r5, boolean r6, boolean r7) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.messenger.NotificationsController.isGlobalNotificationsEnabled(long, java.lang.Boolean, boolean, boolean):boolean");
}
public boolean isGlobalNotificationsEnabled(int type) {
if (type == 4) {
return getAccountInstance().getNotificationsSettings().getBoolean("EnableReactionsMessages", true);
}
if (type == 5) {
return getAccountInstance().getNotificationsSettings().getBoolean("EnableReactionsStories", true);
}
if (type == 3) {
return getAccountInstance().getNotificationsSettings().getBoolean("EnableAllStories", true);
}
return getAccountInstance().getNotificationsSettings().getInt(getGlobalNotificationsKey(type), 0) < getConnectionsManager().getCurrentTime();
}
public void setGlobalNotificationsEnabled(int type, int time) {
getAccountInstance().getNotificationsSettings().edit().putInt(getGlobalNotificationsKey(type), time).commit();
updateServerNotificationsSettings(type);
getMessagesStorage().updateMutedDialogsFiltersCounters();
deleteNotificationChannelGlobal(type);
}
public void muteDialog(long dialog_id, long topicId, boolean mute) {
if (mute) {
getInstance(((BaseController) this).currentAccount).muteUntil(dialog_id, topicId, Integer.MAX_VALUE);
return;
}
boolean isGlobalNotificationsEnabled = getInstance(((BaseController) this).currentAccount).isGlobalNotificationsEnabled(dialog_id, false, false);
boolean z = topicId != 0;
SharedPreferences.Editor edit = MessagesController.getNotificationsSettings(((BaseController) this).currentAccount).edit();
if (isGlobalNotificationsEnabled && !z) {
edit.remove(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(dialog_id, topicId));
} else {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(dialog_id, topicId), 0);
}
if (topicId == 0) {
getMessagesStorage().setDialogFlags(dialog_id, 0L);
TLRPC.Dialog dialog = (TLRPC.Dialog) getMessagesController().dialogs_dict.get(dialog_id);
if (dialog != null) {
dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
}
}
edit.apply();
updateServerNotificationsSettings(dialog_id, topicId);
}
public NotificationsSettingsFacade getNotificationsSettingsFacade() {
return this.dialogsNotificationsFacade;
}
public void loadTopicsNotificationsExceptions(final long dialogId, final Consumer<HashSet<Integer>> consumer) {
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$loadTopicsNotificationsExceptions$51(dialogId, consumer);
}
});
}
public void lambda$loadTopicsNotificationsExceptions$51(long j, final Consumer consumer) {
final HashSet hashSet = new HashSet();
Iterator<Map.Entry<String, ?>> it = MessagesController.getNotificationsSettings(((BaseController) this).currentAccount).getAll().entrySet().iterator();
while (it.hasNext()) {
String key = it.next().getKey();
if (key.startsWith(NotificationsSettingsFacade.PROPERTY_NOTIFY + j)) {
int intValue = Utilities.parseInt((CharSequence) key.replace(NotificationsSettingsFacade.PROPERTY_NOTIFY + j, BuildConfig.APP_CENTER_HASH)).intValue();
if (intValue != 0 && getMessagesController().isDialogMuted(j, intValue) != getMessagesController().isDialogMuted(j, 0L)) {
hashSet.add(Integer.valueOf(intValue));
}
}
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.lambda$loadTopicsNotificationsExceptions$50(consumer, hashSet);
}
});
}
public static void lambda$loadTopicsNotificationsExceptions$50(Consumer consumer, HashSet hashSet) {
if (consumer != null) {
consumer.accept(hashSet);
}
}
public static class DialogKey {
public final long dialogId;
public final boolean story;
public final long topicId;
private DialogKey(long dialogId, long topicId, boolean story) {
this.dialogId = dialogId;
this.topicId = topicId;
this.story = story;
}
}
public static class StoryNotification {
public long date;
public final HashMap<Integer, Pair<Long, Long>> dateByIds;
public final long dialogId;
public boolean hidden;
public String localName;
public StoryNotification(long dialogId, String localName, int id, long date) {
this(dialogId, localName, id, date, date + 86400000);
}
public StoryNotification(long dialogId, String localName, int id, long date, long expire_date) {
HashMap<Integer, Pair<Long, Long>> hashMap = new HashMap<>();
this.dateByIds = hashMap;
this.dialogId = dialogId;
this.localName = localName;
hashMap.put(Integer.valueOf(id), new Pair<>(Long.valueOf(date), Long.valueOf(expire_date)));
this.date = date;
}
public long getLeastDate() {
long j = -1;
for (Pair<Long, Long> pair : this.dateByIds.values()) {
if (j == -1 || j > ((Long) pair.first).longValue()) {
j = ((Long) pair.first).longValue();
}
}
return j;
}
}
public void checkStoryPushes() {
long currentTimeMillis = System.currentTimeMillis();
int i = 0;
boolean z = false;
while (i < this.storyPushMessages.size()) {
StoryNotification storyNotification = this.storyPushMessages.get(i);
Iterator<Map.Entry<Integer, Pair<Long, Long>>> it = storyNotification.dateByIds.entrySet().iterator();
while (it.hasNext()) {
if (currentTimeMillis >= ((Long) it.next().getValue().second).longValue()) {
it.remove();
z = true;
}
}
if (z) {
if (storyNotification.dateByIds.isEmpty()) {
getMessagesStorage().deleteStoryPushMessage(storyNotification.dialogId);
this.storyPushMessages.remove(i);
i--;
} else {
getMessagesStorage().putStoryPushMessage(storyNotification);
}
}
i++;
}
if (z) {
showOrUpdateNotification(false);
}
updateStoryPushesRunnable();
}
private void updateStoryPushesRunnable() {
long j = Long.MAX_VALUE;
for (int i = 0; i < this.storyPushMessages.size(); i++) {
Iterator<Pair<Long, Long>> it = this.storyPushMessages.get(i).dateByIds.values().iterator();
while (it.hasNext()) {
j = Math.min(j, ((Long) it.next().second).longValue());
}
}
DispatchQueue dispatchQueue = notificationsQueue;
dispatchQueue.cancelRunnable(this.checkStoryPushesRunnable);
long currentTimeMillis = j - System.currentTimeMillis();
if (j != Long.MAX_VALUE) {
dispatchQueue.postRunnable(this.checkStoryPushesRunnable, Math.max(0L, currentTimeMillis));
}
}
}