discord-jadx/app/src/main/java/com/discord/widgets/stage/StageChannelNotifications.java

127 lines
5.7 KiB
Java

package com.discord.widgets.stage;
import android.app.Application;
import android.app.Notification;
import android.content.Context;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import c.a.e.d;
import c.q.a.k.a;
import com.discord.api.channel.Channel;
import com.discord.stores.StoreChannels;
import com.discord.stores.StoreStream;
import com.discord.utilities.color.ColorCompat;
import com.discord.utilities.lifecycle.ApplicationProvider;
import com.discord.utilities.voice.VoiceEngineForegroundService;
import com.discord.utilities.voice.VoiceEngineNotificationBuilder;
import d0.g;
import d0.z.d.m;
import kotlin.Lazy;
import kotlin.jvm.internal.DefaultConstructorMarker;
import s.a.j0;
import s.a.w0;
/* compiled from: StageChannelNotifications.kt */
public final class StageChannelNotifications {
public static final Companion Companion = new Companion(null);
private static final Lazy INSTANCE$delegate = g.lazy(StageChannelNotifications$Companion$INSTANCE$2.INSTANCE);
private static final long NOTIFICATION_ICON_FETCH_DELAY_MS = 250;
public static final String NOTIFICATION_TAG = "stage-channels";
private final StoreChannels channelsStore;
/* compiled from: StageChannelNotifications.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final StageChannelNotifications getINSTANCE() {
Lazy access$getINSTANCE$cp = StageChannelNotifications.access$getINSTANCE$cp();
Companion companion = StageChannelNotifications.Companion;
return (StageChannelNotifications) access$getINSTANCE$cp.getValue();
}
}
/* compiled from: StageChannelNotifications.kt */
public static final class Notifications {
public static final Notifications INSTANCE = new Notifications();
/* compiled from: StageChannelNotifications.kt */
public static final class InvitedToSpeak {
public static final InvitedToSpeak INSTANCE = new InvitedToSpeak();
private static final int NOTIFICATION_ID = 102;
private InvitedToSpeak() {
}
public final void cancel(Context context) {
m.checkNotNullParameter(context, "context");
NotificationManagerCompat.from(context).cancel("stage-channels", 102);
}
public final void notify(Context context, Notification notification) {
m.checkNotNullParameter(context, "context");
m.checkNotNullParameter(notification, "notification");
NotificationManagerCompat.from(context).notify("stage-channels", 102, notification);
}
}
private Notifications() {
}
}
public StageChannelNotifications() {
this(null, 1, null);
}
public StageChannelNotifications(StoreChannels storeChannels) {
m.checkNotNullParameter(storeChannels, "channelsStore");
this.channelsStore = storeChannels;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ StageChannelNotifications(StoreChannels storeChannels, int i, DefaultConstructorMarker defaultConstructorMarker) {
this((i & 1) != 0 ? StoreStream.Companion.getChannels() : storeChannels);
}
public static final /* synthetic */ Lazy access$getINSTANCE$cp() {
return INSTANCE$delegate;
}
private final NotificationCompat.Builder createChannelNotificationBuilder(Context context, Channel channel) {
NotificationCompat.Builder color = new NotificationCompat.Builder(context, "Calls").setAutoCancel(true).setOnlyAlertOnce(true).setColor(ColorCompat.getThemedColor(context, 2130969007));
String z2 = channel.z();
if (z2 == null) {
z2 = channel.m();
}
return color.setContentTitle(z2).setSmallIcon(2131231495).setContentIntent(VoiceEngineNotificationBuilder.getCallScreenNavigationIntent$default(VoiceEngineNotificationBuilder.INSTANCE, context, channel.h(), null, null, 6, null));
}
public final void onInviteToSpeakRescinded() {
Notifications.InvitedToSpeak.INSTANCE.cancel(ApplicationProvider.INSTANCE.get());
}
public final void onInvitedToSpeak(long j) {
Channel channel;
d dVar = d.d;
if (d.a && (channel = this.channelsStore.getChannel(j)) != null) {
Application application = ApplicationProvider.INSTANCE.get();
VoiceEngineForegroundService.Companion companion = VoiceEngineForegroundService.Companion;
a.G(w0.i, j0.b, null, new StageChannelNotifications$onInvitedToSpeak$1(channel, createChannelNotificationBuilder(application, channel).setContentText(application.getString(2131893627)).addAction(0, application.getString(2131893624), companion.stageInviteAckPendingIntent(application, j, true)).addAction(0, application.getString(2131893626), companion.stageInviteAckPendingIntent(application, j, false)), application, null), 2, null);
}
}
public final void onInvitedToSpeakAckFailed(long j) {
Channel channel = this.channelsStore.getChannel(j);
if (channel != null) {
Application application = ApplicationProvider.INSTANCE.get();
Notifications.InvitedToSpeak invitedToSpeak = Notifications.InvitedToSpeak.INSTANCE;
Notification build = createChannelNotificationBuilder(application, channel).setContentText(application.getString(2131888384)).build();
m.checkNotNullExpressionValue(build, "createChannelNotificatio…le))\n .build()");
invitedToSpeak.notify(application, build);
}
}
}