forked from Juby210/discord-jadx
327 lines
17 KiB
Java
327 lines
17 KiB
Java
package com.discord.widgets.guilds.contextmenu;
|
|
|
|
import android.animation.Animator;
|
|
import android.content.Context;
|
|
import android.graphics.PointF;
|
|
import android.os.Bundle;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewAnimationUtils;
|
|
import android.view.ViewGroup;
|
|
import android.view.Window;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.TextView;
|
|
import androidx.appcompat.widget.ActivityChooserModel;
|
|
import androidx.cardview.widget.CardView;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import c.a.d.f0;
|
|
import c.a.d.h0;
|
|
import c.a.k.b;
|
|
import c.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetFolderContextMenuBinding;
|
|
import com.discord.utilities.dimen.DimenUtils;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.guilds.contextmenu.FolderContextMenuViewModel;
|
|
import d0.d0.f;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import java.util.Objects;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
/* compiled from: WidgetFolderContextMenu.kt */
|
|
public final class WidgetFolderContextMenu extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetFolderContextMenu.class, "binding", "getBinding()Lcom/discord/databinding/WidgetFolderContextMenuBinding;", 0)};
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final String FRAGMENT_TAG = "WidgetFolderContextMenu";
|
|
private static final int SCREEN_BOTTOM_BUFFER = DimenUtils.dpToPixels(96);
|
|
private static final String VIEW_CONTAINER_TAG = "WidgetFolderContextMenuViewContainer";
|
|
private static boolean isShowingContextMenu;
|
|
private AnimationState animationState;
|
|
private Animator animator;
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetFolderContextMenu$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy viewModel$delegate;
|
|
|
|
/* compiled from: WidgetFolderContextMenu.kt */
|
|
public enum AnimationState {
|
|
ANIMATING_IN,
|
|
ANIMATING_OUT
|
|
}
|
|
|
|
/* compiled from: WidgetFolderContextMenu.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private final int computeMaxContextMenuHeight(Context context) {
|
|
WidgetFolderContextMenuBinding a = WidgetFolderContextMenuBinding.a(LayoutInflater.from(context).inflate(R.layout.widget_folder_context_menu, (ViewGroup) null, false));
|
|
m.checkNotNullExpressionValue(a, "WidgetFolderContextMenuB…om(context), null, false)");
|
|
CardView cardView = a.a;
|
|
m.checkNotNullExpressionValue(cardView, "WidgetFolderContextMenuB…ntext), null, false).root");
|
|
cardView.measure(0, 0);
|
|
return cardView.getMeasuredHeight();
|
|
}
|
|
|
|
private final WidgetFolderContextMenu newInstance(long j) {
|
|
Bundle I = a.I("com.discord.intent.extra.EXTRA_GUILD_FOLDER_ID", j);
|
|
WidgetFolderContextMenu widgetFolderContextMenu = new WidgetFolderContextMenu();
|
|
widgetFolderContextMenu.setArguments(I);
|
|
return widgetFolderContextMenu;
|
|
}
|
|
|
|
public final void hide(FragmentActivity fragmentActivity, boolean z2) {
|
|
m.checkNotNullParameter(fragmentActivity, ActivityChooserModel.ATTRIBUTE_ACTIVITY);
|
|
Fragment findFragmentByTag = fragmentActivity.getSupportFragmentManager().findFragmentByTag(WidgetFolderContextMenu.FRAGMENT_TAG);
|
|
if (!(findFragmentByTag instanceof WidgetFolderContextMenu)) {
|
|
findFragmentByTag = null;
|
|
}
|
|
WidgetFolderContextMenu widgetFolderContextMenu = (WidgetFolderContextMenu) findFragmentByTag;
|
|
if (widgetFolderContextMenu == null) {
|
|
return;
|
|
}
|
|
if (z2) {
|
|
WidgetFolderContextMenu.access$doCircularRemove(widgetFolderContextMenu);
|
|
return;
|
|
}
|
|
fragmentActivity.getSupportFragmentManager().beginTransaction().remove(widgetFolderContextMenu).commitAllowingStateLoss();
|
|
Window window = fragmentActivity.getWindow();
|
|
m.checkNotNullExpressionValue(window, "activity.window");
|
|
View decorView = window.getDecorView();
|
|
m.checkNotNullExpressionValue(decorView, "activity.window.decorView");
|
|
View rootView = decorView.getRootView();
|
|
Objects.requireNonNull(rootView, "null cannot be cast to non-null type android.view.ViewGroup");
|
|
ViewGroup viewGroup = (ViewGroup) rootView;
|
|
Window window2 = fragmentActivity.getWindow();
|
|
m.checkNotNullExpressionValue(window2, "activity.window");
|
|
View decorView2 = window2.getDecorView();
|
|
m.checkNotNullExpressionValue(decorView2, "activity.window.decorView");
|
|
FrameLayout frameLayout = (FrameLayout) decorView2.getRootView().findViewWithTag(WidgetFolderContextMenu.VIEW_CONTAINER_TAG);
|
|
if (frameLayout != null) {
|
|
viewGroup.removeView(frameLayout);
|
|
}
|
|
WidgetFolderContextMenu.access$setShowingContextMenu$cp(false);
|
|
}
|
|
|
|
public final void show(FragmentActivity fragmentActivity, PointF pointF, long j) {
|
|
m.checkNotNullParameter(fragmentActivity, ActivityChooserModel.ATTRIBUTE_ACTIVITY);
|
|
m.checkNotNullParameter(pointF, "absolutePosition");
|
|
if (!WidgetFolderContextMenu.access$isShowingContextMenu$cp()) {
|
|
WidgetFolderContextMenu.access$setShowingContextMenu$cp(true);
|
|
computeMaxContextMenuHeight(fragmentActivity);
|
|
hide(fragmentActivity, false);
|
|
FrameLayout frameLayout = new FrameLayout(fragmentActivity);
|
|
frameLayout.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
|
|
frameLayout.setTag(WidgetFolderContextMenu.VIEW_CONTAINER_TAG);
|
|
Window window = fragmentActivity.getWindow();
|
|
m.checkNotNullExpressionValue(window, "activity.window");
|
|
View decorView = window.getDecorView();
|
|
m.checkNotNullExpressionValue(decorView, "activity.window.decorView");
|
|
View rootView = decorView.getRootView();
|
|
Objects.requireNonNull(rootView, "null cannot be cast to non-null type android.view.ViewGroup");
|
|
ViewGroup viewGroup = (ViewGroup) rootView;
|
|
viewGroup.addView(frameLayout);
|
|
frameLayout.setOnClickListener(new WidgetFolderContextMenu$Companion$show$1(fragmentActivity));
|
|
FrameLayout frameLayout2 = new FrameLayout(fragmentActivity);
|
|
frameLayout2.setId(View.generateViewId());
|
|
frameLayout2.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
|
|
frameLayout.addView(frameLayout2);
|
|
frameLayout2.setX(pointF.x);
|
|
frameLayout2.setY(f.coerceAtMost(pointF.y, (float) ((viewGroup.getHeight() - computeMaxContextMenuHeight(fragmentActivity)) - WidgetFolderContextMenu.access$getSCREEN_BOTTOM_BUFFER$cp())));
|
|
fragmentActivity.getSupportFragmentManager().beginTransaction().add(frameLayout2.getId(), newInstance(j), WidgetFolderContextMenu.FRAGMENT_TAG).commit();
|
|
}
|
|
}
|
|
}
|
|
|
|
public WidgetFolderContextMenu() {
|
|
super(R.layout.widget_folder_context_menu);
|
|
WidgetFolderContextMenu$viewModel$2 widgetFolderContextMenu$viewModel$2 = new WidgetFolderContextMenu$viewModel$2(this);
|
|
f0 f0Var = new f0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(FolderContextMenuViewModel.class), new WidgetFolderContextMenu$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetFolderContextMenu$viewModel$2));
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetFolderContextMenu widgetFolderContextMenu, FolderContextMenuViewModel.ViewState viewState) {
|
|
widgetFolderContextMenu.configureUI(viewState);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$doCircularRemove(WidgetFolderContextMenu widgetFolderContextMenu) {
|
|
widgetFolderContextMenu.doCircularRemove();
|
|
}
|
|
|
|
public static final /* synthetic */ AnimationState access$getAnimationState$p(WidgetFolderContextMenu widgetFolderContextMenu) {
|
|
return widgetFolderContextMenu.animationState;
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetFolderContextMenuBinding access$getBinding$p(WidgetFolderContextMenu widgetFolderContextMenu) {
|
|
return widgetFolderContextMenu.getBinding();
|
|
}
|
|
|
|
public static final /* synthetic */ int access$getSCREEN_BOTTOM_BUFFER$cp() {
|
|
return SCREEN_BOTTOM_BUFFER;
|
|
}
|
|
|
|
public static final /* synthetic */ FolderContextMenuViewModel access$getViewModel$p(WidgetFolderContextMenu widgetFolderContextMenu) {
|
|
return widgetFolderContextMenu.getViewModel();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleEvent(WidgetFolderContextMenu widgetFolderContextMenu, FolderContextMenuViewModel.Event event) {
|
|
widgetFolderContextMenu.handleEvent(event);
|
|
}
|
|
|
|
public static final /* synthetic */ boolean access$isShowingContextMenu$cp() {
|
|
return isShowingContextMenu;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setAnimationState$p(WidgetFolderContextMenu widgetFolderContextMenu, AnimationState animationState) {
|
|
widgetFolderContextMenu.animationState = animationState;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setShowingContextMenu$cp(boolean z2) {
|
|
isShowingContextMenu = z2;
|
|
}
|
|
|
|
private final void configureUI(FolderContextMenuViewModel.ViewState viewState) {
|
|
if (viewState instanceof FolderContextMenuViewModel.ViewState.Valid) {
|
|
configureValidUI((FolderContextMenuViewModel.ViewState.Valid) viewState);
|
|
} else if (m.areEqual(viewState, FolderContextMenuViewModel.ViewState.Invalid.INSTANCE)) {
|
|
Companion companion = Companion;
|
|
FragmentActivity requireActivity = requireActivity();
|
|
m.checkNotNullExpressionValue(requireActivity, "requireActivity()");
|
|
companion.hide(requireActivity, false);
|
|
}
|
|
}
|
|
|
|
private final void configureValidUI(FolderContextMenuViewModel.ViewState.Valid valid) {
|
|
TextView textView = getBinding().f1896c;
|
|
m.checkNotNullExpressionValue(textView, "binding.folderContextMenuHeader");
|
|
CharSequence name = valid.getFolder().getName();
|
|
boolean z2 = false;
|
|
if (name == null) {
|
|
name = b.k(this, R.string.guild_folder_unnamed, new Object[0], null, 4);
|
|
}
|
|
textView.setText(name);
|
|
getBinding().d.setOnClickListener(new WidgetFolderContextMenu$configureValidUI$1(this));
|
|
getBinding().e.setOnClickListener(new WidgetFolderContextMenu$configureValidUI$2(this, valid));
|
|
TextView textView2 = getBinding().d;
|
|
m.checkNotNullExpressionValue(textView2, "binding.folderContextMenuMarkAsRead");
|
|
textView2.setVisibility(valid.getShowMarkAsRead() ? 0 : 8);
|
|
getBinding().b.setContentPadding(0, 0, 0, 0);
|
|
CardView cardView = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView, "binding.folderContextMenuCard");
|
|
if (cardView.getVisibility() == 0) {
|
|
z2 = true;
|
|
}
|
|
if (!z2) {
|
|
doCircularReveal();
|
|
}
|
|
}
|
|
|
|
private final void doCircularRemove() {
|
|
AnimationState animationState = this.animationState;
|
|
if (animationState == AnimationState.ANIMATING_IN) {
|
|
Animator animator = this.animator;
|
|
if (animator != null) {
|
|
animator.cancel();
|
|
}
|
|
Companion companion = Companion;
|
|
FragmentActivity requireActivity = requireActivity();
|
|
m.checkNotNullExpressionValue(requireActivity, "requireActivity()");
|
|
companion.hide(requireActivity, false);
|
|
return;
|
|
}
|
|
AnimationState animationState2 = AnimationState.ANIMATING_OUT;
|
|
if (animationState != animationState2) {
|
|
CardView cardView = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView, "binding.folderContextMenuCard");
|
|
int height = cardView.getHeight() / 2;
|
|
CardView cardView2 = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView2, "binding.folderContextMenuCard");
|
|
int width = cardView2.getWidth();
|
|
CardView cardView3 = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView3, "binding.folderContextMenuCard");
|
|
float hypot = (float) Math.hypot((double) width, (double) (cardView3.getHeight() / 2));
|
|
CardView cardView4 = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView4, "binding.folderContextMenuCard");
|
|
if (cardView4.isAttachedToWindow()) {
|
|
Animator createCircularReveal = ViewAnimationUtils.createCircularReveal(getBinding().b, 0, height, hypot, 0.0f);
|
|
this.animator = createCircularReveal;
|
|
this.animationState = animationState2;
|
|
m.checkNotNullExpressionValue(createCircularReveal, "animator");
|
|
createCircularReveal.setDuration(200);
|
|
createCircularReveal.addListener(new WidgetFolderContextMenu$doCircularRemove$1(this));
|
|
createCircularReveal.start();
|
|
return;
|
|
}
|
|
CardView cardView5 = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView5, "binding.folderContextMenuCard");
|
|
cardView5.setVisibility(8);
|
|
}
|
|
}
|
|
|
|
private final void doCircularReveal() {
|
|
CardView cardView = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView, "binding.folderContextMenuCard");
|
|
if (cardView.isAttachedToWindow()) {
|
|
CardView cardView2 = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView2, "binding.folderContextMenuCard");
|
|
CardView cardView3 = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView3, "binding.folderContextMenuCard");
|
|
int width = cardView3.getWidth();
|
|
CardView cardView4 = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView4, "binding.folderContextMenuCard");
|
|
Animator createCircularReveal = ViewAnimationUtils.createCircularReveal(getBinding().b, 0, cardView2.getHeight() / 2, 0.0f, (float) Math.hypot((double) width, (double) (cardView4.getHeight() / 2)));
|
|
this.animator = createCircularReveal;
|
|
this.animationState = AnimationState.ANIMATING_IN;
|
|
m.checkNotNullExpressionValue(createCircularReveal, "animator");
|
|
createCircularReveal.setDuration(200);
|
|
createCircularReveal.addListener(new WidgetFolderContextMenu$doCircularReveal$1(this));
|
|
CardView cardView5 = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView5, "binding.folderContextMenuCard");
|
|
cardView5.setVisibility(0);
|
|
createCircularReveal.start();
|
|
return;
|
|
}
|
|
CardView cardView6 = getBinding().b;
|
|
m.checkNotNullExpressionValue(cardView6, "binding.folderContextMenuCard");
|
|
cardView6.setVisibility(0);
|
|
}
|
|
|
|
private final WidgetFolderContextMenuBinding getBinding() {
|
|
return (WidgetFolderContextMenuBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final FolderContextMenuViewModel getViewModel() {
|
|
return (FolderContextMenuViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
private final void handleEvent(FolderContextMenuViewModel.Event event) {
|
|
if (m.areEqual(event, FolderContextMenuViewModel.Event.Dismiss.INSTANCE)) {
|
|
doCircularRemove();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
isShowingContextMenu = false;
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment, androidx.fragment.app.Fragment
|
|
public void onResume() {
|
|
super.onResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null), WidgetFolderContextMenu.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetFolderContextMenu$onResume$1(this), 62, (Object) null);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeEvents(), this, null, 2, null), WidgetFolderContextMenu.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetFolderContextMenu$onResume$2(this), 62, (Object) null);
|
|
}
|
|
}
|