Telegram5 v10.6.2版本的 MD5 值为:423cae39e902ed9dd2cc7f4b4547b276
以下内容为反编译后的 NotificationsController.java 源代码,内容仅作参考
package org.telegram.messenger;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.ActivityManager;
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.Context;
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.Color;
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.graphics.drawable.BitmapDrawable;
import android.media.AudioAttributes;
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 android.util.SparseBooleanArray;
import androidx.collection.LongSparseArray;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.app.Person;
import androidx.core.app.RemoteInput;
import androidx.core.content.FileProvider;
import androidx.core.content.LocusIdCompat;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.graphics.ColorUtils;
import androidx.core.graphics.drawable.IconCompat;
import j$.util.Comparator$CC;
import j$.util.function.Consumer;
import j$.util.function.ToLongFunction;
import java.io.File;
import java.io.FileOutputStream;
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$Chat;
import org.telegram.tgnet.TLRPC$ChatPhoto;
import org.telegram.tgnet.TLRPC$Dialog;
import org.telegram.tgnet.TLRPC$EncryptedChat;
import org.telegram.tgnet.TLRPC$FileLocation;
import org.telegram.tgnet.TLRPC$KeyboardButton;
import org.telegram.tgnet.TLRPC$Message;
import org.telegram.tgnet.TLRPC$MessageAction;
import org.telegram.tgnet.TLRPC$MessageFwdHeader;
import org.telegram.tgnet.TLRPC$MessageMedia;
import org.telegram.tgnet.TLRPC$NotificationSound;
import org.telegram.tgnet.TLRPC$Peer;
import org.telegram.tgnet.TLRPC$Poll;
import org.telegram.tgnet.TLRPC$ReplyMarkup;
import org.telegram.tgnet.TLRPC$TL_account_updateNotifySettings;
import org.telegram.tgnet.TLRPC$TL_error;
import org.telegram.tgnet.TLRPC$TL_forumTopic;
import org.telegram.tgnet.TLRPC$TL_inputNotifyBroadcasts;
import org.telegram.tgnet.TLRPC$TL_inputNotifyChats;
import org.telegram.tgnet.TLRPC$TL_inputNotifyForumTopic;
import org.telegram.tgnet.TLRPC$TL_inputNotifyPeer;
import org.telegram.tgnet.TLRPC$TL_inputNotifyUsers;
import org.telegram.tgnet.TLRPC$TL_inputPeerNotifySettings;
import org.telegram.tgnet.TLRPC$TL_keyboardButtonCallback;
import org.telegram.tgnet.TLRPC$TL_keyboardButtonRow;
import org.telegram.tgnet.TLRPC$TL_message;
import org.telegram.tgnet.TLRPC$TL_messageActionChatJoinedByRequest;
import org.telegram.tgnet.TLRPC$TL_messageActionContactSignUp;
import org.telegram.tgnet.TLRPC$TL_messageActionEmpty;
import org.telegram.tgnet.TLRPC$TL_messageActionGameScore;
import org.telegram.tgnet.TLRPC$TL_messageActionGeoProximityReached;
import org.telegram.tgnet.TLRPC$TL_messageActionLoginUnknownLocation;
import org.telegram.tgnet.TLRPC$TL_messageActionPaymentSent;
import org.telegram.tgnet.TLRPC$TL_messageActionPhoneCall;
import org.telegram.tgnet.TLRPC$TL_messageActionPinMessage;
import org.telegram.tgnet.TLRPC$TL_messageActionSetChatTheme;
import org.telegram.tgnet.TLRPC$TL_messageActionSetChatWallPaper;
import org.telegram.tgnet.TLRPC$TL_messageActionSetMessagesTTL;
import org.telegram.tgnet.TLRPC$TL_messageActionSetSameChatWallPaper;
import org.telegram.tgnet.TLRPC$TL_messageActionUserJoined;
import org.telegram.tgnet.TLRPC$TL_messageActionUserUpdatedPhoto;
import org.telegram.tgnet.TLRPC$TL_messageEntitySpoiler;
import org.telegram.tgnet.TLRPC$TL_messageMediaContact;
import org.telegram.tgnet.TLRPC$TL_messageMediaDocument;
import org.telegram.tgnet.TLRPC$TL_messageMediaGeo;
import org.telegram.tgnet.TLRPC$TL_messageMediaGeoLive;
import org.telegram.tgnet.TLRPC$TL_messageMediaGiveaway;
import org.telegram.tgnet.TLRPC$TL_messageMediaGiveawayResults;
import org.telegram.tgnet.TLRPC$TL_messageMediaPhoto;
import org.telegram.tgnet.TLRPC$TL_messageMediaPoll;
import org.telegram.tgnet.TLRPC$TL_messageMediaVenue;
import org.telegram.tgnet.TLRPC$TL_messageService;
import org.telegram.tgnet.TLRPC$TL_notificationSoundDefault;
import org.telegram.tgnet.TLRPC$TL_notificationSoundLocal;
import org.telegram.tgnet.TLRPC$TL_notificationSoundNone;
import org.telegram.tgnet.TLRPC$TL_notificationSoundRingtone;
import org.telegram.tgnet.TLRPC$TL_peerNotifySettings;
import org.telegram.tgnet.TLRPC$TL_peerUser;
import org.telegram.tgnet.TLRPC$User;
import org.telegram.tgnet.TLRPC$UserProfilePhoto;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.BubbleActivity;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.spoilers.SpoilerEffect;
import org.telegram.ui.LaunchActivity;
import org.telegram.ui.PopupNotificationActivity;
import org.telegram.ui.Stories.recorder.StoryEntry;
import org.webrtc.MediaStreamTrack;
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_STORIES = 3;
protected 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;
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;
char[] spoilerChars;
private final ArrayList<StoryNotification> storyPushMessages;
private final LongSparseArray<StoryNotification> storyPushMessagesDict;
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 i) {
return i == 0 ? "EnableGroup2" : i == 1 ? "EnableAll2" : "EnableChannel2";
}
public static void lambda$updateServerNotificationsSettings$45(TLObject tLObject, TLRPC$TL_error tLRPC$TL_error) {
}
public static void lambda$updateServerNotificationsSettings$46(TLObject tLObject, TLRPC$TL_error tLRPC$TL_error) {
}
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(MediaStreamTrack.AUDIO_TRACK_KIND);
Instance = new NotificationsController[4];
lockObjects = new Object[4];
for (int i = 0; i < 4; i++) {
lockObjects[i] = new Object();
}
sharedPrefCachedKeys = new LongSparseArray<>();
}
public static NotificationsController getInstance(int i) {
NotificationsController notificationsController = Instance[i];
if (notificationsController == null) {
synchronized (lockObjects[i]) {
notificationsController = Instance[i];
if (notificationsController == null) {
NotificationsController[] notificationsControllerArr = Instance;
NotificationsController notificationsController2 = new NotificationsController(i);
notificationsControllerArr[i] = notificationsController2;
notificationsController = notificationsController2;
}
}
}
return notificationsController;
}
public NotificationsController(int i) {
super(i);
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.spoilerChars = new char[]{10252, 10338, 10385, 10280};
this.checkStoryPushesRunnable = new Runnable() {
@Override
public final void run() {
NotificationsController.this.checkStoryPushes();
}
};
this.notificationId = this.currentAccount + 1;
StringBuilder sb = new StringBuilder();
sb.append("messages");
int i2 = this.currentAccount;
sb.append(i2 == 0 ? "" : Integer.valueOf(i2));
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(MediaStreamTrack.AUDIO_TRACK_KIND);
} 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(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) {
systemNotificationManager.deleteNotificationChannel(OTHER_NOTIFICATIONS_CHANNEL);
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 e) {
FileLog.e(e);
}
}
}
public static String getSharedPrefKey(long j, long j2) {
return getSharedPrefKey(j, j2, false);
}
public static String getSharedPrefKey(long j, long j2, boolean z) {
String valueOf;
if (z) {
return j2 != 0 ? String.format(Locale.US, "%d_%d", Long.valueOf(j), Long.valueOf(j2)) : String.valueOf(j);
}
long j3 = (j2 << 12) + j;
LongSparseArray<String> longSparseArray = sharedPrefCachedKeys;
int indexOfKey = longSparseArray.indexOfKey(j3);
if (indexOfKey >= 0) {
return longSparseArray.valueAt(indexOfKey);
}
if (j2 != 0) {
valueOf = String.format(Locale.US, "%d_%d", Long.valueOf(j), Long.valueOf(j2));
} else {
valueOf = String.valueOf(j);
}
longSparseArray.put(j3, valueOf);
return valueOf;
}
public void muteUntil(long j, long j2, int i) {
long j3;
if (j != 0) {
SharedPreferences.Editor edit = MessagesController.getNotificationsSettings(this.currentAccount).edit();
boolean z = j2 != 0;
boolean isGlobalNotificationsEnabled = getInstance(this.currentAccount).isGlobalNotificationsEnabled(j);
String sharedPrefKey = getSharedPrefKey(j, j2);
if (i != Integer.MAX_VALUE) {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + sharedPrefKey, 3);
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY_UNTIL + sharedPrefKey, getConnectionsManager().getCurrentTime() + i);
j3 = (((long) i) << 32) | 1;
} else if (!isGlobalNotificationsEnabled && !z) {
edit.remove(NotificationsSettingsFacade.PROPERTY_NOTIFY + sharedPrefKey);
j3 = 0;
} else {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + sharedPrefKey, 2);
j3 = 1L;
}
edit.apply();
if (j2 == 0) {
getInstance(this.currentAccount).removeNotificationsForDialog(j);
MessagesStorage.getInstance(this.currentAccount).setDialogFlags(j, j3);
TLRPC$Dialog tLRPC$Dialog = MessagesController.getInstance(this.currentAccount).dialogs_dict.get(j);
if (tLRPC$Dialog != null) {
TLRPC$TL_peerNotifySettings tLRPC$TL_peerNotifySettings = new TLRPC$TL_peerNotifySettings();
tLRPC$Dialog.notify_settings = tLRPC$TL_peerNotifySettings;
if (i != Integer.MAX_VALUE || isGlobalNotificationsEnabled) {
tLRPC$TL_peerNotifySettings.mute_until = i;
}
}
}
getInstance(this.currentAccount).updateServerNotificationsSettings(j, j2);
}
}
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" + this.currentAccount);
systemNotificationManager.deleteNotificationChannelGroup("groups" + this.currentAccount);
systemNotificationManager.deleteNotificationChannelGroup("private" + this.currentAccount);
systemNotificationManager.deleteNotificationChannelGroup("stories" + this.currentAccount);
systemNotificationManager.deleteNotificationChannelGroup("other" + this.currentAccount);
String str = 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 z) {
this.inChatSoundEnabled = z;
}
public void setOpenedDialogId(final long j, final long j2) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$setOpenedDialogId$2(j, j2);
}
});
}
public void lambda$setOpenedDialogId$2(long j, long j2) {
this.openedDialogId = j;
this.openedTopicId = j2;
}
public void setOpenedInBubble(final long j, final boolean z) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$setOpenedInBubble$3(z, j);
}
});
}
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 i) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$setLastOnlineFromOtherDevice$4(i);
}
});
}
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 j) {
processReadMessages(null, j, 0, ConnectionsManager.DEFAULT_DATACENTER_ID, false);
LongSparseIntArray longSparseIntArray = new LongSparseIntArray();
longSparseIntArray.put(j, 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 tLRPC$Message = messageObject.messageOwner;
if ((!tLRPC$Message.mentioned || !(tLRPC$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 tLRPC$Message = messageObject.messageOwner;
if ((!tLRPC$Message.mentioned || !(tLRPC$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", 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>> longSparseArray, final boolean z) {
final ArrayList arrayList = new ArrayList(0);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$removeDeletedMessagesFromNotifications$9(longSparseArray, z, 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;
int i3 = 0;
while (i3 < longSparseArray.size()) {
long keyAt = longSparseArray2.keyAt(i3);
SparseArray<MessageObject> sparseArray = this.pushMessagesDict.get(keyAt);
if (sparseArray != null) {
ArrayList arrayList2 = (ArrayList) longSparseArray2.get(keyAt);
int size = arrayList2.size();
int i4 = i2;
while (i4 < size) {
int intValue = ((Integer) arrayList2.get(i4)).intValue();
MessageObject messageObject = sparseArray.get(intValue);
if (messageObject == null || (z && !messageObject.isReactionPush)) {
j = keyAt;
} else {
j = keyAt;
long dialogId = messageObject.getDialogId();
Integer num2 = 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 i5 = this.total_unread_count - (num2.intValue() > 0 ? 1 : 0);
this.total_unread_count = i5;
this.total_unread_count = i5 + (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);
}
i4++;
keyAt = j;
}
long j2 = keyAt;
if (sparseArray.size() == 0) {
this.pushMessagesDict.remove(j2);
}
}
i3++;
longSparseArray2 = longSparseArray;
i2 = 0;
}
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(this.currentAccount));
getNotificationCenter().lambda$postNotificationNameOnUIThread$1(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(i));
}
public void removeDeletedHisoryFromNotifications(final LongSparseIntArray longSparseIntArray) {
final ArrayList arrayList = new ArrayList(0);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$removeDeletedHisoryFromNotifications$12(longSparseIntArray, arrayList);
}
});
}
public void lambda$removeDeletedHisoryFromNotifications$12(LongSparseIntArray longSparseIntArray, final ArrayList arrayList) {
Integer num;
int i = this.total_unread_count;
getAccountInstance().getNotificationsSettings();
int i2 = 0;
Integer num2 = 0;
int i3 = 0;
while (true) {
if (i3 >= longSparseIntArray.size()) {
break;
}
long keyAt = longSparseIntArray.keyAt(i3);
long j = -keyAt;
long j2 = longSparseIntArray.get(keyAt);
Integer num3 = this.pushDialogs.get(j);
if (num3 == null) {
num3 = num2;
}
int i4 = i2;
Integer num4 = num3;
while (i4 < this.pushMessages.size()) {
MessageObject messageObject = this.pushMessages.get(i4);
if (messageObject.getDialogId() == j) {
num = num2;
if (messageObject.getId() <= j2) {
SparseArray<MessageObject> 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);
i4--;
if (isPersonalMessage(messageObject)) {
this.personalCount--;
}
arrayList.add(messageObject);
num4 = Integer.valueOf(num4.intValue() - 1);
}
} else {
num = num2;
}
i4++;
num2 = num;
}
Integer num5 = num2;
if (num4.intValue() <= 0) {
this.smartNotificationsDialogs.remove(j);
num4 = num5;
}
if (!num4.equals(num3)) {
if (getMessagesController().isForum(j)) {
int i5 = this.total_unread_count - (num3.intValue() > 0 ? 1 : 0);
this.total_unread_count = i5;
this.total_unread_count = i5 + (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);
}
i3++;
num2 = num5;
i2 = 0;
}
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(this.currentAccount));
getNotificationCenter().lambda$postNotificationNameOnUIThread$1(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(i));
}
public void processDeleteStory(final long j, final int i) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processDeleteStory$13(j, i);
}
});
}
public void lambda$processDeleteStory$13(long j, int i) {
boolean z;
StoryNotification storyNotification = this.storyPushMessagesDict.get(j);
if (storyNotification != null) {
storyNotification.dateByIds.remove(Integer.valueOf(i));
if (storyNotification.dateByIds.isEmpty()) {
this.storyPushMessagesDict.remove(j);
this.storyPushMessages.remove(storyNotification);
z = true;
getMessagesStorage().deleteStoryPushMessage(j);
if (z) {
return;
}
showOrUpdateNotification(false);
return;
}
getMessagesStorage().putStoryPushMessage(storyNotification);
}
z = false;
if (z) {
}
}
public void processReadStories(final long j, int i) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processReadStories$14(j);
}
});
}
public void lambda$processReadStories$14(long j) {
boolean z;
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$15();
}
});
}
public void lambda$processIgnoreStories$15() {
boolean z = !this.storyPushMessages.isEmpty();
this.storyPushMessages.clear();
this.storyPushMessagesDict.clear();
getMessagesStorage().deleteAllStoryPushMessages();
if (z) {
showOrUpdateNotification(false);
}
}
public void processIgnoreStories(final long j) {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processIgnoreStories$16(j);
}
});
}
public void lambda$processIgnoreStories$16(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 longSparseIntArray, final long j, final int i, final int i2, final boolean z) {
final ArrayList arrayList = new ArrayList(0);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processReadMessages$18(longSparseIntArray, arrayList, j, i2, i, z);
}
});
}
public void lambda$processReadMessages$18(LongSparseIntArray longSparseIntArray, final ArrayList arrayList, long j, int i, int i2, boolean z) {
int i3;
int i4 = 1;
if (longSparseIntArray != null) {
int i5 = 0;
while (i5 < longSparseIntArray.size()) {
long keyAt = longSparseIntArray.keyAt(i5);
int i6 = longSparseIntArray.get(keyAt);
int i7 = 0;
while (i7 < this.pushMessages.size()) {
MessageObject messageObject = this.pushMessages.get(i7);
if (messageObject.messageOwner.from_scheduled || messageObject.getDialogId() != keyAt || messageObject.getId() > i6) {
i3 = i5;
} else {
if (isPersonalMessage(messageObject)) {
this.personalCount -= i4;
}
arrayList.add(messageObject);
i3 = i5;
long j2 = messageObject.messageOwner.peer_id.channel_id;
long j3 = j2 != 0 ? -j2 : 0L;
SparseArray<MessageObject> sparseArray = this.pushMessagesDict.get(j3);
if (sparseArray != null) {
sparseArray.remove(messageObject.getId());
if (sparseArray.size() == 0) {
this.pushMessagesDict.remove(j3);
}
}
this.delayedPushMessages.remove(messageObject);
this.pushMessages.remove(i7);
i7--;
}
i7++;
i4 = 1;
i5 = i3;
}
i5++;
i4 = 1;
}
}
if (j != 0 && (i != 0 || i2 != 0)) {
int i8 = 0;
while (i8 < this.pushMessages.size()) {
MessageObject messageObject2 = this.pushMessages.get(i8);
if (messageObject2.getDialogId() == j) {
boolean z2 = i2 != 0 ? true : true;
if (z2) {
if (isPersonalMessage(messageObject2)) {
this.personalCount--;
}
long j4 = messageObject2.messageOwner.peer_id.channel_id;
long j5 = j4 != 0 ? -j4 : 0L;
SparseArray<MessageObject> sparseArray2 = this.pushMessagesDict.get(j5);
if (sparseArray2 != null) {
sparseArray2.remove(messageObject2.getId());
if (sparseArray2.size() == 0) {
this.pushMessagesDict.remove(j5);
}
}
this.pushMessages.remove(i8);
this.delayedPushMessages.remove(messageObject2);
arrayList.add(messageObject2);
i8--;
}
}
i8++;
}
}
if (arrayList.isEmpty()) {
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processReadMessages$17(arrayList);
}
});
}
public void lambda$processReadMessages$17(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(ArrayList<MessageObject> arrayList, MessageObject messageObject, long j, boolean z, SharedPreferences sharedPreferences) {
int i;
if (!DialogObject.isEncryptedDialog(j)) {
if (sharedPreferences.getBoolean(NotificationsSettingsFacade.PROPERTY_CUSTOM + j, false)) {
i = sharedPreferences.getInt("popup_" + j, 0);
} else {
i = 0;
}
if (i == 0) {
if (z) {
i = sharedPreferences.getInt("popupChannel", 0);
} else {
i = sharedPreferences.getInt(DialogObject.isChatDialog(j) ? "popupGroup" : "popupAll", 0);
}
} else if (i == 1) {
i = 3;
}
if (i != 0 && messageObject.messageOwner.peer_id.channel_id != 0 && !messageObject.isSupergroup()) {
i = 0;
}
if (i != 0) {
arrayList.add(0, messageObject);
}
return i;
}
i = 0;
if (i != 0) {
i = 0;
}
if (i != 0) {
}
return i;
}
public void processEditedMessages(final LongSparseArray<ArrayList<MessageObject>> longSparseArray) {
if (longSparseArray.size() == 0) {
return;
}
new ArrayList(0);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processEditedMessages$19(longSparseArray);
}
});
}
public void lambda$processEditedMessages$19(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 = messageObject.messageOwner.peer_id.channel_id;
SparseArray<MessageObject> sparseArray = this.pushMessagesDict.get(j != 0 ? -j : 0L);
if (sparseArray == null) {
break;
}
MessageObject messageObject2 = sparseArray.get(messageObject.getId());
if (messageObject2 != null && messageObject2.isReactionPush) {
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> arrayList, final boolean z, final boolean z2, final CountDownLatch countDownLatch) {
if (!arrayList.isEmpty()) {
final ArrayList arrayList2 = new ArrayList(0);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processNewMessages$23(arrayList, arrayList2, z2, z, countDownLatch);
}
});
} else if (countDownLatch != null) {
countDownLatch.countDown();
}
}
public void lambda$processNewMessages$23(ArrayList arrayList, final ArrayList arrayList2, boolean z, boolean z2, CountDownLatch countDownLatch) {
boolean z3;
int i;
int i2;
Integer num;
boolean z4;
long j;
boolean z5;
boolean z6;
MessageObject messageObject;
int i3;
boolean z7;
MessageObject messageObject2;
long j2;
SparseArray<MessageObject> sparseArray;
long j3;
int i4;
long j4;
long j5;
long j6;
boolean z8;
boolean z9;
long j7;
SparseArray<MessageObject> sparseArray2;
MessageObject messageObject3;
ArrayList arrayList3 = arrayList;
LongSparseArray longSparseArray = new LongSparseArray();
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
boolean z10 = true;
boolean z11 = notificationsSettings.getBoolean("PinnedMessages", true);
int i5 = 0;
int i6 = 0;
boolean z12 = false;
boolean z13 = false;
boolean z14 = false;
boolean z15 = false;
while (i6 < arrayList.size()) {
MessageObject messageObject4 = (MessageObject) arrayList3.get(i6);
if (messageObject4.messageOwner != null) {
if (!messageObject4.isImportedForward()) {
TLRPC$Message tLRPC$Message = messageObject4.messageOwner;
TLRPC$MessageAction tLRPC$MessageAction = tLRPC$Message.action;
if (!(tLRPC$MessageAction instanceof TLRPC$TL_messageActionSetMessagesTTL)) {
if (tLRPC$Message.silent) {
if (!(tLRPC$MessageAction instanceof TLRPC$TL_messageActionContactSignUp)) {
}
}
}
}
z4 = z11;
i3 = i6;
z7 = z12;
z12 = z7;
i6 = i3 + 1;
arrayList3 = arrayList;
z11 = z4;
z10 = true;
}
if (!MessageObject.isTopicActionMessage(messageObject4)) {
if (messageObject4.isStoryPush) {
long currentTimeMillis = messageObject4.messageOwner == null ? System.currentTimeMillis() : r0.date * 1000;
long dialogId = messageObject4.getDialogId();
int id = messageObject4.getId();
StoryNotification storyNotification = this.storyPushMessagesDict.get(dialogId);
if (storyNotification != null) {
storyNotification.dateByIds.put(Integer.valueOf(id), new Pair<>(Long.valueOf(currentTimeMillis), Long.valueOf(currentTimeMillis + 86400000)));
boolean z16 = storyNotification.hidden;
boolean z17 = messageObject4.isStoryPushHidden;
if (z16 != z17) {
storyNotification.hidden = z17;
z15 = z10;
}
storyNotification.date = storyNotification.getLeastDate();
getMessagesStorage().putStoryPushMessage(storyNotification);
z13 = z10;
} else {
StoryNotification storyNotification2 = new StoryNotification(dialogId, messageObject4.localName, id, currentTimeMillis);
storyNotification2.hidden = messageObject4.isStoryPushHidden;
this.storyPushMessages.add(storyNotification2);
this.storyPushMessagesDict.put(dialogId, storyNotification2);
getMessagesStorage().putStoryPushMessage(storyNotification2);
z12 = z10;
z15 = z12;
}
Collections.sort(this.storyPushMessages, Comparator$CC.comparingLong(new ToLongFunction() {
@Override
public final long applyAsLong(Object obj) {
long j8;
j8 = ((NotificationsController.StoryNotification) obj).date;
return j8;
}
}));
z4 = z11;
i3 = i6;
} else {
int id2 = messageObject4.getId();
if (messageObject4.isFcmMessage()) {
j = messageObject4.messageOwner.random_id;
z4 = z11;
} else {
z4 = z11;
j = 0;
}
long dialogId2 = messageObject4.getDialogId();
if (messageObject4.isFcmMessage()) {
z6 = messageObject4.localChannel;
} else if (DialogObject.isChatDialog(dialogId2)) {
TLRPC$Chat chat = getMessagesController().getChat(Long.valueOf(-dialogId2));
z6 = ChatObject.isChannel(chat) && !chat.megagroup;
} else {
z5 = false;
long j8 = messageObject4.messageOwner.peer_id.channel_id;
long j9 = j8 == 0 ? -j8 : 0L;
SparseArray<MessageObject> sparseArray3 = this.pushMessagesDict.get(j9);
messageObject = sparseArray3 == null ? sparseArray3.get(id2) : null;
long j10 = j;
if (messageObject == null) {
long j11 = messageObject4.messageOwner.random_id;
if (j11 != 0 && (messageObject = this.fcmRandomMessagesDict.get(j11)) != null) {
i3 = i6;
z7 = z12;
this.fcmRandomMessagesDict.remove(messageObject4.messageOwner.random_id);
messageObject2 = messageObject;
if (messageObject2 != null) {
if (messageObject2.isFcmMessage()) {
if (sparseArray3 == null) {
sparseArray3 = new SparseArray<>();
this.pushMessagesDict.put(j9, sparseArray3);
}
sparseArray3.put(id2, messageObject4);
int indexOf = this.pushMessages.indexOf(messageObject2);
if (indexOf >= 0) {
this.pushMessages.set(indexOf, messageObject4);
messageObject3 = messageObject4;
i5 = addToPopupMessages(arrayList2, messageObject4, dialogId2, z5, notificationsSettings);
} else {
messageObject3 = messageObject4;
}
if (z) {
boolean z18 = messageObject3.localEdit;
if (z18) {
getMessagesStorage().putPushMessage(messageObject3);
}
z13 = z18;
}
}
} else if (!z13) {
if (z) {
getMessagesStorage().putPushMessage(messageObject4);
}
long topicId = MessageObject.getTopicId(this.currentAccount, messageObject4.messageOwner, getMessagesController().isForum(messageObject4));
if (dialogId2 != this.openedDialogId || !ApplicationLoader.isScreenOn) {
TLRPC$Message tLRPC$Message2 = messageObject4.messageOwner;
if (!tLRPC$Message2.mentioned) {
j2 = dialogId2;
} else if (z4 || !(tLRPC$Message2.action instanceof TLRPC$TL_messageActionPinMessage)) {
j2 = messageObject4.getFromChatId();
}
if (isPersonalMessage(messageObject4)) {
this.personalCount++;
}
DialogObject.isChatDialog(j2);
int indexOfKey = longSparseArray.indexOfKey(j2);
if (indexOfKey >= 0 && topicId == 0) {
z9 = ((Boolean) longSparseArray.valueAt(indexOfKey)).booleanValue();
sparseArray = sparseArray3;
i4 = i5;
j3 = dialogId2;
j4 = j10;
j5 = j9;
j6 = j2;
} else {
sparseArray = sparseArray3;
j3 = dialogId2;
long j12 = j2;
i4 = i5;
j4 = j10;
j5 = j9;
int notifyOverride = getNotifyOverride(notificationsSettings, j2, topicId);
if (notifyOverride == -1) {
j6 = j12;
z8 = isGlobalNotificationsEnabled(j6, Boolean.valueOf(z5));
} else {
j6 = j12;
z8 = notifyOverride != 2;
}
z9 = z8;
longSparseArray.put(j6, Boolean.valueOf(z9));
}
if (z9) {
if (z) {
j7 = j6;
i5 = i4;
} else {
j7 = j6;
i5 = addToPopupMessages(arrayList2, messageObject4, j6, z5, notificationsSettings);
}
if (!z14) {
z14 = messageObject4.messageOwner.from_scheduled;
}
this.delayedPushMessages.add(messageObject4);
appendMessage(messageObject4);
if (id2 != 0) {
if (sparseArray == null) {
sparseArray2 = new SparseArray<>();
this.pushMessagesDict.put(j5, sparseArray2);
} else {
sparseArray2 = sparseArray;
}
sparseArray2.put(id2, messageObject4);
} else if (j4 != 0) {
this.fcmRandomMessagesDict.put(j4, messageObject4);
}
if (j3 != j7) {
long j13 = j3;
Integer num2 = this.pushDialogsOverrideMention.get(j13);
this.pushDialogsOverrideMention.put(j13, Integer.valueOf(num2 == null ? 1 : num2.intValue() + 1));
}
} else {
j7 = j6;
i5 = i4;
}
if (messageObject4.isReactionPush) {
SparseBooleanArray sparseBooleanArray = new SparseBooleanArray();
sparseBooleanArray.put(id2, true);
getMessagesController().checkUnreadReactions(j7, topicId, sparseBooleanArray);
}
z12 = true;
} else if (!z) {
playInChatSound();
}
}
z12 = z7;
}
}
i3 = i6;
z7 = z12;
messageObject2 = messageObject;
if (messageObject2 != null) {
}
z12 = z7;
}
z5 = z6;
long j82 = messageObject4.messageOwner.peer_id.channel_id;
if (j82 == 0) {
}
SparseArray<MessageObject> sparseArray32 = this.pushMessagesDict.get(j9);
if (sparseArray32 == null) {
}
long j102 = j;
if (messageObject == null) {
}
i3 = i6;
z7 = z12;
messageObject2 = messageObject;
if (messageObject2 != null) {
}
z12 = z7;
}
i6 = i3 + 1;
arrayList3 = arrayList;
z11 = z4;
z10 = true;
}
z4 = z11;
i3 = i6;
z7 = z12;
z12 = z7;
i6 = i3 + 1;
arrayList3 = arrayList;
z11 = z4;
z10 = true;
}
final int i7 = i5;
boolean z19 = z12;
if (z19) {
this.notifyCheck = z2;
}
if (!arrayList2.isEmpty() && !AndroidUtilities.needShowPasscode() && !SharedConfig.isWaitingForPasscodeEnter) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processNewMessages$21(arrayList2, i7);
}
});
}
if (z || z14) {
if (z13) {
this.delayedPushMessages.clear();
showOrUpdateNotification(this.notifyCheck);
} else if (z19) {
MessageObject messageObject5 = (MessageObject) arrayList.get(0);
long dialogId3 = messageObject5.getDialogId();
long topicId2 = MessageObject.getTopicId(this.currentAccount, messageObject5.messageOwner, getMessagesController().isForum(dialogId3));
Boolean valueOf = messageObject5.isFcmMessage() ? Boolean.valueOf(messageObject5.localChannel) : null;
int i8 = this.total_unread_count;
int notifyOverride2 = getNotifyOverride(notificationsSettings, dialogId3, topicId2);
if (notifyOverride2 == -1) {
z3 = isGlobalNotificationsEnabled(dialogId3, valueOf);
} else {
z3 = notifyOverride2 != 2;
}
Integer num3 = this.pushDialogs.get(dialogId3);
if (num3 != null) {
i = 1;
i2 = num3.intValue() + 1;
} else {
i = 1;
i2 = 1;
}
if (this.notifyCheck && !z3 && (num = this.pushDialogsOverrideMention.get(dialogId3)) != null && num.intValue() != 0) {
i2 = num.intValue();
z3 = i == true ? 1 : 0;
}
if ((!z3 || messageObject5.isStoryPush) ? false : i == true ? 1 : 0) {
if (getMessagesController().isForum(dialogId3)) {
int i9 = this.total_unread_count - ((num3 == null || num3.intValue() <= 0) ? 0 : i == true ? 1 : 0);
this.total_unread_count = i9;
if (i2 <= 0) {
i = 0;
}
this.total_unread_count = i9 + i;
} else {
if (num3 != null) {
this.total_unread_count -= num3.intValue();
}
this.total_unread_count += i2;
}
this.pushDialogs.put(dialogId3, Integer.valueOf(i2));
}
if (i8 != this.total_unread_count || z15) {
this.delayedPushMessages.clear();
showOrUpdateNotification(this.notifyCheck);
final int size = this.pushDialogs.size();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processNewMessages$22(size);
}
});
}
this.notifyCheck = false;
if (this.showBadgeNumber) {
setBadge(getTotalAllUnreadCount());
}
}
}
if (z15) {
updateStoryPushesRunnable();
}
if (countDownLatch != null) {
countDownLatch.countDown();
}
}
public void lambda$processNewMessages$21(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$22(int i) {
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.notificationsCountUpdated, Integer.valueOf(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 void processDialogsUpdateRead(final LongSparseIntArray longSparseIntArray) {
final ArrayList arrayList = new ArrayList();
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processDialogsUpdateRead$26(longSparseIntArray, arrayList);
}
});
}
public void lambda$processDialogsUpdateRead$26(LongSparseIntArray longSparseIntArray, final ArrayList arrayList) {
int i;
boolean z;
boolean z2;
Integer num;
int i2 = this.total_unread_count;
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
int i3 = 0;
while (true) {
if (i3 >= longSparseIntArray.size()) {
break;
}
long keyAt = longSparseIntArray.keyAt(i3);
Integer num2 = this.pushDialogs.get(keyAt);
int i4 = longSparseIntArray.get(keyAt);
if (DialogObject.isChatDialog(keyAt)) {
TLRPC$Chat chat = getMessagesController().getChat(Long.valueOf(-keyAt));
if (chat == null || chat.min || ChatObject.isNotInChat(chat)) {
i4 = 0;
}
if (chat != null) {
z = chat.forum;
i = i4;
if (!z) {
int notifyOverride = getNotifyOverride(notificationsSettings, keyAt, 0L);
if (notifyOverride == -1) {
z2 = isGlobalNotificationsEnabled(keyAt);
} else if (notifyOverride == 2) {
z2 = false;
}
if (this.notifyCheck && !z2 && (num = this.pushDialogsOverrideMention.get(keyAt)) != null && num.intValue() != 0) {
i = num.intValue();
z2 = true;
}
if (i == 0) {
this.smartNotificationsDialogs.remove(keyAt);
}
if (i < 0) {
if (num2 == null) {
i3++;
} else {
i = num2.intValue() + i;
}
}
if ((!z2 || i == 0) && num2 != null) {
if (getMessagesController().isForum(keyAt)) {
this.total_unread_count -= num2.intValue() > 0 ? 1 : 0;
} else {
this.total_unread_count -= num2.intValue();
}
}
if (i == 0) {
this.pushDialogs.remove(keyAt);
this.pushDialogsOverrideMention.remove(keyAt);
int i5 = 0;
while (i5 < this.pushMessages.size()) {
MessageObject messageObject = this.pushMessages.get(i5);
if (!messageObject.messageOwner.from_scheduled && messageObject.getDialogId() == keyAt) {
if (isPersonalMessage(messageObject)) {
this.personalCount--;
}
this.pushMessages.remove(i5);
i5--;
this.delayedPushMessages.remove(messageObject);
long j = messageObject.messageOwner.peer_id.channel_id;
long j2 = j != 0 ? -j : 0L;
SparseArray<MessageObject> sparseArray = this.pushMessagesDict.get(j2);
if (sparseArray != null) {
sparseArray.remove(messageObject.getId());
if (sparseArray.size() == 0) {
this.pushMessagesDict.remove(j2);
}
}
arrayList.add(messageObject);
}
i5++;
}
} else if (z2) {
if (getMessagesController().isForum(keyAt)) {
this.total_unread_count += i <= 0 ? 0 : 1;
} else {
this.total_unread_count += i;
}
this.pushDialogs.put(keyAt, Integer.valueOf(i));
}
i3++;
}
z2 = true;
if (this.notifyCheck) {
i = num.intValue();
z2 = true;
}
if (i == 0) {
}
if (i < 0) {
}
if (!z2) {
}
if (getMessagesController().isForum(keyAt)) {
}
if (i == 0) {
}
i3++;
}
}
i = i4;
z = false;
if (!z) {
}
z2 = true;
if (this.notifyCheck) {
}
if (i == 0) {
}
if (i < 0) {
}
if (!z2) {
}
if (getMessagesController().isForum(keyAt)) {
}
if (i == 0) {
}
i3++;
}
if (!arrayList.isEmpty()) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processDialogsUpdateRead$24(arrayList);
}
});
}
if (i2 != 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$processDialogsUpdateRead$25(size);
}
});
}
this.notifyCheck = false;
if (this.showBadgeNumber) {
setBadge(getTotalAllUnreadCount());
}
}
public void lambda$processDialogsUpdateRead$24(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$25(int i) {
NotificationCenter.getGlobalInstance().lambda$postNotificationNameOnUIThread$1(NotificationCenter.notificationsCountUpdated, Integer.valueOf(this.currentAccount));
getNotificationCenter().lambda$postNotificationNameOnUIThread$1(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(i));
}
public void processLoadedUnreadMessages(final LongSparseArray<Integer> longSparseArray, final ArrayList<TLRPC$Message> arrayList, final ArrayList<MessageObject> arrayList2, ArrayList<TLRPC$User> arrayList3, ArrayList<TLRPC$Chat> arrayList4, ArrayList<TLRPC$EncryptedChat> arrayList5, final Collection<StoryNotification> collection) {
getMessagesController().putUsers(arrayList3, true);
getMessagesController().putChats(arrayList4, true);
getMessagesController().putEncryptedChats(arrayList5, true);
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$processLoadedUnreadMessages$29(arrayList, longSparseArray, arrayList2, collection);
}
});
}
public void lambda$processLoadedUnreadMessages$29(ArrayList arrayList, LongSparseArray longSparseArray, ArrayList arrayList2, Collection collection) {
int i;
long j;
long j2;
boolean z;
boolean z2;
TLRPC$MessageFwdHeader tLRPC$MessageFwdHeader;
SharedPreferences sharedPreferences;
MessageObject messageObject;
SparseArray<MessageObject> sparseArray;
long j3;
long j4;
int i2;
TLRPC$Message tLRPC$Message;
boolean z3;
boolean z4;
SparseArray<MessageObject> sparseArray2;
ArrayList arrayList3 = arrayList;
this.pushDialogs.clear();
this.pushMessages.clear();
this.pushMessagesDict.clear();
this.storyPushMessages.clear();
this.storyPushMessagesDict.clear();
boolean z5 = false;
this.total_unread_count = 0;
this.personalCount = 0;
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
LongSparseArray longSparseArray2 = new LongSparseArray();
long j5 = 0;
if (arrayList3 != null) {
int i3 = 0;
while (i3 < arrayList.size()) {
TLRPC$Message tLRPC$Message2 = (TLRPC$Message) arrayList3.get(i3);
if (tLRPC$Message2 != null && ((tLRPC$MessageFwdHeader = tLRPC$Message2.fwd_from) == null || !tLRPC$MessageFwdHeader.imported)) {
TLRPC$MessageAction tLRPC$MessageAction = tLRPC$Message2.action;
if (!(tLRPC$MessageAction instanceof TLRPC$TL_messageActionSetMessagesTTL) && (!tLRPC$Message2.silent || (!(tLRPC$MessageAction instanceof TLRPC$TL_messageActionContactSignUp) && !(tLRPC$MessageAction instanceof TLRPC$TL_messageActionUserJoined)))) {
long j6 = tLRPC$Message2.peer_id.channel_id;
long j7 = j6 != j5 ? -j6 : j5;
SparseArray<MessageObject> sparseArray3 = this.pushMessagesDict.get(j7);
if (sparseArray3 == null || sparseArray3.indexOfKey(tLRPC$Message2.id) < 0) {
MessageObject messageObject2 = new MessageObject(this.currentAccount, tLRPC$Message2, z5, z5);
if (isPersonalMessage(messageObject2)) {
this.personalCount++;
}
sharedPreferences = notificationsSettings;
long dialogId = messageObject2.getDialogId();
long topicId = MessageObject.getTopicId(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) {
z4 = ((Boolean) longSparseArray2.valueAt(indexOfKey)).booleanValue();
messageObject = messageObject2;
sparseArray = sparseArray3;
i2 = i3;
j3 = dialogId;
j4 = j7;
tLRPC$Message = tLRPC$Message2;
} else {
messageObject = messageObject2;
sparseArray = sparseArray3;
j3 = dialogId;
j4 = j7;
i2 = i3;
tLRPC$Message = tLRPC$Message2;
int notifyOverride = getNotifyOverride(sharedPreferences, fromChatId, topicId);
if (notifyOverride == -1) {
z3 = isGlobalNotificationsEnabled(fromChatId);
} else {
z3 = notifyOverride != 2;
}
z4 = z3;
longSparseArray2.put(fromChatId, Boolean.valueOf(z4));
}
if (z4 && (fromChatId != this.openedDialogId || !ApplicationLoader.isScreenOn)) {
if (sparseArray == null) {
sparseArray2 = new SparseArray<>();
this.pushMessagesDict.put(j4, sparseArray2);
} else {
sparseArray2 = sparseArray;
}
sparseArray2.put(tLRPC$Message.id, messageObject);
appendMessage(messageObject);
if (j3 != fromChatId) {
long j8 = j3;
Integer num = this.pushDialogsOverrideMention.get(j8);
this.pushDialogsOverrideMention.put(j8, Integer.valueOf(num == null ? 1 : num.intValue() + 1));
}
}
i3 = i2 + 1;
arrayList3 = arrayList;
notificationsSettings = sharedPreferences;
z5 = false;
j5 = 0;
}
}
}
i2 = i3;
sharedPreferences = notificationsSettings;
i3 = i2 + 1;
arrayList3 = arrayList;
notificationsSettings = sharedPreferences;
z5 = false;
j5 = 0;
}
}
SharedPreferences sharedPreferences2 = notificationsSettings;
for (int i4 = 0; i4 < longSparseArray.size(); i4++) {
long keyAt = longSparseArray.keyAt(i4);
int indexOfKey2 = longSparseArray2.indexOfKey(keyAt);
if (indexOfKey2 >= 0) {
z2 = ((Boolean) longSparseArray2.valueAt(indexOfKey2)).booleanValue();
} else {
int notifyOverride2 = getNotifyOverride(sharedPreferences2, keyAt, 0L);
if (notifyOverride2 == -1) {
z2 = isGlobalNotificationsEnabled(keyAt);
} else {
z2 = notifyOverride2 != 2;
}
longSparseArray2.put(keyAt, Boolean.valueOf(z2));
}
if (z2) {
int intValue = ((Integer) longSparseArray.valueAt(i4)).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;
}
}
}
ArrayList arrayList4 = arrayList2;
if (arrayList4 != null) {
int i5 = 0;
while (i5 < arrayList2.size()) {
MessageObject messageObject3 = (MessageObject) arrayList4.get(i5);
int id = messageObject3.getId();
if (this.pushMessagesDict.indexOfKey(id) >= 0) {
i = i5;
} else {
if (isPersonalMessage(messageObject3)) {
this.personalCount++;
}
long dialogId2 = messageObject3.getDialogId();
long topicId2 = MessageObject.getTopicId(this.currentAccount, messageObject3.messageOwner, getMessagesController().isForum(messageObject3));
TLRPC$Message tLRPC$Message3 = messageObject3.messageOwner;
long j9 = tLRPC$Message3.random_id;
long fromChatId2 = tLRPC$Message3.mentioned ? messageObject3.getFromChatId() : dialogId2;
int indexOfKey3 = longSparseArray2.indexOfKey(fromChatId2);
if (indexOfKey3 >= 0 && topicId2 == 0) {
boolean booleanValue = ((Boolean) longSparseArray2.valueAt(indexOfKey3)).booleanValue();
i = i5;
j = j9;
j2 = fromChatId2;
z = booleanValue;
} else {
long j10 = fromChatId2;
i = i5;
j = j9;
int notifyOverride3 = getNotifyOverride(sharedPreferences2, j10, topicId2);
if (notifyOverride3 == -1) {
j2 = j10;
z = isGlobalNotificationsEnabled(j2);
} else {
j2 = j10;
z = notifyOverride3 != 2;
}
longSparseArray2.put(j2, Boolean.valueOf(z));
}
if (z && (j2 != this.openedDialogId || !ApplicationLoader.isScreenOn)) {
if (id != 0) {
long j11 = messageObject3.messageOwner.peer_id.channel_id;
long j12 = j11 != 0 ? -j11 : 0L;
SparseArray<MessageObject> sparseArray4 = this.pushMessagesDict.get(j12);
if (sparseArray4 == null) {
sparseArray4 = new SparseArray<>();
this.pushMessagesDict.put(j12, sparseArray4);
}
sparseArray4.put(id, messageObject3);
} else if (j != 0) {
this.fcmRandomMessagesDict.put(j, messageObject3);
}
appendMessage(messageObject3);
if (dialogId2 != j2) {
Integer num2 = this.pushDialogsOverrideMention.get(dialogId2);
this.pushDialogsOverrideMention.put(dialogId2, Integer.valueOf(num2 == null ? 1 : num2.intValue() + 1));
}
Integer num3 = this.pushDialogs.get(j2);
int intValue2 = num3 != null ? num3.intValue() + 1 : 1;
if (getMessagesController().isForum(j2)) {
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(j2, Integer.valueOf(intValue2));
i5 = i + 1;
arrayList4 = arrayList2;
}
}
i5 = i + 1;
arrayList4 = arrayList2;
}
}
if (collection != null) {
Iterator it = collection.iterator();
while (it.hasNext()) {
StoryNotification storyNotification = (StoryNotification) it.next();
long j13 = storyNotification.dialogId;
StoryNotification storyNotification2 = 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() {
@Override
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$28(size);
}
});
showOrUpdateNotification(SystemClock.elapsedRealtime() / 1000 < 60);
if (this.showBadgeNumber) {
setBadge(getTotalAllUnreadCount());
}
}
public void lambda$processLoadedUnreadMessages$28(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(this.currentAccount));
getNotificationCenter().lambda$postNotificationNameOnUIThread$1(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(i));
}
private int getTotalAllUnreadCount() {
int size;
int i = 0;
for (int i2 = 0; i2 < 4; i2++) {
if (UserConfig.getInstance(i2).isClientActivated()) {
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 tLRPC$Dialog = (TLRPC$Dialog) arrayList.get(i3);
if ((tLRPC$Dialog == null || !DialogObject.isChatDialog(tLRPC$Dialog.id) || !ChatObject.isNotInChat(getMessagesController().getChat(Long.valueOf(-tLRPC$Dialog.id)))) && tLRPC$Dialog != null) {
i += MessagesController.getInstance(i2).getDialogUnreadCount(tLRPC$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 tLRPC$Dialog2 = MessagesController.getInstance(i2).allDialogs.get(i4);
if ((!DialogObject.isChatDialog(tLRPC$Dialog2.id) || !ChatObject.isNotInChat(getMessagesController().getChat(Long.valueOf(-tLRPC$Dialog2.id)))) && MessagesController.getInstance(i2).getDialogUnreadCount(tLRPC$Dialog2) != 0) {
i++;
}
}
} catch (Exception e2) {
FileLog.e((Throwable) e2, false);
}
} else {
size = notificationsController.pushDialogs.size();
}
i += size;
}
}
}
return i;
}
public void lambda$updateBadge$30() {
setBadge(getTotalAllUnreadCount());
}
public void updateBadge() {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$updateBadge$30();
}
});
}
private void setBadge(int i) {
if (this.lastBadgeCount == i) {
return;
}
this.lastBadgeCount = i;
NotificationBadge.applyCount(i);
}
private String getShortStringForMessage(MessageObject messageObject, String[] strArr, boolean[] zArr) {
String str;
String str2;
String str3;
String str4;
SharedPreferences sharedPreferences;
String str5;
char c;
TLRPC$Chat tLRPC$Chat;
SharedPreferences sharedPreferences2;
boolean z;
TLRPC$MessageFwdHeader tLRPC$MessageFwdHeader;
TLRPC$Peer tLRPC$Peer;
TLRPC$Chat chat;
String str6;
TLRPC$MessageFwdHeader tLRPC$MessageFwdHeader2;
TLRPC$Peer tLRPC$Peer2;
boolean z2;
if (AndroidUtilities.needShowPasscode() || SharedConfig.isWaitingForPasscodeEnter) {
return LocaleController.getString("NotificationHiddenMessage", R.string.NotificationHiddenMessage);
}
TLRPC$Message tLRPC$Message = messageObject.messageOwner;
long j = tLRPC$Message.dialog_id;
TLRPC$Peer tLRPC$Peer3 = tLRPC$Message.peer_id;
long j2 = tLRPC$Peer3.chat_id;
if (j2 == 0) {
j2 = tLRPC$Peer3.channel_id;
}
long j3 = tLRPC$Peer3.user_id;
if (zArr != null) {
zArr[0] = true;
}
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
boolean z3 = notificationsSettings.getBoolean(NotificationsSettingsFacade.PROPERTY_CONTENT_PREVIEW + j, true);
if (messageObject.isFcmMessage()) {
if (j2 == 0 && j3 != 0) {
if (Build.VERSION.SDK_INT > 27) {
z2 = false;
strArr[0] = messageObject.localName;
} else {
z2 = false;
}
if (!z3 || !notificationsSettings.getBoolean("EnablePreviewAll", true)) {
if (zArr != null) {
zArr[z2 ? 1 : 0] = z2;
}
return LocaleController.getString("Message", R.string.Message);
}
} else if (j2 != 0) {
if (messageObject.messageOwner.peer_id.channel_id == 0 || messageObject.isSupergroup()) {
strArr[0] = messageObject.localUserName;
} else if (Build.VERSION.SDK_INT > 27) {
strArr[0] = messageObject.localName;
}
if (z3) {
boolean z4 = !messageObject.localChannel ? true : true;
if (messageObject.localChannel) {
}
}
if (zArr != null) {
zArr[0] = false;
}
return (messageObject.messageOwner.peer_id.channel_id == 0 || messageObject.isSupergroup()) ? LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, messageObject.localUserName, messageObject.localName) : LocaleController.formatString("ChannelMessageNoText", R.string.ChannelMessageNoText, messageObject.localName);
}
return replaceSpoilers(messageObject);
}
long clientUserId = getUserConfig().getClientUserId();
if (j3 == 0) {
j3 = messageObject.getFromChatId();
if (j3 == 0) {
j3 = -j2;
}
} else if (j3 == clientUserId) {
j3 = messageObject.getFromChatId();
}
if (j == 0) {
if (j2 != 0) {
j = -j2;
} else if (j3 != 0) {
j = j3;
}
}
if (UserObject.isReplyUser(j) && (tLRPC$MessageFwdHeader2 = messageObject.messageOwner.fwd_from) != null && (tLRPC$Peer2 = tLRPC$MessageFwdHeader2.from_id) != null) {
j3 = MessageObject.getPeerId(tLRPC$Peer2);
}
if (j3 > 0) {
str2 = "Message";
TLRPC$User user = getMessagesController().getUser(Long.valueOf(j3));
if (user != null) {
str6 = UserObject.getUserName(user);
if (j2 != 0) {
strArr[0] = str6;
str = "EnablePreviewGroup";
str3 = "EnablePreviewChannel";
} else {
str3 = "EnablePreviewChannel";
str = "EnablePreviewGroup";
if (Build.VERSION.SDK_INT > 27) {
strArr[0] = str6;
} else {
strArr[0] = null;
}
}
} else {
str = "EnablePreviewGroup";
str3 = "EnablePreviewChannel";
str6 = null;
}
str5 = str6;
str4 = "EnablePreviewAll";
sharedPreferences = notificationsSettings;
} else {
str = "EnablePreviewGroup";
str2 = "Message";
str3 = "EnablePreviewChannel";
str4 = "EnablePreviewAll";
sharedPreferences = notificationsSettings;
TLRPC$Chat chat2 = getMessagesController().getChat(Long.valueOf(-j3));
if (chat2 != null) {
str5 = chat2.title;
strArr[0] = str5;
} else {
str5 = null;
}
}
if (str5 != null && j3 > 0 && UserObject.isReplyUser(j) && (tLRPC$MessageFwdHeader = messageObject.messageOwner.fwd_from) != null && (tLRPC$Peer = tLRPC$MessageFwdHeader.saved_from_peer) != null) {
long peerId = MessageObject.getPeerId(tLRPC$Peer);
if (DialogObject.isChatDialog(peerId) && (chat = getMessagesController().getChat(Long.valueOf(-peerId))) != null) {
str5 = str5 + " @ " + chat.title;
if (strArr[0] != null) {
strArr[0] = str5;
}
}
}
if (str5 == null) {
return null;
}
if (j2 != 0) {
tLRPC$Chat = getMessagesController().getChat(Long.valueOf(j2));
if (tLRPC$Chat == null) {
return null;
}
if (!ChatObject.isChannel(tLRPC$Chat) || tLRPC$Chat.megagroup || Build.VERSION.SDK_INT > 27) {
c = 0;
} else {
c = 0;
strArr[0] = null;
}
} else {
c = 0;
tLRPC$Chat = null;
}
if (DialogObject.isEncryptedDialog(j)) {
strArr[c] = null;
return LocaleController.getString("NotificationHiddenMessage", R.string.NotificationHiddenMessage);
}
boolean z5 = ChatObject.isChannel(tLRPC$Chat) && !tLRPC$Chat.megagroup;
if (z3) {
if (j2 != 0 || j3 == 0) {
sharedPreferences2 = sharedPreferences;
z = true;
} else {
sharedPreferences2 = sharedPreferences;
z = true;
}
if (j2 != 0) {
if (!z5) {
}
if (z5) {
}
}
}
String str7 = str2;
if (zArr != null) {
zArr[0] = false;
}
return LocaleController.getString(str7, R.string.Message);
}
private String replaceSpoilers(MessageObject messageObject) {
TLRPC$Message tLRPC$Message;
String str;
if (messageObject == null || (tLRPC$Message = messageObject.messageOwner) == null || (str = tLRPC$Message.message) == null || tLRPC$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 tLRPC$TL_messageEntitySpoiler = (TLRPC$TL_messageEntitySpoiler) messageObject.messageOwner.entities.get(i);
for (int i2 = 0; i2 < tLRPC$TL_messageEntitySpoiler.length; i2++) {
int i3 = tLRPC$TL_messageEntitySpoiler.offset + i2;
char[] cArr = this.spoilerChars;
sb.setCharAt(i3, cArr[i2 % cArr.length]);
}
}
}
return sb.toString();
}
private String getStringForMessage(MessageObject messageObject, boolean z, boolean[] zArr, boolean[] zArr2) {
String str;
String str2;
String str3;
TLRPC$Chat tLRPC$Chat;
String formatString;
char c;
boolean z2;
String formatString2;
char c2;
boolean z3;
if (AndroidUtilities.needShowPasscode() || SharedConfig.isWaitingForPasscodeEnter) {
return LocaleController.getString("YouHaveNewMessage", R.string.YouHaveNewMessage);
}
if (messageObject.isStoryPush || messageObject.isStoryMentionPush) {
return "!" + messageObject.messageOwner.message;
}
TLRPC$Message tLRPC$Message = messageObject.messageOwner;
long j = tLRPC$Message.dialog_id;
TLRPC$Peer tLRPC$Peer = tLRPC$Message.peer_id;
long j2 = tLRPC$Peer.chat_id;
if (j2 == 0) {
j2 = tLRPC$Peer.channel_id;
}
long j3 = tLRPC$Peer.user_id;
if (zArr2 != null) {
zArr2[0] = true;
}
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
boolean z4 = notificationsSettings.getBoolean(NotificationsSettingsFacade.PROPERTY_CONTENT_PREVIEW + j, true);
if (messageObject.isFcmMessage()) {
if (j2 == 0 && j3 != 0) {
if (!z4 || !notificationsSettings.getBoolean("EnablePreviewAll", true)) {
if (zArr2 != null) {
zArr2[0] = false;
}
return LocaleController.formatString("NotificationMessageNoText", R.string.NotificationMessageNoText, messageObject.localName);
}
z3 = true;
} else {
if (j2 != 0) {
if (z4) {
boolean z5 = !messageObject.localChannel ? true : true;
if (!messageObject.localChannel) {
z3 = z5;
}
}
if (zArr2 != null) {
zArr2[0] = false;
}
return (messageObject.messageOwner.peer_id.channel_id == 0 || messageObject.isSupergroup()) ? LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, messageObject.localUserName, messageObject.localName) : LocaleController.formatString("ChannelMessageNoText", R.string.ChannelMessageNoText, messageObject.localName);
}
c2 = 0;
z3 = true;
zArr[c2] = z3;
return (String) messageObject.messageText;
}
c2 = 0;
zArr[c2] = z3;
return (String) messageObject.messageText;
}
long clientUserId = getUserConfig().getClientUserId();
if (j3 == 0) {
j3 = messageObject.getFromChatId();
if (j3 == 0) {
j3 = -j2;
}
} else if (j3 == clientUserId) {
j3 = messageObject.getFromChatId();
}
if (j == 0) {
if (j2 != 0) {
j = -j2;
} else if (j3 != 0) {
j = j3;
}
}
String str4 = null;
if (j3 > 0) {
if (!messageObject.messageOwner.from_scheduled) {
str = "NotificationMessageGroupNoText";
TLRPC$User user = getMessagesController().getUser(Long.valueOf(j3));
str3 = user != null ? UserObject.getUserName(user) : null;
} else if (j == clientUserId) {
str = "NotificationMessageGroupNoText";
str3 = LocaleController.getString("MessageScheduledReminderNotification", R.string.MessageScheduledReminderNotification);
} else {
str = "NotificationMessageGroupNoText";
str3 = LocaleController.getString("NotificationMessageScheduledName", R.string.NotificationMessageScheduledName);
}
str2 = "NotificationMessageNoText";
} else {
str = "NotificationMessageGroupNoText";
str2 = "NotificationMessageNoText";
TLRPC$Chat chat = getMessagesController().getChat(Long.valueOf(-j3));
str3 = chat != null ? chat.title : null;
}
if (str3 == null) {
return null;
}
if (j2 != 0) {
tLRPC$Chat = getMessagesController().getChat(Long.valueOf(j2));
if (tLRPC$Chat == null) {
return null;
}
} else {
tLRPC$Chat = null;
}
if (DialogObject.isEncryptedDialog(j)) {
str4 = LocaleController.getString("YouHaveNewMessage", R.string.YouHaveNewMessage);
} else {
long j4 = j3;
if (j2 != 0 || j3 == 0) {
if (j2 != 0) {
boolean z6 = ChatObject.isChannel(tLRPC$Chat) && !tLRPC$Chat.megagroup;
if (z4) {
boolean z7 = !z6 ? true : true;
if (z6) {
}
}
String str5 = str;
if (zArr2 != null) {
zArr2[0] = false;
}
return (!ChatObject.isChannel(tLRPC$Chat) || tLRPC$Chat.megagroup) ? LocaleController.formatString(str5, R.string.NotificationMessageGroupNoText, str3, tLRPC$Chat.title) : LocaleController.formatString("ChannelMessageNoText", R.string.ChannelMessageNoText, str3);
}
} else if (z4 && notificationsSettings.getBoolean("EnablePreviewAll", true)) {
TLRPC$Message tLRPC$Message2 = messageObject.messageOwner;
if (tLRPC$Message2 instanceof TLRPC$TL_messageService) {
TLRPC$MessageAction tLRPC$MessageAction = tLRPC$Message2.action;
if (tLRPC$MessageAction instanceof TLRPC$TL_messageActionSetSameChatWallPaper) {
str4 = LocaleController.getString("WallpaperSameNotification", R.string.WallpaperSameNotification);
} else if (tLRPC$MessageAction instanceof TLRPC$TL_messageActionSetChatWallPaper) {
str4 = LocaleController.getString("WallpaperNotification", R.string.WallpaperNotification);
} else if (tLRPC$MessageAction instanceof TLRPC$TL_messageActionGeoProximityReached) {
str4 = messageObject.messageText.toString();
} else if ((tLRPC$MessageAction instanceof TLRPC$TL_messageActionUserJoined) || (tLRPC$MessageAction instanceof TLRPC$TL_messageActionContactSignUp)) {
str4 = LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, str3);
} else if (tLRPC$MessageAction instanceof TLRPC$TL_messageActionUserUpdatedPhoto) {
str4 = LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, str3);
} else if (tLRPC$MessageAction instanceof TLRPC$TL_messageActionLoginUnknownLocation) {
String formatString3 = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(messageObject.messageOwner.date * 1000), LocaleController.getInstance().formatterDay.format(messageObject.messageOwner.date * 1000));
int i = R.string.NotificationUnrecognizedDevice;
TLRPC$MessageAction tLRPC$MessageAction2 = messageObject.messageOwner.action;
str4 = LocaleController.formatString("NotificationUnrecognizedDevice", i, getUserConfig().getCurrentUser().first_name, formatString3, tLRPC$MessageAction2.title, tLRPC$MessageAction2.address);
} else if ((tLRPC$MessageAction instanceof TLRPC$TL_messageActionGameScore) || (tLRPC$MessageAction instanceof TLRPC$TL_messageActionPaymentSent)) {
str4 = messageObject.messageText.toString();
} else if (tLRPC$MessageAction instanceof TLRPC$TL_messageActionPhoneCall) {
if (tLRPC$MessageAction.video) {
str4 = LocaleController.getString("CallMessageVideoIncomingMissed", R.string.CallMessageVideoIncomingMissed);
} else {
str4 = LocaleController.getString("CallMessageIncomingMissed", R.string.CallMessageIncomingMissed);
}
} else if (tLRPC$MessageAction instanceof TLRPC$TL_messageActionSetChatTheme) {
String str6 = ((TLRPC$TL_messageActionSetChatTheme) tLRPC$MessageAction).emoticon;
if (!TextUtils.isEmpty(str6)) {
c = 0;
z2 = true;
if (j == clientUserId) {
formatString2 = LocaleController.formatString("ChangedChatThemeYou", R.string.ChatThemeChangedYou, str6);
} else {
formatString2 = LocaleController.formatString("ChangedChatThemeTo", R.string.ChatThemeChangedTo, str3, str6);
}
} else if (j == clientUserId) {
c = 0;
formatString2 = LocaleController.formatString("ChatThemeDisabledYou", R.string.ChatThemeDisabledYou, new Object[0]);
z2 = true;
} else {
c = 0;
z2 = true;
formatString2 = LocaleController.formatString("ChatThemeDisabled", R.string.ChatThemeDisabled, str3, str6);
}
str4 = formatString2;
zArr[c] = z2;
}
} else if (!messageObject.isMediaEmpty()) {
String str7 = str2;
TLRPC$Message tLRPC$Message3 = messageObject.messageOwner;
if (tLRPC$Message3.media instanceof TLRPC$TL_messageMediaPhoto) {
if (!z && Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(tLRPC$Message3.message)) {
str4 = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, str3, "🖼 " + messageObject.messageOwner.message);
zArr[0] = true;
} else if (messageObject.messageOwner.media.ttl_seconds != 0) {
str4 = LocaleController.formatString("NotificationMessageSDPhoto", R.string.NotificationMessageSDPhoto, str3);
} else {
str4 = LocaleController.formatString("NotificationMessagePhoto", R.string.NotificationMessagePhoto, str3);
}
} else if (messageObject.isVideo()) {
if (!z && Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(messageObject.messageOwner.message)) {
str4 = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, str3, "📹 " + messageObject.messageOwner.message);
zArr[0] = true;
} else if (messageObject.messageOwner.media.ttl_seconds != 0) {
str4 = LocaleController.formatString("NotificationMessageSDVideo", R.string.NotificationMessageSDVideo, str3);
} else {
str4 = LocaleController.formatString("NotificationMessageVideo", R.string.NotificationMessageVideo, str3);
}
} else if (messageObject.isGame()) {
str4 = LocaleController.formatString("NotificationMessageGame", R.string.NotificationMessageGame, str3, messageObject.messageOwner.media.game.title);
} else if (messageObject.isVoice()) {
str4 = LocaleController.formatString("NotificationMessageAudio", R.string.NotificationMessageAudio, str3);
} else if (messageObject.isRoundVideo()) {
str4 = LocaleController.formatString("NotificationMessageRound", R.string.NotificationMessageRound, str3);
} else if (messageObject.isMusic()) {
str4 = LocaleController.formatString("NotificationMessageMusic", R.string.NotificationMessageMusic, str3);
} else {
TLRPC$MessageMedia tLRPC$MessageMedia = messageObject.messageOwner.media;
if (tLRPC$MessageMedia instanceof TLRPC$TL_messageMediaContact) {
TLRPC$TL_messageMediaContact tLRPC$TL_messageMediaContact = (TLRPC$TL_messageMediaContact) tLRPC$MessageMedia;
str4 = LocaleController.formatString("NotificationMessageContact2", R.string.NotificationMessageContact2, str3, ContactsController.formatName(tLRPC$TL_messageMediaContact.first_name, tLRPC$TL_messageMediaContact.last_name));
} else if (tLRPC$MessageMedia instanceof TLRPC$TL_messageMediaGiveaway) {
TLRPC$TL_messageMediaGiveaway tLRPC$TL_messageMediaGiveaway = (TLRPC$TL_messageMediaGiveaway) tLRPC$MessageMedia;
str4 = LocaleController.formatString("NotificationMessageChannelGiveaway", R.string.NotificationMessageChannelGiveaway, str3, Integer.valueOf(tLRPC$TL_messageMediaGiveaway.quantity), Integer.valueOf(tLRPC$TL_messageMediaGiveaway.months));
} else if (tLRPC$MessageMedia instanceof TLRPC$TL_messageMediaGiveawayResults) {
str4 = LocaleController.formatString("BoostingGiveawayResults", R.string.BoostingGiveawayResults, new Object[0]);
} else {
if (tLRPC$MessageMedia instanceof TLRPC$TL_messageMediaPoll) {
TLRPC$Poll tLRPC$Poll = ((TLRPC$TL_messageMediaPoll) tLRPC$MessageMedia).poll;
if (tLRPC$Poll.quiz) {
formatString = LocaleController.formatString("NotificationMessageQuiz2", R.string.NotificationMessageQuiz2, str3, tLRPC$Poll.question);
} else {
formatString = LocaleController.formatString("NotificationMessagePoll2", R.string.NotificationMessagePoll2, str3, tLRPC$Poll.question);
}
} else if ((tLRPC$MessageMedia instanceof TLRPC$TL_messageMediaGeo) || (tLRPC$MessageMedia instanceof TLRPC$TL_messageMediaVenue)) {
str4 = LocaleController.formatString("NotificationMessageMap", R.string.NotificationMessageMap, str3);
} else if (tLRPC$MessageMedia instanceof TLRPC$TL_messageMediaGeoLive) {
str4 = LocaleController.formatString("NotificationMessageLiveLocation", R.string.NotificationMessageLiveLocation, str3);
} else if (tLRPC$MessageMedia instanceof TLRPC$TL_messageMediaDocument) {
if (messageObject.isSticker() || messageObject.isAnimatedSticker()) {
String stickerEmoji = messageObject.getStickerEmoji();
if (stickerEmoji != null) {
formatString = LocaleController.formatString("NotificationMessageStickerEmoji", R.string.NotificationMessageStickerEmoji, str3, stickerEmoji);
} else {
formatString = LocaleController.formatString("NotificationMessageSticker", R.string.NotificationMessageSticker, str3);
}
} else if (messageObject.isGif()) {
if (!z && Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(messageObject.messageOwner.message)) {
str4 = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, str3, "🎬 " + messageObject.messageOwner.message);
zArr[0] = true;
} else {
str4 = LocaleController.formatString("NotificationMessageGif", R.string.NotificationMessageGif, str3);
}
} else if (!z && Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(messageObject.messageOwner.message)) {
str4 = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, str3, "📎 " + messageObject.messageOwner.message);
zArr[0] = true;
} else {
str4 = LocaleController.formatString("NotificationMessageDocument", R.string.NotificationMessageDocument, str3);
}
} else if (!z && !TextUtils.isEmpty(messageObject.messageText)) {
str4 = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, str3, messageObject.messageText);
zArr[0] = true;
} else {
str4 = LocaleController.formatString(str7, R.string.NotificationMessageNoText, str3);
}
str4 = formatString;
}
}
} else if (!z) {
if (!TextUtils.isEmpty(messageObject.messageOwner.message)) {
str4 = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, str3, messageObject.messageOwner.message);
zArr[0] = true;
} else {
str4 = LocaleController.formatString(str2, R.string.NotificationMessageNoText, str3);
}
} else {
str4 = LocaleController.formatString(str2, R.string.NotificationMessageNoText, str3);
}
} else {
String str8 = str2;
if (zArr2 != null) {
zArr2[0] = false;
}
str4 = LocaleController.formatString(str8, R.string.NotificationMessageNoText, str3);
}
}
return str4;
}
private void scheduleNotificationRepeat() {
try {
Intent intent = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationRepeat.class);
intent.putExtra("currentAccount", this.currentAccount);
PendingIntent service = PendingIntent.getService(ApplicationLoader.applicationContext, 0, intent, ConnectionsManager.FileTypeVideo);
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 tLRPC$MessageAction;
TLRPC$Message tLRPC$Message = messageObject.messageOwner;
TLRPC$Peer tLRPC$Peer = tLRPC$Message.peer_id;
return tLRPC$Peer != null && tLRPC$Peer.chat_id == 0 && tLRPC$Peer.channel_id == 0 && ((tLRPC$MessageAction = tLRPC$Message.action) == null || (tLRPC$MessageAction instanceof TLRPC$TL_messageActionEmpty));
}
private int getNotifyOverride(SharedPreferences sharedPreferences, long j, long j2) {
int property = this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_NOTIFY, j, j2, -1);
if (property != 3 || this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_NOTIFY_UNTIL, j, j2, 0) < getConnectionsManager().getCurrentTime()) {
return property;
}
return 2;
}
public void lambda$showNotifications$31() {
showOrUpdateNotification(false);
}
public void showNotifications() {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$showNotifications$31();
}
});
}
public void hideNotifications() {
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$hideNotifications$32();
}
});
}
public void lambda$hideNotifications$32() {
notificationManager.cancel(this.notificationId);
this.lastWearNotifiedMessageId.clear();
for (int i = 0; i < this.wearNotificationsIds.size(); i++) {
notificationManager.cancel(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(this.wearNotificationsIds.valueAt(i).intValue());
}
}
this.wearNotificationsIds.clear();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.lambda$dismissNotification$33();
}
});
} catch (Exception e) {
FileLog.e(e);
}
}
public static void lambda$dismissNotification$33() {
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 {
if (getNotifyOverride(getAccountInstance().getNotificationsSettings(), this.openedDialogId, this.openedTopicId) == 2) {
return;
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$playInChatSound$35();
}
});
} catch (Exception e2) {
FileLog.e(e2);
}
}
public void lambda$playInChatSound$35() {
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$34(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$34(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 z) {
try {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("delay notification start, onlineReason = " + z);
}
this.notificationDelayWakelock.acquire(10000L);
DispatchQueue dispatchQueue = notificationsQueue;
dispatchQueue.cancelRunnable(this.notificationDelayRunnable);
dispatchQueue.postRunnable(this.notificationDelayRunnable, z ? 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$36();
}
});
}
public void lambda$repeatNotificationMaybe$36() {
int i = Calendar.getInstance().get(11);
if (i >= 11 && i <= 22) {
notificationManager.cancel(this.notificationId);
showOrUpdateNotification(true);
} else {
scheduleNotificationRepeat();
}
}
private boolean isEmptyVibration(long[] jArr) {
if (jArr == null || jArr.length == 0) {
return false;
}
for (long j : jArr) {
if (j != 0) {
return false;
}
}
return true;
}
public void deleteNotificationChannel(long j, long j2) {
deleteNotificationChannel(j, j2, -1);
}
public void lambda$deleteNotificationChannel$37(long j, long j2, int i) {
if (Build.VERSION.SDK_INT < 26) {
return;
}
try {
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
SharedPreferences.Editor edit = notificationsSettings.edit();
if (i == 0 || i == -1) {
String str = "org.telegram.key" + j;
if (j2 != 0) {
str = str + ".topic" + j2;
}
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 (i == 1 || i == -1) {
String str2 = "org.telegram.keyia" + j;
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 j, final long j2, final int i) {
if (Build.VERSION.SDK_INT < 26) {
return;
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$deleteNotificationChannel$37(j, j2, i);
}
});
}
public void deleteNotificationChannelGlobal(int i) {
deleteNotificationChannelGlobal(i, -1);
}
public void lambda$deleteNotificationChannelGlobal$38(int i, int i2) {
if (Build.VERSION.SDK_INT < 26) {
return;
}
try {
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
SharedPreferences.Editor edit = notificationsSettings.edit();
if (i2 == 0 || i2 == -1) {
String str = i == 2 ? "channels" : i == 0 ? "groups" : i == 3 ? "stories" : "private";
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 (i2 == 1 || i2 == -1) {
String str2 = i == 2 ? "channels_ia" : i == 0 ? "groups_ia" : i == 3 ? "stories_ia" : "private_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);
}
}
}
edit.remove(i == 2 ? "overwrite_channel" : i == 0 ? "overwrite_group" : i == 3 ? "overwrite_stories" : "overwrite_private");
edit.commit();
} catch (Exception e3) {
FileLog.e(e3);
}
}
public void deleteNotificationChannelGlobal(final int i, final int i2) {
if (Build.VERSION.SDK_INT < 26) {
return;
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$deleteNotificationChannelGlobal$38(i, i2);
}
});
}
public void deleteAllNotificationChannels() {
if (Build.VERSION.SDK_INT < 26) {
return;
}
notificationsQueue.postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$deleteAllNotificationChannels$39();
}
});
}
public void lambda$deleteAllNotificationChannels$39() {
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;
}
@SuppressLint({"RestrictedApi"})
private String createNotificationShortcut(NotificationCompat.Builder builder, long j, String str, TLRPC$User tLRPC$User, TLRPC$Chat tLRPC$Chat, Person person, boolean z) {
String str2;
Bitmap bitmap;
IconCompat createWithResource;
if (!unsupportedNotificationShortcut() && (!ChatObject.isChannel(tLRPC$Chat) || tLRPC$Chat.megagroup)) {
try {
String str3 = "ndid_" + j;
Intent intent = new Intent(ApplicationLoader.applicationContext, (Class<?>) OpenChatReceiver.class);
intent.setAction("com.tmessages.openchat" + Math.random() + ConnectionsManager.DEFAULT_DATACENTER_ID);
if (j > 0) {
intent.putExtra("userId", j);
str2 = "userId";
} else {
str2 = "userId";
intent.putExtra("chatId", -j);
}
ShortcutInfoCompat.Builder locusId = new ShortcutInfoCompat.Builder(ApplicationLoader.applicationContext, str3).setShortLabel(tLRPC$Chat != null ? str : UserObject.getFirstName(tLRPC$User)).setLongLabel(str).setIntent(new Intent("android.intent.action.VIEW")).setIntent(intent).setLongLived(true).setLocusId(new LocusIdCompat(str3));
if (person != null) {
locusId.setPerson(person);
locusId.setIcon(person.getIcon());
if (person.getIcon() != null) {
bitmap = person.getIcon().getBitmap();
ShortcutInfoCompat build = locusId.build();
ShortcutManagerCompat.pushDynamicShortcut(ApplicationLoader.applicationContext, build);
builder.setShortcutInfo(build);
Intent intent2 = new Intent(ApplicationLoader.applicationContext, (Class<?>) BubbleActivity.class);
intent2.setAction("com.tmessages.openchat" + Math.random() + ConnectionsManager.DEFAULT_DATACENTER_ID);
if (!DialogObject.isUserDialog(j)) {
intent2.putExtra(str2, j);
} else {
intent2.putExtra("chatId", -j);
}
intent2.putExtra("currentAccount", this.currentAccount);
if (bitmap == null) {
createWithResource = IconCompat.createWithAdaptiveBitmap(bitmap);
} else if (tLRPC$User != null) {
createWithResource = IconCompat.createWithResource(ApplicationLoader.applicationContext, tLRPC$User.bot ? R.drawable.book_bot : R.drawable.book_user);
} else {
createWithResource = IconCompat.createWithResource(ApplicationLoader.applicationContext, R.drawable.book_group);
}
if (!z) {
NotificationCompat.BubbleMetadata.Builder builder2 = new NotificationCompat.BubbleMetadata.Builder(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2, 167772160), createWithResource);
builder2.setSuppressNotification(this.openedDialogId == j);
builder2.setAutoExpandBubble(false);
builder2.setDesiredHeight(AndroidUtilities.dp(640.0f));
builder.setBubbleMetadata(builder2.build());
} else {
builder.setBubbleMetadata(null);
}
return str3;
}
}
bitmap = null;
ShortcutInfoCompat build2 = locusId.build();
ShortcutManagerCompat.pushDynamicShortcut(ApplicationLoader.applicationContext, build2);
builder.setShortcutInfo(build2);
Intent intent22 = new Intent(ApplicationLoader.applicationContext, (Class<?>) BubbleActivity.class);
intent22.setAction("com.tmessages.openchat" + Math.random() + ConnectionsManager.DEFAULT_DATACENTER_ID);
if (!DialogObject.isUserDialog(j)) {
}
intent22.putExtra("currentAccount", this.currentAccount);
if (bitmap == null) {
}
if (!z) {
}
return str3;
} catch (Exception e) {
FileLog.e(e);
}
}
return null;
}
@TargetApi(26)
protected void ensureGroupsCreated() {
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
if (this.groupsCreated == null) {
this.groupsCreated = Boolean.valueOf(notificationsSettings.getBoolean("groupsCreated4", false));
}
if (!this.groupsCreated.booleanValue()) {
try {
String str = 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("_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("groupsCreated4", true).commit();
this.groupsCreated = Boolean.TRUE;
}
if (this.channelGroupsCreated) {
return;
}
List<NotificationChannelGroup> notificationChannelGroups = systemNotificationManager.getNotificationChannelGroups();
String str2 = "channels" + this.currentAccount;
String str3 = "groups" + this.currentAccount;
String str4 = "private" + this.currentAccount;
String str5 = "stories" + this.currentAccount;
String str6 = "other" + this.currentAccount;
int size2 = notificationChannelGroups.size();
String str7 = str6;
String str8 = str5;
String str9 = 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 (str8 != null && str8.equals(id2)) {
str8 = null;
} else if (str9 != null && str9.equals(id2)) {
str9 = null;
} else if (str7 != null && str7.equals(id2)) {
str7 = null;
}
if (str2 == null && str8 == null && str3 == null && str9 == null && str7 == null) {
break;
}
}
if (str2 != null || str3 != null || str8 != null || str9 != null || str7 != null) {
TLRPC$User user = getMessagesController().getUser(Long.valueOf(getUserConfig().getClientUserId()));
if (user == null) {
getUserConfig().getCurrentUser();
}
String str10 = user != null ? " (" + ContactsController.formatName(user.first_name, user.last_name) + ")" : "";
ArrayList arrayList = new ArrayList();
if (str2 != null) {
arrayList.add(new NotificationChannelGroup(str2, LocaleController.getString("NotificationsChannels", R.string.NotificationsChannels) + str10));
}
if (str3 != null) {
arrayList.add(new NotificationChannelGroup(str3, LocaleController.getString("NotificationsGroups", R.string.NotificationsGroups) + str10));
}
if (str8 != null) {
arrayList.add(new NotificationChannelGroup(str8, LocaleController.getString("NotificationsStories", R.string.NotificationsStories) + str10));
}
if (str9 != null) {
arrayList.add(new NotificationChannelGroup(str9, LocaleController.getString("NotificationsPrivateChats", R.string.NotificationsPrivateChats) + str10));
}
if (str7 != null) {
arrayList.add(new NotificationChannelGroup(str7, LocaleController.getString("NotificationsOther", R.string.NotificationsOther) + str10));
}
systemNotificationManager.createNotificationChannelGroups(arrayList);
}
this.channelGroupsCreated = true;
}
@TargetApi(26)
private String validateChannelId(long j, long j2, String str, long[] jArr, int i, Uri uri, int i2, boolean z, boolean z2, boolean z3, int i3) {
String str2;
String str3;
String str4;
String str5;
String str6;
String string;
int i4;
String str7;
String str8;
String str9;
String str10;
String str11;
StringBuilder sb;
long j3;
int i5;
long[] jArr2;
String str12;
NotificationsController notificationsController;
String str13;
int i6;
int i7;
String str14;
String str15;
String str16;
int i8;
String str17;
Uri uri2;
String MD5;
String str18;
boolean z4;
boolean z5;
String str19;
boolean z6;
long[] jArr3;
String str20;
String str21;
String str22;
int i9;
int i10;
long[] jArr4;
boolean z7;
SharedPreferences.Editor editor;
boolean z8;
boolean z9;
int i11;
int i12;
int i13;
StringBuilder sb2;
SharedPreferences.Editor editor2;
ensureGroupsCreated();
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
String str23 = "private";
if (z3) {
str4 = "other" + this.currentAccount;
str5 = null;
} else {
if (i3 == 2) {
str2 = "channels" + this.currentAccount;
str3 = "overwrite_channel";
} else if (i3 == 0) {
str2 = "groups" + this.currentAccount;
str3 = "overwrite_group";
} else if (i3 == 3) {
str2 = "stories" + this.currentAccount;
str3 = "overwrite_stories";
} else {
str2 = "private" + this.currentAccount;
str3 = "overwrite_private";
}
str4 = str2;
str5 = str3;
}
boolean z10 = !z && DialogObject.isEncryptedDialog(j);
boolean z11 = (z2 || str5 == null || !notificationsSettings.getBoolean(str5, false)) ? false : true;
String MD52 = Utilities.MD5(uri == null ? "NoSound2" : uri.toString());
if (MD52 != null && MD52.length() > 5) {
MD52 = MD52.substring(0, 5);
}
if (z3) {
str23 = "silent";
str6 = LocaleController.getString("NotificationsSilent", R.string.NotificationsSilent);
} else {
if (z) {
String string2 = z2 ? LocaleController.getString("NotificationsInAppDefault", R.string.NotificationsInAppDefault) : LocaleController.getString("NotificationsDefault", R.string.NotificationsDefault);
if (i3 == 2) {
str23 = z2 ? "channels_ia" : "channels";
str6 = string2;
} else {
if (i3 == 0) {
str23 = z2 ? "groups_ia" : "groups";
} else if (i3 == 3) {
str23 = z2 ? "stories_ia" : "stories";
} else if (z2) {
str23 = "private_ia";
}
str6 = string2;
}
} else {
String formatString = z2 ? LocaleController.formatString("NotificationsChatInApp", R.string.NotificationsChatInApp, str) : str;
StringBuilder sb3 = new StringBuilder();
sb3.append(z2 ? "org.telegram.keyia" : "org.telegram.key");
sb3.append(j);
sb3.append("_");
sb3.append(j2);
str23 = sb3.toString();
str6 = formatString;
}
String str24 = str23 + "_" + MD52;
string = notificationsSettings.getString(str24, null);
String string3 = notificationsSettings.getString(str24 + "_s", null);
StringBuilder sb4 = new StringBuilder();
if (string == null) {
NotificationChannel notificationChannel = systemNotificationManager.getNotificationChannel(string);
if (BuildVars.LOGS_ENABLED) {
StringBuilder sb5 = new StringBuilder();
str19 = "_s";
sb5.append("current channel for ");
sb5.append(string);
sb5.append(" = ");
sb5.append(notificationChannel);
FileLog.d(sb5.toString());
} else {
str19 = "_s";
}
if (notificationChannel == null) {
i4 = i;
sb = sb4;
notificationsController = this;
i5 = i2;
str9 = "secret";
str10 = str4;
str11 = "_";
str13 = str24;
j3 = j;
i6 = 0;
str12 = str19;
jArr2 = jArr;
i7 = 0;
str16 = null;
str15 = null;
str14 = null;
} else if (z3 || z11) {
i4 = i;
str7 = string3;
str8 = string;
notificationsController = this;
str9 = "secret";
str10 = str4;
str11 = "_";
sb = sb4;
str13 = str24;
j3 = j;
i5 = i2;
i6 = 0;
str12 = str19;
jArr2 = jArr;
} else {
int importance = notificationChannel.getImportance();
Uri sound = notificationChannel.getSound();
long[] vibrationPattern = notificationChannel.getVibrationPattern();
boolean shouldVibrate = notificationChannel.shouldVibrate();
if (shouldVibrate || vibrationPattern != null) {
z6 = shouldVibrate;
jArr3 = vibrationPattern;
} else {
z6 = shouldVibrate;
jArr3 = new long[]{0, 0};
}
int lightColor = notificationChannel.getLightColor();
if (jArr3 != null) {
for (long j4 : jArr3) {
sb4.append(j4);
}
}
sb4.append(lightColor);
if (sound != null) {
sb4.append(sound.toString());
}
sb4.append(importance);
if (!z && z10) {
sb4.append("secret");
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("current channel settings for " + string + " = " + ((Object) sb4) + " old = " + string3);
}
String MD53 = Utilities.MD5(sb4.toString());
i6 = 0;
sb4.setLength(0);
if (MD53.equals(string3)) {
jArr2 = jArr;
i4 = i;
str20 = string3;
str21 = string;
notificationsController = this;
str9 = "secret";
str10 = str4;
str11 = "_";
j3 = j;
str13 = str24;
sb = sb4;
i5 = i2;
str12 = str19;
str22 = MD53;
i9 = 0;
} else {
if (importance == 0) {
SharedPreferences.Editor edit = notificationsSettings.edit();
if (z) {
if (z2) {
str13 = str24;
sb2 = sb4;
str20 = string3;
i13 = 0;
str21 = string;
i10 = lightColor;
jArr4 = jArr3;
str9 = "secret";
str10 = str4;
str11 = "_";
z7 = z6;
} else {
if (i3 == 3) {
edit.putBoolean("EnableAllStories", false);
} else {
edit.putInt(getGlobalNotificationsKey(i3), ConnectionsManager.DEFAULT_DATACENTER_ID);
}
updateServerNotificationsSettings(i3);
str13 = str24;
sb2 = sb4;
str20 = string3;
str21 = string;
i10 = lightColor;
jArr4 = jArr3;
str9 = "secret";
str10 = str4;
str11 = "_";
z7 = z6;
i13 = 0;
}
editor2 = edit;
j3 = j;
str12 = str19;
str22 = MD53;
} else {
if (i3 == 3) {
StringBuilder sb6 = new StringBuilder();
sb6.append(NotificationsSettingsFacade.PROPERTY_STORIES_NOTIFY);
i12 = lightColor;
sb6.append(getSharedPrefKey(j, 0L));
i13 = 0;
edit.putBoolean(sb6.toString(), false);
} else {
i12 = lightColor;
i13 = 0;
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(j, 0L), 2);
}
sb2 = sb4;
str20 = string3;
String str25 = str19;
str13 = str24;
str21 = string;
str22 = MD53;
str12 = str25;
z7 = z6;
jArr4 = jArr3;
str9 = "secret";
str10 = str4;
str11 = "_";
i10 = i12;
editor2 = edit;
j3 = j;
updateServerNotificationsSettings(j, 0L, true);
}
notificationsController = this;
i5 = i2;
i6 = i13;
sb = sb2;
editor = editor2;
i9 = 1;
} else {
str13 = str24;
str20 = string3;
str21 = string;
i10 = lightColor;
jArr4 = jArr3;
str9 = "secret";
str10 = str4;
str11 = "_";
z7 = z6;
int i14 = 4;
j3 = j;
sb = sb4;
i5 = i2;
str12 = str19;
str22 = MD53;
if (importance != i5) {
if (z2) {
editor = null;
} else {
editor = notificationsSettings.edit();
if (importance == 4 || importance == 5) {
z8 = true;
i14 = 1;
} else {
z8 = true;
if (importance != 1) {
i14 = importance == 2 ? 5 : 0;
}
}
if (z) {
if (i3 == 3) {
editor.putBoolean("EnableAllStories", z8);
} else {
editor.putInt(getGlobalNotificationsKey(i3), 0);
}
if (i3 == 2) {
editor.putInt("priority_channel", i14);
} else if (i3 == 0) {
editor.putInt("priority_group", i14);
} else if (i3 == 3) {
editor.putInt("priority_stories", i14);
} else {
editor.putInt("priority_messages", i14);
}
} else if (i3 == 3) {
editor.putBoolean(NotificationsSettingsFacade.PROPERTY_STORIES_NOTIFY + j3, true);
} else {
editor.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + j3, 0);
editor.remove(NotificationsSettingsFacade.PROPERTY_NOTIFY_UNTIL + j3);
editor.putInt("priority_" + j3, i14);
}
}
i9 = 1;
notificationsController = this;
} else {
editor = null;
notificationsController = this;
jArr2 = jArr;
i9 = 0;
z9 = z7;
if ((!notificationsController.isEmptyVibration(jArr2)) == z9) {
if (!z2) {
if (editor == null) {
editor = notificationsSettings.edit();
}
if (!z) {
editor.putInt("vibrate_" + j3, z9 ? i6 : 2);
} else if (i3 == 2) {
editor.putInt("vibrate_channel", z9 ? i6 : 2);
} else if (i3 == 0) {
editor.putInt("vibrate_group", z9 ? i6 : 2);
} else if (i3 == 3) {
editor.putInt("vibrate_stories", z9 ? i6 : 2);
} else {
editor.putInt("vibrate_messages", z9 ? i6 : 2);
}
}
jArr2 = jArr4;
i4 = i;
i11 = i10;
i9 = 1;
} else {
i4 = i;
i11 = i10;
}
if (i11 != i4) {
if (!z2) {
if (editor == null) {
editor = notificationsSettings.edit();
}
if (!z) {
editor.putInt("color_" + j3, i11);
} else if (i3 == 2) {
editor.putInt("ChannelLed", i11);
} else if (i3 == 0) {
editor.putInt("GroupLed", i11);
} else if (i3 == 3) {
editor.putInt("StoriesLed", i11);
} else {
editor.putInt("MessagesLed", i11);
}
}
i4 = i11;
i9 = 1;
}
if (editor != null) {
editor.commit();
}
}
}
jArr2 = jArr;
z9 = z7;
if ((!notificationsController.isEmptyVibration(jArr2)) == z9) {
}
if (i11 != i4) {
}
if (editor != null) {
}
}
str16 = str22;
i7 = i9;
str14 = str20;
str15 = str21;
}
if (i7 == 0 && str16 != null) {
notificationsSettings.edit().putString(str13, str15).putString(str13 + str12, str16).commit();
if (BuildVars.LOGS_ENABLED) {
FileLog.d("change edited channel " + str15);
}
} else if (!z11 || str16 == null || !z2 || !z) {
i8 = i6;
while (i8 < jArr2.length) {
sb.append(jArr2[i8]);
i8++;
str15 = str15;
}
str17 = str15;
sb.append(i4);
uri2 = uri;
if (uri2 != null) {
sb.append(uri.toString());
}
sb.append(i5);
if (!z && z10) {
sb.append(str9);
}
MD5 = Utilities.MD5(sb.toString());
if (!z3 || str17 == null || (!z11 && str14.equals(MD5))) {
str15 = str17;
str16 = MD5;
} else {
try {
str18 = str17;
} catch (Exception e) {
e = e;
str18 = str17;
}
try {
systemNotificationManager.deleteNotificationChannel(str18);
} catch (Exception e2) {
e = e2;
FileLog.e(e);
if (BuildVars.LOGS_ENABLED) {
}
str16 = MD5;
str15 = null;
if (str15 == null) {
}
return str15;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("delete channel by settings change " + str18);
}
str16 = MD5;
str15 = null;
}
if (str15 == null) {
str15 = z ? notificationsController.currentAccount + "channel_" + str13 + str11 + Utilities.random.nextLong() : notificationsController.currentAccount + "channel_" + j3 + str11 + Utilities.random.nextLong();
if (z10) {
str6 = LocaleController.getString("SecretChatName", R.string.SecretChatName);
}
NotificationChannel notificationChannel2 = new NotificationChannel(str15, str6, i5);
notificationChannel2.setGroup(str10);
if (i4 != 0) {
z4 = true;
notificationChannel2.enableLights(true);
notificationChannel2.setLightColor(i4);
z5 = false;
} else {
z4 = true;
z5 = false;
notificationChannel2.enableLights(false);
}
if (!notificationsController.isEmptyVibration(jArr2)) {
notificationChannel2.enableVibration(z4);
if (jArr2.length > 0) {
notificationChannel2.setVibrationPattern(jArr2);
}
} else {
notificationChannel2.enableVibration(z5);
}
AudioAttributes.Builder builder = new AudioAttributes.Builder();
builder.setContentType(4);
builder.setUsage(5);
if (uri2 != null) {
notificationChannel2.setSound(uri2, builder.build());
} else {
notificationChannel2.setSound(null, builder.build());
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("create new channel " + str15);
}
notificationsController.lastNotificationChannelCreateTime = SystemClock.elapsedRealtime();
systemNotificationManager.createNotificationChannel(notificationChannel2);
notificationsSettings.edit().putString(str13, str15).putString(str13 + str12, str16).commit();
}
return str15;
}
uri2 = uri;
if (str15 == null) {
}
return str15;
}
i4 = i;
str7 = string3;
str8 = string;
str9 = "secret";
str10 = str4;
str11 = "_";
sb = sb4;
j3 = j;
i5 = i2;
jArr2 = jArr;
str12 = "_s";
notificationsController = this;
str13 = str24;
i6 = 0;
i7 = i6;
str14 = str7;
str15 = str8;
str16 = null;
if (i7 == 0) {
}
if (!z11) {
}
i8 = i6;
while (i8 < jArr2.length) {
}
str17 = str15;
sb.append(i4);
uri2 = uri;
if (uri2 != null) {
}
sb.append(i5);
if (!z) {
sb.append(str9);
}
MD5 = Utilities.MD5(sb.toString());
if (z3) {
}
str15 = str17;
str16 = MD5;
if (str15 == null) {
}
return str15;
}
String str242 = str23 + "_" + MD52;
string = notificationsSettings.getString(str242, null);
String string32 = notificationsSettings.getString(str242 + "_s", null);
StringBuilder sb42 = new StringBuilder();
if (string == null) {
}
i7 = i6;
str14 = str7;
str15 = str8;
str16 = null;
if (i7 == 0) {
}
if (!z11) {
}
i8 = i6;
while (i8 < jArr2.length) {
}
str17 = str15;
sb.append(i4);
uri2 = uri;
if (uri2 != null) {
}
sb.append(i5);
if (!z) {
}
MD5 = Utilities.MD5(sb.toString());
if (z3) {
}
str15 = str17;
str16 = MD5;
if (str15 == null) {
}
return str15;
}
private void showOrUpdateNotification(boolean z) {
MessageObject messageObject;
Bitmap bitmap;
long j;
long j2;
TLRPC$Chat tLRPC$Chat;
boolean z2;
boolean z3;
String userName;
boolean z4;
String string;
boolean z5;
String str;
String str2;
TLRPC$User tLRPC$User;
SharedPreferences sharedPreferences;
long j3;
boolean z6;
MessageObject messageObject2;
String str3;
NotificationCompat.Builder builder;
boolean z7;
String str4;
NotificationCompat.InboxStyle inboxStyle;
String str5;
boolean z8;
String str6;
boolean z9;
String str7;
SharedPreferences sharedPreferences2;
long j4;
boolean z10;
boolean z11;
long j5;
boolean z12;
boolean z13;
CharSequence charSequence;
String str8;
long j6;
int i;
int i2;
String str9;
Integer num;
boolean z14;
String str10;
CharSequence charSequence2;
NotificationCompat.Builder builder2;
Object obj;
int i3;
String str11;
int i4;
int i5;
int i6;
boolean z15;
String string2;
boolean z16;
String str12;
int i7;
int i8;
boolean z17;
int i9;
boolean z18;
int i10;
boolean z19;
int i11;
String str13;
int i12;
MessageObject messageObject3;
TLRPC$User tLRPC$User2;
TLRPC$FileLocation tLRPC$FileLocation;
TLRPC$FileLocation tLRPC$FileLocation2;
NotificationCompat.Builder builder3;
long[] jArr;
boolean z20;
int i13;
int i14;
long[] jArr2;
Uri uri;
int i15;
long j7;
boolean z21;
int i16;
TLRPC$ReplyMarkup tLRPC$ReplyMarkup;
ArrayList<TLRPC$TL_keyboardButtonRow> arrayList;
MessageObject messageObject4;
int i17;
TLRPC$TL_keyboardButtonRow tLRPC$TL_keyboardButtonRow;
int i18;
long j8;
Uri uri2;
long[] jArr3;
long[] jArr4;
int i19;
int i20;
String str14;
int ringerMode;
String string3;
String string4;
boolean z22;
int i21;
int i22;
String str15;
boolean z23;
int i23;
String formatPluralString;
if (!getUserConfig().isClientActivated() || ((this.pushMessages.isEmpty() && this.storyPushMessages.isEmpty()) || (!SharedConfig.showNotificationsForAllAccounts && this.currentAccount != UserConfig.selectedAccount))) {
dismissNotification();
return;
}
try {
getConnectionsManager().resumeNetworkMaybe();
long j9 = 0;
StoryNotification storyNotification = null;
for (int i24 = 0; i24 < this.pushMessages.size(); i24++) {
MessageObject messageObject5 = this.pushMessages.get(i24);
int i25 = messageObject5.messageOwner.date;
if (j9 < i25) {
j9 = i25;
storyNotification = messageObject5;
}
}
for (int i26 = 0; i26 < this.storyPushMessages.size(); i26++) {
StoryNotification storyNotification2 = this.storyPushMessages.get(i26);
long j10 = storyNotification2.date;
if (j9 < j10 / 1000) {
storyNotification = storyNotification2;
j9 = j10 / 1000;
}
}
if (storyNotification == null) {
return;
}
if (storyNotification instanceof StoryNotification) {
StoryNotification storyNotification3 = storyNotification;
TLRPC$TL_message tLRPC$TL_message = new TLRPC$TL_message();
tLRPC$TL_message.date = (int) (System.currentTimeMillis() / 1000);
boolean z24 = false;
int i27 = 0;
for (int i28 = 0; i28 < this.storyPushMessages.size(); i28++) {
z24 |= this.storyPushMessages.get(i28).hidden;
tLRPC$TL_message.date = Math.min(tLRPC$TL_message.date, (int) (this.storyPushMessages.get(i28).date / 1000));
i27 += this.storyPushMessages.get(i28).dateByIds.size();
}
TLRPC$TL_peerUser tLRPC$TL_peerUser = new TLRPC$TL_peerUser();
long j11 = storyNotification3.dialogId;
tLRPC$TL_peerUser.user_id = j11;
tLRPC$TL_message.dialog_id = j11;
tLRPC$TL_message.peer_id = tLRPC$TL_peerUser;
ArrayList<String> arrayList2 = new ArrayList<>();
ArrayList<Object> arrayList3 = new ArrayList<>();
parseStoryPushes(arrayList2, arrayList3);
Bitmap loadMultipleAvatars = SharedConfig.getDevicePerformanceClass() >= 1 ? loadMultipleAvatars(arrayList3) : null;
if (!z24 && this.storyPushMessages.size() < 2 && !arrayList2.isEmpty()) {
formatPluralString = arrayList2.get(0);
i23 = 0;
if (!z24) {
tLRPC$TL_message.message = LocaleController.formatPluralString("StoryNotificationHidden", i27, new Object[i23]);
} else if (arrayList2.isEmpty()) {
tLRPC$TL_message.message = "";
} else if (arrayList2.size() == 1) {
if (i27 == 1) {
tLRPC$TL_message.message = LocaleController.getString("StoryNotificationSingle");
} else {
tLRPC$TL_message.message = LocaleController.formatPluralString("StoryNotification1", i27, arrayList2.get(0));
}
} else if (arrayList2.size() == 2) {
tLRPC$TL_message.message = LocaleController.formatString(R.string.StoryNotification2, arrayList2.get(0), arrayList2.get(1));
} else if (arrayList2.size() == 3 && this.storyPushMessages.size() == 3) {
tLRPC$TL_message.message = LocaleController.formatString(R.string.StoryNotification3, cutLastName(arrayList2.get(0)), cutLastName(arrayList2.get(1)), cutLastName(arrayList2.get(2)));
} else {
tLRPC$TL_message.message = LocaleController.formatPluralString("StoryNotification4", this.storyPushMessages.size() - 2, cutLastName(arrayList2.get(0)), cutLastName(arrayList2.get(1)));
}
MessageObject messageObject6 = new MessageObject(this.currentAccount, tLRPC$TL_message, tLRPC$TL_message.message, formatPluralString, formatPluralString, false, false, false, false);
messageObject6.isStoryPush = true;
messageObject = messageObject6;
bitmap = loadMultipleAvatars;
}
i23 = 0;
formatPluralString = LocaleController.formatPluralString("Stories", i27, new Object[0]);
if (!z24) {
}
MessageObject messageObject62 = new MessageObject(this.currentAccount, tLRPC$TL_message, tLRPC$TL_message.message, formatPluralString, formatPluralString, false, false, false, false);
messageObject62.isStoryPush = true;
messageObject = messageObject62;
bitmap = loadMultipleAvatars;
} else {
messageObject = this.pushMessages.get(0);
bitmap = null;
}
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
int i29 = notificationsSettings.getInt("dismissDate", 0);
if (!messageObject.isStoryPush && messageObject.messageOwner.date <= i29) {
dismissNotification();
return;
}
long dialogId = messageObject.getDialogId();
long topicId = MessageObject.getTopicId(this.currentAccount, messageObject.messageOwner, getMessagesController().isForum(messageObject));
boolean z25 = messageObject.isStoryPush;
long fromChatId = messageObject.messageOwner.mentioned ? messageObject.getFromChatId() : dialogId;
messageObject.getId();
TLRPC$Peer tLRPC$Peer = messageObject.messageOwner.peer_id;
long j12 = tLRPC$Peer.chat_id;
if (j12 == 0) {
j12 = tLRPC$Peer.channel_id;
}
long j13 = tLRPC$Peer.user_id;
if (messageObject.isFromUser() && (j13 == 0 || j13 == getUserConfig().getClientUserId())) {
j13 = messageObject.messageOwner.from_id.user_id;
}
TLRPC$User user = getMessagesController().getUser(Long.valueOf(j13));
if (j12 != 0) {
tLRPC$Chat = getMessagesController().getChat(Long.valueOf(j12));
if (tLRPC$Chat == null && messageObject.isFcmMessage()) {
z23 = messageObject.localChannel;
} else {
z23 = ChatObject.isChannel(tLRPC$Chat) && !tLRPC$Chat.megagroup;
}
z2 = z23;
j = j12;
j2 = topicId;
} else {
j = j12;
j2 = topicId;
tLRPC$Chat = null;
z2 = false;
}
long j14 = j13;
TLRPC$Chat tLRPC$Chat2 = tLRPC$Chat;
Bitmap bitmap2 = bitmap;
int notifyOverride = getNotifyOverride(notificationsSettings, fromChatId, j2);
if (notifyOverride == -1) {
z3 = isGlobalNotificationsEnabled(dialogId, Boolean.valueOf(z2));
} else {
z3 = notifyOverride != 2;
}
if (((j12 != 0 && tLRPC$Chat2 == null) || user == null) && messageObject.isFcmMessage()) {
userName = messageObject.localName;
} else if (tLRPC$Chat2 != null) {
userName = tLRPC$Chat2.title;
} else {
userName = UserObject.getUserName(user);
}
String str16 = userName;
if (!AndroidUtilities.needShowPasscode() && !SharedConfig.isWaitingForPasscodeEnter) {
z4 = false;
if (!DialogObject.isEncryptedDialog(dialogId) && this.pushDialogs.size() <= 1 && !z4) {
string = str16;
z5 = true;
if (UserConfig.getActivatedAccountsCount() > 1) {
str = "";
} else if (this.pushDialogs.size() == 1) {
str = UserObject.getFirstName(getUserConfig().getCurrentUser());
} else {
str = UserObject.getFirstName(getUserConfig().getCurrentUser()) + "・";
}
if (this.pushDialogs.size() == 1 && Build.VERSION.SDK_INT >= 23) {
str2 = "currentAccount";
tLRPC$User = user;
sharedPreferences = notificationsSettings;
j3 = dialogId;
NotificationCompat.Builder builder4 = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
if (this.pushMessages.size() > 1) {
boolean[] zArr = new boolean[1];
z6 = z3;
str4 = getStringForMessage(messageObject, false, zArr, null);
z7 = isSilentMessage(messageObject);
if (str4 == null) {
return;
}
if (!z5) {
str15 = str4;
} else if (tLRPC$Chat2 != null) {
str15 = str4.replace(" @ " + string, "");
} else if (zArr[0]) {
str15 = str4.replace(string + ": ", "");
} else {
str15 = str4.replace(string + " ", "");
}
builder4.setContentText(str15);
builder4.setStyle(new NotificationCompat.BigTextStyle().bigText(str15));
builder = builder4;
str3 = str;
messageObject2 = messageObject;
} else {
z6 = z3;
builder4.setContentText(str);
NotificationCompat.InboxStyle inboxStyle2 = new NotificationCompat.InboxStyle();
inboxStyle2.setBigContentTitle(string);
int min = Math.min(10, this.pushMessages.size());
messageObject2 = messageObject;
boolean[] zArr2 = new boolean[1];
?? r2 = 2;
int i30 = 0;
String str17 = null;
while (i30 < min) {
int i31 = min;
MessageObject messageObject7 = this.pushMessages.get(i30);
String str18 = str;
NotificationCompat.InboxStyle inboxStyle3 = inboxStyle2;
int i32 = i30;
String stringForMessage = getStringForMessage(messageObject7, false, zArr2, null);
if (stringForMessage != null && (messageObject7.isStoryPush || messageObject7.messageOwner.date > i29)) {
if (r2 == 2) {
str5 = stringForMessage;
r2 = isSilentMessage(messageObject7);
} else {
str5 = str17;
r2 = r2;
}
if (this.pushDialogs.size() == 1 && z5) {
if (tLRPC$Chat2 != null) {
stringForMessage = stringForMessage.replace(" @ " + string, "");
} else if (zArr2[0]) {
stringForMessage = stringForMessage.replace(string + ": ", "");
} else {
stringForMessage = stringForMessage.replace(string + " ", "");
}
}
inboxStyle = inboxStyle3;
inboxStyle.addLine(stringForMessage);
str17 = str5;
i30 = i32 + 1;
inboxStyle2 = inboxStyle;
min = i31;
str = str18;
r2 = r2;
}
inboxStyle = inboxStyle3;
i30 = i32 + 1;
inboxStyle2 = inboxStyle;
min = i31;
str = str18;
r2 = r2;
}
str3 = str;
NotificationCompat.InboxStyle inboxStyle4 = inboxStyle2;
inboxStyle4.setSummaryText(str3);
builder = builder4;
builder.setStyle(inboxStyle4);
z7 = r2 == true ? 1 : 0;
str4 = str17;
}
if (z && z6 && !MediaController.getInstance().isRecordingAudio() && !z7) {
z8 = false;
if (z8 && j3 == fromChatId && tLRPC$Chat2 != null) {
StringBuilder sb = new StringBuilder();
sb.append(NotificationsSettingsFacade.PROPERTY_CUSTOM);
j4 = j3;
sb.append(j4);
sharedPreferences2 = sharedPreferences;
if (sharedPreferences2.getBoolean(sb.toString(), false)) {
i22 = sharedPreferences2.getInt("smart_max_count_" + j4, 2);
i21 = sharedPreferences2.getInt("smart_delay_" + j4, 180);
} else {
i21 = 180;
i22 = 2;
}
if (i22 != 0) {
Point point = this.smartNotificationsDialogs.get(j4);
if (point == null) {
this.smartNotificationsDialogs.put(j4, new Point(1, (int) (SystemClock.elapsedRealtime() / 1000)));
} else {
z9 = z8;
int i33 = point.y + i21;
str6 = str4;
if (i33 < SystemClock.elapsedRealtime() / 1000) {
point.set(1, (int) (SystemClock.elapsedRealtime() / 1000));
str7 = str3;
} else {
int i34 = point.x;
if (i34 < i22) {
str7 = str3;
point.set(i34 + 1, (int) (SystemClock.elapsedRealtime() / 1000));
} else {
str7 = str3;
z10 = true;
if (z10) {
z11 = z10;
j5 = j2;
} else {
StringBuilder sb2 = new StringBuilder();
sb2.append("sound_enabled_");
z11 = z10;
j5 = j2;
sb2.append(getSharedPrefKey(j4, j5));
if (!sharedPreferences2.getBoolean(sb2.toString(), true)) {
z12 = true;
String path = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
z13 = ApplicationLoader.mainInterfacePaused;
getSharedPrefKey(j4, j5);
if (this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_CUSTOM, j4, j5, false)) {
charSequence = "";
str8 = str6;
j6 = j5;
i = 0;
i2 = 3;
str9 = null;
num = null;
z14 = false;
} else {
int property = this.dialogsNotificationsFacade.getProperty("vibrate_", j4, j5, 0);
int property2 = this.dialogsNotificationsFacade.getProperty("priority_", j4, j5, 3);
str8 = str6;
long property3 = this.dialogsNotificationsFacade.getProperty("sound_document_id_", j4, j5, 0L);
if (property3 != 0) {
charSequence = "";
str9 = getMediaDataController().ringtoneDataStore.getSoundPath(property3);
z22 = true;
} else {
charSequence = "";
str9 = this.dialogsNotificationsFacade.getPropertyString("sound_path_", j4, j5, null);
z22 = false;
}
int property4 = this.dialogsNotificationsFacade.getProperty("color_", j4, j5, 0);
num = property4 != 0 ? Integer.valueOf(property4) : null;
j6 = j5;
z14 = z22;
i = property;
i2 = property2;
}
if (j12 != 0) {
str10 = str8;
charSequence2 = string;
builder2 = builder;
if (j14 != 0) {
long j15 = sharedPreferences2.getLong(z25 ? "StoriesSoundDocId" : "GlobalSoundDocId", 0L);
if (j15 != 0) {
string2 = getMediaDataController().ringtoneDataStore.getSoundPath(j15);
z16 = true;
} else {
string2 = sharedPreferences2.getString(z25 ? "StoriesSoundPath" : "GlobalSoundPath", path);
z16 = false;
}
int i35 = sharedPreferences2.getInt("vibrate_messages", 0);
str12 = string2;
i5 = sharedPreferences2.getInt("priority_messages", 1);
i7 = sharedPreferences2.getInt("MessagesLed", -16776961);
i6 = z25 ? 3 : 1;
i4 = i35;
} else {
obj = path;
i3 = -16776961;
str11 = null;
i4 = 0;
i5 = 0;
i6 = 1;
z15 = false;
if (i4 == 4) {
z17 = true;
i8 = 0;
} else {
i8 = i4;
z17 = false;
}
if (!TextUtils.isEmpty(str9) || TextUtils.equals(str11, str9)) {
str9 = str11;
z14 = z15;
i9 = 3;
z18 = true;
} else {
i9 = 3;
z18 = false;
}
if (i2 != i9 && i5 != i2) {
i5 = i2;
z18 = false;
}
if (num != null && num.intValue() != i3) {
i3 = num.intValue();
z18 = false;
}
if (i != 0 || i == 4) {
i10 = i8;
} else {
i10 = i8;
if (i != i10) {
i10 = i;
z19 = false;
if (z13) {
if (!sharedPreferences2.getBoolean("EnableInAppSounds", true)) {
str9 = null;
}
if (!sharedPreferences2.getBoolean("EnableInAppVibrate", true)) {
i10 = 2;
}
if (!sharedPreferences2.getBoolean("EnableInAppPriority", false)) {
i5 = 0;
} else if (i5 == 2) {
i5 = 1;
}
}
if (z17 && i10 != 2) {
try {
ringerMode = audioManager.getRingerMode();
if (ringerMode != 0 && ringerMode != 1) {
i10 = 2;
}
} catch (Exception e) {
FileLog.e(e);
}
}
if (z12) {
i11 = i10;
str13 = str9;
i12 = i3;
} else {
str13 = null;
i11 = 0;
i5 = 0;
i12 = 0;
}
Intent intent = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
StringBuilder sb3 = new StringBuilder();
sb3.append("com.tmessages.openchat");
int i36 = i12;
sb3.append(Math.random());
sb3.append(ConnectionsManager.DEFAULT_DATACENTER_ID);
intent.setAction(sb3.toString());
intent.setFlags(ConnectionsManager.FileTypeFile);
messageObject3 = messageObject2;
if (!messageObject3.isStoryPush) {
long[] jArr5 = new long[this.storyPushMessages.size()];
for (int i37 = 0; i37 < this.storyPushMessages.size(); i37++) {
jArr5[i37] = this.storyPushMessages.get(i37).dialogId;
}
intent.putExtra("storyDialogIds", jArr5);
} else {
if (!DialogObject.isEncryptedDialog(j4)) {
if (this.pushDialogs.size() == 1) {
if (j12 != 0) {
intent.putExtra("chatId", j);
} else if (j14 != 0) {
intent.putExtra("userId", j14);
}
}
if (!AndroidUtilities.needShowPasscode() && !SharedConfig.isWaitingForPasscodeEnter && this.pushDialogs.size() == 1 && Build.VERSION.SDK_INT < 28) {
if (tLRPC$Chat2 != null) {
TLRPC$ChatPhoto tLRPC$ChatPhoto = tLRPC$Chat2.photo;
if (tLRPC$ChatPhoto != null && (tLRPC$FileLocation2 = tLRPC$ChatPhoto.photo_small) != null && tLRPC$FileLocation2.volume_id != 0 && tLRPC$FileLocation2.local_id != 0) {
tLRPC$FileLocation = tLRPC$FileLocation2;
tLRPC$User2 = tLRPC$User;
}
} else if (tLRPC$User != null) {
tLRPC$User2 = tLRPC$User;
TLRPC$UserProfilePhoto tLRPC$UserProfilePhoto = tLRPC$User2.photo;
if (tLRPC$UserProfilePhoto != null && (tLRPC$FileLocation = tLRPC$UserProfilePhoto.photo_small) != null && tLRPC$FileLocation.volume_id != 0 && tLRPC$FileLocation.local_id != 0) {
}
}
String str19 = str2;
intent.putExtra(str19, this.currentAccount);
long j16 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str20 = str13;
int i38 = i11;
showWhen.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null && tLRPC$User2 != null && (str14 = tLRPC$User2.phone) != null && str14.length() > 0) {
builder3.addPerson("tel:+" + tLRPC$User2.phone);
}
Intent intent2 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent2.putExtra("messageDate", messageObject3.messageOwner.date);
intent2.putExtra(str19, this.currentAccount);
if (messageObject3.isStoryPush) {
i20 = 1;
} else {
i20 = 1;
intent2.putExtra("story", true);
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent2, 167772160));
if (bitmap2 == null) {
builder3.setLargeIcon(bitmap2);
} else if (tLRPC$FileLocation != null) {
jArr = null;
BitmapDrawable imageFromMemory = ImageLoader.getInstance().getImageFromMemory(tLRPC$FileLocation, null, "50_50");
if (imageFromMemory != null) {
builder3.setLargeIcon(imageFromMemory.getBitmap());
} else {
try {
File pathToAttach = getFileLoader().getPathToAttach(tLRPC$FileLocation, true);
if (pathToAttach.exists()) {
float dp = 160.0f / AndroidUtilities.dp(50.0f);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = dp < 1.0f ? 1 : (int) dp;
Bitmap decodeFile = BitmapFactory.decodeFile(pathToAttach.getAbsolutePath(), options);
if (decodeFile != null) {
builder3.setLargeIcon(decodeFile);
}
}
} catch (Throwable unused) {
}
}
if (z || z7) {
builder3.setPriority(-1);
} else if (i5 == 0) {
builder3.setPriority(0);
if (Build.VERSION.SDK_INT >= 26) {
z20 = true;
i13 = 3;
}
z20 = true;
i13 = 0;
} else {
if (i5 == 1) {
i19 = 1;
} else if (i5 == 2) {
i19 = 1;
} else {
if (i5 == 4) {
builder3.setPriority(-2);
if (Build.VERSION.SDK_INT >= 26) {
z20 = true;
i13 = 1;
}
} else if (i5 == 5) {
builder3.setPriority(-1);
if (Build.VERSION.SDK_INT >= 26) {
z20 = true;
i13 = 2;
}
}
z20 = true;
i13 = 0;
}
builder3.setPriority(i19);
if (Build.VERSION.SDK_INT >= 26) {
z20 = true;
i13 = 4;
}
z20 = true;
i13 = 0;
}
if (z7 != z20 && !z12) {
if (!z13 || (sharedPreferences2.getBoolean("EnableInAppPreview", z20) && str10 != null)) {
builder3.setTicker(str10.length() > 100 ? str10.substring(0, 100).replace('\n', ' ').trim() + "..." : str10);
}
if (str20 != null && !str20.equalsIgnoreCase("NoSound")) {
int i39 = Build.VERSION.SDK_INT;
if (i39 >= 26) {
if (!str20.equalsIgnoreCase("Default") && !str20.equals(obj)) {
if (z14) {
Uri uriForFile = FileProvider.getUriForFile(ApplicationLoader.applicationContext, ApplicationLoader.getApplicationId() + ".provider", new File(str20));
ApplicationLoader.applicationContext.grantUriPermission("com.android.systemui", uriForFile, 1);
uri2 = uriForFile;
} else {
uri2 = Uri.parse(str20);
}
if (i36 != 0) {
i14 = i36;
builder3.setLights(i14, 1000, 1000);
} else {
i14 = i36;
}
if (i38 == 2) {
jArr4 = new long[]{0, 0};
builder3.setVibrate(jArr4);
} else if (i38 == 1) {
jArr4 = new long[]{0, 100, 0, 100};
builder3.setVibrate(jArr4);
} else {
if (i38 != 0 && i38 != 4) {
if (i38 == 3) {
jArr3 = new long[]{0, 1000};
builder3.setVibrate(jArr3);
jArr2 = jArr3;
uri = uri2;
} else {
jArr2 = jArr;
uri = uri2;
}
}
builder3.setDefaults(2);
jArr3 = new long[0];
jArr2 = jArr3;
uri = uri2;
}
jArr2 = jArr4;
uri = uri2;
}
uri2 = Settings.System.DEFAULT_NOTIFICATION_URI;
if (i36 != 0) {
}
if (i38 == 2) {
}
jArr2 = jArr4;
uri = uri2;
} else if (str20.equals(obj)) {
builder3.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, 5);
} else if (i39 >= 24 && str20.startsWith("file://") && !AndroidUtilities.isInternalUri(Uri.parse(str20))) {
try {
Uri uriForFile2 = FileProvider.getUriForFile(ApplicationLoader.applicationContext, ApplicationLoader.getApplicationId() + ".provider", new File(str20.replace("file://", charSequence)));
ApplicationLoader.applicationContext.grantUriPermission("com.android.systemui", uriForFile2, 1);
builder3.setSound(uriForFile2, 5);
} catch (Exception unused2) {
builder3.setSound(Uri.parse(str20), 5);
}
} else {
builder3.setSound(Uri.parse(str20), 5);
}
}
uri2 = jArr;
if (i36 != 0) {
}
if (i38 == 2) {
}
jArr2 = jArr4;
uri = uri2;
} else {
i14 = i36;
long[] jArr6 = {0, 0};
builder3.setVibrate(jArr6);
jArr2 = jArr6;
uri = jArr;
}
if (AndroidUtilities.needShowPasscode() || SharedConfig.isWaitingForPasscodeEnter || messageObject3.getDialogId() != 777000 || (tLRPC$ReplyMarkup = messageObject3.messageOwner.reply_markup) == null) {
i15 = i13;
j7 = j16;
z21 = false;
} else {
ArrayList<TLRPC$TL_keyboardButtonRow> arrayList4 = tLRPC$ReplyMarkup.rows;
int size = arrayList4.size();
int i40 = 0;
boolean z26 = false;
while (i40 < size) {
TLRPC$TL_keyboardButtonRow tLRPC$TL_keyboardButtonRow2 = arrayList4.get(i40);
int size2 = tLRPC$TL_keyboardButtonRow2.buttons.size();
boolean z27 = z26;
int i41 = 0;
while (i41 < size2) {
TLRPC$KeyboardButton tLRPC$KeyboardButton = tLRPC$TL_keyboardButtonRow2.buttons.get(i41);
int i42 = size2;
if (tLRPC$KeyboardButton instanceof TLRPC$TL_keyboardButtonCallback) {
arrayList = arrayList4;
i17 = size;
Intent intent3 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationCallbackReceiver.class);
intent3.putExtra(str19, this.currentAccount);
TLRPC$TL_keyboardButtonRow tLRPC$TL_keyboardButtonRow3 = tLRPC$TL_keyboardButtonRow2;
i18 = i13;
j8 = j16;
intent3.putExtra("did", j8);
byte[] bArr = tLRPC$KeyboardButton.data;
if (bArr != null) {
tLRPC$TL_keyboardButtonRow = tLRPC$TL_keyboardButtonRow3;
intent3.putExtra("data", bArr);
} else {
tLRPC$TL_keyboardButtonRow = tLRPC$TL_keyboardButtonRow3;
}
intent3.putExtra("mid", messageObject3.getId());
String str21 = tLRPC$KeyboardButton.text;
Context context = ApplicationLoader.applicationContext;
int i43 = this.lastButtonId;
messageObject4 = messageObject3;
this.lastButtonId = i43 + 1;
builder3.addAction(0, str21, PendingIntent.getBroadcast(context, i43, intent3, 167772160));
z27 = true;
} else {
arrayList = arrayList4;
messageObject4 = messageObject3;
i17 = size;
tLRPC$TL_keyboardButtonRow = tLRPC$TL_keyboardButtonRow2;
i18 = i13;
j8 = j16;
}
i41++;
size2 = i42;
j16 = j8;
arrayList4 = arrayList;
size = i17;
i13 = i18;
tLRPC$TL_keyboardButtonRow2 = tLRPC$TL_keyboardButtonRow;
messageObject3 = messageObject4;
}
i40++;
z26 = z27;
arrayList4 = arrayList4;
i13 = i13;
}
i15 = i13;
j7 = j16;
z21 = z26;
}
if (!z21 && (i16 = Build.VERSION.SDK_INT) < 24 && SharedConfig.passcodeHash.length() == 0 && hasMessagesToReply()) {
Intent intent4 = new Intent(ApplicationLoader.applicationContext, (Class<?>) PopupReplyReceiver.class);
intent4.putExtra(str19, this.currentAccount);
if (i16 <= 19) {
builder3.addAction(R.drawable.ic_ab_reply2, LocaleController.getString("Reply", R.string.Reply), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, intent4, 167772160));
} else {
builder3.addAction(R.drawable.ic_ab_reply, LocaleController.getString("Reply", R.string.Reply), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, intent4, 167772160));
}
}
showExtraNotifications(builder3, str7, j7, j6, str16, jArr2, i14, uri, i15, z19, z13, z12, i6);
scheduleNotificationRepeat();
return;
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
}
} else {
tLRPC$User2 = tLRPC$User;
if (this.pushDialogs.size() == 1 && j4 != globalSecretChatId) {
intent.putExtra("encId", DialogObject.getEncryptedChatId(j4));
}
}
tLRPC$FileLocation = null;
String str192 = str2;
intent.putExtra(str192, this.currentAccount);
long j162 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen2 = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str202 = str13;
int i382 = i11;
showWhen2.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null) {
builder3.addPerson("tel:+" + tLRPC$User2.phone);
}
Intent intent22 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent22.putExtra("messageDate", messageObject3.messageOwner.date);
intent22.putExtra(str192, this.currentAccount);
if (messageObject3.isStoryPush) {
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent22, 167772160));
if (bitmap2 == null) {
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
}
tLRPC$User2 = tLRPC$User;
tLRPC$FileLocation = null;
String str1922 = str2;
intent.putExtra(str1922, this.currentAccount);
long j1622 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen22 = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str2022 = str13;
int i3822 = i11;
showWhen22.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null) {
}
Intent intent222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent222.putExtra("messageDate", messageObject3.messageOwner.date);
intent222.putExtra(str1922, this.currentAccount);
if (messageObject3.isStoryPush) {
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent222, 167772160));
if (bitmap2 == null) {
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
}
}
z19 = z18;
if (z13) {
}
if (z17) {
ringerMode = audioManager.getRingerMode();
if (ringerMode != 0) {
i10 = 2;
}
}
if (z12) {
}
Intent intent5 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
StringBuilder sb32 = new StringBuilder();
sb32.append("com.tmessages.openchat");
int i362 = i12;
sb32.append(Math.random());
sb32.append(ConnectionsManager.DEFAULT_DATACENTER_ID);
intent5.setAction(sb32.toString());
intent5.setFlags(ConnectionsManager.FileTypeFile);
messageObject3 = messageObject2;
if (!messageObject3.isStoryPush) {
}
tLRPC$User2 = tLRPC$User;
tLRPC$FileLocation = null;
String str19222 = str2;
intent5.putExtra(str19222, this.currentAccount);
long j16222 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen222 = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent5, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str20222 = str13;
int i38222 = i11;
showWhen222.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null) {
}
Intent intent2222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent2222.putExtra("messageDate", messageObject3.messageOwner.date);
intent2222.putExtra(str19222, this.currentAccount);
if (messageObject3.isStoryPush) {
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent2222, 167772160));
if (bitmap2 == null) {
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
}
} else if (z2) {
str10 = str8;
charSequence2 = string;
builder2 = builder;
long j17 = sharedPreferences2.getLong("ChannelSoundDocId", 0L);
if (j17 != 0) {
string4 = getMediaDataController().ringtoneDataStore.getSoundPath(j17);
z16 = true;
} else {
string4 = sharedPreferences2.getString("ChannelSoundPath", path);
z16 = false;
}
int i44 = sharedPreferences2.getInt("vibrate_channel", 0);
str12 = string4;
i5 = sharedPreferences2.getInt("priority_channel", 1);
i7 = sharedPreferences2.getInt("ChannelLed", -16776961);
i4 = i44;
i6 = 2;
} else {
str10 = str8;
charSequence2 = string;
builder2 = builder;
long j18 = sharedPreferences2.getLong("GroupSoundDocId", 0L);
if (j18 != 0) {
string3 = getMediaDataController().ringtoneDataStore.getSoundPath(j18);
z16 = true;
} else {
string3 = sharedPreferences2.getString("GroupSoundPath", path);
z16 = false;
}
int i45 = sharedPreferences2.getInt("vibrate_group", 0);
str12 = string3;
i5 = sharedPreferences2.getInt("priority_group", 1);
i7 = sharedPreferences2.getInt("GroupLed", -16776961);
i4 = i45;
i6 = 0;
}
obj = path;
boolean z28 = z16;
i3 = i7;
str11 = str12;
z15 = z28;
if (i4 == 4) {
}
if (TextUtils.isEmpty(str9)) {
}
str9 = str11;
z14 = z15;
i9 = 3;
z18 = true;
if (i2 != i9) {
i5 = i2;
z18 = false;
}
if (num != null) {
i3 = num.intValue();
z18 = false;
}
if (i != 0) {
}
i10 = i8;
z19 = z18;
if (z13) {
}
if (z17) {
}
if (z12) {
}
Intent intent52 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
StringBuilder sb322 = new StringBuilder();
sb322.append("com.tmessages.openchat");
int i3622 = i12;
sb322.append(Math.random());
sb322.append(ConnectionsManager.DEFAULT_DATACENTER_ID);
intent52.setAction(sb322.toString());
intent52.setFlags(ConnectionsManager.FileTypeFile);
messageObject3 = messageObject2;
if (!messageObject3.isStoryPush) {
}
tLRPC$User2 = tLRPC$User;
tLRPC$FileLocation = null;
String str192222 = str2;
intent52.putExtra(str192222, this.currentAccount);
long j162222 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen2222 = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent52, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str202222 = str13;
int i382222 = i11;
showWhen2222.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null) {
}
Intent intent22222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent22222.putExtra("messageDate", messageObject3.messageOwner.date);
intent22222.putExtra(str192222, this.currentAccount);
if (messageObject3.isStoryPush) {
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent22222, 167772160));
if (bitmap2 == null) {
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
}
}
z12 = z11;
String path2 = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
if (ApplicationLoader.mainInterfacePaused) {
}
getSharedPrefKey(j4, j5);
if (this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_CUSTOM, j4, j5, false)) {
}
if (j12 != 0) {
}
obj = path2;
boolean z282 = z16;
i3 = i7;
str11 = str12;
z15 = z282;
if (i4 == 4) {
}
if (TextUtils.isEmpty(str9)) {
}
str9 = str11;
z14 = z15;
i9 = 3;
z18 = true;
if (i2 != i9) {
}
if (num != null) {
}
if (i != 0) {
}
i10 = i8;
z19 = z18;
if (z13) {
}
if (z17) {
}
if (z12) {
}
Intent intent522 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
StringBuilder sb3222 = new StringBuilder();
sb3222.append("com.tmessages.openchat");
int i36222 = i12;
sb3222.append(Math.random());
sb3222.append(ConnectionsManager.DEFAULT_DATACENTER_ID);
intent522.setAction(sb3222.toString());
intent522.setFlags(ConnectionsManager.FileTypeFile);
messageObject3 = messageObject2;
if (!messageObject3.isStoryPush) {
}
tLRPC$User2 = tLRPC$User;
tLRPC$FileLocation = null;
String str1922222 = str2;
intent522.putExtra(str1922222, this.currentAccount);
long j1622222 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen22222 = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent522, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str2022222 = str13;
int i3822222 = i11;
showWhen22222.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null) {
}
Intent intent222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent222222.putExtra("messageDate", messageObject3.messageOwner.date);
intent222222.putExtra(str1922222, this.currentAccount);
if (messageObject3.isStoryPush) {
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent222222, 167772160));
if (bitmap2 == null) {
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
}
}
}
}
str6 = str4;
z9 = z8;
str7 = str3;
} else {
str6 = str4;
z9 = z8;
str7 = str3;
sharedPreferences2 = sharedPreferences;
j4 = j3;
}
z10 = z9;
if (z10) {
}
z12 = z11;
String path22 = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
if (ApplicationLoader.mainInterfacePaused) {
}
getSharedPrefKey(j4, j5);
if (this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_CUSTOM, j4, j5, false)) {
}
if (j12 != 0) {
}
obj = path22;
boolean z2822 = z16;
i3 = i7;
str11 = str12;
z15 = z2822;
if (i4 == 4) {
}
if (TextUtils.isEmpty(str9)) {
}
str9 = str11;
z14 = z15;
i9 = 3;
z18 = true;
if (i2 != i9) {
}
if (num != null) {
}
if (i != 0) {
}
i10 = i8;
z19 = z18;
if (z13) {
}
if (z17) {
}
if (z12) {
}
Intent intent5222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
StringBuilder sb32222 = new StringBuilder();
sb32222.append("com.tmessages.openchat");
int i362222 = i12;
sb32222.append(Math.random());
sb32222.append(ConnectionsManager.DEFAULT_DATACENTER_ID);
intent5222.setAction(sb32222.toString());
intent5222.setFlags(ConnectionsManager.FileTypeFile);
messageObject3 = messageObject2;
if (!messageObject3.isStoryPush) {
}
tLRPC$User2 = tLRPC$User;
tLRPC$FileLocation = null;
String str19222222 = str2;
intent5222.putExtra(str19222222, this.currentAccount);
long j16222222 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen222222 = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent5222, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str20222222 = str13;
int i38222222 = i11;
showWhen222222.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null) {
}
Intent intent2222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent2222222.putExtra("messageDate", messageObject3.messageOwner.date);
intent2222222.putExtra(str19222222, this.currentAccount);
if (messageObject3.isStoryPush) {
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent2222222, 167772160));
if (bitmap2 == null) {
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
}
z8 = true;
if (z8) {
}
str6 = str4;
z9 = z8;
str7 = str3;
sharedPreferences2 = sharedPreferences;
j4 = j3;
z10 = z9;
if (z10) {
}
z12 = z11;
String path222 = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
if (ApplicationLoader.mainInterfacePaused) {
}
getSharedPrefKey(j4, j5);
if (this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_CUSTOM, j4, j5, false)) {
}
if (j12 != 0) {
}
obj = path222;
boolean z28222 = z16;
i3 = i7;
str11 = str12;
z15 = z28222;
if (i4 == 4) {
}
if (TextUtils.isEmpty(str9)) {
}
str9 = str11;
z14 = z15;
i9 = 3;
z18 = true;
if (i2 != i9) {
}
if (num != null) {
}
if (i != 0) {
}
i10 = i8;
z19 = z18;
if (z13) {
}
if (z17) {
}
if (z12) {
}
Intent intent52222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
StringBuilder sb322222 = new StringBuilder();
sb322222.append("com.tmessages.openchat");
int i3622222 = i12;
sb322222.append(Math.random());
sb322222.append(ConnectionsManager.DEFAULT_DATACENTER_ID);
intent52222.setAction(sb322222.toString());
intent52222.setFlags(ConnectionsManager.FileTypeFile);
messageObject3 = messageObject2;
if (!messageObject3.isStoryPush) {
}
tLRPC$User2 = tLRPC$User;
tLRPC$FileLocation = null;
String str192222222 = str2;
intent52222.putExtra(str192222222, this.currentAccount);
long j162222222 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen2222222 = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent52222, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str202222222 = str13;
int i382222222 = i11;
showWhen2222222.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null) {
}
Intent intent22222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent22222222.putExtra("messageDate", messageObject3.messageOwner.date);
intent22222222.putExtra(str192222222, this.currentAccount);
if (messageObject3.isStoryPush) {
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent22222222, 167772160));
if (bitmap2 == null) {
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
}
str2 = "currentAccount";
if (this.pushDialogs.size() != 1) {
StringBuilder sb4 = new StringBuilder();
sb4.append(str);
tLRPC$User = user;
sb4.append(LocaleController.formatPluralString("NewMessages", this.total_unread_count, new Object[0]));
str = sb4.toString();
sharedPreferences = notificationsSettings;
j3 = dialogId;
NotificationCompat.Builder builder42 = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
if (this.pushMessages.size() > 1) {
}
if (z) {
z8 = false;
if (z8) {
}
str6 = str4;
z9 = z8;
str7 = str3;
sharedPreferences2 = sharedPreferences;
j4 = j3;
z10 = z9;
if (z10) {
}
z12 = z11;
String path2222 = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
if (ApplicationLoader.mainInterfacePaused) {
}
getSharedPrefKey(j4, j5);
if (this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_CUSTOM, j4, j5, false)) {
}
if (j12 != 0) {
}
obj = path2222;
boolean z282222 = z16;
i3 = i7;
str11 = str12;
z15 = z282222;
if (i4 == 4) {
}
if (TextUtils.isEmpty(str9)) {
}
str9 = str11;
z14 = z15;
i9 = 3;
z18 = true;
if (i2 != i9) {
}
if (num != null) {
}
if (i != 0) {
}
i10 = i8;
z19 = z18;
if (z13) {
}
if (z17) {
}
if (z12) {
}
Intent intent522222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
StringBuilder sb3222222 = new StringBuilder();
sb3222222.append("com.tmessages.openchat");
int i36222222 = i12;
sb3222222.append(Math.random());
sb3222222.append(ConnectionsManager.DEFAULT_DATACENTER_ID);
intent522222.setAction(sb3222222.toString());
intent522222.setFlags(ConnectionsManager.FileTypeFile);
messageObject3 = messageObject2;
if (!messageObject3.isStoryPush) {
}
tLRPC$User2 = tLRPC$User;
tLRPC$FileLocation = null;
String str1922222222 = str2;
intent522222.putExtra(str1922222222, this.currentAccount);
long j1622222222 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen22222222 = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent522222, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str2022222222 = str13;
int i3822222222 = i11;
showWhen22222222.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null) {
}
Intent intent222222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent222222222.putExtra("messageDate", messageObject3.messageOwner.date);
intent222222222.putExtra(str1922222222, this.currentAccount);
if (messageObject3.isStoryPush) {
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent222222222, 167772160));
if (bitmap2 == null) {
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
}
z8 = true;
if (z8) {
}
str6 = str4;
z9 = z8;
str7 = str3;
sharedPreferences2 = sharedPreferences;
j4 = j3;
z10 = z9;
if (z10) {
}
z12 = z11;
String path22222 = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
if (ApplicationLoader.mainInterfacePaused) {
}
getSharedPrefKey(j4, j5);
if (this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_CUSTOM, j4, j5, false)) {
}
if (j12 != 0) {
}
obj = path22222;
boolean z2822222 = z16;
i3 = i7;
str11 = str12;
z15 = z2822222;
if (i4 == 4) {
}
if (TextUtils.isEmpty(str9)) {
}
str9 = str11;
z14 = z15;
i9 = 3;
z18 = true;
if (i2 != i9) {
}
if (num != null) {
}
if (i != 0) {
}
i10 = i8;
z19 = z18;
if (z13) {
}
if (z17) {
}
if (z12) {
}
Intent intent5222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
StringBuilder sb32222222 = new StringBuilder();
sb32222222.append("com.tmessages.openchat");
int i362222222 = i12;
sb32222222.append(Math.random());
sb32222222.append(ConnectionsManager.DEFAULT_DATACENTER_ID);
intent5222222.setAction(sb32222222.toString());
intent5222222.setFlags(ConnectionsManager.FileTypeFile);
messageObject3 = messageObject2;
if (!messageObject3.isStoryPush) {
}
tLRPC$User2 = tLRPC$User;
tLRPC$FileLocation = null;
String str19222222222 = str2;
intent5222222.putExtra(str19222222222, this.currentAccount);
long j16222222222 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen222222222 = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent5222222, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str20222222222 = str13;
int i38222222222 = i11;
showWhen222222222.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null) {
}
Intent intent2222222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent2222222222.putExtra("messageDate", messageObject3.messageOwner.date);
intent2222222222.putExtra(str19222222222, this.currentAccount);
if (messageObject3.isStoryPush) {
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent2222222222, 167772160));
if (bitmap2 == null) {
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
} else {
tLRPC$User = user;
StringBuilder sb5 = new StringBuilder();
sb5.append(str);
sharedPreferences = notificationsSettings;
j3 = dialogId;
sb5.append(LocaleController.formatString("NotificationMessagesPeopleDisplayOrder", R.string.NotificationMessagesPeopleDisplayOrder, LocaleController.formatPluralString("NewMessages", this.total_unread_count, new Object[0]), LocaleController.formatPluralString("FromChats", this.pushDialogs.size(), new Object[0])));
str = sb5.toString();
NotificationCompat.Builder builder422 = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
if (this.pushMessages.size() > 1) {
}
if (z) {
}
z8 = true;
if (z8) {
}
str6 = str4;
z9 = z8;
str7 = str3;
sharedPreferences2 = sharedPreferences;
j4 = j3;
z10 = z9;
if (z10) {
}
z12 = z11;
String path222222 = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
if (ApplicationLoader.mainInterfacePaused) {
}
getSharedPrefKey(j4, j5);
if (this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_CUSTOM, j4, j5, false)) {
}
if (j12 != 0) {
}
obj = path222222;
boolean z28222222 = z16;
i3 = i7;
str11 = str12;
z15 = z28222222;
if (i4 == 4) {
}
if (TextUtils.isEmpty(str9)) {
}
str9 = str11;
z14 = z15;
i9 = 3;
z18 = true;
if (i2 != i9) {
}
if (num != null) {
}
if (i != 0) {
}
i10 = i8;
z19 = z18;
if (z13) {
}
if (z17) {
}
if (z12) {
}
Intent intent52222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
StringBuilder sb322222222 = new StringBuilder();
sb322222222.append("com.tmessages.openchat");
int i3622222222 = i12;
sb322222222.append(Math.random());
sb322222222.append(ConnectionsManager.DEFAULT_DATACENTER_ID);
intent52222222.setAction(sb322222222.toString());
intent52222222.setFlags(ConnectionsManager.FileTypeFile);
messageObject3 = messageObject2;
if (!messageObject3.isStoryPush) {
}
tLRPC$User2 = tLRPC$User;
tLRPC$FileLocation = null;
String str192222222222 = str2;
intent52222222.putExtra(str192222222222, this.currentAccount);
long j162222222222 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen2222222222 = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent52222222, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str202222222222 = str13;
int i382222222222 = i11;
showWhen2222222222.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null) {
}
Intent intent22222222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent22222222222.putExtra("messageDate", messageObject3.messageOwner.date);
intent22222222222.putExtra(str192222222222, this.currentAccount);
if (messageObject3.isStoryPush) {
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent22222222222, 167772160));
if (bitmap2 == null) {
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
}
}
string = LocaleController.getString("AppName", R.string.AppName);
z5 = false;
if (UserConfig.getActivatedAccountsCount() > 1) {
}
if (this.pushDialogs.size() == 1) {
str2 = "currentAccount";
tLRPC$User = user;
sharedPreferences = notificationsSettings;
j3 = dialogId;
NotificationCompat.Builder builder4222 = new NotificationCompat.Builder(ApplicationLoader.applicationContext);
if (this.pushMessages.size() > 1) {
}
if (z) {
}
z8 = true;
if (z8) {
}
str6 = str4;
z9 = z8;
str7 = str3;
sharedPreferences2 = sharedPreferences;
j4 = j3;
z10 = z9;
if (z10) {
}
z12 = z11;
String path2222222 = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
if (ApplicationLoader.mainInterfacePaused) {
}
getSharedPrefKey(j4, j5);
if (this.dialogsNotificationsFacade.getProperty(NotificationsSettingsFacade.PROPERTY_CUSTOM, j4, j5, false)) {
}
if (j12 != 0) {
}
obj = path2222222;
boolean z282222222 = z16;
i3 = i7;
str11 = str12;
z15 = z282222222;
if (i4 == 4) {
}
if (TextUtils.isEmpty(str9)) {
}
str9 = str11;
z14 = z15;
i9 = 3;
z18 = true;
if (i2 != i9) {
}
if (num != null) {
}
if (i != 0) {
}
i10 = i8;
z19 = z18;
if (z13) {
}
if (z17) {
}
if (z12) {
}
Intent intent522222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
StringBuilder sb3222222222 = new StringBuilder();
sb3222222222.append("com.tmessages.openchat");
int i36222222222 = i12;
sb3222222222.append(Math.random());
sb3222222222.append(ConnectionsManager.DEFAULT_DATACENTER_ID);
intent522222222.setAction(sb3222222222.toString());
intent522222222.setFlags(ConnectionsManager.FileTypeFile);
messageObject3 = messageObject2;
if (!messageObject3.isStoryPush) {
}
tLRPC$User2 = tLRPC$User;
tLRPC$FileLocation = null;
String str1922222222222 = str2;
intent522222222.putExtra(str1922222222222, this.currentAccount);
long j1622222222222 = j4;
builder3 = builder2;
NotificationCompat.Builder showWhen22222222222 = builder3.setContentTitle(charSequence2).setSmallIcon(R.drawable.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent522222222, 1140850688)).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true);
String str2022222222222 = str13;
int i3822222222222 = i11;
showWhen22222222222.setWhen(messageObject3.messageOwner.date * 1000).setColor(-15618822);
builder3.setCategory("msg");
if (tLRPC$Chat2 == null) {
}
Intent intent222222222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent222222222222.putExtra("messageDate", messageObject3.messageOwner.date);
intent222222222222.putExtra(str1922222222222, this.currentAccount);
if (messageObject3.isStoryPush) {
}
builder3.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, i20, intent222222222222, 167772160));
if (bitmap2 == null) {
}
jArr = null;
if (z) {
}
builder3.setPriority(-1);
}
str2 = "currentAccount";
if (this.pushDialogs.size() != 1) {
}
}
z4 = true;
if (!DialogObject.isEncryptedDialog(dialogId)) {
string = str16;
z5 = true;
if (UserConfig.getActivatedAccountsCount() > 1) {
}
if (this.pushDialogs.size() == 1) {
}
str2 = "currentAccount";
if (this.pushDialogs.size() != 1) {
}
}
string = LocaleController.getString("AppName", R.string.AppName);
z5 = false;
if (UserConfig.getActivatedAccountsCount() > 1) {
}
if (this.pushDialogs.size() == 1) {
}
str2 = "currentAccount";
if (this.pushDialogs.size() != 1) {
}
} catch (Exception e2) {
FileLog.e(e2);
}
}
private boolean isSilentMessage(MessageObject messageObject) {
return messageObject.messageOwner.silent || messageObject.isReactionPush;
}
@SuppressLint({"NewApi"})
private void setNotificationChannel(Notification notification, NotificationCompat.Builder builder, boolean z) {
if (z) {
builder.setChannelId(OTHER_NOTIFICATIONS_CHANNEL);
} else {
builder.setChannelId(notification.getChannelId());
}
}
public void resetNotificationSound(NotificationCompat.Builder builder, long j, long j2, String str, long[] jArr, int i, Uri uri, int i2, boolean z, boolean z2, boolean z3, int i3) {
Uri uri2 = Settings.System.DEFAULT_RINGTONE_URI;
if (uri2 == null || uri == null || TextUtils.equals(uri2.toString(), uri.toString())) {
return;
}
SharedPreferences.Editor edit = getAccountInstance().getNotificationsSettings().edit();
String uri3 = uri2.toString();
String string = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone);
if (z) {
if (i3 == 2) {
edit.putString("ChannelSound", string);
} else if (i3 == 0) {
edit.putString("GroupSound", string);
} else if (i3 == 1) {
edit.putString("GlobalSound", string);
} else if (i3 == 3) {
edit.putString("StoriesSound", string);
}
if (i3 == 2) {
edit.putString("ChannelSoundPath", uri3);
} else if (i3 == 0) {
edit.putString("GroupSoundPath", uri3);
} else if (i3 == 1) {
edit.putString("GlobalSoundPath", uri3);
} else if (i3 == 3) {
edit.putString("StoriesSoundPath", uri3);
}
getNotificationsController().lambda$deleteNotificationChannelGlobal$38(i3, -1);
} else {
edit.putString("sound_" + getSharedPrefKey(j, j2), string);
edit.putString("sound_path_" + getSharedPrefKey(j, j2), uri3);
lambda$deleteNotificationChannel$37(j, j2, -1);
}
edit.commit();
builder.setChannelId(validateChannelId(j, j2, str, jArr, i, Settings.System.DEFAULT_RINGTONE_URI, i2, z, z2, z3, i3));
notificationManager.notify(this.notificationId, builder.build());
}
@SuppressLint({"InlinedApi"})
private void showExtraNotifications(NotificationCompat.Builder builder, String str, long j, long j2, String str2, long[] jArr, int i, Uri uri, int i2, boolean z, boolean z2, boolean z3, int i3) {
NotificationCompat.Builder builder2;
boolean z4;
long clientUserId;
boolean z5;
int i4;
LongSparseArray longSparseArray;
int size;
int i5;
LongSparseArray longSparseArray2;
NotificationsController notificationsController;
ArrayList arrayList;
int i6;
int size2;
int i7;
LongSparseArray longSparseArray3;
DialogKey dialogKey;
int i8;
int i9;
ArrayList arrayList2;
long j3;
ArrayList arrayList3;
Notification notification;
long j4;
int id;
ArrayList<StoryNotification> arrayList4;
LongSparseArray longSparseArray4;
MessageObject messageObject;
boolean z6;
long j5;
int i10;
int i11;
LongSparseArray longSparseArray5;
String str3;
ArrayList<StoryNotification> arrayList5;
DialogKey dialogKey2;
MessageObject messageObject2;
Integer num;
long j6;
TLRPC$User tLRPC$User;
String string;
TLRPC$User tLRPC$User2;
boolean z7;
TLRPC$FileLocation tLRPC$FileLocation;
int i12;
NotificationsController notificationsController2;
LongSparseArray longSparseArray6;
ArrayList arrayList6;
Notification notification2;
boolean z8;
TLRPC$Chat tLRPC$Chat;
boolean z9;
boolean z10;
TLRPC$FileLocation tLRPC$FileLocation2;
String str4;
TLRPC$FileLocation tLRPC$FileLocation3;
ArrayList<StoryNotification> arrayList7;
TLRPC$User tLRPC$User3;
long j7;
DialogKey dialogKey3;
String str5;
String str6;
TLRPC$User tLRPC$User4;
Bitmap bitmap;
File file;
Bitmap bitmap2;
Bitmap bitmap3;
File file2;
long j8;
TLRPC$Chat tLRPC$Chat2;
String str7;
int i13;
String formatString;
NotificationCompat.Action build;
Integer num2;
DialogKey dialogKey4;
int max;
Person person;
String str8;
long j9;
NotificationCompat.MessagingStyle messagingStyle;
NotificationCompat.MessagingStyle messagingStyle2;
int i14;
long j10;
NotificationCompat.Action action;
String str9;
DialogKey dialogKey5;
ArrayList<TLRPC$TL_keyboardButtonRow> arrayList8;
LongSparseArray longSparseArray7;
StringBuilder sb;
ArrayList<StoryNotification> arrayList9;
int i15;
Bitmap bitmap4;
String str10;
LongSparseArray longSparseArray8;
ArrayList<TLRPC$TL_keyboardButtonRow> arrayList10;
long senderId;
StringBuilder sb2;
ArrayList<TLRPC$TL_keyboardButtonRow> arrayList11;
ArrayList<StoryNotification> arrayList12;
LongSparseArray longSparseArray9;
Person person2;
String str11;
String str12;
int i16;
String[] strArr;
File file3;
TLRPC$UserProfilePhoto tLRPC$UserProfilePhoto;
TLRPC$FileLocation tLRPC$FileLocation4;
LongSparseArray longSparseArray10;
TLRPC$ReplyMarkup tLRPC$ReplyMarkup;
boolean z11;
List<NotificationCompat.MessagingStyle.Message> messages;
Uri uri2;
File file4;
final File file5;
final Uri uriForFile;
File file6;
DialogKey dialogKey6;
long j11;
ArrayList<TLRPC$TL_keyboardButtonRow> arrayList13;
Bitmap bitmap5;
NotificationCompat.Action build2;
NotificationCompat.Action action2;
String str13;
long j12;
ArrayList<StoryNotification> arrayList14;
long j13;
NotificationCompat.Builder category;
TLRPC$User tLRPC$User5;
int size3;
int i17;
int i18;
ArrayList<TLRPC$TL_keyboardButtonRow> arrayList15;
String str14;
int i19;
TLRPC$User user;
TLRPC$UserProfilePhoto tLRPC$UserProfilePhoto2;
TLRPC$FileLocation tLRPC$FileLocation5;
Bitmap bitmap6;
String string2;
Integer num3;
TLRPC$UserProfilePhoto tLRPC$UserProfilePhoto3;
int i20 = Build.VERSION.SDK_INT;
if (i20 >= 26) {
builder2 = builder;
builder2.setChannelId(validateChannelId(j, j2, str2, jArr, i, uri, i2, z, z2, z3, i3));
} else {
builder2 = builder;
}
Notification build3 = builder.build();
if (i20 <= 19) {
notificationManager.notify(this.notificationId, build3);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("show summary notification by SDK check");
return;
}
return;
}
NotificationsController notificationsController3 = this;
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
ArrayList arrayList16 = new ArrayList();
if (!notificationsController3.storyPushMessages.isEmpty()) {
arrayList16.add(new DialogKey(0L, 0L, true));
}
LongSparseArray longSparseArray11 = new LongSparseArray();
int i21 = 0;
int i22 = 0;
while (i22 < notificationsController3.pushMessages.size()) {
MessageObject messageObject3 = notificationsController3.pushMessages.get(i22);
long dialogId = messageObject3.getDialogId();
long topicId = MessageObject.getTopicId(notificationsController3.currentAccount, messageObject3.messageOwner, getMessagesController().isForum(messageObject3));
int i23 = notificationsSettings.getInt("dismissDate" + dialogId, i21);
if (messageObject3.isStoryPush || messageObject3.messageOwner.date > i23) {
ArrayList arrayList17 = (ArrayList) longSparseArray11.get(dialogId);
if (arrayList17 == null) {
ArrayList arrayList18 = new ArrayList();
longSparseArray11.put(dialogId, arrayList18);
arrayList16.add(new DialogKey(dialogId, topicId, false));
arrayList17 = arrayList18;
}
arrayList17.add(messageObject3);
}
i22++;
i21 = 0;
}
LongSparseArray longSparseArray12 = new LongSparseArray();
for (int i24 = 0; i24 < notificationsController3.wearNotificationsIds.size(); i24++) {
longSparseArray12.put(notificationsController3.wearNotificationsIds.keyAt(i24), notificationsController3.wearNotificationsIds.valueAt(i24));
}
notificationsController3.wearNotificationsIds.clear();
ArrayList arrayList19 = new ArrayList();
int i25 = Build.VERSION.SDK_INT;
if (i25 > 27) {
if (arrayList16.size() <= (notificationsController3.storyPushMessages.isEmpty() ? 1 : 2)) {
z4 = false;
if (z4 && i25 >= 26) {
checkOtherNotificationsChannel();
}
clientUserId = getUserConfig().getClientUserId();
z5 = !AndroidUtilities.needShowPasscode() || SharedConfig.isWaitingForPasscodeEnter;
SharedConfig.passcodeHash.length();
i4 = 7;
longSparseArray = new LongSparseArray();
size = arrayList16.size();
i5 = 0;
while (i5 < size && arrayList19.size() < i4) {
dialogKey = (DialogKey) arrayList16.get(i5);
if (!dialogKey.story) {
ArrayList<StoryNotification> arrayList20 = new ArrayList<>();
if (notificationsController3.storyPushMessages.isEmpty()) {
longSparseArray6 = longSparseArray;
j7 = clientUserId;
z8 = z4;
i8 = size;
i9 = i5;
longSparseArray5 = longSparseArray12;
longSparseArray4 = longSparseArray11;
arrayList3 = arrayList16;
notification2 = build3;
notificationsController2 = notificationsController3;
i12 = 7;
arrayList6 = arrayList19;
i5 = i9 + 1;
arrayList19 = arrayList6;
i4 = i12;
size = i8;
arrayList16 = arrayList3;
longSparseArray11 = longSparseArray4;
clientUserId = j7;
z4 = z8;
longSparseArray12 = longSparseArray5;
longSparseArray = longSparseArray6;
build3 = notification2;
notificationsController3 = notificationsController2;
} else {
i8 = size;
i9 = i5;
arrayList2 = arrayList19;
j3 = notificationsController3.storyPushMessages.get(0).dialogId;
Iterator<Integer> it = notificationsController3.storyPushMessages.get(0).dateByIds.keySet().iterator();
id = 0;
while (it.hasNext()) {
id = Math.max(id, it.next().intValue());
arrayList20 = arrayList20;
}
longSparseArray4 = longSparseArray11;
notification = build3;
arrayList4 = arrayList20;
messageObject = null;
arrayList3 = arrayList16;
j4 = 0;
}
} else {
i8 = size;
i9 = i5;
arrayList2 = arrayList19;
j3 = dialogKey.dialogId;
arrayList3 = arrayList16;
notification = build3;
j4 = dialogKey.topicId;
ArrayList<StoryNotification> arrayList21 = (ArrayList) longSparseArray11.get(j3);
id = ((MessageObject) arrayList21.get(0)).getId();
arrayList4 = arrayList21;
longSparseArray4 = longSparseArray11;
messageObject = (MessageObject) arrayList21.get(0);
}
int i26 = (Integer) longSparseArray12.get(j3);
z6 = z4;
if (!dialogKey.story) {
i26 = 2147483646;
j5 = j4;
} else if (i26 == null) {
j5 = j4;
i26 = Integer.valueOf(((int) j3) + ((int) (j3 >> 32)));
} else {
j5 = j4;
longSparseArray12.remove(j3);
}
Integer num4 = i26;
int i27 = 0;
for (i10 = 0; i10 < arrayList4.size(); i10++) {
if (i27 < ((MessageObject) arrayList4.get(i10)).messageOwner.date) {
i27 = ((MessageObject) arrayList4.get(i10)).messageOwner.date;
}
}
if (!dialogKey.story) {
TLRPC$User user2 = getMessagesController().getUser(Long.valueOf(j3));
longSparseArray5 = longSparseArray12;
if (notificationsController3.storyPushMessages.size() == 1) {
if (user2 != null) {
string = UserObject.getFirstName(user2);
} else {
string = notificationsController3.storyPushMessages.get(0).localName;
}
i11 = i27;
} else {
i11 = i27;
string = LocaleController.formatPluralString("Stories", notificationsController3.storyPushMessages.size(), new Object[0]);
}
if (user2 == null || (tLRPC$UserProfilePhoto3 = user2.photo) == null || (tLRPC$FileLocation = tLRPC$UserProfilePhoto3.photo_small) == null) {
str3 = "Stories";
num3 = num4;
} else {
str3 = "Stories";
num3 = num4;
if (tLRPC$FileLocation.volume_id != 0 && tLRPC$FileLocation.local_id != 0) {
arrayList5 = arrayList4;
dialogKey2 = dialogKey;
messageObject2 = messageObject;
num = num3;
j6 = j5;
tLRPC$Chat = null;
z9 = false;
z10 = false;
tLRPC$User2 = user2;
z7 = false;
}
}
arrayList5 = arrayList4;
dialogKey2 = dialogKey;
messageObject2 = messageObject;
num = num3;
j6 = j5;
tLRPC$FileLocation = null;
tLRPC$Chat = null;
z9 = false;
z10 = false;
tLRPC$User2 = user2;
z7 = false;
} else {
i11 = i27;
longSparseArray5 = longSparseArray12;
str3 = "Stories";
if (!DialogObject.isEncryptedDialog(j3)) {
z7 = (messageObject == null || messageObject.isReactionPush || j3 == 777000) ? false : true;
if (DialogObject.isUserDialog(j3)) {
TLRPC$User user3 = getMessagesController().getUser(Long.valueOf(j3));
if (user3 == null) {
if (messageObject.isFcmMessage()) {
string = messageObject.localName;
} else if (BuildVars.LOGS_ENABLED) {
FileLog.w("not found user to show dialog notification " + j3);
}
} else {
string = UserObject.getUserName(user3);
TLRPC$UserProfilePhoto tLRPC$UserProfilePhoto4 = user3.photo;
if (tLRPC$UserProfilePhoto4 != null && (tLRPC$FileLocation3 = tLRPC$UserProfilePhoto4.photo_small) != null) {
arrayList7 = arrayList4;
tLRPC$User3 = user3;
if (tLRPC$FileLocation3.volume_id != 0 && tLRPC$FileLocation3.local_id != 0) {
tLRPC$FileLocation = tLRPC$FileLocation3;
if (UserObject.isReplyUser(j3)) {
string = LocaleController.getString("RepliesTitle", R.string.RepliesTitle);
} else if (j3 == clientUserId) {
string = LocaleController.getString("MessageScheduledReminderNotification", R.string.MessageScheduledReminderNotification);
}
dialogKey2 = dialogKey;
messageObject2 = messageObject;
arrayList5 = arrayList7;
num = num4;
j6 = j5;
tLRPC$User2 = tLRPC$User3;
}
tLRPC$FileLocation = null;
if (UserObject.isReplyUser(j3)) {
}
dialogKey2 = dialogKey;
messageObject2 = messageObject;
arrayList5 = arrayList7;
num = num4;
j6 = j5;
tLRPC$User2 = tLRPC$User3;
}
}
arrayList7 = arrayList4;
tLRPC$User3 = user3;
tLRPC$FileLocation = null;
if (UserObject.isReplyUser(j3)) {
}
dialogKey2 = dialogKey;
messageObject2 = messageObject;
arrayList5 = arrayList7;
num = num4;
j6 = j5;
tLRPC$User2 = tLRPC$User3;
} else {
ArrayList<StoryNotification> arrayList22 = arrayList4;
TLRPC$Chat chat = getMessagesController().getChat(Long.valueOf(-j3));
if (chat == null) {
if (messageObject.isFcmMessage()) {
boolean isSupergroup = messageObject.isSupergroup();
string = messageObject.localName;
z9 = isSupergroup;
tLRPC$Chat = chat;
arrayList5 = arrayList22;
messageObject2 = messageObject;
z10 = messageObject.localChannel;
num = num4;
j6 = j5;
z7 = false;
tLRPC$FileLocation = null;
tLRPC$User2 = null;
dialogKey2 = dialogKey;
} else if (BuildVars.LOGS_ENABLED) {
FileLog.w("not found chat to show dialog notification " + j3);
}
} else {
boolean z12 = chat.megagroup;
boolean z13 = ChatObject.isChannel(chat) && !chat.megagroup;
String str15 = chat.title;
z9 = z12;
TLRPC$ChatPhoto tLRPC$ChatPhoto = chat.photo;
if (tLRPC$ChatPhoto == null || (tLRPC$FileLocation2 = tLRPC$ChatPhoto.photo_small) == null) {
messageObject2 = messageObject;
z10 = z13;
} else {
messageObject2 = messageObject;
z10 = z13;
if (tLRPC$FileLocation2.volume_id != 0) {
}
}
tLRPC$FileLocation2 = null;
if (j5 != 0) {
arrayList5 = arrayList22;
dialogKey2 = dialogKey;
num = num4;
j6 = j5;
TLRPC$TL_forumTopic findTopic = getMessagesController().getTopicsController().findTopic(chat.id, j6);
if (findTopic != null) {
str4 = findTopic.title + " in " + str15;
if (z7) {
z7 = ChatObject.canSendPlain(chat);
}
tLRPC$Chat = chat;
tLRPC$User2 = null;
TLRPC$FileLocation tLRPC$FileLocation6 = tLRPC$FileLocation2;
string = str4;
tLRPC$FileLocation = tLRPC$FileLocation6;
}
} else {
arrayList5 = arrayList22;
dialogKey2 = dialogKey;
num = num4;
j6 = j5;
}
str4 = str15;
if (z7) {
}
tLRPC$Chat = chat;
tLRPC$User2 = null;
TLRPC$FileLocation tLRPC$FileLocation62 = tLRPC$FileLocation2;
string = str4;
tLRPC$FileLocation = tLRPC$FileLocation62;
}
}
longSparseArray6 = longSparseArray;
notificationsController2 = notificationsController3;
arrayList6 = arrayList2;
notification2 = notification;
z8 = z6;
i12 = 7;
j7 = clientUserId;
i5 = i9 + 1;
arrayList19 = arrayList6;
i4 = i12;
size = i8;
arrayList16 = arrayList3;
longSparseArray11 = longSparseArray4;
clientUserId = j7;
z4 = z8;
longSparseArray12 = longSparseArray5;
longSparseArray = longSparseArray6;
build3 = notification2;
notificationsController3 = notificationsController2;
} else {
arrayList5 = arrayList4;
dialogKey2 = dialogKey;
messageObject2 = messageObject;
num = num4;
j6 = j5;
if (j3 != globalSecretChatId) {
int encryptedChatId = DialogObject.getEncryptedChatId(j3);
TLRPC$EncryptedChat encryptedChat = getMessagesController().getEncryptedChat(Integer.valueOf(encryptedChatId));
if (encryptedChat == null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("not found secret chat to show dialog notification " + encryptedChatId);
}
} else {
tLRPC$User = getMessagesController().getUser(Long.valueOf(encryptedChat.user_id));
if (tLRPC$User == null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("not found secret chat user to show dialog notification " + encryptedChat.user_id);
}
}
}
i12 = 7;
notificationsController2 = this;
longSparseArray6 = longSparseArray;
arrayList6 = arrayList2;
notification2 = notification;
z8 = z6;
j7 = clientUserId;
i5 = i9 + 1;
arrayList19 = arrayList6;
i4 = i12;
size = i8;
arrayList16 = arrayList3;
longSparseArray11 = longSparseArray4;
clientUserId = j7;
z4 = z8;
longSparseArray12 = longSparseArray5;
longSparseArray = longSparseArray6;
build3 = notification2;
notificationsController3 = notificationsController2;
} else {
tLRPC$User = null;
}
string = LocaleController.getString("SecretChatName", R.string.SecretChatName);
tLRPC$User2 = tLRPC$User;
z7 = false;
tLRPC$FileLocation = null;
}
tLRPC$Chat = null;
z9 = false;
z10 = false;
}
if (z5) {
dialogKey3 = dialogKey2;
} else {
if (DialogObject.isChatDialog(j3)) {
string2 = LocaleController.getString("NotificationHiddenChatName", R.string.NotificationHiddenChatName);
} else {
string2 = LocaleController.getString("NotificationHiddenName", R.string.NotificationHiddenName);
}
string = string2;
dialogKey3 = dialogKey2;
z7 = false;
tLRPC$FileLocation = null;
}
if (tLRPC$FileLocation == null) {
tLRPC$User4 = tLRPC$User2;
file = getFileLoader().getPathToAttach(tLRPC$FileLocation, true);
str6 = "NotificationHiddenName";
if (Build.VERSION.SDK_INT < 28) {
str5 = "NotificationHiddenChatName";
bitmap6 = null;
BitmapDrawable imageFromMemory = ImageLoader.getInstance().getImageFromMemory(tLRPC$FileLocation, null, "50_50");
if (imageFromMemory != null) {
bitmap = imageFromMemory.getBitmap();
} else {
try {
if (file.exists()) {
float dp = 160.0f / AndroidUtilities.dp(50.0f);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = dp < 1.0f ? 1 : (int) dp;
bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
}
} catch (Throwable unused) {
}
}
} else {
str5 = "NotificationHiddenChatName";
bitmap6 = null;
}
bitmap = bitmap6;
} else {
str5 = "NotificationHiddenChatName";
str6 = "NotificationHiddenName";
tLRPC$User4 = tLRPC$User2;
bitmap = null;
file = null;
}
if (tLRPC$Chat == null) {
Person.Builder name = new Person.Builder().setName(string);
if (file != null && file.exists() && Build.VERSION.SDK_INT >= 28) {
loadRoundAvatar(file, name);
}
bitmap2 = bitmap;
longSparseArray.put(-tLRPC$Chat.id, name.build());
} else {
bitmap2 = bitmap;
}
if (!(z10 || z9) || !z7 || SharedConfig.isWaitingForPasscodeEnter || clientUserId == j3 || UserObject.isReplyUser(j3)) {
str7 = "max_id";
i13 = id;
bitmap3 = bitmap2;
file2 = file;
tLRPC$Chat2 = tLRPC$Chat;
j8 = j6;
notificationsController3 = this;
build = null;
} else {
bitmap3 = bitmap2;
file2 = file;
Intent intent = new Intent(ApplicationLoader.applicationContext, (Class<?>) WearReplyReceiver.class);
intent.putExtra("dialog_id", j3);
intent.putExtra("max_id", id);
intent.putExtra("topic_id", j6);
j8 = j6;
notificationsController3 = this;
intent.putExtra("currentAccount", notificationsController3.currentAccount);
tLRPC$Chat2 = tLRPC$Chat;
str7 = "max_id";
PendingIntent broadcast = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, num.intValue(), intent, 167772160);
RemoteInput build4 = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(LocaleController.getString("Reply", R.string.Reply)).build();
if (!DialogObject.isChatDialog(j3)) {
i13 = id;
formatString = LocaleController.formatString("ReplyToGroup", R.string.ReplyToGroup, string);
} else {
i13 = id;
formatString = LocaleController.formatString("ReplyToUser", R.string.ReplyToUser, string);
}
build = new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon, formatString, broadcast).setAllowGeneratedReplies(true).setSemanticAction(1).addRemoteInput(build4).setShowsUserInterface(false).build();
}
num2 = notificationsController3.pushDialogs.get(j3);
if (num2 == null) {
num2 = 0;
}
dialogKey4 = dialogKey3;
if (!dialogKey4.story) {
max = notificationsController3.storyPushMessages.size();
} else {
max = Math.max(num2.intValue(), arrayList5.size());
}
String format = (max > 1 || Build.VERSION.SDK_INT >= 28) ? string : String.format("%1$s (%2$d)", string, Integer.valueOf(max));
person = (Person) longSparseArray.get(clientUserId);
if (Build.VERSION.SDK_INT >= 28 && person == null) {
user = getMessagesController().getUser(Long.valueOf(clientUserId));
if (user == null) {
user = getUserConfig().getCurrentUser();
}
if (user != null) {
try {
tLRPC$UserProfilePhoto2 = user.photo;
} catch (Throwable th) {
th = th;
str8 = string;
j9 = j8;
}
if (tLRPC$UserProfilePhoto2 != null && (tLRPC$FileLocation5 = tLRPC$UserProfilePhoto2.photo_small) != null) {
str8 = string;
j9 = j8;
try {
if (tLRPC$FileLocation5.volume_id != 0 && tLRPC$FileLocation5.local_id != 0) {
Person.Builder name2 = new Person.Builder().setName(LocaleController.getString("FromYou", R.string.FromYou));
loadRoundAvatar(getFileLoader().getPathToAttach(user.photo.photo_small, true), name2);
Person build5 = name2.build();
try {
longSparseArray.put(clientUserId, build5);
person = build5;
} catch (Throwable th2) {
th = th2;
person = build5;
FileLog.e(th);
if (messageObject2 == null) {
}
if (person == null) {
}
messagingStyle = new NotificationCompat.MessagingStyle("");
messagingStyle2 = messagingStyle;
i14 = Build.VERSION.SDK_INT;
if (i14 >= 28) {
}
messagingStyle2.setConversationTitle(format);
messagingStyle2.setGroupConversation(i14 >= 28 || (!z10 && DialogObject.isChatDialog(j3)) || UserObject.isReplyUser(j3));
StringBuilder sb3 = new StringBuilder();
String[] strArr2 = new String[1];
boolean[] zArr = new boolean[1];
if (!dialogKey4.story) {
}
Intent intent2 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
intent2.setAction("com.tmessages.openchat" + Math.random() + ConnectionsManager.DEFAULT_DATACENTER_ID);
intent2.setFlags(ConnectionsManager.FileTypeFile);
intent2.addCategory("android.intent.category.LAUNCHER");
dialogKey6 = dialogKey5;
if (!dialogKey6.story) {
}
StringBuilder sb4 = new StringBuilder();
sb4.append("show extra notifications chatId ");
sb4.append(j3);
sb4.append(" topicId ");
j11 = j9;
sb4.append(j11);
FileLog.d(sb4.toString());
if (j11 != 0) {
}
String str16 = str9;
intent2.putExtra(str16, notificationsController3.currentAccount);
PendingIntent activity = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2, 1140850688);
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();
NotificationCompat.Action action3 = action;
if (action != null) {
}
Intent intent3 = new Intent(ApplicationLoader.applicationContext, (Class<?>) AutoMessageHeardReceiver.class);
intent3.addFlags(32);
intent3.setAction("org.telegram.messenger.ACTION_MESSAGE_HEARD");
intent3.putExtra("dialog_id", j3);
int i28 = i13;
intent3.putExtra(str7, i28);
intent3.putExtra(str16, notificationsController3.currentAccount);
int i29 = i15;
arrayList13 = arrayList8;
bitmap5 = bitmap4;
build2 = new NotificationCompat.Action.Builder(R.drawable.msg_markread, LocaleController.getString("MarkAsRead", R.string.MarkAsRead), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, num.intValue(), intent3, 167772160)).setSemanticAction(2).setShowsUserInterface(false).build();
if (!DialogObject.isEncryptedDialog(j3)) {
}
if (str13 == null) {
}
StringBuilder sb5 = new StringBuilder();
sb5.append("tgaccount");
long j14 = j10;
sb5.append(j14);
wearableExtender.setBridgeTag(sb5.toString());
if (!dialogKey6.story) {
}
NotificationCompat.Builder autoCancel = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(str10).setSmallIcon(R.drawable.notification).setContentText(sb.toString()).setAutoCancel(true);
if (dialogKey6.story) {
}
category = autoCancel.setNumber(arrayList14.size()).setColor(-15618822).setGroupSummary(false).setWhen(j13).setShowWhen(true).setStyle(messagingStyle2).setContentIntent(activity).extend(wearableExtender).setSortKey(String.valueOf(Long.MAX_VALUE - j13)).setCategory("msg");
Intent intent4 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent4.putExtra("messageDate", i11);
intent4.putExtra("dialogId", j3);
intent4.putExtra(str16, notificationsController3.currentAccount);
if (dialogKey6.story) {
}
category.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, num.intValue(), intent4, 167772160));
if (z6) {
}
if (action2 != null) {
}
if (!z5) {
}
if (arrayList3.size() != 1) {
}
if (DialogObject.isEncryptedDialog(j3)) {
}
if (bitmap5 != null) {
}
if (!AndroidUtilities.needShowPasscode(false)) {
}
if (tLRPC$Chat2 == null) {
}
tLRPC$User5 = tLRPC$User4;
Notification notification3 = notification;
if (Build.VERSION.SDK_INT >= 26) {
}
j7 = j12;
longSparseArray6 = longSparseArray7;
i12 = 7;
z8 = z6;
notification2 = notification3;
arrayList6 = arrayList2;
arrayList6.add(new C1NotificationHolder(num.intValue(), j3, dialogKey6.story, j11, str10, tLRPC$User5, tLRPC$Chat2, category, j2, str2, jArr, i, uri, i2, z, z2, z3, i3));
notificationsController2 = this;
notificationsController2.wearNotificationsIds.put(j3, num);
i5 = i9 + 1;
arrayList19 = arrayList6;
i4 = i12;
size = i8;
arrayList16 = arrayList3;
longSparseArray11 = longSparseArray4;
clientUserId = j7;
z4 = z8;
longSparseArray12 = longSparseArray5;
longSparseArray = longSparseArray6;
build3 = notification2;
notificationsController3 = notificationsController2;
}
}
} catch (Throwable th3) {
th = th3;
}
boolean z14 = (messageObject2 == null && (messageObject2.messageOwner.action instanceof TLRPC$TL_messageActionChatJoinedByRequest)) ? false : true;
if (person == null && z14) {
messagingStyle = new NotificationCompat.MessagingStyle(person);
} else {
messagingStyle = new NotificationCompat.MessagingStyle("");
}
messagingStyle2 = messagingStyle;
i14 = Build.VERSION.SDK_INT;
if (i14 >= 28 || ((DialogObject.isChatDialog(j3) && !z10) || UserObject.isReplyUser(j3))) {
messagingStyle2.setConversationTitle(format);
}
messagingStyle2.setGroupConversation(i14 >= 28 || (!z10 && DialogObject.isChatDialog(j3)) || UserObject.isReplyUser(j3));
StringBuilder sb32 = new StringBuilder();
String[] strArr22 = new String[1];
boolean[] zArr2 = new boolean[1];
if (!dialogKey4.story) {
ArrayList<String> arrayList23 = new ArrayList<>();
ArrayList<Object> arrayList24 = new ArrayList<>();
Pair<Integer, Boolean> parseStoryPushes = notificationsController3.parseStoryPushes(arrayList23, arrayList24);
int intValue = ((Integer) parseStoryPushes.first).intValue();
boolean booleanValue = ((Boolean) parseStoryPushes.second).booleanValue();
if (booleanValue) {
action = build;
sb32.append(LocaleController.formatPluralString("StoryNotificationHidden", intValue, new Object[0]));
} else {
action = build;
if (!arrayList23.isEmpty()) {
if (arrayList23.size() == 1) {
if (intValue == 1) {
sb32.append(LocaleController.getString("StoryNotificationSingle"));
} else {
sb32.append(LocaleController.formatPluralString("StoryNotification1", intValue, arrayList23.get(0)));
}
} else if (arrayList23.size() != 2) {
str9 = "currentAccount";
if (arrayList23.size() == 3 && notificationsController3.storyPushMessages.size() == 3) {
dialogKey5 = dialogKey4;
sb32.append(LocaleController.formatString(R.string.StoryNotification3, notificationsController3.cutLastName(arrayList23.get(0)), notificationsController3.cutLastName(arrayList23.get(1)), notificationsController3.cutLastName(arrayList23.get(2))));
} else {
dialogKey5 = dialogKey4;
sb32.append(LocaleController.formatPluralString("StoryNotification4", notificationsController3.storyPushMessages.size() - 2, notificationsController3.cutLastName(arrayList23.get(0)), notificationsController3.cutLastName(arrayList23.get(1))));
}
long j15 = Long.MAX_VALUE;
i19 = 0;
while (i19 < notificationsController3.storyPushMessages.size()) {
}
j10 = clientUserId;
LongSparseArray longSparseArray13 = longSparseArray;
messagingStyle2.setGroupConversation(false);
if (arrayList23.size() == 1) {
}
messagingStyle2.addMessage(sb32, j15, new Person.Builder().setName(r0).build());
if (!booleanValue) {
}
longSparseArray7 = longSparseArray13;
sb = sb32;
arrayList9 = arrayList5;
arrayList8 = null;
i15 = 0;
str10 = r0;
} else {
str9 = "currentAccount";
sb32.append(LocaleController.formatString(R.string.StoryNotification2, arrayList23.get(0), arrayList23.get(1)));
dialogKey5 = dialogKey4;
long j152 = Long.MAX_VALUE;
i19 = 0;
while (i19 < notificationsController3.storyPushMessages.size()) {
j152 = Math.min(notificationsController3.storyPushMessages.get(i19).date, j152);
i19++;
longSparseArray = longSparseArray;
clientUserId = clientUserId;
}
j10 = clientUserId;
LongSparseArray longSparseArray132 = longSparseArray;
messagingStyle2.setGroupConversation(false);
String formatPluralString = (arrayList23.size() == 1 || booleanValue) ? LocaleController.formatPluralString(str3, intValue, new Object[0]) : arrayList23.get(0);
messagingStyle2.addMessage(sb32, j152, new Person.Builder().setName(formatPluralString).build());
bitmap4 = !booleanValue ? loadMultipleAvatars(arrayList24) : null;
longSparseArray7 = longSparseArray132;
sb = sb32;
arrayList9 = arrayList5;
arrayList8 = null;
i15 = 0;
str10 = formatPluralString;
}
}
longSparseArray6 = longSparseArray;
notificationsController2 = notificationsController3;
arrayList6 = arrayList2;
notification2 = notification;
z8 = z6;
i12 = 7;
j7 = clientUserId;
i5 = i9 + 1;
arrayList19 = arrayList6;
i4 = i12;
size = i8;
arrayList16 = arrayList3;
longSparseArray11 = longSparseArray4;
clientUserId = j7;
z4 = z8;
longSparseArray12 = longSparseArray5;
longSparseArray = longSparseArray6;
build3 = notification2;
notificationsController3 = notificationsController2;
}
str9 = "currentAccount";
dialogKey5 = dialogKey4;
long j1522 = Long.MAX_VALUE;
i19 = 0;
while (i19 < notificationsController3.storyPushMessages.size()) {
}
j10 = clientUserId;
LongSparseArray longSparseArray1322 = longSparseArray;
messagingStyle2.setGroupConversation(false);
if (arrayList23.size() == 1) {
}
messagingStyle2.addMessage(sb32, j1522, new Person.Builder().setName(formatPluralString).build());
if (!booleanValue) {
}
longSparseArray7 = longSparseArray1322;
sb = sb32;
arrayList9 = arrayList5;
arrayList8 = null;
i15 = 0;
str10 = formatPluralString;
} else {
j10 = clientUserId;
action = build;
str9 = "currentAccount";
dialogKey5 = dialogKey4;
LongSparseArray longSparseArray14 = longSparseArray;
int size4 = arrayList5.size() - 1;
int i30 = 0;
arrayList8 = null;
while (size4 >= 0) {
ArrayList<StoryNotification> arrayList25 = arrayList5;
MessageObject messageObject4 = (MessageObject) arrayList25.get(size4);
int i31 = i30;
if (j9 != MessageObject.getTopicId(notificationsController3.currentAccount, messageObject4.messageOwner, getMessagesController().isForum(messageObject4))) {
i16 = size4;
longSparseArray10 = longSparseArray14;
arrayList11 = arrayList8;
arrayList12 = arrayList25;
sb2 = sb32;
} else {
String shortStringForMessage = notificationsController3.getShortStringForMessage(messageObject4, strArr22, zArr2);
if (j3 == j10) {
strArr22[0] = str8;
} else if (DialogObject.isChatDialog(j3) && messageObject4.messageOwner.from_scheduled) {
longSparseArray8 = longSparseArray14;
strArr22[0] = LocaleController.getString("NotificationMessageScheduledName", R.string.NotificationMessageScheduledName);
if (shortStringForMessage != null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("message text is null for " + messageObject4.getId() + " did = " + messageObject4.getDialogId());
}
i16 = size4;
arrayList11 = arrayList8;
arrayList12 = arrayList25;
sb2 = sb32;
longSparseArray10 = longSparseArray8;
} else {
if (sb32.length() > 0) {
sb32.append("\n\n");
}
if (j3 != j10 && messageObject4.messageOwner.from_scheduled && DialogObject.isUserDialog(j3)) {
shortStringForMessage = String.format("%1$s: %2$s", LocaleController.getString("NotificationMessageScheduledName", R.string.NotificationMessageScheduledName), shortStringForMessage);
sb32.append(shortStringForMessage);
} else if (strArr22[0] != null) {
sb32.append(String.format("%1$s: %2$s", strArr22[0], shortStringForMessage));
} else {
sb32.append(shortStringForMessage);
}
String str17 = shortStringForMessage;
if (DialogObject.isUserDialog(j3)) {
arrayList10 = arrayList8;
} else {
if (z10) {
arrayList10 = arrayList8;
senderId = -j3;
} else {
arrayList10 = arrayList8;
if (DialogObject.isChatDialog(j3)) {
senderId = messageObject4.getSenderId();
}
}
sb2 = sb32;
arrayList11 = arrayList10;
arrayList12 = arrayList25;
longSparseArray9 = longSparseArray8;
person2 = (Person) longSparseArray9.get(senderId + (j9 << 16));
if (strArr22[0] != null) {
if (z5) {
if (DialogObject.isChatDialog(j3)) {
if (z10) {
if (Build.VERSION.SDK_INT > 27) {
str12 = LocaleController.getString(str5, R.string.NotificationHiddenChatName);
}
} else {
str12 = LocaleController.getString("NotificationHiddenChatUserName", R.string.NotificationHiddenChatUserName);
}
str11 = str6;
} else if (Build.VERSION.SDK_INT > 27) {
str11 = str6;
str12 = LocaleController.getString(str11, R.string.NotificationHiddenName);
}
}
str11 = str6;
str12 = "";
} else {
str11 = str6;
str12 = strArr22[0];
}
str6 = str11;
if (person2 == null && TextUtils.equals(person2.getName(), str12)) {
i16 = size4;
strArr = strArr22;
} else {
Person.Builder name3 = new Person.Builder().setName(str12);
if (zArr2[0] || DialogObject.isEncryptedDialog(j3) || Build.VERSION.SDK_INT < 28) {
i16 = size4;
strArr = strArr22;
} else {
if (DialogObject.isUserDialog(j3) || z10) {
i16 = size4;
strArr = strArr22;
file3 = file2;
} else {
long senderId2 = messageObject4.getSenderId();
strArr = strArr22;
i16 = size4;
TLRPC$User user4 = getMessagesController().getUser(Long.valueOf(senderId2));
if (user4 == null && (user4 = getMessagesStorage().getUserSync(senderId2)) != null) {
getMessagesController().putUser(user4, true);
}
file3 = (user4 == null || (tLRPC$UserProfilePhoto = user4.photo) == null || (tLRPC$FileLocation4 = tLRPC$UserProfilePhoto.photo_small) == null || tLRPC$FileLocation4.volume_id == 0 || tLRPC$FileLocation4.local_id == 0) ? null : getFileLoader().getPathToAttach(user4.photo.photo_small, true);
}
loadRoundAvatar(file3, name3);
}
person2 = name3.build();
longSparseArray9.put(senderId, person2);
}
Person person3 = person2;
if (DialogObject.isEncryptedDialog(j3)) {
if (!zArr2[0] || Build.VERSION.SDK_INT < 28 || ((ActivityManager) ApplicationLoader.applicationContext.getSystemService("activity")).isLowRamDevice() || z5 || messageObject4.isSecretMedia() || !(messageObject4.type == 1 || messageObject4.isSticker())) {
longSparseArray10 = longSparseArray9;
} else {
File pathToMessage = getFileLoader().getPathToMessage(messageObject4.messageOwner);
if (pathToMessage.exists() && messageObject4.hasMediaSpoilers()) {
file5 = new File(pathToMessage.getParentFile(), pathToMessage.getName() + ".blur.jpg");
if (file5.exists()) {
file6 = pathToMessage;
longSparseArray10 = longSparseArray9;
} else {
try {
Bitmap decodeFile = BitmapFactory.decodeFile(pathToMessage.getAbsolutePath());
Bitmap stackBlurBitmapMax = Utilities.stackBlurBitmapMax(decodeFile);
decodeFile.recycle();
Bitmap createScaledBitmap = Bitmap.createScaledBitmap(stackBlurBitmapMax, decodeFile.getWidth(), decodeFile.getHeight(), true);
Utilities.stackBlurBitmap(createScaledBitmap, 5);
stackBlurBitmapMax.recycle();
Canvas canvas = new Canvas(createScaledBitmap);
file6 = pathToMessage;
try {
notificationsController3.mediaSpoilerEffect.setColor(ColorUtils.setAlphaComponent(-1, (int) (Color.alpha(-1) * 0.325f)));
longSparseArray10 = longSparseArray9;
} catch (Exception e) {
e = e;
longSparseArray10 = longSparseArray9;
FileLog.e(e);
file4 = file6;
NotificationCompat.MessagingStyle.Message message = new NotificationCompat.MessagingStyle.Message(str17, messageObject4.messageOwner.date * 1000, person3);
String str18 = messageObject4.isSticker() ? "image/webp" : "image/jpeg";
if (file4.exists()) {
}
if (uriForFile != null) {
}
z11 = false;
if (!z11) {
}
if (zArr2[0]) {
}
if (j3 == 777000) {
}
i30 = i31;
arrayList8 = arrayList11;
size4 = i16 - 1;
strArr22 = strArr;
arrayList5 = arrayList12;
sb32 = sb2;
longSparseArray14 = longSparseArray10;
}
try {
notificationsController3.mediaSpoilerEffect.setBounds(0, 0, createScaledBitmap.getWidth(), createScaledBitmap.getHeight());
notificationsController3.mediaSpoilerEffect.draw(canvas);
FileOutputStream fileOutputStream = new FileOutputStream(file5);
createScaledBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.close();
createScaledBitmap.recycle();
file4 = file5;
} catch (Exception e2) {
e = e2;
FileLog.e(e);
file4 = file6;
NotificationCompat.MessagingStyle.Message message2 = new NotificationCompat.MessagingStyle.Message(str17, messageObject4.messageOwner.date * 1000, person3);
String str182 = messageObject4.isSticker() ? "image/webp" : "image/jpeg";
if (file4.exists()) {
}
if (uriForFile != null) {
}
z11 = false;
if (!z11) {
}
if (zArr2[0]) {
}
if (j3 == 777000) {
}
i30 = i31;
arrayList8 = arrayList11;
size4 = i16 - 1;
strArr22 = strArr;
arrayList5 = arrayList12;
sb32 = sb2;
longSparseArray14 = longSparseArray10;
}
} catch (Exception e3) {
e = e3;
file6 = pathToMessage;
}
}
file4 = file6;
} else {
longSparseArray10 = longSparseArray9;
file4 = pathToMessage;
file5 = null;
}
NotificationCompat.MessagingStyle.Message message22 = new NotificationCompat.MessagingStyle.Message(str17, messageObject4.messageOwner.date * 1000, person3);
String str1822 = messageObject4.isSticker() ? "image/webp" : "image/jpeg";
if (file4.exists()) {
try {
uriForFile = FileProvider.getUriForFile(ApplicationLoader.applicationContext, ApplicationLoader.getApplicationId() + ".provider", file4);
} catch (Exception e4) {
FileLog.e(e4);
}
} else {
if (getFileLoader().isLoadingFile(file4.getName())) {
uriForFile = new Uri.Builder().scheme("content").authority(NotificationImageProvider.getAuthority()).appendPath("msg_media_raw").appendPath(notificationsController3.currentAccount + "").appendPath(file4.getName()).appendQueryParameter("final_path", file4.getAbsolutePath()).build();
}
uriForFile = null;
}
if (uriForFile != null) {
message22.setData(str1822, uriForFile);
messagingStyle2.addMessage(message22);
ApplicationLoader.applicationContext.grantUriPermission("com.android.systemui", uriForFile, 1);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationsController.lambda$showExtraNotifications$40(uriForFile, file5);
}
}, 20000L);
if (!TextUtils.isEmpty(messageObject4.caption)) {
messagingStyle2.addMessage(messageObject4.caption, messageObject4.messageOwner.date * 1000, person3);
}
z11 = true;
if (!z11) {
messagingStyle2.addMessage(str17, messageObject4.messageOwner.date * 1000, person3);
}
if (zArr2[0] && !z5 && messageObject4.isVoice()) {
messages = messagingStyle2.getMessages();
if (!messages.isEmpty()) {
File pathToMessage2 = getFileLoader().getPathToMessage(messageObject4.messageOwner);
if (Build.VERSION.SDK_INT >= 24) {
try {
uri2 = FileProvider.getUriForFile(ApplicationLoader.applicationContext, ApplicationLoader.getApplicationId() + ".provider", pathToMessage2);
} catch (Exception unused2) {
uri2 = null;
}
} else {
uri2 = Uri.fromFile(pathToMessage2);
}
if (uri2 != null) {
messages.get(messages.size() - 1).setData("audio/ogg", uri2);
}
}
}
}
}
z11 = false;
if (!z11) {
}
if (zArr2[0]) {
messages = messagingStyle2.getMessages();
if (!messages.isEmpty()) {
}
}
} else {
longSparseArray10 = longSparseArray9;
messagingStyle2.addMessage(str17, messageObject4.messageOwner.date * 1000, person3);
}
if (j3 == 777000 && (tLRPC$ReplyMarkup = messageObject4.messageOwner.reply_markup) != null) {
arrayList8 = tLRPC$ReplyMarkup.rows;
i30 = messageObject4.getId();
size4 = i16 - 1;
strArr22 = strArr;
arrayList5 = arrayList12;
sb32 = sb2;
longSparseArray14 = longSparseArray10;
}
i30 = i31;
arrayList8 = arrayList11;
size4 = i16 - 1;
strArr22 = strArr;
arrayList5 = arrayList12;
sb32 = sb2;
longSparseArray14 = longSparseArray10;
}
senderId = j3;
sb2 = sb32;
arrayList11 = arrayList10;
arrayList12 = arrayList25;
longSparseArray9 = longSparseArray8;
person2 = (Person) longSparseArray9.get(senderId + (j9 << 16));
if (strArr22[0] != null) {
}
str6 = str11;
if (person2 == null) {
}
Person.Builder name32 = new Person.Builder().setName(str12);
if (zArr2[0]) {
}
i16 = size4;
strArr = strArr22;
person2 = name32.build();
longSparseArray9.put(senderId, person2);
Person person32 = person2;
if (DialogObject.isEncryptedDialog(j3)) {
}
if (j3 == 777000) {
arrayList8 = tLRPC$ReplyMarkup.rows;
i30 = messageObject4.getId();
size4 = i16 - 1;
strArr22 = strArr;
arrayList5 = arrayList12;
sb32 = sb2;
longSparseArray14 = longSparseArray10;
}
i30 = i31;
arrayList8 = arrayList11;
size4 = i16 - 1;
strArr22 = strArr;
arrayList5 = arrayList12;
sb32 = sb2;
longSparseArray14 = longSparseArray10;
}
}
longSparseArray8 = longSparseArray14;
if (shortStringForMessage != null) {
}
}
strArr = strArr22;
i30 = i31;
arrayList8 = arrayList11;
size4 = i16 - 1;
strArr22 = strArr;
arrayList5 = arrayList12;
sb32 = sb2;
longSparseArray14 = longSparseArray10;
}
longSparseArray7 = longSparseArray14;
sb = sb32;
arrayList9 = arrayList5;
i15 = i30;
bitmap4 = bitmap3;
str10 = str8;
}
Intent intent22 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
intent22.setAction("com.tmessages.openchat" + Math.random() + ConnectionsManager.DEFAULT_DATACENTER_ID);
intent22.setFlags(ConnectionsManager.FileTypeFile);
intent22.addCategory("android.intent.category.LAUNCHER");
dialogKey6 = dialogKey5;
if (!dialogKey6.story) {
long[] jArr2 = new long[notificationsController3.storyPushMessages.size()];
for (int i32 = 0; i32 < notificationsController3.storyPushMessages.size(); i32++) {
jArr2[i32] = notificationsController3.storyPushMessages.get(i32).dialogId;
}
intent22.putExtra("storyDialogIds", jArr2);
} else if (DialogObject.isEncryptedDialog(j3)) {
intent22.putExtra("encId", DialogObject.getEncryptedChatId(j3));
} else if (DialogObject.isUserDialog(j3)) {
intent22.putExtra("userId", j3);
} else {
intent22.putExtra("chatId", -j3);
}
StringBuilder sb42 = new StringBuilder();
sb42.append("show extra notifications chatId ");
sb42.append(j3);
sb42.append(" topicId ");
j11 = j9;
sb42.append(j11);
FileLog.d(sb42.toString());
if (j11 != 0) {
intent22.putExtra("topicId", j11);
}
String str162 = str9;
intent22.putExtra(str162, notificationsController3.currentAccount);
PendingIntent activity2 = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent22, 1140850688);
NotificationCompat.WearableExtender wearableExtender2 = new NotificationCompat.WearableExtender();
NotificationCompat.Action action32 = action;
if (action != null) {
wearableExtender2.addAction(action32);
}
Intent intent32 = new Intent(ApplicationLoader.applicationContext, (Class<?>) AutoMessageHeardReceiver.class);
intent32.addFlags(32);
intent32.setAction("org.telegram.messenger.ACTION_MESSAGE_HEARD");
intent32.putExtra("dialog_id", j3);
int i282 = i13;
intent32.putExtra(str7, i282);
intent32.putExtra(str162, notificationsController3.currentAccount);
int i292 = i15;
arrayList13 = arrayList8;
bitmap5 = bitmap4;
build2 = new NotificationCompat.Action.Builder(R.drawable.msg_markread, LocaleController.getString("MarkAsRead", R.string.MarkAsRead), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, num.intValue(), intent32, 167772160)).setSemanticAction(2).setShowsUserInterface(false).build();
if (!DialogObject.isEncryptedDialog(j3)) {
action2 = action32;
str13 = j3 != globalSecretChatId ? "tgenc" + DialogObject.getEncryptedChatId(j3) + "_" + i282 : null;
} else if (DialogObject.isUserDialog(j3)) {
str13 = "tguser" + j3 + "_" + i282;
action2 = action32;
} else {
StringBuilder sb6 = new StringBuilder();
sb6.append("tgchat");
action2 = action32;
sb6.append(-j3);
sb6.append("_");
sb6.append(i282);
str13 = sb6.toString();
}
if (str13 == null) {
wearableExtender2.setDismissalId(str13);
NotificationCompat.WearableExtender wearableExtender3 = new NotificationCompat.WearableExtender();
wearableExtender3.setDismissalId("summary_" + str13);
builder.extend(wearableExtender3);
}
StringBuilder sb52 = new StringBuilder();
sb52.append("tgaccount");
long j142 = j10;
sb52.append(j142);
wearableExtender2.setBridgeTag(sb52.toString());
if (!dialogKey6.story) {
j12 = j142;
j13 = Long.MAX_VALUE;
for (int i33 = 0; i33 < notificationsController3.storyPushMessages.size(); i33++) {
j13 = Math.min(notificationsController3.storyPushMessages.get(i33).date, j13);
}
arrayList14 = arrayList9;
} else {
j12 = j142;
arrayList14 = arrayList9;
j13 = ((MessageObject) arrayList14.get(0)).messageOwner.date * 1000;
}
NotificationCompat.Builder autoCancel2 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(str10).setSmallIcon(R.drawable.notification).setContentText(sb.toString()).setAutoCancel(true);
if (dialogKey6.story) {
arrayList14 = notificationsController3.storyPushMessages;
}
category = autoCancel2.setNumber(arrayList14.size()).setColor(-15618822).setGroupSummary(false).setWhen(j13).setShowWhen(true).setStyle(messagingStyle2).setContentIntent(activity2).extend(wearableExtender2).setSortKey(String.valueOf(Long.MAX_VALUE - j13)).setCategory("msg");
Intent intent42 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent42.putExtra("messageDate", i11);
intent42.putExtra("dialogId", j3);
intent42.putExtra(str162, notificationsController3.currentAccount);
if (dialogKey6.story) {
intent42.putExtra("story", true);
}
category.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, num.intValue(), intent42, 167772160));
if (z6) {
category.setGroup(notificationsController3.notificationGroup);
category.setGroupAlertBehavior(1);
}
if (action2 != null) {
category.addAction(action2);
}
if (!z5 && !dialogKey6.story) {
category.addAction(build2);
}
if (arrayList3.size() != 1 && !TextUtils.isEmpty(str) && !dialogKey6.story) {
category.setSubText(str);
}
if (DialogObject.isEncryptedDialog(j3)) {
category.setLocalOnly(true);
}
if (bitmap5 != null) {
category.setLargeIcon(bitmap5);
}
if (!AndroidUtilities.needShowPasscode(false) && !SharedConfig.isWaitingForPasscodeEnter && arrayList13 != null) {
size3 = arrayList13.size();
i17 = 0;
while (i17 < size3) {
ArrayList<TLRPC$TL_keyboardButtonRow> arrayList26 = arrayList13;
TLRPC$TL_keyboardButtonRow tLRPC$TL_keyboardButtonRow = arrayList26.get(i17);
int size5 = tLRPC$TL_keyboardButtonRow.buttons.size();
int i34 = 0;
while (i34 < size5) {
TLRPC$KeyboardButton tLRPC$KeyboardButton = tLRPC$TL_keyboardButtonRow.buttons.get(i34);
if (tLRPC$KeyboardButton instanceof TLRPC$TL_keyboardButtonCallback) {
i18 = size3;
arrayList15 = arrayList26;
Intent intent5 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationCallbackReceiver.class);
intent5.putExtra(str162, notificationsController3.currentAccount);
intent5.putExtra("did", j3);
byte[] bArr = tLRPC$KeyboardButton.data;
if (bArr != null) {
intent5.putExtra("data", bArr);
}
intent5.putExtra("mid", i292);
String str19 = tLRPC$KeyboardButton.text;
Context context = ApplicationLoader.applicationContext;
int i35 = notificationsController3.lastButtonId;
str14 = str162;
notificationsController3.lastButtonId = i35 + 1;
category.addAction(0, str19, PendingIntent.getBroadcast(context, i35, intent5, 167772160));
} else {
i18 = size3;
arrayList15 = arrayList26;
str14 = str162;
}
i34++;
size3 = i18;
arrayList26 = arrayList15;
str162 = str14;
}
i17++;
arrayList13 = arrayList26;
str162 = str162;
}
}
if (tLRPC$Chat2 == null || tLRPC$User4 == null) {
tLRPC$User5 = tLRPC$User4;
} else {
tLRPC$User5 = tLRPC$User4;
String str20 = tLRPC$User5.phone;
if (str20 != null && str20.length() > 0) {
category.addPerson("tel:+" + tLRPC$User5.phone);
}
}
Notification notification32 = notification;
if (Build.VERSION.SDK_INT >= 26) {
notificationsController3.setNotificationChannel(notification32, category, z6);
}
j7 = j12;
longSparseArray6 = longSparseArray7;
i12 = 7;
z8 = z6;
notification2 = notification32;
arrayList6 = arrayList2;
arrayList6.add(new C1NotificationHolder(num.intValue(), j3, dialogKey6.story, j11, str10, tLRPC$User5, tLRPC$Chat2, category, j2, str2, jArr, i, uri, i2, z, z2, z3, i3));
notificationsController2 = this;
notificationsController2.wearNotificationsIds.put(j3, num);
i5 = i9 + 1;
arrayList19 = arrayList6;
i4 = i12;
size = i8;
arrayList16 = arrayList3;
longSparseArray11 = longSparseArray4;
clientUserId = j7;
z4 = z8;
longSparseArray12 = longSparseArray5;
longSparseArray = longSparseArray6;
build3 = notification2;
notificationsController3 = notificationsController2;
}
}
}
str8 = string;
j9 = j8;
if (messageObject2 == null) {
}
if (person == null) {
}
messagingStyle = new NotificationCompat.MessagingStyle("");
messagingStyle2 = messagingStyle;
i14 = Build.VERSION.SDK_INT;
if (i14 >= 28) {
}
messagingStyle2.setConversationTitle(format);
messagingStyle2.setGroupConversation(i14 >= 28 || (!z10 && DialogObject.isChatDialog(j3)) || UserObject.isReplyUser(j3));
StringBuilder sb322 = new StringBuilder();
String[] strArr222 = new String[1];
boolean[] zArr22 = new boolean[1];
if (!dialogKey4.story) {
}
Intent intent222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
intent222.setAction("com.tmessages.openchat" + Math.random() + ConnectionsManager.DEFAULT_DATACENTER_ID);
intent222.setFlags(ConnectionsManager.FileTypeFile);
intent222.addCategory("android.intent.category.LAUNCHER");
dialogKey6 = dialogKey5;
if (!dialogKey6.story) {
}
StringBuilder sb422 = new StringBuilder();
sb422.append("show extra notifications chatId ");
sb422.append(j3);
sb422.append(" topicId ");
j11 = j9;
sb422.append(j11);
FileLog.d(sb422.toString());
if (j11 != 0) {
}
String str1622 = str9;
intent222.putExtra(str1622, notificationsController3.currentAccount);
PendingIntent activity22 = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent222, 1140850688);
NotificationCompat.WearableExtender wearableExtender22 = new NotificationCompat.WearableExtender();
NotificationCompat.Action action322 = action;
if (action != null) {
}
Intent intent322 = new Intent(ApplicationLoader.applicationContext, (Class<?>) AutoMessageHeardReceiver.class);
intent322.addFlags(32);
intent322.setAction("org.telegram.messenger.ACTION_MESSAGE_HEARD");
intent322.putExtra("dialog_id", j3);
int i2822 = i13;
intent322.putExtra(str7, i2822);
intent322.putExtra(str1622, notificationsController3.currentAccount);
int i2922 = i15;
arrayList13 = arrayList8;
bitmap5 = bitmap4;
build2 = new NotificationCompat.Action.Builder(R.drawable.msg_markread, LocaleController.getString("MarkAsRead", R.string.MarkAsRead), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, num.intValue(), intent322, 167772160)).setSemanticAction(2).setShowsUserInterface(false).build();
if (!DialogObject.isEncryptedDialog(j3)) {
}
if (str13 == null) {
}
StringBuilder sb522 = new StringBuilder();
sb522.append("tgaccount");
long j1422 = j10;
sb522.append(j1422);
wearableExtender22.setBridgeTag(sb522.toString());
if (!dialogKey6.story) {
}
NotificationCompat.Builder autoCancel22 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(str10).setSmallIcon(R.drawable.notification).setContentText(sb.toString()).setAutoCancel(true);
if (dialogKey6.story) {
}
category = autoCancel22.setNumber(arrayList14.size()).setColor(-15618822).setGroupSummary(false).setWhen(j13).setShowWhen(true).setStyle(messagingStyle2).setContentIntent(activity22).extend(wearableExtender22).setSortKey(String.valueOf(Long.MAX_VALUE - j13)).setCategory("msg");
Intent intent422 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent422.putExtra("messageDate", i11);
intent422.putExtra("dialogId", j3);
intent422.putExtra(str1622, notificationsController3.currentAccount);
if (dialogKey6.story) {
}
category.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, num.intValue(), intent422, 167772160));
if (z6) {
}
if (action2 != null) {
}
if (!z5) {
category.addAction(build2);
}
if (arrayList3.size() != 1) {
}
if (DialogObject.isEncryptedDialog(j3)) {
}
if (bitmap5 != null) {
}
if (!AndroidUtilities.needShowPasscode(false)) {
size3 = arrayList13.size();
i17 = 0;
while (i17 < size3) {
}
}
if (tLRPC$Chat2 == null) {
}
tLRPC$User5 = tLRPC$User4;
Notification notification322 = notification;
if (Build.VERSION.SDK_INT >= 26) {
}
j7 = j12;
longSparseArray6 = longSparseArray7;
i12 = 7;
z8 = z6;
notification2 = notification322;
arrayList6 = arrayList2;
arrayList6.add(new C1NotificationHolder(num.intValue(), j3, dialogKey6.story, j11, str10, tLRPC$User5, tLRPC$Chat2, category, j2, str2, jArr, i, uri, i2, z, z2, z3, i3));
notificationsController2 = this;
notificationsController2.wearNotificationsIds.put(j3, num);
i5 = i9 + 1;
arrayList19 = arrayList6;
i4 = i12;
size = i8;
arrayList16 = arrayList3;
longSparseArray11 = longSparseArray4;
clientUserId = j7;
z4 = z8;
longSparseArray12 = longSparseArray5;
longSparseArray = longSparseArray6;
build3 = notification2;
notificationsController3 = notificationsController2;
}
LongSparseArray longSparseArray15 = longSparseArray;
longSparseArray2 = longSparseArray12;
Notification notification4 = build3;
NotificationsController notificationsController4 = notificationsController3;
ArrayList arrayList27 = arrayList19;
if (!z4) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("show summary with id " + notificationsController4.notificationId);
}
try {
notificationManager.notify(notificationsController4.notificationId, notification4);
notificationsController = notificationsController4;
arrayList = arrayList27;
} catch (SecurityException e5) {
FileLog.e(e5);
notificationsController = this;
arrayList = arrayList27;
notificationsController.resetNotificationSound(builder, j, j2, str2, jArr, i, uri, i2, z, z2, z3, i3);
}
} else {
notificationsController = notificationsController4;
arrayList = arrayList27;
if (notificationsController.openedInBubbleDialogs.isEmpty()) {
notificationManager.cancel(notificationsController.notificationId);
}
}
i6 = 0;
while (i6 < longSparseArray2.size()) {
LongSparseArray longSparseArray16 = longSparseArray2;
if (!notificationsController.openedInBubbleDialogs.contains(Long.valueOf(longSparseArray16.keyAt(i6)))) {
Integer num5 = (Integer) longSparseArray16.valueAt(i6);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("cancel notification id " + num5);
}
notificationManager.cancel(num5.intValue());
}
i6++;
longSparseArray2 = longSparseArray16;
}
ArrayList arrayList28 = new ArrayList(arrayList.size());
size2 = arrayList.size();
i7 = 0;
while (i7 < size2) {
ArrayList arrayList29 = arrayList;
C1NotificationHolder c1NotificationHolder = (C1NotificationHolder) arrayList29.get(i7);
arrayList28.clear();
if (Build.VERSION.SDK_INT < 29 || DialogObject.isEncryptedDialog(c1NotificationHolder.dialogId)) {
longSparseArray3 = longSparseArray15;
} else {
NotificationCompat.Builder builder3 = c1NotificationHolder.notification;
long j16 = c1NotificationHolder.dialogId;
longSparseArray3 = longSparseArray15;
String createNotificationShortcut = createNotificationShortcut(builder3, j16, c1NotificationHolder.name, c1NotificationHolder.user, c1NotificationHolder.chat, (Person) longSparseArray3.get(j16), !c1NotificationHolder.story);
if (createNotificationShortcut != null) {
arrayList28.add(createNotificationShortcut);
}
}
c1NotificationHolder.call();
if (!unsupportedNotificationShortcut() && !arrayList28.isEmpty()) {
ShortcutManagerCompat.removeDynamicShortcuts(ApplicationLoader.applicationContext, arrayList28);
}
i7++;
arrayList = arrayList29;
longSparseArray15 = longSparseArray3;
}
}
}
z4 = true;
if (z4) {
checkOtherNotificationsChannel();
}
clientUserId = getUserConfig().getClientUserId();
if (AndroidUtilities.needShowPasscode()) {
}
SharedConfig.passcodeHash.length();
i4 = 7;
longSparseArray = new LongSparseArray();
size = arrayList16.size();
i5 = 0;
while (i5 < size) {
dialogKey = (DialogKey) arrayList16.get(i5);
if (!dialogKey.story) {
}
int i262 = (Integer) longSparseArray12.get(j3);
z6 = z4;
if (!dialogKey.story) {
}
Integer num42 = i262;
int i272 = 0;
while (i10 < arrayList4.size()) {
}
if (!dialogKey.story) {
}
if (z5) {
}
if (tLRPC$FileLocation == null) {
}
if (tLRPC$Chat == null) {
}
if (z10) {
}
bitmap3 = bitmap2;
file2 = file;
Intent intent6 = new Intent(ApplicationLoader.applicationContext, (Class<?>) WearReplyReceiver.class);
intent6.putExtra("dialog_id", j3);
intent6.putExtra("max_id", id);
intent6.putExtra("topic_id", j6);
j8 = j6;
notificationsController3 = this;
intent6.putExtra("currentAccount", notificationsController3.currentAccount);
tLRPC$Chat2 = tLRPC$Chat;
str7 = "max_id";
PendingIntent broadcast2 = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, num.intValue(), intent6, 167772160);
RemoteInput build42 = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(LocaleController.getString("Reply", R.string.Reply)).build();
if (!DialogObject.isChatDialog(j3)) {
}
build = new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon, formatString, broadcast2).setAllowGeneratedReplies(true).setSemanticAction(1).addRemoteInput(build42).setShowsUserInterface(false).build();
num2 = notificationsController3.pushDialogs.get(j3);
if (num2 == null) {
}
dialogKey4 = dialogKey3;
if (!dialogKey4.story) {
}
if (max > 1) {
}
person = (Person) longSparseArray.get(clientUserId);
if (Build.VERSION.SDK_INT >= 28) {
user = getMessagesController().getUser(Long.valueOf(clientUserId));
if (user == null) {
}
if (user != null) {
}
}
str8 = string;
j9 = j8;
if (messageObject2 == null) {
}
if (person == null) {
}
messagingStyle = new NotificationCompat.MessagingStyle("");
messagingStyle2 = messagingStyle;
i14 = Build.VERSION.SDK_INT;
if (i14 >= 28) {
}
messagingStyle2.setConversationTitle(format);
messagingStyle2.setGroupConversation(i14 >= 28 || (!z10 && DialogObject.isChatDialog(j3)) || UserObject.isReplyUser(j3));
StringBuilder sb3222 = new StringBuilder();
String[] strArr2222 = new String[1];
boolean[] zArr222 = new boolean[1];
if (!dialogKey4.story) {
}
Intent intent2222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
intent2222.setAction("com.tmessages.openchat" + Math.random() + ConnectionsManager.DEFAULT_DATACENTER_ID);
intent2222.setFlags(ConnectionsManager.FileTypeFile);
intent2222.addCategory("android.intent.category.LAUNCHER");
dialogKey6 = dialogKey5;
if (!dialogKey6.story) {
}
StringBuilder sb4222 = new StringBuilder();
sb4222.append("show extra notifications chatId ");
sb4222.append(j3);
sb4222.append(" topicId ");
j11 = j9;
sb4222.append(j11);
FileLog.d(sb4222.toString());
if (j11 != 0) {
}
String str16222 = str9;
intent2222.putExtra(str16222, notificationsController3.currentAccount);
PendingIntent activity222 = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2222, 1140850688);
NotificationCompat.WearableExtender wearableExtender222 = new NotificationCompat.WearableExtender();
NotificationCompat.Action action3222 = action;
if (action != null) {
}
Intent intent3222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) AutoMessageHeardReceiver.class);
intent3222.addFlags(32);
intent3222.setAction("org.telegram.messenger.ACTION_MESSAGE_HEARD");
intent3222.putExtra("dialog_id", j3);
int i28222 = i13;
intent3222.putExtra(str7, i28222);
intent3222.putExtra(str16222, notificationsController3.currentAccount);
int i29222 = i15;
arrayList13 = arrayList8;
bitmap5 = bitmap4;
build2 = new NotificationCompat.Action.Builder(R.drawable.msg_markread, LocaleController.getString("MarkAsRead", R.string.MarkAsRead), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, num.intValue(), intent3222, 167772160)).setSemanticAction(2).setShowsUserInterface(false).build();
if (!DialogObject.isEncryptedDialog(j3)) {
}
if (str13 == null) {
}
StringBuilder sb5222 = new StringBuilder();
sb5222.append("tgaccount");
long j14222 = j10;
sb5222.append(j14222);
wearableExtender222.setBridgeTag(sb5222.toString());
if (!dialogKey6.story) {
}
NotificationCompat.Builder autoCancel222 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(str10).setSmallIcon(R.drawable.notification).setContentText(sb.toString()).setAutoCancel(true);
if (dialogKey6.story) {
}
category = autoCancel222.setNumber(arrayList14.size()).setColor(-15618822).setGroupSummary(false).setWhen(j13).setShowWhen(true).setStyle(messagingStyle2).setContentIntent(activity222).extend(wearableExtender222).setSortKey(String.valueOf(Long.MAX_VALUE - j13)).setCategory("msg");
Intent intent4222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
intent4222.putExtra("messageDate", i11);
intent4222.putExtra("dialogId", j3);
intent4222.putExtra(str16222, notificationsController3.currentAccount);
if (dialogKey6.story) {
}
category.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, num.intValue(), intent4222, 167772160));
if (z6) {
}
if (action2 != null) {
}
if (!z5) {
}
if (arrayList3.size() != 1) {
}
if (DialogObject.isEncryptedDialog(j3)) {
}
if (bitmap5 != null) {
}
if (!AndroidUtilities.needShowPasscode(false)) {
}
if (tLRPC$Chat2 == null) {
}
tLRPC$User5 = tLRPC$User4;
Notification notification3222 = notification;
if (Build.VERSION.SDK_INT >= 26) {
}
j7 = j12;
longSparseArray6 = longSparseArray7;
i12 = 7;
z8 = z6;
notification2 = notification3222;
arrayList6 = arrayList2;
arrayList6.add(new C1NotificationHolder(num.intValue(), j3, dialogKey6.story, j11, str10, tLRPC$User5, tLRPC$Chat2, category, j2, str2, jArr, i, uri, i2, z, z2, z3, i3));
notificationsController2 = this;
notificationsController2.wearNotificationsIds.put(j3, num);
i5 = i9 + 1;
arrayList19 = arrayList6;
i4 = i12;
size = i8;
arrayList16 = arrayList3;
longSparseArray11 = longSparseArray4;
clientUserId = j7;
z4 = z8;
longSparseArray12 = longSparseArray5;
longSparseArray = longSparseArray6;
build3 = notification2;
notificationsController3 = notificationsController2;
}
LongSparseArray longSparseArray152 = longSparseArray;
longSparseArray2 = longSparseArray12;
Notification notification42 = build3;
NotificationsController notificationsController42 = notificationsController3;
ArrayList arrayList272 = arrayList19;
if (!z4) {
}
i6 = 0;
while (i6 < longSparseArray2.size()) {
}
ArrayList arrayList282 = new ArrayList(arrayList.size());
size2 = arrayList.size();
i7 = 0;
while (i7 < size2) {
}
}
public class C1NotificationHolder {
TLRPC$Chat chat;
long dialogId;
int id;
String name;
NotificationCompat.Builder notification;
boolean story;
long topicId;
TLRPC$User user;
final String val$chatName;
final int val$chatType;
final int val$importance;
final boolean val$isDefault;
final boolean val$isInApp;
final boolean val$isSilent;
final long val$lastTopicId;
final int val$ledColor;
final Uri val$sound;
final long[] val$vibrationPattern;
C1NotificationHolder(int i, long j, boolean z, long j2, String str, TLRPC$User tLRPC$User, TLRPC$Chat tLRPC$Chat, NotificationCompat.Builder builder, long j3, String str2, long[] jArr, int i2, Uri uri, int i3, boolean z2, boolean z3, boolean z4, int i4) {
this.val$lastTopicId = j3;
this.val$chatName = str2;
this.val$vibrationPattern = jArr;
this.val$ledColor = i2;
this.val$sound = uri;
this.val$importance = i3;
this.val$isDefault = z2;
this.val$isInApp = z3;
this.val$isSilent = z4;
this.val$chatType = i4;
this.id = i;
this.name = str;
this.user = tLRPC$User;
this.chat = tLRPC$Chat;
this.notification = builder;
this.dialogId = j;
this.story = z;
this.topicId = j2;
}
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$40(Uri uri, File file) {
ApplicationLoader.applicationContext.revokeUriPermission(uri, 1);
if (file != null) {
file.delete();
}
}
private String cutLastName(String str) {
if (str == null) {
return null;
}
int indexOf = str.indexOf(32);
if (indexOf < 0) {
return str;
}
StringBuilder sb = new StringBuilder();
sb.append(str.substring(0, indexOf));
sb.append(str.endsWith("…") ? "…" : "");
return sb.toString();
}
private Pair<Integer, Boolean> parseStoryPushes(ArrayList<String> arrayList, ArrayList<Object> arrayList2) {
int i;
String str;
TLRPC$FileLocation tLRPC$FileLocation;
int min = Math.min(3, this.storyPushMessages.size());
boolean z = false;
int i2 = 0;
for (0; i < min; i + 1) {
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 tLRPC$UserProfilePhoto = user.photo;
if (tLRPC$UserProfilePhoto != null && (tLRPC$FileLocation = tLRPC$UserProfilePhoto.photo_small) != null && tLRPC$FileLocation.volume_id != 0 && tLRPC$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) + "…";
}
arrayList.add(str);
if (obj == null && user != null) {
arrayList2.add(user);
} else if (obj != null) {
arrayList2.add(obj);
}
}
if (z) {
arrayList2.clear();
}
return new Pair<>(Integer.valueOf(i2), Boolean.valueOf(z));
}
public static Person.Builder loadRoundAvatar(File file, Person.Builder builder) {
if (file != null && Build.VERSION.SDK_INT >= 28) {
try {
builder.setIcon(IconCompat.createWithBitmap(ImageDecoder.decodeBitmap(ImageDecoder.createSource(file), new ImageDecoder.OnHeaderDecodedListener() {
@Override
public final void onHeaderDecoded(ImageDecoder imageDecoder, ImageDecoder.ImageInfo imageInfo, ImageDecoder.Source source) {
NotificationsController.lambda$loadRoundAvatar$42(imageDecoder, imageInfo, source);
}
})));
} catch (Throwable unused) {
}
}
return builder;
}
public static void lambda$loadRoundAvatar$42(ImageDecoder imageDecoder, ImageDecoder.ImageInfo imageInfo, ImageDecoder.Source source) {
imageDecoder.setPostProcessor(new PostProcessor() {
@Override
public final int onPostProcess(Canvas canvas) {
int lambda$loadRoundAvatar$41;
lambda$loadRoundAvatar$41 = NotificationsController.lambda$loadRoundAvatar$41(canvas);
return lambda$loadRoundAvatar$41;
}
});
}
public static int lambda$loadRoundAvatar$41(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> arrayList) {
int i;
Bitmap bitmap;
Paint paint;
boolean z;
float f;
char c;
int i2;
float f2;
float size;
float size2;
float f3;
float f4;
float f5;
float f6;
Object obj;
TextPaint textPaint;
ArrayList<Object> arrayList2 = arrayList;
if (Build.VERSION.SDK_INT < 28 || arrayList2 == null || arrayList.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);
boolean z2 = true;
Paint paint3 = new Paint(1);
Rect rect = new Rect();
paint3.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
float f7 = 1.0f;
char c2 = 2;
float f8 = arrayList.size() == 1 ? 1.0f : arrayList.size() == 2 ? 0.65f : 0.5f;
int i3 = 0;
TextPaint textPaint2 = null;
while (i3 < arrayList.size()) {
float f9 = dp;
float f10 = (f7 - f8) * f9;
try {
size = (f10 / arrayList.size()) * ((arrayList.size() - 1) - i3);
try {
size2 = i3 * (f10 / arrayList.size());
f3 = f9 * f8;
f4 = f3 / 2.0f;
i = dp;
f5 = size + f4;
f = f8;
f6 = size2 + f4;
bitmap = createBitmap;
try {
canvas.drawCircle(f5, f6, AndroidUtilities.dp(2.0f) + f4, paint3);
obj = arrayList2.get(i3);
paint = paint3;
} catch (Throwable unused) {
paint = paint3;
}
try {
} catch (Throwable unused2) {
i2 = i3;
z = true;
c = 2;
f2 = 1.0f;
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
} catch (Throwable unused3) {
i = dp;
bitmap = createBitmap;
paint = paint3;
z = z2;
f = f8;
i2 = i3;
}
} catch (Throwable unused4) {
i = dp;
bitmap = createBitmap;
paint = paint3;
z = z2;
f = f8;
c = c2;
i2 = i3;
}
if (obj instanceof File) {
try {
String absolutePath = ((File) arrayList2.get(i3)).getAbsolutePath();
BitmapFactory.Options options = new BitmapFactory.Options();
z = true;
try {
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(absolutePath, options);
int i4 = (int) f3;
options.inSampleSize = StoryEntry.calculateInSampleSize(options, i4, i4);
try {
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(f3 / decodeFile.getWidth(), f3 / decodeFile.getHeight());
matrix.postTranslate(size, size2);
bitmapShader.setLocalMatrix(matrix);
paint2.setShader(bitmapShader);
canvas.drawCircle(f5, f6, f4, paint2);
decodeFile.recycle();
} catch (Throwable unused5) {
i2 = i3;
z = true;
c = 2;
f2 = 1.0f;
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
} catch (Throwable unused6) {
i2 = i3;
c = 2;
f2 = 1.0f;
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
} catch (Throwable unused7) {
i2 = i3;
z = true;
c = 2;
f2 = 1.0f;
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
} else if (obj instanceof TLRPC$User) {
TLRPC$User tLRPC$User = (TLRPC$User) obj;
try {
int[] iArr = new int[2];
i2 = i3;
textPaint = textPaint2;
try {
try {
iArr[0] = Theme.getColor(Theme.keys_avatar_background[AvatarDrawable.getColorIndex(tLRPC$User.id)]);
try {
iArr[1] = Theme.getColor(Theme.keys_avatar_background2[AvatarDrawable.getColorIndex(tLRPC$User.id)]);
float f11 = size2 + f3;
c = 2;
try {
float[] fArr = new float[2];
try {
fArr[0] = 0.0f;
f2 = 1.0f;
try {
fArr[1] = 1.0f;
try {
paint2.setShader(new LinearGradient(size, size2, size, f11, iArr, fArr, Shader.TileMode.CLAMP));
canvas.drawCircle(f5, f6, f4, paint2);
if (textPaint == null) {
try {
z = true;
} catch (Throwable unused8) {
z = true;
}
try {
TextPaint textPaint3 = new TextPaint(1);
try {
textPaint3.setTypeface(AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM));
textPaint3.setTextSize(f9 * 0.25f);
textPaint3.setColor(-1);
textPaint2 = textPaint3;
} catch (Throwable unused9) {
textPaint2 = textPaint3;
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
} catch (Throwable unused10) {
textPaint2 = textPaint;
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
} else {
z = true;
textPaint2 = textPaint;
}
try {
StringBuilder sb = new StringBuilder();
AvatarDrawable.getAvatarSymbols(tLRPC$User.first_name, tLRPC$User.last_name, null, sb);
String sb2 = sb.toString();
try {
textPaint2.getTextBounds(sb2, 0, sb2.length(), rect);
canvas.drawText(sb2, (f5 - (rect.width() / 2.0f)) - rect.left, (f6 - (rect.height() / 2.0f)) - rect.top, textPaint2);
} catch (Throwable unused11) {
}
} catch (Throwable unused12) {
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
} catch (Throwable unused13) {
z = true;
}
} catch (Throwable unused14) {
z = true;
}
} catch (Throwable unused15) {
z = true;
}
} catch (Throwable unused16) {
z = true;
}
} catch (Throwable unused17) {
z = true;
c = 2;
f2 = 1.0f;
textPaint2 = textPaint;
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
} catch (Throwable unused18) {
z = true;
c = 2;
f2 = 1.0f;
textPaint2 = textPaint;
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
} catch (Throwable unused19) {
}
} catch (Throwable unused20) {
c = 2;
i2 = i3;
z = true;
f2 = 1.0f;
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
i2 = i3;
textPaint = textPaint2;
z = true;
c = 2;
f2 = 1.0f;
textPaint2 = textPaint;
i3 = i2 + 1;
arrayList2 = arrayList;
z2 = z;
c2 = c;
f7 = f2;
dp = i;
f8 = f;
createBitmap = bitmap;
paint3 = paint;
}
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$44();
}
});
}
public void lambda$playOutChatSound$44() {
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$43(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$43(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 j, long j2) {
SharedPreferences.Editor edit = getAccountInstance().getNotificationsSettings().edit();
String sharedPrefKey = getSharedPrefKey(j, j2);
edit.remove(NotificationsSettingsFacade.PROPERTY_NOTIFY + sharedPrefKey).remove(NotificationsSettingsFacade.PROPERTY_CUSTOM + sharedPrefKey);
getMessagesStorage().setDialogFlags(j, 0L);
TLRPC$Dialog tLRPC$Dialog = getMessagesController().dialogs_dict.get(j);
if (tLRPC$Dialog != null) {
tLRPC$Dialog.notify_settings = new TLRPC$TL_peerNotifySettings();
}
edit.commit();
getNotificationsController().updateServerNotificationsSettings(j, j2, true);
}
public void setDialogNotificationsSettings(long j, long j2, int i) {
SharedPreferences.Editor edit = getAccountInstance().getNotificationsSettings().edit();
TLRPC$Dialog tLRPC$Dialog = MessagesController.getInstance(UserConfig.selectedAccount).dialogs_dict.get(j);
if (i == 4) {
if (isGlobalNotificationsEnabled(j)) {
edit.remove(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(j, j2));
} else {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(j, j2), 0);
}
getMessagesStorage().setDialogFlags(j, 0L);
if (tLRPC$Dialog != null) {
tLRPC$Dialog.notify_settings = new TLRPC$TL_peerNotifySettings();
}
} else {
int currentTime = ConnectionsManager.getInstance(UserConfig.selectedAccount).getCurrentTime();
if (i == 0) {
currentTime += 3600;
} else if (i == 1) {
currentTime += 28800;
} else if (i == 2) {
currentTime += 172800;
} else if (i == 3) {
currentTime = ConnectionsManager.DEFAULT_DATACENTER_ID;
}
long j3 = 1;
if (i == 3) {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(j, j2), 2);
} else {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(j, j2), 3);
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY_UNTIL + getSharedPrefKey(j, j2), currentTime);
j3 = 1 | (((long) currentTime) << 32);
}
getInstance(UserConfig.selectedAccount).removeNotificationsForDialog(j);
MessagesStorage.getInstance(UserConfig.selectedAccount).setDialogFlags(j, j3);
if (tLRPC$Dialog != null) {
TLRPC$TL_peerNotifySettings tLRPC$TL_peerNotifySettings = new TLRPC$TL_peerNotifySettings();
tLRPC$Dialog.notify_settings = tLRPC$TL_peerNotifySettings;
tLRPC$TL_peerNotifySettings.mute_until = currentTime;
}
}
edit.commit();
updateServerNotificationsSettings(j, j2);
}
public void updateServerNotificationsSettings(long j, long j2) {
updateServerNotificationsSettings(j, j2, true);
}
public void updateServerNotificationsSettings(long j, long j2, boolean z) {
if (z) {
getNotificationCenter().lambda$postNotificationNameOnUIThread$1(NotificationCenter.notificationsSettingsUpdated, new Object[0]);
}
if (DialogObject.isEncryptedDialog(j)) {
return;
}
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
TLRPC$TL_account_updateNotifySettings tLRPC$TL_account_updateNotifySettings = new TLRPC$TL_account_updateNotifySettings();
tLRPC$TL_account_updateNotifySettings.settings = new TLRPC$TL_inputPeerNotifySettings();
String sharedPrefKey = getSharedPrefKey(j, j2);
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings = tLRPC$TL_account_updateNotifySettings.settings;
tLRPC$TL_inputPeerNotifySettings.flags |= 1;
tLRPC$TL_inputPeerNotifySettings.show_previews = notificationsSettings.getBoolean(NotificationsSettingsFacade.PROPERTY_CONTENT_PREVIEW + sharedPrefKey, true);
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings2 = tLRPC$TL_account_updateNotifySettings.settings;
tLRPC$TL_inputPeerNotifySettings2.flags = tLRPC$TL_inputPeerNotifySettings2.flags | 2;
tLRPC$TL_inputPeerNotifySettings2.silent = notificationsSettings.getBoolean(NotificationsSettingsFacade.PROPERTY_SILENT + sharedPrefKey, false);
if (notificationsSettings.contains(NotificationsSettingsFacade.PROPERTY_STORIES_NOTIFY + sharedPrefKey)) {
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings3 = tLRPC$TL_account_updateNotifySettings.settings;
tLRPC$TL_inputPeerNotifySettings3.flags |= 64;
tLRPC$TL_inputPeerNotifySettings3.stories_muted = !notificationsSettings.getBoolean(NotificationsSettingsFacade.PROPERTY_STORIES_NOTIFY + sharedPrefKey, true);
}
int i = notificationsSettings.getInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(j, j2), -1);
if (i != -1) {
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings4 = tLRPC$TL_account_updateNotifySettings.settings;
tLRPC$TL_inputPeerNotifySettings4.flags |= 4;
if (i == 3) {
tLRPC$TL_inputPeerNotifySettings4.mute_until = notificationsSettings.getInt(NotificationsSettingsFacade.PROPERTY_NOTIFY_UNTIL + getSharedPrefKey(j, j2), 0);
} else {
tLRPC$TL_inputPeerNotifySettings4.mute_until = i == 2 ? ConnectionsManager.DEFAULT_DATACENTER_ID : 0;
}
}
long j3 = notificationsSettings.getLong("sound_document_id_" + getSharedPrefKey(j, j2), 0L);
String string = notificationsSettings.getString("sound_path_" + getSharedPrefKey(j, j2), null);
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings5 = tLRPC$TL_account_updateNotifySettings.settings;
tLRPC$TL_inputPeerNotifySettings5.flags = tLRPC$TL_inputPeerNotifySettings5.flags | 8;
if (j3 != 0) {
TLRPC$TL_notificationSoundRingtone tLRPC$TL_notificationSoundRingtone = new TLRPC$TL_notificationSoundRingtone();
tLRPC$TL_notificationSoundRingtone.id = j3;
tLRPC$TL_account_updateNotifySettings.settings.sound = tLRPC$TL_notificationSoundRingtone;
} else if (string != null) {
if (string.equalsIgnoreCase("NoSound")) {
tLRPC$TL_account_updateNotifySettings.settings.sound = new TLRPC$TL_notificationSoundNone();
} else {
TLRPC$TL_notificationSoundLocal tLRPC$TL_notificationSoundLocal = new TLRPC$TL_notificationSoundLocal();
tLRPC$TL_notificationSoundLocal.title = notificationsSettings.getString("sound_" + getSharedPrefKey(j, j2), null);
tLRPC$TL_notificationSoundLocal.data = string;
tLRPC$TL_account_updateNotifySettings.settings.sound = tLRPC$TL_notificationSoundLocal;
}
} else {
tLRPC$TL_inputPeerNotifySettings5.sound = new TLRPC$TL_notificationSoundDefault();
}
if (j2 != 0 && j != getUserConfig().getClientUserId()) {
TLRPC$TL_inputNotifyForumTopic tLRPC$TL_inputNotifyForumTopic = new TLRPC$TL_inputNotifyForumTopic();
tLRPC$TL_inputNotifyForumTopic.peer = getMessagesController().getInputPeer(j);
tLRPC$TL_inputNotifyForumTopic.top_msg_id = (int) j2;
tLRPC$TL_account_updateNotifySettings.peer = tLRPC$TL_inputNotifyForumTopic;
} else {
TLRPC$TL_inputNotifyPeer tLRPC$TL_inputNotifyPeer = new TLRPC$TL_inputNotifyPeer();
tLRPC$TL_account_updateNotifySettings.peer = tLRPC$TL_inputNotifyPeer;
tLRPC$TL_inputNotifyPeer.peer = getMessagesController().getInputPeer(j);
}
getConnectionsManager().sendRequest(tLRPC$TL_account_updateNotifySettings, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC$TL_error tLRPC$TL_error) {
NotificationsController.lambda$updateServerNotificationsSettings$45(tLObject, tLRPC$TL_error);
}
});
}
public void updateServerNotificationsSettings(int i) {
SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
TLRPC$TL_account_updateNotifySettings tLRPC$TL_account_updateNotifySettings = new TLRPC$TL_account_updateNotifySettings();
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings = new TLRPC$TL_inputPeerNotifySettings();
tLRPC$TL_account_updateNotifySettings.settings = tLRPC$TL_inputPeerNotifySettings;
tLRPC$TL_inputPeerNotifySettings.flags = 5;
if (i == 0) {
tLRPC$TL_account_updateNotifySettings.peer = new TLRPC$TL_inputNotifyChats();
tLRPC$TL_account_updateNotifySettings.settings.mute_until = notificationsSettings.getInt("EnableGroup2", 0);
tLRPC$TL_account_updateNotifySettings.settings.show_previews = notificationsSettings.getBoolean("EnablePreviewGroup", true);
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings2 = tLRPC$TL_account_updateNotifySettings.settings;
tLRPC$TL_inputPeerNotifySettings2.flags |= 8;
tLRPC$TL_inputPeerNotifySettings2.sound = getInputSound(notificationsSettings, "GroupSound", "GroupSoundDocId", "GroupSoundPath");
} else if (i == 1 || i == 3) {
tLRPC$TL_account_updateNotifySettings.peer = new TLRPC$TL_inputNotifyUsers();
tLRPC$TL_account_updateNotifySettings.settings.mute_until = notificationsSettings.getInt("EnableAll2", 0);
tLRPC$TL_account_updateNotifySettings.settings.show_previews = notificationsSettings.getBoolean("EnablePreviewAll", true);
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings3 = tLRPC$TL_account_updateNotifySettings.settings;
tLRPC$TL_inputPeerNotifySettings3.flags |= 128;
tLRPC$TL_inputPeerNotifySettings3.stories_hide_sender = notificationsSettings.getBoolean("EnableHideStoriesSenders", false);
if (notificationsSettings.contains("EnableAllStories")) {
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings4 = tLRPC$TL_account_updateNotifySettings.settings;
tLRPC$TL_inputPeerNotifySettings4.flags |= 64;
tLRPC$TL_inputPeerNotifySettings4.stories_muted = !notificationsSettings.getBoolean("EnableAllStories", true);
}
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings5 = tLRPC$TL_account_updateNotifySettings.settings;
tLRPC$TL_inputPeerNotifySettings5.flags |= 8;
tLRPC$TL_inputPeerNotifySettings5.sound = getInputSound(notificationsSettings, "GlobalSound", "GlobalSoundDocId", "GlobalSoundPath");
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings6 = tLRPC$TL_account_updateNotifySettings.settings;
tLRPC$TL_inputPeerNotifySettings6.flags |= 256;
tLRPC$TL_inputPeerNotifySettings6.stories_sound = getInputSound(notificationsSettings, "StoriesSound", "StoriesSoundDocId", "StoriesSoundPath");
} else {
tLRPC$TL_account_updateNotifySettings.peer = new TLRPC$TL_inputNotifyBroadcasts();
tLRPC$TL_account_updateNotifySettings.settings.mute_until = notificationsSettings.getInt("EnableChannel2", 0);
tLRPC$TL_account_updateNotifySettings.settings.show_previews = notificationsSettings.getBoolean("EnablePreviewChannel", true);
TLRPC$TL_inputPeerNotifySettings tLRPC$TL_inputPeerNotifySettings7 = tLRPC$TL_account_updateNotifySettings.settings;
tLRPC$TL_inputPeerNotifySettings7.flags |= 8;
tLRPC$TL_inputPeerNotifySettings7.sound = getInputSound(notificationsSettings, "ChannelSound", "ChannelSoundDocId", "ChannelSoundPath");
}
getConnectionsManager().sendRequest(tLRPC$TL_account_updateNotifySettings, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC$TL_error tLRPC$TL_error) {
NotificationsController.lambda$updateServerNotificationsSettings$46(tLObject, tLRPC$TL_error);
}
});
}
private TLRPC$NotificationSound getInputSound(SharedPreferences sharedPreferences, String str, String str2, String str3) {
long j = sharedPreferences.getLong(str2, 0L);
String string = sharedPreferences.getString(str3, "NoSound");
if (j != 0) {
TLRPC$TL_notificationSoundRingtone tLRPC$TL_notificationSoundRingtone = new TLRPC$TL_notificationSoundRingtone();
tLRPC$TL_notificationSoundRingtone.id = j;
return tLRPC$TL_notificationSoundRingtone;
}
if (string != null) {
if (string.equalsIgnoreCase("NoSound")) {
return new TLRPC$TL_notificationSoundNone();
}
TLRPC$TL_notificationSoundLocal tLRPC$TL_notificationSoundLocal = new TLRPC$TL_notificationSoundLocal();
tLRPC$TL_notificationSoundLocal.title = sharedPreferences.getString(str, null);
tLRPC$TL_notificationSoundLocal.data = string;
return tLRPC$TL_notificationSoundLocal;
}
return new TLRPC$TL_notificationSoundDefault();
}
public boolean isGlobalNotificationsEnabled(long j) {
return isGlobalNotificationsEnabled(j, null);
}
public boolean isGlobalNotificationsEnabled(long j, Boolean bool) {
int i = 2;
if (!DialogObject.isChatDialog(j)) {
i = 1;
} else if (bool == null) {
TLRPC$Chat chat = getMessagesController().getChat(Long.valueOf(-j));
if (ChatObject.isChannel(chat)) {
}
i = 0;
}
return isGlobalNotificationsEnabled(i);
}
public boolean isGlobalNotificationsEnabled(int i) {
if (i == 3) {
return getAccountInstance().getNotificationsSettings().getBoolean("EnableAllStories", true);
}
return getAccountInstance().getNotificationsSettings().getInt(getGlobalNotificationsKey(i), 0) < getConnectionsManager().getCurrentTime();
}
public void setGlobalNotificationsEnabled(int i, int i2) {
getAccountInstance().getNotificationsSettings().edit().putInt(getGlobalNotificationsKey(i), i2).commit();
updateServerNotificationsSettings(i);
getMessagesStorage().updateMutedDialogsFiltersCounters();
deleteNotificationChannelGlobal(i);
}
public void muteDialog(long j, long j2, boolean z) {
if (z) {
getInstance(this.currentAccount).muteUntil(j, j2, ConnectionsManager.DEFAULT_DATACENTER_ID);
return;
}
boolean isGlobalNotificationsEnabled = getInstance(this.currentAccount).isGlobalNotificationsEnabled(j);
boolean z2 = j2 != 0;
SharedPreferences.Editor edit = MessagesController.getNotificationsSettings(this.currentAccount).edit();
if (isGlobalNotificationsEnabled && !z2) {
edit.remove(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(j, j2));
} else {
edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + getSharedPrefKey(j, j2), 0);
}
if (j2 == 0) {
getMessagesStorage().setDialogFlags(j, 0L);
TLRPC$Dialog tLRPC$Dialog = getMessagesController().dialogs_dict.get(j);
if (tLRPC$Dialog != null) {
tLRPC$Dialog.notify_settings = new TLRPC$TL_peerNotifySettings();
}
}
edit.apply();
updateServerNotificationsSettings(j, j2);
}
public NotificationsSettingsFacade getNotificationsSettingsFacade() {
return this.dialogsNotificationsFacade;
}
public void loadTopicsNotificationsExceptions(final long j, final Consumer<HashSet<Integer>> consumer) {
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
NotificationsController.this.lambda$loadTopicsNotificationsExceptions$48(j, consumer);
}
});
}
public void lambda$loadTopicsNotificationsExceptions$48(long j, final Consumer consumer) {
final HashSet hashSet = new HashSet();
Iterator<Map.Entry<String, ?>> it = MessagesController.getNotificationsSettings(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, "")).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$47(Consumer.this, hashSet);
}
});
}
public static void lambda$loadTopicsNotificationsExceptions$47(Consumer consumer, HashSet hashSet) {
if (consumer != null) {
consumer.accept(hashSet);
}
}
public static class DialogKey {
final long dialogId;
final boolean story;
final long topicId;
private DialogKey(long j, long j2, boolean z) {
this.dialogId = j;
this.topicId = j2;
this.story = z;
}
}
public static class StoryNotification {
public long date;
final HashMap<Integer, Pair<Long, Long>> dateByIds;
final long dialogId;
boolean hidden;
String localName;
public StoryNotification(long j, String str, int i, long j2) {
this(j, str, i, j2, j2 + 86400000);
}
public StoryNotification(long j, String str, int i, long j2, long j3) {
HashMap<Integer, Pair<Long, Long>> hashMap = new HashMap<>();
this.dateByIds = hashMap;
this.dialogId = j;
this.localName = str;
hashMap.put(Integer.valueOf(i), new Pair<>(Long.valueOf(j2), Long.valueOf(j3)));
this.date = j2;
}
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());
}
}
AndroidUtilities.cancelRunOnUIThread(this.checkStoryPushesRunnable);
long currentTimeMillis = j - System.currentTimeMillis();
if (j != Long.MAX_VALUE) {
AndroidUtilities.runOnUIThread(this.checkStoryPushesRunnable, Math.max(0L, currentTimeMillis));
}
}
}