正在查看: Plus 12 v10.13.1.1 应用的 PlusSettings.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Plus 12 v10.13.1.1 应用的 PlusSettings.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.telegram.ui.ActionBar;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import androidx.collection.LongSparseArray;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.internal.LinkedTreeMap;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.DownloadController;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.PlusUtils;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BottomSheet;
import org.telegram.ui.Cells.CheckBoxCell;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.NumberPicker;
public class PlusSettings {
public static SharedPreferences accountPreferences;
public static boolean addAppFolderToSaveToOption;
public static boolean addDateToEventLogMessages;
public static boolean addDateToForwardedMessages;
public static boolean addSecondsToTime;
public static boolean addTranslateToSendButton;
public static boolean allowChangingSortingOnDoubleClick;
public static boolean allowPinTopics;
public static boolean allowScheduleMessagesInTopics;
public static boolean alwaysShowMediaSpoilers;
public static boolean alwaysShowSpoilers;
public static boolean archivedDialogsHideTabs;
public static boolean autoConnectToProxy;
public static int backwardSeconds;
public static boolean changeDialogReaction;
public static boolean changeEmojiToIcon;
public static boolean closeAppOnBackPressed;
public static boolean confirmAudioVideoBeforeSending;
public static boolean confirmBeforeSending;
public static boolean copyLinkOnLongClick;
public static int count;
public static boolean countArchivedChats;
public static boolean countChats;
public static boolean countHiddenChats;
public static boolean countMentionAsUnmuted;
public static boolean countUnmuted;
public static boolean deleteSharedMediaCaption;
public static int dialogsClickOnGroupPic;
public static int dialogsClickOnPic;
public static int directShareButtonAction;
public static CharSequence[] directShareButtonActionList;
public static int directShareButtonLongClickAction;
public static boolean disableActionsVibrations;
public static boolean disableAudioStop;
public static boolean disableAvatarAnimationInChat;
public static boolean disableAvatarAnimationInMain;
public static boolean disableAvatarAnimationInProfile;
public static boolean disableCheckForThemes;
public static boolean disableHideTopicOnSwipe;
public static boolean disableJumpingToNextChannel;
public static boolean disableLinkPreview;
public static boolean disableLoadingNextMedia;
public static boolean disableMusicStop;
public static boolean disableParametersFromBotLinks;
public static boolean disablePremiumStickersAnimation;
public static boolean disableReactionAnimation;
public static boolean disableTabletMode;
public static boolean disableUsersThemeModifications;
public static boolean discardMediaTap;
public static long discussionChat;
public static boolean doNotClosePreviewOnRelease;
public static boolean doNotMarkStoriesAsRead;
public static boolean doNotShowDialogOnCacheDeleting;
public static boolean dontPlayNextMedia;
public static int doubleTapAction;
public static CharSequence[] doubleTapActionList;
public static int doubleTapActionOut;
public static int downloadSpeedBoost;
public static boolean drawDialogIcons;
public static boolean drawerHideDownloads;
public static boolean drawerHideMarkedMessages;
public static boolean drawerHideMyProfile;
public static boolean drawerHideMyStoriesDivider;
public static boolean drawerHideSetEmojiStatus;
public static boolean drawerHideWallet;
public static boolean editMentionText;
public static boolean enableHiddenDialogs;
public static boolean enableReturnToMessageStack;
public static boolean enableSwipeInChannels;
public static boolean floatingButtonOpensSavedMessages;
public static boolean forceEnableBlurInChat;
public static boolean forceShowDownloadsButton;
public static boolean forceSmallReactionsLayout;
public static int forwardSeconds;
public static boolean groupMedia;
public static boolean hiddenDialogsHideTabs;
public static boolean hideAddTagsActionModeButton;
public static boolean hideAutoPlayGifs;
public static boolean hideBackupActionModeButton;
public static boolean hideBotKeyboard;
public static boolean hideChannelsStories;
public static boolean hideChatGreeting;
public static boolean hideChatPreviewMenu;
public static boolean hideCloudFolders;
public static boolean hideCopyActionModeButton;
public static boolean hideCreateStoryButton;
public static boolean hideDeleteActionModeButton;
public static boolean hideDialogThumb;
public static boolean hideDirectShareActionModeButton;
public static boolean hideEditActionModeButton;
public static boolean hideEditOption;
public static boolean hideForwardActionModeButton;
public static boolean hideForwardOption;
public static boolean hideForwardWithoutQuotingActionModeButton;
public static boolean hideKeyboardOnScroll;
public static boolean hideMarkOption;
public static boolean hideMsgDeletedHint;
public static boolean hidePlusPromoDialog;
public static boolean hidePremiumEmojisTabs;
public static boolean hidePremiumStickers;
public static boolean hideProxySponsor;
public static boolean hideReactions;
public static boolean hideReactionsButtonsInMessages;
public static boolean hideReplyOption;
public static boolean hideReplyPrivately;
public static boolean hideReportOption;
public static boolean hideSaveToActionModeButton;
public static boolean hideSavedMessagesButton;
public static boolean hideScheduleDownloadOption;
public static boolean hideScheduledDownloadReminder;
public static Boolean hideSeenStories;
public static boolean hideSelectMessagesActionModeButton;
public static boolean hideSenderSelector;
public static boolean hideSlashBotButton;
public static boolean hideStickerSize;
public static boolean hideStories;
public static boolean hideTimeInStickers;
public static boolean hideTranslateOption;
public static boolean hideViaBotIfForwardingWithoutQuoting;
public static boolean hideViewStatistic;
public static boolean hideVoiceTranscriptionButton;
public static Boolean ignoreBlocked;
public static boolean improveVoiceRecordingQuality;
public static boolean includePendingDownloads;
public static boolean increaseInstantVideoQuality;
public static boolean insideHidden;
public static boolean keepFilenameEqual;
public static boolean keepFormatting;
public static boolean keepOriginalFileName;
public static long lastCheck;
public static int lastTabId;
public static int loadOperationsPathsSize;
public static boolean markdownParseLinks;
public static LongSparseArray<ArrayList<Integer>> markedList;
public static LongSparseArray<ArrayList<TLRPC.Message>> markedListMessages;
public static LongSparseArray<ArrayList<MessageObject>> markedListMessagesObjects;
public static ArrayList<Long> markedMessagesDialogIds;
public static ArrayList<Integer> markedMessagesIds;
public static ArrayList<MessageObject> markedMessagesObject;
public static int notFilesQeue;
public static String officialChannelLang;
public static boolean openArchiveOnPullDown;
public static boolean openAvatarInsteadOfSettings;
public static boolean openHiddenDialogsWithoutPasscode;
public static boolean openProfilePicsInsteadOfStories;
public static boolean openReplyMsgWhenShowingUserMsgs;
public static boolean openTopicsAsNormalGroups;
public static String periodTag;
public static boolean pinnedFirst;
public static boolean pinnedTopicLoaded;
public static LongSparseArray<HashMap<Integer, Integer>> pinnedTopics;
public static boolean playGifAsVideo;
public static int plusDialogClicked;
public static int plusDialogClickedAcc;
public static long plusDialogEnabled;
public static String plusDialogLink;
public static String plusDialogSubtitle;
public static String plusDialogThemesAppLink;
public static String plusDialogTitle;
public static int plusDialogType;
public static int plusDialogTypePlayStore;
public static boolean plusHideImageSize;
public static boolean plusHideSenderName;
public static long plusPromoDialogEnabled;
public static String plusPromoDialogEnabledLangs;
public static long plusPromoDialogHideOptionEnabled;
public static long plusPromoDialogId;
public static String plusPromoDialogUsername;
public static boolean plusShowArchivedChatOnItsTab;
public static boolean plusShowArchivedDialogsInTabs;
public static HashMap<Long, ArrayList<Integer>> recentDownloads;
public static HashMap<Long, ArrayList<MessageObject>> recentDownloadsMessages;
public static boolean removeArchiveFromList;
public static boolean resumeArchiveTab;
public static boolean resumeLastTab;
public static boolean saveViewTopicsAsMessagesOption;
public static HashMap<String, String> scheduledDownloadsIds;
public static Boolean selectBestProxyByPing;
public static boolean showAllRecentStickers;
public static boolean showAnimatedStickersFirst;
public static boolean showBackForwardAudioPlayerButtons;
public static boolean showBotMoreInfo;
public static boolean showDownloadsOnlyIfActive;
public static boolean showFoldersIfForwarding;
public static boolean showForwardsCounter;
public static boolean showFullBio;
public static boolean showFullScreenAvatarOnSingleTap;
public static boolean showHiddenDialogsIcon;
public static boolean showHiddenDialogsMentionsNotifications;
public static boolean showHiddenDialogsNotifications;
public static boolean showHiddenDialogsWhenSearching;
public static boolean showIdInProfile;
public static boolean showIfMutualContact;
public static boolean showMediaSizeInPhotoViewer;
public static boolean showMemberJoinDateInsteadOfStatus;
public static boolean showMoreByDefaultInGlobalSearch;
public static boolean showMuteInNotification;
public static boolean showNotificationEvenIfArchived;
public static boolean showOldMediaRows;
public static boolean showOnlineContacts;
public static boolean showOnlineNotificationForGroups;
public static boolean showOnlyGroupsWithTopics;
public static boolean showPinDialogAlways;
public static boolean showPlusDialogEvenIfInstalled;
public static boolean showPlusHintDialogCell;
public static boolean showProfilePicDateInsteadOfStatus;
public static boolean showSearchIcon;
public static boolean showSendWithoutSound;
public static boolean showSetDefaultFolder;
public static boolean showToastOnErrors;
public static boolean showUnmutedFirstIfUnread;
public static boolean showUserStatusCircleInChatOnlyIfOnline;
public static boolean showUserStatusCircleInMainOnlyIfOnline;
public static int simultaneousDownloads;
public static boolean sortProxyListByPing;
public static Integer storage;
public static int swipeLeftAction;
public static CharSequence[] swipeLeftActionList;
public static int swipeLeftActionOut;
public static int swipeRightAction;
public static CharSequence[] swipeRightActionList;
public static int swipeRightActionOut;
public static int tapAndHoldAvatarAction;
public static CharSequence[] tapAndHoldAvatarActionList;
public static int tapAvatarAction;
public static CharSequence[] tapAvatarActionList;
public static boolean tapOn;
public static String translationLanguage;
public static Integer updateAppMethod;
public static boolean uploadSpeedBoost;
public static boolean useAvatarAsBackground;
public static Boolean useExternalStorage;
public static boolean useOldShowUserMessagesMethod;
public static Boolean usePlusFolder;
public static Boolean useTelegramDataPath;
public static boolean usernameOpensChatInsteadOfProfile;
public static boolean verifyLinkTip;
public static boolean viewAllTopicsAsMessages;
public static ArrayList<Long> viewTopicsAsMessagesList;
public static SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("plusconfig", 0);
public static int translationProvider = 0;
public static int tabsSwipeSensitivity = 1;
public static int maxProfilePhotosCount = 200;
public static boolean enableTestDataCenterAutomaticReboot = true;
public static int seenUsersLimit = 100;
public static float stickerSize = 14.0f;
public interface Callback {
void onCompleted();
}
public interface HideDrawerOptionsDelegate {
public final class CC {
public static void $default$didClickCheck(HideDrawerOptionsDelegate hideDrawerOptionsDelegate, int i) {
}
}
void didClickCheck(int position);
void didClickSave(boolean changed);
}
public interface HideDrawerPlusOptionsDelegate {
public final class CC {
public static void $default$didClickCheck(HideDrawerPlusOptionsDelegate hideDrawerPlusOptionsDelegate, int i) {
}
}
void didClickCheck(int position);
void didClickSave(boolean changed);
}
public static int getDirectShareAction(int action) {
if (action == 0) {
return 7;
}
if (action == 1) {
return 2;
}
if (action == 2) {
return 1;
}
switch (action) {
case 7:
return 8;
case 8:
return 9;
case 9:
return 11;
case 10:
return 12;
default:
return action;
}
}
public static String getSwipeLeftIcon(int option) {
switch (option) {
case 1:
return "drawableTranslateIcon";
case 2:
return "drawableCopyIcon";
case 3:
return "drawableCloudIcon";
case 4:
return "drawableForwardQuoteIcon";
case 5:
return "drawableForwardIcon";
case 6:
return "drawableShareIcon";
case 7:
return "drawableMarkIcon";
case 8:
return "drawableDeleteIcon";
case 9:
return "drawableEditIcon";
case 10:
return "drawableReportIcon";
case 11:
return "drawableClearIcon";
default:
return "drawableReplyIcon";
}
}
static {
int i = R.string.OpenProfile;
int i2 = R.string.ShowMenu;
int i3 = R.string.PreviewAvatar;
int i4 = R.string.ShowPics;
tapAvatarActionList = new CharSequence[]{LocaleController.getString("OpenProfile", i), LocaleController.getString("ShowMenu", i2), LocaleController.getString("PreviewAvatar", i3), LocaleController.getString("ShowPics", i4)};
tapAndHoldAvatarActionList = new CharSequence[]{LocaleController.getString("PreviewAvatar", i3), LocaleController.getString("ShowMenu", i2), LocaleController.getString("OpenProfile", i), LocaleController.getString("ShowPics", i4)};
new LongSparseArray();
markedList = new LongSparseArray<>();
markedListMessages = new LongSparseArray<>();
markedListMessagesObjects = new LongSparseArray<>();
recentDownloads = new HashMap<>();
recentDownloadsMessages = new HashMap<>();
scheduledDownloadsIds = new HashMap<>();
int i5 = R.string.Translate;
int i6 = R.string.Reply;
int i7 = R.string.Copy;
int i8 = R.string.SaveToCloud;
int i9 = R.string.Forward;
int i10 = R.string.ForwardNoQuote;
int i11 = R.string.DirectShare;
int i12 = R.string.MarkMessage;
int i13 = R.string.Delete;
int i14 = R.string.Edit;
int i15 = R.string.ReportChat;
int i16 = R.string.ClearHistoryCache;
doubleTapActionList = new CharSequence[]{LocaleController.getString("Reactions", R.string.Reactions), LocaleController.getString("Translate", i5), LocaleController.getString("Reply", i6), LocaleController.getString("Copy", i7), LocaleController.getString("SaveToCloud", i8), LocaleController.getString("Forward", i9), LocaleController.getString("ForwardNoQuote", i10), LocaleController.getString("DirectShare", i11), LocaleController.getString("MarkMessage", i12), LocaleController.getString("Delete", i13), LocaleController.getString("Edit", i14), LocaleController.getString("ReportChat", i15), LocaleController.getString("ClearHistoryCache", i16)};
swipeLeftActionList = new CharSequence[]{LocaleController.getString("Reply", i6), LocaleController.getString("Translate", i5), LocaleController.getString("Copy", i7), LocaleController.getString("SaveToCloud", i8), LocaleController.getString("Forward", i9), LocaleController.getString("ForwardNoQuote", i10), LocaleController.getString("DirectShare", i11), LocaleController.getString("MarkMessage", i12), LocaleController.getString("Delete", i13), LocaleController.getString("Edit", i14), LocaleController.getString("ReportChat", i15), LocaleController.getString("ClearHistoryCache", i16)};
directShareButtonActionList = new CharSequence[]{LocaleController.getString("DirectShare", i11), LocaleController.getString("Reply", i6), LocaleController.getString("Translate", i5), LocaleController.getString("Copy", i7), LocaleController.getString("SaveToCloud", i8), LocaleController.getString("Forward", i9), LocaleController.getString("ForwardNoQuote", i10), LocaleController.getString("MarkMessage", i12), LocaleController.getString("Delete", i13), LocaleController.getString("ReportChat", i15), LocaleController.getString("ClearHistoryCache", i16)};
simultaneousDownloads = 1;
keepFormatting = true;
backwardSeconds = 5;
forwardSeconds = 5;
openReplyMsgWhenShowingUserMsgs = true;
viewAllTopicsAsMessages = false;
saveViewTopicsAsMessagesOption = false;
allowPinTopics = false;
hideDialogThumb = false;
pinnedTopics = new LongSparseArray<>();
openTopicsAsNormalGroups = false;
showOnlyGroupsWithTopics = false;
allowScheduleMessagesInTopics = true;
useOldShowUserMessagesMethod = false;
openArchiveOnPullDown = false;
markdownParseLinks = false;
showIdInProfile = true;
disableHideTopicOnSwipe = false;
showToastOnErrors = false;
improveVoiceRecordingQuality = false;
addDateToForwardedMessages = false;
hideVoiceTranscriptionButton = false;
showUserStatusCircleInChatOnlyIfOnline = false;
showUserStatusCircleInMainOnlyIfOnline = false;
showOnlineNotificationForGroups = false;
showNotificationEvenIfArchived = false;
hideStories = false;
showMediaSizeInPhotoViewer = true;
disableParametersFromBotLinks = false;
lastCheck = -1L;
periodTag = "repeatPeriod";
markedMessagesObject = new ArrayList<>();
markedMessagesDialogIds = new ArrayList<>();
markedMessagesIds = new ArrayList<>();
count = 0;
}
public static void loadPlusSettings() {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ActionBar.PlusSettings.loadPlusSettings():void");
}
public static String getOfficialChannelLang() {
if (TextUtils.isEmpty(officialChannelLang)) {
String replace = LocaleController.getString("ChannelLink", R.string.ChannelLink).replace("https://t.me/plusmsgr", "");
officialChannelLang = replace;
officialChannelLang = TextUtils.isEmpty(replace) ? "en" : officialChannelLang;
}
return officialChannelLang;
}
public static void loadPlusAccountSettings() {
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("plusconfig" + UserConfig.selectedAccount, 0);
accountPreferences = sharedPreferences;
plusDialogClickedAcc = sharedPreferences.getInt("plusDialogClickedAcc", 0);
}
public static boolean isInstalled(String packageName) {
try {
return ApplicationLoader.applicationContext.getPackageManager().getLaunchIntentForPackage(packageName) != null;
} catch (Exception e) {
FileLog.e(e);
return false;
}
}
public static int getPlusDialogType() {
return (PlusUtils.verifyInstallerId() || SharedConfig.buildVersion() % 10 == 0) ? plusDialogTypePlayStore : plusDialogType;
}
public static String getPlusDialogTitle() {
return getPlusDialogTitle(plusDialogType);
}
public static String getPlusDialogTitle(int type) {
if (type == 0) {
return LocaleController.formatString(R.string.DownloadNewThemes, new Object[0]);
}
if (type != 1) {
return "";
}
if (!TextUtils.isEmpty(LocaleController.getString(plusDialogTitle))) {
return LocaleController.getString(plusDialogTitle);
}
return plusDialogTitle;
}
public static String getPlusDialogSubtitle() {
return getPlusDialogSubtitle(plusDialogType);
}
public static String getPlusDialogSubtitle(int type) {
if (type == 0) {
return LocaleController.formatString(R.string.ThemesAppMsg, new Object[0]);
}
if (type != 1) {
return "";
}
if (!TextUtils.isEmpty(LocaleController.getString(plusDialogSubtitle))) {
return LocaleController.getString(plusDialogSubtitle);
}
return plusDialogSubtitle;
}
public static void resetPlusDialogClicked(long enabled) {
if (enabled == plusDialogEnabled || enabled > 7) {
plusDialogClickedAcc = 0;
plusDialogClicked = 0;
lastCheck = -1L;
SharedPreferences.Editor edit = preferences.edit();
edit.remove("plusDialogClicked");
edit.remove("lastTime");
edit.remove(periodTag);
edit.apply();
}
}
public static boolean isPlusDialogVisible() {
if (!showPlusDialogEvenIfInstalled) {
String str = "es.rafalense.telegram.themes";
if (!TextUtils.isEmpty(plusDialogThemesAppLink) && !plusDialogThemesAppLink.contains("es.rafalense.telegram.themes")) {
str = plusDialogThemesAppLink;
}
if (isInstalled(str)) {
return false;
}
}
long j = preferences.getInt(periodTag, 1) * 60 * 60 * 1000;
long currentTimeMillis = System.currentTimeMillis();
long j2 = lastCheck;
long j3 = currentTimeMillis - j2;
if (j2 < 0 || (j3 < j && j2 > 0)) {
lastCheck = preferences.getLong("lastTime", 0L);
return false;
}
if (plusDialogClicked < 2) {
return isPlusDialogEnabled();
}
if (j3 > j && j2 > 0) {
resetPlusDialogClicked(8L);
}
return false;
}
public static boolean isPlusDialogEnabled() {
return isPlusObjectEnabled(plusDialogEnabled);
}
public static boolean isPlusPromoDialogLangEnabled() {
if (TextUtils.isEmpty(plusPromoDialogEnabledLangs)) {
plusPromoDialogEnabledLangs = getOfficialChannelLang();
return true;
}
return plusPromoDialogEnabledLangs.contains(getOfficialChannelLang());
}
public static boolean isPlusPromoDialogEnabled() {
return isPlusObjectEnabled(plusPromoDialogEnabled) && !(hidePlusPromoDialog && isPlusPromoDialogHideOptionEnabled()) && isPlusPromoDialogLangEnabled();
}
public static boolean isPlusPromoDialogHideOptionEnabled() {
return isPlusObjectEnabled(plusPromoDialogHideOptionEnabled);
}
public static boolean isPlusObjectEnabled(long enabled) {
if (enabled > 7) {
return true;
}
if (enabled == 7 && BuildVars.BETA_2) {
return true;
}
if (enabled == 6 && (BuildVars.STANDALONE || (PlusUtils.verifyInstallerId() && !BuildVars.BETA_PS))) {
return true;
}
if (enabled == 5 && BuildVars.BETA) {
return true;
}
if (enabled < 5 && enabled >= 0) {
if (PlusUtils.verifyInstallerId() && enabled <= 1) {
return (BuildVars.BETA_PS && enabled == 0) ? false : true;
}
if (!PlusUtils.verifyInstallerId() && enabled > 1) {
if (BuildVars.BETA_DIRECT && enabled == 2) {
return false;
}
return !BuildVars.BETA || enabled > 3;
}
}
return false;
}
public static void setPlusPromoDialogHideOptionEnabled(long value) {
plusPromoDialogHideOptionEnabled = value;
setLong("plusPromoDialogHideOptionEnabled", value);
}
public static void setPlusPromoDialogEnabled(long value) {
plusPromoDialogEnabled = value;
setLong("plusPromoDialogEnabled", value);
}
public static void setPlusPromoDialogId(long value) {
plusPromoDialogId = value;
setLong("plusPromoDialogId", value);
}
public static void setPlusPromoDialogUsername(String value) {
plusPromoDialogUsername = value;
setString("plusPromoDialogUsername", value);
}
public static void setPlusPromoDialogEnabledLangs(String value) {
plusPromoDialogEnabledLangs = value;
setString("plusPromoDialogEnabledLangs", value);
}
public static void onPlusDialogClick(Activity activity) {
onPlusDialogClick(activity, plusDialogType);
}
public static void onPlusDialogClick(final Activity activity, final int type) {
plusDialogClicked = 1;
setInt("plusDialogClicked", 1);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
Intent launchIntentForPackage;
int i = type;
boolean z = true;
boolean z2 = false;
if (i == 0) {
try {
String str = "es.rafalense.telegram.themes";
if (!TextUtils.isEmpty(PlusSettings.plusDialogThemesAppLink) && !PlusSettings.plusDialogThemesAppLink.contains("es.rafalense.telegram.themes")) {
str = PlusSettings.plusDialogThemesAppLink;
}
launchIntentForPackage = activity.getPackageManager().getLaunchIntentForPackage(str);
if (launchIntentForPackage == null) {
launchIntentForPackage = new Intent("android.intent.action.VIEW", Uri.parse("market://details?id=" + str));
z = false;
}
} catch (Exception e) {
e = e;
}
try {
activity.startActivity(launchIntentForPackage);
z2 = z;
} catch (Exception e2) {
e = e2;
z2 = z;
FileLog.e(e);
try {
activity.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://play.google.com/store/apps/details?id=es.rafalense.themes")));
} catch (Exception e3) {
FileLog.e(e3);
}
Bundle bundle = new Bundle();
bundle.putString("versionCode", SharedConfig.buildVersion() + "");
bundle.putString("version", BuildVars.BUILD_VERSION_STRING);
bundle.putBoolean("installed", z2);
bundle.putInt("clicked", PlusSettings.plusDialogClicked);
bundle.putInt("type", type);
bundle.putString("link", PlusSettings.plusDialogLink);
FirebaseAnalytics.getInstance(activity).logEvent("onPlusDialogClick", bundle);
}
} else if (i == 1) {
try {
if (!TextUtils.isEmpty(PlusSettings.plusDialogLink)) {
activity.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(PlusSettings.plusDialogLink)));
}
} catch (Exception e4) {
FileLog.e(e4);
}
}
Bundle bundle2 = new Bundle();
bundle2.putString("versionCode", SharedConfig.buildVersion() + "");
bundle2.putString("version", BuildVars.BUILD_VERSION_STRING);
bundle2.putBoolean("installed", z2);
bundle2.putInt("clicked", PlusSettings.plusDialogClicked);
bundle2.putInt("type", type);
bundle2.putString("link", PlusSettings.plusDialogLink);
FirebaseAnalytics.getInstance(activity).logEvent("onPlusDialogClick", bundle2);
}
});
}
public static void onPlusDialogCloseClick() {
showPlusHintDialogCell = false;
setBoolean("showPlusHintDialogCell", false);
plusDialogClickedAcc = 2;
plusDialogClicked = 2;
setInt("plusDialogClicked", 2);
setInt(accountPreferences, "plusDialogClickedAcc", plusDialogClickedAcc);
long currentTimeMillis = System.currentTimeMillis();
lastCheck = currentTimeMillis;
setLong("lastTime", currentTimeMillis);
setInt(periodTag, 720);
Bundle bundle = new Bundle();
bundle.putString("versionCode", SharedConfig.buildVersion() + "");
bundle.putString("version", BuildVars.BUILD_VERSION_STRING);
bundle.putInt("clicked", plusDialogClicked);
FirebaseAnalytics.getInstance(ApplicationLoader.applicationContext).logEvent("onPlusDialogClose", bundle);
}
public static void onFoldersErrorCloseClick() {
plusDialogClickedAcc = 2;
setInt(accountPreferences, "plusDialogClickedAcc", 2);
Bundle bundle = new Bundle();
bundle.putString("versionCode", SharedConfig.buildVersion() + "");
bundle.putString("version", BuildVars.BUILD_VERSION_STRING);
bundle.putInt("clicked", plusDialogClicked);
FirebaseAnalytics.getInstance(ApplicationLoader.applicationContext).logEvent("onFoldersErrorCloseClick", bundle);
}
public static void setShowPlusHintDialogCell(boolean value) {
showPlusHintDialogCell = value;
setBoolean("showPlusHintDialogCell", value);
}
public static void setDisableCheckForThemes(boolean value) {
disableCheckForThemes = value;
setBoolean("disableCheckForThemes", value);
}
public static void setShowPlusDialogEvenIfInstalled(boolean value) {
showPlusDialogEvenIfInstalled = value;
setBoolean("showPlusDialogEvenIfInstalled", value);
}
public static void setHidePlusDialogUntilLoaded(boolean value) {
setBoolean("hidePlusDialogUntilLoaded", value);
}
public static void setPlusLoadConsent(boolean value) {
setBoolean("plusLoadConsent", value);
}
public static void setPlusDialogType(long value) {
int i = (int) value;
plusDialogType = i;
setInt("plusDialogType", i);
}
public static void setPlusDialogTypePlayStore(long value) {
int i = (int) value;
plusDialogTypePlayStore = i;
setInt("plusDialogTypePlayStore", i);
}
public static void setPlusDialogEnabled(long value) {
plusDialogEnabled = value;
setLong("plusDialogEnabled", value);
}
public static void setPlusDialogTitle(String value) {
plusDialogTitle = value;
setString("plusDialogTitle", value);
}
public static void setPlusDialogSubtitle(String value) {
plusDialogSubtitle = value;
setString("plusDialogSubtitle", value);
}
public static void setPlusDialogLink(String value) {
plusDialogLink = value;
setString("plusDialogLink", value);
}
public static void setPlusDialogThemesAppLink(String value) {
plusDialogThemesAppLink = value;
setString("plusDialogThemesAppLink", value);
}
public static void setFoldersErrorDialog() {
setPlusDialogTitle("Error with folders detected");
setPlusDialogSubtitle("PassportCorrectErrors");
setPlusDialogType(1L);
setPlusDialogTypePlayStore(1L);
setPlusDialogLink("");
}
public static void setBoolean(String key, boolean value) {
SharedPreferences.Editor edit = preferences.edit();
edit.putBoolean(key, value);
edit.apply();
}
public static void setInt(SharedPreferences sharedPreferences, String key, int value) {
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putInt(key, value);
edit.apply();
}
public static void setInt(String key, int value) {
SharedPreferences.Editor edit = preferences.edit();
edit.putInt(key, value);
edit.apply();
}
public static void setLong(String key, long value) {
SharedPreferences.Editor edit = preferences.edit();
edit.putLong(key, value);
edit.apply();
}
public static void setString(String key, String value) {
SharedPreferences.Editor edit = preferences.edit();
edit.putString(key, value);
edit.apply();
}
public static HashMap getPinnedTopicsList(long dialogId) {
LongSparseArray<HashMap<Integer, Integer>> longSparseArray = pinnedTopics;
if (longSparseArray == null) {
pinnedTopics = new LongSparseArray<>();
} else if (!longSparseArray.isEmpty() || pinnedTopicLoaded) {
return pinnedTopics.get(dialogId) == null ? new HashMap() : (HashMap) pinnedTopics.get(dialogId);
}
String string = preferences.getString("pinnedTopics", null);
if (string != null) {
Gson gson = new Gson();
LongSparseArray longSparseArray2 = (LongSparseArray) gson.fromJson(string, new TypeToken<LongSparseArray<HashMap<Integer, Integer>>>() {
}.getType());
for (int i = 0; i < longSparseArray2.size(); i++) {
long keyAt = longSparseArray2.keyAt(i);
LinkedTreeMap linkedTreeMap = (LinkedTreeMap) longSparseArray2.valueAt(i);
if (linkedTreeMap != null && !linkedTreeMap.isEmpty()) {
pinnedTopics.put(keyAt, (HashMap) gson.fromJson(gson.toJson(linkedTreeMap), new TypeToken<HashMap<Integer, Integer>>() {
}.getType()));
}
}
}
pinnedTopicLoaded = true;
return pinnedTopics.get(dialogId) == null ? new HashMap() : (HashMap) pinnedTopics.get(dialogId);
}
public static void clearPinnedTopicsList(long did) {
try {
pinnedTopics.remove(did);
SharedPreferences.Editor edit = preferences.edit();
edit.remove("pinnedTopics_" + did);
if (pinnedTopics.isEmpty()) {
edit.remove("pinnedTopics");
} else {
savePinnedTopicsList();
}
edit.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
public static boolean topicIsPinned(long did, int topicId) {
return getPinnedTopicsList(did).containsKey(Integer.valueOf(topicId));
}
public static void addToPinnedTopicsList(long did, int topicId, int position) {
if (topicIsPinned(did, topicId)) {
return;
}
HashMap pinnedTopicsList = getPinnedTopicsList(did);
pinnedTopicsList.put(Integer.valueOf(topicId), Integer.valueOf(position));
pinnedTopics.put(did, pinnedTopicsList);
savePinnedTopicsList();
}
public static void removeFromPinnedTopicsList(long did, int topicId) {
if (topicIsPinned(did, topicId)) {
HashMap pinnedTopicsList = getPinnedTopicsList(did);
pinnedTopicsList.remove(Integer.valueOf(topicId));
if (!pinnedTopicsList.isEmpty()) {
pinnedTopics.put(did, pinnedTopicsList);
} else {
pinnedTopics.remove(did);
}
savePinnedTopicsList();
}
}
public static void clearAllPinnedTopicLists() {
SharedPreferences.Editor edit = preferences.edit();
int size = pinnedTopics.size();
for (int i = 0; i < size; i++) {
long keyAt = pinnedTopics.keyAt(i);
edit.remove("pinnedTopics_" + keyAt);
MessagesController.getInstance(UserConfig.selectedAccount).getTopicsController().reloadTopics(keyAt, false);
}
edit.remove("pinnedTopics");
edit.commit();
pinnedTopics.clear();
}
public static void resetPinnedDialog(BaseFragment fragment, final long did, final Callback callback) {
AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity());
builder.setTitle(LocaleController.getString("ResetPinnedSettings", R.string.ResetPinnedSettings));
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
builder.setPositiveButton(LocaleController.getString("Yes", R.string.Yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
long j = did;
if (j <= 0) {
PlusSettings.clearAllPinnedTopicLists();
} else {
PlusSettings.clearPinnedTopicsList(j);
}
Callback callback2 = callback;
if (callback2 != null) {
callback2.onCompleted();
}
}
});
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
fragment.showDialog(builder.create());
}
public static void savePinnedTopicsList() {
try {
SharedPreferences.Editor edit = preferences.edit();
edit.putString("pinnedTopics", new Gson().toJson(pinnedTopics));
edit.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
public static ArrayList getViewTopicsAsMessagesList() {
ArrayList<Long> arrayList = viewTopicsAsMessagesList;
if (arrayList == null) {
viewTopicsAsMessagesList = new ArrayList<>();
} else if (!arrayList.isEmpty()) {
return viewTopicsAsMessagesList;
}
String string = preferences.getString("viewTopicsAsMessagesList", null);
if (!TextUtils.isEmpty(string)) {
try {
viewTopicsAsMessagesList = (ArrayList) new Gson().fromJson(string, new TypeToken<ArrayList<Long>>() {
}.getType());
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
}
return viewTopicsAsMessagesList;
}
public static boolean isInViewTopicsAsMessagesList(long did) {
return getViewTopicsAsMessagesList().contains(Long.valueOf(did));
}
public static void addToTopicsAsMessagesList(long did) {
if (isInViewTopicsAsMessagesList(did)) {
return;
}
viewTopicsAsMessagesList.add(Long.valueOf(did));
saveTopicsAsMessagesList();
}
public static void removeFromTopicsAsMessagesList(long did) {
if (isInViewTopicsAsMessagesList(did)) {
viewTopicsAsMessagesList.remove(Long.valueOf(did));
saveTopicsAsMessagesList();
}
}
public static void saveTopicsAsMessagesList() {
try {
SharedPreferences.Editor edit = preferences.edit();
edit.putString("viewTopicsAsMessagesList", new Gson().toJson(viewTopicsAsMessagesList));
edit.apply();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void setBackwardSeconds() {
preferences.edit().putInt("backwardSeconds", backwardSeconds).apply();
}
public static void setForwardSeconds() {
preferences.edit().putInt("forwardSeconds", forwardSeconds).apply();
}
public static void toggleMusicStop() {
SharedPreferences.Editor edit = preferences.edit();
boolean z = !disableMusicStop;
disableMusicStop = z;
edit.putBoolean("usePlusFolder", z).apply();
}
public static boolean getUseBestProxy() {
if (selectBestProxyByPing == null) {
selectBestProxyByPing = Boolean.FALSE;
}
return selectBestProxyByPing.booleanValue();
}
public static String getShareButtonIcon() {
switch (directShareButtonAction) {
case 1:
return "drawableReplyIcon";
case 2:
return "drawableTranslateIcon";
case 3:
return "drawableCopyIcon";
case 4:
return "drawableCloudIcon";
case 5:
return "drawableForwardQuoteIcon";
case 6:
return "drawableForwardIcon";
case 7:
return "drawableMarkIcon";
case 8:
return "drawableDeleteIcon";
case 9:
return "drawableReportIcon";
case 10:
return "drawableClearIcon";
default:
return "drawableShareIcon";
}
}
public static void setVerifyLinkTip(boolean shown) {
verifyLinkTip = shown;
SharedPreferences.Editor edit = preferences.edit();
edit.putBoolean("verifyLinkTip", verifyLinkTip);
edit.commit();
}
public static ArrayList<Integer> getMarkedMessages(long did) {
ArrayList<Integer> arrayList = (ArrayList) markedList.get(did);
if (arrayList != null) {
return arrayList;
}
ArrayList<Integer> arrayList2 = new ArrayList<>();
String string = preferences.getString("marked_" + did, null);
if (!TextUtils.isEmpty(string)) {
try {
arrayList2 = (ArrayList) new Gson().fromJson(string, new TypeToken<ArrayList<Integer>>() {
}.getType());
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
}
markedList.put(did, arrayList2);
return arrayList2;
}
public static void getAllMarkedMessages(final Runnable onCompleted) {
Map<String, ?> all = preferences.getAll();
markedList = new LongSparseArray<>();
for (Map.Entry<String, ?> entry : all.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key.contains("marked_")) {
try {
new ArrayList();
long parseLong = Long.parseLong(key.replace("marked_", ""));
if (value != null) {
String obj = value.toString();
if (!TextUtils.isEmpty(obj)) {
try {
markedList.put(parseLong, (ArrayList) new Gson().fromJson(obj, new TypeToken<ArrayList<Integer>>() {
}.getType()));
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
}
}
} catch (NumberFormatException e2) {
e2.printStackTrace();
}
}
}
markedMessagesObject = new ArrayList<>();
markedMessagesIds = new ArrayList<>();
count = 0;
if (markedList.size() <= 0) {
if (onCompleted != null) {
AndroidUtilities.runOnUIThread(onCompleted);
return;
}
return;
}
final int size = markedList.size();
for (int i = 0; i < size; i++) {
final long keyAt = markedList.keyAt(i);
final ArrayList arrayList = (ArrayList) markedList.valueAt(i);
markedMessagesIds.addAll(arrayList);
MessagesStorage.getInstance(UserConfig.selectedAccount).updateMarkedMessages(keyAt, arrayList, new Runnable() {
@Override
public void run() {
Runnable runnable;
PlusSettings.count++;
ArrayList arrayList2 = (ArrayList) PlusSettings.markedListMessagesObjects.get(keyAt);
if (arrayList2 != null) {
PlusSettings.markedMessagesObject.addAll(arrayList2);
}
int size2 = arrayList.size();
for (int i2 = 0; i2 < size2; i2++) {
PlusSettings.markedMessagesDialogIds.add(Long.valueOf(keyAt));
}
if (PlusSettings.count != size || (runnable = onCompleted) == null) {
return;
}
AndroidUtilities.runOnUIThread(runnable);
}
});
}
}
public static void clearAllMarkedMessages() {
Map<String, ?> all = preferences.getAll();
SharedPreferences.Editor edit = preferences.edit();
Iterator<Map.Entry<String, ?>> it = all.entrySet().iterator();
while (it.hasNext()) {
String key = it.next().getKey();
if (key.contains("marked_")) {
edit.remove("marked_" + Long.parseLong(key.replace("marked_", "")));
}
}
edit.commit();
markedMessagesIds.clear();
markedMessagesDialogIds.clear();
markedMessagesObject.clear();
markedList.clear();
}
public static void clearMarkedMessages(long did) {
try {
((ArrayList) markedList.get(did)).clear();
SharedPreferences.Editor edit = preferences.edit();
edit.remove("marked_" + did);
edit.commit();
((ArrayList) markedListMessages.get(did)).clear();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void deleteMarkedMessage(long dialogId, int msgId) {
ArrayList arrayList = (ArrayList) markedList.get(dialogId);
if (arrayList == null) {
return;
}
arrayList.remove(Integer.valueOf(msgId));
if (arrayList.isEmpty()) {
markedList.remove(dialogId);
} else {
markedList.put(dialogId, arrayList);
}
saveMarkedMessages(arrayList, dialogId);
}
public static void saveMarkedMessages(ArrayList<Integer> list, long dialogId) {
if (list.isEmpty()) {
markedList.remove(dialogId);
} else {
markedList.put(dialogId, list);
}
SharedPreferences.Editor edit = preferences.edit();
try {
if (!list.isEmpty()) {
edit.putString("marked_" + dialogId, new Gson().toJson(list));
} else {
edit.remove("marked_" + dialogId);
}
edit.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void saveRecentDownloads() {
SharedPreferences.Editor edit = preferences.edit();
try {
edit.putString("recent_downloads", new Gson().toJson(recentDownloads));
edit.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
public static HashMap<Long, ArrayList<Integer>> getRecentDownloads() {
HashMap<Long, ArrayList<Integer>> hashMap = recentDownloads;
if (hashMap != null && !hashMap.isEmpty()) {
return recentDownloads;
}
String string = preferences.getString("recent_downloads", null);
if (string != null && !TextUtils.isEmpty(string) && !"null".equals(string)) {
try {
recentDownloads = (HashMap) new Gson().fromJson(string, new TypeToken<HashMap<Long, ArrayList<Integer>>>() {
}.getType());
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
}
return recentDownloads;
}
public static ArrayList<Integer> getRecentDownloads(long did) {
HashMap<Long, ArrayList<Integer>> hashMap = recentDownloads;
if (hashMap == null || hashMap.isEmpty()) {
recentDownloads = getRecentDownloads();
}
ArrayList<Integer> arrayList = recentDownloads.get(Long.valueOf(did));
if (arrayList == null) {
arrayList = new ArrayList<>();
}
if (recentDownloads.size() > 20) {
clearRecentDownloadsMessages();
} else if (recentDownloads.size() == 20) {
Iterator<Map.Entry<Long, ArrayList<Integer>>> it = recentDownloads.entrySet().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
long longValue = it.next().getKey().longValue();
if (longValue != did) {
recentDownloads.remove(Long.valueOf(longValue));
break;
}
}
}
recentDownloads.put(Long.valueOf(did), arrayList);
return arrayList;
}
public static boolean addRecentDownload(long dialogId, int msgId) {
try {
ArrayList<Integer> recentDownloads2 = getRecentDownloads(dialogId);
if (!recentDownloads2.contains(Integer.valueOf(msgId))) {
if (recentDownloads2.size() >= 20) {
recentDownloads2.remove(0);
}
recentDownloads2.add(Integer.valueOf(msgId));
recentDownloads.put(Long.valueOf(dialogId), recentDownloads2);
saveRecentDownloads();
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
public static boolean allowedRecentFile(MessageObject messageObject) {
return (messageObject.isAnyKindOfSticker() || messageObject.isAnimatedSticker() || messageObject.isGif() || messageObject.isNewGif()) ? false : true;
}
public static boolean addRecentDownload(MessageObject messageObject) {
if (allowedRecentFile(messageObject)) {
return addRecentDownload(messageObject.getDialogId(), messageObject.getId());
}
return false;
}
public static ArrayList<Integer> removeRecentDownload(MessageObject messageObject) {
long dialogId = messageObject.getDialogId();
int id = messageObject.getId();
ArrayList<Integer> recentDownloads2 = getRecentDownloads(dialogId);
recentDownloads2.remove(Integer.valueOf(id));
if (recentDownloads2.isEmpty()) {
recentDownloads.remove(Long.valueOf(dialogId));
} else {
recentDownloads.put(Long.valueOf(dialogId), recentDownloads2);
}
saveRecentDownloads();
return recentDownloads2;
}
public static void clearRecentDownloadsMessages() {
try {
recentDownloads.clear();
recentDownloadsMessages.clear();
SharedPreferences.Editor edit = preferences.edit();
edit.remove("recent_downloads");
edit.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
public static HashMap<String, String> getScheduledDownloadsIds() {
HashMap<String, String> hashMap = scheduledDownloadsIds;
if (hashMap != null && !hashMap.isEmpty()) {
return scheduledDownloadsIds;
}
String string = preferences.getString("scheduled_downloads", null);
if (string != null && !TextUtils.isEmpty(string) && !"null".equals(string)) {
try {
scheduledDownloadsIds = (HashMap) new Gson().fromJson(string, new TypeToken<HashMap<String, String>>() {
}.getType());
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
}
return scheduledDownloadsIds;
}
public static void saveScheduledDownloadsIds() {
SharedPreferences.Editor edit = preferences.edit();
try {
edit.putString("scheduled_downloads", new Gson().toJson(scheduledDownloadsIds));
edit.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void clearScheduledDownloadsIds() {
try {
scheduledDownloadsIds.clear();
SharedPreferences.Editor edit = preferences.edit();
edit.remove("scheduled_downloads");
edit.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
public static int getActiveDownloads() {
if (!includePendingDownloads) {
return FileLoader.getInstance(UserConfig.selectedAccount).getActiveFileLoadOperations().size();
}
int size = FileLoader.getInstance(UserConfig.selectedAccount).getLoadOperationsPaths().size();
if (size != loadOperationsPathsSize) {
loadOperationsPathsSize = size;
notFilesQeue = 0;
Iterator it = FileLoader.getInstance(UserConfig.selectedAccount).getLoadOperationsPaths().entrySet().iterator();
while (it.hasNext()) {
if (((ArrayList) DownloadController.getInstance(UserConfig.selectedAccount).getLoadingFileMessagesObservers().get((String) ((Map.Entry) it.next()).getKey())) == null) {
notFilesQeue++;
}
}
}
return size - notFilesQeue;
}
public static int getStorage() {
if (storage == null) {
storage = Integer.valueOf(preferences.getInt("storage", 0));
}
return storage.intValue();
}
public static void toggleStorage() {
storage = Integer.valueOf(storage.intValue() == 0 ? 1 : 0);
preferences.edit().putInt("storage", storage.intValue()).apply();
}
public static void setStorage(int strg) {
storage = Integer.valueOf(strg);
preferences.edit().putInt("storage", storage.intValue()).apply();
}
public static boolean usePlusFolder() {
if (usePlusFolder == null) {
usePlusFolder = Boolean.valueOf(preferences.getBoolean("usePlusFolder", false));
}
return usePlusFolder.booleanValue();
}
public static void toggleUsePlusFolder() {
SharedPreferences.Editor edit = preferences.edit();
Boolean valueOf = Boolean.valueOf(!usePlusFolder.booleanValue());
usePlusFolder = valueOf;
edit.putBoolean("usePlusFolder", valueOf.booleanValue()).apply();
}
public static boolean useExternalStorage() {
if (useExternalStorage == null) {
useExternalStorage = Boolean.valueOf(preferences.getBoolean("useExternalStorage", false));
}
return useExternalStorage.booleanValue();
}
public static void toggleUseExternalStorage() {
SharedPreferences.Editor edit = preferences.edit();
Boolean valueOf = Boolean.valueOf(!useExternalStorage.booleanValue());
useExternalStorage = valueOf;
edit.putBoolean("useExternalStorage", valueOf.booleanValue()).apply();
}
public static void toggleUseTelegramDataPath() {
SharedPreferences.Editor edit = preferences.edit();
Boolean valueOf = Boolean.valueOf(!useTelegramDataPath.booleanValue());
useTelegramDataPath = valueOf;
edit.putBoolean("useTelegramDataPath", valueOf.booleanValue()).apply();
}
public static boolean useTelegramDataPath() {
if (useTelegramDataPath == null) {
useTelegramDataPath = Boolean.valueOf(preferences.getBoolean("useTelegramDataPath", false));
}
return useTelegramDataPath.booleanValue();
}
public static boolean getHideSeenStories() {
if (hideSeenStories == null) {
hideSeenStories = Boolean.valueOf(preferences.getBoolean("hideSeenStories", false));
}
return hideSeenStories.booleanValue();
}
public static boolean getIgnoreBlocked() {
if (ignoreBlocked == null) {
boolean z = false;
if (BuildVars.BETA_DIRECT && preferences.getBoolean("ignoreBlocked", false)) {
z = true;
}
ignoreBlocked = Boolean.valueOf(z);
}
return ignoreBlocked.booleanValue();
}
public static int getAppUpdateMethod() {
if (updateAppMethod == null) {
updateAppMethod = Integer.valueOf(preferences.getInt("updateAppMethod", 0));
}
return updateAppMethod.intValue();
}
public static boolean isUpdateEnabled() {
int appUpdateMethod = getAppUpdateMethod();
if (appUpdateMethod == 0) {
return true;
}
return appUpdateMethod == 1 && ApplicationLoader.isConnectedToWiFi();
}
public static boolean getAddDayToFormatterSchedule() {
return preferences.getBoolean("addDayToFormatterSchedule", true);
}
public static boolean getKeepOriginalFilename() {
boolean z = preferences.getBoolean("keepOriginalFilename", false);
keepOriginalFileName = z;
return z;
}
public static boolean getKeepFilenameEqual() {
boolean z = preferences.getBoolean("keepFilenameEqual", false);
keepFilenameEqual = z;
return z;
}
public static void toggleKeepFilenameEqual() {
SharedPreferences.Editor edit = preferences.edit();
boolean z = !keepFilenameEqual;
keepFilenameEqual = z;
edit.putBoolean("keepFilenameEqual", z).apply();
}
public static void setDeleteCaption(boolean delete) {
deleteSharedMediaCaption = delete;
preferences.edit().putBoolean("deleteSharedMediaCaption", deleteSharedMediaCaption).apply();
}
public static void saveTranslationLanguage() {
preferences.edit().putString("translationLanguage", translationLanguage).apply();
}
public static String getChatTranslationLanguage(long id) {
return preferences.getString("translationChatLang_" + id, translationLanguage);
}
public static String getChatLang(long id) {
String chatTranslationLanguage = getChatTranslationLanguage(id);
if (!chatTranslationLanguage.isEmpty()) {
return chatTranslationLanguage;
}
if (!translationLanguage.isEmpty()) {
return translationLanguage;
}
Locale locale = LocaleController.getInstance().currentLocale;
if (translationProvider != 3 && locale.getLanguage().equals("zh") && (locale.getCountry().toUpperCase().equals("CN") || locale.getCountry().toUpperCase().equals("TW"))) {
return locale.getLanguage() + "-" + locale.getCountry().toUpperCase();
}
return locale.getLanguage();
}
public static void saveChatTranslationLanguage(long id, String lang) {
preferences.edit().putString("translationChatLang_" + id, lang).apply();
}
public static void saveTabId(int id) {
if (Theme.plusHideAllTab && id == 0) {
id = 1;
}
lastTabId = id;
preferences.edit().putInt("lastTabId", lastTabId).apply();
}
public static void setTranslationProvider(int provider) {
translationProvider = provider;
preferences.edit().putInt("translationProvider", translationProvider).apply();
}
public static Dialog createHideDrawerOptionsAlert(Activity parentActivity, final HideDrawerOptionsDelegate delegate) {
String str;
if (parentActivity == null) {
return null;
}
final BottomSheet.Builder builder = new BottomSheet.Builder(parentActivity);
int i = 14;
final boolean[] zArr = new boolean[14];
builder.setTitle(LocaleController.getString("ShowMenuOptions", R.string.ShowMenuOptions));
builder.setApplyTopPadding(false);
builder.setApplyBottomPadding(false);
ScrollView scrollView = new ScrollView(parentActivity);
scrollView.setFillViewport(true);
int i2 = Theme.key_windowBackgroundGray;
scrollView.setTag(Integer.valueOf(i2));
scrollView.setBackgroundColor(Theme.usePlusTheme ? Theme.prefShadowColor : Theme.getColor(i2));
LinearLayout linearLayout = new LinearLayout(parentActivity);
linearLayout.setOrientation(1);
int i3 = -1;
scrollView.addView(linearLayout, new FrameLayout.LayoutParams(-1, -2));
BottomSheet.BottomSheetCell bottomSheetCell = new BottomSheet.BottomSheetCell(parentActivity, 1);
final boolean[] zArr2 = new boolean[1];
int i4 = 0;
while (i4 < i) {
if (i4 == 0) {
zArr[i4] = !Theme.plusDrawerHideNewGroup;
str = LocaleController.getString("NewGroup", R.string.NewGroup);
} else if (i4 == 1) {
zArr[i4] = !Theme.plusDrawerHideNewSecretChat;
str = LocaleController.getString("NewSecretChat", R.string.NewSecretChat);
} else if (i4 == 2) {
zArr[i4] = !Theme.plusDrawerHideNewChannel;
str = LocaleController.getString("NewChannel", R.string.NewChannel);
} else if (i4 == 3) {
zArr[i4] = !Theme.plusDrawerHideContacts;
str = LocaleController.getString("Contacts", R.string.Contacts);
} else if (i4 == 4) {
zArr[i4] = !drawerHideDownloads;
str = LocaleController.getString("Downloads", R.string.Downloads);
} else if (i4 == 5) {
zArr[i4] = !Theme.plusDrawerHideFolders;
str = LocaleController.getString("Filters", R.string.Filters);
} else if (i4 == 6) {
zArr[i4] = !Theme.plusDrawerHidePeopleNearby;
str = LocaleController.getString("PeopleNearby", R.string.PeopleNearby);
} else if (i4 == 7) {
zArr[i4] = !Theme.plusDrawerHideSavedMessages;
str = LocaleController.getString("SavedMessages", R.string.SavedMessages);
} else if (i4 == 8) {
zArr[i4] = !drawerHideMarkedMessages;
str = LocaleController.getString("MarkedMessages", R.string.MarkedMessages);
} else if (i4 == 9) {
zArr[i4] = !Theme.plusDrawerHideCalls;
str = LocaleController.getString("Calls", R.string.Calls);
} else if (i4 == 10) {
zArr[i4] = !Theme.plusDrawerHideArchivedChats;
str = LocaleController.getString("ArchivedChats", R.string.ArchivedChats);
} else if (i4 == 11) {
zArr[i4] = !drawerHideSetEmojiStatus;
str = LocaleController.getString("SetEmojiStatus", R.string.SetEmojiStatus);
} else if (i4 == 12) {
zArr[i4] = !drawerHideMyProfile;
str = LocaleController.getString("MyProfile", R.string.MyProfile);
} else if (i4 == 13) {
zArr[i4] = !drawerHideWallet;
str = LocaleController.getString("Wallet", R.string.Wallet);
} else {
str = null;
}
CheckBoxCell checkBoxCell = new CheckBoxCell(parentActivity, 1);
checkBoxCell.setTag(Integer.valueOf(i4));
checkBoxCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
linearLayout.addView(checkBoxCell, LayoutHelper.createLinear(i3, -2));
checkBoxCell.setText(str, "", zArr[i4], true);
checkBoxCell.setTextColor(Theme.usePlusTheme ? Theme.dialogTextColor : Theme.getColor(Theme.key_dialogTextBlack));
checkBoxCell.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CheckBoxCell checkBoxCell2 = (CheckBoxCell) v;
int intValue = ((Integer) checkBoxCell2.getTag()).intValue();
boolean[] zArr3 = zArr;
zArr3[intValue] = !zArr3[intValue];
checkBoxCell2.setChecked(zArr3[intValue], true);
zArr2[0] = true;
HideDrawerOptionsDelegate hideDrawerOptionsDelegate = delegate;
if (hideDrawerOptionsDelegate != null) {
hideDrawerOptionsDelegate.didClickCheck(intValue);
}
}
});
i4++;
i = 14;
i3 = -1;
}
bottomSheetCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
bottomSheetCell.setTextAndIcon(LocaleController.getString("Save", R.string.Save).toUpperCase(), 0);
bottomSheetCell.setTextColor(Theme.getColor(Theme.key_dialogTextBlue2));
bottomSheetCell.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences.Editor edit = PlusSettings.preferences.edit();
boolean z = !zArr[0];
Theme.plusDrawerHideNewGroup = z;
edit.putBoolean("drawerHideNewGroup", z);
boolean z2 = !zArr[1];
Theme.plusDrawerHideNewSecretChat = z2;
edit.putBoolean("drawerHideNewSecretChat", z2);
boolean z3 = !zArr[2];
Theme.plusDrawerHideNewChannel = z3;
edit.putBoolean("drawerHideNewChannel", z3);
boolean z4 = !zArr[3];
Theme.plusDrawerHideContacts = z4;
edit.putBoolean("drawerHideContacts", z4);
boolean z5 = !zArr[4];
PlusSettings.drawerHideDownloads = z5;
edit.putBoolean("drawerHideDownloads", z5);
boolean z6 = !zArr[5];
Theme.plusDrawerHideFolders = z6;
edit.putBoolean("drawerHideFolders", z6);
boolean z7 = !zArr[6];
Theme.plusDrawerHidePeopleNearby = z7;
edit.putBoolean("drawerHidePeopleNearby", z7);
boolean z8 = !zArr[7];
Theme.plusDrawerHideSavedMessages = z8;
edit.putBoolean("drawerHideSavedMessages", z8);
boolean z9 = !zArr[8];
PlusSettings.drawerHideMarkedMessages = z9;
edit.putBoolean("drawerHideMarkedMessages", z9);
boolean z10 = !zArr[9];
Theme.plusDrawerHideCalls = z10;
edit.putBoolean("drawerHideCalls", z10);
boolean z11 = !zArr[10];
Theme.plusDrawerHideArchivedChats = z11;
edit.putBoolean("drawerHideArchivedChats", z11);
boolean z12 = !zArr[11];
PlusSettings.drawerHideSetEmojiStatus = z12;
edit.putBoolean("drawerHideSetEmojiStatus", z12);
boolean z13 = !zArr[12];
PlusSettings.drawerHideMyProfile = z13;
edit.putBoolean("drawerHideMyProfile", z13);
boolean z14 = !zArr[13];
PlusSettings.drawerHideWallet = z14;
edit.putBoolean("drawerHideWallet", z14);
boolean z15 = Theme.plusDrawerHideNewGroup && Theme.plusDrawerHideNewSecretChat && Theme.plusDrawerHideNewChannel;
Theme.plusDrawerHideNewDivider = z15;
edit.putBoolean("drawerHideNewDivider", z15);
boolean z16 = PlusSettings.drawerHideSetEmojiStatus && PlusSettings.drawerHideWallet;
PlusSettings.drawerHideMyStoriesDivider = z16;
edit.putBoolean("drawerHideMyStoriesDivider", z16);
edit.apply();
HideDrawerOptionsDelegate hideDrawerOptionsDelegate = delegate;
if (hideDrawerOptionsDelegate != null) {
hideDrawerOptionsDelegate.didClickSave(zArr2[0]);
zArr2[0] = false;
}
builder.getDismissRunnable().run();
}
});
linearLayout.addView(bottomSheetCell, LayoutHelper.createLinear(-1, -2));
builder.setCustomView(scrollView);
return builder.create();
}
public static void changeMaxAccountCount(final BaseFragment fragment) {
final Activity parentActivity = fragment.getParentActivity();
if (parentActivity == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
builder.setTitle(LocaleController.getString("MaxAccountCount", R.string.MaxAccountCount));
final NumberPicker numberPicker = new NumberPicker(parentActivity);
final int maxAccountCount2 = UserConfig.getMaxAccountCount2();
int i = 0;
for (int i2 = 0; i2 < maxAccountCount2; i2++) {
if (UserConfig.getInstance(i2).isClientActivated()) {
i = i2;
}
}
numberPicker.setMinValue(Math.max(i, 3));
numberPicker.setMaxValue(100);
numberPicker.setValue(maxAccountCount2);
builder.setView(numberPicker);
builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i3) {
PlusSettings.lambda$changeMaxAccountCount$0(numberPicker, maxAccountCount2, parentActivity, fragment, dialogInterface, i3);
}
});
fragment.showDialog(builder.create());
}
public static void lambda$changeMaxAccountCount$0(NumberPicker numberPicker, int i, Activity activity, BaseFragment baseFragment, DialogInterface dialogInterface, int i2) {
final int value = numberPicker.getValue();
if (value != i) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(LocaleController.getString("MaxAccountCount", R.string.MaxAccountCount));
builder.setMessage(LocaleController.getString("ClickOkToRestart", R.string.ClickOkToRestart));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface2, int i3) {
UserConfig.setMaxAccountCount(value);
Utilities.restartApp();
}
});
baseFragment.showDialog(builder.create());
}
}
public static Dialog createHideDrawerPlusOptionsAlert(Activity parentActivity, final HideDrawerPlusOptionsDelegate delegate) {
String str;
if (parentActivity == null) {
return null;
}
final BottomSheet.Builder builder = new BottomSheet.Builder(parentActivity);
int i = 7;
final boolean[] zArr = new boolean[7];
builder.setTitle(LocaleController.getString("ShowMenuPlusOptions", R.string.ShowMenuPlusOptions));
builder.setApplyTopPadding(false);
builder.setApplyBottomPadding(false);
ScrollView scrollView = new ScrollView(parentActivity);
scrollView.setFillViewport(true);
int i2 = Theme.key_windowBackgroundGray;
scrollView.setTag(Integer.valueOf(i2));
scrollView.setBackgroundColor(Theme.usePlusTheme ? Theme.prefShadowColor : Theme.getColor(i2));
LinearLayout linearLayout = new LinearLayout(parentActivity);
linearLayout.setOrientation(1);
int i3 = -1;
scrollView.addView(linearLayout, new FrameLayout.LayoutParams(-1, -2));
BottomSheet.BottomSheetCell bottomSheetCell = new BottomSheet.BottomSheetCell(parentActivity, 1);
final boolean[] zArr2 = new boolean[1];
int i4 = 0;
while (i4 < i) {
if (i4 == 0) {
zArr[i4] = !Theme.plusDrawerHideCategories;
str = LocaleController.getString("Categories", R.string.Categories);
} else if (i4 == 1) {
zArr[i4] = !Theme.plusDrawerHideDownloadThemes;
str = LocaleController.getString("DownloadThemes", R.string.DownloadThemes);
} else if (i4 == 2) {
zArr[i4] = !Theme.plusDrawerHideTheming;
str = LocaleController.getString("Theming", R.string.Theming);
} else if (i4 == 3) {
zArr[i4] = !Theme.plusDrawerHideSupportGroup;
str = LocaleController.getString("SupportGroup", R.string.SupportGroup);
} else if (i4 == 4) {
zArr[i4] = !Theme.plusDrawerHideChannel;
str = LocaleController.getString("OfficialChannel", R.string.OfficialChannel);
} else if (i4 == 5) {
zArr[i4] = !Theme.plusDrawerHideOffTopicGroup;
str = LocaleController.getString("OffTopicGroup", R.string.OffTopicGroup);
} else if (i4 == 6) {
zArr[i4] = !Theme.plusDrawerHideChatsCounter;
str = LocaleController.getString("ChatsCounters", R.string.ChatsCounters);
} else {
str = null;
}
CheckBoxCell checkBoxCell = new CheckBoxCell(parentActivity, 1);
checkBoxCell.setTag(Integer.valueOf(i4));
checkBoxCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
linearLayout.addView(checkBoxCell, LayoutHelper.createLinear(i3, -2));
checkBoxCell.setText(str, "", zArr[i4], true);
checkBoxCell.setTextColor(Theme.usePlusTheme ? Theme.dialogTextColor : Theme.getColor(Theme.key_dialogTextBlack));
checkBoxCell.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CheckBoxCell checkBoxCell2 = (CheckBoxCell) v;
int intValue = ((Integer) checkBoxCell2.getTag()).intValue();
boolean[] zArr3 = zArr;
zArr3[intValue] = !zArr3[intValue];
checkBoxCell2.setChecked(zArr3[intValue], true);
zArr2[0] = true;
HideDrawerPlusOptionsDelegate hideDrawerPlusOptionsDelegate = delegate;
if (hideDrawerPlusOptionsDelegate != null) {
hideDrawerPlusOptionsDelegate.didClickCheck(intValue);
}
}
});
i4++;
i = 7;
i3 = -1;
}
bottomSheetCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
bottomSheetCell.setTextAndIcon(LocaleController.getString("Save", R.string.Save).toUpperCase(), 0);
bottomSheetCell.setTextColor(Theme.getColor(Theme.key_dialogTextBlue2));
bottomSheetCell.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences.Editor edit = PlusSettings.preferences.edit();
boolean z = !zArr[0];
Theme.plusDrawerHideCategories = z;
edit.putBoolean("drawerHideCategories", z);
boolean z2 = !zArr[1];
Theme.plusDrawerHideDownloadThemes = z2;
edit.putBoolean("drawerHideDownloadThemes", z2);
boolean z3 = !zArr[2];
Theme.plusDrawerHideTheming = z3;
edit.putBoolean("drawerHideTheming", z3);
boolean z4 = !zArr[3];
Theme.plusDrawerHideSupportGroup = z4;
edit.putBoolean("drawerHideSupportGroup", z4);
boolean z5 = !zArr[4];
Theme.plusDrawerHideChannel = z5;
edit.putBoolean("drawerHideChannel", z5);
boolean z6 = !zArr[5];
Theme.plusDrawerHideOffTopicGroup = z6;
edit.putBoolean("drawerHideOffTopicGroup", z6);
boolean z7 = !zArr[6];
Theme.plusDrawerHideChatsCounter = z7;
edit.putBoolean("drawerHideChatsCounter", z7);
edit.apply();
HideDrawerPlusOptionsDelegate hideDrawerPlusOptionsDelegate = delegate;
if (hideDrawerPlusOptionsDelegate != null) {
hideDrawerPlusOptionsDelegate.didClickSave(zArr2[0]);
zArr2[0] = false;
}
builder.getDismissRunnable().run();
}
});
linearLayout.addView(bottomSheetCell, LayoutHelper.createLinear(-1, -2));
builder.setCustomView(scrollView);
return builder.create();
}
public static void deleteHiddenPasscode() {
SharedConfig.hiddenPasscodeHash = "";
SharedConfig.hiddenPasscodeSalt = new byte[0];
SharedPreferences.Editor edit = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", 0).edit();
edit.putString("hiddenPasscodeHash", "");
edit.putString("hiddenPasscodeSalt", "");
edit.apply();
SharedPreferences.Editor edit2 = preferences.edit();
enableHiddenDialogs = false;
edit2.putBoolean("enableHiddenDialogs", false).apply();
MessagesController.getGlobalMainSettings().edit().putBoolean("firstTimeHidding", true).apply();
}
}