2021-08-09 22:50:52 +00:00
|
|
|
package com.discord.utilities;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.pm.ShortcutManager;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Build;
|
|
|
|
import androidx.core.app.Person;
|
|
|
|
import androidx.core.content.pm.ShortcutInfoCompat;
|
|
|
|
import androidx.core.graphics.drawable.IconCompat;
|
|
|
|
import c.d.b.a.a;
|
|
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
|
|
import com.discord.api.channel.Channel;
|
|
|
|
import com.discord.models.user.User;
|
|
|
|
import com.discord.stores.StoreStream;
|
|
|
|
import com.discord.utilities.dimen.DimenUtils;
|
|
|
|
import com.discord.utilities.intent.IntentUtils;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import d0.g0.t;
|
|
|
|
import d0.t.n;
|
|
|
|
import d0.t.o;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Objects;
|
|
|
|
import kotlin.jvm.functions.Function0;
|
|
|
|
import kotlin.jvm.functions.Function1;
|
|
|
|
import rx.Observable;
|
|
|
|
/* compiled from: ShareUtils.kt */
|
|
|
|
public final class ShareUtils {
|
|
|
|
public static final ShareUtils INSTANCE = new ShareUtils();
|
|
|
|
|
|
|
|
/* compiled from: ShareUtils.kt */
|
|
|
|
public static final class SharedContent {
|
|
|
|
private final CharSequence text;
|
|
|
|
private final List<Uri> uris;
|
|
|
|
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r2v0, resolved type: java.util.List<? extends android.net.Uri> */
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
public SharedContent(CharSequence charSequence, List<? extends Uri> list) {
|
|
|
|
this.text = charSequence;
|
|
|
|
this.uris = list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.utilities.ShareUtils$SharedContent */
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
public static /* synthetic */ SharedContent copy$default(SharedContent sharedContent, CharSequence charSequence, List list, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
charSequence = sharedContent.text;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
list = sharedContent.uris;
|
|
|
|
}
|
|
|
|
return sharedContent.copy(charSequence, list);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final CharSequence component1() {
|
|
|
|
return this.text;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<Uri> component2() {
|
|
|
|
return this.uris;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final SharedContent copy(CharSequence charSequence, List<? extends Uri> list) {
|
|
|
|
return new SharedContent(charSequence, list);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof SharedContent)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
SharedContent sharedContent = (SharedContent) obj;
|
|
|
|
return m.areEqual(this.text, sharedContent.text) && m.areEqual(this.uris, sharedContent.uris);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final CharSequence getText() {
|
|
|
|
return this.text;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<Uri> getUris() {
|
|
|
|
return this.uris;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
CharSequence charSequence = this.text;
|
|
|
|
int i = 0;
|
|
|
|
int hashCode = (charSequence != null ? charSequence.hashCode() : 0) * 31;
|
|
|
|
List<Uri> list = this.uris;
|
|
|
|
if (list != null) {
|
|
|
|
i = list.hashCode();
|
|
|
|
}
|
|
|
|
return hashCode + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-08-18 07:29:27 +00:00
|
|
|
StringBuilder L = a.L("SharedContent(text=");
|
|
|
|
L.append(this.text);
|
|
|
|
L.append(", uris=");
|
|
|
|
return a.E(L, this.uris, ")");
|
2021-08-09 22:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private ShareUtils() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ ShortcutInfoCompat access$toShortcutInfo(ShareUtils shareUtils, Channel channel, Context context, IconCompat iconCompat, int i) {
|
|
|
|
return shareUtils.toShortcutInfo(channel, context, iconCompat, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final ShortcutInfoCompat toShortcutInfo(Channel channel, Context context, IconCompat iconCompat, int i) {
|
|
|
|
ShortcutInfoCompat.Builder longLived = new ShortcutInfoCompat.Builder(context, String.valueOf(channel.h())).setShortLabel(AnimatableValueParser.y0(channel)).setLongLabel(AnimatableValueParser.y0(channel)).setIcon(iconCompat).setIntent(IntentUtils.RouteBuilders.selectChannel$default(channel.h(), 0, null, 6, null).setPackage(context.getPackageName())).setRank(i).setLongLived(true);
|
2021-08-18 07:29:27 +00:00
|
|
|
c.a.d.m0.a aVar = c.a.d.m0.a.b;
|
|
|
|
ShortcutInfoCompat.Builder categories = longLived.setCategories(c.a.d.m0.a.a);
|
2021-08-09 22:50:52 +00:00
|
|
|
List<User> G0 = AnimatableValueParser.G0(channel);
|
|
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(G0, 10));
|
|
|
|
for (User user : G0) {
|
|
|
|
arrayList.add(new Person.Builder().setName(user.getUsername()).setKey(user.toString()).setBot(user.isBot()).build());
|
|
|
|
}
|
|
|
|
Object[] array = arrayList.toArray(new Person[0]);
|
|
|
|
Objects.requireNonNull(array, "null cannot be cast to non-null type kotlin.Array<T>");
|
|
|
|
ShortcutInfoCompat build = categories.setPersons((Person[]) array).build();
|
|
|
|
m.checkNotNullExpressionValue(build, "ShortcutInfoCompat.Build… )\n .build()");
|
|
|
|
return build;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final SharedContent getSharedContent(Intent intent, boolean z2) {
|
|
|
|
Uri uri;
|
|
|
|
m.checkNotNullParameter(intent, "intent");
|
|
|
|
CharSequence charSequenceExtra = intent.getCharSequenceExtra("android.intent.extra.TEXT");
|
|
|
|
String stringExtra = intent.getStringExtra("android.intent.extra.SUBJECT");
|
|
|
|
ArrayList arrayList = null;
|
|
|
|
if (charSequenceExtra == null || t.isBlank(charSequenceExtra)) {
|
|
|
|
charSequenceExtra = !(stringExtra == null || t.isBlank(stringExtra)) ? stringExtra : null;
|
|
|
|
}
|
|
|
|
String action = intent.getAction();
|
|
|
|
if (action != null) {
|
|
|
|
int hashCode = action.hashCode();
|
|
|
|
if (hashCode != -1173264947) {
|
|
|
|
if (hashCode == -58484670 && action.equals("android.intent.action.SEND_MULTIPLE")) {
|
|
|
|
arrayList = intent.getParcelableArrayListExtra("android.intent.extra.STREAM");
|
|
|
|
}
|
|
|
|
} else if (action.equals("android.intent.action.SEND") && (uri = (Uri) intent.getParcelableExtra("android.intent.extra.STREAM")) != null) {
|
|
|
|
arrayList = n.arrayListOf(uri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (z2) {
|
|
|
|
intent.removeExtra("android.intent.extra.TEXT");
|
|
|
|
intent.removeExtra("android.intent.extra.SUBJECT");
|
|
|
|
intent.removeExtra("android.intent.extra.STREAM");
|
|
|
|
}
|
|
|
|
return new SharedContent(charSequenceExtra, arrayList);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void updateDirectShareTargets(Context context) {
|
|
|
|
m.checkNotNullParameter(context, "context");
|
|
|
|
int dpToPixels = DimenUtils.dpToPixels(72);
|
|
|
|
int dpToPixels2 = DimenUtils.dpToPixels(108);
|
|
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
|
|
Observable F = ObservableExtensionsKt.takeSingleUntilTimeout$default(companion.getChannels().observeDirectShareCandidates(context), 0, false, 1, null).F(ShareUtils$updateDirectShareTargets$1.INSTANCE);
|
|
|
|
Observable<Map<Long, Channel>> x2 = companion.getChannels().observeGuildAndPrivateChannels().x(ShareUtils$updateDirectShareTargets$2.INSTANCE);
|
|
|
|
m.checkNotNullExpressionValue(x2, "StoreStream\n …ilter { it.isNotEmpty() }");
|
|
|
|
Observable j = Observable.j(F, ObservableExtensionsKt.takeSingleUntilTimeout$default(x2, 0, false, 1, null), new ShareUtils$updateDirectShareTargets$3(context));
|
|
|
|
m.checkNotNullExpressionValue(j, "Observable.combineLatest…o to icon }\n }\n }");
|
|
|
|
Observable z2 = ObservableExtensionsKt.computationLatest(j).z(new ShareUtils$updateDirectShareTargets$4(dpToPixels, dpToPixels2));
|
|
|
|
m.checkNotNullExpressionValue(z2, "Observable.combineLatest…riPairs to it }\n }");
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui(z2), ShareUtils.class, context, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new ShareUtils$updateDirectShareTargets$5(context), 60, (Object) null);
|
|
|
|
if (Build.VERSION.SDK_INT >= 25) {
|
|
|
|
Observable<Map<Long, Channel>> x3 = companion.getChannels().observeGuildAndPrivateChannels().x(ShareUtils$updateDirectShareTargets$6.INSTANCE);
|
|
|
|
m.checkNotNullExpressionValue(x3, "StoreStream.getChannels(…ilter { it.isNotEmpty() }");
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui(ObservableExtensionsKt.takeSingleUntilTimeout$default(x3, 0, false, 1, null)), ShareUtils.class, context, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new ShareUtils$updateDirectShareTargets$7((ShortcutManager) context.getSystemService(ShortcutManager.class), context), 60, (Object) null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|