NekoX/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java

711 lines
31 KiB
Java
Raw Normal View History

2019-06-11 09:13:04 +02:00
package tw.nekomimi.nekogram;
import android.app.Activity;
2019-07-29 17:22:59 +02:00
import android.content.Intent;
2019-06-11 09:13:04 +02:00
import android.content.SharedPreferences;
2020-07-19 09:44:11 +02:00
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
2019-06-11 09:13:04 +02:00
import org.telegram.messenger.ApplicationLoader;
2020-06-25 17:25:17 +02:00
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter;
2020-02-25 10:04:26 +01:00
import org.telegram.messenger.NotificationsService;
2020-06-25 17:25:17 +02:00
import org.telegram.messenger.R;
import java.util.Locale;
import cn.hutool.core.util.StrUtil;
2019-06-11 09:13:04 +02:00
public class NekoConfig {
2020-04-26 08:50:44 +02:00
public static final int TITLE_TYPE_TEXT = 0;
public static final int TITLE_TYPE_ICON = 1;
public static final int TITLE_TYPE_MIX = 2;
2020-07-19 09:44:11 +02:00
public static SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
2020-06-25 17:25:17 +02:00
public static boolean useIPv6;
public static boolean useSystemEmoji;
public static boolean ignoreBlocked;
public static boolean hideProxySponsorChannel;
public static boolean disablePhotoSideAction;
public static boolean hideKeyboardOnChatScroll;
public static boolean rearVideoMessages;
public static boolean hideAllTab;
public static boolean confirmAVMessage;
public static boolean askBeforeCall;
public static boolean disableNumberRounding;
public static int mapPreviewProvider;
public static float stickerSize;
public static int translationProvider;
public static int tabsTitleType;
public static boolean showAddToSavedMessages;
public static boolean showReport;
public static boolean showViewHistory;
public static boolean showAdminActions;
public static boolean showChangePermissions;
public static boolean showDeleteDownloadedFile;
public static boolean showMessageDetails;
public static boolean showTranslate;
public static boolean showRepeat;
public static boolean hidePhone;
public static int typeface;
public static boolean transparentStatusBar;
public static boolean forceTablet;
public static boolean openArchiveOnPull;
public static boolean avatarAsDrawerBackground;
public static boolean showTabsOnForward;
public static int nameOrder;
public static int eventType;
public static boolean newYear;
public static int actionBarDecoration;
public static boolean unlimitedFavedStickers;
public static boolean unlimitedPinnedDialogs;
public static boolean residentNotification;
public static boolean disableChatAction;
public static boolean sortByUnread;
public static boolean sortByUnmuted;
public static boolean sortByUser;
public static boolean sortByContacts;
public static boolean disableUndo;
public static boolean filterUsers;
public static boolean filterContacts;
public static boolean filterGroups;
public static boolean filterChannels;
public static boolean filterBots;
public static boolean filterAdmins;
public static boolean filterUnmuted;
public static boolean filterUnread;
public static boolean filterUnmutedAndUnread;
public static boolean ignoreMutedCount;
public static boolean disableSystemAccount;
public static boolean disableProxyWhenVpnEnabled;
public static boolean skipOpenLinkConfirm;
public static boolean removeTitleEmoji;
public static boolean useDefaultTheme;
public static boolean showIdAndDc;
public static String googleCloudTranslateKey;
public static String cachePath;
public static String translateToLang;
public static String translateInputLang;
2020-12-17 18:32:45 +01:00
public static String ccToLang;
public static String ccInputLang;
2021-01-03 07:43:35 +01:00
public static boolean increaseVoiceMessageQuality;
2020-12-17 18:32:45 +01:00
2020-06-25 17:25:17 +02:00
public static boolean hideProxyByDefault;
public static boolean useProxyItem;
public static boolean disableAppBarShadow;
public static boolean mediaPreview;
public static boolean proxyAutoSwitch;
2020-07-19 09:44:11 +02:00
public static String openPGPApp;
public static long openPGPKeyId;
2020-07-26 18:07:20 +02:00
public static boolean disableVibration;
2020-07-31 17:47:36 +02:00
public static boolean autoPauseVideo;
public static boolean disableProximityEvents;
2020-07-26 18:07:20 +02:00
2020-10-11 11:30:08 +02:00
public static boolean ignoreContentRestrictions;
public static boolean useChatAttachMediaMenu;
public static boolean disableLinkPreviewByDefault;
2020-11-10 17:51:53 +01:00
public static boolean sendCommentAfterForward;
2021-01-03 07:43:35 +01:00
public static boolean acceptSecretChat;
2020-10-11 11:30:08 +02:00
2020-07-19 09:44:11 +02:00
public static String getOpenPGPAppName() {
if (StrUtil.isNotBlank(openPGPApp)) {
try {
PackageManager manager = ApplicationLoader.applicationContext.getPackageManager();
ApplicationInfo info = manager.getApplicationInfo(openPGPApp, PackageManager.GET_META_DATA);
return (String) manager.getApplicationLabel(info);
} catch (PackageManager.NameNotFoundException e) {
openPGPApp = "";
}
}
2021-01-03 07:43:35 +01:00
return LocaleController.getString("None", R.string.None);
2020-07-19 09:44:11 +02:00
}
2020-06-25 17:25:17 +02:00
public static String formatLang(String name) {
if (name == null) {
return LocaleController.getString("Default", R.string.Default);
} else {
if (name.contains("-")) {
return new Locale(StrUtil.subBefore(name, "-", false), StrUtil.subAfter(name, "-", false)).getDisplayName(LocaleController.getInstance().currentLocale);
} else {
return new Locale(name).getDisplayName(LocaleController.getInstance().currentLocale);
2019-06-11 09:13:04 +02:00
}
2020-06-25 17:25:17 +02:00
2019-06-11 09:13:04 +02:00
}
2020-06-25 17:25:17 +02:00
2019-06-11 09:13:04 +02:00
}
2020-06-25 17:25:17 +02:00
static {
useIPv6 = preferences.getBoolean("useIPv6", false);
hidePhone = preferences.getBoolean("hidePhone", true);
ignoreBlocked = preferences.getBoolean("ignoreBlocked", false);
forceTablet = preferences.getBoolean("forceTablet", false);
typeface = preferences.getInt("typeface", 0);
nameOrder = preferences.getInt("nameOrder", 1);
mapPreviewProvider = preferences.getInt("mapPreviewProvider", 0);
transparentStatusBar = preferences.getBoolean("transparentStatusBar", false);
residentNotification = preferences.getBoolean("residentNotification", false);
hideProxySponsorChannel = preferences.getBoolean("hideProxySponsorChannel", false);
2020-10-27 05:58:08 +01:00
showAddToSavedMessages = preferences.getBoolean("showAddToSavedMessages", false);
2020-06-25 17:25:17 +02:00
showReport = preferences.getBoolean("showReport", false);
showViewHistory = preferences.getBoolean("showViewHistory", true);
showAdminActions = preferences.getBoolean("showAdminActions", true);
showChangePermissions = preferences.getBoolean("showChangePermissions", true);
showDeleteDownloadedFile = preferences.getBoolean("showDeleteDownloadedFile", true);
showMessageDetails = preferences.getBoolean("showMessageDetails", false);
showTranslate = preferences.getBoolean("showTranslate", true);
showRepeat = preferences.getBoolean("showRepeat", true);
eventType = preferences.getInt("eventType", 0);
actionBarDecoration = preferences.getInt("actionBarDecoration", 0);
newYear = preferences.getBoolean("newYear", false);
stickerSize = preferences.getFloat("stickerSize", 14.0f);
unlimitedFavedStickers = preferences.getBoolean("unlimitedFavedStickers", false);
unlimitedPinnedDialogs = preferences.getBoolean("unlimitedPinnedDialogs", false);
translationProvider = preferences.getInt("translationProvider", 1);
disablePhotoSideAction = preferences.getBoolean("disablePhotoSideAction", true);
openArchiveOnPull = preferences.getBoolean("openArchiveOnPull", false);
//showHiddenFeature = preferences.getBoolean("showHiddenFeature", false);
hideKeyboardOnChatScroll = preferences.getBoolean("hideKeyboardOnChatScroll", false);
avatarAsDrawerBackground = preferences.getBoolean("avatarAsDrawerBackground", true);
useSystemEmoji = preferences.getBoolean("useSystemEmoji", false);
showTabsOnForward = preferences.getBoolean("showTabsOnForward", false);
2020-06-25 17:25:17 +02:00
rearVideoMessages = preferences.getBoolean("rearVideoMessages", false);
hideAllTab = preferences.getBoolean("hideAllTab", false);
disableChatAction = preferences.getBoolean("disable_chat_action", false);
sortByUnread = preferences.getBoolean("sort_by_unread", false);
sortByUnmuted = preferences.getBoolean("sort_by_unmuted", true);
sortByUser = preferences.getBoolean("sort_by_user", true);
sortByContacts = preferences.getBoolean("sort_by_contacts", true);
disableUndo = preferences.getBoolean("disable_undo", false);
filterUsers = preferences.getBoolean("filter_users", true);
filterContacts = preferences.getBoolean("filter_contacts", true);
filterGroups = preferences.getBoolean("filter_groups", true);
filterChannels = preferences.getBoolean("filter_channels", true);
filterBots = preferences.getBoolean("filter_bots", true);
filterAdmins = preferences.getBoolean("filter_admins", true);
filterUnmuted = preferences.getBoolean("filter_unmuted", true);
filterUnread = preferences.getBoolean("filter_unread", true);
filterUnmutedAndUnread = preferences.getBoolean("filter_unmuted_and_unread", true);
disableSystemAccount = preferences.getBoolean("disable_system_account", false);
disableProxyWhenVpnEnabled = preferences.getBoolean("disable_proxy_when_vpn_enabled", false);
skipOpenLinkConfirm = preferences.getBoolean("skip_open_link_confirm", false);
removeTitleEmoji = preferences.getBoolean("remove_title_emoji", true);
ignoreMutedCount = preferences.getBoolean("ignore_muted_count", true);
useDefaultTheme = preferences.getBoolean("use_default_theme", false);
showIdAndDc = preferences.getBoolean("show_id_and_dc", false);
googleCloudTranslateKey = preferences.getString("google_cloud_translate_key", null);
cachePath = preferences.getString("cache_path", null);
translateToLang = preferences.getString("trans_to_lang", null);
translateInputLang = preferences.getString("trans_input_to_lang", "en");
2020-12-17 19:29:42 +01:00
ccToLang = preferences.getString("opencc_to_lang", null);
ccInputLang = preferences.getString("opencc_input_to_lang", null);
2020-12-17 18:32:45 +01:00
2020-06-25 17:25:17 +02:00
tabsTitleType = preferences.getInt("tabsTitleType", TITLE_TYPE_TEXT);
confirmAVMessage = preferences.getBoolean("confirmAVMessage", false);
askBeforeCall = preferences.getBoolean("askBeforeCall", false);
disableNumberRounding = preferences.getBoolean("disableNumberRounding", false);
2020-06-26 05:10:18 +02:00
hideProxyByDefault = preferences.getBoolean("hide_proxy_by_default", false);
useProxyItem = preferences.getBoolean("use_proxy_item", true);
2020-06-25 17:25:17 +02:00
disableAppBarShadow = preferences.getBoolean("disableAppBarShadow", false);
2020-07-26 10:57:33 +02:00
mediaPreview = preferences.getBoolean("mediaPreview", true);
2019-06-11 09:13:04 +02:00
proxyAutoSwitch = preferences.getBoolean("proxy_auto_switch", false);
2020-12-17 06:45:19 +01:00
//preferences.getBoolean("usePersianCalender", false);
2021-01-03 07:43:35 +01:00
openPGPApp = preferences.getString("openPGPApp", "");
openPGPKeyId = preferences.getLong("openPGPKeyId", 0L);
2020-07-26 18:07:20 +02:00
disableVibration = preferences.getBoolean("disableVibration", false);
2020-07-31 17:47:36 +02:00
autoPauseVideo = preferences.getBoolean("autoPauseVideo", false);
2020-10-18 06:28:53 +02:00
disableProximityEvents = preferences.getBoolean("disableProximityEvents", false);
2020-07-26 18:07:20 +02:00
2020-10-11 11:30:08 +02:00
ignoreContentRestrictions = preferences.getBoolean("ignoreContentRestrictions", false);
useChatAttachMediaMenu = preferences.getBoolean("useChatAttachMediaMenu", true);
disableLinkPreviewByDefault = preferences.getBoolean("disableLinkPreviewByDefault", false);
2020-11-10 17:51:53 +01:00
sendCommentAfterForward = preferences.getBoolean("sendCommentAfterForward", true);
increaseVoiceMessageQuality = preferences.getBoolean("increaseVoiceMessageQuality", true);
2021-01-03 07:43:35 +01:00
acceptSecretChat = preferences.getBoolean("acceptSecretChat", true);
2020-10-11 11:30:08 +02:00
2019-06-11 09:13:04 +02:00
}
2019-12-07 07:35:27 +01:00
public static void toggleShowAddToSavedMessages() {
showAddToSavedMessages = !showAddToSavedMessages;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("showAddToSavedMessages", showAddToSavedMessages);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-12-07 07:35:27 +01:00
}
public static void toggleShowReport() {
showReport = !showReport;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("showReport", showReport);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-12-07 07:35:27 +01:00
}
2020-01-11 04:50:05 +01:00
public static void toggleShowViewHistory() {
showViewHistory = !showViewHistory;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("showViewHistory", showViewHistory);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-12-07 07:35:27 +01:00
}
public static void toggleShowAdminActions() {
showAdminActions = !showAdminActions;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("showAdminActions", showAdminActions);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-12-07 07:35:27 +01:00
}
public static void toggleShowChangePermissions() {
showChangePermissions = !showChangePermissions;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("showChangePermissions", showChangePermissions);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-12-07 07:35:27 +01:00
}
2020-01-10 10:13:03 +01:00
public static void toggleShowDeleteDownloadedFile() {
showDeleteDownloadedFile = !showDeleteDownloadedFile;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("showDeleteDownloadedFile", showDeleteDownloadedFile);
2020-06-25 17:25:17 +02:00
editor.apply();
2020-01-10 10:13:03 +01:00
}
2020-01-18 12:57:04 +01:00
public static void toggleShowMessageDetails() {
showMessageDetails = !showMessageDetails;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("showMessageDetails", showMessageDetails);
2020-06-25 17:25:17 +02:00
editor.apply();
2020-01-18 12:57:04 +01:00
}
2019-12-07 07:35:27 +01:00
public static void toggleShowRepeat() {
showRepeat = !showRepeat;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("showRepeat", showRepeat);
2020-06-25 17:25:17 +02:00
editor.apply();
}
2019-06-11 09:13:04 +02:00
public static void toggleIPv6() {
useIPv6 = !useIPv6;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("useIPv6", useIPv6);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-06-11 09:13:04 +02:00
}
public static void toggleHidePhone() {
hidePhone = !hidePhone;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("hidePhone", hidePhone);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-06-11 09:13:04 +02:00
}
public static void toggleIgnoreBlocked() {
ignoreBlocked = !ignoreBlocked;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("ignoreBlocked", ignoreBlocked);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-06-11 09:13:04 +02:00
}
public static void toggleForceTablet() {
forceTablet = !forceTablet;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("forceTablet", forceTablet);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-06-11 09:13:04 +02:00
}
2019-12-30 06:43:49 +01:00
public static void toggleTypeface() {
2019-12-14 05:19:38 +01:00
typeface = typeface == 0 ? 1 : 0;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("typeface", typeface);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-12-14 05:19:38 +01:00
}
2019-06-11 09:13:04 +02:00
public static void setNameOrder(int order) {
nameOrder = order;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("nameOrder", nameOrder);
2020-06-25 17:25:17 +02:00
editor.apply();
LocaleController.getInstance().recreateFormatters();
2019-06-11 09:13:04 +02:00
}
2019-12-17 09:06:28 +01:00
public static void setMapPreviewProvider(int provider) {
mapPreviewProvider = provider;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("mapPreviewProvider", mapPreviewProvider);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-12-17 09:06:28 +01:00
}
2019-07-07 07:31:28 +02:00
public static void toggleTransparentStatusBar() {
transparentStatusBar = !transparentStatusBar;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("transparentStatusBar", transparentStatusBar);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-07-07 07:31:28 +02:00
}
2019-07-29 17:22:59 +02:00
public static void toggleResidentNotification() {
residentNotification = !residentNotification;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("residentNotification", residentNotification);
2020-06-25 17:25:17 +02:00
editor.apply();
2020-02-25 10:04:26 +01:00
ApplicationLoader.applicationContext.stopService(new Intent(ApplicationLoader.applicationContext, NotificationsService.class));
ApplicationLoader.startPushService();
2019-07-29 17:22:59 +02:00
}
2020-01-11 04:03:24 +01:00
public static void toggleHideProxySponsorChannel() {
hideProxySponsorChannel = !hideProxySponsorChannel;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("hideProxySponsorChannel", hideProxySponsorChannel);
2020-06-25 17:25:17 +02:00
editor.apply();
}
2020-02-16 05:30:15 +01:00
public static void setActionBarDecoration(int decoration) {
actionBarDecoration = decoration;
2019-12-30 06:43:49 +01:00
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
2020-02-16 05:30:15 +01:00
editor.putInt("actionBarDecoration", actionBarDecoration);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-12-30 06:43:49 +01:00
}
2020-02-16 05:30:15 +01:00
public static void toggleNewYear() {
newYear = !newYear;
2019-12-30 14:00:42 +01:00
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
2020-02-16 05:30:15 +01:00
editor.putBoolean("newYear", newYear);
2020-06-25 17:25:17 +02:00
editor.apply();
2019-12-30 14:00:42 +01:00
}
2020-01-18 07:35:06 +01:00
public static void toggleUnlimitedFavedStickers() {
unlimitedFavedStickers = !unlimitedFavedStickers;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("unlimitedFavedStickers", unlimitedFavedStickers);
2020-06-25 17:25:17 +02:00
editor.apply();
2020-01-18 07:35:06 +01:00
}
public static void toggleUnlimitedPinnedDialogs() {
unlimitedPinnedDialogs = !unlimitedPinnedDialogs;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("unlimitedPinnedDialogs", unlimitedPinnedDialogs);
2020-06-25 17:25:17 +02:00
editor.apply();
}
2020-01-29 10:02:51 +01:00
public static void toggleShowTranslate() {
showTranslate = !showTranslate;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("showTranslate", showTranslate);
2020-06-25 17:25:17 +02:00
editor.apply();
2020-01-29 10:02:51 +01:00
}
2020-01-16 17:10:29 +01:00
public static void setStickerSize(float size) {
stickerSize = size;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putFloat("stickerSize", stickerSize);
2020-06-25 17:25:17 +02:00
editor.apply();
2020-01-16 17:10:29 +01:00
}
2020-02-11 06:26:46 +01:00
public static void setTranslationProvider(int provider) {
translationProvider = provider;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("translationProvider", translationProvider);
2020-06-25 17:25:17 +02:00
editor.apply();
2020-02-11 06:26:46 +01:00
}
2020-02-17 15:02:50 +01:00
public static void toggleDisablePhotoSideAction() {
disablePhotoSideAction = !disablePhotoSideAction;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("disablePhotoSideAction", disablePhotoSideAction);
2020-06-25 17:25:17 +02:00
editor.apply();
2020-02-17 15:02:50 +01:00
}
2020-02-20 13:35:34 +01:00
public static void toggleOpenArchiveOnPull() {
openArchiveOnPull = !openArchiveOnPull;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("openArchiveOnPull", openArchiveOnPull);
2020-06-25 17:25:17 +02:00
editor.apply();
2020-02-20 13:35:34 +01:00
}
2020-03-01 16:09:48 +01:00
public static void toggleHideKeyboardOnChatScroll() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("hideKeyboardOnChatScroll", hideKeyboardOnChatScroll = !hideKeyboardOnChatScroll).apply();
2020-03-01 16:09:48 +01:00
}
2020-03-26 10:02:35 +01:00
public static void toggleAvatarAsDrawerBackground() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("avatarAsDrawerBackground", avatarAsDrawerBackground = !avatarAsDrawerBackground).apply();
2020-03-26 10:02:35 +01:00
}
2020-03-30 06:23:34 +02:00
public static void toggleUseSystemEmoji() {
2020-06-25 17:25:17 +02:00
preferences.edit().putBoolean("useSystemEmoji", useSystemEmoji = !useSystemEmoji).apply();
}
public static void toggleDisableChatAction() {
preferences.edit().putBoolean("disable_chat_action", disableChatAction = !disableChatAction).apply();
}
public static void toggleSortByUnread() {
preferences.edit().putBoolean("sort_by_unread", sortByUnread = !sortByUnread).apply();
2020-03-30 06:23:34 +02:00
}
2020-04-08 10:16:23 +02:00
public static void toggleShowTabsOnForward() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("showTabsOnForward", showTabsOnForward = !showTabsOnForward).apply();
2020-04-08 10:16:23 +02:00
}
2020-04-17 04:13:43 +02:00
public static void toggleRearVideoMessages() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("rearVideoMessages", rearVideoMessages = !rearVideoMessages).apply();
}
2020-04-17 05:27:50 +02:00
public static void toggleHideAllTab() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("hideAllTab", hideAllTab = !hideAllTab).apply();
2020-06-25 17:25:17 +02:00
}
public static void toggleSortByUnmuted() {
preferences.edit().putBoolean("sort_by_unmuted", sortByUnmuted = !sortByUnmuted).apply();
}
public static void toggleSortByUser() {
preferences.edit().putBoolean("sort_by_user", sortByUser = !sortByUser).apply();
}
public static void toggleSortByContacts() {
preferences.edit().putBoolean("sort_by_contacts", sortByContacts = !sortByContacts).apply();
}
public static void toggleDisableUndo() {
preferences.edit().putBoolean("disable_undo", disableUndo = !disableUndo).apply();
}
public static void toggleFilterUsers() {
preferences.edit().putBoolean("filter_users", filterUsers = !filterUsers).apply();
}
public static void toggleFilterContacts() {
preferences.edit().putBoolean("filter_contacts", filterContacts = !filterContacts).apply();
}
public static void toggleFilterGroups() {
preferences.edit().putBoolean("filterGroups", filterGroups = !filterGroups).apply();
}
public static void toggleFilterChannels() {
preferences.edit().putBoolean("filter_channels", filterChannels = !filterChannels).apply();
}
public static void toggleFilterBots() {
preferences.edit().putBoolean("filter_bots", filterBots = !filterBots).apply();
}
public static void toggleFilterAdmins() {
preferences.edit().putBoolean("filter_admins", filterAdmins = !filterAdmins).apply();
}
public static void toggleFilterUnmuted() {
preferences.edit().putBoolean("filter_unmuted", filterUnmuted = !filterUnmuted).apply();
}
public static void toggleDisableFilterUnread() {
preferences.edit().putBoolean("filter_unread", filterUnread = !filterUnread).apply();
}
public static void toggleFilterUnmutedAndUnread() {
preferences.edit().putBoolean("filter_unmuted_and_unread", filterUnmutedAndUnread = !filterUnmutedAndUnread).apply();
}
public static void toggleDisableSystemAccount() {
preferences.edit().putBoolean("disable_system_account", disableSystemAccount = !disableSystemAccount).apply();
}
public static void toggleDisableProxyWhenVpnEnabled() {
preferences.edit().putBoolean("disable_proxy_when_vpn_enabled", disableProxyWhenVpnEnabled = !disableProxyWhenVpnEnabled).apply();
}
public static void toggleSkipOpenLinkConfirm() {
preferences.edit().putBoolean("skip_open_link_confirm", skipOpenLinkConfirm = !skipOpenLinkConfirm).apply();
}
public static void toggleRemoveTitleEmoji() {
preferences.edit().putBoolean("remove_title_emoji", removeTitleEmoji = !removeTitleEmoji).apply();
}
public static void toggleIgnoredMutedCount() {
preferences.edit().putBoolean("ignore_muted_count", ignoreMutedCount = !ignoreMutedCount).apply();
}
public static void toggleUseDefaultTheme() {
preferences.edit().putBoolean("use_default_theme", useDefaultTheme = !useDefaultTheme).apply();
}
public static void toggleShowIdAndDc() {
preferences.edit().putBoolean("show_id_and_dc", showIdAndDc = !showIdAndDc).apply();
}
public static void setGoogleTranslateKey(String key) {
preferences.edit().putString("google_cloud_translate_key", googleCloudTranslateKey = key).apply();
}
public static void setCachePath(String cachePath) {
preferences.edit().putString("cache_path", NekoConfig.cachePath = cachePath).apply();
}
public static void setTranslateToLang(String toLang) {
preferences.edit().putString("trans_to_lang", translateToLang = toLang).apply();
}
public static void setTranslateInputToLang(String toLang) {
preferences.edit().putString("trans_input_to_lang", translateInputLang = toLang).apply();
2020-04-17 05:27:50 +02:00
}
2020-04-26 08:50:44 +02:00
public static void setTabsTitleType(int type) {
2020-06-25 17:25:17 +02:00
preferences.edit().putInt("tabsTitleType", tabsTitleType = type).apply();
2020-04-26 08:50:44 +02:00
}
public static void toggleConfirmAVMessage() {
2020-06-25 17:25:17 +02:00
preferences.edit().putBoolean("confirmAVMessage", confirmAVMessage = !confirmAVMessage).apply();
}
2020-05-07 08:11:40 +02:00
public static void toggleAskBeforeCall() {
2020-06-25 17:25:17 +02:00
preferences.edit().putBoolean("askBeforeCall", askBeforeCall = !askBeforeCall).apply();
2020-05-07 08:11:40 +02:00
}
2020-05-12 13:35:15 +02:00
2020-06-25 17:25:17 +02:00
public static void toggleHideProxyByDefault() {
preferences.edit().putBoolean("hide_proxy_by_default", hideProxyByDefault = !hideProxyByDefault).apply();
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxySettingsChanged);
}
public static void toggleUseProxyItem() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("use_proxy_item", useProxyItem = !useProxyItem).apply();
2020-06-25 17:25:17 +02:00
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxySettingsChanged);
2020-05-12 13:35:15 +02:00
}
public static void toggleDisableNumberRounding() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("disableNumberRounding", disableNumberRounding = !disableNumberRounding).apply();
}
2020-05-30 12:36:45 +02:00
public static void toggleDisableAppBarShadow() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("disableAppBarShadow", disableAppBarShadow = !disableAppBarShadow).apply();
2020-05-30 12:36:45 +02:00
}
public static void toggleMediaPreview() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("mediaPreview", mediaPreview = !mediaPreview).apply();
}
public static void toggleProxyAutoSwitch() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("proxy_auto_switch", proxyAutoSwitch = !proxyAutoSwitch).apply();
}
2020-07-19 09:44:11 +02:00
public static void setOpenPGPApp(String packageName) {
2021-01-03 07:43:35 +01:00
preferences.edit().putString("openPGPApp", openPGPApp = packageName).apply();
2020-07-19 09:44:11 +02:00
}
public static void setOpenPGPKeyId(long keyId) {
2021-01-03 07:43:35 +01:00
preferences.edit().putLong("openPGPKeyId", openPGPKeyId = keyId).apply();
2020-07-19 09:44:11 +02:00
}
2020-07-26 18:07:20 +02:00
public static void toggleDisableVibration() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("disableVibration", disableVibration = !disableVibration).apply();
2020-07-26 18:07:20 +02:00
}
2020-07-19 02:22:26 +02:00
2020-07-31 17:47:36 +02:00
public static void toggleAutoPauseVideo() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("autoPauseVideo", autoPauseVideo = !autoPauseVideo).apply();
2020-07-31 17:47:36 +02:00
}
public static void toggleDisableProximityEvents() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("disableProximityEvents", disableProximityEvents = !disableProximityEvents).apply();
2020-07-31 17:47:36 +02:00
}
2020-10-11 11:30:08 +02:00
public static void toggleIgnoreContentRestrictions() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("ignoreContentRestrictions", ignoreContentRestrictions = !ignoreContentRestrictions).apply();
2020-10-11 11:30:08 +02:00
}
public static void toggleUseChatAttachMediaMenu() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("useChatAttachMediaMenu", useChatAttachMediaMenu = !useChatAttachMediaMenu).apply();
}
public static void toggleDisableLinkPreviewByDefault() {
2020-12-17 18:32:45 +01:00
preferences.edit().putBoolean("disableLinkPreviewByDefault", disableLinkPreviewByDefault = !disableLinkPreviewByDefault).apply();
}
2020-11-10 17:51:53 +01:00
public static void toggleSendCommentAfterForward() {
2020-12-17 18:32:45 +01:00
preferences.edit().putBoolean("sendCommentAfterForward", sendCommentAfterForward = !sendCommentAfterForward).apply();
}
public static void setCCToLang(String toLang) {
preferences.edit().putString("opencc_to_lang", ccToLang = toLang).apply();
2020-11-10 17:51:53 +01:00
}
2020-12-17 18:32:45 +01:00
public static void setCCInputToLang(String toLang) {
preferences.edit().putString("opencc_input_to_lang", ccInputLang = toLang).apply();
}
public static void toggleIncreaseVoiceMessageQuality() {
2021-01-03 07:43:35 +01:00
preferences.edit().putBoolean("increaseVoiceMessageQuality", increaseVoiceMessageQuality = !increaseVoiceMessageQuality).apply();
}
public static void toggleAcceptSecretChat() {
preferences.edit().putBoolean("acceptSecretChat", acceptSecretChat = !acceptSecretChat).apply();
}
2020-12-17 18:32:45 +01:00
2020-06-25 17:25:17 +02:00
}