正在查看: Plus 12 v10.13.1.1 应用的 ThemePreviewActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Plus 12 v10.13.1.1 应用的 ThemePreviewActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.telegram.ui;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.BlendMode;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.util.Property;
import android.util.SparseIntArray;
import android.util.StateSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Scroller;
import android.widget.TextView;
import androidx.collection.LongSparseArray;
import androidx.core.graphics.ColorUtils;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import com.google.android.exoplayer2.util.Consumer;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ChannelBoostsController;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.DownloadController;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.ImageReceiver;
import org.telegram.messenger.LiteMode;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.PlusUtils;
import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.SvgHelper;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.UserObject;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.VideoEditedInfo;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_stories;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.INavigationLayout;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.ChatActionCell;
import org.telegram.ui.Cells.ChatMessageCell;
import org.telegram.ui.Cells.DialogCell;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.LoadingCell;
import org.telegram.ui.Cells.PatternCell;
import org.telegram.ui.Cells.TextSelectionHelper;
import org.telegram.ui.ChatActivity;
import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.AnimatedEmojiSpan;
import org.telegram.ui.Components.AnimatedFloat;
import org.telegram.ui.Components.BackgroundGradientDrawable;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.CircularProgressDrawable;
import org.telegram.ui.Components.ColorPicker;
import org.telegram.ui.Components.ColoredImageSpan;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.Easings;
import org.telegram.ui.Components.GestureDetector2;
import org.telegram.ui.Components.HintView;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.MotionBackgroundDrawable;
import org.telegram.ui.Components.Premium.LimitReachedBottomSheet;
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.SeekBarView;
import org.telegram.ui.Components.ShareAlert;
import org.telegram.ui.Components.Text;
import org.telegram.ui.Components.UndoView;
import org.telegram.ui.Components.WallpaperCheckBoxView;
import org.telegram.ui.Components.WallpaperParallaxEffect;
import org.telegram.ui.PhotoViewer;
import org.telegram.ui.Stories.recorder.PreviewView;
import org.telegram.ui.Stories.recorder.SliderView;
import org.telegram.ui.ThemePreviewActivity;
import org.telegram.ui.WallpapersListActivity;
public class ThemePreviewActivity extends BaseFragment implements DownloadController.FileDownloadProgressListener, NotificationCenter.NotificationCenterDelegate {
public int TAG;
public Theme.ThemeAccent accent;
public ActionBar actionBar2;
public HintView animationHint;
public BlurButton applyButton1;
public BlurButton applyButton2;
public Runnable applyColorAction;
public boolean applyColorScheduled;
public Theme.ThemeInfo applyingTheme;
public FrameLayout backgroundButtonsContainer;
public WallpaperCheckBoxView[] backgroundCheckBoxView;
public int backgroundColor;
public int backgroundGradientColor1;
public int backgroundGradientColor2;
public int backgroundGradientColor3;
public BackgroundGradientDrawable.Disposable backgroundGradientDisposable;
public BackgroundView backgroundImage;
public BackgroundView[] backgroundImages;
public ImageView backgroundPlayAnimationImageView;
public FrameLayout backgroundPlayAnimationView;
public AnimatorSet backgroundPlayViewAnimator;
public int backgroundRotation;
public int backupAccentColor;
public int backupAccentColor2;
public long backupBackgroundGradientOverrideColor1;
public long backupBackgroundGradientOverrideColor2;
public long backupBackgroundGradientOverrideColor3;
public long backupBackgroundOverrideColor;
public int backupBackgroundRotation;
public float backupIntensity;
public int backupMyMessagesAccentColor;
public boolean backupMyMessagesAnimated;
public int backupMyMessagesGradientAccentColor1;
public int backupMyMessagesGradientAccentColor2;
public int backupMyMessagesGradientAccentColor3;
public String backupSlug;
public final PorterDuff.Mode blendMode;
public Bitmap blurredBitmap;
public BitmapDrawable blurredDrawable;
public TL_stories.TL_premium_boostsStatus boostsStatus;
public FrameLayout bottomOverlayChat;
public TextView cancelButton;
public View changeDayNightView;
public ValueAnimator changeDayNightViewAnimator;
public ValueAnimator changeDayNightViewAnimator2;
public float changeDayNightViewProgress;
public int checkColor;
public boolean checkedBoostsLevel;
public boolean checkingBoostsLevel;
public ColorPicker colorPicker;
public int colorType;
public float croppedWidth;
public float currentIntensity;
public float currentScrollOffset;
public Object currentWallpaper;
public Bitmap currentWallpaperBitmap;
public ActionBarMenuItem dayNightItem;
public float defaultScrollOffset;
public WallpaperActivityDelegate delegate;
public boolean deleteOnCancel;
public long dialogId;
public DialogsAdapter dialogsAdapter;
public float dimAmount;
public SliderView dimmingSlider;
public FrameLayout dimmingSliderContainer;
public TextView doneButton;
public View dotsContainer;
public TextView dropDown;
public ActionBarMenuItem dropDownContainer;
public boolean editingTheme;
public ImageView floatingButton;
public FrameLayout frameLayout;
public GestureDetector2 gestureDetector2;
public boolean hasScrollingBackground;
public String imageFilter;
public HeaderCell intensityCell;
public SeekBarView intensitySeekBar;
public boolean isBlurred;
public boolean isMotion;
public WeakReference<Drawable> lastDrawableToBlur;
public int lastPickedColor;
public int lastPickedColorNum;
public TLRPC.TL_wallPaper lastSelectedPattern;
public int lastSizeHash;
public RecyclerListView listView;
public RecyclerListView listView2;
public ColoredImageSpan lockSpan;
public float maxScrollOffset;
public int maxWallpaperSize;
public MessagesAdapter messagesAdapter;
public FrameLayout messagesButtonsContainer;
public WallpaperCheckBoxView[] messagesCheckBoxView;
public ImageView messagesPlayAnimationImageView;
public FrameLayout messagesPlayAnimationView;
public AnimatorSet messagesPlayViewAnimator;
public AnimatorSet motionAnimation;
public Theme.MessageDrawable msgOutDrawable;
public Theme.MessageDrawable msgOutDrawableSelected;
public Theme.MessageDrawable msgOutMediaDrawable;
public Theme.MessageDrawable msgOutMediaDrawableSelected;
public boolean nightTheme;
public ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener;
public DayNightSwitchDelegate onSwitchDayNightDelegate;
public Bitmap originalBitmap;
public FrameLayout page1;
public FrameLayout page2;
public WallpaperParallaxEffect parallaxEffect;
public float parallaxScale;
public int patternColor;
public FrameLayout[] patternLayout;
public TextView patternTitleView;
public AnimatorSet patternViewAnimation;
public ArrayList<Object> patterns;
public PatternsAdapter patternsAdapter;
public FrameLayout[] patternsButtonsContainer;
public TextView[] patternsCancelButton;
public HashMap<Long, Object> patternsDict;
public LinearLayoutManager patternsLayoutManager;
public RecyclerListView patternsListView;
public TextView[] patternsSaveButton;
public int previousBackgroundColor;
public int previousBackgroundGradientColor1;
public int previousBackgroundGradientColor2;
public int previousBackgroundGradientColor3;
public int previousBackgroundRotation;
public float previousIntensity;
public TLRPC.TL_wallPaper previousSelectedPattern;
public float progressToDarkTheme;
public boolean progressVisible;
public boolean removeBackgroundOverride;
public boolean rotatePreview;
public FrameLayout saveButtonsContainer;
public ActionBarMenuItem saveItem;
public final int screenType;
public Scroller scroller;
public TLRPC.TL_wallPaper selectedPattern;
public boolean self;
public MessageObject serverWallpaper;
public boolean setupFinished;
public Drawable sheetDrawable;
public boolean shouldShowBrightnessControll;
public boolean shouldShowDayNightIcon;
public boolean showColor;
public boolean showExport;
public RLottieDrawable sunDrawable;
public final ThemeDelegate themeDelegate;
public List<ThemeDescription> themeDescriptions;
public UndoView undoView;
public boolean useDefaultThemeForButtons;
public ValueAnimator valueAnimator;
public ViewPager viewPager;
public boolean wasScroll;
public long watchForKeyboardEndTime;
public interface DayNightSwitchDelegate {
boolean isDark();
boolean supportsAnimation();
void switchDayNight(boolean animated);
}
public interface WallpaperActivityDelegate {
void didSetNewBackground(TLRPC.WallPaper wallpaper);
}
public static void lambda$applyWallpaperBackground$21() {
}
public static void lambda$createView$3(View view, int i) {
}
public static boolean lambda$toggleTheme$34(View view, MotionEvent motionEvent) {
return true;
}
public void onProgressDownload(String fileName, long downloadedSize, long totalSize) {
}
public void onProgressUpload(String fileName, long uploadedSize, long totalSize, boolean isEncrypted) {
}
public void setResourceProvider(Theme.ResourcesProvider resourceProvider) {
this.themeDelegate.parentProvider = resourceProvider;
}
public Theme.ResourcesProvider getResourceProvider() {
return this.themeDelegate;
}
public void lambda$new$0() {
this.applyColorScheduled = false;
applyColor(this.lastPickedColor, this.lastPickedColorNum);
this.lastPickedColorNum = -1;
}
public final void checkBoostsLevel() {
if (this.dialogId >= 0 || this.checkingBoostsLevel || this.checkedBoostsLevel || this.boostsStatus != null) {
return;
}
this.checkingBoostsLevel = true;
getMessagesController().getBoostsController().getBoostsStats(this.dialogId, new Consumer() {
public final void accept(Object obj) {
ThemePreviewActivity.this.lambda$checkBoostsLevel$1((TL_stories.TL_premium_boostsStatus) obj);
}
});
}
public void lambda$checkBoostsLevel$1(TL_stories.TL_premium_boostsStatus tL_premium_boostsStatus) {
this.boostsStatus = tL_premium_boostsStatus;
this.checkedBoostsLevel = true;
updateApplyButton1(true);
this.checkingBoostsLevel = false;
}
public static void showFor(final ChatActivity chatActivity, MessageObject message) {
TLRPC.TL_wallPaper tL_wallPaper;
TLRPC.TL_messageActionSetChatWallPaper tL_messageActionSetChatWallPaper = message.messageOwner.action;
if (tL_messageActionSetChatWallPaper instanceof TLRPC.TL_messageActionSetChatWallPaper) {
TLRPC.TL_wallPaper tL_wallPaper2 = ((TLRPC.MessageAction) tL_messageActionSetChatWallPaper).wallpaper;
if (((TLRPC.WallPaper) tL_wallPaper2).pattern || ((TLRPC.WallPaper) tL_wallPaper2).document == null) {
String str = ((TLRPC.WallPaper) tL_wallPaper2).slug;
TLRPC.WallPaperSettings wallPaperSettings = ((TLRPC.WallPaper) tL_wallPaper2).settings;
TLRPC.TL_wallPaper colorWallpaper = new WallpapersListActivity.ColorWallpaper(str, wallPaperSettings.background_color, wallPaperSettings.second_background_color, wallPaperSettings.third_background_color, wallPaperSettings.fourth_background_color, AndroidUtilities.getWallpaperRotation(wallPaperSettings.rotation, false), r3.intensity / 100.0f, ((TLRPC.WallPaper) tL_wallPaper2).settings.motion, null);
if (tL_wallPaper2 instanceof TLRPC.TL_wallPaper) {
colorWallpaper.pattern = tL_wallPaper2;
}
tL_wallPaper = colorWallpaper;
} else {
tL_wallPaper = tL_wallPaper2;
}
final boolean isDark = Theme.getActiveTheme().isDark();
ThemePreviewActivity themePreviewActivity = new ThemePreviewActivity(tL_wallPaper, null, true, false) {
public void onFragmentClosed() {
super.onFragmentClosed();
ChatActivity.ThemeDelegate themeDelegate = chatActivity.themeDelegate;
themeDelegate.setCurrentTheme(themeDelegate.getCurrentTheme(), chatActivity.themeDelegate.getCurrentWallpaper(), false, Boolean.valueOf(isDark));
}
};
TLRPC.WallPaperSettings wallPaperSettings2 = ((TLRPC.WallPaper) tL_wallPaper2).settings;
if (wallPaperSettings2 != null) {
themePreviewActivity.setInitialModes(wallPaperSettings2.blur, wallPaperSettings2.motion, wallPaperSettings2.intensity / 100.0f);
}
themePreviewActivity.setCurrentServerWallpaper(message);
themePreviewActivity.setDialogId(message.getDialogId());
themePreviewActivity.setResourceProvider(chatActivity.themeDelegate);
themePreviewActivity.setOnSwitchDayNightDelegate(new DayNightSwitchDelegate(isDark, chatActivity) {
public boolean forceDark;
public final ChatActivity val$chatActivity;
public final boolean val$initialIsDark;
@Override
public boolean supportsAnimation() {
return true;
}
{
this.val$initialIsDark = isDark;
this.val$chatActivity = chatActivity;
this.forceDark = isDark;
}
@Override
public boolean isDark() {
return this.forceDark;
}
@Override
public void switchDayNight(boolean animated) {
this.forceDark = !this.forceDark;
ChatActivity.ThemeDelegate themeDelegate = this.val$chatActivity.themeDelegate;
themeDelegate.setCurrentTheme(themeDelegate.getCurrentTheme(), this.val$chatActivity.themeDelegate.getCurrentWallpaper(), animated, Boolean.valueOf(this.forceDark));
}
});
chatActivity.presentFragment(themePreviewActivity);
}
}
public final void setCurrentServerWallpaper(MessageObject messageObject) {
this.serverWallpaper = messageObject;
}
public void setDialogId(long dialogId) {
this.dialogId = dialogId;
this.self = dialogId == 0 || dialogId == getUserConfig().getClientUserId();
}
public void setOnSwitchDayNightDelegate(DayNightSwitchDelegate delegate) {
this.onSwitchDayNightDelegate = delegate;
}
public ThemePreviewActivity(Object wallPaper, Bitmap bitmap) {
this(wallPaper, bitmap, false, false);
}
public ThemePreviewActivity(Object wallPaper, Bitmap bitmap, boolean rotate, boolean openColor) {
this.themeDelegate = new ThemeDelegate() {
@Override
public boolean isDark() {
DayNightSwitchDelegate dayNightSwitchDelegate = ThemePreviewActivity.this.onSwitchDayNightDelegate;
if (dayNightSwitchDelegate != null) {
return dayNightSwitchDelegate.isDark();
}
return super.isDark();
}
};
this.useDefaultThemeForButtons = true;
this.colorType = 1;
this.msgOutDrawable = new MessageDrawable(0, true, false);
this.msgOutDrawableSelected = new MessageDrawable(0, true, true);
this.msgOutMediaDrawable = new MessageDrawable(1, true, false);
this.msgOutMediaDrawableSelected = new MessageDrawable(1, true, true);
this.lastPickedColorNum = -1;
this.applyColorAction = new Runnable() {
@Override
public final void run() {
ThemePreviewActivity.this.lambda$new$0();
}
};
this.backgroundImages = new BackgroundView[2];
this.patternLayout = new FrameLayout[2];
this.patternsCancelButton = new TextView[2];
this.patternsSaveButton = new TextView[2];
this.patternsButtonsContainer = new FrameLayout[2];
this.patternsDict = new HashMap<>();
this.currentIntensity = 0.5f;
this.dimAmount = 0.0f;
this.blendMode = PorterDuff.Mode.SRC_IN;
this.parallaxScale = 1.0f;
this.imageFilter = "640_360";
this.maxWallpaperSize = 1920;
this.showExport = true;
this.self = true;
this.gestureDetector2 = new GestureDetector2(getContext(), new GestureDetector2.OnGestureListener() {
public void onLongPress(MotionEvent e) {
}
public void onShowPress(MotionEvent e) {
}
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
public void onUp(MotionEvent e) {
}
public boolean onDown(MotionEvent e) {
if (ThemePreviewActivity.this.scroller == null) {
return true;
}
ThemePreviewActivity.this.scroller.abortAnimation();
return true;
}
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (ThemePreviewActivity.this.scroller != null) {
ThemePreviewActivity.this.scroller.abortAnimation();
}
ThemePreviewActivity themePreviewActivity = ThemePreviewActivity.this;
themePreviewActivity.currentScrollOffset = Utilities.clamp(themePreviewActivity.currentScrollOffset + distanceX, themePreviewActivity.maxScrollOffset, 0.0f);
ThemePreviewActivity.this.invalidateBlur();
ThemePreviewActivity.this.backgroundImage.invalidate();
return true;
}
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (ThemePreviewActivity.this.scroller == null) {
return true;
}
ThemePreviewActivity.this.scroller.abortAnimation();
ThemePreviewActivity.this.scroller.fling((int) ThemePreviewActivity.this.currentScrollOffset, 0, Math.round(-velocityX), Math.round(velocityY), 0, (int) ThemePreviewActivity.this.maxScrollOffset, 0, Integer.MAX_VALUE);
ThemePreviewActivity.this.backgroundImage.postInvalidate();
return true;
}
});
this.checkingBoostsLevel = false;
this.checkedBoostsLevel = false;
this.screenType = 2;
this.showColor = openColor;
this.currentWallpaper = wallPaper;
this.currentWallpaperBitmap = bitmap;
this.rotatePreview = rotate;
if (wallPaper instanceof WallpapersListActivity.ColorWallpaper) {
WallpapersListActivity.ColorWallpaper colorWallpaper = (WallpapersListActivity.ColorWallpaper) wallPaper;
this.isMotion = colorWallpaper.motion;
TLRPC.TL_wallPaper tL_wallPaper = colorWallpaper.pattern;
this.selectedPattern = tL_wallPaper;
if (tL_wallPaper != null) {
float f = colorWallpaper.intensity;
this.currentIntensity = f;
if (f < 0.0f && !Theme.getActiveTheme().isDark()) {
this.currentIntensity *= -1.0f;
}
}
}
this.msgOutDrawable.themePreview = true;
this.msgOutMediaDrawable.themePreview = true;
this.msgOutDrawableSelected.themePreview = true;
this.msgOutMediaDrawableSelected.themePreview = true;
}
public ThemePreviewActivity(Theme.ThemeInfo themeInfo) {
this(themeInfo, false, 0, false, false);
}
public ThemePreviewActivity(Theme.ThemeInfo themeInfo, boolean deleteFile, int screenType, boolean edit, boolean night) {
this.themeDelegate = new ThemeDelegate() {
@Override
public boolean isDark() {
DayNightSwitchDelegate dayNightSwitchDelegate = ThemePreviewActivity.this.onSwitchDayNightDelegate;
if (dayNightSwitchDelegate != null) {
return dayNightSwitchDelegate.isDark();
}
return super.isDark();
}
};
this.useDefaultThemeForButtons = true;
this.colorType = 1;
this.msgOutDrawable = new MessageDrawable(0, true, false);
this.msgOutDrawableSelected = new MessageDrawable(0, true, true);
this.msgOutMediaDrawable = new MessageDrawable(1, true, false);
this.msgOutMediaDrawableSelected = new MessageDrawable(1, true, true);
this.lastPickedColorNum = -1;
this.applyColorAction = new Runnable() {
@Override
public final void run() {
ThemePreviewActivity.this.lambda$new$0();
}
};
this.backgroundImages = new BackgroundView[2];
this.patternLayout = new FrameLayout[2];
this.patternsCancelButton = new TextView[2];
this.patternsSaveButton = new TextView[2];
this.patternsButtonsContainer = new FrameLayout[2];
this.patternsDict = new HashMap<>();
this.currentIntensity = 0.5f;
this.dimAmount = 0.0f;
this.blendMode = PorterDuff.Mode.SRC_IN;
this.parallaxScale = 1.0f;
this.imageFilter = "640_360";
this.maxWallpaperSize = 1920;
this.showExport = true;
this.self = true;
this.gestureDetector2 = new GestureDetector2(getContext(), new GestureDetector2.OnGestureListener() {
public void onLongPress(MotionEvent e) {
}
public void onShowPress(MotionEvent e) {
}
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
public void onUp(MotionEvent e) {
}
public boolean onDown(MotionEvent e) {
if (ThemePreviewActivity.this.scroller == null) {
return true;
}
ThemePreviewActivity.this.scroller.abortAnimation();
return true;
}
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (ThemePreviewActivity.this.scroller != null) {
ThemePreviewActivity.this.scroller.abortAnimation();
}
ThemePreviewActivity themePreviewActivity = ThemePreviewActivity.this;
themePreviewActivity.currentScrollOffset = Utilities.clamp(themePreviewActivity.currentScrollOffset + distanceX, themePreviewActivity.maxScrollOffset, 0.0f);
ThemePreviewActivity.this.invalidateBlur();
ThemePreviewActivity.this.backgroundImage.invalidate();
return true;
}
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (ThemePreviewActivity.this.scroller == null) {
return true;
}
ThemePreviewActivity.this.scroller.abortAnimation();
ThemePreviewActivity.this.scroller.fling((int) ThemePreviewActivity.this.currentScrollOffset, 0, Math.round(-velocityX), Math.round(velocityY), 0, (int) ThemePreviewActivity.this.maxScrollOffset, 0, Integer.MAX_VALUE);
ThemePreviewActivity.this.backgroundImage.postInvalidate();
return true;
}
});
this.checkingBoostsLevel = false;
this.checkedBoostsLevel = false;
this.screenType = screenType;
this.nightTheme = night;
this.applyingTheme = themeInfo;
this.deleteOnCancel = deleteFile;
this.editingTheme = edit;
if (screenType == 1) {
Theme.ThemeAccent accent = themeInfo.getAccent(!edit);
this.accent = accent;
if (accent != null) {
this.useDefaultThemeForButtons = false;
this.backupAccentColor = accent.accentColor;
this.backupAccentColor2 = accent.accentColor2;
this.backupMyMessagesAccentColor = accent.myMessagesAccentColor;
this.backupMyMessagesGradientAccentColor1 = accent.myMessagesGradientAccentColor1;
this.backupMyMessagesGradientAccentColor2 = accent.myMessagesGradientAccentColor2;
this.backupMyMessagesGradientAccentColor3 = accent.myMessagesGradientAccentColor3;
this.backupMyMessagesAnimated = accent.myMessagesAnimated;
this.backupBackgroundOverrideColor = accent.backgroundOverrideColor;
this.backupBackgroundGradientOverrideColor1 = accent.backgroundGradientOverrideColor1;
this.backupBackgroundGradientOverrideColor2 = accent.backgroundGradientOverrideColor2;
this.backupBackgroundGradientOverrideColor3 = accent.backgroundGradientOverrideColor3;
this.backupIntensity = accent.patternIntensity;
this.backupSlug = accent.patternSlug;
this.backupBackgroundRotation = accent.backgroundRotation;
}
} else {
if (screenType == 0) {
this.useDefaultThemeForButtons = false;
}
Theme.ThemeAccent accent2 = themeInfo.getAccent(false);
this.accent = accent2;
if (accent2 != null) {
this.selectedPattern = accent2.pattern;
}
}
Theme.ThemeAccent themeAccent = this.accent;
if (themeAccent != null) {
this.isMotion = themeAccent.patternMotion;
if (!TextUtils.isEmpty(themeAccent.patternSlug)) {
this.currentIntensity = this.accent.patternIntensity;
}
Theme.applyThemeTemporary(this.applyingTheme, true);
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.goingToPreviewTheme, new Object[0]);
this.msgOutDrawable.themePreview = true;
this.msgOutMediaDrawable.themePreview = true;
this.msgOutDrawableSelected.themePreview = true;
this.msgOutMediaDrawableSelected.themePreview = true;
}
public void setInitialModes(boolean blur, boolean motion, float dim) {
this.isBlurred = blur;
this.isMotion = motion;
this.dimAmount = dim;
}
@android.annotation.SuppressLint({"Recycle"})
public android.view.View createView(android.content.Context r36) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ThemePreviewActivity.createView(android.content.Context):android.view.View");
}
public void lambda$createView$2() {
if (getParentActivity() == null || getContext() == null) {
return;
}
SharedConfig.increaseDayNightWallpaperSiwtchHint();
HintView hintView = new HintView(getContext(), 7, true);
hintView.setAlpha(0.0f);
hintView.setVisibility(4);
hintView.setShowingDuration(4000L);
this.frameLayout.addView((View) hintView, (ViewGroup.LayoutParams) LayoutHelper.createFrame(-2, -2.0f, 51, 4.0f, 0.0f, 4.0f, 0.0f));
if (this.onSwitchDayNightDelegate.isDark()) {
hintView.setText(LocaleController.getString("PreviewWallpaperDay", R.string.PreviewWallpaperDay));
} else {
hintView.setText(LocaleController.getString("PreviewWallpaperNight", R.string.PreviewWallpaperNight));
}
hintView.setBackgroundColor(-366530760, -1);
hintView.showForView(this.dayNightItem, true);
hintView.setExtraTranslationY(-AndroidUtilities.dp(14.0f));
}
public class AnonymousClass9 extends ActionBar.ActionBarMenuOnItemClick {
public AnonymousClass9() {
}
@Override
public void onItemClick(int id) {
File file;
Theme.ThemeAccent accent;
String url;
String str;
int i = 0;
if (id == -1) {
if (ThemePreviewActivity.this.checkDiscard()) {
ThemePreviewActivity.this.cancelThemeApply(false);
return;
}
return;
}
if (id >= 1 && id <= 3) {
ThemePreviewActivity.this.selectColorType(id);
return;
}
if (id == 4) {
if (ThemePreviewActivity.this.removeBackgroundOverride) {
Theme.resetCustomWallpaper(false);
}
File pathToWallpaper = ThemePreviewActivity.this.accent.getPathToWallpaper();
if (pathToWallpaper != null) {
pathToWallpaper.delete();
}
ThemePreviewActivity.this.accent.patternSlug = ThemePreviewActivity.this.selectedPattern != null ? ((TLRPC.WallPaper) ThemePreviewActivity.this.selectedPattern).slug : "";
ThemePreviewActivity.this.accent.patternIntensity = ThemePreviewActivity.this.currentIntensity;
ThemePreviewActivity.this.accent.patternMotion = ThemePreviewActivity.this.isMotion;
if (((int) ThemePreviewActivity.this.accent.backgroundOverrideColor) == 0) {
ThemePreviewActivity.this.accent.backgroundOverrideColor = 4294967296L;
}
if (((int) ThemePreviewActivity.this.accent.backgroundGradientOverrideColor1) == 0) {
ThemePreviewActivity.this.accent.backgroundGradientOverrideColor1 = 4294967296L;
}
if (((int) ThemePreviewActivity.this.accent.backgroundGradientOverrideColor2) == 0) {
ThemePreviewActivity.this.accent.backgroundGradientOverrideColor2 = 4294967296L;
}
if (((int) ThemePreviewActivity.this.accent.backgroundGradientOverrideColor3) == 0) {
ThemePreviewActivity.this.accent.backgroundGradientOverrideColor3 = 4294967296L;
}
ThemePreviewActivity.this.saveAccentWallpaper();
NotificationCenter.getGlobalInstance().removeObserver(ThemePreviewActivity.this, NotificationCenter.wallpapersDidLoad);
Theme.saveThemeAccents(ThemePreviewActivity.this.applyingTheme, true, false, false, true);
Theme.applyPreviousTheme();
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, new Object[]{ThemePreviewActivity.this.applyingTheme, Boolean.valueOf(ThemePreviewActivity.this.nightTheme), null, -1});
ThemePreviewActivity.this.finishFragment();
return;
}
if (id == 5) {
if (ThemePreviewActivity.this.getParentActivity() == null) {
return;
}
StringBuilder sb = new StringBuilder();
if (ThemePreviewActivity.this.isBlurred) {
sb.append("blur");
}
if (ThemePreviewActivity.this.isMotion) {
if (sb.length() > 0) {
sb.append("+");
}
sb.append("motion");
}
if (ThemePreviewActivity.this.currentWallpaper instanceof TLRPC.TL_wallPaper) {
String str2 = "https://" + MessagesController.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).linkPrefix + "/bg/" + ((TLRPC.WallPaper) ((TLRPC.TL_wallPaper) ThemePreviewActivity.this.currentWallpaper)).slug;
if (sb.length() > 0) {
str2 = str2 + "?mode=" + sb.toString();
}
str = str2;
} else {
if (ThemePreviewActivity.this.currentWallpaper instanceof WallpapersListActivity.ColorWallpaper) {
WallpapersListActivity.ColorWallpaper colorWallpaper = new WallpapersListActivity.ColorWallpaper(ThemePreviewActivity.this.selectedPattern != null ? ((TLRPC.WallPaper) ThemePreviewActivity.this.selectedPattern).slug : "c", ThemePreviewActivity.this.backgroundColor, ThemePreviewActivity.this.backgroundGradientColor1, ThemePreviewActivity.this.backgroundGradientColor2, ThemePreviewActivity.this.backgroundGradientColor3, ThemePreviewActivity.this.backgroundRotation, ThemePreviewActivity.this.currentIntensity, ThemePreviewActivity.this.isMotion, null);
colorWallpaper.pattern = ThemePreviewActivity.this.selectedPattern;
url = colorWallpaper.getUrl();
} else {
if (!BuildVars.DEBUG_PRIVATE_VERSION || (accent = Theme.getActiveTheme().getAccent(false)) == null) {
return;
}
WallpapersListActivity.ColorWallpaper colorWallpaper2 = new WallpapersListActivity.ColorWallpaper(accent.patternSlug, (int) accent.backgroundOverrideColor, (int) accent.backgroundGradientOverrideColor1, (int) accent.backgroundGradientOverrideColor2, (int) accent.backgroundGradientOverrideColor3, accent.backgroundRotation, accent.patternIntensity, accent.patternMotion, null);
int size = ThemePreviewActivity.this.patterns.size();
while (true) {
if (i >= size) {
break;
}
TLRPC.TL_wallPaper tL_wallPaper = (TLRPC.TL_wallPaper) ThemePreviewActivity.this.patterns.get(i);
if (((TLRPC.WallPaper) tL_wallPaper).pattern && accent.patternSlug.equals(((TLRPC.WallPaper) tL_wallPaper).slug)) {
colorWallpaper2.pattern = tL_wallPaper;
break;
}
i++;
}
url = colorWallpaper2.getUrl();
}
str = url;
}
ThemePreviewActivity.this.showDialog(new ShareAlert(ThemePreviewActivity.this.getParentActivity(), null, str, false, str, false) {
public void onSend(LongSparseArray<TLRPC.Dialog> dids, int count, TLRPC.TL_forumTopic topic) {
if (dids.size() == 1) {
ThemePreviewActivity.this.undoView.showWithAction(((TLRPC.Dialog) dids.valueAt(0)).id, 61, Integer.valueOf(count));
} else {
ThemePreviewActivity.this.undoView.showWithAction(0L, 61, Integer.valueOf(count), Integer.valueOf(dids.size()), (Runnable) null, (Runnable) null);
}
}
});
return;
}
if (id == 6) {
if (SharedConfig.dayNightWallpaperSwitchHint <= 3) {
SharedConfig.dayNightWallpaperSwitchHint = 10;
SharedConfig.increaseDayNightWallpaperSiwtchHint();
}
boolean isDark = ThemePreviewActivity.this.onSwitchDayNightDelegate.isDark();
DayNightSwitchDelegate dayNightSwitchDelegate = ThemePreviewActivity.this.onSwitchDayNightDelegate;
if (dayNightSwitchDelegate != null) {
if (!dayNightSwitchDelegate.supportsAnimation()) {
ThemePreviewActivity.this.toggleTheme();
return;
}
ThemePreviewActivity.this.onSwitchDayNightDelegate.switchDayNight(true);
ThemePreviewActivity.this.sunDrawable.setPlayInDirectionOfCustomEndFrame(true);
if (isDark) {
ThemePreviewActivity.this.sunDrawable.setCustomEndFrame(0);
} else {
ThemePreviewActivity.this.sunDrawable.setCustomEndFrame(36);
}
ThemePreviewActivity.this.sunDrawable.start();
if (ThemePreviewActivity.this.shouldShowBrightnessControll) {
DayNightSwitchDelegate dayNightSwitchDelegate2 = ThemePreviewActivity.this.onSwitchDayNightDelegate;
if (dayNightSwitchDelegate2 != null && dayNightSwitchDelegate2.isDark()) {
ThemePreviewActivity.this.dimmingSlider.setVisibility(0);
ThemePreviewActivity.this.dimmingSlider.animateValueTo(ThemePreviewActivity.this.dimAmount);
} else {
ThemePreviewActivity.this.dimmingSlider.animateValueTo(0.0f);
}
if (ThemePreviewActivity.this.changeDayNightViewAnimator2 != null) {
ThemePreviewActivity.this.changeDayNightViewAnimator2.removeAllListeners();
ThemePreviewActivity.this.changeDayNightViewAnimator2.cancel();
}
ThemePreviewActivity themePreviewActivity = ThemePreviewActivity.this;
float[] fArr = new float[2];
fArr[0] = themePreviewActivity.progressToDarkTheme;
fArr[1] = ThemePreviewActivity.this.onSwitchDayNightDelegate.isDark() ? 1.0f : 0.0f;
themePreviewActivity.changeDayNightViewAnimator2 = ValueAnimator.ofFloat(fArr);
ThemePreviewActivity.this.changeDayNightViewAnimator2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
ThemePreviewActivity.AnonymousClass9.this.lambda$onItemClick$0(valueAnimator);
}
});
ThemePreviewActivity.this.changeDayNightViewAnimator2.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (ThemePreviewActivity.this.onSwitchDayNightDelegate.isDark()) {
return;
}
ThemePreviewActivity.this.dimmingSlider.setVisibility(8);
}
});
ThemePreviewActivity.this.changeDayNightViewAnimator2.setDuration(250L);
ThemePreviewActivity.this.changeDayNightViewAnimator2.setInterpolator(CubicBezierInterpolator.DEFAULT);
ThemePreviewActivity.this.changeDayNightViewAnimator2.start();
return;
}
return;
}
return;
}
if (id == 7 && (ThemePreviewActivity.this.currentWallpaper instanceof WallpapersListActivity.FileWallpaper) && (file = ((WallpapersListActivity.FileWallpaper) ThemePreviewActivity.this.currentWallpaper).originalPath) != null) {
final MediaController.PhotoEntry photoEntry = new MediaController.PhotoEntry(0, 0, 0L, file.getAbsolutePath(), 0, false, 0, 0, 0L);
photoEntry.isVideo = false;
((MediaController.MediaEditState) photoEntry).thumbPath = null;
ArrayList<Object> arrayList = new ArrayList<>();
arrayList.add(photoEntry);
PhotoViewer.getInstance().setParentActivity(ThemePreviewActivity.this.getParentActivity());
PhotoViewer.getInstance().openPhotoForSelect(arrayList, 0, 3, false, new PhotoViewer.EmptyPhotoViewerProvider() {
@Override
public boolean allowCaption() {
return false;
}
@Override
public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo, boolean notify, int scheduleDate, boolean forceDocument) {
if (((MediaController.MediaEditState) photoEntry).imagePath != null) {
File file2 = new File(FileLoader.getDirectory(4), Utilities.random.nextInt() + ".jpg");
Point realScreenSize = AndroidUtilities.getRealScreenSize();
Bitmap loadBitmap = ImageLoader.loadBitmap(((MediaController.MediaEditState) photoEntry).imagePath, (Uri) null, (float) realScreenSize.x, (float) realScreenSize.y, true);
try {
loadBitmap.compress(Bitmap.CompressFormat.JPEG, 87, new FileOutputStream(file2));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
File file3 = new File(((MediaController.MediaEditState) photoEntry).imagePath);
ThemePreviewActivity.this.currentWallpaper = new WallpapersListActivity.FileWallpaper("", file3, file3);
ThemePreviewActivity.this.currentWallpaperBitmap = loadBitmap;
ThemePreviewActivity.this.lastSizeHash = 0;
ThemePreviewActivity.this.backgroundImage.requestLayout();
ThemePreviewActivity.this.setCurrentImage(false);
ThemePreviewActivity.this.blurredBitmap = null;
ThemePreviewActivity.this.updateBlurred();
}
}
}, null);
}
}
public void lambda$onItemClick$0(ValueAnimator valueAnimator) {
ThemePreviewActivity.this.progressToDarkTheme = ((Float) valueAnimator.getAnimatedValue()).floatValue();
ThemePreviewActivity.this.backgroundImage.invalidate();
ThemePreviewActivity.this.bottomOverlayChat.invalidate();
ThemePreviewActivity.this.dimmingSlider.setAlpha(ThemePreviewActivity.this.progressToDarkTheme);
ThemePreviewActivity.this.dimmingSliderContainer.invalidate();
ThemePreviewActivity.this.invalidateBlur();
}
}
public void lambda$createView$4(ImageReceiver imageReceiver, boolean z, boolean z2, boolean z3) {
if (this.currentWallpaper instanceof WallpapersListActivity.ColorWallpaper) {
return;
}
Drawable drawable = imageReceiver.getDrawable();
if (!z || drawable == null) {
return;
}
this.themeDelegate.applyChatServiceMessageColor(AndroidUtilities.calcDrawableColor(drawable), checkBlur(drawable), drawable, Float.valueOf(this.currentIntensity));
if (!z2 && this.isBlurred && this.blurredBitmap == null) {
this.backgroundImage.getImageReceiver().setCrossfadeWithOldImage(false);
updateBlurred();
this.backgroundImage.getImageReceiver().setCrossfadeWithOldImage(true);
}
invalidateBlur();
}
public void lambda$createView$5(View view) {
this.dropDownContainer.toggleSubMenu();
}
public void lambda$createView$6(View view, int i, float f, float f2) {
if (view instanceof ChatMessageCell) {
ChatMessageCell chatMessageCell = (ChatMessageCell) view;
if (chatMessageCell.isInsideBackground(f, f2)) {
if (chatMessageCell.getMessageObject().isOutOwner()) {
selectColorType(3);
return;
} else {
selectColorType(1);
return;
}
}
selectColorType(2);
}
}
public void lambda$createView$7(int i, int i2, float f) {
if (this.isMotion) {
this.backgroundImage.getBackground();
float scaleX = this.motionAnimation != null ? (this.backgroundImage.getScaleX() - 1.0f) / (this.parallaxScale - 1.0f) : 1.0f;
this.backgroundImage.setTranslationX(i * scaleX);
this.backgroundImage.setTranslationY(i2 * scaleX);
}
}
public void lambda$createView$8(View view) {
applyWallpaperBackground(false);
}
public void lambda$createView$9(View view) {
applyWallpaperBackground(true);
}
public void lambda$createView$10(Float f) {
this.dimAmount = f.floatValue();
this.backgroundImage.invalidate();
invalidateBlur();
}
public void lambda$createView$11(int i, WallpaperCheckBoxView wallpaperCheckBoxView, View view) {
if (this.backgroundButtonsContainer.getAlpha() == 1.0f && this.patternViewAnimation == null) {
int i2 = this.screenType;
if ((i2 == 1 || (this.currentWallpaper instanceof WallpapersListActivity.ColorWallpaper)) && i == 2) {
wallpaperCheckBoxView.setChecked(!wallpaperCheckBoxView.isChecked(), true);
boolean isChecked = wallpaperCheckBoxView.isChecked();
this.isMotion = isChecked;
this.parallaxEffect.setEnabled(isChecked);
animateMotionChange();
return;
}
if (i == 1 && (i2 == 1 || (this.currentWallpaper instanceof WallpapersListActivity.ColorWallpaper))) {
if (this.backgroundCheckBoxView[1].isChecked()) {
this.lastSelectedPattern = this.selectedPattern;
this.backgroundImage.setImageDrawable((Drawable) null);
this.selectedPattern = null;
this.isMotion = false;
updateButtonState(false, true);
animateMotionChange();
if (this.patternLayout[1].getVisibility() == 0) {
if (this.screenType == 1) {
showPatternsView(0, true, true);
} else {
showPatternsView(i, this.patternLayout[i].getVisibility() != 0, true);
}
}
} else {
selectPattern(this.lastSelectedPattern != null ? -1 : 0);
if (this.screenType == 1) {
showPatternsView(1, true, true);
} else {
showPatternsView(i, this.patternLayout[i].getVisibility() != 0, true);
}
}
this.backgroundCheckBoxView[1].setChecked(this.selectedPattern != null, true);
updateSelectedPattern(true);
this.patternsListView.invalidateViews();
updateMotionButton();
return;
}
if (this.currentWallpaper instanceof WallpapersListActivity.ColorWallpaper) {
showPatternsView(i, this.patternLayout[i].getVisibility() != 0, true);
return;
}
if (i2 != 1) {
wallpaperCheckBoxView.setChecked(!wallpaperCheckBoxView.isChecked(), true);
if (i == 0) {
boolean isChecked2 = wallpaperCheckBoxView.isChecked();
this.isBlurred = isChecked2;
if (isChecked2) {
this.backgroundImage.getImageReceiver().setForceCrossfade(true);
}
updateBlurred();
return;
}
boolean isChecked3 = wallpaperCheckBoxView.isChecked();
this.isMotion = isChecked3;
this.parallaxEffect.setEnabled(isChecked3);
animateMotionChange();
}
}
}
public void lambda$createView$12(int i, WallpaperCheckBoxView wallpaperCheckBoxView, View view) {
if (this.messagesButtonsContainer.getAlpha() == 1.0f && i == 0) {
wallpaperCheckBoxView.setChecked(!wallpaperCheckBoxView.isChecked(), true);
this.accent.myMessagesAnimated = wallpaperCheckBoxView.isChecked();
Theme.refreshThemeColors(true, true);
this.listView2.invalidateViews();
}
}
public void lambda$createView$13(int i, View view) {
if (this.patternViewAnimation != null) {
return;
}
if (i == 0) {
this.backgroundRotation = this.previousBackgroundRotation;
setBackgroundColor(this.previousBackgroundGradientColor3, 3, true, true);
setBackgroundColor(this.previousBackgroundGradientColor2, 2, true, true);
setBackgroundColor(this.previousBackgroundGradientColor1, 1, true, true);
setBackgroundColor(this.previousBackgroundColor, 0, true, true);
} else {
TLRPC.TL_wallPaper tL_wallPaper = this.previousSelectedPattern;
this.selectedPattern = tL_wallPaper;
if (tL_wallPaper == null) {
this.backgroundImage.setImageDrawable((Drawable) null);
} else {
BackgroundView backgroundView = this.backgroundImage;
ImageLocation forDocument = ImageLocation.getForDocument(((TLRPC.WallPaper) tL_wallPaper).document);
String str = this.imageFilter;
TLRPC.TL_wallPaper tL_wallPaper2 = this.selectedPattern;
backgroundView.setImage(forDocument, str, (ImageLocation) null, (String) null, "jpg", ((TLRPC.WallPaper) tL_wallPaper2).document.size, 1, tL_wallPaper2);
}
this.backgroundCheckBoxView[1].setChecked(this.selectedPattern != null, false);
float f = this.previousIntensity;
this.currentIntensity = f;
this.intensitySeekBar.setProgress(f);
this.backgroundImage.getImageReceiver().setAlpha(this.currentIntensity);
updateButtonState(false, true);
updateSelectedPattern(true);
}
if (this.screenType == 2) {
showPatternsView(i, false, true);
return;
}
if (this.selectedPattern == null) {
if (this.isMotion) {
this.isMotion = false;
this.backgroundCheckBoxView[0].setChecked(false, true);
animateMotionChange();
}
updateMotionButton();
}
showPatternsView(0, true, true);
}
public void lambda$createView$14(int i, View view) {
if (this.patternViewAnimation != null) {
return;
}
if (this.screenType == 2) {
showPatternsView(i, false, true);
} else {
showPatternsView(0, true, true);
}
}
public void lambda$createView$15(View view, int i) {
boolean z = this.selectedPattern != null;
selectPattern(i);
if (z == (this.selectedPattern == null)) {
animateMotionChange();
updateMotionButton();
}
updateSelectedPattern(true);
this.backgroundCheckBoxView[1].setChecked(this.selectedPattern != null, true);
this.patternsListView.invalidateViews();
int left = view.getLeft();
int right = view.getRight();
int dp = AndroidUtilities.dp(52.0f);
int i2 = left - dp;
if (i2 < 0) {
this.patternsListView.smoothScrollBy(i2, 0);
return;
}
int i3 = right + dp;
if (i3 > this.patternsListView.getMeasuredWidth()) {
RecyclerListView recyclerListView = this.patternsListView;
recyclerListView.smoothScrollBy(i3 - recyclerListView.getMeasuredWidth(), 0);
}
}
public class AnonymousClass27 implements ColorPicker.ColorPickerDelegate {
public AnonymousClass27() {
}
public void setColor(int color, int num, boolean applyNow) {
if (ThemePreviewActivity.this.screenType == 2) {
ThemePreviewActivity.this.setBackgroundColor(color, num, applyNow, true);
} else {
ThemePreviewActivity.this.scheduleApplyColor(color, num, applyNow);
}
}
public void openThemeCreate(boolean share) {
if (share) {
if (ThemePreviewActivity.this.accent.info == null) {
ThemePreviewActivity.this.finishFragment();
MessagesController.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).saveThemeToServer(ThemePreviewActivity.this.accent.parentTheme, ThemePreviewActivity.this.accent);
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needShareTheme, new Object[]{ThemePreviewActivity.this.accent.parentTheme, ThemePreviewActivity.this.accent});
return;
}
String str = "https://" + MessagesController.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).linkPrefix + "/addtheme/" + ThemePreviewActivity.this.accent.info.slug;
ThemePreviewActivity.this.showDialog(new ShareAlert(ThemePreviewActivity.this.getParentActivity(), (ArrayList) null, str, false, str, false));
return;
}
AlertsCreator.createThemeCreateDialog(ThemePreviewActivity.this, 1, (Theme.ThemeInfo) null, (Theme.ThemeAccent) null);
}
public void deleteTheme() {
if (ThemePreviewActivity.this.getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(ThemePreviewActivity.this.getParentActivity());
builder.setTitle(LocaleController.getString("DeleteThemeTitle", R.string.DeleteThemeTitle));
builder.setMessage(LocaleController.getString("DeleteThemeAlert", R.string.DeleteThemeAlert));
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ThemePreviewActivity.AnonymousClass27.this.lambda$deleteTheme$0(dialogInterface, i);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog create = builder.create();
ThemePreviewActivity.this.showDialog(create);
TextView textView = (TextView) create.getButton(-1);
if (textView != null) {
textView.setTextColor(ThemePreviewActivity.this.getThemedColor(Theme.key_text_RedBold));
}
}
public void lambda$deleteTheme$0(DialogInterface dialogInterface, int i) {
Theme.deleteThemeAccent(ThemePreviewActivity.this.applyingTheme, ThemePreviewActivity.this.accent, true);
Theme.applyPreviousTheme();
Theme.refreshThemeColors();
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, new Object[]{ThemePreviewActivity.this.applyingTheme, Boolean.valueOf(ThemePreviewActivity.this.nightTheme), null, -1});
ThemePreviewActivity.this.finishFragment();
}
public int getDefaultColor(int num) {
Theme.ThemeAccent themeAccent;
if (ThemePreviewActivity.this.colorType == 3 && ThemePreviewActivity.this.applyingTheme.firstAccentIsDefault && num == 0 && (themeAccent = ThemePreviewActivity.this.applyingTheme.themeAccentsMap.get(Theme.DEFALT_THEME_ACCENT_ID)) != null) {
return themeAccent.myMessagesAccentColor;
}
return 0;
}
}
public void lambda$createView$16() {
this.watchForKeyboardEndTime = SystemClock.elapsedRealtime() + 1500;
this.frameLayout.invalidate();
}
public void lambda$createView$17(View view) {
this.showExport = true;
cancelThemeApply(false);
this.showExport = false;
}
public void lambda$createView$18(View view) {
Theme.ThemeAccent accent;
Theme.setUsePlusThemeKey(false);
Theme.ThemeInfo previousTheme = Theme.getPreviousTheme();
if (previousTheme == null) {
return;
}
int i = previousTheme.prevAccentId;
if (i >= 0) {
accent = previousTheme.themeAccentsMap.get(i);
} else {
accent = previousTheme.getAccent(false);
}
if (this.accent != null) {
saveAccentWallpaper();
Theme.saveThemeAccents(this.applyingTheme, true, false, false, false);
Theme.clearPreviousTheme();
Theme.applyTheme(this.applyingTheme, this.nightTheme);
((BaseFragment) this).parentLayout.rebuildAllFragmentViews(false, false);
} else {
((BaseFragment) this).parentLayout.rebuildAllFragmentViews(false, false);
File file = new File(this.applyingTheme.pathToFile);
Theme.ThemeInfo themeInfo = this.applyingTheme;
Theme.applyThemeFile(file, themeInfo.name, themeInfo.info, false);
MessagesController.getInstance(this.applyingTheme.account).saveTheme(this.applyingTheme, (Theme.ThemeAccent) null, false, false);
SharedPreferences.Editor edit = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", 0).edit();
edit.putString("lastDayTheme", this.applyingTheme.getKey());
edit.commit();
}
BaseFragment baseFragment = getParentLayout().getFragmentStack().get(Math.max(0, getParentLayout().getFragmentStack().size() - 2));
finishFragment();
if (this.screenType == 0) {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didApplyNewTheme, new Object[]{previousTheme, accent, Boolean.valueOf(this.deleteOnCancel)});
}
Theme.turnOffAutoNight(baseFragment);
}
public boolean insideBottomSheet() {
INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
return (iNavigationLayout == null || iNavigationLayout.getBottomSheet() == null) ? false : true;
}
public final void updateIntensity() {
this.backgroundImage.getImageReceiver().setAlpha(Math.abs(this.currentIntensity));
this.backgroundImage.invalidate();
this.patternsListView.invalidateViews();
if (this.currentIntensity >= 0.0f) {
this.backgroundImage.getImageReceiver().setGradientBitmap((Bitmap) null);
} else {
if (Build.VERSION.SDK_INT >= 29) {
this.backgroundImage.getImageReceiver().setBlendMode((Object) null);
}
if (this.backgroundImage.getBackground() instanceof MotionBackgroundDrawable) {
this.backgroundImage.getImageReceiver().setGradientBitmap(this.backgroundImage.getBackground().getBitmap());
}
}
ThemeDelegate themeDelegate = this.themeDelegate;
int i = this.checkColor;
themeDelegate.applyChatServiceMessageColor(new int[]{i, i, i, i}, this.backgroundImage.getBackground(), this.backgroundImage.getBackground(), Float.valueOf(this.currentIntensity));
invalidateBlur();
}
public final void updateApplyButton1(boolean animated) {
long j = this.dialogId;
if (j > 0) {
this.applyButton1.setText(LocaleController.getString(R.string.ApplyWallpaperForMe));
return;
}
if (j < 0) {
TLRPC.Chat chat = getMessagesController().getChat(Long.valueOf(-this.dialogId));
if (chat != null) {
this.applyButton1.setText(LocaleController.formatString(R.string.ApplyWallpaperForChannel, new Object[]{chat.title}));
TL_stories.TL_premium_boostsStatus tL_premium_boostsStatus = this.boostsStatus;
if (tL_premium_boostsStatus != null && tL_premium_boostsStatus.level < getCustomWallpaperLevelMin()) {
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("l");
if (this.lockSpan == null) {
ColoredImageSpan coloredImageSpan = new ColoredImageSpan(R.drawable.mini_switch_lock);
this.lockSpan = coloredImageSpan;
coloredImageSpan.setTopOffset(1);
}
spannableStringBuilder.setSpan(this.lockSpan, 0, 1, 33);
spannableStringBuilder.append((CharSequence) " ").append((CharSequence) LocaleController.formatPluralString("ReactionLevelRequiredBtn", getCustomWallpaperLevelMin(), new Object[0]));
this.applyButton1.setSubText(spannableStringBuilder, animated);
return;
}
if (this.boostsStatus == null) {
checkBoostsLevel();
return;
} else {
this.applyButton1.setSubText(null, animated);
return;
}
}
this.applyButton1.setText(LocaleController.formatString(R.string.ApplyWallpaperForChannel, new Object[]{LocaleController.getString(R.string.AccDescrChannel).toLowerCase()}));
return;
}
this.applyButton1.setText(LocaleController.getString(R.string.ApplyWallpaper));
}
public final int getCustomWallpaperLevelMin() {
if (ChatObject.isChannelAndNotMegaGroup(-this.dialogId, ((BaseFragment) this).currentAccount)) {
return getMessagesController().channelCustomWallpaperLevelMin;
}
return getMessagesController().groupCustomWallpaperLevelMin;
}
public final void applyWallpaperBackground(boolean r33) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ThemePreviewActivity.applyWallpaperBackground(boolean):void");
}
public void lambda$applyWallpaperBackground$20(ChannelBoostsController.CanApplyBoost canApplyBoost) {
if (getContext() == null) {
return;
}
?? limitReachedBottomSheet = new LimitReachedBottomSheet(this, getContext(), 23, ((BaseFragment) this).currentAccount, getResourceProvider());
limitReachedBottomSheet.setCanApplyBoost(canApplyBoost);
limitReachedBottomSheet.setBoostsStats(this.boostsStatus, true);
limitReachedBottomSheet.setDialogId(this.dialogId);
if (!insideBottomSheet()) {
limitReachedBottomSheet.showStatisticButtonInLink(new Runnable() {
@Override
public final void run() {
ThemePreviewActivity.this.lambda$applyWallpaperBackground$19();
}
});
}
showDialog((Dialog) limitReachedBottomSheet);
}
public void lambda$applyWallpaperBackground$19() {
presentFragment(StatisticActivity.create(getMessagesController().getChat(Long.valueOf(-this.dialogId))));
}
public final void onColorsRotate() {
if (this.screenType == 2) {
this.backgroundRotation += 45;
while (true) {
int i = this.backgroundRotation;
if (i >= 360) {
this.backgroundRotation = i - 360;
} else {
setBackgroundColor(this.backgroundColor, 0, true, true);
return;
}
}
} else {
Theme.ThemeAccent themeAccent = this.accent;
if (themeAccent == null) {
return;
}
themeAccent.backgroundRotation += 45;
while (true) {
Theme.ThemeAccent themeAccent2 = this.accent;
int i2 = themeAccent2.backgroundRotation;
if (i2 >= 360) {
themeAccent2.backgroundRotation = i2 - 360;
} else {
Theme.refreshThemeColors();
return;
}
}
}
}
public final void selectColorType(int id) {
selectColorType(id, true);
}
public final void selectColorType(int id, boolean ask) {
int i;
if (getParentActivity() == null || this.colorType == id || this.patternViewAnimation != null || this.accent == null) {
return;
}
if (ask && id == 2 && (Theme.hasCustomWallpaper() || this.accent.backgroundOverrideColor == 4294967296L)) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("ChangeChatBackground", R.string.ChangeChatBackground));
if (!Theme.hasCustomWallpaper() || Theme.isCustomWallpaperColor()) {
builder.setMessage(LocaleController.getString("ChangeColorToColor", R.string.ChangeColorToColor));
builder.setPositiveButton(LocaleController.getString("Reset", R.string.Reset), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i2) {
ThemePreviewActivity.this.lambda$selectColorType$22(dialogInterface, i2);
}
});
builder.setNegativeButton(LocaleController.getString("Continue", R.string.Continue), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i2) {
ThemePreviewActivity.this.lambda$selectColorType$23(dialogInterface, i2);
}
});
} else {
builder.setMessage(LocaleController.getString("ChangeWallpaperToColor", R.string.ChangeWallpaperToColor));
builder.setPositiveButton(LocaleController.getString("Change", R.string.Change), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i2) {
ThemePreviewActivity.this.lambda$selectColorType$24(dialogInterface, i2);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
}
showDialog(builder.create());
return;
}
int i2 = this.colorType;
this.colorType = id;
if (id == 1) {
this.dropDown.setText(LocaleController.getString("ColorPickerMainColor", R.string.ColorPickerMainColor));
this.colorPicker.setType(1, hasChanges(1), 2, this.accent.accentColor2 != 0 ? 2 : 1, false, 0, false);
this.colorPicker.setColor(this.accent.accentColor, 0);
int i3 = this.accent.accentColor2;
if (i3 != 0) {
this.colorPicker.setColor(i3, 1);
}
if (i2 == 2 || (i2 == 3 && this.accent.myMessagesGradientAccentColor2 != 0)) {
this.messagesAdapter.notifyItemRemoved(0);
}
} else if (id == 2) {
this.dropDown.setText(LocaleController.getString("ColorPickerBackground", R.string.ColorPickerBackground));
int themedColor = getThemedColor(Theme.key_chat_wallpaper);
int i4 = Theme.key_chat_wallpaper_gradient_to1;
int themedColor2 = Theme.hasThemeKey(i4) ? getThemedColor(i4) : 0;
int i5 = Theme.key_chat_wallpaper_gradient_to2;
int themedColor3 = Theme.hasThemeKey(i5) ? getThemedColor(i5) : 0;
int i6 = Theme.key_chat_wallpaper_gradient_to3;
int themedColor4 = Theme.hasThemeKey(i6) ? getThemedColor(i6) : 0;
Theme.ThemeAccent themeAccent = this.accent;
long j = themeAccent.backgroundGradientOverrideColor1;
int i7 = (int) j;
if (i7 == 0 && j != 0) {
themedColor2 = 0;
}
long j2 = themeAccent.backgroundGradientOverrideColor2;
int i8 = (int) j2;
if (i8 == 0 && j2 != 0) {
themedColor3 = 0;
}
long j3 = themeAccent.backgroundGradientOverrideColor3;
int i9 = (int) j3;
if (i9 == 0 && j3 != 0) {
themedColor4 = 0;
}
int i10 = (int) themeAccent.backgroundOverrideColor;
this.colorPicker.setType(2, hasChanges(2), 4, (i7 == 0 && themedColor2 == 0) ? 1 : (i9 == 0 && themedColor4 == 0) ? (i8 == 0 && themedColor3 == 0) ? 2 : 3 : 4, false, this.accent.backgroundRotation, false);
ColorPicker colorPicker = this.colorPicker;
if (i9 == 0) {
i9 = themedColor4;
}
colorPicker.setColor(i9, 3);
ColorPicker colorPicker2 = this.colorPicker;
if (i8 == 0) {
i8 = themedColor3;
}
colorPicker2.setColor(i8, 2);
ColorPicker colorPicker3 = this.colorPicker;
if (i7 == 0) {
i7 = themedColor2;
}
colorPicker3.setColor(i7, 1);
ColorPicker colorPicker4 = this.colorPicker;
if (i10 != 0) {
themedColor = i10;
}
colorPicker4.setColor(themedColor, 0);
if (i2 == 1 || this.accent.myMessagesGradientAccentColor2 == 0) {
this.messagesAdapter.notifyItemInserted(0);
} else {
this.messagesAdapter.notifyItemChanged(0);
}
this.listView2.smoothScrollBy(0, AndroidUtilities.dp(60.0f));
} else if (id == 3) {
this.dropDown.setText(LocaleController.getString("ColorPickerMyMessages", R.string.ColorPickerMyMessages));
Theme.ThemeAccent themeAccent2 = this.accent;
if (themeAccent2.myMessagesGradientAccentColor1 == 0) {
i = 1;
} else if (themeAccent2.myMessagesGradientAccentColor3 != 0) {
i = 4;
} else {
i = themeAccent2.myMessagesGradientAccentColor2 != 0 ? 3 : 2;
}
this.colorPicker.setType(2, hasChanges(3), 4, i, true, 0, false);
this.colorPicker.setColor(this.accent.myMessagesGradientAccentColor3, 3);
this.colorPicker.setColor(this.accent.myMessagesGradientAccentColor2, 2);
this.colorPicker.setColor(this.accent.myMessagesGradientAccentColor1, 1);
ColorPicker colorPicker5 = this.colorPicker;
Theme.ThemeAccent themeAccent3 = this.accent;
int i11 = themeAccent3.myMessagesAccentColor;
if (i11 == 0) {
i11 = themeAccent3.accentColor;
}
colorPicker5.setColor(i11, 0);
this.messagesCheckBoxView[1].setColor(0, this.accent.myMessagesAccentColor);
this.messagesCheckBoxView[1].setColor(1, this.accent.myMessagesGradientAccentColor1);
this.messagesCheckBoxView[1].setColor(2, this.accent.myMessagesGradientAccentColor2);
this.messagesCheckBoxView[1].setColor(3, this.accent.myMessagesGradientAccentColor3);
if (this.accent.myMessagesGradientAccentColor2 != 0) {
if (i2 == 1) {
this.messagesAdapter.notifyItemInserted(0);
} else {
this.messagesAdapter.notifyItemChanged(0);
}
} else if (i2 == 2) {
this.messagesAdapter.notifyItemRemoved(0);
}
this.listView2.smoothScrollBy(0, AndroidUtilities.dp(60.0f));
showAnimationHint();
}
if (id == 1 || id == 3) {
if (i2 == 2 && this.patternLayout[1].getVisibility() == 0) {
showPatternsView(0, true, true);
}
if (id == 1) {
if (this.applyingTheme.isDark()) {
this.colorPicker.setMinBrightness(0.2f);
return;
} else {
this.colorPicker.setMinBrightness(0.05f);
this.colorPicker.setMaxBrightness(0.8f);
return;
}
}
this.colorPicker.setMinBrightness(0.0f);
this.colorPicker.setMaxBrightness(1.0f);
return;
}
this.colorPicker.setMinBrightness(0.0f);
this.colorPicker.setMaxBrightness(1.0f);
}
public void lambda$selectColorType$22(DialogInterface dialogInterface, int i) {
Theme.ThemeAccent themeAccent = this.accent;
if (themeAccent.backgroundOverrideColor == 4294967296L) {
themeAccent.backgroundOverrideColor = 0L;
themeAccent.backgroundGradientOverrideColor1 = 0L;
themeAccent.backgroundGradientOverrideColor2 = 0L;
themeAccent.backgroundGradientOverrideColor3 = 0L;
updatePlayAnimationView(false);
Theme.refreshThemeColors();
}
this.removeBackgroundOverride = true;
Theme.resetCustomWallpaper(true);
selectColorType(2, false);
}
public void lambda$selectColorType$23(DialogInterface dialogInterface, int i) {
if (Theme.isCustomWallpaperColor()) {
Theme.ThemeAccent themeAccent = this.accent;
Theme.OverrideWallpaperInfo overrideWallpaperInfo = themeAccent.overrideWallpaper;
themeAccent.backgroundOverrideColor = overrideWallpaperInfo.color;
themeAccent.backgroundGradientOverrideColor1 = overrideWallpaperInfo.gradientColor1;
themeAccent.backgroundGradientOverrideColor2 = overrideWallpaperInfo.gradientColor2;
themeAccent.backgroundGradientOverrideColor3 = overrideWallpaperInfo.gradientColor3;
themeAccent.backgroundRotation = overrideWallpaperInfo.rotation;
String str = overrideWallpaperInfo.slug;
themeAccent.patternSlug = str;
float f = overrideWallpaperInfo.intensity;
themeAccent.patternIntensity = f;
this.currentIntensity = f;
if (str != null && !"c".equals(str)) {
int size = this.patterns.size();
int i2 = 0;
while (true) {
if (i2 >= size) {
break;
}
TLRPC.TL_wallPaper tL_wallPaper = (TLRPC.TL_wallPaper) this.patterns.get(i2);
if (((TLRPC.WallPaper) tL_wallPaper).pattern && this.accent.patternSlug.equals(((TLRPC.WallPaper) tL_wallPaper).slug)) {
this.selectedPattern = tL_wallPaper;
break;
}
i2++;
}
} else {
this.selectedPattern = null;
}
this.removeBackgroundOverride = true;
this.backgroundCheckBoxView[1].setChecked(this.selectedPattern != null, true);
updatePlayAnimationView(false);
Theme.refreshThemeColors();
}
MotionBackgroundDrawable background = this.backgroundImage.getBackground();
if (background instanceof MotionBackgroundDrawable) {
MotionBackgroundDrawable motionBackgroundDrawable = background;
motionBackgroundDrawable.setPatternBitmap(100, (Bitmap) null);
if (Theme.getActiveTheme().isDark()) {
if (this.currentIntensity < 0.0f) {
this.backgroundImage.getImageReceiver().setGradientBitmap(motionBackgroundDrawable.getBitmap());
}
SeekBarView seekBarView = this.intensitySeekBar;
if (seekBarView != null) {
seekBarView.setTwoSided(true);
}
} else {
float f2 = this.currentIntensity;
if (f2 < 0.0f) {
this.currentIntensity = -f2;
}
}
}
SeekBarView seekBarView2 = this.intensitySeekBar;
if (seekBarView2 != null) {
seekBarView2.setProgress(this.currentIntensity);
}
Theme.resetCustomWallpaper(true);
selectColorType(2, false);
}
public void lambda$selectColorType$24(DialogInterface dialogInterface, int i) {
Theme.ThemeAccent themeAccent = this.accent;
if (themeAccent.backgroundOverrideColor == 4294967296L) {
themeAccent.backgroundOverrideColor = 0L;
themeAccent.backgroundGradientOverrideColor1 = 0L;
themeAccent.backgroundGradientOverrideColor2 = 0L;
themeAccent.backgroundGradientOverrideColor3 = 0L;
updatePlayAnimationView(false);
Theme.refreshThemeColors();
}
this.removeBackgroundOverride = true;
Theme.resetCustomWallpaper(true);
selectColorType(2, false);
}
public final void selectPattern(int position) {
TLRPC.TL_wallPaper tL_wallPaper;
if (position >= 0 && position < this.patterns.size()) {
tL_wallPaper = (TLRPC.TL_wallPaper) this.patterns.get(position);
} else {
tL_wallPaper = this.lastSelectedPattern;
}
if (tL_wallPaper == null) {
return;
}
ValueAnimator valueAnimator = this.valueAnimator;
if (valueAnimator != null) {
valueAnimator.removeAllListeners();
this.valueAnimator.cancel();
}
BackgroundView[] backgroundViewArr = this.backgroundImages;
Object[] objArr = backgroundViewArr[0];
backgroundViewArr[0] = backgroundViewArr[1];
backgroundViewArr[1] = objArr;
this.page2.removeView(backgroundViewArr[0]);
this.page2.addView(this.backgroundImages[0], this.page2.indexOfChild(this.backgroundImages[1]) + 1);
BackgroundView[] backgroundViewArr2 = this.backgroundImages;
BackgroundView backgroundView = backgroundViewArr2[0];
this.backgroundImage = backgroundView;
backgroundView.setBackground(backgroundViewArr2[1].getBackground());
updateIntensity();
this.backgroundImages[1].setVisibility(0);
this.backgroundImages[1].setAlpha(1.0f);
this.backgroundImage.setVisibility(0);
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
this.valueAnimator = ofFloat;
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
ThemePreviewActivity.this.backgroundImage.setAlpha(((Float) animation.getAnimatedValue()).floatValue());
}
});
this.valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
ThemePreviewActivity.this.backgroundImage.invalidate();
ThemePreviewActivity.this.backgroundImages[1].setVisibility(8);
ThemePreviewActivity.this.valueAnimator = null;
}
});
this.valueAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT);
this.valueAnimator.setDuration(300L);
this.valueAnimator.start();
this.backgroundImage.getImageReceiver().setCrossfadeDuration(300);
this.backgroundImage.getImageReceiver().setImage(ImageLocation.getForDocument(((TLRPC.WallPaper) tL_wallPaper).document), this.imageFilter, (ImageLocation) null, (String) null, (Drawable) null, ((TLRPC.WallPaper) tL_wallPaper).document.size, "jpg", tL_wallPaper, 1);
this.backgroundImage.onNewImageSet();
this.selectedPattern = tL_wallPaper;
this.isMotion = this.backgroundCheckBoxView[2].isChecked();
updateButtonState(false, true);
}
public final void saveAccentWallpaper() {
Theme.ThemeAccent themeAccent = this.accent;
if (themeAccent == null || TextUtils.isEmpty(themeAccent.patternSlug)) {
return;
}
try {
File pathToWallpaper = this.accent.getPathToWallpaper();
Drawable background = this.backgroundImage.getBackground();
Bitmap bitmap = this.backgroundImage.getImageReceiver().getBitmap();
if (background instanceof MotionBackgroundDrawable) {
FileOutputStream fileOutputStream = new FileOutputStream(pathToWallpaper);
bitmap.compress(Bitmap.CompressFormat.PNG, 87, fileOutputStream);
fileOutputStream.close();
} else {
Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
background.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
background.draw(canvas);
Paint paint = new Paint(2);
paint.setColorFilter(new PorterDuffColorFilter(this.patternColor, this.blendMode));
paint.setAlpha((int) (this.currentIntensity * 255.0f));
canvas.drawBitmap(bitmap, 0.0f, 0.0f, paint);
FileOutputStream fileOutputStream2 = new FileOutputStream(pathToWallpaper);
createBitmap.compress(Bitmap.CompressFormat.JPEG, 87, fileOutputStream2);
fileOutputStream2.close();
}
} catch (Throwable th) {
FileLog.e(th);
}
}
public final boolean hasChanges(int type) {
int defaultAccentColor;
long j;
if (this.editingTheme) {
return false;
}
if (type == 1 || type == 2) {
long j2 = this.backupBackgroundOverrideColor;
if (j2 == 0) {
int defaultAccentColor2 = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper);
int i = (int) this.accent.backgroundOverrideColor;
if (i == 0) {
i = defaultAccentColor2;
}
if (i != defaultAccentColor2) {
return true;
}
} else if (j2 != this.accent.backgroundOverrideColor) {
return true;
}
long j3 = this.backupBackgroundGradientOverrideColor1;
if (j3 == 0 && this.backupBackgroundGradientOverrideColor2 == 0 && this.backupBackgroundGradientOverrideColor3 == 0) {
for (int i2 = 0; i2 < 3; i2++) {
if (i2 == 0) {
defaultAccentColor = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to1);
j = this.accent.backgroundGradientOverrideColor1;
} else if (i2 == 1) {
defaultAccentColor = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to2);
j = this.accent.backgroundGradientOverrideColor2;
} else {
defaultAccentColor = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to3);
j = this.accent.backgroundGradientOverrideColor3;
}
int i3 = (int) j;
if (i3 == 0 && j != 0) {
i3 = 0;
} else if (i3 == 0) {
i3 = defaultAccentColor;
}
if (i3 != defaultAccentColor) {
return true;
}
}
} else {
Theme.ThemeAccent themeAccent = this.accent;
if (j3 != themeAccent.backgroundGradientOverrideColor1 || this.backupBackgroundGradientOverrideColor2 != themeAccent.backgroundGradientOverrideColor2 || this.backupBackgroundGradientOverrideColor3 != themeAccent.backgroundGradientOverrideColor3) {
return true;
}
}
if (this.accent.backgroundRotation != this.backupBackgroundRotation) {
return true;
}
}
if (type == 1 || type == 3) {
int i4 = this.backupAccentColor;
Theme.ThemeAccent themeAccent2 = this.accent;
if (i4 != themeAccent2.accentColor2) {
return true;
}
int i5 = this.backupMyMessagesAccentColor;
if (i5 != 0) {
if (i5 != themeAccent2.myMessagesAccentColor) {
return true;
}
} else {
int i6 = themeAccent2.myMessagesAccentColor;
if (i6 != 0 && i6 != themeAccent2.accentColor) {
return true;
}
}
int i7 = this.backupMyMessagesGradientAccentColor1;
if (i7 != 0) {
if (i7 != themeAccent2.myMessagesGradientAccentColor1) {
return true;
}
} else if (themeAccent2.myMessagesGradientAccentColor1 != 0) {
return true;
}
int i8 = this.backupMyMessagesGradientAccentColor2;
if (i8 != 0) {
if (i8 != themeAccent2.myMessagesGradientAccentColor2) {
return true;
}
} else if (themeAccent2.myMessagesGradientAccentColor2 != 0) {
return true;
}
int i9 = this.backupMyMessagesGradientAccentColor3;
if (i9 != 0) {
if (i9 != themeAccent2.myMessagesGradientAccentColor3) {
return true;
}
} else if (themeAccent2.myMessagesGradientAccentColor3 != 0) {
return true;
}
if (this.backupMyMessagesAnimated != themeAccent2.myMessagesAnimated) {
return true;
}
}
return false;
}
public final boolean checkDiscard() {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ThemePreviewActivity.checkDiscard():boolean");
}
public void lambda$checkDiscard$25(DialogInterface dialogInterface, int i) {
this.actionBar2.getActionBarMenuOnItemClick().onItemClick(4);
}
public void lambda$checkDiscard$26(DialogInterface dialogInterface, int i) {
cancelThemeApply(false);
}
public boolean onFragmentCreate() {
NotificationCenter.getInstance(((BaseFragment) this).currentAccount).addObserver(this, NotificationCenter.chatWasBoostedByUser);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiLoaded);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.invalidateMotionBackground);
getNotificationCenter().addObserver(this, NotificationCenter.wallpaperSettedToUser);
int i = this.screenType;
if (i == 1 || i == 0) {
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetNewWallpapper);
}
int i2 = this.screenType;
if (i2 == 2 || i2 == 1) {
Theme.setChangingWallpaper(true);
}
if (this.screenType != 0 || this.accent != null) {
Point point = AndroidUtilities.displaySize;
int min = Math.min(point.x, point.y);
Point point2 = AndroidUtilities.displaySize;
this.imageFilter = ((int) (min / AndroidUtilities.density)) + "_" + ((int) (Math.max(point2.x, point2.y) / AndroidUtilities.density)) + "_f";
Point point3 = AndroidUtilities.displaySize;
this.maxWallpaperSize = Math.max(point3.x, point3.y);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.wallpapersNeedReload);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.wallpapersDidLoad);
this.TAG = DownloadController.getInstance(((BaseFragment) this).currentAccount).generateObserverTag();
if (this.patterns == null) {
this.patterns = new ArrayList<>();
MessagesStorage.getInstance(((BaseFragment) this).currentAccount).getWallpapers();
}
} else {
this.isMotion = Theme.isWallpaperMotion();
}
return super.onFragmentCreate();
}
public void onFragmentDestroy() {
NotificationCenter.getInstance(((BaseFragment) this).currentAccount).removeObserver(this, NotificationCenter.chatWasBoostedByUser);
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiLoaded);
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.invalidateMotionBackground);
getNotificationCenter().removeObserver(this, NotificationCenter.wallpaperSettedToUser);
FrameLayout frameLayout = this.frameLayout;
if (frameLayout != null && this.onGlobalLayoutListener != null) {
frameLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this.onGlobalLayoutListener);
}
int i = this.screenType;
if ((i == 2 || i == 1) && this.onSwitchDayNightDelegate == null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
Theme.setChangingWallpaper(false);
}
});
}
int i2 = this.screenType;
if (i2 == 2) {
Bitmap bitmap = this.blurredBitmap;
if (bitmap != null) {
bitmap.recycle();
this.blurredBitmap = null;
}
this.themeDelegate.applyChatServiceMessageColor();
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewWallpapper, new Object[0]);
} else if (i2 == 1 || i2 == 0) {
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetNewWallpapper);
}
if (this.screenType != 0 || this.accent != null) {
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.wallpapersNeedReload);
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.wallpapersDidLoad);
}
super.onFragmentDestroy();
checkBlur(null);
}
public final BitmapDrawable checkBlur(Drawable d) {
WeakReference<Drawable> weakReference = this.lastDrawableToBlur;
if (weakReference != null && weakReference.get() == d) {
return this.blurredDrawable;
}
WeakReference<Drawable> weakReference2 = this.lastDrawableToBlur;
if (weakReference2 != null) {
weakReference2.clear();
}
this.lastDrawableToBlur = null;
if (d == null || d.getIntrinsicWidth() == 0 || d.getIntrinsicHeight() == 0) {
this.blurredDrawable = null;
return null;
}
this.lastDrawableToBlur = new WeakReference<>(d);
int intrinsicWidth = (int) ((d.getIntrinsicWidth() / d.getIntrinsicHeight()) * 24.0f);
Bitmap createBitmap = Bitmap.createBitmap(intrinsicWidth, 24, Bitmap.Config.ARGB_8888);
d.setBounds(0, 0, intrinsicWidth, 24);
if (Build.VERSION.SDK_INT >= 21) {
ColorFilter colorFilter = d.getColorFilter();
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(1.3f);
AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix, 0.94f);
d.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
d.draw(new Canvas(createBitmap));
d.setColorFilter(colorFilter);
} else {
d.draw(new Canvas(createBitmap));
}
Utilities.blurBitmap(createBitmap, 3, 1, createBitmap.getWidth(), createBitmap.getHeight(), createBitmap.getRowBytes());
BitmapDrawable bitmapDrawable = new BitmapDrawable(getContext().getResources(), createBitmap);
this.blurredDrawable = bitmapDrawable;
bitmapDrawable.setFilterBitmap(true);
return this.blurredDrawable;
}
public final void invalidateBlur() {
FrameLayout frameLayout = this.dimmingSliderContainer;
if (frameLayout != null) {
frameLayout.invalidate();
}
FrameLayout frameLayout2 = this.backgroundButtonsContainer;
if (frameLayout2 != null) {
int childCount = frameLayout2.getChildCount();
for (int i = 0; i < childCount; i++) {
this.backgroundButtonsContainer.getChildAt(i).invalidate();
}
}
FrameLayout frameLayout3 = this.messagesButtonsContainer;
if (frameLayout3 != null) {
int childCount2 = frameLayout3.getChildCount();
for (int i2 = 0; i2 < childCount2; i2++) {
this.messagesButtonsContainer.getChildAt(i2).invalidate();
}
}
if (this.backgroundCheckBoxView != null) {
int i3 = 0;
while (true) {
WallpaperCheckBoxView[] wallpaperCheckBoxViewArr = this.backgroundCheckBoxView;
if (i3 >= wallpaperCheckBoxViewArr.length) {
break;
}
if (wallpaperCheckBoxViewArr[i3] != null) {
wallpaperCheckBoxViewArr[i3].setDimAmount(this.shouldShowBrightnessControll ? this.dimAmount * this.progressToDarkTheme : 0.0f);
this.backgroundCheckBoxView[i3].invalidate();
}
i3++;
}
}
if (this.listView != null) {
for (int i4 = 0; i4 < this.listView.getChildCount(); i4++) {
View childAt = this.listView.getChildAt(i4);
if (childAt instanceof ChatActionCell) {
setVisiblePart((ChatActionCell) childAt);
childAt.invalidate();
}
}
}
if (this.listView2 != null) {
for (int i5 = 0; i5 < this.listView2.getChildCount(); i5++) {
View childAt2 = this.listView2.getChildAt(i5);
if (childAt2 instanceof ChatActionCell) {
setVisiblePart((ChatActionCell) childAt2);
childAt2.invalidate();
}
}
}
BlurButton blurButton = this.applyButton1;
if (blurButton != null) {
blurButton.invalidate();
}
BlurButton blurButton2 = this.applyButton2;
if (blurButton2 != null) {
blurButton2.invalidate();
}
FrameLayout frameLayout4 = this.bottomOverlayChat;
if (frameLayout4 != null) {
frameLayout4.invalidate();
}
}
public final void setVisiblePart(ChatActionCell cell) {
float f;
float f2;
BackgroundView backgroundView = this.backgroundImage;
if (backgroundView == null) {
return;
}
if (backgroundView != null) {
if (this.themeDelegate.serviceBitmap != null) {
float width = this.themeDelegate.serviceBitmap.getWidth();
f2 = ((this.backgroundImage.getMeasuredWidth() - (width * Math.max(this.backgroundImage.getMeasuredWidth() / width, this.backgroundImage.getMeasuredHeight() / this.themeDelegate.serviceBitmap.getHeight()))) / 2.0f) + this.currentScrollOffset + 0.0f;
} else {
f2 = this.currentScrollOffset + 0.0f;
}
f = (-this.backgroundImage.ty) + 0.0f;
} else {
f = 0.0f;
f2 = 0.0f;
}
cell.setVisiblePart(cell.getY() - f, f2, this.backgroundImage.getMeasuredHeight(), this.shouldShowBrightnessControll ? this.dimAmount * this.progressToDarkTheme : 0.0f);
}
public void onTransitionAnimationStart(boolean isOpen, boolean backward) {
super.onTransitionAnimationStart(isOpen, backward);
if (isOpen || this.screenType != 2) {
return;
}
this.themeDelegate.applyChatServiceMessageColor();
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewWallpapper, new Object[0]);
}
public void onBottomSheetCreated() {
super.onBottomSheetCreated();
INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
if (iNavigationLayout == null || iNavigationLayout.getBottomSheet() == null) {
return;
}
((BaseFragment) this).parentLayout.getBottomSheet().fixNavigationBar(getThemedColor(Theme.key_dialogBackground));
if (this.screenType != 2 || this.dialogId == 0) {
return;
}
((BaseFragment) this).parentLayout.getBottomSheet().setOverlayNavBarColor(-16777216);
}
public void onResume() {
super.onResume();
DialogsAdapter dialogsAdapter = this.dialogsAdapter;
if (dialogsAdapter != null) {
dialogsAdapter.notifyDataSetChanged();
}
MessagesAdapter messagesAdapter = this.messagesAdapter;
if (messagesAdapter != null) {
messagesAdapter.notifyDataSetChanged();
}
if (this.isMotion) {
this.parallaxEffect.setEnabled(true);
}
Theme.disallowChangeServiceMessageColor = true;
}
public void onPause() {
super.onPause();
if (this.isMotion) {
this.parallaxEffect.setEnabled(false);
}
Theme.disallowChangeServiceMessageColor = false;
}
public boolean isSwipeBackEnabled(MotionEvent event) {
if (this.screenType != 2) {
return false;
}
return !this.hasScrollingBackground || event == null || event.getY() <= ((float) (AndroidUtilities.statusBarHeight + ActionBar.getCurrentActionBarHeight()));
}
public void onFailedDownload(String fileName, boolean canceled) {
updateButtonState(true, canceled);
}
public void onSuccessDownload(String fileName) {
updateButtonState(false, true);
}
public int getObserverTag() {
return this.TAG;
}
public final void updateBlurred() {
if (this.isBlurred && this.blurredBitmap == null) {
Bitmap bitmap = this.currentWallpaperBitmap;
if (bitmap != null) {
this.originalBitmap = bitmap;
this.blurredBitmap = Utilities.blurWallpaper(bitmap);
} else {
ImageReceiver imageReceiver = this.backgroundImage.getImageReceiver();
if (imageReceiver.hasNotThumb() || imageReceiver.hasStaticThumb()) {
this.originalBitmap = imageReceiver.getBitmap();
this.blurredBitmap = Utilities.blurWallpaper(imageReceiver.getBitmap());
}
}
}
if (this.isBlurred) {
Bitmap bitmap2 = this.blurredBitmap;
if (bitmap2 != null) {
this.backgroundImage.setImageBitmap(bitmap2);
return;
}
return;
}
setCurrentImage(false);
}
public boolean onBackPressed() {
if (!checkDiscard()) {
return false;
}
cancelThemeApply(true);
return true;
}
public void didReceivedNotification(int id, int account, Object... args) {
TLRPC.TL_wallPaper tL_wallPaper;
String str;
if (id == NotificationCenter.chatWasBoostedByUser) {
if (this.dialogId == ((Long) args[2]).longValue()) {
this.boostsStatus = (TL_stories.TL_premium_boostsStatus) args[0];
updateApplyButton1(true);
return;
}
return;
}
if (id == NotificationCenter.emojiLoaded) {
RecyclerListView recyclerListView = this.listView;
if (recyclerListView == null) {
return;
}
int childCount = recyclerListView.getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = this.listView.getChildAt(i);
if (childAt instanceof DialogCell) {
((DialogCell) childAt).update(0);
}
}
return;
}
if (id == NotificationCenter.invalidateMotionBackground) {
RecyclerListView recyclerListView2 = this.listView2;
if (recyclerListView2 != null) {
recyclerListView2.invalidateViews();
return;
}
return;
}
if (id == NotificationCenter.didSetNewWallpapper) {
if (this.page2 != null) {
setCurrentImage(true);
return;
}
return;
}
if (id == NotificationCenter.wallpapersNeedReload) {
Object obj = this.currentWallpaper;
if (obj instanceof WallpapersListActivity.FileWallpaper) {
WallpapersListActivity.FileWallpaper fileWallpaper = (WallpapersListActivity.FileWallpaper) obj;
if (fileWallpaper.slug == null) {
fileWallpaper.slug = (String) args[0];
return;
}
return;
}
return;
}
long j = 0;
if (id == NotificationCenter.wallpapersDidLoad) {
ArrayList arrayList = (ArrayList) args[0];
this.patterns.clear();
this.patternsDict.clear();
int size = arrayList.size();
boolean z = false;
for (int i2 = 0; i2 < size; i2++) {
TLRPC.TL_wallPaper tL_wallPaper2 = (TLRPC.WallPaper) arrayList.get(i2);
if ((tL_wallPaper2 instanceof TLRPC.TL_wallPaper) && ((TLRPC.WallPaper) tL_wallPaper2).pattern) {
TLRPC.Document document = ((TLRPC.WallPaper) tL_wallPaper2).document;
if (document != null && !this.patternsDict.containsKey(Long.valueOf(document.id))) {
this.patterns.add(tL_wallPaper2);
this.patternsDict.put(Long.valueOf(((TLRPC.WallPaper) tL_wallPaper2).document.id), tL_wallPaper2);
}
Theme.ThemeAccent themeAccent = this.accent;
if (themeAccent != null && (str = themeAccent.patternSlug) != null && str.equals(((TLRPC.WallPaper) tL_wallPaper2).slug)) {
this.selectedPattern = tL_wallPaper2;
setCurrentImage(false);
updateButtonState(false, false);
} else if (this.accent == null) {
TLRPC.TL_wallPaper tL_wallPaper3 = this.selectedPattern;
if (tL_wallPaper3 != null) {
String str2 = ((TLRPC.WallPaper) tL_wallPaper3).slug;
if (str2 != null) {
if (!str2.equals(((TLRPC.WallPaper) tL_wallPaper2).slug)) {
}
}
}
}
z = true;
}
}
if (!z && (tL_wallPaper = this.selectedPattern) != null) {
this.patterns.add(0, tL_wallPaper);
}
PatternsAdapter patternsAdapter = this.patternsAdapter;
if (patternsAdapter != null) {
patternsAdapter.notifyDataSetChanged();
}
int size2 = arrayList.size();
for (int i3 = 0; i3 < size2; i3++) {
TLRPC.WallPaper wallPaper = (TLRPC.WallPaper) arrayList.get(i3);
if (wallPaper instanceof TLRPC.TL_wallPaper) {
j = MediaDataController.calcHash(j, wallPaper.id);
}
}
TLRPC.TL_account_getWallPapers tL_account_getWallPapers = new TLRPC.TL_account_getWallPapers();
tL_account_getWallPapers.hash = j;
ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).bindRequestToGuid(ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).sendRequest(tL_account_getWallPapers, new RequestDelegate() {
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ThemePreviewActivity.this.lambda$didReceivedNotification$31(tLObject, tL_error);
}
}), ((BaseFragment) this).classGuid);
return;
}
if (id != NotificationCenter.wallpaperSettedToUser || this.dialogId == 0) {
return;
}
finishFragment();
}
public void lambda$didReceivedNotification$31(final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ThemePreviewActivity.this.lambda$didReceivedNotification$30(tLObject);
}
});
}
public void lambda$didReceivedNotification$30(TLObject tLObject) {
Theme.ThemeAccent themeAccent;
TLRPC.TL_wallPaper tL_wallPaper;
String str;
if (tLObject instanceof TLRPC.TL_account_wallPapers) {
TLRPC.TL_account_wallPapers tL_account_wallPapers = (TLRPC.TL_account_wallPapers) tLObject;
this.patterns.clear();
this.patternsDict.clear();
int size = tL_account_wallPapers.wallpapers.size();
boolean z = false;
for (int i = 0; i < size; i++) {
if (tL_account_wallPapers.wallpapers.get(i) instanceof TLRPC.TL_wallPaper) {
TLRPC.TL_wallPaper tL_wallPaper2 = (TLRPC.TL_wallPaper) tL_account_wallPapers.wallpapers.get(i);
if (((TLRPC.WallPaper) tL_wallPaper2).pattern) {
TLRPC.Document document = ((TLRPC.WallPaper) tL_wallPaper2).document;
if (document != null && !this.patternsDict.containsKey(Long.valueOf(document.id))) {
this.patterns.add(tL_wallPaper2);
this.patternsDict.put(Long.valueOf(((TLRPC.WallPaper) tL_wallPaper2).document.id), tL_wallPaper2);
}
Theme.ThemeAccent themeAccent2 = this.accent;
if (themeAccent2 != null && (str = themeAccent2.patternSlug) != null && str.equals(((TLRPC.WallPaper) tL_wallPaper2).slug)) {
this.selectedPattern = tL_wallPaper2;
setCurrentImage(false);
updateButtonState(false, false);
} else if (this.accent == null) {
TLRPC.TL_wallPaper tL_wallPaper3 = this.selectedPattern;
if (tL_wallPaper3 != null) {
String str2 = ((TLRPC.WallPaper) tL_wallPaper3).slug;
if (str2 != null) {
if (!str2.equals(((TLRPC.WallPaper) tL_wallPaper2).slug)) {
}
}
}
}
z = true;
}
}
}
if (!z && (tL_wallPaper = this.selectedPattern) != null) {
this.patterns.add(0, tL_wallPaper);
}
PatternsAdapter patternsAdapter = this.patternsAdapter;
if (patternsAdapter != null) {
patternsAdapter.notifyDataSetChanged();
}
MessagesStorage.getInstance(((BaseFragment) this).currentAccount).putWallpapers(tL_account_wallPapers.wallpapers, 1);
}
if (this.selectedPattern != null || (themeAccent = this.accent) == null || TextUtils.isEmpty(themeAccent.patternSlug)) {
return;
}
TLRPC.TL_account_getWallPaper tL_account_getWallPaper = new TLRPC.TL_account_getWallPaper();
TLRPC.TL_inputWallPaperSlug tL_inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug();
tL_inputWallPaperSlug.slug = this.accent.patternSlug;
tL_account_getWallPaper.wallpaper = tL_inputWallPaperSlug;
ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).bindRequestToGuid(getConnectionsManager().sendRequest(tL_account_getWallPaper, new RequestDelegate() {
public final void run(TLObject tLObject2, TLRPC.TL_error tL_error) {
ThemePreviewActivity.this.lambda$didReceivedNotification$29(tLObject2, tL_error);
}
}), ((BaseFragment) this).classGuid);
}
public void lambda$didReceivedNotification$29(final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ThemePreviewActivity.this.lambda$didReceivedNotification$28(tLObject);
}
});
}
public void lambda$didReceivedNotification$28(TLObject tLObject) {
if (tLObject instanceof TLRPC.TL_wallPaper) {
TLRPC.TL_wallPaper tL_wallPaper = (TLRPC.TL_wallPaper) tLObject;
if (((TLRPC.WallPaper) tL_wallPaper).pattern) {
this.selectedPattern = tL_wallPaper;
setCurrentImage(false);
updateButtonState(false, false);
this.patterns.add(0, this.selectedPattern);
PatternsAdapter patternsAdapter = this.patternsAdapter;
if (patternsAdapter != null) {
patternsAdapter.notifyDataSetChanged();
}
}
}
}
public final void cancelThemeApply(boolean back) {
if (this.screenType == 2) {
if (back) {
return;
}
finishFragment();
return;
}
if (this.showExport && !back) {
PlusUtils.exportTheme(getParentActivity(), this.applyingTheme);
}
Theme.applyPreviousTheme();
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetNewWallpapper);
if (this.screenType == 1) {
if (this.editingTheme) {
Theme.ThemeAccent themeAccent = this.accent;
themeAccent.accentColor = this.backupAccentColor;
themeAccent.accentColor2 = this.backupAccentColor2;
themeAccent.myMessagesAccentColor = this.backupMyMessagesAccentColor;
themeAccent.myMessagesGradientAccentColor1 = this.backupMyMessagesGradientAccentColor1;
themeAccent.myMessagesGradientAccentColor2 = this.backupMyMessagesGradientAccentColor2;
themeAccent.myMessagesGradientAccentColor3 = this.backupMyMessagesGradientAccentColor3;
themeAccent.myMessagesAnimated = this.backupMyMessagesAnimated;
themeAccent.backgroundOverrideColor = this.backupBackgroundOverrideColor;
themeAccent.backgroundGradientOverrideColor1 = this.backupBackgroundGradientOverrideColor1;
themeAccent.backgroundGradientOverrideColor2 = this.backupBackgroundGradientOverrideColor2;
themeAccent.backgroundGradientOverrideColor3 = this.backupBackgroundGradientOverrideColor3;
themeAccent.backgroundRotation = this.backupBackgroundRotation;
themeAccent.patternSlug = this.backupSlug;
themeAccent.patternIntensity = this.backupIntensity;
}
Theme.saveThemeAccents(this.applyingTheme, false, true, false, false);
} else {
if (this.accent != null) {
Theme.saveThemeAccents(this.applyingTheme, false, this.deleteOnCancel, false, false);
}
((BaseFragment) this).parentLayout.rebuildAllFragmentViews(false, false);
if (this.deleteOnCancel) {
Theme.ThemeInfo themeInfo = this.applyingTheme;
if (themeInfo.pathToFile != null && !Theme.isThemeInstalled(themeInfo)) {
new File(this.applyingTheme.pathToFile).delete();
}
}
}
if (back) {
return;
}
finishFragment();
}
public final int getButtonsColor(int key) {
return this.useDefaultThemeForButtons ? Theme.getDefaultColor(key) : getThemedColor(key);
}
public final void scheduleApplyColor(int color, int num, boolean applyNow) {
if (num == -1) {
int i = this.colorType;
if (i == 1 || i == 2) {
long j = this.backupBackgroundOverrideColor;
if (j != 0) {
this.accent.backgroundOverrideColor = j;
} else {
this.accent.backgroundOverrideColor = 0L;
}
long j2 = this.backupBackgroundGradientOverrideColor1;
if (j2 != 0) {
this.accent.backgroundGradientOverrideColor1 = j2;
} else {
this.accent.backgroundGradientOverrideColor1 = 0L;
}
long j3 = this.backupBackgroundGradientOverrideColor2;
if (j3 != 0) {
this.accent.backgroundGradientOverrideColor2 = j3;
} else {
this.accent.backgroundGradientOverrideColor2 = 0L;
}
long j4 = this.backupBackgroundGradientOverrideColor3;
if (j4 != 0) {
this.accent.backgroundGradientOverrideColor3 = j4;
} else {
this.accent.backgroundGradientOverrideColor3 = 0L;
}
this.accent.backgroundRotation = this.backupBackgroundRotation;
if (i == 2) {
int defaultAccentColor = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper);
int defaultAccentColor2 = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to1);
int defaultAccentColor3 = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to2);
int defaultAccentColor4 = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to3);
Theme.ThemeAccent themeAccent = this.accent;
int i2 = (int) themeAccent.backgroundGradientOverrideColor1;
int i3 = (int) themeAccent.backgroundGradientOverrideColor2;
int i4 = (int) themeAccent.backgroundGradientOverrideColor3;
int i5 = (int) themeAccent.backgroundOverrideColor;
ColorPicker colorPicker = this.colorPicker;
if (i4 != 0) {
defaultAccentColor4 = i4;
}
colorPicker.setColor(defaultAccentColor4, 3);
ColorPicker colorPicker2 = this.colorPicker;
if (i3 != 0) {
defaultAccentColor3 = i3;
}
colorPicker2.setColor(defaultAccentColor3, 2);
ColorPicker colorPicker3 = this.colorPicker;
if (i2 != 0) {
defaultAccentColor2 = i2;
}
colorPicker3.setColor(defaultAccentColor2, 1);
ColorPicker colorPicker4 = this.colorPicker;
if (i5 != 0) {
defaultAccentColor = i5;
}
colorPicker4.setColor(defaultAccentColor, 0);
}
}
int i6 = this.colorType;
if (i6 == 1 || i6 == 3) {
int i7 = this.backupMyMessagesAccentColor;
if (i7 != 0) {
this.accent.myMessagesAccentColor = i7;
} else {
this.accent.myMessagesAccentColor = 0;
}
int i8 = this.backupMyMessagesGradientAccentColor1;
if (i8 != 0) {
this.accent.myMessagesGradientAccentColor1 = i8;
} else {
this.accent.myMessagesGradientAccentColor1 = 0;
}
int i9 = this.backupMyMessagesGradientAccentColor2;
if (i9 != 0) {
this.accent.myMessagesGradientAccentColor2 = i9;
} else {
this.accent.myMessagesGradientAccentColor2 = 0;
}
int i10 = this.backupMyMessagesGradientAccentColor3;
if (i10 != 0) {
this.accent.myMessagesGradientAccentColor3 = i10;
} else {
this.accent.myMessagesGradientAccentColor3 = 0;
}
if (i6 == 3) {
this.colorPicker.setColor(this.accent.myMessagesGradientAccentColor3, 3);
this.colorPicker.setColor(this.accent.myMessagesGradientAccentColor2, 2);
this.colorPicker.setColor(this.accent.myMessagesGradientAccentColor1, 1);
ColorPicker colorPicker5 = this.colorPicker;
Theme.ThemeAccent themeAccent2 = this.accent;
int i11 = themeAccent2.myMessagesAccentColor;
if (i11 == 0) {
i11 = themeAccent2.accentColor;
}
colorPicker5.setColor(i11, 0);
}
}
Theme.refreshThemeColors();
this.listView2.invalidateViews();
return;
}
int i12 = this.lastPickedColorNum;
if (i12 != -1 && i12 != num) {
this.applyColorAction.run();
}
this.lastPickedColor = color;
this.lastPickedColorNum = num;
if (applyNow) {
this.applyColorAction.run();
} else {
if (this.applyColorScheduled) {
return;
}
this.applyColorScheduled = true;
((BaseFragment) this).fragmentView.postDelayed(this.applyColorAction, 16L);
}
}
public final void applyColor(int color, int num) {
int i = this.colorType;
if (i == 1) {
if (num == 0) {
this.accent.accentColor = color;
Theme.refreshThemeColors();
} else if (num == 1) {
this.accent.accentColor2 = color;
Theme.refreshThemeColors(true, true);
this.listView2.invalidateViews();
this.colorPicker.setHasChanges(hasChanges(this.colorType));
updatePlayAnimationView(true);
}
} else if (i == 2) {
if (this.lastPickedColorNum == 0) {
this.accent.backgroundOverrideColor = color;
} else if (num == 1) {
int defaultAccentColor = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to1);
if (color == 0 && defaultAccentColor != 0) {
this.accent.backgroundGradientOverrideColor1 = 4294967296L;
} else {
this.accent.backgroundGradientOverrideColor1 = color;
}
} else if (num == 2) {
int defaultAccentColor2 = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to2);
if (color == 0 && defaultAccentColor2 != 0) {
this.accent.backgroundGradientOverrideColor2 = 4294967296L;
} else {
this.accent.backgroundGradientOverrideColor2 = color;
}
} else if (num == 3) {
int defaultAccentColor3 = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to3);
if (color == 0 && defaultAccentColor3 != 0) {
this.accent.backgroundGradientOverrideColor3 = 4294967296L;
} else {
this.accent.backgroundGradientOverrideColor3 = color;
}
}
Theme.refreshThemeColors(true, false);
this.colorPicker.setHasChanges(hasChanges(this.colorType));
updatePlayAnimationView(true);
} else if (i == 3) {
int i2 = this.lastPickedColorNum;
if (i2 == 0) {
this.accent.myMessagesAccentColor = color;
} else if (i2 == 1) {
this.accent.myMessagesGradientAccentColor1 = color;
} else if (i2 == 2) {
Theme.ThemeAccent themeAccent = this.accent;
int i3 = themeAccent.myMessagesGradientAccentColor2;
themeAccent.myMessagesGradientAccentColor2 = color;
if (i3 != 0 && color == 0) {
this.messagesAdapter.notifyItemRemoved(0);
} else if (i3 == 0 && color != 0) {
this.messagesAdapter.notifyItemInserted(0);
showAnimationHint();
}
} else {
this.accent.myMessagesGradientAccentColor3 = color;
}
int i4 = this.lastPickedColorNum;
if (i4 >= 0) {
this.messagesCheckBoxView[1].setColor(i4, color);
}
Theme.refreshThemeColors(true, true);
this.listView2.invalidateViews();
this.colorPicker.setHasChanges(hasChanges(this.colorType));
updatePlayAnimationView(true);
}
int size = this.themeDescriptions.size();
for (int i5 = 0; i5 < size; i5++) {
ThemeDescription themeDescription = this.themeDescriptions.get(i5);
themeDescription.setColor(getThemedColor(themeDescription.getCurrentKey()), false, false);
}
this.listView.invalidateViews();
this.listView2.invalidateViews();
View view = this.dotsContainer;
if (view != null) {
view.invalidate();
}
}
public final void updateButtonState(boolean ifSame, boolean animated) {
File httpFilePath;
String name;
int i;
long j;
FrameLayout frameLayout;
Object obj = this.selectedPattern;
if (obj == null) {
obj = this.currentWallpaper;
}
boolean z = obj instanceof TLRPC.TL_wallPaper;
if (z || (obj instanceof MediaController.SearchImage)) {
if (z) {
TLRPC.TL_wallPaper tL_wallPaper = (TLRPC.TL_wallPaper) obj;
name = FileLoader.getAttachFileName(((TLRPC.WallPaper) tL_wallPaper).document);
if (TextUtils.isEmpty(name)) {
return;
}
httpFilePath = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToAttach(((TLRPC.WallPaper) tL_wallPaper).document, true);
j = ((TLRPC.WallPaper) tL_wallPaper).document.size;
} else {
MediaController.SearchImage searchImage = (MediaController.SearchImage) obj;
TLRPC.Photo photo = searchImage.photo;
if (photo != null) {
TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, this.maxWallpaperSize, true);
httpFilePath = FileLoader.getInstance(((BaseFragment) this).currentAccount).getPathToAttach(closestPhotoSizeWithSize, true);
name = FileLoader.getAttachFileName(closestPhotoSizeWithSize);
i = closestPhotoSizeWithSize.size;
} else {
httpFilePath = ImageLoader.getHttpFilePath(searchImage.imageUrl, "jpg");
name = httpFilePath.getName();
i = searchImage.size;
}
j = i;
if (TextUtils.isEmpty(name)) {
return;
}
}
boolean exists = httpFilePath.exists();
if (exists) {
DownloadController.getInstance(((BaseFragment) this).currentAccount).removeLoadingFileObserver(this);
this.backgroundImage.invalidate();
if (this.screenType == 2) {
if (j != 0 && this.dialogId == 0) {
this.actionBar2.setSubtitle(AndroidUtilities.formatFileSize(j));
} else {
this.actionBar2.setSubtitle(null);
}
}
} else {
DownloadController.getInstance(((BaseFragment) this).currentAccount).addLoadingFileObserver(name, (MessageObject) null, this);
if (this.screenType == 2 && this.dialogId == 0) {
this.actionBar2.setSubtitle(LocaleController.getString("LoadingFullImage", R.string.LoadingFullImage));
}
this.backgroundImage.invalidate();
}
if (this.selectedPattern == null && (frameLayout = this.backgroundButtonsContainer) != null) {
frameLayout.setAlpha(exists ? 1.0f : 0.5f);
}
int i2 = this.screenType;
if (i2 == 0) {
this.doneButton.setEnabled(exists);
this.doneButton.setAlpha(exists ? 1.0f : 0.5f);
return;
}
if (i2 == 2) {
this.bottomOverlayChat.setEnabled(exists);
BlurButton blurButton = this.applyButton1;
if (blurButton != null) {
blurButton.setAlpha(exists ? 1.0f : 0.5f);
}
BlurButton blurButton2 = this.applyButton2;
if (blurButton2 != null) {
blurButton2.setAlpha(exists ? 1.0f : 0.5f);
return;
}
return;
}
this.saveItem.setEnabled(exists);
this.saveItem.setAlpha(exists ? 1.0f : 0.5f);
}
}
public void setDelegate(WallpaperActivityDelegate wallpaperActivityDelegate) {
this.delegate = wallpaperActivityDelegate;
}
public void setPatterns(ArrayList<Object> arrayList) {
this.patterns = arrayList;
if (this.screenType == 1 || (this.currentWallpaper instanceof WallpapersListActivity.ColorWallpaper)) {
WallpapersListActivity.ColorWallpaper colorWallpaper = (WallpapersListActivity.ColorWallpaper) this.currentWallpaper;
if (colorWallpaper.patternId != 0) {
int i = 0;
int size = arrayList.size();
while (true) {
if (i >= size) {
break;
}
TLRPC.TL_wallPaper tL_wallPaper = (TLRPC.TL_wallPaper) this.patterns.get(i);
if (((TLRPC.WallPaper) tL_wallPaper).id == colorWallpaper.patternId) {
this.selectedPattern = tL_wallPaper;
break;
}
i++;
}
this.currentIntensity = colorWallpaper.intensity;
}
}
}
public final void showAnimationHint() {
if (this.page2 == null || this.messagesCheckBoxView == null || this.accent.myMessagesGradientAccentColor2 == 0) {
return;
}
final SharedPreferences globalMainSettings = MessagesController.getGlobalMainSettings();
if (globalMainSettings.getBoolean("bganimationhint", false)) {
return;
}
if (this.animationHint == null) {
HintView hintView = new HintView(getParentActivity(), 8);
this.animationHint = hintView;
hintView.setShowingDuration(5000L);
this.animationHint.setAlpha(0.0f);
this.animationHint.setVisibility(4);
this.animationHint.setText(LocaleController.getString("BackgroundAnimateInfo", R.string.BackgroundAnimateInfo));
this.animationHint.setExtraTranslationY(AndroidUtilities.dp(6.0f));
this.frameLayout.addView((View) this.animationHint, (ViewGroup.LayoutParams) LayoutHelper.createFrame(-2, -2.0f, 51, 10.0f, 0.0f, 10.0f, 0.0f));
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ThemePreviewActivity.this.lambda$showAnimationHint$32(globalMainSettings);
}
}, 500L);
}
public void lambda$showAnimationHint$32(SharedPreferences sharedPreferences) {
if (this.colorType != 3) {
return;
}
sharedPreferences.edit().putBoolean("bganimationhint", true).commit();
this.animationHint.showForView(this.messagesCheckBoxView[0], true);
}
public final void updateSelectedPattern(boolean animated) {
int childCount = this.patternsListView.getChildCount();
for (int i = 0; i < childCount; i++) {
Object childAt = this.patternsListView.getChildAt(i);
if (childAt instanceof PatternCell) {
((PatternCell) childAt).updateSelected(animated);
}
}
}
public final void updateMotionButton() {
int i = this.screenType;
if (i == 1 || i == 2) {
if (this.selectedPattern == null && (this.currentWallpaper instanceof WallpapersListActivity.ColorWallpaper)) {
this.backgroundCheckBoxView[2].setChecked(false, true);
}
this.backgroundCheckBoxView[this.selectedPattern != null ? (char) 2 : (char) 0].setVisibility(0);
AnimatorSet animatorSet = new AnimatorSet();
Animator[] animatorArr = new Animator[2];
WallpaperCheckBoxView wallpaperCheckBoxView = this.backgroundCheckBoxView[2];
Property property = View.ALPHA;
float[] fArr = new float[1];
fArr[0] = this.selectedPattern != null ? 1.0f : 0.0f;
animatorArr[0] = ObjectAnimator.ofFloat(wallpaperCheckBoxView, (Property<WallpaperCheckBoxView, Float>) property, fArr);
WallpaperCheckBoxView wallpaperCheckBoxView2 = this.backgroundCheckBoxView[0];
Property property2 = View.ALPHA;
float[] fArr2 = new float[1];
fArr2[0] = this.selectedPattern != null ? 0.0f : 1.0f;
animatorArr[1] = ObjectAnimator.ofFloat(wallpaperCheckBoxView2, (Property<WallpaperCheckBoxView, Float>) property2, fArr2);
animatorSet.playTogether(animatorArr);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
ThemePreviewActivity.this.backgroundCheckBoxView[ThemePreviewActivity.this.selectedPattern != null ? (char) 0 : (char) 2].setVisibility(4);
}
});
animatorSet.setInterpolator(CubicBezierInterpolator.EASE_OUT);
animatorSet.setDuration(200L);
animatorSet.start();
return;
}
boolean isEnabled = this.backgroundCheckBoxView[0].isEnabled();
TLRPC.TL_wallPaper tL_wallPaper = this.selectedPattern;
if (isEnabled == (tL_wallPaper != null)) {
return;
}
if (tL_wallPaper == null) {
this.backgroundCheckBoxView[0].setChecked(false, true);
}
this.backgroundCheckBoxView[0].setEnabled(this.selectedPattern != null);
if (this.selectedPattern != null) {
this.backgroundCheckBoxView[0].setVisibility(0);
}
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.backgroundCheckBoxView[1].getLayoutParams();
AnimatorSet animatorSet2 = new AnimatorSet();
int dp = (layoutParams.width + AndroidUtilities.dp(9.0f)) / 2;
Animator[] animatorArr2 = new Animator[1];
WallpaperCheckBoxView wallpaperCheckBoxView3 = this.backgroundCheckBoxView[0];
Property property3 = View.ALPHA;
float[] fArr3 = new float[1];
fArr3[0] = this.selectedPattern == null ? 0.0f : 1.0f;
animatorArr2[0] = ObjectAnimator.ofFloat(wallpaperCheckBoxView3, (Property<WallpaperCheckBoxView, Float>) property3, fArr3);
animatorSet2.playTogether(animatorArr2);
Animator[] animatorArr3 = new Animator[1];
WallpaperCheckBoxView wallpaperCheckBoxView4 = this.backgroundCheckBoxView[0];
Property property4 = View.TRANSLATION_X;
float[] fArr4 = new float[1];
fArr4[0] = this.selectedPattern != null ? 0.0f : dp;
animatorArr3[0] = ObjectAnimator.ofFloat(wallpaperCheckBoxView4, (Property<WallpaperCheckBoxView, Float>) property4, fArr4);
animatorSet2.playTogether(animatorArr3);
Animator[] animatorArr4 = new Animator[1];
WallpaperCheckBoxView wallpaperCheckBoxView5 = this.backgroundCheckBoxView[1];
Property property5 = View.TRANSLATION_X;
float[] fArr5 = new float[1];
fArr5[0] = this.selectedPattern == null ? -dp : 0.0f;
animatorArr4[0] = ObjectAnimator.ofFloat(wallpaperCheckBoxView5, (Property<WallpaperCheckBoxView, Float>) property5, fArr5);
animatorSet2.playTogether(animatorArr4);
animatorSet2.setInterpolator(CubicBezierInterpolator.EASE_OUT);
animatorSet2.setDuration(200L);
animatorSet2.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (ThemePreviewActivity.this.selectedPattern == null) {
ThemePreviewActivity.this.backgroundCheckBoxView[0].setVisibility(4);
}
}
});
animatorSet2.start();
}
public final void showPatternsView(final int num, final boolean show, boolean animated) {
int indexOf;
final boolean z = show && num == 1 && this.selectedPattern != null;
if (show) {
if (num == 0) {
if (this.screenType == 2) {
this.previousBackgroundColor = this.backgroundColor;
int i = this.backgroundGradientColor1;
this.previousBackgroundGradientColor1 = i;
int i2 = this.backgroundGradientColor2;
this.previousBackgroundGradientColor2 = i2;
int i3 = this.backgroundGradientColor3;
this.previousBackgroundGradientColor3 = i3;
int i4 = this.backupBackgroundRotation;
this.previousBackgroundRotation = i4;
this.colorPicker.setType(0, false, 4, i3 != 0 ? 4 : i2 != 0 ? 3 : i != 0 ? 2 : 1, false, i4, false);
this.colorPicker.setColor(this.backgroundGradientColor3, 3);
this.colorPicker.setColor(this.backgroundGradientColor2, 2);
this.colorPicker.setColor(this.backgroundGradientColor1, 1);
this.colorPicker.setColor(this.backgroundColor, 0);
}
} else {
this.previousSelectedPattern = this.selectedPattern;
this.previousIntensity = this.currentIntensity;
this.patternsAdapter.notifyDataSetChanged();
ArrayList<Object> arrayList = this.patterns;
if (arrayList != null) {
TLRPC.TL_wallPaper tL_wallPaper = this.selectedPattern;
if (tL_wallPaper == null) {
indexOf = 0;
} else {
indexOf = arrayList.indexOf(tL_wallPaper) + (this.screenType == 2 ? 1 : 0);
}
this.patternsLayoutManager.scrollToPositionWithOffset(indexOf, (this.patternsListView.getMeasuredWidth() - AndroidUtilities.dp(124.0f)) / 2);
}
}
}
int i5 = this.screenType;
if (i5 == 1 || i5 == 2) {
this.backgroundCheckBoxView[z ? (char) 2 : (char) 0].setVisibility(0);
}
if (num == 1 && !this.intensitySeekBar.isTwoSided()) {
float f = this.currentIntensity;
if (f < 0.0f) {
float f2 = -f;
this.currentIntensity = f2;
this.intensitySeekBar.setProgress(f2);
}
}
if (animated) {
this.patternViewAnimation = new AnimatorSet();
ArrayList arrayList2 = new ArrayList();
int i6 = num == 0 ? 1 : 0;
if (show) {
this.patternLayout[num].setVisibility(0);
int i7 = this.screenType;
if (i7 == 1) {
RecyclerListView recyclerListView = this.listView2;
Property property = View.TRANSLATION_Y;
float[] fArr = new float[1];
fArr[0] = num == 1 ? -AndroidUtilities.dp(21.0f) : 0.0f;
arrayList2.add(ObjectAnimator.ofFloat(recyclerListView, (Property<RecyclerListView, Float>) property, fArr));
WallpaperCheckBoxView wallpaperCheckBoxView = this.backgroundCheckBoxView[2];
Property property2 = View.ALPHA;
float[] fArr2 = new float[1];
fArr2[0] = z ? 1.0f : 0.0f;
arrayList2.add(ObjectAnimator.ofFloat(wallpaperCheckBoxView, (Property<WallpaperCheckBoxView, Float>) property2, fArr2));
WallpaperCheckBoxView wallpaperCheckBoxView2 = this.backgroundCheckBoxView[0];
Property property3 = View.ALPHA;
float[] fArr3 = new float[1];
fArr3[0] = z ? 0.0f : 1.0f;
arrayList2.add(ObjectAnimator.ofFloat(wallpaperCheckBoxView2, (Property<WallpaperCheckBoxView, Float>) property3, fArr3));
if (num == 1) {
arrayList2.add(ObjectAnimator.ofFloat(this.patternLayout[num], (Property<FrameLayout, Float>) View.ALPHA, 0.0f, 1.0f));
} else {
this.patternLayout[num].setAlpha(1.0f);
arrayList2.add(ObjectAnimator.ofFloat(this.patternLayout[i6], (Property<FrameLayout, Float>) View.ALPHA, 0.0f));
}
this.colorPicker.hideKeyboard();
} else if (i7 == 2) {
RecyclerListView recyclerListView2 = this.listView2;
Property property4 = View.TRANSLATION_Y;
float[] fArr4 = new float[1];
fArr4[0] = (-this.patternLayout[num].getMeasuredHeight()) + AndroidUtilities.dp((this.applyButton2 == null ? 0 : 58) + 72) + (insideBottomSheet() ? AndroidUtilities.navigationBarHeight : 0);
arrayList2.add(ObjectAnimator.ofFloat(recyclerListView2, (Property<RecyclerListView, Float>) property4, fArr4));
WallpaperCheckBoxView wallpaperCheckBoxView3 = this.backgroundCheckBoxView[2];
Property property5 = View.ALPHA;
float[] fArr5 = new float[1];
fArr5[0] = z ? 1.0f : 0.0f;
arrayList2.add(ObjectAnimator.ofFloat(wallpaperCheckBoxView3, (Property<WallpaperCheckBoxView, Float>) property5, fArr5));
WallpaperCheckBoxView wallpaperCheckBoxView4 = this.backgroundCheckBoxView[0];
Property property6 = View.ALPHA;
float[] fArr6 = new float[1];
fArr6[0] = z ? 0.0f : 1.0f;
arrayList2.add(ObjectAnimator.ofFloat(wallpaperCheckBoxView4, (Property<WallpaperCheckBoxView, Float>) property6, fArr6));
if (this.patternLayout[i6].getVisibility() == 0) {
arrayList2.add(ObjectAnimator.ofFloat(this.patternLayout[i6], (Property<FrameLayout, Float>) View.ALPHA, 0.0f));
arrayList2.add(ObjectAnimator.ofFloat(this.patternLayout[num], (Property<FrameLayout, Float>) View.ALPHA, 0.0f, 1.0f));
this.patternLayout[num].setTranslationY(0.0f);
} else {
arrayList2.add(ObjectAnimator.ofFloat(this.patternLayout[num], (Property<FrameLayout, Float>) View.TRANSLATION_Y, r8[num].getMeasuredHeight(), 0.0f));
}
} else {
if (num == 1) {
arrayList2.add(ObjectAnimator.ofFloat(this.patternLayout[num], (Property<FrameLayout, Float>) View.ALPHA, 0.0f, 1.0f));
} else {
this.patternLayout[num].setAlpha(1.0f);
arrayList2.add(ObjectAnimator.ofFloat(this.patternLayout[i6], (Property<FrameLayout, Float>) View.ALPHA, 0.0f));
}
this.colorPicker.hideKeyboard();
}
} else {
arrayList2.add(ObjectAnimator.ofFloat(this.listView2, (Property<RecyclerListView, Float>) View.TRANSLATION_Y, 0.0f));
arrayList2.add(ObjectAnimator.ofFloat(this.patternLayout[num], (Property<FrameLayout, Float>) View.TRANSLATION_Y, r8[num].getMeasuredHeight()));
arrayList2.add(ObjectAnimator.ofFloat(this.backgroundCheckBoxView[0], (Property<WallpaperCheckBoxView, Float>) View.ALPHA, 1.0f));
arrayList2.add(ObjectAnimator.ofFloat(this.backgroundCheckBoxView[2], (Property<WallpaperCheckBoxView, Float>) View.ALPHA, 0.0f));
arrayList2.add(ObjectAnimator.ofFloat(this.backgroundImage, (Property<BackgroundView, Float>) View.ALPHA, 1.0f));
}
this.patternViewAnimation.playTogether(arrayList2);
final int i8 = i6;
this.patternViewAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
ThemePreviewActivity.this.patternViewAnimation = null;
if (show && ThemePreviewActivity.this.patternLayout[i8].getVisibility() == 0) {
ThemePreviewActivity.this.patternLayout[i8].setAlpha(1.0f);
ThemePreviewActivity.this.patternLayout[i8].setVisibility(4);
} else if (!show) {
ThemePreviewActivity.this.patternLayout[num].setVisibility(4);
}
if (ThemePreviewActivity.this.screenType == 1 || ThemePreviewActivity.this.screenType == 2) {
ThemePreviewActivity.this.backgroundCheckBoxView[z ? (char) 0 : (char) 2].setVisibility(4);
} else if (num == 1) {
ThemePreviewActivity.this.patternLayout[i8].setAlpha(0.0f);
}
}
});
this.patternViewAnimation.setInterpolator(CubicBezierInterpolator.EASE_OUT);
this.patternViewAnimation.setDuration(200L);
this.patternViewAnimation.start();
return;
}
char c = num == 0 ? (char) 1 : (char) 0;
if (show) {
this.patternLayout[num].setVisibility(0);
int i9 = this.screenType;
if (i9 == 1) {
this.listView2.setTranslationY(num == 1 ? -AndroidUtilities.dp(21.0f) : 0.0f);
this.backgroundCheckBoxView[2].setAlpha(z ? 1.0f : 0.0f);
this.backgroundCheckBoxView[0].setAlpha(z ? 0.0f : 1.0f);
if (num == 1) {
this.patternLayout[num].setAlpha(1.0f);
} else {
this.patternLayout[num].setAlpha(1.0f);
this.patternLayout[c].setAlpha(0.0f);
}
this.colorPicker.hideKeyboard();
} else if (i9 == 2) {
this.listView2.setTranslationY((-AndroidUtilities.dp(num == 0 ? 343.0f : 316.0f)) + AndroidUtilities.dp((this.applyButton2 == null ? 0 : 58) + 72) + (insideBottomSheet() ? AndroidUtilities.navigationBarHeight : 0));
this.backgroundCheckBoxView[2].setAlpha(z ? 1.0f : 0.0f);
this.backgroundCheckBoxView[0].setAlpha(z ? 0.0f : 1.0f);
if (this.patternLayout[c].getVisibility() == 0) {
this.patternLayout[c].setAlpha(0.0f);
this.patternLayout[num].setAlpha(1.0f);
this.patternLayout[num].setTranslationY(0.0f);
} else {
this.patternLayout[num].setTranslationY(0.0f);
}
} else {
if (num == 1) {
this.patternLayout[num].setAlpha(1.0f);
} else {
this.patternLayout[num].setAlpha(1.0f);
this.patternLayout[c].setAlpha(0.0f);
}
this.colorPicker.hideKeyboard();
}
} else {
this.listView2.setTranslationY(0.0f);
this.patternLayout[num].setTranslationY(r8[num].getMeasuredHeight());
this.backgroundCheckBoxView[0].setAlpha(1.0f);
this.backgroundCheckBoxView[2].setAlpha(1.0f);
this.backgroundImage.setAlpha(1.0f);
}
if (show && this.patternLayout[c].getVisibility() == 0) {
this.patternLayout[c].setAlpha(1.0f);
this.patternLayout[c].setVisibility(4);
} else if (!show) {
this.patternLayout[num].setVisibility(4);
}
int i10 = this.screenType;
if (i10 == 1 || i10 == 2) {
this.backgroundCheckBoxView[z ? (char) 0 : (char) 2].setVisibility(4);
} else if (num == 1) {
this.patternLayout[c].setAlpha(0.0f);
}
}
public final void animateMotionChange() {
AnimatorSet animatorSet = this.motionAnimation;
if (animatorSet != null) {
animatorSet.cancel();
}
AnimatorSet animatorSet2 = new AnimatorSet();
this.motionAnimation = animatorSet2;
if (this.isMotion) {
animatorSet2.playTogether(ObjectAnimator.ofFloat(this.backgroundImage, (Property<BackgroundView, Float>) View.SCALE_X, this.parallaxScale), ObjectAnimator.ofFloat(this.backgroundImage, (Property<BackgroundView, Float>) View.SCALE_Y, this.parallaxScale));
} else {
animatorSet2.playTogether(ObjectAnimator.ofFloat(this.backgroundImage, (Property<BackgroundView, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.backgroundImage, (Property<BackgroundView, Float>) View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(this.backgroundImage, (Property<BackgroundView, Float>) View.TRANSLATION_X, 0.0f), ObjectAnimator.ofFloat(this.backgroundImage, (Property<BackgroundView, Float>) View.TRANSLATION_Y, 0.0f));
}
this.motionAnimation.setInterpolator(CubicBezierInterpolator.EASE_OUT);
this.motionAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
ThemePreviewActivity.this.motionAnimation = null;
}
});
this.motionAnimation.start();
}
public final void updatePlayAnimationView(boolean r20) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ThemePreviewActivity.updatePlayAnimationView(boolean):void");
}
public final void setBackgroundColor(int color, int num, boolean applyNow, boolean animated) {
MotionBackgroundDrawable motionBackgroundDrawable;
if (num == 0) {
this.backgroundColor = color;
} else if (num == 1) {
this.backgroundGradientColor1 = color;
} else if (num == 2) {
this.backgroundGradientColor2 = color;
} else if (num == 3) {
this.backgroundGradientColor3 = color;
}
updatePlayAnimationView(animated);
if (this.backgroundCheckBoxView != null) {
int i = 0;
while (true) {
WallpaperCheckBoxView[] wallpaperCheckBoxViewArr = this.backgroundCheckBoxView;
if (i >= wallpaperCheckBoxViewArr.length) {
break;
}
if (wallpaperCheckBoxViewArr[i] != null) {
wallpaperCheckBoxViewArr[i].setColor(num, color);
}
i++;
}
}
if (this.backgroundGradientColor2 != 0) {
if (this.intensitySeekBar != null && Theme.getActiveTheme().isDark()) {
this.intensitySeekBar.setTwoSided(true);
}
MotionBackgroundDrawable background = this.backgroundImage.getBackground();
if (background instanceof MotionBackgroundDrawable) {
motionBackgroundDrawable = background;
} else {
motionBackgroundDrawable = new MotionBackgroundDrawable();
motionBackgroundDrawable.setParentView(this.backgroundImage);
if (this.rotatePreview) {
motionBackgroundDrawable.rotatePreview(false);
}
}
motionBackgroundDrawable.setColors(this.backgroundColor, this.backgroundGradientColor1, this.backgroundGradientColor2, this.backgroundGradientColor3);
this.backgroundImage.setBackground(motionBackgroundDrawable);
this.patternColor = motionBackgroundDrawable.getPatternColor();
this.checkColor = 754974720;
} else if (this.backgroundGradientColor1 != 0) {
this.backgroundImage.setBackground(new GradientDrawable(BackgroundGradientDrawable.getGradientOrientation(this.backgroundRotation), new int[]{this.backgroundColor, this.backgroundGradientColor1}));
int patternColor = AndroidUtilities.getPatternColor(AndroidUtilities.getAverageColor(this.backgroundColor, this.backgroundGradientColor1));
this.checkColor = patternColor;
this.patternColor = patternColor;
} else {
this.backgroundImage.setBackgroundColor(this.backgroundColor);
int patternColor2 = AndroidUtilities.getPatternColor(this.backgroundColor);
this.checkColor = patternColor2;
this.patternColor = patternColor2;
}
int i2 = Theme.key_chat_serviceBackground;
if (!Theme.hasThemeKey(i2) || (this.backgroundImage.getBackground() instanceof MotionBackgroundDrawable)) {
ThemeDelegate themeDelegate = this.themeDelegate;
int i3 = this.checkColor;
themeDelegate.applyChatServiceMessageColor(new int[]{i3, i3, i3, i3}, this.backgroundImage.getBackground(), this.backgroundImage.getBackground(), Float.valueOf(this.currentIntensity));
} else if (Theme.getCachedWallpaperNonBlocking() instanceof MotionBackgroundDrawable) {
int themedColor = getThemedColor(i2);
this.themeDelegate.applyChatServiceMessageColor(new int[]{themedColor, themedColor, themedColor, themedColor}, this.backgroundImage.getBackground(), this.backgroundImage.getBackground(), Float.valueOf(this.currentIntensity));
}
ImageView imageView = this.backgroundPlayAnimationImageView;
if (imageView != null) {
imageView.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_serviceText), PorterDuff.Mode.MULTIPLY));
}
ImageView imageView2 = this.messagesPlayAnimationImageView;
if (imageView2 != null) {
imageView2.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_serviceText), PorterDuff.Mode.MULTIPLY));
}
BackgroundView backgroundView = this.backgroundImage;
if (backgroundView != null) {
backgroundView.getImageReceiver().setColorFilter(new PorterDuffColorFilter(this.patternColor, this.blendMode));
this.backgroundImage.getImageReceiver().setAlpha(Math.abs(this.currentIntensity));
this.backgroundImage.invalidate();
if (Theme.getActiveTheme().isDark() && (this.backgroundImage.getBackground() instanceof MotionBackgroundDrawable)) {
SeekBarView seekBarView = this.intensitySeekBar;
if (seekBarView != null) {
seekBarView.setTwoSided(true);
}
if (this.currentIntensity < 0.0f) {
this.backgroundImage.getImageReceiver().setGradientBitmap(this.backgroundImage.getBackground().getBitmap());
}
} else {
this.backgroundImage.getImageReceiver().setGradientBitmap((Bitmap) null);
SeekBarView seekBarView2 = this.intensitySeekBar;
if (seekBarView2 != null) {
seekBarView2.setTwoSided(false);
}
}
SeekBarView seekBarView3 = this.intensitySeekBar;
if (seekBarView3 != null) {
seekBarView3.setProgress(this.currentIntensity);
}
}
RecyclerListView recyclerListView = this.listView2;
if (recyclerListView != null) {
recyclerListView.invalidateViews();
}
FrameLayout frameLayout = this.backgroundButtonsContainer;
if (frameLayout != null) {
int childCount = frameLayout.getChildCount();
for (int i4 = 0; i4 < childCount; i4++) {
this.backgroundButtonsContainer.getChildAt(i4).invalidate();
}
}
FrameLayout frameLayout2 = this.messagesButtonsContainer;
if (frameLayout2 != null) {
int childCount2 = frameLayout2.getChildCount();
for (int i5 = 0; i5 < childCount2; i5++) {
this.messagesButtonsContainer.getChildAt(i5).invalidate();
}
}
}
public final void setCurrentImage(boolean setThumb) {
MotionBackgroundDrawable colorDrawable;
int i = this.screenType;
if (i == 0 && this.accent == null) {
this.backgroundImage.setBackground(Theme.getCachedWallpaper());
} else {
if (i == 2) {
Object obj = this.currentWallpaper;
if (obj instanceof TLRPC.TL_wallPaper) {
TLRPC.TL_wallPaper tL_wallPaper = (TLRPC.TL_wallPaper) obj;
TLRPC.PhotoSize closestPhotoSizeWithSize = setThumb ? FileLoader.getClosestPhotoSizeWithSize(((TLRPC.WallPaper) tL_wallPaper).document.thumbs, 100) : null;
this.backgroundImage.setImage(ImageLocation.getForDocument(((TLRPC.WallPaper) tL_wallPaper).document), this.imageFilter, ImageLocation.getForDocument(closestPhotoSizeWithSize, ((TLRPC.WallPaper) tL_wallPaper).document), "100_100_b", closestPhotoSizeWithSize instanceof TLRPC.TL_photoStrippedSize ? new BitmapDrawable(ImageLoader.getStrippedPhotoBitmap(closestPhotoSizeWithSize.bytes, "b")) : null, "jpg", ((TLRPC.WallPaper) tL_wallPaper).document.size, 1, tL_wallPaper);
} else if (obj instanceof WallpapersListActivity.ColorWallpaper) {
WallpapersListActivity.ColorWallpaper colorWallpaper = (WallpapersListActivity.ColorWallpaper) obj;
this.backgroundRotation = colorWallpaper.gradientRotation;
setBackgroundColor(colorWallpaper.color, 0, true, false);
int i2 = colorWallpaper.gradientColor1;
if (i2 != 0) {
setBackgroundColor(i2, 1, true, false);
}
setBackgroundColor(colorWallpaper.gradientColor2, 2, true, false);
setBackgroundColor(colorWallpaper.gradientColor3, 3, true, false);
TLRPC.TL_wallPaper tL_wallPaper2 = this.selectedPattern;
if (tL_wallPaper2 != null) {
BackgroundView backgroundView = this.backgroundImage;
ImageLocation forDocument = ImageLocation.getForDocument(((TLRPC.WallPaper) tL_wallPaper2).document);
String str = this.imageFilter;
TLRPC.TL_wallPaper tL_wallPaper3 = this.selectedPattern;
backgroundView.setImage(forDocument, str, (ImageLocation) null, (String) null, "jpg", ((TLRPC.WallPaper) tL_wallPaper3).document.size, 1, tL_wallPaper3);
} else if ("d".equals(colorWallpaper.slug)) {
Point point = AndroidUtilities.displaySize;
int min = Math.min(point.x, point.y);
Point point2 = AndroidUtilities.displaySize;
this.backgroundImage.setImageBitmap(SvgHelper.getBitmap(R.raw.default_pattern, min, Math.max(point2.x, point2.y), Build.VERSION.SDK_INT >= 29 ? 1459617792 : MotionBackgroundDrawable.getPatternColor(colorWallpaper.color, colorWallpaper.gradientColor1, colorWallpaper.gradientColor2, colorWallpaper.gradientColor3)));
}
} else if (obj instanceof WallpapersListActivity.FileWallpaper) {
Bitmap bitmap = this.currentWallpaperBitmap;
if (bitmap != null) {
this.backgroundImage.setImageBitmap(bitmap);
} else {
WallpapersListActivity.FileWallpaper fileWallpaper = (WallpapersListActivity.FileWallpaper) obj;
File file = fileWallpaper.originalPath;
if (file != null) {
this.backgroundImage.setImage(file.getAbsolutePath(), this.imageFilter, (Drawable) null);
} else {
File file2 = fileWallpaper.path;
if (file2 != null) {
this.backgroundImage.setImage(file2.getAbsolutePath(), this.imageFilter, (Drawable) null);
} else if ("t".equals(fileWallpaper.slug)) {
BackupImageView backupImageView = this.backgroundImage;
backupImageView.setImageDrawable(Theme.getThemedWallpaper(false, backupImageView));
} else {
int i3 = fileWallpaper.resId;
if (i3 != 0) {
this.backgroundImage.setImageResource(i3);
}
}
}
}
} else if (obj instanceof MediaController.SearchImage) {
MediaController.SearchImage searchImage = (MediaController.SearchImage) obj;
TLRPC.Photo photo = searchImage.photo;
if (photo != null) {
BitmapDrawable closestPhotoSizeWithSize2 = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 100);
BitmapDrawable closestPhotoSizeWithSize3 = FileLoader.getClosestPhotoSizeWithSize(searchImage.photo.sizes, this.maxWallpaperSize, true);
BitmapDrawable bitmapDrawable = closestPhotoSizeWithSize3 != closestPhotoSizeWithSize2 ? closestPhotoSizeWithSize3 : null;
this.backgroundImage.setImage(ImageLocation.getForPhoto(bitmapDrawable, searchImage.photo), this.imageFilter, ImageLocation.getForPhoto(closestPhotoSizeWithSize2, searchImage.photo), "100_100_b", "jpg", bitmapDrawable != null ? ((TLRPC.PhotoSize) bitmapDrawable).size : 0, 1, searchImage);
} else {
this.backgroundImage.setImage(searchImage.imageUrl, this.imageFilter, searchImage.thumbUrl, "100_100_b");
}
} else if (obj instanceof WallpapersListActivity.EmojiWallpaper) {
DayNightSwitchDelegate dayNightSwitchDelegate = this.onSwitchDayNightDelegate;
Drawable backgroundDrawableFromTheme = PreviewView.getBackgroundDrawableFromTheme(((BaseFragment) this).currentAccount, ((WallpapersListActivity.EmojiWallpaper) this.currentWallpaper).emoticon, dayNightSwitchDelegate != null ? dayNightSwitchDelegate.isDark() : Theme.isCurrentThemeDark());
this.backgroundImage.setBackground(backgroundDrawableFromTheme);
this.themeDelegate.applyChatServiceMessageColor(AndroidUtilities.calcDrawableColor(backgroundDrawableFromTheme), checkBlur(backgroundDrawableFromTheme), backgroundDrawableFromTheme, Float.valueOf(this.currentIntensity));
}
} else {
BackgroundGradientDrawable.Disposable disposable = this.backgroundGradientDisposable;
if (disposable != null) {
disposable.dispose();
this.backgroundGradientDisposable = null;
}
int defaultAccentColor = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper);
int i4 = (int) this.accent.backgroundOverrideColor;
if (i4 != 0) {
defaultAccentColor = i4;
}
int defaultAccentColor2 = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to1);
long j = this.accent.backgroundGradientOverrideColor1;
int i5 = (int) j;
if (i5 == 0 && j != 0) {
defaultAccentColor2 = 0;
} else if (i5 != 0) {
defaultAccentColor2 = i5;
}
int defaultAccentColor3 = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to2);
long j2 = this.accent.backgroundGradientOverrideColor2;
int i6 = (int) j2;
if (i6 == 0 && j2 != 0) {
defaultAccentColor3 = 0;
} else if (i6 != 0) {
defaultAccentColor3 = i6;
}
int defaultAccentColor4 = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to3);
Theme.ThemeAccent themeAccent = this.accent;
long j3 = themeAccent.backgroundGradientOverrideColor3;
int i7 = (int) j3;
if (i7 == 0 && j3 != 0) {
defaultAccentColor4 = 0;
} else if (i7 != 0) {
defaultAccentColor4 = i7;
}
if (!TextUtils.isEmpty(themeAccent.patternSlug) && !Theme.hasCustomWallpaper()) {
if (defaultAccentColor3 != 0) {
MotionBackgroundDrawable background = this.backgroundImage.getBackground();
if (background instanceof MotionBackgroundDrawable) {
colorDrawable = background;
} else {
colorDrawable = new MotionBackgroundDrawable();
colorDrawable.setParentView(this.backgroundImage);
if (this.rotatePreview) {
colorDrawable.rotatePreview(false);
}
}
colorDrawable.setColors(defaultAccentColor, defaultAccentColor2, defaultAccentColor3, defaultAccentColor4);
} else if (defaultAccentColor2 != 0) {
MotionBackgroundDrawable backgroundGradientDrawable = new BackgroundGradientDrawable(BackgroundGradientDrawable.getGradientOrientation(this.accent.backgroundRotation), new int[]{defaultAccentColor, defaultAccentColor2});
this.backgroundGradientDisposable = backgroundGradientDrawable.startDithering(BackgroundGradientDrawable.Sizes.ofDeviceScreen(), new BackgroundGradientDrawable.ListenerAdapter() {
public void onSizeReady(int width, int height) {
Point point3 = AndroidUtilities.displaySize;
if ((point3.x <= point3.y) == (width <= height)) {
ThemePreviewActivity.this.backgroundImage.invalidate();
}
}
}, 100L);
colorDrawable = backgroundGradientDrawable;
} else {
colorDrawable = new ColorDrawable(defaultAccentColor);
}
this.backgroundImage.setBackground(colorDrawable);
TLRPC.TL_wallPaper tL_wallPaper4 = this.selectedPattern;
if (tL_wallPaper4 != null) {
BackgroundView backgroundView2 = this.backgroundImage;
ImageLocation forDocument2 = ImageLocation.getForDocument(((TLRPC.WallPaper) tL_wallPaper4).document);
String str2 = this.imageFilter;
TLRPC.TL_wallPaper tL_wallPaper5 = this.selectedPattern;
backgroundView2.setImage(forDocument2, str2, (ImageLocation) null, (String) null, "jpg", ((TLRPC.WallPaper) tL_wallPaper5).document.size, 1, tL_wallPaper5);
}
} else {
MotionBackgroundDrawable cachedWallpaperNonBlocking = Theme.getCachedWallpaperNonBlocking();
if (cachedWallpaperNonBlocking != null) {
if (cachedWallpaperNonBlocking instanceof MotionBackgroundDrawable) {
cachedWallpaperNonBlocking.setParentView(this.backgroundImage);
}
this.backgroundImage.setBackground(cachedWallpaperNonBlocking);
}
}
if (defaultAccentColor2 == 0) {
int patternColor = AndroidUtilities.getPatternColor(defaultAccentColor);
this.checkColor = patternColor;
this.patternColor = patternColor;
} else if (defaultAccentColor3 != 0) {
this.patternColor = MotionBackgroundDrawable.getPatternColor(defaultAccentColor, defaultAccentColor2, defaultAccentColor3, defaultAccentColor4);
this.checkColor = 754974720;
} else {
int patternColor2 = AndroidUtilities.getPatternColor(AndroidUtilities.getAverageColor(defaultAccentColor, defaultAccentColor2));
this.checkColor = patternColor2;
this.patternColor = patternColor2;
}
BackgroundView backgroundView3 = this.backgroundImage;
if (backgroundView3 != null) {
backgroundView3.getImageReceiver().setColorFilter(new PorterDuffColorFilter(this.patternColor, this.blendMode));
this.backgroundImage.getImageReceiver().setAlpha(Math.abs(this.currentIntensity));
this.backgroundImage.invalidate();
if (Theme.getActiveTheme().isDark() && (this.backgroundImage.getBackground() instanceof MotionBackgroundDrawable)) {
SeekBarView seekBarView = this.intensitySeekBar;
if (seekBarView != null) {
seekBarView.setTwoSided(true);
}
if (this.currentIntensity < 0.0f) {
this.backgroundImage.getImageReceiver().setGradientBitmap(this.backgroundImage.getBackground().getBitmap());
}
} else {
this.backgroundImage.getImageReceiver().setGradientBitmap((Bitmap) null);
SeekBarView seekBarView2 = this.intensitySeekBar;
if (seekBarView2 != null) {
seekBarView2.setTwoSided(false);
}
}
SeekBarView seekBarView3 = this.intensitySeekBar;
if (seekBarView3 != null) {
seekBarView3.setProgress(this.currentIntensity);
}
}
if (this.backgroundCheckBoxView != null) {
int i8 = 0;
while (true) {
WallpaperCheckBoxView[] wallpaperCheckBoxViewArr = this.backgroundCheckBoxView;
if (i8 >= wallpaperCheckBoxViewArr.length) {
break;
}
wallpaperCheckBoxViewArr[i8].setColor(0, defaultAccentColor);
this.backgroundCheckBoxView[i8].setColor(1, defaultAccentColor2);
this.backgroundCheckBoxView[i8].setColor(2, defaultAccentColor3);
this.backgroundCheckBoxView[i8].setColor(3, defaultAccentColor4);
i8++;
}
}
ImageView imageView = this.backgroundPlayAnimationImageView;
if (imageView != null) {
imageView.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_serviceText), PorterDuff.Mode.MULTIPLY));
}
ImageView imageView2 = this.messagesPlayAnimationImageView;
if (imageView2 != null) {
imageView2.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_serviceText), PorterDuff.Mode.MULTIPLY));
}
invalidateBlur();
}
}
this.rotatePreview = false;
}
public static class DialogsAdapter extends RecyclerListView.SelectionAdapter {
public ArrayList<DialogCell.CustomDialog> dialogs = new ArrayList<>();
public Context mContext;
public DialogsAdapter(Context context) {
this.mContext = context;
int currentTimeMillis = (int) (System.currentTimeMillis() / 1000);
DialogCell.CustomDialog customDialog = new DialogCell.CustomDialog();
customDialog.name = LocaleController.getString("ThemePreviewDialog1", R.string.ThemePreviewDialog1);
customDialog.message = LocaleController.getString("ThemePreviewDialogMessage1", R.string.ThemePreviewDialogMessage1);
customDialog.id = 0;
customDialog.unread_count = 0;
customDialog.pinned = true;
customDialog.muted = false;
customDialog.type = 0;
customDialog.date = currentTimeMillis;
customDialog.verified = false;
customDialog.isMedia = false;
customDialog.sent = 2;
this.dialogs.add(customDialog);
DialogCell.CustomDialog customDialog2 = new DialogCell.CustomDialog();
customDialog2.name = LocaleController.getString("ThemePreviewDialog2", R.string.ThemePreviewDialog2);
customDialog2.message = LocaleController.getString("ThemePreviewDialogMessage2", R.string.ThemePreviewDialogMessage2);
customDialog2.id = 1;
customDialog2.unread_count = 2;
customDialog2.pinned = false;
customDialog2.muted = false;
customDialog2.type = 0;
customDialog2.date = currentTimeMillis - 3600;
customDialog2.verified = false;
customDialog2.isMedia = false;
customDialog2.sent = -1;
this.dialogs.add(customDialog2);
DialogCell.CustomDialog customDialog3 = new DialogCell.CustomDialog();
customDialog3.name = LocaleController.getString("ThemePreviewDialog3", R.string.ThemePreviewDialog3);
customDialog3.message = LocaleController.getString("ThemePreviewDialogMessage3", R.string.ThemePreviewDialogMessage3);
customDialog3.id = 2;
customDialog3.unread_count = 3;
customDialog3.pinned = false;
customDialog3.muted = true;
customDialog3.type = 0;
customDialog3.date = currentTimeMillis - 7200;
customDialog3.verified = false;
customDialog3.isMedia = true;
customDialog3.sent = -1;
this.dialogs.add(customDialog3);
DialogCell.CustomDialog customDialog4 = new DialogCell.CustomDialog();
customDialog4.name = LocaleController.getString("ThemePreviewDialog4", R.string.ThemePreviewDialog4);
customDialog4.message = LocaleController.getString("ThemePreviewDialogMessage4", R.string.ThemePreviewDialogMessage4);
customDialog4.id = 3;
customDialog4.unread_count = 0;
customDialog4.pinned = false;
customDialog4.muted = false;
customDialog4.type = 2;
customDialog4.date = currentTimeMillis - 10800;
customDialog4.verified = false;
customDialog4.isMedia = false;
customDialog4.sent = -1;
this.dialogs.add(customDialog4);
DialogCell.CustomDialog customDialog5 = new DialogCell.CustomDialog();
customDialog5.name = LocaleController.getString("ThemePreviewDialog5", R.string.ThemePreviewDialog5);
customDialog5.message = LocaleController.getString("ThemePreviewDialogMessage5", R.string.ThemePreviewDialogMessage5);
customDialog5.id = 4;
customDialog5.unread_count = 0;
customDialog5.pinned = false;
customDialog5.muted = false;
customDialog5.type = 1;
customDialog5.date = currentTimeMillis - 14400;
customDialog5.verified = false;
customDialog5.isMedia = false;
customDialog5.sent = 2;
this.dialogs.add(customDialog5);
DialogCell.CustomDialog customDialog6 = new DialogCell.CustomDialog();
customDialog6.name = LocaleController.getString("ThemePreviewDialog6", R.string.ThemePreviewDialog6);
customDialog6.message = LocaleController.getString("ThemePreviewDialogMessage6", R.string.ThemePreviewDialogMessage6);
customDialog6.id = 5;
customDialog6.unread_count = 0;
customDialog6.pinned = false;
customDialog6.muted = false;
customDialog6.type = 0;
customDialog6.date = currentTimeMillis - 18000;
customDialog6.verified = false;
customDialog6.isMedia = false;
customDialog6.sent = -1;
this.dialogs.add(customDialog6);
DialogCell.CustomDialog customDialog7 = new DialogCell.CustomDialog();
customDialog7.name = LocaleController.getString("ThemePreviewDialog7", R.string.ThemePreviewDialog7);
customDialog7.message = LocaleController.getString("ThemePreviewDialogMessage7", R.string.ThemePreviewDialogMessage7);
customDialog7.id = 6;
customDialog7.unread_count = 0;
customDialog7.pinned = false;
customDialog7.muted = false;
customDialog7.type = 0;
customDialog7.date = currentTimeMillis - 21600;
customDialog7.verified = true;
customDialog7.isMedia = false;
customDialog7.sent = -1;
this.dialogs.add(customDialog7);
DialogCell.CustomDialog customDialog8 = new DialogCell.CustomDialog();
customDialog8.name = LocaleController.getString("ThemePreviewDialog8", R.string.ThemePreviewDialog8);
customDialog8.message = LocaleController.getString("ThemePreviewDialogMessage8", R.string.ThemePreviewDialogMessage8);
customDialog8.id = 0;
customDialog8.unread_count = 0;
customDialog8.pinned = false;
customDialog8.muted = false;
customDialog8.type = 0;
customDialog8.date = currentTimeMillis - 25200;
customDialog8.verified = true;
customDialog8.isMedia = false;
customDialog8.sent = -1;
this.dialogs.add(customDialog8);
}
public int getItemCount() {
return this.dialogs.size();
}
public boolean isEnabled(RecyclerView.ViewHolder holder) {
return holder.getItemViewType() != 1;
}
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View loadingCell;
if (viewType == 0) {
loadingCell = new DialogCell(null, this.mContext, false, false);
} else {
loadingCell = new LoadingCell(this.mContext);
}
loadingCell.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
return new RecyclerListView.Holder(loadingCell);
}
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
if (viewHolder.getItemViewType() == 0) {
DialogCell dialogCell = (DialogCell) viewHolder.itemView;
dialogCell.useSeparator = i != getItemCount() - 1;
dialogCell.setDialog(this.dialogs.get(i));
}
}
public int getItemViewType(int i) {
return i == this.dialogs.size() ? 1 : 0;
}
}
public class MessagesAdapter extends RecyclerListView.SelectionAdapter {
public Context mContext;
public ArrayList<MessageObject> messages;
public boolean showSecretMessages;
public boolean isEnabled(RecyclerView.ViewHolder holder) {
return false;
}
public MessagesAdapter(Context context) {
String str;
long j;
MessageObject messageObject;
this.showSecretMessages = ThemePreviewActivity.this.screenType == 0 && Utilities.random.nextInt(100) <= 1;
this.mContext = context;
this.messages = new ArrayList<>();
int currentTimeMillis = ((int) (System.currentTimeMillis() / 1000)) - 3600;
if (ThemePreviewActivity.this.screenType == 2) {
if (ThemePreviewActivity.this.dialogId >= 0) {
TLRPC.TL_message tL_message = new TLRPC.TL_message();
if (ThemePreviewActivity.this.currentWallpaper instanceof WallpapersListActivity.ColorWallpaper) {
((TLRPC.Message) tL_message).message = LocaleController.getString(R.string.BackgroundColorSinglePreviewLine2);
} else {
((TLRPC.Message) tL_message).message = LocaleController.getString(R.string.BackgroundPreviewLine2);
}
((TLRPC.Message) tL_message).date = currentTimeMillis + 60;
((TLRPC.Message) tL_message).dialog_id = 1L;
((TLRPC.Message) tL_message).flags = 259;
((TLRPC.Message) tL_message).id = 1;
((TLRPC.Message) tL_message).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message).out = true;
TLRPC.TL_peerUser tL_peerUser = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message).from_id = tL_peerUser;
((TLRPC.Peer) tL_peerUser).user_id = UserConfig.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).getClientUserId();
TLRPC.TL_peerUser tL_peerUser2 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message).peer_id = tL_peerUser2;
((TLRPC.Peer) tL_peerUser2).user_id = UserConfig.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).getClientUserId();
MessageObject messageObject2 = new MessageObject(this, ((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message, true, false, ThemePreviewActivity.this) {
public boolean needDrawAvatar() {
return false;
}
};
messageObject2.eventId = 1L;
messageObject2.resetLayout();
this.messages.add(messageObject2);
}
TLRPC.TL_message tL_message2 = new TLRPC.TL_message();
TLRPC.Chat chat = ThemePreviewActivity.this.dialogId < 0 ? ThemePreviewActivity.this.getMessagesController().getChat(Long.valueOf(-ThemePreviewActivity.this.dialogId)) : null;
if (chat != null) {
((TLRPC.Message) tL_message2).message = LocaleController.getString(R.string.ChannelBackgroundMessagePreview);
TLRPC.TL_message tL_message3 = new TLRPC.TL_message();
((TLRPC.Message) tL_message3).message = LocaleController.getString(R.string.ChannelBackgroundMessageReplyText);
j = 0;
messageObject = new MessageObject(this, ((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message3, true, false, ThemePreviewActivity.this) {
public boolean needDrawAvatar() {
return false;
}
};
TLRPC.TL_peerChannel tL_peerChannel = new TLRPC.TL_peerChannel();
((TLRPC.Message) tL_message2).from_id = tL_peerChannel;
((TLRPC.Peer) tL_peerChannel).channel_id = chat.id;
TLRPC.TL_peerChannel tL_peerChannel2 = new TLRPC.TL_peerChannel();
((TLRPC.Message) tL_message2).peer_id = tL_peerChannel2;
((TLRPC.Peer) tL_peerChannel2).channel_id = chat.id;
} else {
j = 0;
if (ThemePreviewActivity.this.dialogId != 0) {
((TLRPC.Message) tL_message2).message = LocaleController.getString(R.string.BackgroundColorSinglePreviewLine3);
} else if (ThemePreviewActivity.this.currentWallpaper instanceof WallpapersListActivity.ColorWallpaper) {
((TLRPC.Message) tL_message2).message = LocaleController.getString(R.string.BackgroundColorSinglePreviewLine1);
} else {
((TLRPC.Message) tL_message2).message = LocaleController.getString(R.string.BackgroundPreviewLine1);
}
((TLRPC.Message) tL_message2).from_id = new TLRPC.TL_peerUser();
TLRPC.TL_peerUser tL_peerUser3 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message2).peer_id = tL_peerUser3;
((TLRPC.Peer) tL_peerUser3).user_id = UserConfig.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).getClientUserId();
messageObject = null;
}
int i = currentTimeMillis + 60;
((TLRPC.Message) tL_message2).date = i;
((TLRPC.Message) tL_message2).dialog_id = 1L;
((TLRPC.Message) tL_message2).flags = 265;
((TLRPC.Message) tL_message2).id = 1;
((TLRPC.Message) tL_message2).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message2).out = false;
MessageObject messageObject3 = new MessageObject(this, ((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message2, messageObject, true, false, ThemePreviewActivity.this) {
public boolean needDrawAvatar() {
return false;
}
};
if (messageObject != null) {
messageObject3.customReplyName = LocaleController.getString(R.string.ChannelBackgroundMessageReplyName);
}
messageObject3.eventId = 1L;
messageObject3.resetLayout();
this.messages.add(messageObject3);
if (ThemePreviewActivity.this.dialogId == j || ThemePreviewActivity.this.serverWallpaper != null) {
return;
}
TLRPC.User user = ThemePreviewActivity.this.getMessagesController().getUser(Long.valueOf(ThemePreviewActivity.this.dialogId));
TLRPC.TL_message tL_message4 = new TLRPC.TL_message();
((TLRPC.Message) tL_message4).message = "";
MessageObject messageObject4 = new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message4, true, false);
messageObject4.eventId = 1L;
messageObject4.contentType = 5;
this.messages.add(messageObject4);
TLRPC.TL_message tL_message5 = new TLRPC.TL_message();
if (user != null) {
((TLRPC.Message) tL_message5).message = LocaleController.formatString(R.string.ChatBackgroundHint, new Object[]{UserObject.getFirstName(user)});
} else {
((TLRPC.Message) tL_message5).message = LocaleController.getString(R.string.ChannelBackgroundHint);
}
((TLRPC.Message) tL_message5).date = i;
((TLRPC.Message) tL_message5).dialog_id = 1L;
((TLRPC.Message) tL_message5).flags = 265;
((TLRPC.Message) tL_message5).from_id = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message5).id = 1;
((TLRPC.Message) tL_message5).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message5).out = false;
TLRPC.TL_peerUser tL_peerUser4 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message5).peer_id = tL_peerUser4;
((TLRPC.Peer) tL_peerUser4).user_id = UserConfig.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).getClientUserId();
MessageObject messageObject5 = new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message5, true, false);
messageObject5.eventId = 1L;
messageObject5.resetLayout();
messageObject5.contentType = 1;
this.messages.add(messageObject5);
return;
}
if (ThemePreviewActivity.this.screenType == 1) {
TLRPC.TL_message tL_message6 = new TLRPC.TL_message();
TLRPC.TL_messageMediaDocument tL_messageMediaDocument = new TLRPC.TL_messageMediaDocument();
((TLRPC.Message) tL_message6).media = tL_messageMediaDocument;
((TLRPC.MessageMedia) tL_messageMediaDocument).document = new TLRPC.TL_document();
TLRPC.Document document = ((TLRPC.Message) tL_message6).media.document;
document.mime_type = "audio/mp3";
document.file_reference = new byte[0];
document.id = -2147483648L;
document.size = 2621440L;
document.dc_id = Integer.MIN_VALUE;
TLRPC.TL_documentAttributeFilename tL_documentAttributeFilename = new TLRPC.TL_documentAttributeFilename();
((TLRPC.DocumentAttribute) tL_documentAttributeFilename).file_name = LocaleController.getString("NewThemePreviewReply2", R.string.NewThemePreviewReply2) + ".mp3";
((TLRPC.Message) tL_message6).media.document.attributes.add(tL_documentAttributeFilename);
int i2 = currentTimeMillis + 60;
((TLRPC.Message) tL_message6).date = i2;
((TLRPC.Message) tL_message6).dialog_id = 1L;
((TLRPC.Message) tL_message6).flags = 259;
TLRPC.TL_peerUser tL_peerUser5 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message6).from_id = tL_peerUser5;
((TLRPC.Peer) tL_peerUser5).user_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId();
((TLRPC.Message) tL_message6).id = 1;
((TLRPC.Message) tL_message6).out = true;
TLRPC.TL_peerUser tL_peerUser6 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message6).peer_id = tL_peerUser6;
((TLRPC.Peer) tL_peerUser6).user_id = 0L;
MessageObject messageObject6 = new MessageObject(UserConfig.selectedAccount, tL_message6, true, false);
if (BuildVars.DEBUG_PRIVATE_VERSION) {
TLRPC.TL_message tL_message7 = new TLRPC.TL_message();
((TLRPC.Message) tL_message7).message = "this is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text\nthis is very very long text";
((TLRPC.Message) tL_message7).date = currentTimeMillis + 960;
str = "audio/ogg";
((TLRPC.Message) tL_message7).dialog_id = 1L;
((TLRPC.Message) tL_message7).flags = 259;
TLRPC.TL_peerUser tL_peerUser7 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message7).from_id = tL_peerUser7;
((TLRPC.Peer) tL_peerUser7).user_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId();
((TLRPC.Message) tL_message7).id = 1;
((TLRPC.Message) tL_message7).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message7).out = true;
TLRPC.TL_peerUser tL_peerUser8 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message7).peer_id = tL_peerUser8;
((TLRPC.Peer) tL_peerUser8).user_id = 0L;
MessageObject messageObject7 = new MessageObject(UserConfig.selectedAccount, tL_message7, true, false);
messageObject7.resetLayout();
messageObject7.eventId = 1L;
this.messages.add(messageObject7);
} else {
str = "audio/ogg";
}
TLRPC.TL_message tL_message8 = new TLRPC.TL_message();
String string = LocaleController.getString("NewThemePreviewLine3", R.string.NewThemePreviewLine3);
StringBuilder sb = new StringBuilder(string);
int indexOf = string.indexOf(42);
int lastIndexOf = string.lastIndexOf(42);
if (indexOf != -1 && lastIndexOf != -1) {
sb.replace(lastIndexOf, lastIndexOf + 1, "");
sb.replace(indexOf, indexOf + 1, "");
TLRPC.TL_messageEntityTextUrl tL_messageEntityTextUrl = new TLRPC.TL_messageEntityTextUrl();
((TLRPC.MessageEntity) tL_messageEntityTextUrl).offset = indexOf;
((TLRPC.MessageEntity) tL_messageEntityTextUrl).length = (lastIndexOf - indexOf) - 1;
((TLRPC.MessageEntity) tL_messageEntityTextUrl).url = "https://telegram.org";
((TLRPC.Message) tL_message8).entities.add(tL_messageEntityTextUrl);
}
((TLRPC.Message) tL_message8).message = sb.toString();
((TLRPC.Message) tL_message8).date = currentTimeMillis + 960;
((TLRPC.Message) tL_message8).dialog_id = 1L;
((TLRPC.Message) tL_message8).flags = 259;
TLRPC.TL_peerUser tL_peerUser9 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message8).from_id = tL_peerUser9;
((TLRPC.Peer) tL_peerUser9).user_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId();
((TLRPC.Message) tL_message8).id = 1;
((TLRPC.Message) tL_message8).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message8).out = true;
TLRPC.TL_peerUser tL_peerUser10 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message8).peer_id = tL_peerUser10;
((TLRPC.Peer) tL_peerUser10).user_id = 0L;
MessageObject messageObject8 = new MessageObject(UserConfig.selectedAccount, tL_message8, true, false);
messageObject8.resetLayout();
messageObject8.eventId = 1L;
this.messages.add(messageObject8);
TLRPC.TL_message tL_message9 = new TLRPC.TL_message();
((TLRPC.Message) tL_message9).message = LocaleController.getString("NewThemePreviewLine1", R.string.NewThemePreviewLine1);
((TLRPC.Message) tL_message9).date = i2;
((TLRPC.Message) tL_message9).dialog_id = 1L;
((TLRPC.Message) tL_message9).flags = 265;
((TLRPC.Message) tL_message9).from_id = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message9).id = 1;
TLRPC.TL_messageReplyHeader tL_messageReplyHeader = new TLRPC.TL_messageReplyHeader();
((TLRPC.Message) tL_message9).reply_to = tL_messageReplyHeader;
((TLRPC.MessageReplyHeader) tL_messageReplyHeader).flags |= 16;
((TLRPC.MessageReplyHeader) tL_messageReplyHeader).reply_to_msg_id = 5;
((TLRPC.Message) tL_message9).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message9).out = false;
TLRPC.TL_peerUser tL_peerUser11 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message9).peer_id = tL_peerUser11;
((TLRPC.Peer) tL_peerUser11).user_id = UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId();
MessageObject messageObject9 = new MessageObject(UserConfig.selectedAccount, tL_message9, true, false);
messageObject9.customReplyName = LocaleController.getString("NewThemePreviewName", R.string.NewThemePreviewName);
messageObject8.customReplyName = "Test User";
messageObject9.eventId = 1L;
messageObject9.resetLayout();
messageObject9.replyMessageObject = messageObject6;
messageObject8.replyMessageObject = messageObject9;
this.messages.add(messageObject9);
this.messages.add(messageObject6);
TLRPC.TL_message tL_message10 = new TLRPC.TL_message();
((TLRPC.Message) tL_message10).date = currentTimeMillis + 120;
((TLRPC.Message) tL_message10).dialog_id = 1L;
((TLRPC.Message) tL_message10).flags = 259;
((TLRPC.Message) tL_message10).out = false;
((TLRPC.Message) tL_message10).from_id = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message10).id = 1;
TLRPC.TL_messageMediaDocument tL_messageMediaDocument2 = new TLRPC.TL_messageMediaDocument();
((TLRPC.Message) tL_message10).media = tL_messageMediaDocument2;
((TLRPC.MessageMedia) tL_messageMediaDocument2).flags |= 3;
((TLRPC.MessageMedia) tL_messageMediaDocument2).document = new TLRPC.TL_document();
TLRPC.Document document2 = ((TLRPC.Message) tL_message10).media.document;
document2.mime_type = str;
document2.file_reference = new byte[0];
TLRPC.TL_documentAttributeAudio tL_documentAttributeAudio = new TLRPC.TL_documentAttributeAudio();
((TLRPC.DocumentAttribute) tL_documentAttributeAudio).flags = 1028;
((TLRPC.DocumentAttribute) tL_documentAttributeAudio).duration = 3.0d;
((TLRPC.DocumentAttribute) tL_documentAttributeAudio).voice = true;
((TLRPC.DocumentAttribute) tL_documentAttributeAudio).waveform = new byte[]{0, 4, 17, -50, -93, 86, -103, -45, -12, -26, 63, -25, -3, 109, -114, -54, -4, -1, -1, -1, -1, -29, -1, -1, -25, -1, -1, -97, -43, 57, -57, -108, 1, -91, -4, -47, 21, 99, 10, 97, 43, 45, 115, -112, -77, 51, -63, 66, 40, 34, -122, -116, 48, -124, 16, 66, -120, 16, 68, 16, 33, 4, 1};
((TLRPC.Message) tL_message10).media.document.attributes.add(tL_documentAttributeAudio);
((TLRPC.Message) tL_message10).out = true;
TLRPC.TL_peerUser tL_peerUser12 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message10).peer_id = tL_peerUser12;
((TLRPC.Peer) tL_peerUser12).user_id = 0L;
MessageObject messageObject10 = new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message10, true, false);
messageObject10.audioProgressSec = 1;
messageObject10.audioProgress = 0.3f;
messageObject10.useCustomPhoto = true;
this.messages.add(messageObject10);
return;
}
if (this.showSecretMessages) {
TLRPC.TL_user tL_user = new TLRPC.TL_user();
((TLRPC.User) tL_user).id = 2147483647L;
((TLRPC.User) tL_user).first_name = "Me";
TLRPC.TL_user tL_user2 = new TLRPC.TL_user();
((TLRPC.User) tL_user2).id = 2147483646L;
((TLRPC.User) tL_user2).first_name = "Serj";
ArrayList arrayList = new ArrayList();
arrayList.add(tL_user);
arrayList.add(tL_user2);
MessagesController.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).putUsers(arrayList, true);
TLRPC.TL_message tL_message11 = new TLRPC.TL_message();
((TLRPC.Message) tL_message11).message = "Guess why Half-Life 3 was never released.";
int i3 = currentTimeMillis + 960;
((TLRPC.Message) tL_message11).date = i3;
((TLRPC.Message) tL_message11).dialog_id = -1L;
((TLRPC.Message) tL_message11).flags = 259;
((TLRPC.Message) tL_message11).id = 2147483646;
((TLRPC.Message) tL_message11).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message11).out = false;
TLRPC.TL_peerChat tL_peerChat = new TLRPC.TL_peerChat();
((TLRPC.Message) tL_message11).peer_id = tL_peerChat;
((TLRPC.Peer) tL_peerChat).chat_id = 1L;
TLRPC.TL_peerUser tL_peerUser13 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message11).from_id = tL_peerUser13;
((TLRPC.Peer) tL_peerUser13).user_id = ((TLRPC.User) tL_user2).id;
this.messages.add(new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message11, true, false));
TLRPC.TL_message tL_message12 = new TLRPC.TL_message();
((TLRPC.Message) tL_message12).message = "No.\nAnd every unnecessary ping of the dev delays the release for 10 days.\nEvery request for ETA delays the release for 2 weeks.";
((TLRPC.Message) tL_message12).date = i3;
((TLRPC.Message) tL_message12).dialog_id = -1L;
((TLRPC.Message) tL_message12).flags = 259;
((TLRPC.Message) tL_message12).id = 1;
((TLRPC.Message) tL_message12).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message12).out = false;
TLRPC.TL_peerChat tL_peerChat2 = new TLRPC.TL_peerChat();
((TLRPC.Message) tL_message12).peer_id = tL_peerChat2;
((TLRPC.Peer) tL_peerChat2).chat_id = 1L;
TLRPC.TL_peerUser tL_peerUser14 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message12).from_id = tL_peerUser14;
((TLRPC.Peer) tL_peerUser14).user_id = ((TLRPC.User) tL_user2).id;
this.messages.add(new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message12, true, false));
TLRPC.TL_message tL_message13 = new TLRPC.TL_message();
((TLRPC.Message) tL_message13).message = "Is source code for Android coming anytime soon?";
((TLRPC.Message) tL_message13).date = currentTimeMillis + 600;
((TLRPC.Message) tL_message13).dialog_id = -1L;
((TLRPC.Message) tL_message13).flags = 259;
((TLRPC.Message) tL_message13).id = 1;
((TLRPC.Message) tL_message13).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message13).out = false;
TLRPC.TL_peerChat tL_peerChat3 = new TLRPC.TL_peerChat();
((TLRPC.Message) tL_message13).peer_id = tL_peerChat3;
((TLRPC.Peer) tL_peerChat3).chat_id = 1L;
TLRPC.TL_peerUser tL_peerUser15 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message13).from_id = tL_peerUser15;
((TLRPC.Peer) tL_peerUser15).user_id = ((TLRPC.User) tL_user).id;
this.messages.add(new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message13, true, false));
return;
}
TLRPC.TL_message tL_message14 = new TLRPC.TL_message();
((TLRPC.Message) tL_message14).message = LocaleController.getString("ThemePreviewLine1", R.string.ThemePreviewLine1);
int i4 = currentTimeMillis + 60;
((TLRPC.Message) tL_message14).date = i4;
((TLRPC.Message) tL_message14).dialog_id = 1L;
((TLRPC.Message) tL_message14).flags = 259;
TLRPC.TL_peerUser tL_peerUser16 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message14).from_id = tL_peerUser16;
((TLRPC.Peer) tL_peerUser16).user_id = UserConfig.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).getClientUserId();
((TLRPC.Message) tL_message14).id = 1;
((TLRPC.Message) tL_message14).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message14).out = true;
TLRPC.TL_peerUser tL_peerUser17 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message14).peer_id = tL_peerUser17;
((TLRPC.Peer) tL_peerUser17).user_id = 0L;
MessageObject messageObject11 = new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message14, true, false);
TLRPC.TL_message tL_message15 = new TLRPC.TL_message();
((TLRPC.Message) tL_message15).message = LocaleController.getString("ThemePreviewLine2", R.string.ThemePreviewLine2);
((TLRPC.Message) tL_message15).date = currentTimeMillis + 960;
((TLRPC.Message) tL_message15).dialog_id = 1L;
((TLRPC.Message) tL_message15).flags = 259;
TLRPC.TL_peerUser tL_peerUser18 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message15).from_id = tL_peerUser18;
((TLRPC.Peer) tL_peerUser18).user_id = UserConfig.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).getClientUserId();
((TLRPC.Message) tL_message15).id = 1;
((TLRPC.Message) tL_message15).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message15).out = true;
TLRPC.TL_peerUser tL_peerUser19 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message15).peer_id = tL_peerUser19;
((TLRPC.Peer) tL_peerUser19).user_id = 0L;
this.messages.add(new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message15, true, false));
TLRPC.TL_message tL_message16 = new TLRPC.TL_message();
((TLRPC.Message) tL_message16).date = currentTimeMillis + 130;
((TLRPC.Message) tL_message16).dialog_id = 1L;
((TLRPC.Message) tL_message16).flags = 259;
((TLRPC.Message) tL_message16).from_id = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message16).id = 5;
TLRPC.TL_messageMediaDocument tL_messageMediaDocument3 = new TLRPC.TL_messageMediaDocument();
((TLRPC.Message) tL_message16).media = tL_messageMediaDocument3;
((TLRPC.MessageMedia) tL_messageMediaDocument3).flags |= 3;
((TLRPC.MessageMedia) tL_messageMediaDocument3).document = new TLRPC.TL_document();
TLRPC.Document document3 = ((TLRPC.Message) tL_message16).media.document;
document3.mime_type = "audio/mp4";
document3.file_reference = new byte[0];
TLRPC.TL_documentAttributeAudio tL_documentAttributeAudio2 = new TLRPC.TL_documentAttributeAudio();
((TLRPC.DocumentAttribute) tL_documentAttributeAudio2).duration = 243.0d;
((TLRPC.DocumentAttribute) tL_documentAttributeAudio2).performer = LocaleController.getString("ThemePreviewSongPerformer", R.string.ThemePreviewSongPerformer);
((TLRPC.DocumentAttribute) tL_documentAttributeAudio2).title = LocaleController.getString("ThemePreviewSongTitle", R.string.ThemePreviewSongTitle);
((TLRPC.Message) tL_message16).media.document.attributes.add(tL_documentAttributeAudio2);
((TLRPC.Message) tL_message16).out = false;
TLRPC.TL_peerUser tL_peerUser20 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message16).peer_id = tL_peerUser20;
((TLRPC.Peer) tL_peerUser20).user_id = UserConfig.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).getClientUserId();
this.messages.add(new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message16, true, false));
TLRPC.TL_message tL_message17 = new TLRPC.TL_message();
((TLRPC.Message) tL_message17).message = LocaleController.getString("ThemePreviewLine3", R.string.ThemePreviewLine3);
((TLRPC.Message) tL_message17).date = i4;
((TLRPC.Message) tL_message17).dialog_id = 1L;
((TLRPC.Message) tL_message17).flags = 265;
((TLRPC.Message) tL_message17).from_id = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message17).id = 1;
TLRPC.TL_messageReplyHeader tL_messageReplyHeader2 = new TLRPC.TL_messageReplyHeader();
((TLRPC.Message) tL_message17).reply_to = tL_messageReplyHeader2;
((TLRPC.MessageReplyHeader) tL_messageReplyHeader2).flags |= 16;
((TLRPC.MessageReplyHeader) tL_messageReplyHeader2).reply_to_msg_id = 5;
((TLRPC.Message) tL_message17).media = new TLRPC.TL_messageMediaEmpty();
((TLRPC.Message) tL_message17).out = false;
TLRPC.TL_peerUser tL_peerUser21 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message17).peer_id = tL_peerUser21;
((TLRPC.Peer) tL_peerUser21).user_id = UserConfig.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).getClientUserId();
MessageObject messageObject12 = new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message17, true, false);
messageObject12.customReplyName = LocaleController.getString("ThemePreviewLine3Reply", R.string.ThemePreviewLine3Reply);
messageObject12.replyMessageObject = messageObject11;
this.messages.add(messageObject12);
TLRPC.TL_message tL_message18 = new TLRPC.TL_message();
((TLRPC.Message) tL_message18).date = currentTimeMillis + 120;
((TLRPC.Message) tL_message18).dialog_id = 1L;
((TLRPC.Message) tL_message18).flags = 259;
TLRPC.TL_peerUser tL_peerUser22 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message18).from_id = tL_peerUser22;
((TLRPC.Peer) tL_peerUser22).user_id = UserConfig.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).getClientUserId();
((TLRPC.Message) tL_message18).id = 1;
TLRPC.TL_messageMediaDocument tL_messageMediaDocument4 = new TLRPC.TL_messageMediaDocument();
((TLRPC.Message) tL_message18).media = tL_messageMediaDocument4;
((TLRPC.MessageMedia) tL_messageMediaDocument4).flags |= 3;
((TLRPC.MessageMedia) tL_messageMediaDocument4).document = new TLRPC.TL_document();
TLRPC.Document document4 = ((TLRPC.Message) tL_message18).media.document;
document4.mime_type = "audio/ogg";
document4.file_reference = new byte[0];
TLRPC.TL_documentAttributeAudio tL_documentAttributeAudio3 = new TLRPC.TL_documentAttributeAudio();
((TLRPC.DocumentAttribute) tL_documentAttributeAudio3).flags = 1028;
((TLRPC.DocumentAttribute) tL_documentAttributeAudio3).duration = 3.0d;
((TLRPC.DocumentAttribute) tL_documentAttributeAudio3).voice = true;
((TLRPC.DocumentAttribute) tL_documentAttributeAudio3).waveform = new byte[]{0, 4, 17, -50, -93, 86, -103, -45, -12, -26, 63, -25, -3, 109, -114, -54, -4, -1, -1, -1, -1, -29, -1, -1, -25, -1, -1, -97, -43, 57, -57, -108, 1, -91, -4, -47, 21, 99, 10, 97, 43, 45, 115, -112, -77, 51, -63, 66, 40, 34, -122, -116, 48, -124, 16, 66, -120, 16, 68, 16, 33, 4, 1};
((TLRPC.Message) tL_message18).media.document.attributes.add(tL_documentAttributeAudio3);
((TLRPC.Message) tL_message18).out = true;
TLRPC.TL_peerUser tL_peerUser23 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message18).peer_id = tL_peerUser23;
((TLRPC.Peer) tL_peerUser23).user_id = 0L;
MessageObject messageObject13 = new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message18, true, false);
messageObject13.audioProgressSec = 1;
messageObject13.audioProgress = 0.3f;
messageObject13.useCustomPhoto = true;
this.messages.add(messageObject13);
this.messages.add(messageObject11);
TLRPC.TL_message tL_message19 = new TLRPC.TL_message();
((TLRPC.Message) tL_message19).date = currentTimeMillis + 10;
((TLRPC.Message) tL_message19).dialog_id = 1L;
((TLRPC.Message) tL_message19).flags = 257;
((TLRPC.Message) tL_message19).from_id = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message19).id = 1;
TLRPC.TL_messageMediaPhoto tL_messageMediaPhoto = new TLRPC.TL_messageMediaPhoto();
((TLRPC.Message) tL_message19).media = tL_messageMediaPhoto;
((TLRPC.MessageMedia) tL_messageMediaPhoto).flags |= 3;
((TLRPC.MessageMedia) tL_messageMediaPhoto).photo = new TLRPC.TL_photo();
TLRPC.Photo photo = ((TLRPC.Message) tL_message19).media.photo;
photo.file_reference = new byte[0];
photo.has_stickers = false;
photo.id = 1L;
photo.access_hash = 0L;
photo.date = currentTimeMillis;
TLRPC.TL_photoSize tL_photoSize = new TLRPC.TL_photoSize();
((TLRPC.PhotoSize) tL_photoSize).size = 0;
((TLRPC.PhotoSize) tL_photoSize).w = 500;
((TLRPC.PhotoSize) tL_photoSize).h = 302;
((TLRPC.PhotoSize) tL_photoSize).type = "s";
((TLRPC.PhotoSize) tL_photoSize).location = new TLRPC.TL_fileLocationUnavailable();
((TLRPC.Message) tL_message19).media.photo.sizes.add(tL_photoSize);
((TLRPC.Message) tL_message19).message = LocaleController.getString("ThemePreviewLine4", R.string.ThemePreviewLine4);
((TLRPC.Message) tL_message19).out = false;
TLRPC.TL_peerUser tL_peerUser24 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_message19).peer_id = tL_peerUser24;
((TLRPC.Peer) tL_peerUser24).user_id = UserConfig.getInstance(((BaseFragment) ThemePreviewActivity.this).currentAccount).getClientUserId();
MessageObject messageObject14 = new MessageObject(((BaseFragment) ThemePreviewActivity.this).currentAccount, tL_message19, true, false);
messageObject14.useCustomPhoto = true;
this.messages.add(messageObject14);
}
public final boolean hasButtons() {
if (ThemePreviewActivity.this.messagesButtonsContainer != null && ThemePreviewActivity.this.screenType == 1 && ThemePreviewActivity.this.colorType == 3 && ThemePreviewActivity.this.accent.myMessagesGradientAccentColor2 != 0) {
return true;
}
if (ThemePreviewActivity.this.backgroundButtonsContainer != null) {
if (ThemePreviewActivity.this.screenType == 2) {
return true;
}
if (ThemePreviewActivity.this.screenType == 1 && ThemePreviewActivity.this.colorType == 2) {
return true;
}
}
return false;
}
public int getItemCount() {
int size = this.messages.size();
return hasButtons() ? size + 1 : size;
}
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
FrameLayout frameLayout;
if (i == 0) {
?? chatMessageCell = new ChatMessageCell(this.mContext, ((BaseFragment) ThemePreviewActivity.this).currentAccount, false, null, new Theme.ResourcesProvider() {
@Override
public ColorFilter getAnimatedEmojiColorFilter() {
return Theme.ResourcesProvider.CC.$default$getAnimatedEmojiColorFilter(this);
}
@Override
public void setAnimatedColor(int i2, int i3) {
Theme.ResourcesProvider.CC.$default$setAnimatedColor(this, i2, i3);
}
@Override
public int getColor(int key) {
return ThemePreviewActivity.this.themeDelegate.getColor(key);
}
@Override
public Drawable getDrawable(String drawableKey) {
if (drawableKey.equals("drawableMsgOut")) {
return ThemePreviewActivity.this.msgOutDrawable;
}
if (drawableKey.equals("drawableMsgOutSelected")) {
return ThemePreviewActivity.this.msgOutDrawableSelected;
}
if (drawableKey.equals("drawableMsgOutMedia")) {
return ThemePreviewActivity.this.msgOutMediaDrawable;
}
if (drawableKey.equals("drawableMsgOutMediaSelected")) {
return ThemePreviewActivity.this.msgOutMediaDrawableSelected;
}
ThemeDelegate themeDelegate = ThemePreviewActivity.this.themeDelegate;
if (themeDelegate != null) {
return themeDelegate.getDrawable(drawableKey);
}
return Theme.getThemeDrawable(drawableKey);
}
@Override
public boolean isDark() {
return ThemePreviewActivity.this.themeDelegate.isDark();
}
@Override
public int getCurrentColor(int key) {
return ThemePreviewActivity.this.themeDelegate.getCurrentColor(key);
}
@Override
public int getColorOrDefault(int key) {
return ThemePreviewActivity.this.themeDelegate.getColorOrDefault(key);
}
@Override
public Paint getPaint(String paintKey) {
return ThemePreviewActivity.this.themeDelegate.getPaint(paintKey);
}
@Override
public boolean hasGradientService() {
return ThemePreviewActivity.this.themeDelegate.hasGradientService();
}
@Override
public void applyServiceShaderMatrix(int w, int h, float translationX, float translationY) {
ThemeDelegate themeDelegate = ThemePreviewActivity.this.themeDelegate;
if (themeDelegate == null) {
Theme.applyServiceShaderMatrix(w, h, translationX, translationY);
} else {
themeDelegate.applyServiceShaderMatrix(w, h, translationX, translationY);
}
}
});
chatMessageCell.setDelegate(new ChatMessageCell.ChatMessageCellDelegate(this) {
@Override
public boolean canDrawOutboundsContent() {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$canDrawOutboundsContent(this);
}
@Override
public boolean canPerformActions() {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$canPerformActions(this);
}
@Override
public void didLongPress(ChatMessageCell chatMessageCell2, float f, float f2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didLongPress(this, chatMessageCell2, f, f2);
}
@Override
public boolean didLongPressAvatar(ChatMessageCell chatMessageCell2, TLRPC.User user, float f, float f2) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$didLongPressAvatar(this, chatMessageCell2, user, f, f2);
}
@Override
public void didLongPressBotButton(ChatMessageCell chatMessageCell2, TLRPC.KeyboardButton keyboardButton) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didLongPressBotButton(this, chatMessageCell2, keyboardButton);
}
@Override
public boolean didLongPressChannelAvatar(ChatMessageCell chatMessageCell2, TLRPC.Chat chat, int i2, float f, float f2) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$didLongPressChannelAvatar(this, chatMessageCell2, chat, i2, f, f2);
}
@Override
public boolean didLongPressSideButton(ChatMessageCell chatMessageCell2) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$didLongPressSideButton(this, chatMessageCell2);
}
@Override
public boolean didLongPressUserAvatar(ChatMessageCell chatMessageCell2, TLRPC.User user, float f, float f2) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$didLongPressUserAvatar(this, chatMessageCell2, user, f, f2);
}
@Override
public void didPressAboutRevenueSharingAds() {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressAboutRevenueSharingAds(this);
}
@Override
public boolean didPressAnimatedEmoji(ChatMessageCell chatMessageCell2, AnimatedEmojiSpan animatedEmojiSpan) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressAnimatedEmoji(this, chatMessageCell2, animatedEmojiSpan);
}
@Override
public void didPressBoostCounter(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressBoostCounter(this, chatMessageCell2);
}
@Override
public void didPressBotButton(ChatMessageCell chatMessageCell2, TLRPC.KeyboardButton keyboardButton) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressBotButton(this, chatMessageCell2, keyboardButton);
}
@Override
public void didPressCancelSendButton(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressCancelSendButton(this, chatMessageCell2);
}
@Override
public void didPressChannelAvatar(ChatMessageCell chatMessageCell2, TLRPC.Chat chat, int i2, float f, float f2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressChannelAvatar(this, chatMessageCell2, chat, i2, f, f2);
}
@Override
public void didPressChannelRecommendation(ChatMessageCell chatMessageCell2, TLRPC.Chat chat, boolean z) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressChannelRecommendation(this, chatMessageCell2, chat, z);
}
@Override
public void didPressChannelRecommendationsClose(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressChannelRecommendationsClose(this, chatMessageCell2);
}
@Override
public void didPressCodeCopy(ChatMessageCell chatMessageCell2, MessageObject.TextLayoutBlock textLayoutBlock) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressCodeCopy(this, chatMessageCell2, textLayoutBlock);
}
@Override
public void didPressCommentButton(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressCommentButton(this, chatMessageCell2);
}
@Override
public void didPressDialogButton(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressDialogButton(this, chatMessageCell2);
}
@Override
public void didPressEffect(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressEffect(this, chatMessageCell2);
}
@Override
public void didPressExtendedMediaPreview(ChatMessageCell chatMessageCell2, TLRPC.KeyboardButton keyboardButton) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressExtendedMediaPreview(this, chatMessageCell2, keyboardButton);
}
@Override
public void didPressFactCheck(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressFactCheck(this, chatMessageCell2);
}
@Override
public void didPressFactCheckWhat(ChatMessageCell chatMessageCell2, int i2, int i3) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressFactCheckWhat(this, chatMessageCell2, i2, i3);
}
@Override
public void didPressGiveawayChatButton(ChatMessageCell chatMessageCell2, int i2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressGiveawayChatButton(this, chatMessageCell2, i2);
}
@Override
public void didPressHiddenForward(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressHiddenForward(this, chatMessageCell2);
}
@Override
public void didPressHint(ChatMessageCell chatMessageCell2, int i2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressHint(this, chatMessageCell2, i2);
}
@Override
public void didPressImage(ChatMessageCell chatMessageCell2, float f, float f2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressImage(this, chatMessageCell2, f, f2);
}
@Override
public void didPressInstantButton(ChatMessageCell chatMessageCell2, int i2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressInstantButton(this, chatMessageCell2, i2);
}
@Override
public void didPressMoreChannelRecommendations(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressMoreChannelRecommendations(this, chatMessageCell2);
}
@Override
public void didPressOther(ChatMessageCell chatMessageCell2, float f, float f2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressOther(this, chatMessageCell2, f, f2);
}
@Override
public void didPressReaction(ChatMessageCell chatMessageCell2, TLRPC.ReactionCount reactionCount, boolean z) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressReaction(this, chatMessageCell2, reactionCount, z);
}
@Override
public void didPressReplyMessage(ChatMessageCell chatMessageCell2, int i2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressReplyMessage(this, chatMessageCell2, i2);
}
@Override
public void didPressSideButton(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressSideButton(this, chatMessageCell2);
}
@Override
public void didPressSponsoredClose(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressSponsoredClose(this, chatMessageCell2);
}
@Override
public void didPressSponsoredInfo(ChatMessageCell chatMessageCell2, float f, float f2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressSponsoredInfo(this, chatMessageCell2, f, f2);
}
@Override
public void didPressTime(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressTime(this, chatMessageCell2);
}
@Override
public void didPressTopicButton(ChatMessageCell chatMessageCell2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressTopicButton(this, chatMessageCell2);
}
@Override
public void didPressUrl(ChatMessageCell chatMessageCell2, CharacterStyle characterStyle, boolean z) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressUrl(this, chatMessageCell2, characterStyle, z);
}
@Override
public void didPressUserAvatar(ChatMessageCell chatMessageCell2, TLRPC.User user, float f, float f2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressUserAvatar(this, chatMessageCell2, user, f, f2);
}
@Override
public void didPressUserStatus(ChatMessageCell chatMessageCell2, TLRPC.User user, TLRPC.Document document) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressUserStatus(this, chatMessageCell2, user, document);
}
@Override
public void didPressViaBot(ChatMessageCell chatMessageCell2, String str) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressViaBot(this, chatMessageCell2, str);
}
@Override
public void didPressViaBotNotInline(ChatMessageCell chatMessageCell2, long j) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressViaBotNotInline(this, chatMessageCell2, j);
}
@Override
public void didPressVoteButtons(ChatMessageCell chatMessageCell2, ArrayList arrayList, int i2, int i3, int i4) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressVoteButtons(this, chatMessageCell2, arrayList, i2, i3, i4);
}
@Override
public void didPressWebPage(ChatMessageCell chatMessageCell2, TLRPC.WebPage webPage, String str, boolean z) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didPressWebPage(this, chatMessageCell2, webPage, str, z);
}
@Override
public void didStartVideoStream(MessageObject messageObject) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$didStartVideoStream(this, messageObject);
}
@Override
public boolean disableThemeModifications() {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$disableThemeModifications(this);
}
@Override
public boolean doNotShowLoadingReply(MessageObject messageObject) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$doNotShowLoadingReply(this, messageObject);
}
@Override
public void forceUpdate(ChatMessageCell chatMessageCell2, boolean z) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$forceUpdate(this, chatMessageCell2, z);
}
@Override
public String getAdminRank(long j) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$getAdminRank(this, j);
}
@Override
public long getDialogId() {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$getDialogId(this);
}
@Override
public PinchToZoomHelper getPinchToZoomHelper() {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$getPinchToZoomHelper(this);
}
@Override
public String getProgressLoadingBotButtonUrl(ChatMessageCell chatMessageCell2) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$getProgressLoadingBotButtonUrl(this, chatMessageCell2);
}
@Override
public CharacterStyle getProgressLoadingLink(ChatMessageCell chatMessageCell2) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$getProgressLoadingLink(this, chatMessageCell2);
}
@Override
public TextSelectionHelper.ChatListTextSelectionHelper getTextSelectionHelper() {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$getTextSelectionHelper(this);
}
@Override
public boolean hasSelectedMessages() {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$hasSelectedMessages(this);
}
@Override
public void invalidateBlur() {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$invalidateBlur(this);
}
@Override
public boolean isLandscape() {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$isLandscape(this);
}
@Override
public boolean isProgressLoading(ChatMessageCell chatMessageCell2, int i2) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$isProgressLoading(this, chatMessageCell2, i2);
}
@Override
public boolean isReplyOrSelf() {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$isReplyOrSelf(this);
}
@Override
public boolean keyboardIsOpened() {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$keyboardIsOpened(this);
}
@Override
public void needOpenWebView(MessageObject messageObject, String str, String str2, String str3, String str4, int i2, int i3) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$needOpenWebView(this, messageObject, str, str2, str3, str4, i2, i3);
}
@Override
public boolean needPlayMessage(ChatMessageCell chatMessageCell2, MessageObject messageObject, boolean z) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$needPlayMessage(this, chatMessageCell2, messageObject, z);
}
@Override
public void needReloadPolls() {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$needReloadPolls(this);
}
@Override
public void needShowPremiumBulletin(int i2) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$needShowPremiumBulletin(this, i2);
}
@Override
public boolean onAccessibilityAction(int i2, Bundle bundle) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$onAccessibilityAction(this, i2, bundle);
}
@Override
public void onDiceFinished() {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$onDiceFinished(this);
}
@Override
public void setShouldNotRepeatSticker(MessageObject messageObject) {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$setShouldNotRepeatSticker(this, messageObject);
}
@Override
public boolean shouldDrawThreadProgress(ChatMessageCell chatMessageCell2, boolean z) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$shouldDrawThreadProgress(this, chatMessageCell2, z);
}
@Override
public boolean shouldRepeatSticker(MessageObject messageObject) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$shouldRepeatSticker(this, messageObject);
}
@Override
public boolean shouldShowDialogButton(ChatMessageCell chatMessageCell2) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$shouldShowDialogButton(this, chatMessageCell2);
}
@Override
public boolean shouldShowTopicButton(ChatMessageCell chatMessageCell2) {
return ChatMessageCell.ChatMessageCellDelegate.CC.$default$shouldShowTopicButton(this, chatMessageCell2);
}
@Override
public void videoTimerReached() {
ChatMessageCell.ChatMessageCellDelegate.CC.$default$videoTimerReached(this);
}
});
frameLayout = chatMessageCell;
} else if (i == 1) {
?? chatActionCell = new ChatActionCell(this.mContext, false, ThemePreviewActivity.this.themeDelegate);
chatActionCell.setDelegate(new ChatActionCell.ChatActionCellDelegate(this) {
@Override
public boolean canDrawOutboundsContent() {
return ChatActionCell.ChatActionCellDelegate.CC.$default$canDrawOutboundsContent(this);
}
@Override
public void didClickButton(ChatActionCell chatActionCell2) {
ChatActionCell.ChatActionCellDelegate.CC.$default$didClickButton(this, chatActionCell2);
}
@Override
public void didClickImage(ChatActionCell chatActionCell2) {
ChatActionCell.ChatActionCellDelegate.CC.$default$didClickImage(this, chatActionCell2);
}
@Override
public boolean didLongPress(ChatActionCell chatActionCell2, float f, float f2) {
return ChatActionCell.ChatActionCellDelegate.CC.$default$didLongPress(this, chatActionCell2, f, f2);
}
@Override
public void didOpenPremiumGift(ChatActionCell chatActionCell2, TLRPC.TL_premiumGiftOption tL_premiumGiftOption, String str, boolean z) {
ChatActionCell.ChatActionCellDelegate.CC.$default$didOpenPremiumGift(this, chatActionCell2, tL_premiumGiftOption, str, z);
}
@Override
public void didOpenPremiumGiftChannel(ChatActionCell chatActionCell2, String str, boolean z) {
ChatActionCell.ChatActionCellDelegate.CC.$default$didOpenPremiumGiftChannel(this, chatActionCell2, str, z);
}
@Override
public void didPressReplyMessage(ChatActionCell chatActionCell2, int i2) {
ChatActionCell.ChatActionCellDelegate.CC.$default$didPressReplyMessage(this, chatActionCell2, i2);
}
@Override
public BaseFragment getBaseFragment() {
return ChatActionCell.ChatActionCellDelegate.CC.$default$getBaseFragment(this);
}
@Override
public long getDialogId() {
return ChatActionCell.ChatActionCellDelegate.CC.$default$getDialogId(this);
}
@Override
public long getTopicId() {
return ChatActionCell.ChatActionCellDelegate.CC.$default$getTopicId(this);
}
@Override
public void needOpenInviteLink(TLRPC.TL_chatInviteExported tL_chatInviteExported) {
ChatActionCell.ChatActionCellDelegate.CC.$default$needOpenInviteLink(this, tL_chatInviteExported);
}
@Override
public void needOpenUserProfile(long j) {
ChatActionCell.ChatActionCellDelegate.CC.$default$needOpenUserProfile(this, j);
}
@Override
public void needShowEffectOverlay(ChatActionCell chatActionCell2, TLRPC.Document document, TLRPC.VideoSize videoSize) {
ChatActionCell.ChatActionCellDelegate.CC.$default$needShowEffectOverlay(this, chatActionCell2, document, videoSize);
}
});
frameLayout = chatActionCell;
} else if (i == 2) {
if (ThemePreviewActivity.this.backgroundButtonsContainer.getParent() != null) {
((ViewGroup) ThemePreviewActivity.this.backgroundButtonsContainer.getParent()).removeView(ThemePreviewActivity.this.backgroundButtonsContainer);
}
FrameLayout frameLayout2 = new FrameLayout(this, this.mContext) {
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthMeasureSpec), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(60.0f), 1073741824));
}
};
frameLayout2.addView(ThemePreviewActivity.this.backgroundButtonsContainer, LayoutHelper.createFrame(-1, 76, 17));
frameLayout = frameLayout2;
} else if (i == 5) {
frameLayout = new View(this, ThemePreviewActivity.this.getContext()) {
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(4.0f), 1073741824));
}
};
} else {
if (ThemePreviewActivity.this.messagesButtonsContainer.getParent() != null) {
((ViewGroup) ThemePreviewActivity.this.messagesButtonsContainer.getParent()).removeView(ThemePreviewActivity.this.messagesButtonsContainer);
}
FrameLayout frameLayout3 = new FrameLayout(this, this.mContext) {
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthMeasureSpec), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(60.0f), 1073741824));
}
};
frameLayout3.addView(ThemePreviewActivity.this.messagesButtonsContainer, LayoutHelper.createFrame(-1, 76, 17));
frameLayout = frameLayout3;
}
frameLayout.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
return new RecyclerListView.Holder(frameLayout);
}
public void onBindViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder r11, int r12) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ThemePreviewActivity.MessagesAdapter.onBindViewHolder(androidx.recyclerview.widget.RecyclerView$ViewHolder, int):void");
}
public int getItemViewType(int position) {
if (hasButtons()) {
if (position == 0) {
return ThemePreviewActivity.this.colorType == 3 ? 3 : 2;
}
position--;
}
if (position < 0 || position >= this.messages.size()) {
return 4;
}
return this.messages.get(position).contentType;
}
}
public class PatternsAdapter extends RecyclerListView.SelectionAdapter {
public Context mContext;
public int getItemViewType(int position) {
return 0;
}
public boolean isEnabled(RecyclerView.ViewHolder holder) {
return false;
}
public PatternsAdapter(Context context) {
this.mContext = context;
}
public int getItemCount() {
if (ThemePreviewActivity.this.patterns != null) {
return ThemePreviewActivity.this.patterns.size();
}
return 0;
}
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new RecyclerListView.Holder(new PatternCell(this.mContext, ThemePreviewActivity.this.maxWallpaperSize, new PatternCell.PatternCellDelegate() {
@Override
public TLRPC.TL_wallPaper getSelectedPattern() {
return ThemePreviewActivity.this.selectedPattern;
}
@Override
public int getCheckColor() {
return ThemePreviewActivity.this.checkColor;
}
@Override
public int getBackgroundColor() {
if (ThemePreviewActivity.this.screenType == 2) {
return ThemePreviewActivity.this.backgroundColor;
}
int defaultAccentColor = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper);
int i = (int) ThemePreviewActivity.this.accent.backgroundOverrideColor;
return i != 0 ? i : defaultAccentColor;
}
@Override
public int getBackgroundGradientColor1() {
if (ThemePreviewActivity.this.screenType == 2) {
return ThemePreviewActivity.this.backgroundGradientColor1;
}
int defaultAccentColor = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to1);
int i = (int) ThemePreviewActivity.this.accent.backgroundGradientOverrideColor1;
return i != 0 ? i : defaultAccentColor;
}
@Override
public int getBackgroundGradientColor2() {
if (ThemePreviewActivity.this.screenType == 2) {
return ThemePreviewActivity.this.backgroundGradientColor2;
}
int defaultAccentColor = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to2);
int i = (int) ThemePreviewActivity.this.accent.backgroundGradientOverrideColor2;
return i != 0 ? i : defaultAccentColor;
}
@Override
public int getBackgroundGradientColor3() {
if (ThemePreviewActivity.this.screenType == 2) {
return ThemePreviewActivity.this.backgroundGradientColor3;
}
int defaultAccentColor = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to3);
int i = (int) ThemePreviewActivity.this.accent.backgroundGradientOverrideColor3;
return i != 0 ? i : defaultAccentColor;
}
@Override
public int getBackgroundGradientAngle() {
if (ThemePreviewActivity.this.screenType == 2) {
return ThemePreviewActivity.this.backgroundRotation;
}
return ThemePreviewActivity.this.accent.backgroundRotation;
}
@Override
public float getIntensity() {
return ThemePreviewActivity.this.currentIntensity;
}
@Override
public int getPatternColor() {
return ThemePreviewActivity.this.patternColor;
}
}));
}
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
PatternCell patternCell = (PatternCell) holder.itemView;
patternCell.setPattern((TLRPC.TL_wallPaper) ThemePreviewActivity.this.patterns.get(position));
patternCell.getImageReceiver().setColorFilter(new PorterDuffColorFilter(ThemePreviewActivity.this.patternColor, ThemePreviewActivity.this.blendMode));
if (Build.VERSION.SDK_INT >= 29) {
int i = 0;
if (ThemePreviewActivity.this.screenType == 1) {
int defaultAccentColor = Theme.getDefaultAccentColor(Theme.key_chat_wallpaper_gradient_to2);
int i2 = (int) ThemePreviewActivity.this.accent.backgroundGradientOverrideColor2;
if (i2 != 0 || ThemePreviewActivity.this.accent.backgroundGradientOverrideColor2 == 0) {
if (i2 != 0) {
defaultAccentColor = i2;
}
i = defaultAccentColor;
}
} else if (ThemePreviewActivity.this.currentWallpaper instanceof WallpapersListActivity.ColorWallpaper) {
i = ThemePreviewActivity.this.backgroundGradientColor2;
}
if (i != 0 && ThemePreviewActivity.this.currentIntensity >= 0.0f) {
ThemePreviewActivity.this.backgroundImage.getImageReceiver().setBlendMode(BlendMode.SOFT_LIGHT);
} else {
patternCell.getImageReceiver().setBlendMode((Object) null);
}
}
}
}
public ArrayList<ThemeDescription> getThemeDescriptionsInternal() {
ThemeDescription.ThemeDescriptionDelegate themeDescriptionDelegate = new ThemeDescription.ThemeDescriptionDelegate() {
@Override
public final void didSetColor() {
ThemePreviewActivity.this.lambda$getThemeDescriptionsInternal$33();
}
@Override
public void onAnimationProgress(float f) {
ThemeDescription.ThemeDescriptionDelegate.CC.$default$onAnimationProgress(this, f);
}
};
ArrayList<ThemeDescription> arrayList = new ArrayList<>();
FrameLayout frameLayout = this.page1;
int i = ThemeDescription.FLAG_BACKGROUND;
int i2 = Theme.key_windowBackgroundWhite;
arrayList.add(new ThemeDescription(frameLayout, i, null, null, null, themeDescriptionDelegate, i2));
ViewPager viewPager = this.viewPager;
int i3 = ThemeDescription.FLAG_LISTGLOWCOLOR;
int i4 = Theme.key_actionBarDefault;
arrayList.add(new ThemeDescription(viewPager, i3, null, null, null, null, i4));
arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, i4));
ActionBar actionBar = ((BaseFragment) this).actionBar;
int i5 = ThemeDescription.FLAG_AB_SELECTORCOLOR;
int i6 = Theme.key_actionBarDefaultSelector;
arrayList.add(new ThemeDescription(actionBar, i5, null, null, null, null, i6));
ActionBar actionBar2 = ((BaseFragment) this).actionBar;
int i7 = ThemeDescription.FLAG_AB_TITLECOLOR;
int i8 = Theme.key_actionBarDefaultTitle;
arrayList.add(new ThemeDescription(actionBar2, i7, null, null, null, null, i8));
arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SEARCH, null, null, null, null, Theme.key_actionBarDefaultSearch));
arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_actionBarDefaultSearchPlaceholder));
arrayList.add(new ThemeDescription(this.actionBar2, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, i4));
arrayList.add(new ThemeDescription(this.actionBar2, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, i8));
arrayList.add(new ThemeDescription(this.actionBar2, ThemeDescription.FLAG_AB_SUBTITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultSubtitle));
arrayList.add(new ThemeDescription(this.actionBar2, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, i6));
arrayList.add(new ThemeDescription(this.actionBar2, ThemeDescription.FLAG_AB_SUBMENUBACKGROUND, null, null, null, themeDescriptionDelegate, Theme.key_actionBarDefaultSubmenuBackground));
arrayList.add(new ThemeDescription(this.actionBar2, ThemeDescription.FLAG_AB_SUBMENUITEM, null, null, null, themeDescriptionDelegate, Theme.key_actionBarDefaultSubmenuItem));
arrayList.add(new ThemeDescription(this.listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, i4));
arrayList.add(new ThemeDescription(this.listView2, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, i4));
arrayList.add(new ThemeDescription(this.floatingButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chats_actionIcon));
arrayList.add(new ThemeDescription(this.floatingButton, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chats_actionBackground));
arrayList.add(new ThemeDescription(this.floatingButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_chats_actionPressedBackground));
if (!this.useDefaultThemeForButtons) {
arrayList.add(new ThemeDescription(this.saveButtonsContainer, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, i2));
TextView textView = this.cancelButton;
int i9 = ThemeDescription.FLAG_TEXTCOLOR;
int i10 = Theme.key_chat_fieldOverlayText;
arrayList.add(new ThemeDescription(textView, i9, null, null, null, null, i10));
arrayList.add(new ThemeDescription(this.doneButton, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, i10));
}
ColorPicker colorPicker = this.colorPicker;
if (colorPicker != null) {
colorPicker.provideThemeDescriptions(arrayList);
}
if (this.patternLayout != null) {
for (int i11 = 0; i11 < this.patternLayout.length; i11++) {
arrayList.add(new ThemeDescription(this.patternLayout[i11], 0, null, null, new Drawable[]{Theme.chat_composeShadowDrawable}, null, Theme.key_chat_messagePanelShadow));
arrayList.add(new ThemeDescription(this.patternLayout[i11], 0, null, Theme.chat_composeBackgroundPaint, null, null, Theme.key_chat_messagePanelBackground));
}
for (int i12 = 0; i12 < this.patternsButtonsContainer.length; i12++) {
arrayList.add(new ThemeDescription(this.patternsButtonsContainer[i12], 0, null, null, new Drawable[]{Theme.chat_composeShadowDrawable}, null, Theme.key_chat_messagePanelShadow));
arrayList.add(new ThemeDescription(this.patternsButtonsContainer[i12], 0, null, Theme.chat_composeBackgroundPaint, null, null, Theme.key_chat_messagePanelBackground));
}
arrayList.add(new ThemeDescription(this.bottomOverlayChat, 0, null, null, new Drawable[]{Theme.chat_composeShadowDrawable}, null, Theme.key_chat_messagePanelShadow));
arrayList.add(new ThemeDescription(this.bottomOverlayChat, 0, null, Theme.chat_composeBackgroundPaint, null, null, Theme.key_chat_messagePanelBackground));
for (int i13 = 0; i13 < this.patternsSaveButton.length; i13++) {
arrayList.add(new ThemeDescription(this.patternsSaveButton[i13], ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_fieldOverlayText));
}
for (int i14 = 0; i14 < this.patternsCancelButton.length; i14++) {
arrayList.add(new ThemeDescription(this.patternsCancelButton[i14], ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_fieldOverlayText));
}
arrayList.add(new ThemeDescription((View) this.intensitySeekBar, 0, new Class[]{SeekBarView.class}, new String[]{"innerPaint1"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_player_progressBackground));
arrayList.add(new ThemeDescription((View) this.intensitySeekBar, 0, new Class[]{SeekBarView.class}, new String[]{"outerPaint1"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_player_progress));
arrayList.add(new ThemeDescription(this.intensityCell, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_windowBackgroundWhiteBlueHeader));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInDrawable, Theme.chat_msgInMediaDrawable}, null, Theme.key_chat_inBubble));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgInSelectedDrawable, Theme.chat_msgInMediaSelectedDrawable}, null, Theme.key_chat_inBubbleSelected));
Drawable[] shadowDrawables = Theme.chat_msgInDrawable.getShadowDrawables();
int i15 = Theme.key_chat_inBubbleShadow;
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, shadowDrawables, null, i15));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgInMediaDrawable.getShadowDrawables(), null, i15));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{this.msgOutDrawable, this.msgOutMediaDrawable}, null, Theme.key_chat_outBubble));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{this.msgOutDrawable, this.msgOutMediaDrawable}, null, Theme.key_chat_outBubbleGradient1));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{this.msgOutDrawable, this.msgOutMediaDrawable}, null, Theme.key_chat_outBubbleGradient2));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{this.msgOutDrawable, this.msgOutMediaDrawable}, null, Theme.key_chat_outBubbleGradient3));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutSelectedDrawable, Theme.chat_msgOutMediaSelectedDrawable}, null, Theme.key_chat_outBubbleSelected));
Drawable[] shadowDrawables2 = Theme.chat_msgOutDrawable.getShadowDrawables();
int i16 = Theme.key_chat_outBubbleShadow;
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, shadowDrawables2, null, i16));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, Theme.chat_msgOutMediaDrawable.getShadowDrawables(), null, i16));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_messageTextIn));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_messageTextOut));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutCheckDrawable}, null, Theme.key_chat_outSentCheck));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutCheckSelectedDrawable}, null, Theme.key_chat_outSentCheckSelected));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutCheckReadDrawable, Theme.chat_msgOutHalfCheckDrawable}, null, Theme.key_chat_outSentCheckRead));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgOutCheckReadSelectedDrawable, Theme.chat_msgOutHalfCheckSelectedDrawable}, null, Theme.key_chat_outSentCheckReadSelected));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, new Drawable[]{Theme.chat_msgMediaCheckDrawable, Theme.chat_msgMediaHalfCheckDrawable}, null, Theme.key_chat_mediaSentCheck));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inReplyLine));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outReplyLine));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inReplyNameText));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outReplyNameText));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inReplyMessageText));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outReplyMessageText));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inReplyMediaMessageSelectedText));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outReplyMediaMessageSelectedText));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inTimeText));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outTimeText));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inTimeSelectedText));
arrayList.add(new ThemeDescription(this.listView2, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outTimeSelectedText));
}
arrayList.add(new ThemeDescription((View) null, 0, (Class[]) null, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_divider));
arrayList.add(new ThemeDescription((View) null, 0, (Class[]) null, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_dialogBackground));
arrayList.add(new ThemeDescription((View) null, 0, (Class[]) null, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_windowBackgroundWhiteBlackText));
arrayList.add(new ThemeDescription((View) null, 0, (Class[]) null, (String[]) null, (Paint[]) null, (Drawable[]) null, themeDescriptionDelegate, Theme.key_dialogBackgroundGray));
for (int i17 = 0; i17 < arrayList.size(); i17++) {
arrayList.get(i17).resourcesProvider = getResourceProvider();
}
return arrayList;
}
public void lambda$getThemeDescriptionsInternal$33() {
ActionBarMenuItem actionBarMenuItem = this.dropDownContainer;
int i = 0;
if (actionBarMenuItem != null) {
actionBarMenuItem.redrawPopup(getThemedColor(Theme.key_actionBarDefaultSubmenuBackground));
this.dropDownContainer.setPopupItemsColor(getThemedColor(Theme.key_actionBarDefaultSubmenuItem), false);
}
Drawable drawable = this.sheetDrawable;
if (drawable != null) {
drawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_windowBackgroundWhite), PorterDuff.Mode.MULTIPLY));
}
FrameLayout frameLayout = this.bottomOverlayChat;
if (frameLayout != null) {
frameLayout.invalidate();
}
if (this.onSwitchDayNightDelegate != null) {
INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
if (iNavigationLayout != null && iNavigationLayout.getBottomSheet() != null) {
((BaseFragment) this).parentLayout.getBottomSheet().fixNavigationBar(getThemedColor(Theme.key_dialogBackground));
if (this.screenType == 2 && this.dialogId != 0) {
((BaseFragment) this).parentLayout.getBottomSheet().setOverlayNavBarColor(-16777216);
}
} else {
setNavigationBarColor(getThemedColor(Theme.key_dialogBackground));
}
}
if (this.backgroundCheckBoxView != null) {
int i2 = 0;
while (true) {
View[] viewArr = this.backgroundCheckBoxView;
if (i2 >= viewArr.length) {
break;
}
if (viewArr[i2] != null) {
viewArr[i2].invalidate();
}
i2++;
}
}
if (this.messagesCheckBoxView != null) {
while (true) {
View[] viewArr2 = this.messagesCheckBoxView;
if (i >= viewArr2.length) {
break;
}
if (viewArr2[i] != null) {
viewArr2[i].invalidate();
}
i++;
}
}
TextView textView = this.patternTitleView;
if (textView != null) {
textView.setTextColor(getThemedColor(Theme.key_windowBackgroundWhiteBlackText));
}
ColorPicker colorPicker = this.colorPicker;
if (colorPicker != null) {
colorPicker.invalidate();
}
}
public ArrayList<ThemeDescription> getThemeDescriptions() {
if (this.shouldShowDayNightIcon) {
return getThemeDescriptionsInternal();
}
return super.getThemeDescriptions();
}
public final void createServiceMessageLocal(TLRPC.WallPaper wallPaper, boolean forBoth) {
TLRPC.TL_messageService tL_messageService = new TLRPC.TL_messageService();
((TLRPC.Message) tL_messageService).random_id = SendMessagesHelper.getInstance(((BaseFragment) this).currentAccount).getNextRandomId();
((TLRPC.Message) tL_messageService).dialog_id = this.dialogId;
((TLRPC.Message) tL_messageService).unread = true;
((TLRPC.Message) tL_messageService).out = true;
int newMessageId = getUserConfig().getNewMessageId();
((TLRPC.Message) tL_messageService).id = newMessageId;
((TLRPC.Message) tL_messageService).local_id = newMessageId;
TLRPC.Chat chat = getMessagesController().getChat(Long.valueOf(-this.dialogId));
if (ChatObject.isChannel(chat)) {
TLRPC.TL_peerChannel tL_peerChannel = new TLRPC.TL_peerChannel();
((TLRPC.Message) tL_messageService).from_id = tL_peerChannel;
((TLRPC.Peer) tL_peerChannel).channel_id = chat.id;
TLRPC.TL_peerChannel tL_peerChannel2 = new TLRPC.TL_peerChannel();
((TLRPC.Message) tL_messageService).peer_id = tL_peerChannel2;
((TLRPC.Peer) tL_peerChannel2).channel_id = chat.id;
} else {
TLRPC.TL_peerUser tL_peerUser = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_messageService).from_id = tL_peerUser;
((TLRPC.Peer) tL_peerUser).user_id = getUserConfig().getClientUserId();
TLRPC.TL_peerUser tL_peerUser2 = new TLRPC.TL_peerUser();
((TLRPC.Message) tL_messageService).peer_id = tL_peerUser2;
((TLRPC.Peer) tL_peerUser2).user_id = this.dialogId;
}
((TLRPC.Message) tL_messageService).flags |= 256;
((TLRPC.Message) tL_messageService).date = getConnectionsManager().getCurrentTime();
TLRPC.TL_messageActionSetChatWallPaper tL_messageActionSetChatWallPaper = new TLRPC.TL_messageActionSetChatWallPaper();
((TLRPC.Message) tL_messageService).action = tL_messageActionSetChatWallPaper;
((TLRPC.MessageAction) tL_messageActionSetChatWallPaper).wallpaper = wallPaper;
tL_messageActionSetChatWallPaper.for_both = forBoth;
ArrayList arrayList = new ArrayList();
arrayList.add(new MessageObject(((BaseFragment) this).currentAccount, tL_messageService, false, false));
new ArrayList().add(tL_messageService);
MessagesController.getInstance(((BaseFragment) this).currentAccount).updateInterfaceWithMessages(this.dialogId, arrayList, 0);
}
public class BackgroundView extends BackupImageView {
public Drawable background;
public boolean drawBackground;
public float tx;
public float ty;
public BackgroundView(Context context) {
super(context);
this.drawBackground = true;
}
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super/*android.view.View*/.onMeasure(widthMeasureSpec, heightMeasureSpec);
ThemePreviewActivity themePreviewActivity = ThemePreviewActivity.this;
themePreviewActivity.parallaxScale = themePreviewActivity.parallaxEffect.getScale(getMeasuredWidth(), getMeasuredHeight());
if (ThemePreviewActivity.this.isMotion) {
setScaleX(ThemePreviewActivity.this.parallaxScale);
setScaleY(ThemePreviewActivity.this.parallaxScale);
}
ThemePreviewActivity themePreviewActivity2 = ThemePreviewActivity.this;
themePreviewActivity2.progressVisible = themePreviewActivity2.screenType == 2 && getMeasuredWidth() <= getMeasuredHeight();
int measuredWidth = getMeasuredWidth() + (getMeasuredHeight() << 16);
if (ThemePreviewActivity.this.lastSizeHash != measuredWidth) {
ThemePreviewActivity.this.hasScrollingBackground = false;
if (ThemePreviewActivity.this.currentWallpaperBitmap != null) {
int width = (int) (ThemePreviewActivity.this.currentWallpaperBitmap.getWidth() * (getMeasuredHeight() / ThemePreviewActivity.this.currentWallpaperBitmap.getHeight()));
if (width - getMeasuredWidth() > 100) {
ThemePreviewActivity.this.hasScrollingBackground = true;
ThemePreviewActivity.this.croppedWidth = (int) (getMeasuredWidth() * (ThemePreviewActivity.this.currentWallpaperBitmap.getHeight() / getMeasuredHeight()));
ThemePreviewActivity themePreviewActivity3 = ThemePreviewActivity.this;
float measuredWidth2 = (width - getMeasuredWidth()) / 2.0f;
themePreviewActivity3.currentScrollOffset = measuredWidth2;
themePreviewActivity3.defaultScrollOffset = measuredWidth2;
ThemePreviewActivity themePreviewActivity4 = ThemePreviewActivity.this;
themePreviewActivity4.maxScrollOffset = themePreviewActivity4.currentScrollOffset * 2.0f;
setSize(width, getMeasuredHeight());
((BackupImageView) this).drawFromStart = true;
ThemePreviewActivity.this.invalidateBlur();
}
}
if (!ThemePreviewActivity.this.hasScrollingBackground) {
setSize(-1, -1);
((BackupImageView) this).drawFromStart = false;
}
}
ThemePreviewActivity.this.lastSizeHash = measuredWidth;
}
public void onDraw(Canvas canvas) {
this.tx = 0.0f;
this.ty = 0.0f;
if (this.drawBackground) {
Drawable drawable = this.background;
if ((drawable instanceof ColorDrawable) || (drawable instanceof GradientDrawable) || (drawable instanceof MotionBackgroundDrawable)) {
drawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
this.background.draw(canvas);
} else if (drawable instanceof BitmapDrawable) {
if (((BitmapDrawable) drawable).getTileModeX() == Shader.TileMode.REPEAT) {
canvas.save();
float f = 2.0f / AndroidUtilities.density;
canvas.scale(f, f);
this.background.setBounds(0, 0, (int) Math.ceil(getMeasuredWidth() / f), (int) Math.ceil(getMeasuredHeight() / f));
this.background.draw(canvas);
canvas.restore();
} else {
int measuredHeight = getMeasuredHeight();
float max = Math.max(getMeasuredWidth() / this.background.getIntrinsicWidth(), measuredHeight / this.background.getIntrinsicHeight());
int ceil = (int) Math.ceil(this.background.getIntrinsicWidth() * max * ThemePreviewActivity.this.parallaxScale);
int ceil2 = (int) Math.ceil(this.background.getIntrinsicHeight() * max * ThemePreviewActivity.this.parallaxScale);
int measuredWidth = (getMeasuredWidth() - ceil) / 2;
int i = (measuredHeight - ceil2) / 2;
this.ty = i;
this.background.setBounds(measuredWidth, i, ceil + measuredWidth, ceil2 + i);
this.background.draw(canvas);
}
}
}
if (ThemePreviewActivity.this.hasScrollingBackground) {
if (!ThemePreviewActivity.this.scroller.isFinished() && ThemePreviewActivity.this.scroller.computeScrollOffset()) {
float startX = ThemePreviewActivity.this.scroller.getStartX();
ThemePreviewActivity themePreviewActivity = ThemePreviewActivity.this;
if (startX < themePreviewActivity.maxScrollOffset && themePreviewActivity.scroller.getStartX() > 0) {
ThemePreviewActivity.this.currentScrollOffset = r1.scroller.getCurrX();
}
ThemePreviewActivity.this.invalidateBlur();
invalidate();
}
canvas.save();
float f2 = ThemePreviewActivity.this.currentScrollOffset;
this.tx = -f2;
canvas.translate(-f2, 0.0f);
super.onDraw(canvas);
canvas.restore();
} else {
super.onDraw(canvas);
}
if (!ThemePreviewActivity.this.shouldShowBrightnessControll || ThemePreviewActivity.this.dimAmount <= 0.0f) {
return;
}
canvas.drawColor(ColorUtils.setAlphaComponent(-16777216, (int) (ThemePreviewActivity.this.dimAmount * 255.0f * ThemePreviewActivity.this.progressToDarkTheme)));
}
public Drawable getBackground() {
return this.background;
}
public void setBackground(Drawable drawable) {
this.background = drawable;
if (drawable != null) {
drawable.setCallback(this);
}
}
public boolean verifyDrawable(Drawable who) {
return this.background == who || super/*android.view.View*/.verifyDrawable(who);
}
}
public class MessageDrawable extends Theme.MessageDrawable {
public MessageDrawable(int typeMedia, boolean b, boolean b1) {
super(typeMedia, b, b1);
}
@Override
public void setTop(int top, int backgroundWidth, int backgroundHeight, boolean topNear, boolean bottomNear) {
if (ThemePreviewActivity.this.setupFinished) {
return;
}
super.setTop(top, backgroundWidth, backgroundHeight, topNear, bottomNear);
}
@Override
public void setTop(int top, int backgroundWidth, int backgroundHeight, int heightOffset, int blurredViewTopOffset, int blurredViewBottomOffset, boolean topNear, boolean bottomNear) {
if (ThemePreviewActivity.this.setupFinished) {
return;
}
super.setTop(top, backgroundWidth, backgroundHeight, heightOffset, blurredViewTopOffset, blurredViewBottomOffset, topNear, bottomNear);
}
}
public class BlurButton extends View {
public final ColorFilter colorFilter;
public final Paint dimPaint;
public final Paint dimPaint2;
public CircularProgressDrawable loadingDrawable;
public float loadingT;
public final Drawable rippleDrawable;
public Text subtext;
public boolean subtextShown;
public AnimatedFloat subtextShownT;
public Text text;
public BlurButton(Context context) {
super(context);
this.subtextShownT = new AnimatedFloat(this, 0L, 350L, CubicBezierInterpolator.EASE_OUT_QUINT);
Drawable createRadSelectorDrawable = Theme.createRadSelectorDrawable(285212671, 8, 8);
this.rippleDrawable = createRadSelectorDrawable;
this.dimPaint = new Paint(1);
this.dimPaint2 = new Paint(1);
this.loadingT = 0.0f;
createRadSelectorDrawable.setCallback(this);
ColorMatrix colorMatrix = new ColorMatrix();
AndroidUtilities.adjustSaturationColorMatrix(colorMatrix, 0.35f);
AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix, 0.9f);
this.colorFilter = new ColorMatrixColorFilter(colorMatrix);
}
public void setText(CharSequence text) {
this.text = new Text(text, 14.0f, AndroidUtilities.bold());
}
public void setSubText(CharSequence subtext, boolean animated) {
if (subtext != null) {
this.subtext = new Text(subtext, 12.0f);
}
boolean z = subtext != null;
this.subtextShown = z;
if (!animated) {
this.subtextShownT.set(z, true);
}
invalidate();
}
public CharSequence getText() {
Text text = this.text;
if (text != null) {
return text.getText();
}
return null;
}
@Override
public void onDraw(Canvas canvas) {
Text text;
float dp = AndroidUtilities.dp(8.0f);
RectF rectF = AndroidUtilities.rectTmp;
rectF.set(0.0f, 0.0f, getWidth(), getHeight());
Theme.applyServiceShaderMatrixForView(this, ThemePreviewActivity.this.backgroundImage, ThemePreviewActivity.this.themeDelegate);
Paint paint = ThemePreviewActivity.this.themeDelegate.getPaint("paintChatActionBackground");
ColorFilter colorFilter = paint.getColorFilter();
paint.setColorFilter(this.colorFilter);
canvas.drawRoundRect(rectF, dp, dp, paint);
paint.setColorFilter(colorFilter);
if (ThemePreviewActivity.this.shouldShowBrightnessControll && ThemePreviewActivity.this.dimAmount > 0.0f) {
this.dimPaint2.setColor(ColorUtils.setAlphaComponent(-16777216, (int) (ThemePreviewActivity.this.dimAmount * 255.0f * ThemePreviewActivity.this.progressToDarkTheme)));
canvas.drawRoundRect(rectF, dp, dp, this.dimPaint2);
}
this.dimPaint.setColor(520093695);
canvas.drawRoundRect(rectF, dp, dp, this.dimPaint);
if (this.loadingT > 0.0f) {
if (this.loadingDrawable == null) {
this.loadingDrawable = new CircularProgressDrawable(-1);
}
int dp2 = (int) ((1.0f - this.loadingT) * AndroidUtilities.dp(-24.0f));
this.loadingDrawable.setBounds(0, dp2, getWidth(), getHeight() + dp2);
this.loadingDrawable.setAlpha((int) (this.loadingT * 255.0f));
this.loadingDrawable.draw(canvas);
invalidate();
}
float f = this.subtextShownT.set(this.subtextShown);
if (this.loadingT < 1.0f && (text = this.text) != null) {
text.ellipsize(getWidth() - AndroidUtilities.dp(14.0f)).draw(canvas, (getWidth() - this.text.getWidth()) / 2.0f, ((getHeight() / 2.0f) + (this.loadingT * AndroidUtilities.dp(24.0f))) - (AndroidUtilities.dp(7.0f) * f), -1, 1.0f - this.loadingT);
}
if (this.loadingT < 1.0f && this.subtext != null) {
canvas.save();
canvas.scale(f, f, getWidth() / 2.0f, (getHeight() / 2.0f) + AndroidUtilities.dp(11.0f));
this.subtext.ellipsize(getWidth() - AndroidUtilities.dp(14.0f)).draw(canvas, (getWidth() - this.subtext.getWidth()) / 2.0f, (getHeight() / 2.0f) + (this.loadingT * AndroidUtilities.dp(24.0f)) + AndroidUtilities.dp(11.0f), Theme.multAlpha(-1, 0.75f), 1.0f - this.loadingT);
canvas.restore();
}
this.rippleDrawable.setBounds(0, 0, getWidth(), getHeight());
this.rippleDrawable.draw(canvas);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean z;
if (event.getAction() == 0) {
if (Build.VERSION.SDK_INT >= 21) {
this.rippleDrawable.setHotspot(event.getX(), event.getY());
}
this.rippleDrawable.setState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed});
z = true;
} else {
if (event.getAction() == 1 || event.getAction() == 3) {
this.rippleDrawable.setState(StateSet.NOTHING);
}
z = false;
}
return super.onTouchEvent(event) || z;
}
@Override
public boolean verifyDrawable(Drawable who) {
return who == this.rippleDrawable || super.verifyDrawable(who);
}
}
public class ThemeDelegate implements Theme.ResourcesProvider {
public final Paint chat_actionBackgroundGradientDarkenPaint;
public final TextPaint chat_actionTextPaint;
public final TextPaint chat_actionTextPaint2;
public final TextPaint chat_botButtonPaint;
public Theme.ResourcesProvider parentProvider;
public Bitmap serviceBitmap;
public Matrix serviceBitmapMatrix;
public BitmapShader serviceBitmapShader;
public final SparseIntArray currentColors = new SparseIntArray();
public final Paint chat_actionBackgroundPaint = new Paint(3);
public final Paint chat_actionBackgroundSelectedPaint = new Paint(3);
@Override
public ColorFilter getAnimatedEmojiColorFilter() {
return Theme.ResourcesProvider.CC.$default$getAnimatedEmojiColorFilter(this);
}
@Override
public int getColorOrDefault(int i) {
return getColor(i);
}
@Override
public void setAnimatedColor(int i, int i2) {
Theme.ResourcesProvider.CC.$default$setAnimatedColor(this, i, i2);
}
public ThemeDelegate() {
Paint paint = new Paint(3);
this.chat_actionBackgroundGradientDarkenPaint = paint;
TextPaint textPaint = new TextPaint();
this.chat_actionTextPaint = textPaint;
TextPaint textPaint2 = new TextPaint();
this.chat_actionTextPaint2 = textPaint2;
TextPaint textPaint3 = new TextPaint();
this.chat_botButtonPaint = textPaint3;
textPaint.setTextSize(AndroidUtilities.dp(Math.max(16, SharedConfig.fontSize) - 2));
textPaint2.setTextSize(AndroidUtilities.dp(Math.max(16, SharedConfig.fontSize) - 2));
textPaint3.setTextSize(AndroidUtilities.dp(15.0f));
textPaint3.setTypeface(AndroidUtilities.bold());
paint.setColor(352321536);
}
@Override
public int getColor(int key) {
Theme.ResourcesProvider resourcesProvider = this.parentProvider;
if (resourcesProvider != null) {
return resourcesProvider.getColor(key);
}
return Theme.getColor(key);
}
@Override
public Drawable getDrawable(String drawableKey) {
Theme.ResourcesProvider resourcesProvider = this.parentProvider;
if (resourcesProvider != null) {
return resourcesProvider.getDrawable(drawableKey);
}
return Theme.getThemeDrawable(drawableKey);
}
@Override
public int getCurrentColor(int key) {
int color;
Theme.ResourcesProvider resourcesProvider = this.parentProvider;
if (resourcesProvider == null) {
color = getColor(key);
return color;
}
return resourcesProvider.getCurrentColor(key);
}
@Override
public Paint getPaint(String paintKey) {
paintKey.hashCode();
switch (paintKey) {
case "paintChatActionText2":
return this.chat_actionTextPaint2;
case "paintChatActionBackground":
return this.chat_actionBackgroundPaint;
case "paintChatBotButton":
return this.chat_botButtonPaint;
case "paintChatActionBackgroundDarken":
return this.chat_actionBackgroundGradientDarkenPaint;
case "paintChatActionBackgroundSelected":
return this.chat_actionBackgroundSelectedPaint;
case "paintChatActionText":
return this.chat_actionTextPaint;
default:
Theme.ResourcesProvider resourcesProvider = this.parentProvider;
if (resourcesProvider != null) {
return resourcesProvider.getPaint(paintKey);
}
return Theme.ResourcesProvider.CC.$default$getPaint(this, paintKey);
}
}
@Override
public boolean hasGradientService() {
Theme.ResourcesProvider resourcesProvider = this.parentProvider;
if (resourcesProvider != null) {
return resourcesProvider.hasGradientService();
}
return Theme.hasGradientService();
}
public void applyChatServiceMessageColor() {
applyChatServiceMessageColor(null, null, null, null);
}
public void applyChatServiceMessageColor(int[] custom, Drawable wallpaperOverride, Drawable currentWallpaper, Float overrideIntensity) {
Bitmap bitmap;
int i = Theme.key_chat_serviceBackground;
int color = getColor(i);
int color2 = getColor(Theme.key_chat_serviceBackgroundSelected);
if (wallpaperOverride == null) {
wallpaperOverride = currentWallpaper;
}
boolean z = wallpaperOverride instanceof MotionBackgroundDrawable;
if ((z || (wallpaperOverride instanceof BitmapDrawable)) && SharedConfig.getDevicePerformanceClass() != 0 && LiteMode.isEnabled(32)) {
if (z) {
bitmap = ((MotionBackgroundDrawable) wallpaperOverride).getBitmap();
} else {
bitmap = wallpaperOverride instanceof BitmapDrawable ? ((BitmapDrawable) wallpaperOverride).getBitmap() : null;
}
if (this.serviceBitmap != bitmap) {
this.serviceBitmap = bitmap;
Bitmap bitmap2 = this.serviceBitmap;
Shader.TileMode tileMode = Shader.TileMode.CLAMP;
this.serviceBitmapShader = new BitmapShader(bitmap2, tileMode, tileMode);
if (this.serviceBitmapMatrix == null) {
this.serviceBitmapMatrix = new Matrix();
}
}
this.chat_actionTextPaint.setColor(-1);
this.chat_actionTextPaint2.setColor(-1);
this.chat_actionTextPaint.linkColor = -1;
this.chat_botButtonPaint.setColor(-1);
} else {
this.serviceBitmap = null;
this.serviceBitmapShader = null;
TextPaint textPaint = this.chat_actionTextPaint;
int i2 = Theme.key_chat_serviceText;
textPaint.setColor(getColor(i2));
this.chat_actionTextPaint2.setColor(getColor(i2));
this.chat_actionTextPaint.linkColor = getColor(Theme.key_chat_serviceLink);
}
this.chat_actionBackgroundPaint.setColor(color);
this.chat_actionBackgroundSelectedPaint.setColor(color2);
if (this.serviceBitmapShader != null && (this.currentColors.indexOfKey(i) < 0 || z || (wallpaperOverride instanceof BitmapDrawable))) {
ColorMatrix colorMatrix = new ColorMatrix();
if (z) {
if (((MotionBackgroundDrawable) wallpaperOverride).getIntensity() >= 0.0f) {
colorMatrix.setSaturation(1.6f);
AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix, isDark() ? 0.97f : 0.92f);
AndroidUtilities.adjustBrightnessColorMatrix(colorMatrix, isDark() ? 0.12f : -0.06f);
} else {
colorMatrix.setSaturation(1.1f);
AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix, isDark() ? 0.4f : 0.8f);
AndroidUtilities.adjustBrightnessColorMatrix(colorMatrix, isDark() ? 0.08f : -0.06f);
}
} else {
colorMatrix.setSaturation(1.6f);
AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix, isDark() ? 0.9f : 0.84f);
AndroidUtilities.adjustBrightnessColorMatrix(colorMatrix, isDark() ? -0.04f : 0.06f);
}
if (z) {
float intensity = ((MotionBackgroundDrawable) wallpaperOverride).getIntensity();
if (overrideIntensity != null) {
intensity = overrideIntensity.floatValue();
}
if (intensity >= 0.0f) {
colorMatrix.setSaturation(1.8f);
AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix, 0.97f);
AndroidUtilities.adjustBrightnessColorMatrix(colorMatrix, 0.03f);
} else {
colorMatrix.setSaturation(0.5f);
AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix, 0.35f);
AndroidUtilities.adjustBrightnessColorMatrix(colorMatrix, 0.03f);
}
} else {
colorMatrix.setSaturation(1.6f);
AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix, 0.97f);
AndroidUtilities.adjustBrightnessColorMatrix(colorMatrix, 0.06f);
}
this.chat_actionBackgroundPaint.setShader(this.serviceBitmapShader);
this.chat_actionBackgroundPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
this.chat_actionBackgroundPaint.setAlpha(255);
this.chat_actionBackgroundSelectedPaint.setShader(this.serviceBitmapShader);
ColorMatrix colorMatrix2 = new ColorMatrix(colorMatrix);
AndroidUtilities.multiplyBrightnessColorMatrix(colorMatrix2, 0.85f);
this.chat_actionBackgroundSelectedPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix2));
this.chat_actionBackgroundSelectedPaint.setAlpha(255);
return;
}
this.chat_actionBackgroundPaint.setColorFilter(null);
this.chat_actionBackgroundPaint.setShader(null);
this.chat_actionBackgroundSelectedPaint.setColorFilter(null);
this.chat_actionBackgroundSelectedPaint.setShader(null);
}
@Override
public void applyServiceShaderMatrix(int w, int h, float translationX, float translationY) {
BitmapShader bitmapShader;
Bitmap bitmap = this.serviceBitmap;
if (bitmap == null || (bitmapShader = this.serviceBitmapShader) == null) {
Theme.applyServiceShaderMatrix(w, h, translationX, translationY);
} else {
Theme.applyServiceShaderMatrix(bitmap, bitmapShader, this.serviceBitmapMatrix, w, h, translationX, translationY);
}
}
@Override
public boolean isDark() {
DayNightSwitchDelegate dayNightSwitchDelegate = ThemePreviewActivity.this.onSwitchDayNightDelegate;
if (dayNightSwitchDelegate != null) {
return dayNightSwitchDelegate.isDark();
}
Theme.ResourcesProvider resourcesProvider = this.parentProvider;
return resourcesProvider != null ? resourcesProvider.isDark() : Theme.isCurrentThemeDark();
}
}
@SuppressLint({"NotifyDataSetChanged"})
public void toggleTheme() {
if (this.changeDayNightView != null) {
return;
}
FrameLayout frameLayout = (FrameLayout) (insideBottomSheet() ? ((BaseFragment) this).parentLayout.getBottomSheet().getWindow() : getParentActivity().getWindow()).getDecorView();
final Bitmap createBitmap = Bitmap.createBitmap(frameLayout.getWidth(), frameLayout.getHeight(), Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(createBitmap);
this.dayNightItem.setAlpha(0.0f);
frameLayout.draw(canvas);
this.dayNightItem.setAlpha(1.0f);
final Paint paint = new Paint(1);
paint.setColor(-16777216);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
final Paint paint2 = new Paint(1);
paint2.setFilterBitmap(true);
int[] iArr = new int[2];
this.dayNightItem.getLocationInWindow(iArr);
final float f = iArr[0];
final float f2 = iArr[1];
final float measuredWidth = f + (this.dayNightItem.getMeasuredWidth() / 2.0f);
final float measuredHeight = f2 + (this.dayNightItem.getMeasuredHeight() / 2.0f);
final float max = Math.max(createBitmap.getHeight(), createBitmap.getWidth()) + AndroidUtilities.navigationBarHeight;
Shader.TileMode tileMode = Shader.TileMode.CLAMP;
paint2.setShader(new BitmapShader(createBitmap, tileMode, tileMode));
View view = new View(getContext()) {
@Override
public void onDraw(Canvas canvas2) {
super.onDraw(canvas2);
if (ThemePreviewActivity.this.themeDelegate.isDark()) {
if (ThemePreviewActivity.this.changeDayNightViewProgress > 0.0f) {
canvas.drawCircle(measuredWidth, measuredHeight, max * ThemePreviewActivity.this.changeDayNightViewProgress, paint);
}
canvas2.drawBitmap(createBitmap, 0.0f, 0.0f, paint2);
} else {
canvas2.drawCircle(measuredWidth, measuredHeight, max * (1.0f - ThemePreviewActivity.this.changeDayNightViewProgress), paint2);
}
canvas2.save();
canvas2.translate(f, f2);
ThemePreviewActivity.this.dayNightItem.draw(canvas2);
canvas2.restore();
}
};
this.changeDayNightView = view;
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public final boolean onTouch(View view2, MotionEvent motionEvent) {
boolean lambda$toggleTheme$34;
lambda$toggleTheme$34 = ThemePreviewActivity.lambda$toggleTheme$34(view2, motionEvent);
return lambda$toggleTheme$34;
}
});
this.changeDayNightViewProgress = 0.0f;
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
this.changeDayNightViewAnimator = ofFloat;
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public boolean changedNavigationBarColor = false;
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
ThemePreviewActivity.this.changeDayNightViewProgress = ((Float) valueAnimator.getAnimatedValue()).floatValue();
ThemePreviewActivity.this.changeDayNightView.invalidate();
if (this.changedNavigationBarColor || ThemePreviewActivity.this.changeDayNightViewProgress <= 0.5f) {
return;
}
this.changedNavigationBarColor = true;
}
});
this.changeDayNightViewAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (ThemePreviewActivity.this.changeDayNightView != null) {
if (ThemePreviewActivity.this.changeDayNightView.getParent() != null) {
((ViewGroup) ThemePreviewActivity.this.changeDayNightView.getParent()).removeView(ThemePreviewActivity.this.changeDayNightView);
}
ThemePreviewActivity.this.changeDayNightView = null;
}
ThemePreviewActivity.this.changeDayNightViewAnimator = null;
super.onAnimationEnd(animation);
}
});
this.changeDayNightViewAnimator.setDuration(400L);
this.changeDayNightViewAnimator.setInterpolator(Easings.easeInOutQuad);
this.changeDayNightViewAnimator.start();
frameLayout.addView(this.changeDayNightView, new ViewGroup.LayoutParams(-1, -1));
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ThemePreviewActivity.this.lambda$toggleTheme$36();
}
});
}
public void lambda$toggleTheme$36() {
this.onSwitchDayNightDelegate.switchDayNight(false);
setForceDark(this.themeDelegate.isDark(), true);
setCurrentImage(false);
invalidateBlur();
updateBlurred();
if (this.themeDescriptions != null) {
for (int i = 0; i < this.themeDescriptions.size(); i++) {
this.themeDescriptions.get(i).setColor(getThemedColor(this.themeDescriptions.get(i).getCurrentKey()), false, false);
}
}
if (this.shouldShowBrightnessControll) {
DayNightSwitchDelegate dayNightSwitchDelegate = this.onSwitchDayNightDelegate;
if (dayNightSwitchDelegate != null && dayNightSwitchDelegate.isDark()) {
this.dimmingSlider.setVisibility(0);
this.dimmingSlider.animateValueTo(this.dimAmount);
} else {
this.dimmingSlider.animateValueTo(0.0f);
}
ValueAnimator valueAnimator = this.changeDayNightViewAnimator2;
if (valueAnimator != null) {
valueAnimator.removeAllListeners();
this.changeDayNightViewAnimator2.cancel();
}
float[] fArr = new float[2];
fArr[0] = this.progressToDarkTheme;
fArr[1] = this.onSwitchDayNightDelegate.isDark() ? 1.0f : 0.0f;
ValueAnimator ofFloat = ValueAnimator.ofFloat(fArr);
this.changeDayNightViewAnimator2 = ofFloat;
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
ThemePreviewActivity.this.lambda$toggleTheme$35(valueAnimator2);
}
});
this.changeDayNightViewAnimator2.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (ThemePreviewActivity.this.onSwitchDayNightDelegate.isDark()) {
return;
}
ThemePreviewActivity.this.dimmingSlider.setVisibility(8);
}
});
this.changeDayNightViewAnimator2.setDuration(250L);
this.changeDayNightViewAnimator2.setInterpolator(CubicBezierInterpolator.DEFAULT);
this.changeDayNightViewAnimator2.start();
}
}
public void lambda$toggleTheme$35(ValueAnimator valueAnimator) {
this.progressToDarkTheme = ((Float) valueAnimator.getAnimatedValue()).floatValue();
this.backgroundImage.invalidate();
this.bottomOverlayChat.invalidate();
this.dimmingSlider.setAlpha(this.progressToDarkTheme);
this.dimmingSliderContainer.invalidate();
invalidateBlur();
}
public void setForceDark(boolean isDark, boolean playAnimation) {
if (playAnimation) {
RLottieDrawable rLottieDrawable = this.sunDrawable;
rLottieDrawable.setCustomEndFrame(isDark ? rLottieDrawable.getFramesCount() : 0);
RLottieDrawable rLottieDrawable2 = this.sunDrawable;
if (rLottieDrawable2 != null) {
rLottieDrawable2.start();
return;
}
return;
}
int framesCount = isDark ? this.sunDrawable.getFramesCount() - 1 : 0;
this.sunDrawable.setCurrentFrame(framesCount, false, true);
this.sunDrawable.setCustomEndFrame(framesCount);
ActionBarMenuItem actionBarMenuItem = this.dayNightItem;
if (actionBarMenuItem != null) {
actionBarMenuItem.invalidate();
}
}
}