正在查看: Plus 12 v10.13.1.1 应用的 Bulletin.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Plus 12 v10.13.1.1 应用的 Bulletin.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.telegram.ui.Components;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.Property;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.util.Consumer;
import androidx.core.view.ViewCompat;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.FloatPropertyCompat;
import androidx.dynamicanimation.animation.FloatValueHolder;
import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.support.SparseLongArray;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ChatActivity;
import org.telegram.ui.Components.AnimationProperties;
import org.telegram.ui.Components.Bulletin;
import org.telegram.ui.Components.LinkSpanDrawable;
import org.telegram.ui.Components.Reactions.ReactionsLayoutInBubble;
import org.telegram.ui.Components.ReactionsContainerLayout;
import org.telegram.ui.DialogsActivity;
import org.telegram.ui.LaunchActivity;
public class Bulletin {
public static final HashMap<FrameLayout, Delegate> delegates = new HashMap<>();
public static final HashMap<BaseFragment, Delegate> fragmentDelegates = new HashMap<>();
@SuppressLint({"StaticFieldLeak"})
public static Bulletin visibleBulletin;
public SpringAnimation bottomOffsetSpring;
public boolean canHide;
public final BaseFragment containerFragment;
public final FrameLayout containerLayout;
public View.OnLayoutChangeListener containerLayoutListener;
public int currentBottomOffset;
public Delegate currentDelegate;
public int duration;
public int hash;
public boolean hideAfterBottomSheet;
public final Runnable hideRunnable;
public int lastBottomOffset;
public final Layout layout;
public Layout.Transition layoutTransition;
public boolean loaded;
public Runnable onHideListener;
public final ParentLayout parentLayout;
public boolean showing;
public int tag;
public interface Delegate {
public final class CC {
public static boolean $default$allowLayoutChanges(Delegate delegate) {
return true;
}
public static boolean $default$bottomOffsetAnimated(Delegate delegate) {
return true;
}
public static boolean $default$clipWithGradient(Delegate delegate, int i) {
return false;
}
public static int $default$getBottomOffset(Delegate delegate, int i) {
return 0;
}
public static int $default$getTopOffset(Delegate delegate, int i) {
return 0;
}
public static void $default$onBottomOffsetChange(Delegate delegate, float f) {
}
public static void $default$onHide(Delegate delegate, Bulletin bulletin) {
}
public static void $default$onShow(Delegate delegate, Bulletin bulletin) {
}
}
boolean allowLayoutChanges();
boolean bottomOffsetAnimated();
boolean clipWithGradient(int tag);
int getBottomOffset(int tag);
int getTopOffset(int tag);
void onBottomOffsetChange(float offset);
void onHide(Bulletin bulletin);
void onShow(Bulletin bulletin);
}
public interface LoadingLayout {
void onTextLoaded(CharSequence text);
}
public static Bulletin make(FrameLayout containerLayout, Layout contentLayout, int duration) {
return new Bulletin(null, containerLayout, contentLayout, duration);
}
public Bulletin setOnClickListener(View.OnClickListener onClickListener) {
Layout layout = this.layout;
if (layout != null) {
layout.setOnClickListener(onClickListener);
}
return this;
}
@SuppressLint({"RtlHardcoded"})
public static Bulletin make(BaseFragment fragment, Layout contentLayout, int duration) {
if (fragment instanceof ChatActivity) {
contentLayout.setWideScreenParams(-2, 1);
} else if (fragment instanceof DialogsActivity) {
contentLayout.setWideScreenParams(-1, 0);
}
return new Bulletin(fragment, fragment.getLayoutContainer(), contentLayout, duration);
}
public static Bulletin find(FrameLayout containerLayout) {
int childCount = containerLayout.getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = containerLayout.getChildAt(i);
if (childAt instanceof Layout) {
return ((Layout) childAt).bulletin;
}
}
return null;
}
public static void hide(FrameLayout containerLayout) {
hide(containerLayout, true);
}
public static void hide(FrameLayout containerLayout, boolean animated) {
Bulletin find = find(containerLayout);
if (find != null) {
find.hide(animated && isTransitionsEnabled(), 0L);
}
}
public Bulletin() {
this.hideRunnable = new Runnable() {
@Override
public final void run() {
Bulletin.this.hide();
}
};
this.loaded = true;
this.hideAfterBottomSheet = true;
this.layout = null;
this.parentLayout = null;
this.containerFragment = null;
this.containerLayout = null;
}
public Bulletin(BaseFragment fragment, final FrameLayout containerLayout, Layout layout, int duration) {
this.hideRunnable = new Runnable() {
@Override
public final void run() {
Bulletin.this.hide();
}
};
this.loaded = true;
this.hideAfterBottomSheet = true;
this.layout = layout;
this.loaded = true ^ (layout instanceof LoadingLayout);
this.parentLayout = new ParentLayout(layout) {
@Override
public void onPressedStateChanged(boolean pressed) {
Bulletin.this.setCanHide(!pressed);
if (containerLayout.getParent() != null) {
containerLayout.getParent().requestDisallowInterceptTouchEvent(pressed);
}
}
@Override
public void onHide() {
Bulletin.this.hide();
}
};
this.containerFragment = fragment;
this.containerLayout = containerLayout;
this.duration = duration;
}
public static Bulletin getVisibleBulletin() {
return visibleBulletin;
}
public static void hideVisible() {
Bulletin bulletin = visibleBulletin;
if (bulletin != null) {
bulletin.hide();
}
}
public static void hideVisible(ViewGroup container) {
Bulletin bulletin = visibleBulletin;
if (bulletin == null || bulletin.containerLayout != container) {
return;
}
bulletin.hide();
}
public Bulletin setDuration(int duration) {
this.duration = duration;
return this;
}
public Bulletin hideAfterBottomSheet(boolean hide) {
this.hideAfterBottomSheet = hide;
return this;
}
public Bulletin setTag(int tag) {
this.tag = tag;
return this;
}
public Bulletin show() {
return show(false);
}
public Bulletin show(final boolean top) {
if (!this.showing && this.containerLayout != null) {
this.showing = true;
this.layout.setTop(top);
CharSequence accessibilityText = this.layout.getAccessibilityText();
if (accessibilityText != null) {
AndroidUtilities.makeAccessibilityAnnouncement(accessibilityText);
}
if (this.layout.getParent() != this.parentLayout) {
throw new IllegalStateException("Layout has incorrect parent");
}
Bulletin bulletin = visibleBulletin;
if (bulletin != null) {
bulletin.hide();
}
visibleBulletin = this;
this.layout.onAttach(this);
FrameLayout frameLayout = this.containerLayout;
View.OnLayoutChangeListener onLayoutChangeListener = new View.OnLayoutChangeListener() {
@Override
public final void onLayoutChange(View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
Bulletin.this.lambda$show$2(top, view, i, i2, i3, i4, i5, i6, i7, i8);
}
};
this.containerLayoutListener = onLayoutChangeListener;
frameLayout.addOnLayoutChangeListener(onLayoutChangeListener);
this.layout.addOnLayoutChangeListener(new AnonymousClass2(top));
this.layout.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View v) {
}
@Override
public void onViewDetachedFromWindow(View v) {
Bulletin.this.layout.removeOnAttachStateChangeListener(this);
Bulletin.this.hide(false, 0L);
}
});
this.containerLayout.addView(this.parentLayout);
}
return this;
}
public void lambda$show$2(boolean z, View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) {
Delegate delegate = this.currentDelegate;
if ((delegate == null || delegate.allowLayoutChanges()) && !z) {
Delegate delegate2 = this.currentDelegate;
int bottomOffset = delegate2 != null ? delegate2.getBottomOffset(this.tag) : 0;
if (this.lastBottomOffset != bottomOffset) {
SpringAnimation springAnimation = this.bottomOffsetSpring;
if (springAnimation == null || !springAnimation.isRunning()) {
SpringAnimation spring = new SpringAnimation(new FloatValueHolder(this.lastBottomOffset)).setSpring(new SpringForce().setFinalPosition(bottomOffset).setStiffness(900.0f).setDampingRatio(1.0f));
this.bottomOffsetSpring = spring;
spring.addUpdateListener(new DynamicAnimation.OnAnimationUpdateListener() {
public final void onAnimationUpdate(DynamicAnimation dynamicAnimation, float f, float f2) {
Bulletin.this.lambda$show$0(dynamicAnimation, f, f2);
}
});
this.bottomOffsetSpring.addEndListener(new DynamicAnimation.OnAnimationEndListener() {
public final void onAnimationEnd(DynamicAnimation dynamicAnimation, boolean z2, float f, float f2) {
Bulletin.this.lambda$show$1(dynamicAnimation, z2, f, f2);
}
});
} else {
this.bottomOffsetSpring.getSpring().setFinalPosition(bottomOffset);
}
this.bottomOffsetSpring.start();
}
}
}
public void lambda$show$0(DynamicAnimation dynamicAnimation, float f, float f2) {
this.lastBottomOffset = (int) f;
updatePosition();
}
public void lambda$show$1(DynamicAnimation dynamicAnimation, boolean z, float f, float f2) {
if (this.bottomOffsetSpring == dynamicAnimation) {
this.bottomOffsetSpring = null;
}
}
public class AnonymousClass2 implements View.OnLayoutChangeListener {
public final boolean val$top;
public AnonymousClass2(final boolean val$top) {
this.val$top = val$top;
}
@Override
public void onLayoutChange(View v, int left, int t, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
Bulletin.this.layout.removeOnLayoutChangeListener(this);
if (Bulletin.this.showing) {
Bulletin.this.layout.onShow();
Bulletin bulletin = Bulletin.this;
bulletin.currentDelegate = Bulletin.findDelegate(bulletin.containerFragment, Bulletin.this.containerLayout);
if (Bulletin.this.bottomOffsetSpring == null || !Bulletin.this.bottomOffsetSpring.isRunning()) {
Bulletin bulletin2 = Bulletin.this;
bulletin2.lastBottomOffset = bulletin2.currentDelegate != null ? Bulletin.this.currentDelegate.getBottomOffset(Bulletin.this.tag) : 0;
}
if (Bulletin.this.currentDelegate != null) {
Bulletin.this.currentDelegate.onShow(Bulletin.this);
}
if (Bulletin.isTransitionsEnabled()) {
Bulletin.this.ensureLayoutTransitionCreated();
Bulletin.this.layout.transitionRunningEnter = true;
Bulletin.this.layout.delegate = Bulletin.this.currentDelegate;
Bulletin.this.layout.invalidate();
Layout.Transition transition = Bulletin.this.layoutTransition;
Layout layout = Bulletin.this.layout;
final Layout layout2 = Bulletin.this.layout;
Objects.requireNonNull(layout2);
Runnable runnable = new Runnable() {
@Override
public final void run() {
Bulletin.Layout.this.onEnterTransitionStart();
}
};
Runnable runnable2 = new Runnable() {
@Override
public final void run() {
Bulletin.AnonymousClass2.this.lambda$onLayoutChange$0();
}
};
final boolean z = this.val$top;
transition.animateEnter(layout, runnable, runnable2, new Consumer() {
public final void accept(Object obj) {
Bulletin.AnonymousClass2.this.lambda$onLayoutChange$1(z, (Float) obj);
}
}, Bulletin.this.currentBottomOffset);
return;
}
if (Bulletin.this.currentDelegate != null && !this.val$top) {
Bulletin.this.currentDelegate.onBottomOffsetChange(Bulletin.this.layout.getHeight() - Bulletin.this.currentBottomOffset);
}
Bulletin.this.updatePosition();
Bulletin.this.layout.onEnterTransitionStart();
Bulletin.this.layout.onEnterTransitionEnd();
Bulletin.this.setCanHide(true);
}
}
public void lambda$onLayoutChange$0() {
Bulletin.this.layout.transitionRunningEnter = false;
Bulletin.this.layout.onEnterTransitionEnd();
Bulletin.this.setCanHide(true);
}
public void lambda$onLayoutChange$1(boolean z, Float f) {
if (Bulletin.this.currentDelegate == null || z) {
return;
}
Bulletin.this.currentDelegate.onBottomOffsetChange(Bulletin.this.layout.getHeight() - f.floatValue());
}
}
public void setCanHide(boolean canHide) {
Layout layout;
boolean z = canHide && this.loaded;
if (this.canHide == z || (layout = this.layout) == null) {
return;
}
this.canHide = z;
if (z) {
layout.postDelayed(this.hideRunnable, this.duration);
} else {
layout.removeCallbacks(this.hideRunnable);
}
}
public Bulletin setOnHideListener(Runnable listener) {
this.onHideListener = listener;
return this;
}
public final void ensureLayoutTransitionCreated() {
Layout layout = this.layout;
if (layout == null || this.layoutTransition != null) {
return;
}
this.layoutTransition = layout.createTransition();
}
public void hide() {
hide(isTransitionsEnabled(), 0L);
}
public void hide(long duration) {
hide(isTransitionsEnabled(), duration);
}
public void hide(boolean animated, long duration) {
Layout layout = this.layout;
if (layout != null && this.showing) {
this.showing = false;
if (visibleBulletin == this) {
visibleBulletin = null;
}
int i = this.currentBottomOffset;
this.currentBottomOffset = 0;
if (ViewCompat.isLaidOut(layout)) {
this.layout.removeCallbacks(this.hideRunnable);
if (animated) {
Layout layout2 = this.layout;
layout2.transitionRunningExit = true;
layout2.delegate = this.currentDelegate;
layout2.invalidate();
if (duration >= 0) {
Layout.DefaultTransition defaultTransition = new Layout.DefaultTransition();
defaultTransition.duration = duration;
this.layoutTransition = defaultTransition;
} else {
ensureLayoutTransitionCreated();
}
Layout.Transition transition = this.layoutTransition;
final Layout layout3 = this.layout;
Objects.requireNonNull(layout3);
transition.animateExit(layout3, new Runnable() {
@Override
public final void run() {
Bulletin.Layout.this.onExitTransitionStart();
}
}, new Runnable() {
@Override
public final void run() {
Bulletin.this.lambda$hide$3();
}
}, new Consumer() {
public final void accept(Object obj) {
Bulletin.this.lambda$hide$4((Float) obj);
}
}, i);
return;
}
}
Delegate delegate = this.currentDelegate;
if (delegate != null && !this.layout.top) {
delegate.onBottomOffsetChange(0.0f);
this.currentDelegate.onHide(this);
}
this.layout.onExitTransitionStart();
this.layout.onExitTransitionEnd();
this.layout.onHide();
if (this.containerLayout != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
Bulletin.this.lambda$hide$5();
}
});
}
this.layout.onDetach();
Runnable runnable = this.onHideListener;
if (runnable != null) {
runnable.run();
}
}
}
public void lambda$hide$3() {
Delegate delegate = this.currentDelegate;
if (delegate != null && !this.layout.top) {
delegate.onBottomOffsetChange(0.0f);
this.currentDelegate.onHide(this);
}
Layout layout = this.layout;
layout.transitionRunningExit = false;
layout.onExitTransitionEnd();
this.layout.onHide();
this.containerLayout.removeView(this.parentLayout);
this.containerLayout.removeOnLayoutChangeListener(this.containerLayoutListener);
this.layout.onDetach();
Runnable runnable = this.onHideListener;
if (runnable != null) {
runnable.run();
}
}
public void lambda$hide$4(Float f) {
Delegate delegate = this.currentDelegate;
if (delegate != null) {
if (this.layout.top) {
return;
}
delegate.onBottomOffsetChange(r1.getHeight() - f.floatValue());
}
}
public void lambda$hide$5() {
this.containerLayout.removeView(this.parentLayout);
this.containerLayout.removeOnLayoutChangeListener(this.containerLayoutListener);
}
public boolean isShowing() {
return this.showing;
}
public Layout getLayout() {
return this.layout;
}
public static boolean isTransitionsEnabled() {
return MessagesController.getGlobalMainSettings().getBoolean("view_animations", true) && Build.VERSION.SDK_INT >= 18;
}
public void updatePosition() {
Layout layout = this.layout;
if (layout != null) {
layout.updatePosition();
}
}
public static abstract class ParentLayout extends FrameLayout {
public final GestureDetector gestureDetector;
public boolean hideAnimationRunning;
public final Layout layout;
public boolean needLeftAlphaAnimation;
public boolean needRightAlphaAnimation;
public boolean pressed;
public final android.graphics.Rect rect;
public float translationX;
public abstract void onHide();
public abstract void onPressedStateChanged(boolean pressed);
public ParentLayout(Layout layout) {
super(layout.getContext());
this.rect = new android.graphics.Rect();
this.layout = layout;
GestureDetector gestureDetector = new GestureDetector(layout.getContext(), new AnonymousClass1(layout));
this.gestureDetector = gestureDetector;
gestureDetector.setIsLongpressEnabled(false);
addView(layout);
}
public class AnonymousClass1 extends GestureDetector.SimpleOnGestureListener {
public final Layout val$layout;
public AnonymousClass1(final Layout val$layout) {
this.val$layout = val$layout;
}
@Override
public boolean onDown(MotionEvent e) {
if (ParentLayout.this.hideAnimationRunning) {
return false;
}
ParentLayout.this.needLeftAlphaAnimation = this.val$layout.isNeedSwipeAlphaAnimation(true);
ParentLayout.this.needRightAlphaAnimation = this.val$layout.isNeedSwipeAlphaAnimation(false);
return true;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
Layout layout = this.val$layout;
ParentLayout parentLayout = ParentLayout.this;
float f = parentLayout.translationX - distanceX;
parentLayout.translationX = f;
layout.setTranslationX(f);
if (ParentLayout.this.translationX != 0.0f && ((ParentLayout.this.translationX >= 0.0f || !ParentLayout.this.needLeftAlphaAnimation) && (ParentLayout.this.translationX <= 0.0f || !ParentLayout.this.needRightAlphaAnimation))) {
return true;
}
this.val$layout.setAlpha(1.0f - (Math.abs(ParentLayout.this.translationX) / this.val$layout.getWidth()));
return true;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
boolean z = false;
if (Math.abs(velocityX) <= 2000.0f) {
return false;
}
if ((velocityX < 0.0f && ParentLayout.this.needLeftAlphaAnimation) || (velocityX > 0.0f && ParentLayout.this.needRightAlphaAnimation)) {
z = true;
}
SpringAnimation springAnimation = new SpringAnimation(this.val$layout, DynamicAnimation.TRANSLATION_X, Math.signum(velocityX) * this.val$layout.getWidth() * 2.0f);
if (!z) {
springAnimation.addEndListener(new DynamicAnimation.OnAnimationEndListener() {
public final void onAnimationEnd(DynamicAnimation dynamicAnimation, boolean z2, float f, float f2) {
Bulletin.ParentLayout.AnonymousClass1.this.lambda$onFling$0(dynamicAnimation, z2, f, f2);
}
});
final Layout layout = this.val$layout;
springAnimation.addUpdateListener(new DynamicAnimation.OnAnimationUpdateListener() {
public final void onAnimationUpdate(DynamicAnimation dynamicAnimation, float f, float f2) {
Bulletin.ParentLayout.AnonymousClass1.lambda$onFling$1(Bulletin.Layout.this, dynamicAnimation, f, f2);
}
});
}
springAnimation.getSpring().setDampingRatio(1.0f);
springAnimation.getSpring().setStiffness(100.0f);
springAnimation.setStartVelocity(velocityX);
springAnimation.start();
if (z) {
SpringAnimation springAnimation2 = new SpringAnimation(this.val$layout, DynamicAnimation.ALPHA, 0.0f);
springAnimation2.addEndListener(new DynamicAnimation.OnAnimationEndListener() {
public final void onAnimationEnd(DynamicAnimation dynamicAnimation, boolean z2, float f, float f2) {
Bulletin.ParentLayout.AnonymousClass1.this.lambda$onFling$2(dynamicAnimation, z2, f, f2);
}
});
springAnimation2.addUpdateListener(new DynamicAnimation.OnAnimationUpdateListener() {
public final void onAnimationUpdate(DynamicAnimation dynamicAnimation, float f, float f2) {
Bulletin.ParentLayout.AnonymousClass1.lambda$onFling$3(dynamicAnimation, f, f2);
}
});
springAnimation.getSpring().setDampingRatio(1.0f);
springAnimation.getSpring().setStiffness(10.0f);
springAnimation.setStartVelocity(velocityX);
springAnimation2.start();
}
ParentLayout.this.hideAnimationRunning = true;
return true;
}
public void lambda$onFling$0(DynamicAnimation dynamicAnimation, boolean z, float f, float f2) {
ParentLayout.this.onHide();
}
public static void lambda$onFling$1(Layout layout, DynamicAnimation dynamicAnimation, float f, float f2) {
if (Math.abs(f) > layout.getWidth()) {
dynamicAnimation.cancel();
}
}
public void lambda$onFling$2(DynamicAnimation dynamicAnimation, boolean z, float f, float f2) {
ParentLayout.this.onHide();
}
public static void lambda$onFling$3(DynamicAnimation dynamicAnimation, float f, float f2) {
if (f <= 0.0f) {
dynamicAnimation.cancel();
}
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!this.pressed && !inLayoutHitRect(event.getX(), event.getY())) {
return false;
}
this.gestureDetector.onTouchEvent(event);
int actionMasked = event.getActionMasked();
if (actionMasked == 0) {
if (!this.pressed && !this.hideAnimationRunning) {
this.layout.animate().cancel();
this.translationX = this.layout.getTranslationX();
this.pressed = true;
onPressedStateChanged(true);
}
} else if ((actionMasked == 1 || actionMasked == 3) && this.pressed) {
if (!this.hideAnimationRunning) {
if (Math.abs(this.translationX) > this.layout.getWidth() / 3.0f) {
final float signum = Math.signum(this.translationX) * this.layout.getWidth();
float f = this.translationX;
this.layout.animate().translationX(signum).alpha(((f > 0.0f ? 1 : (f == 0.0f ? 0 : -1)) < 0 && this.needLeftAlphaAnimation) || ((f > 0.0f ? 1 : (f == 0.0f ? 0 : -1)) > 0 && this.needRightAlphaAnimation) ? 0.0f : 1.0f).setDuration(200L).setInterpolator(AndroidUtilities.accelerateInterpolator).withEndAction(new Runnable() {
@Override
public final void run() {
Bulletin.ParentLayout.this.lambda$onTouchEvent$0(signum);
}
}).start();
} else {
this.layout.animate().translationX(0.0f).alpha(1.0f).setDuration(200L).start();
}
}
this.pressed = false;
onPressedStateChanged(false);
}
return true;
}
public void lambda$onTouchEvent$0(float f) {
if (this.layout.getTranslationX() == f) {
onHide();
}
}
public final boolean inLayoutHitRect(float x, float y) {
this.layout.getHitRect(this.rect);
return this.rect.contains((int) x, (int) y);
}
}
public static void addDelegate(BaseFragment fragment, Delegate delegate) {
fragmentDelegates.put(fragment, delegate);
}
public static void addDelegate(FrameLayout containerLayout, Delegate delegate) {
delegates.put(containerLayout, delegate);
}
public static Delegate findDelegate(BaseFragment probableFragment, FrameLayout probableContainer) {
Delegate delegate = fragmentDelegates.get(probableFragment);
if (delegate != null) {
return delegate;
}
Delegate delegate2 = delegates.get(probableContainer);
if (delegate2 != null) {
return delegate2;
}
return null;
}
public static void removeDelegate(BaseFragment fragment) {
fragmentDelegates.remove(fragment);
}
public static void removeDelegate(FrameLayout containerLayout) {
delegates.remove(containerLayout);
}
public static abstract class Layout extends FrameLayout {
public static final FloatPropertyCompat<Layout> IN_OUT_OFFSET_Y;
public static final Property<Layout, Float> IN_OUT_OFFSET_Y2;
public Drawable background;
public Bulletin bulletin;
public final List<Callback> callbacks;
public LinearGradient clipGradient;
public Matrix clipMatrix;
public Paint clipPaint;
public Delegate delegate;
public float inOutOffset;
public final Theme.ResourcesProvider resourcesProvider;
public boolean top;
public boolean transitionRunningEnter;
public boolean transitionRunningExit;
public int wideScreenGravity;
public int wideScreenWidth;
public interface Callback {
public final class CC {
public static void $default$onAttach(Callback callback, Layout layout, Bulletin bulletin) {
}
public static void $default$onDetach(Callback callback, Layout layout) {
}
public static void $default$onEnterTransitionEnd(Callback callback, Layout layout) {
}
public static void $default$onEnterTransitionStart(Callback callback, Layout layout) {
}
public static void $default$onExitTransitionEnd(Callback callback, Layout layout) {
}
public static void $default$onExitTransitionStart(Callback callback, Layout layout) {
}
}
void onAttach(Layout layout, Bulletin bulletin);
void onDetach(Layout layout);
void onEnterTransitionEnd(Layout layout);
void onEnterTransitionStart(Layout layout);
void onExitTransitionEnd(Layout layout);
void onExitTransitionStart(Layout layout);
void onHide(Layout layout);
void onShow(Layout layout);
}
public interface Transition {
void animateEnter(Layout layout, Runnable startAction, Runnable endAction, Consumer<Float> onUpdate, int bottomOffset);
void animateExit(Layout layout, Runnable startAction, Runnable endAction, Consumer<Float> onUpdate, int bottomOffset);
}
public CharSequence getAccessibilityText() {
return null;
}
public boolean isTransitionRunning() {
return this.transitionRunningEnter || this.transitionRunningExit;
}
public Layout(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context);
this.callbacks = new ArrayList();
this.wideScreenWidth = -2;
this.wideScreenGravity = 1;
this.resourcesProvider = resourcesProvider;
setMinimumHeight(AndroidUtilities.dp(48.0f));
setBackground(getThemedColor(Theme.key_undo_background));
updateSize();
setPadding(AndroidUtilities.dp(8.0f), AndroidUtilities.dp(8.0f), AndroidUtilities.dp(8.0f), AndroidUtilities.dp(8.0f));
setWillNotDraw(false);
ScaleStateListAnimator.apply(this, 0.02f, 1.5f);
}
@Override
public boolean verifyDrawable(Drawable who) {
return this.background == who || super.verifyDrawable(who);
}
public void setBackground(int color) {
setBackground(color, 10);
}
public void setBackground(int color, int rounding) {
this.background = Theme.createRoundRectDrawable(AndroidUtilities.dp(rounding), color);
}
static {
String str = "offsetY";
IN_OUT_OFFSET_Y = new FloatPropertyCompat<Layout>(str) {
public float getValue(Layout object) {
return object.inOutOffset;
}
public void setValue(Layout object, float value) {
object.setInOutOffset(value);
}
};
IN_OUT_OFFSET_Y2 = new AnimationProperties.FloatProperty<Layout>(str) {
@Override
public Float get(Layout layout) {
return Float.valueOf(layout.inOutOffset);
}
@Override
public void setValue(Layout object, float value) {
object.setInOutOffset(value);
}
};
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
updateSize();
}
public void setTop(boolean top) {
this.top = top;
updateSize();
}
private void updateSize() {
boolean isWideScreen = isWideScreen();
int i = isWideScreen ? this.wideScreenWidth : -1;
if (isWideScreen) {
r3 = (this.top ? 48 : 80) | this.wideScreenGravity;
} else if (!this.top) {
r3 = 80;
}
setLayoutParams(LayoutHelper.createFrame(i, -2, r3));
}
public final boolean isWideScreen() {
if (!AndroidUtilities.isTablet()) {
android.graphics.Point point = AndroidUtilities.displaySize;
if (point.x < point.y) {
return false;
}
}
return true;
}
public final void setWideScreenParams(int width, int gravity) {
boolean z;
boolean z2 = true;
if (this.wideScreenWidth != width) {
this.wideScreenWidth = width;
z = true;
} else {
z = false;
}
if (this.wideScreenGravity != gravity) {
this.wideScreenGravity = gravity;
} else {
z2 = z;
}
if (isWideScreen() && z2) {
updateSize();
}
}
@SuppressLint({"RtlHardcoded"})
public final boolean isNeedSwipeAlphaAnimation(boolean swipeLeft) {
if (!isWideScreen() || this.wideScreenWidth == -1) {
return false;
}
int i = this.wideScreenGravity;
if (i == 1) {
return true;
}
return swipeLeft ? i == 5 : i != 5;
}
public Bulletin getBulletin() {
return this.bulletin;
}
public void onAttach(Bulletin bulletin) {
this.bulletin = bulletin;
int size = this.callbacks.size();
for (int i = 0; i < size; i++) {
this.callbacks.get(i).onAttach(this, bulletin);
}
}
public void onDetach() {
this.bulletin = null;
int size = this.callbacks.size();
for (int i = 0; i < size; i++) {
this.callbacks.get(i).onDetach(this);
}
}
public void onShow() {
int size = this.callbacks.size();
for (int i = 0; i < size; i++) {
this.callbacks.get(i).onShow(this);
}
}
public void onHide() {
int size = this.callbacks.size();
for (int i = 0; i < size; i++) {
this.callbacks.get(i).onHide(this);
}
}
public void onEnterTransitionStart() {
int size = this.callbacks.size();
for (int i = 0; i < size; i++) {
this.callbacks.get(i).onEnterTransitionStart(this);
}
}
public void onEnterTransitionEnd() {
int size = this.callbacks.size();
for (int i = 0; i < size; i++) {
this.callbacks.get(i).onEnterTransitionEnd(this);
}
}
public void onExitTransitionStart() {
int size = this.callbacks.size();
for (int i = 0; i < size; i++) {
this.callbacks.get(i).onExitTransitionStart(this);
}
}
public void onExitTransitionEnd() {
int size = this.callbacks.size();
for (int i = 0; i < size; i++) {
this.callbacks.get(i).onExitTransitionEnd(this);
}
}
public void addCallback(Callback callback) {
this.callbacks.add(callback);
}
public void removeCallback(Callback callback) {
this.callbacks.remove(callback);
}
public void updatePosition() {
float f = 0.0f;
if (this.delegate != null) {
if (this.top) {
f = 0.0f - r0.getTopOffset(this.bulletin != null ? r2.tag : 0);
} else {
f = 0.0f + getBottomOffset();
}
}
setTranslationY((-f) + (this.inOutOffset * (this.top ? -1 : 1)));
}
public float getBottomOffset() {
int bottomOffset;
Delegate delegate;
if (this.bulletin != null && (((delegate = this.delegate) == null || delegate.bottomOffsetAnimated()) && this.bulletin.bottomOffsetSpring != null && this.bulletin.bottomOffsetSpring.isRunning())) {
bottomOffset = this.bulletin.lastBottomOffset;
} else {
Delegate delegate2 = this.delegate;
Bulletin bulletin = this.bulletin;
bottomOffset = delegate2.getBottomOffset(bulletin != null ? bulletin.tag : 0);
}
return bottomOffset;
}
public Transition createTransition() {
return new SpringTransition();
}
public static class DefaultTransition implements Transition {
public long duration = 255;
@Override
public void animateEnter(final Layout layout, final Runnable startAction, final Runnable endAction, final Consumer<Float> onUpdate, int bottomOffset) {
layout.setInOutOffset(layout.getMeasuredHeight());
if (onUpdate != null) {
onUpdate.accept(Float.valueOf(layout.getTranslationY()));
}
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(layout, Layout.IN_OUT_OFFSET_Y2, 0.0f);
ofFloat.setDuration(this.duration);
ofFloat.setInterpolator(Easings.easeOutQuad);
if (startAction != null || endAction != null) {
ofFloat.addListener(new AnimatorListenerAdapter(this) {
@Override
public void onAnimationStart(Animator animation) {
Runnable runnable = startAction;
if (runnable != null) {
runnable.run();
}
}
@Override
public void onAnimationEnd(Animator animation) {
Runnable runnable = endAction;
if (runnable != null) {
runnable.run();
}
}
});
}
if (onUpdate != null) {
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
Bulletin.Layout.DefaultTransition.lambda$animateEnter$0(onUpdate, layout, valueAnimator);
}
});
}
ofFloat.start();
}
public static void lambda$animateEnter$0(Consumer consumer, Layout layout, ValueAnimator valueAnimator) {
consumer.accept(Float.valueOf(layout.getTranslationY()));
}
@Override
public void animateExit(final Layout layout, final Runnable startAction, final Runnable endAction, final Consumer<Float> onUpdate, int bottomOffset) {
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(layout, Layout.IN_OUT_OFFSET_Y2, layout.getHeight());
ofFloat.setDuration(175L);
ofFloat.setInterpolator(Easings.easeInQuad);
if (startAction != null || endAction != null) {
ofFloat.addListener(new AnimatorListenerAdapter(this) {
@Override
public void onAnimationStart(Animator animation) {
Runnable runnable = startAction;
if (runnable != null) {
runnable.run();
}
}
@Override
public void onAnimationEnd(Animator animation) {
Runnable runnable = endAction;
if (runnable != null) {
runnable.run();
}
}
});
}
if (onUpdate != null) {
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
Bulletin.Layout.DefaultTransition.lambda$animateExit$1(onUpdate, layout, valueAnimator);
}
});
}
ofFloat.start();
}
public static void lambda$animateExit$1(Consumer consumer, Layout layout, ValueAnimator valueAnimator) {
consumer.accept(Float.valueOf(layout.getTranslationY()));
}
}
public static class SpringTransition implements Transition {
@Override
public void animateEnter(final Layout layout, Runnable startAction, final Runnable endAction, final Consumer<Float> onUpdate, int bottomOffset) {
layout.setInOutOffset(layout.getMeasuredHeight());
if (onUpdate != null) {
onUpdate.accept(Float.valueOf(layout.getTranslationY()));
}
SpringAnimation springAnimation = new SpringAnimation(layout, Layout.IN_OUT_OFFSET_Y, 0.0f);
springAnimation.getSpring().setDampingRatio(0.8f);
springAnimation.getSpring().setStiffness(400.0f);
if (endAction != null) {
springAnimation.addEndListener(new DynamicAnimation.OnAnimationEndListener() {
public final void onAnimationEnd(DynamicAnimation dynamicAnimation, boolean z, float f, float f2) {
Bulletin.Layout.SpringTransition.lambda$animateEnter$0(Bulletin.Layout.this, endAction, dynamicAnimation, z, f, f2);
}
});
}
if (onUpdate != null) {
springAnimation.addUpdateListener(new DynamicAnimation.OnAnimationUpdateListener() {
public final void onAnimationUpdate(DynamicAnimation dynamicAnimation, float f, float f2) {
Bulletin.Layout.SpringTransition.lambda$animateEnter$1(onUpdate, layout, dynamicAnimation, f, f2);
}
});
}
springAnimation.start();
if (startAction != null) {
startAction.run();
}
}
public static void lambda$animateEnter$0(Layout layout, Runnable runnable, DynamicAnimation dynamicAnimation, boolean z, float f, float f2) {
layout.setInOutOffset(0.0f);
if (z) {
return;
}
runnable.run();
}
public static void lambda$animateEnter$1(Consumer consumer, Layout layout, DynamicAnimation dynamicAnimation, float f, float f2) {
consumer.accept(Float.valueOf(layout.getTranslationY()));
}
@Override
public void animateExit(final Layout layout, Runnable startAction, final Runnable endAction, final Consumer<Float> onUpdate, int bottomOffset) {
SpringAnimation springAnimation = new SpringAnimation(layout, Layout.IN_OUT_OFFSET_Y, layout.getHeight());
springAnimation.getSpring().setDampingRatio(0.8f);
springAnimation.getSpring().setStiffness(400.0f);
if (endAction != null) {
springAnimation.addEndListener(new DynamicAnimation.OnAnimationEndListener() {
public final void onAnimationEnd(DynamicAnimation dynamicAnimation, boolean z, float f, float f2) {
Bulletin.Layout.SpringTransition.lambda$animateExit$2(endAction, dynamicAnimation, z, f, f2);
}
});
}
if (onUpdate != null) {
springAnimation.addUpdateListener(new DynamicAnimation.OnAnimationUpdateListener() {
public final void onAnimationUpdate(DynamicAnimation dynamicAnimation, float f, float f2) {
Bulletin.Layout.SpringTransition.lambda$animateExit$3(onUpdate, layout, dynamicAnimation, f, f2);
}
});
}
springAnimation.start();
if (startAction != null) {
startAction.run();
}
}
public static void lambda$animateExit$2(Runnable runnable, DynamicAnimation dynamicAnimation, boolean z, float f, float f2) {
if (z) {
return;
}
runnable.run();
}
public static void lambda$animateExit$3(Consumer consumer, Layout layout, DynamicAnimation dynamicAnimation, float f, float f2) {
consumer.accept(Float.valueOf(layout.getTranslationY()));
}
}
public void setInOutOffset(float offset) {
this.inOutOffset = offset;
updatePosition();
}
public int getMeasuredBackgroundHeight() {
return getMeasuredHeight();
}
@Override
public void dispatchDraw(Canvas canvas) {
Delegate delegate;
if (this.bulletin == null) {
return;
}
this.background.setBounds(getPaddingLeft(), getPaddingTop(), getMeasuredWidth() - getPaddingRight(), getMeasuredBackgroundHeight() - getPaddingBottom());
if (isTransitionRunning() && (delegate = this.delegate) != null) {
float topOffset = delegate.getTopOffset(this.bulletin.tag) - getY();
float measuredHeight = (((View) getParent()).getMeasuredHeight() - getBottomOffset()) - getY();
boolean clipWithGradient = this.delegate.clipWithGradient(this.bulletin.tag);
canvas.save();
canvas.clipRect(0.0f, topOffset, getMeasuredWidth(), measuredHeight);
if (clipWithGradient) {
canvas.saveLayerAlpha(0.0f, 0.0f, getWidth(), getHeight(), 255, 31);
}
this.background.draw(canvas);
super.dispatchDraw(canvas);
if (clipWithGradient) {
if (this.clipPaint == null) {
Paint paint = new Paint(1);
this.clipPaint = paint;
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
this.clipGradient = new LinearGradient(0.0f, 0.0f, 0.0f, AndroidUtilities.dp(8.0f), this.top ? new int[]{-16777216, 0} : new int[]{0, -16777216}, new float[]{0.0f, 1.0f}, Shader.TileMode.CLAMP);
Matrix matrix = new Matrix();
this.clipMatrix = matrix;
this.clipGradient.setLocalMatrix(matrix);
this.clipPaint.setShader(this.clipGradient);
}
canvas.save();
this.clipMatrix.reset();
this.clipMatrix.postTranslate(0.0f, this.top ? topOffset : measuredHeight - AndroidUtilities.dp(8.0f));
this.clipGradient.setLocalMatrix(this.clipMatrix);
if (this.top) {
canvas.drawRect(0.0f, topOffset, getWidth(), topOffset + AndroidUtilities.dp(8.0f), this.clipPaint);
} else {
canvas.drawRect(0.0f, measuredHeight - AndroidUtilities.dp(8.0f), getWidth(), measuredHeight, this.clipPaint);
}
canvas.restore();
canvas.restore();
}
canvas.restore();
invalidate();
return;
}
this.background.draw(canvas);
super.dispatchDraw(canvas);
}
public int getThemedColor(int key) {
return Theme.getColor(key, this.resourcesProvider);
}
}
@SuppressLint({"ViewConstructor"})
public static class ButtonLayout extends Layout {
public Button button;
public int childrenMeasuredWidth;
public Theme.ResourcesProvider resourcesProvider;
public TimerView timerView;
public boolean wrapWidth;
public ButtonLayout(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context, resourcesProvider);
this.resourcesProvider = resourcesProvider;
}
public void setWrapWidth() {
this.wrapWidth = true;
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
this.childrenMeasuredWidth = 0;
if (this.wrapWidth) {
widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthMeasureSpec), Integer.MIN_VALUE);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (this.button == null || View.MeasureSpec.getMode(widthMeasureSpec) != Integer.MIN_VALUE) {
return;
}
setMeasuredDimension(this.childrenMeasuredWidth + this.button.getMeasuredWidth(), getMeasuredHeight());
}
@Override
public void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
Button button = this.button;
if (button != null && child != button) {
widthUsed += button.getMeasuredWidth() - AndroidUtilities.dp(12.0f);
}
super.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed);
if (child != this.button) {
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) child.getLayoutParams();
this.childrenMeasuredWidth = Math.max(this.childrenMeasuredWidth, marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + child.getMeasuredWidth());
}
}
public Button getButton() {
return this.button;
}
public void setButton(Button button) {
Button button2 = this.button;
if (button2 != null) {
removeCallback(button2);
removeView(this.button);
}
this.button = button;
if (button != null) {
addCallback(button);
addView(button, 0, LayoutHelper.createFrameRelatively(-2.0f, -2.0f, 8388629));
}
}
public void setTimer() {
TimerView timerView = new TimerView(getContext(), this.resourcesProvider);
this.timerView = timerView;
timerView.timeLeft = 5000L;
addView(this.timerView, LayoutHelper.createFrameRelatively(20.0f, 20.0f, 8388627, 21.0f, 0.0f, 21.0f, 0.0f));
}
}
public static class SimpleLayout extends ButtonLayout {
public final ImageView imageView;
public final LinkSpanDrawable.LinksTextView textView;
public SimpleLayout(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context, resourcesProvider);
int themedColor = getThemedColor(Theme.key_undo_infoColor);
ImageView imageView = new ImageView(context);
this.imageView = imageView;
imageView.setColorFilter(new PorterDuffColorFilter(themedColor, PorterDuff.Mode.MULTIPLY));
addView(imageView, LayoutHelper.createFrameRelatively(24.0f, 24.0f, 8388627, 16.0f, 12.0f, 16.0f, 12.0f));
LinkSpanDrawable.LinksTextView linksTextView = new LinkSpanDrawable.LinksTextView(context);
this.textView = linksTextView;
linksTextView.setDisablePaddingsOffsetY(true);
linksTextView.setSingleLine();
linksTextView.setTextColor(themedColor);
linksTextView.setTypeface(Typeface.SANS_SERIF);
linksTextView.setTextSize(1, 15.0f);
addView(linksTextView, LayoutHelper.createFrameRelatively(-2.0f, -2.0f, 8388627, 56.0f, 0.0f, 16.0f, 0.0f));
}
@Override
public CharSequence getAccessibilityText() {
return this.textView.getText();
}
}
@SuppressLint({"ViewConstructor"})
public static class MultiLineLayout extends ButtonLayout {
public final BackupImageView imageView;
public final TextView textView;
public MultiLineLayout(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context, resourcesProvider);
BackupImageView backupImageView = new BackupImageView(getContext());
this.imageView = backupImageView;
TextView textView = new TextView(getContext());
this.textView = textView;
addView(backupImageView, LayoutHelper.createFrameRelatively(30.0f, 30.0f, 8388627, 12.0f, 8.0f, 12.0f, 8.0f));
textView.setGravity(8388611);
textView.setPadding(0, AndroidUtilities.dp(8.0f), 0, AndroidUtilities.dp(8.0f));
textView.setTextColor(getThemedColor(Theme.key_undo_infoColor));
textView.setTextSize(1, 15.0f);
textView.setTypeface(Typeface.SANS_SERIF);
addView(textView, LayoutHelper.createFrameRelatively(-1.0f, -2.0f, 8388627, 56.0f, 0.0f, 16.0f, 0.0f));
}
@Override
public CharSequence getAccessibilityText() {
return this.textView.getText();
}
}
@SuppressLint({"ViewConstructor"})
public static class TwoLineLayout extends ButtonLayout {
public final BackupImageView imageView;
public final LinearLayout linearLayout;
public final TextView subtitleTextView;
public final TextView titleTextView;
public TwoLineLayout(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context, resourcesProvider);
int themedColor = getThemedColor(Theme.key_undo_infoColor);
BackupImageView backupImageView = new BackupImageView(context);
this.imageView = backupImageView;
addView(backupImageView, LayoutHelper.createFrameRelatively(29.0f, 29.0f, 8388627, 12.0f, 12.0f, 12.0f, 12.0f));
LinearLayout linearLayout = new LinearLayout(context);
this.linearLayout = linearLayout;
linearLayout.setOrientation(1);
addView(linearLayout, LayoutHelper.createFrameRelatively(-2.0f, -2.0f, 8388627, 54.0f, 8.0f, 12.0f, 8.0f));
TextView textView = new TextView(context);
this.titleTextView = textView;
textView.setSingleLine();
textView.setTextColor(themedColor);
textView.setTextSize(1, 14.0f);
textView.setTypeface(AndroidUtilities.bold());
linearLayout.addView(textView);
TextView textView2 = new TextView(context);
this.subtitleTextView = textView2;
textView2.setMaxLines(2);
textView2.setTextColor(themedColor);
textView2.setLinkTextColor(getThemedColor(Theme.key_undo_cancelColor));
textView2.setMovementMethod(new LinkMovementMethod());
textView2.setTypeface(Typeface.SANS_SERIF);
textView2.setTextSize(1, 13.0f);
linearLayout.addView(textView2);
}
@Override
public CharSequence getAccessibilityText() {
return ((Object) this.titleTextView.getText()) + ".\n" + ((Object) this.subtitleTextView.getText());
}
}
public static class TwoLineLottieLayout extends ButtonLayout {
public final RLottieImageView imageView;
public final LinearLayout linearLayout;
public final LinkSpanDrawable.LinksTextView subtitleTextView;
public final int textColor;
public final LinkSpanDrawable.LinksTextView titleTextView;
public TwoLineLottieLayout(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context, resourcesProvider);
int i = Theme.key_undo_infoColor;
this.textColor = getThemedColor(i);
setBackground(getThemedColor(Theme.key_undo_background));
RLottieImageView rLottieImageView = new RLottieImageView(context);
this.imageView = rLottieImageView;
rLottieImageView.setScaleType(ImageView.ScaleType.CENTER);
addView(rLottieImageView, LayoutHelper.createFrameRelatively(56.0f, 48.0f, 8388627));
int themedColor = getThemedColor(i);
int themedColor2 = getThemedColor(Theme.key_undo_cancelColor);
LinearLayout linearLayout = new LinearLayout(context);
this.linearLayout = linearLayout;
linearLayout.setOrientation(1);
addView(linearLayout, LayoutHelper.createFrameRelatively(-2.0f, -2.0f, 8388627, 52.0f, 8.0f, 8.0f, 8.0f));
LinkSpanDrawable.LinksTextView linksTextView = new LinkSpanDrawable.LinksTextView(context);
this.titleTextView = linksTextView;
linksTextView.setPadding(AndroidUtilities.dp(4.0f), 0, AndroidUtilities.dp(4.0f), 0);
linksTextView.setSingleLine();
linksTextView.setTextColor(themedColor);
linksTextView.setTextSize(1, 14.0f);
linksTextView.setTypeface(AndroidUtilities.bold());
linearLayout.addView(linksTextView);
LinkSpanDrawable.LinksTextView linksTextView2 = new LinkSpanDrawable.LinksTextView(context);
this.subtitleTextView = linksTextView2;
linksTextView2.setPadding(AndroidUtilities.dp(4.0f), 0, AndroidUtilities.dp(4.0f), 0);
linksTextView2.setTextColor(themedColor);
linksTextView2.setLinkTextColor(themedColor2);
linksTextView2.setTypeface(Typeface.SANS_SERIF);
linksTextView2.setTextSize(1, 13.0f);
linearLayout.addView(linksTextView2);
}
@Override
public void onShow() {
super.onShow();
this.imageView.playAnimation();
}
public void setAnimation(int resId, String... layers) {
setAnimation(resId, 32, 32, layers);
}
public void setAnimation(int resId, int w, int h, String... layers) {
this.imageView.setAnimation(resId, w, h);
for (String str : layers) {
this.imageView.setLayerColor(str + ".**", this.textColor);
}
}
@Override
public CharSequence getAccessibilityText() {
return ((Object) this.titleTextView.getText()) + ".\n" + ((Object) this.subtitleTextView.getText());
}
}
public static class LottieLayoutWithReactions extends LottieLayout implements NotificationCenter.NotificationCenterDelegate {
public Bulletin bulletin;
public final BaseFragment fragment;
public final int messagesCount;
public SparseLongArray newMessagesByIds;
public ReactionsContainerLayout reactionsContainerLayout;
public LottieLayoutWithReactions(BaseFragment fragment, int messagesCount) {
super(fragment.getContext(), fragment.getResourceProvider());
this.fragment = fragment;
this.messagesCount = messagesCount;
init();
}
public void setBulletin(Bulletin b) {
this.bulletin = b;
}
public void init() {
this.textView.setLayoutParams(LayoutHelper.createFrameRelatively(-2.0f, -2.0f, 8388659, 56.0f, 6.0f, 8.0f, 0.0f));
this.imageView.setLayoutParams(LayoutHelper.createFrameRelatively(56.0f, 48.0f, 8388659));
AnonymousClass1 anonymousClass1 = new AnonymousClass1(3, this.fragment, getContext(), this.fragment.getCurrentAccount(), this.fragment.getResourceProvider());
this.reactionsContainerLayout = anonymousClass1;
anonymousClass1.setPadding(AndroidUtilities.dp(4.0f), AndroidUtilities.dp(24.0f), AndroidUtilities.dp(4.0f), AndroidUtilities.dp(0.0f));
this.reactionsContainerLayout.setDelegate(new AnonymousClass2());
this.reactionsContainerLayout.setTop(true);
this.reactionsContainerLayout.setClipChildren(false);
this.reactionsContainerLayout.setClipToPadding(false);
this.reactionsContainerLayout.setVisibility(0);
this.reactionsContainerLayout.setBubbleOffset(-AndroidUtilities.dp(80.0f));
this.reactionsContainerLayout.setHint(LocaleController.getString(R.string.SavedTagReactionsHint));
addView(this.reactionsContainerLayout, LayoutHelper.createFrame(-2, 92.5f, 1, 0.0f, 36.0f, 0.0f, 0.0f));
this.reactionsContainerLayout.setMessage(null, null, true);
}
public class AnonymousClass1 extends ReactionsContainerLayout {
public AnonymousClass1(int type, BaseFragment fragment, Context context, int currentAccount, Theme.ResourcesProvider resourcesProvider) {
super(type, fragment, context, currentAccount, resourcesProvider);
}
@Override
public void onShownCustomEmojiReactionDialog() {
Bulletin visibleBulletin = Bulletin.getVisibleBulletin();
if (visibleBulletin != null) {
visibleBulletin.setCanHide(false);
}
LottieLayoutWithReactions.this.reactionsContainerLayout.getReactionsWindow().windowView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
Bulletin.LottieLayoutWithReactions.AnonymousClass1.this.lambda$onShownCustomEmojiReactionDialog$0(view);
}
});
}
public void lambda$onShownCustomEmojiReactionDialog$0(View view) {
LottieLayoutWithReactions.this.hideReactionsDialog();
Bulletin.hideVisible();
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == 0) {
if (LottieLayoutWithReactions.this.bulletin != null) {
LottieLayoutWithReactions.this.bulletin.setCanHide(false);
}
} else if (ev.getAction() == 1 && LottieLayoutWithReactions.this.bulletin != null) {
LottieLayoutWithReactions.this.bulletin.setCanHide(true);
}
return super.dispatchTouchEvent(ev);
}
}
public class AnonymousClass2 implements ReactionsContainerLayout.ReactionsContainerDelegate {
@Override
public boolean drawBackground() {
return ReactionsContainerLayout.ReactionsContainerDelegate.CC.$default$drawBackground(this);
}
@Override
public void drawRoundRect(Canvas canvas, RectF rectF, float f, float f2, float f3, int i, boolean z) {
ReactionsContainerLayout.ReactionsContainerDelegate.CC.$default$drawRoundRect(this, canvas, rectF, f, f2, f3, i, z);
}
@Override
public boolean needEnterText() {
return ReactionsContainerLayout.ReactionsContainerDelegate.CC.$default$needEnterText(this);
}
@Override
public void onEmojiWindowDismissed() {
ReactionsContainerLayout.ReactionsContainerDelegate.CC.$default$onEmojiWindowDismissed(this);
}
public AnonymousClass2() {
}
@Override
public void onReactionClicked(View view, ReactionsLayoutInBubble.VisibleReaction visibleReaction, boolean longpress, boolean addToRecent) {
if (LottieLayoutWithReactions.this.newMessagesByIds == null) {
return;
}
boolean z = (LottieLayoutWithReactions.this.fragment instanceof ChatActivity) && LottieLayoutWithReactions.this.fragment.getDialogId() == UserConfig.getInstance(LottieLayoutWithReactions.this.fragment.getCurrentAccount()).getClientUserId();
int i = 0;
for (int i2 = 0; i2 < LottieLayoutWithReactions.this.newMessagesByIds.size(); i2++) {
int keyAt = LottieLayoutWithReactions.this.newMessagesByIds.keyAt(i2);
TLRPC.Message message = new TLRPC.Message();
message.dialog_id = LottieLayoutWithReactions.this.fragment.getUserConfig().getClientUserId();
message.id = keyAt;
MessageObject messageObject = new MessageObject(LottieLayoutWithReactions.this.fragment.getCurrentAccount(), message, false, false);
ArrayList arrayList = new ArrayList();
arrayList.add(visibleReaction);
LottieLayoutWithReactions.this.fragment.getSendMessagesHelper().sendReaction(messageObject, arrayList, visibleReaction, false, false, LottieLayoutWithReactions.this.fragment, (Runnable) null);
i = message.id;
}
LottieLayoutWithReactions.this.hideReactionsDialog();
Bulletin.hideVisible();
showTaggedReactionToast(visibleReaction, LottieLayoutWithReactions.this.fragment.getCurrentAccount(), i, !z);
}
public final void showTaggedReactionToast(final ReactionsLayoutInBubble.VisibleReaction visibleReaction, final int currentAccount, final int messageId, final boolean addViewButton) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
Bulletin.LottieLayoutWithReactions.AnonymousClass2.this.lambda$showTaggedReactionToast$1(visibleReaction, addViewButton, currentAccount, messageId);
}
}, 300L);
}
public void lambda$showTaggedReactionToast$1(ReactionsLayoutInBubble.VisibleReaction visibleReaction, boolean z, final int i, final int i2) {
TLRPC.Document findDocument;
final BaseFragment lastFragment = LaunchActivity.getLastFragment();
long j = visibleReaction.documentId;
if (j == 0) {
TLRPC.TL_availableReaction tL_availableReaction = MediaDataController.getInstance(UserConfig.selectedAccount).getReactionsMap().get(visibleReaction.emojicon);
if (tL_availableReaction == null) {
return;
} else {
findDocument = tL_availableReaction.activate_animation;
}
} else {
findDocument = AnimatedEmojiDrawable.findDocument(UserConfig.selectedAccount, j);
}
if (findDocument == null || lastFragment == null) {
return;
}
BulletinFactory.of(lastFragment).createMessagesTaggedBulletin(LottieLayoutWithReactions.this.messagesCount, findDocument, z ? new Runnable() {
@Override
public final void run() {
Bulletin.LottieLayoutWithReactions.AnonymousClass2.lambda$showTaggedReactionToast$0(i, i2, lastFragment);
}
} : null).show(true);
}
public static void lambda$showTaggedReactionToast$0(int i, int i2, BaseFragment baseFragment) {
Bundle bundle = new Bundle();
bundle.putLong("user_id", UserConfig.getInstance(i).getClientUserId());
bundle.putInt("message_id", i2);
baseFragment.presentFragment(new ChatActivity(bundle));
}
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
NotificationCenter.getInstance(UserConfig.selectedAccount).addObserver(this, NotificationCenter.savedMessagesForwarded);
}
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
NotificationCenter.getInstance(UserConfig.selectedAccount).removeObserver(this, NotificationCenter.savedMessagesForwarded);
}
public void hideReactionsDialog() {
if (this.reactionsContainerLayout.getReactionsWindow() != null) {
this.reactionsContainerLayout.dismissWindow();
if (this.reactionsContainerLayout.getReactionsWindow().containerView != null) {
this.reactionsContainerLayout.getReactionsWindow().containerView.animate().alpha(0.0f).setDuration(180L).start();
}
}
}
@Override
public int getMeasuredBackgroundHeight() {
return this.textView.getMeasuredHeight() + AndroidUtilities.dp(30.0f);
}
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.savedMessagesForwarded) {
this.newMessagesByIds = (SparseLongArray) args[0];
}
}
}
public static class LottieLayout extends ButtonLayout {
public RLottieImageView imageView;
public int textColor;
public TextView textView;
public LottieLayout(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context, resourcesProvider);
RLottieImageView rLottieImageView = new RLottieImageView(context);
this.imageView = rLottieImageView;
rLottieImageView.setScaleType(ImageView.ScaleType.CENTER);
addView(this.imageView, LayoutHelper.createFrameRelatively(56.0f, 48.0f, 8388627));
LinkSpanDrawable.LinksTextView linksTextView = new LinkSpanDrawable.LinksTextView(this, context) {
{
setDisablePaddingsOffset(true);
}
@Override
public void setText(CharSequence text, TextView.BufferType type) {
super.setText(Emoji.replaceEmoji(text, getPaint().getFontMetricsInt(), AndroidUtilities.dp(13.0f), false), type);
}
};
this.textView = linksTextView;
NotificationCenter.listenEmojiLoading(linksTextView);
this.textView.setSingleLine();
this.textView.setTypeface(Typeface.SANS_SERIF);
this.textView.setTextSize(1, 15.0f);
this.textView.setEllipsize(TextUtils.TruncateAt.END);
this.textView.setPadding(0, AndroidUtilities.dp(8.0f), 0, AndroidUtilities.dp(8.0f));
addView(this.textView, LayoutHelper.createFrameRelatively(-2.0f, -2.0f, 8388627, 56.0f, 0.0f, 8.0f, 0.0f));
this.textView.setLinkTextColor(getThemedColor(Theme.key_undo_cancelColor));
setTextColor(getThemedColor(Theme.key_undo_infoColor));
setBackground(getThemedColor(Theme.key_undo_background));
}
public LottieLayout(Context context, Theme.ResourcesProvider resourcesProvider, int backgroundColor, int textColor) {
this(context, resourcesProvider);
setBackground(backgroundColor);
setTextColor(textColor);
}
public void setTextColor(int textColor) {
this.textColor = textColor;
this.textView.setTextColor(textColor);
}
@Override
public void onShow() {
super.onShow();
this.imageView.playAnimation();
}
public void setAnimation(int resId, String... layers) {
setAnimation(resId, 32, 32, layers);
}
public void setAnimation(int resId, int w, int h, String... layers) {
this.imageView.setAnimation(resId, w, h);
for (String str : layers) {
this.imageView.setLayerColor(str + ".**", this.textColor);
}
}
public void setAnimation(TLRPC.Document document, int w, int h, String... layers) {
this.imageView.setAutoRepeat(true);
this.imageView.setAnimation(document, w, h);
for (String str : layers) {
this.imageView.setLayerColor(str + ".**", this.textColor);
}
}
public void setIconPaddingBottom(int paddingBottom) {
this.imageView.setLayoutParams(LayoutHelper.createFrameRelatively(56.0f, 48 - paddingBottom, 8388627, 0.0f, 0.0f, 0.0f, paddingBottom));
}
@Override
public CharSequence getAccessibilityText() {
return this.textView.getText();
}
}
public static class LoadingLottieLayout extends LottieLayout implements LoadingLayout {
public LinkSpanDrawable.LinksTextView textLoadingView;
public LoadingLottieLayout(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context, resourcesProvider);
LinkSpanDrawable.LinksTextView linksTextView = new LinkSpanDrawable.LinksTextView(context);
this.textLoadingView = linksTextView;
linksTextView.setDisablePaddingsOffset(true);
this.textLoadingView.setSingleLine();
this.textLoadingView.setTypeface(Typeface.SANS_SERIF);
this.textLoadingView.setTextSize(1, 15.0f);
this.textLoadingView.setEllipsize(TextUtils.TruncateAt.END);
this.textLoadingView.setPadding(0, AndroidUtilities.dp(8.0f), 0, AndroidUtilities.dp(8.0f));
this.textView.setVisibility(8);
addView(this.textLoadingView, LayoutHelper.createFrameRelatively(-2.0f, -2.0f, 8388627, 56.0f, 0.0f, 8.0f, 0.0f));
setTextColor(getThemedColor(Theme.key_undo_infoColor));
}
@Override
public void setTextColor(int textColor) {
super.setTextColor(textColor);
LinkSpanDrawable.LinksTextView linksTextView = this.textLoadingView;
if (linksTextView != null) {
linksTextView.setTextColor(textColor);
}
}
@Override
public void onTextLoaded(CharSequence text) {
this.textView.setText(text);
AndroidUtilities.updateViewShow(this.textLoadingView, false, false, true);
AndroidUtilities.updateViewShow(this.textView, true, false, true);
}
}
public static class UsersLayout extends ButtonLayout {
public AvatarsImageView avatarsImageView;
public LinearLayout linearLayout;
public TextView subtitleView;
public TextView textView;
public UsersLayout(Context context, boolean subtitle, Theme.ResourcesProvider resourcesProvider) {
super(context, resourcesProvider);
AvatarsImageView avatarsImageView = new AvatarsImageView(context, false);
this.avatarsImageView = avatarsImageView;
avatarsImageView.setStyle(11);
this.avatarsImageView.setAvatarsTextSize(AndroidUtilities.dp(18.0f));
addView(this.avatarsImageView, LayoutHelper.createFrameRelatively(56.0f, 48.0f, 8388627, 12.0f, 0.0f, 0.0f, 0.0f));
if (!subtitle) {
LinkSpanDrawable.LinksTextView linksTextView = new LinkSpanDrawable.LinksTextView(this, context) {
@Override
public void setText(CharSequence text, TextView.BufferType type) {
super.setText(Emoji.replaceEmoji(text, getPaint().getFontMetricsInt(), AndroidUtilities.dp(13.0f), false), type);
}
};
this.textView = linksTextView;
NotificationCenter.listenEmojiLoading(linksTextView);
this.textView.setTypeface(Typeface.SANS_SERIF);
this.textView.setTextSize(1, 15.0f);
this.textView.setEllipsize(TextUtils.TruncateAt.END);
this.textView.setPadding(0, AndroidUtilities.dp(8.0f), 0, AndroidUtilities.dp(8.0f));
this.textView.setGravity(LocaleController.isRTL ? 5 : 3);
addView(this.textView, LayoutHelper.createFrameRelatively(-2.0f, -2.0f, 8388627, 70.0f, 0.0f, 12.0f, 0.0f));
} else {
LinearLayout linearLayout = new LinearLayout(getContext());
this.linearLayout = linearLayout;
linearLayout.setOrientation(1);
addView(this.linearLayout, LayoutHelper.createFrameRelatively(-1.0f, -2.0f, 8388627, 76.0f, 0.0f, 12.0f, 0.0f));
LinkSpanDrawable.LinksTextView linksTextView2 = new LinkSpanDrawable.LinksTextView(this, context) {
@Override
public void setText(CharSequence text, TextView.BufferType type) {
super.setText(Emoji.replaceEmoji(text, getPaint().getFontMetricsInt(), AndroidUtilities.dp(13.0f), false), type);
}
};
this.textView = linksTextView2;
NotificationCenter.listenEmojiLoading(linksTextView2);
this.textView.setTypeface(Typeface.SANS_SERIF);
this.textView.setTextSize(1, 14.0f);
this.textView.setEllipsize(TextUtils.TruncateAt.END);
this.textView.setMaxLines(1);
this.linearLayout.addView(this.textView);
LinkSpanDrawable.LinksTextView linksTextView3 = new LinkSpanDrawable.LinksTextView(context);
this.subtitleView = linksTextView3;
linksTextView3.setTypeface(Typeface.SANS_SERIF);
this.subtitleView.setTextSize(1, 13.0f);
this.subtitleView.setEllipsize(TextUtils.TruncateAt.END);
this.subtitleView.setMaxLines(1);
this.subtitleView.setLinkTextColor(getThemedColor(Theme.key_undo_cancelColor));
this.linearLayout.addView(this.subtitleView, LayoutHelper.createLinear(-2, -2, 0, 0, 0, 0, 0));
}
this.textView.setLinkTextColor(getThemedColor(Theme.key_undo_cancelColor));
setTextColor(getThemedColor(Theme.key_undo_infoColor));
setBackground(getThemedColor(Theme.key_undo_background));
}
public void setTextColor(int textColor) {
this.textView.setTextColor(textColor);
TextView textView = this.subtitleView;
if (textView != null) {
textView.setTextColor(textColor);
}
}
@Override
public void onShow() {
super.onShow();
}
@Override
public CharSequence getAccessibilityText() {
return this.textView.getText();
}
}
@SuppressLint({"ViewConstructor"})
public static abstract class Button extends FrameLayout implements Layout.Callback {
@Override
public void onEnterTransitionEnd(Layout layout) {
}
@Override
public void onEnterTransitionStart(Layout layout) {
}
@Override
public void onExitTransitionEnd(Layout layout) {
}
@Override
public void onExitTransitionStart(Layout layout) {
}
@Override
public void onHide(Layout layout) {
}
@Override
public void onShow(Layout layout) {
}
public Button(Context context) {
super(context);
}
}
@SuppressLint({"ViewConstructor"})
public static final class UndoButton extends Button {
public Bulletin bulletin;
public Runnable delayedAction;
public boolean isUndone;
public final Theme.ResourcesProvider resourcesProvider;
public Runnable undoAction;
public TextView undoTextView;
public UndoButton(Context context, boolean text) {
this(context, text, null);
}
public UndoButton(Context context, boolean text, Theme.ResourcesProvider resourcesProvider) {
this(context, text, !text, resourcesProvider);
}
public UndoButton(Context context, boolean text, boolean icon, Theme.ResourcesProvider resourcesProvider) {
super(context);
this.resourcesProvider = resourcesProvider;
int themedColor = getThemedColor(Theme.key_undo_cancelColor);
if (text) {
TextView textView = new TextView(context);
this.undoTextView = textView;
textView.setBackground(Theme.createSelectorDrawable((themedColor & 16777215) | 419430400, 7));
this.undoTextView.setTextSize(1, 14.0f);
this.undoTextView.setTypeface(AndroidUtilities.bold());
this.undoTextView.setTextColor(themedColor);
this.undoTextView.setText(LocaleController.getString("Undo", R.string.Undo));
this.undoTextView.setGravity(16);
ViewHelper.setPaddingRelative(this.undoTextView, icon ? 34.0f : 12.0f, 8.0f, 12.0f, 8.0f);
addView(this.undoTextView, LayoutHelper.createFrameRelatively(-2.0f, -2.0f, 16, 8.0f, 0.0f, 8.0f, 0.0f));
}
if (icon) {
ImageView imageView = new ImageView(getContext());
imageView.setImageResource(R.drawable.chats_undo);
imageView.setColorFilter(new PorterDuffColorFilter(themedColor, PorterDuff.Mode.MULTIPLY));
if (!text) {
imageView.setBackground(Theme.createSelectorDrawable((themedColor & 16777215) | 419430400));
}
ViewHelper.setPaddingRelative(imageView, 0.0f, 12.0f, 0.0f, 12.0f);
addView(imageView, LayoutHelper.createFrameRelatively(56.0f, 48.0f, 16));
}
setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
Bulletin.UndoButton.this.lambda$new$0(view);
}
});
}
public void lambda$new$0(View view) {
undo();
}
public UndoButton setText(CharSequence text) {
TextView textView = this.undoTextView;
if (textView != null) {
textView.setText(text);
}
return this;
}
public void undo() {
if (this.bulletin != null) {
this.isUndone = true;
Runnable runnable = this.undoAction;
if (runnable != null) {
runnable.run();
}
Bulletin bulletin = this.bulletin;
if (bulletin != null) {
bulletin.hide();
}
}
}
@Override
public void onAttach(Layout layout, Bulletin bulletin) {
this.bulletin = bulletin;
}
@Override
public void onDetach(Layout layout) {
this.bulletin = null;
Runnable runnable = this.delayedAction;
if (runnable == null || this.isUndone) {
return;
}
runnable.run();
}
public UndoButton setUndoAction(Runnable undoAction) {
this.undoAction = undoAction;
return this;
}
public UndoButton setDelayedAction(Runnable delayedAction) {
this.delayedAction = delayedAction;
return this;
}
public int getThemedColor(int key) {
Theme.ResourcesProvider resourcesProvider = this.resourcesProvider;
if (resourcesProvider != null) {
return resourcesProvider.getColor(key);
}
return Theme.getColor(key);
}
}
public void onLoaded(CharSequence text) {
this.loaded = true;
ViewParent viewParent = this.layout;
if (viewParent instanceof LoadingLayout) {
((LoadingLayout) viewParent).onTextLoaded(text);
}
setCanHide(true);
}
public static class EmptyBulletin extends Bulletin {
@Override
public Bulletin show() {
return this;
}
public EmptyBulletin() {
super();
}
}
public static class TimerView extends View {
public long lastUpdateTime;
public int prevSeconds;
public final Paint progressPaint;
public RectF rect;
public TextPaint textPaint;
public int textWidth;
public int textWidthOut;
public StaticLayout timeLayout;
public StaticLayout timeLayoutOut;
public long timeLeft;
public String timeLeftString;
public float timeReplaceProgress;
public TimerView(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context);
this.timeReplaceProgress = 1.0f;
this.rect = new RectF();
TextPaint textPaint = new TextPaint(1);
this.textPaint = textPaint;
textPaint.setTextSize(AndroidUtilities.dp(12.0f));
this.textPaint.setTypeface(AndroidUtilities.bold());
TextPaint textPaint2 = this.textPaint;
int i = Theme.key_undo_infoColor;
textPaint2.setColor(Theme.getColor(i, resourcesProvider));
Paint paint = new Paint(1);
this.progressPaint = paint;
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(AndroidUtilities.dp(2.0f));
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setColor(Theme.getColor(i, resourcesProvider));
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
int ceil = this.timeLeft > 0 ? (int) Math.ceil(r0 / 1000.0f) : 0;
this.rect.set(AndroidUtilities.dp(1.0f), AndroidUtilities.dp(1.0f), getMeasuredWidth() - AndroidUtilities.dp(1.0f), getMeasuredHeight() - AndroidUtilities.dp(1.0f));
if (this.prevSeconds != ceil) {
this.prevSeconds = ceil;
this.timeLeftString = String.valueOf(Math.max(0, ceil));
StaticLayout staticLayout = this.timeLayout;
if (staticLayout != null) {
this.timeLayoutOut = staticLayout;
this.timeReplaceProgress = 0.0f;
this.textWidthOut = this.textWidth;
}
this.textWidth = (int) Math.ceil(this.textPaint.measureText(r0));
this.timeLayout = new StaticLayout(this.timeLeftString, this.textPaint, Integer.MAX_VALUE, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
float f = this.timeReplaceProgress;
if (f < 1.0f) {
float f2 = f + 0.10666667f;
this.timeReplaceProgress = f2;
if (f2 > 1.0f) {
this.timeReplaceProgress = 1.0f;
} else {
invalidate();
}
}
int alpha = this.textPaint.getAlpha();
if (this.timeLayoutOut != null) {
float f3 = this.timeReplaceProgress;
if (f3 < 1.0f) {
this.textPaint.setAlpha((int) (alpha * (1.0f - f3)));
canvas.save();
canvas.translate(this.rect.centerX() - (this.textWidthOut / 2.0f), (this.rect.centerY() - (this.timeLayoutOut.getHeight() / 2.0f)) + (AndroidUtilities.dp(10.0f) * this.timeReplaceProgress));
this.timeLayoutOut.draw(canvas);
this.textPaint.setAlpha(alpha);
canvas.restore();
}
}
if (this.timeLayout != null) {
float f4 = this.timeReplaceProgress;
if (f4 != 1.0f) {
this.textPaint.setAlpha((int) (alpha * f4));
}
canvas.save();
canvas.translate(this.rect.centerX() - (this.textWidth / 2.0f), (this.rect.centerY() - (this.timeLayout.getHeight() / 2.0f)) - (AndroidUtilities.dp(10.0f) * (1.0f - this.timeReplaceProgress)));
this.timeLayout.draw(canvas);
if (this.timeReplaceProgress != 1.0f) {
this.textPaint.setAlpha(alpha);
}
canvas.restore();
}
canvas.drawArc(this.rect, -90.0f, (Math.max(0L, this.timeLeft) / 5000.0f) * (-360.0f), false, this.progressPaint);
if (this.lastUpdateTime != 0) {
long currentTimeMillis = System.currentTimeMillis();
this.timeLeft -= currentTimeMillis - this.lastUpdateTime;
this.lastUpdateTime = currentTimeMillis;
} else {
this.lastUpdateTime = System.currentTimeMillis();
}
invalidate();
}
}
public static class BulletinWindow extends Dialog {
public final BulletinWindowLayout container;
public WindowManager.LayoutParams params;
public static BulletinWindowLayout make(Context context, Delegate delegate) {
return new BulletinWindow(context, delegate).container;
}
public static BulletinWindowLayout make(Context context) {
return new BulletinWindow(context, null).container;
}
public BulletinWindow(Context context, final Delegate delegate) {
super(context);
BulletinWindowLayout bulletinWindowLayout = new BulletinWindowLayout(context);
this.container = bulletinWindowLayout;
setContentView(bulletinWindowLayout, new ViewGroup.LayoutParams(-1, -1));
int i = Build.VERSION.SDK_INT;
boolean z = true;
if (i >= 21) {
bulletinWindowLayout.setFitsSystemWindows(true);
bulletinWindowLayout.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
public final WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
WindowInsets lambda$new$0;
lambda$new$0 = Bulletin.BulletinWindow.this.lambda$new$0(view, windowInsets);
return lambda$new$0;
}
});
if (i >= 30) {
bulletinWindowLayout.setSystemUiVisibility(1792);
} else {
bulletinWindowLayout.setSystemUiVisibility(1280);
}
}
Bulletin.addDelegate(bulletinWindowLayout, new Delegate(this) {
@Override
public boolean allowLayoutChanges() {
return Delegate.CC.$default$allowLayoutChanges(this);
}
@Override
public boolean bottomOffsetAnimated() {
return Delegate.CC.$default$bottomOffsetAnimated(this);
}
@Override
public void onBottomOffsetChange(float f) {
Delegate.CC.$default$onBottomOffsetChange(this, f);
}
@Override
public void onHide(Bulletin bulletin) {
Delegate.CC.$default$onHide(this, bulletin);
}
@Override
public void onShow(Bulletin bulletin) {
Delegate.CC.$default$onShow(this, bulletin);
}
@Override
public int getBottomOffset(int tag) {
Delegate delegate2 = delegate;
if (delegate2 == null) {
return 0;
}
return delegate2.getBottomOffset(tag);
}
@Override
public int getTopOffset(int tag) {
Delegate delegate2 = delegate;
return delegate2 == null ? AndroidUtilities.statusBarHeight : delegate2.getTopOffset(tag);
}
@Override
public boolean clipWithGradient(int tag) {
Delegate delegate2 = delegate;
return delegate2 != null && delegate2.clipWithGradient(tag);
}
});
try {
Window window = getWindow();
window.setWindowAnimations(R.style.DialogNoAnimation);
window.setBackgroundDrawable(null);
WindowManager.LayoutParams attributes = window.getAttributes();
this.params = attributes;
attributes.width = -1;
attributes.height = -1;
attributes.gravity = 51;
attributes.dimAmount = 0.0f;
int i2 = attributes.flags & (-3);
attributes.flags = i2;
int i3 = i2 | 8;
attributes.flags = i3;
if (i >= 19) {
attributes.flags = i3 | 201326592;
}
int i4 = attributes.flags | 16;
attributes.flags = i4;
if (i >= 21) {
attributes.flags = i4 | (-2147417856);
}
attributes.flags &= -1025;
if (i >= 28) {
attributes.layoutInDisplayCutoutMode = 1;
}
window.setAttributes(attributes);
if (AndroidUtilities.computePerceivedBrightness(Theme.getColor(Theme.key_windowBackgroundGray)) <= 0.721f) {
z = false;
}
AndroidUtilities.setLightNavigationBar(window, z);
} catch (Exception unused) {
}
}
public WindowInsets lambda$new$0(View view, WindowInsets windowInsets) {
applyInsets(windowInsets);
view.requestLayout();
if (Build.VERSION.SDK_INT >= 30) {
return WindowInsets.CONSUMED;
}
return windowInsets.consumeSystemWindowInsets();
}
@Override
public void show() {
if (AndroidUtilities.isSafeToShow(getContext())) {
super.show();
}
}
public final void applyInsets(WindowInsets insets) {
BulletinWindowLayout bulletinWindowLayout = this.container;
if (bulletinWindowLayout != null) {
bulletinWindowLayout.setPadding(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
}
}
public class BulletinWindowLayout extends FrameLayout {
public BulletinWindowLayout(Context context) {
super(context);
}
@Override
public void addView(View child) {
super.addView(child);
BulletinWindow.this.show();
}
@Override
public void removeView(View child) {
super.removeView(child);
try {
BulletinWindow.this.dismiss();
} catch (Exception unused) {
}
Bulletin.removeDelegate(BulletinWindow.this.container);
}
public void setTouchable(boolean touchable) {
if (BulletinWindow.this.params == null) {
return;
}
if (!touchable) {
BulletinWindow.this.params.flags |= 16;
} else {
BulletinWindow.this.params.flags &= -17;
}
BulletinWindow.this.getWindow().setAttributes(BulletinWindow.this.params);
}
public WindowManager.LayoutParams getLayout() {
return BulletinWindow.this.params;
}
public void updateLayout() {
BulletinWindow.this.getWindow().setAttributes(BulletinWindow.this.params);
}
}
}
}