2021-08-09 22:50:52 +00:00
|
|
|
package com.discord.widgets.home;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewStub;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import androidx.annotation.MainThread;
|
|
|
|
import androidx.core.view.ViewCompat;
|
|
|
|
import androidx.core.view.ViewKt;
|
|
|
|
import androidx.core.view.WindowInsetsCompat;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
import androidx.fragment.app.FragmentTransaction;
|
2021-08-18 07:29:27 +00:00
|
|
|
import c.a.d.f;
|
|
|
|
import c.a.k.b;
|
2021-08-09 22:50:52 +00:00
|
|
|
import com.discord.R;
|
|
|
|
import com.discord.api.user.NsfwAllowance;
|
|
|
|
import com.discord.app.AppComponent;
|
|
|
|
import com.discord.databinding.WidgetHomeBinding;
|
|
|
|
import com.discord.databinding.WidgetHomePanelCenterNsfwBinding;
|
|
|
|
import com.discord.stores.StoreGuildsNsfw;
|
|
|
|
import com.discord.stores.StoreStream;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import com.discord.utilities.view.text.LinkifiedTextView;
|
|
|
|
import com.google.android.material.button.MaterialButton;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import java.lang.ref.WeakReference;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import kotlin.jvm.functions.Function0;
|
|
|
|
import kotlin.jvm.functions.Function1;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
import rx.Observable;
|
|
|
|
import rx.Subscription;
|
|
|
|
/* compiled from: WidgetHomePanelNsfw.kt */
|
|
|
|
public final class WidgetHomePanelNsfw {
|
|
|
|
private static final Companion Companion = new Companion(null);
|
|
|
|
@Deprecated
|
|
|
|
private static final long HIDE_DELAY_MILLIS = 500;
|
|
|
|
private final AppComponent appComponent;
|
|
|
|
private WidgetHomePanelCenterNsfwBinding binding;
|
|
|
|
private final WeakReference<FragmentManager> fragmentManager;
|
|
|
|
private final StoreGuildsNsfw guildsNsfwStore = StoreStream.Companion.getGuildsNsfw();
|
|
|
|
private Subscription hidePanelSubscription;
|
|
|
|
private ViewStub stub;
|
|
|
|
|
|
|
|
/* compiled from: WidgetHomePanelNsfw.kt */
|
|
|
|
public static final class Companion {
|
|
|
|
private Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public WidgetHomePanelNsfw(WidgetHomeBinding widgetHomeBinding, AppComponent appComponent, FragmentManager fragmentManager) {
|
|
|
|
m.checkNotNullParameter(widgetHomeBinding, "binding");
|
|
|
|
m.checkNotNullParameter(appComponent, "appComponent");
|
|
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
|
|
this.appComponent = appComponent;
|
|
|
|
this.fragmentManager = new WeakReference<>(fragmentManager);
|
|
|
|
this.stub = widgetHomeBinding.d.b.b;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ StoreGuildsNsfw access$getGuildsNsfwStore$p(WidgetHomePanelNsfw widgetHomePanelNsfw) {
|
|
|
|
return widgetHomePanelNsfw.guildsNsfwStore;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Subscription access$getHidePanelSubscription$p(WidgetHomePanelNsfw widgetHomePanelNsfw) {
|
|
|
|
return widgetHomePanelNsfw.hidePanelSubscription;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setContainerViewHidden(WidgetHomePanelNsfw widgetHomePanelNsfw, boolean z2) {
|
|
|
|
widgetHomePanelNsfw.setContainerViewHidden(z2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setHidePanelSubscription$p(WidgetHomePanelNsfw widgetHomePanelNsfw, Subscription subscription) {
|
|
|
|
widgetHomePanelNsfw.hidePanelSubscription = subscription;
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void setChatListHidden(boolean z2) {
|
|
|
|
FragmentManager fragmentManager = this.fragmentManager.get();
|
|
|
|
if (fragmentManager != null) {
|
|
|
|
m.checkNotNullExpressionValue(fragmentManager, "fragmentManager.get() ?: return");
|
|
|
|
Fragment findFragmentById = fragmentManager.findFragmentById(R.id.widget_chat_list);
|
|
|
|
if (findFragmentById != null) {
|
|
|
|
m.checkNotNullExpressionValue(findFragmentById, "fragmentManager.findFrag…dget_chat_list) ?: return");
|
|
|
|
FragmentTransaction beginTransaction = fragmentManager.beginTransaction();
|
|
|
|
m.checkNotNullExpressionValue(beginTransaction, "fragmentManager.beginTransaction()");
|
|
|
|
if (z2) {
|
|
|
|
beginTransaction.hide(findFragmentById);
|
|
|
|
} else {
|
|
|
|
beginTransaction.show(findFragmentById);
|
|
|
|
}
|
|
|
|
beginTransaction.commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void setContainerViewHidden(boolean z2) {
|
|
|
|
LinearLayout linearLayout;
|
|
|
|
LinearLayout linearLayout2;
|
|
|
|
LinearLayout linearLayout3;
|
|
|
|
LinearLayout linearLayout4;
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding = this.binding;
|
|
|
|
if ((widgetHomePanelCenterNsfwBinding == null || (linearLayout4 = widgetHomePanelCenterNsfwBinding.a) == null || linearLayout4.getVisibility() != 8) && z2) {
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding2 = this.binding;
|
|
|
|
if (!(widgetHomePanelCenterNsfwBinding2 == null || (linearLayout3 = widgetHomePanelCenterNsfwBinding2.a) == null)) {
|
|
|
|
linearLayout3.setVisibility(8);
|
|
|
|
}
|
|
|
|
setChatListHidden(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding3 = this.binding;
|
|
|
|
if ((widgetHomePanelCenterNsfwBinding3 == null || (linearLayout2 = widgetHomePanelCenterNsfwBinding3.a) == null || linearLayout2.getVisibility() != 0) && !z2) {
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding4 = this.binding;
|
|
|
|
if (!(widgetHomePanelCenterNsfwBinding4 == null || (linearLayout = widgetHomePanelCenterNsfwBinding4.a) == null)) {
|
|
|
|
linearLayout.setVisibility(0);
|
|
|
|
}
|
|
|
|
setChatListHidden(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void toggleContainerVisibility(boolean z2, boolean z3, NsfwAllowance nsfwAllowance) {
|
|
|
|
LinkifiedTextView linkifiedTextView;
|
|
|
|
LinkifiedTextView linkifiedTextView2;
|
|
|
|
TextView textView;
|
|
|
|
MaterialButton materialButton;
|
|
|
|
ImageView imageView;
|
|
|
|
MaterialButton materialButton2;
|
|
|
|
View inflate;
|
|
|
|
boolean z4 = nsfwAllowance == NsfwAllowance.DISALLOWED;
|
|
|
|
if (!z2 || (!z3 && !z4)) {
|
2021-08-24 07:28:10 +00:00
|
|
|
Observable<Long> c02 = Observable.c0(HIDE_DELAY_MILLIS, TimeUnit.MILLISECONDS);
|
|
|
|
m.checkNotNullExpressionValue(c02, "Observable.timer(HIDE_DE…S, TimeUnit.MILLISECONDS)");
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(c02, this.appComponent, null, 2, null), WidgetHomePanelNsfw.class, (Context) null, new WidgetHomePanelNsfw$toggleContainerVisibility$2(this), (Function1) null, (Function0) null, (Function0) null, new WidgetHomePanelNsfw$toggleContainerVisibility$3(this), 58, (Object) null);
|
2021-08-09 22:50:52 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ViewStub viewStub = this.stub;
|
|
|
|
if (!(viewStub == null || (inflate = viewStub.inflate()) == null)) {
|
|
|
|
this.stub = null;
|
|
|
|
int i = R.id.home_panel_center_nsfw_anchor_wrap;
|
|
|
|
LinearLayout linearLayout = (LinearLayout) inflate.findViewById(R.id.home_panel_center_nsfw_anchor_wrap);
|
|
|
|
if (linearLayout != null) {
|
|
|
|
i = R.id.home_panel_center_nsfw_art;
|
|
|
|
ImageView imageView2 = (ImageView) inflate.findViewById(R.id.home_panel_center_nsfw_art);
|
|
|
|
if (imageView2 != null) {
|
|
|
|
i = R.id.home_panel_center_nsfw_confirm;
|
|
|
|
MaterialButton materialButton3 = (MaterialButton) inflate.findViewById(R.id.home_panel_center_nsfw_confirm);
|
|
|
|
if (materialButton3 != null) {
|
|
|
|
i = R.id.home_panel_center_nsfw_deny;
|
|
|
|
MaterialButton materialButton4 = (MaterialButton) inflate.findViewById(R.id.home_panel_center_nsfw_deny);
|
|
|
|
if (materialButton4 != null) {
|
|
|
|
i = R.id.home_panel_center_nsfw_description;
|
|
|
|
LinkifiedTextView linkifiedTextView3 = (LinkifiedTextView) inflate.findViewById(R.id.home_panel_center_nsfw_description);
|
|
|
|
if (linkifiedTextView3 != null) {
|
|
|
|
i = R.id.home_panel_center_nsfw_title;
|
|
|
|
TextView textView2 = (TextView) inflate.findViewById(R.id.home_panel_center_nsfw_title);
|
|
|
|
if (textView2 != null) {
|
|
|
|
this.binding = new WidgetHomePanelCenterNsfwBinding((LinearLayout) inflate, linearLayout, imageView2, materialButton3, materialButton4, linkifiedTextView3, textView2);
|
|
|
|
ViewCompat.setOnApplyWindowInsetsListener(inflate, WidgetHomePanelNsfw$toggleContainerVisibility$1$1.INSTANCE);
|
|
|
|
inflate.requestApplyInsets();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i)));
|
|
|
|
}
|
|
|
|
if (z4) {
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding = this.binding;
|
2021-08-24 07:28:10 +00:00
|
|
|
if (!(widgetHomePanelCenterNsfwBinding == null || (materialButton2 = widgetHomePanelCenterNsfwBinding.f1858c) == null)) {
|
2021-08-09 22:50:52 +00:00
|
|
|
ViewKt.setVisible(materialButton2, false);
|
|
|
|
}
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding2 = this.binding;
|
|
|
|
if (!(widgetHomePanelCenterNsfwBinding2 == null || (imageView = widgetHomePanelCenterNsfwBinding2.b) == null)) {
|
|
|
|
imageView.setImageResource(R.drawable.img_age_gate_failure);
|
|
|
|
}
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding3 = this.binding;
|
|
|
|
if (!(widgetHomePanelCenterNsfwBinding3 == null || (materialButton = widgetHomePanelCenterNsfwBinding3.d) == null)) {
|
|
|
|
b.n(materialButton, R.string.back, new Object[0], null, 4);
|
|
|
|
}
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding4 = this.binding;
|
|
|
|
if (!(widgetHomePanelCenterNsfwBinding4 == null || (textView = widgetHomePanelCenterNsfwBinding4.f) == null)) {
|
|
|
|
b.n(textView, R.string.age_gate_nsfw_underage_header, new Object[0], null, 4);
|
|
|
|
}
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding5 = this.binding;
|
|
|
|
if (!(widgetHomePanelCenterNsfwBinding5 == null || (linkifiedTextView2 = widgetHomePanelCenterNsfwBinding5.e) == null)) {
|
|
|
|
b.n(linkifiedTextView2, R.string.age_gate_nsfw_underage_body, new Object[]{f.a.a(115000084051L, "h_5206f3f2-0ee4-4380-b50a-25319e45bc7c")}, null, 4);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding6 = this.binding;
|
|
|
|
if (!(widgetHomePanelCenterNsfwBinding6 == null || (linkifiedTextView = widgetHomePanelCenterNsfwBinding6.e) == null)) {
|
|
|
|
b.n(linkifiedTextView, R.string.age_gate_nsfw_description, new Object[0], null, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setContainerViewHidden(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@MainThread
|
|
|
|
public final void configureUI(WidgetHomeModel widgetHomeModel) {
|
|
|
|
MaterialButton materialButton;
|
|
|
|
MaterialButton materialButton2;
|
|
|
|
m.checkNotNullParameter(widgetHomeModel, "model");
|
|
|
|
Subscription subscription = this.hidePanelSubscription;
|
|
|
|
if (subscription != null) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
toggleContainerVisibility(widgetHomeModel.isChannelNsfw(), widgetHomeModel.isNsfwUnConsented(), widgetHomeModel.getNsfwAllowed());
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding = this.binding;
|
|
|
|
if (!(widgetHomePanelCenterNsfwBinding == null || (materialButton2 = widgetHomePanelCenterNsfwBinding.d) == null)) {
|
|
|
|
materialButton2.setOnClickListener(new WidgetHomePanelNsfw$configureUI$1(this, widgetHomeModel));
|
|
|
|
}
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding2 = this.binding;
|
2021-08-24 07:28:10 +00:00
|
|
|
if (widgetHomePanelCenterNsfwBinding2 != null && (materialButton = widgetHomePanelCenterNsfwBinding2.f1858c) != null) {
|
2021-08-09 22:50:52 +00:00
|
|
|
materialButton.setOnClickListener(new WidgetHomePanelNsfw$configureUI$2(this, widgetHomeModel));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void dispatchApplyWindowInsets(WindowInsetsCompat windowInsetsCompat) {
|
|
|
|
LinearLayout linearLayout;
|
|
|
|
m.checkNotNullParameter(windowInsetsCompat, "insets");
|
|
|
|
WidgetHomePanelCenterNsfwBinding widgetHomePanelCenterNsfwBinding = this.binding;
|
|
|
|
if (widgetHomePanelCenterNsfwBinding != null && (linearLayout = widgetHomePanelCenterNsfwBinding.a) != null) {
|
|
|
|
ViewCompat.dispatchApplyWindowInsets(linearLayout, windowInsetsCompat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|