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;
|
2021-04-11 02:53:15 +02:00
|
|
|
import android.content.res.Configuration;
|
2021-01-08 10:09:16 +01:00
|
|
|
import android.graphics.Typeface;
|
2019-06-11 09:13:04 +02:00
|
|
|
|
2021-04-11 02:53:15 +02:00
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
2019-06-11 09:13:04 +02:00
|
|
|
import org.telegram.messenger.ApplicationLoader;
|
2021-04-19 14:25:33 +02:00
|
|
|
import org.telegram.messenger.BuildVars;
|
2021-01-08 10:09:16 +01:00
|
|
|
import org.telegram.messenger.FileLog;
|
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;
|
2021-04-11 02:53:15 +02:00
|
|
|
import org.telegram.ui.ActionBar.Theme;
|
2020-06-25 17:25:17 +02:00
|
|
|
|
2021-01-08 10:09:16 +01:00
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.FileReader;
|
2021-01-11 12:22:07 +01:00
|
|
|
import java.util.Locale;
|
2021-01-08 10:09:16 +01:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
2019-06-11 09:13:04 +02:00
|
|
|
|
2021-01-11 12:22:07 +01:00
|
|
|
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;
|
2021-04-23 18:40:35 +02:00
|
|
|
public static boolean pressTitleToOpenAllChats;
|
2020-06-25 17:25:17 +02:00
|
|
|
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;
|
2021-04-13 06:51:17 +02:00
|
|
|
public static boolean showMessageHide;
|
2020-06-25 17:25:17 +02:00
|
|
|
|
|
|
|
public static boolean hidePhone;
|
|
|
|
public static int typeface;
|
|
|
|
public static boolean transparentStatusBar;
|
2021-01-11 12:22:07 +01:00
|
|
|
public static int tabletMode;
|
2020-06-25 17:25:17 +02:00
|
|
|
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 useDefaultTheme;
|
|
|
|
public static boolean showIdAndDc;
|
|
|
|
|
|
|
|
public static String googleCloudTranslateKey;
|
|
|
|
|
|
|
|
public static String cachePath;
|
2021-01-08 10:09:16 +01:00
|
|
|
private static Typeface systemEmojiTypeface;
|
|
|
|
public static boolean loadSystemEmojiFailed = false;
|
2020-06-25 17:25:17 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2021-08-19 21:10:27 +02:00
|
|
|
public static boolean useSystemDNS;
|
|
|
|
public static String customDoH;
|
2020-06-25 17:25:17 +02:00
|
|
|
public static boolean hideProxyByDefault;
|
|
|
|
public static boolean useProxyItem;
|
|
|
|
|
|
|
|
public static boolean disableAppBarShadow;
|
|
|
|
public static boolean mediaPreview;
|
|
|
|
|
2020-06-27 07:36:00 +02:00
|
|
|
public static boolean proxyAutoSwitch;
|
2021-04-01 04:06:54 +02:00
|
|
|
|
|
|
|
public static int usePersianCalendar;
|
2021-04-02 07:56:28 +02:00
|
|
|
public static boolean displayPersianCalendarByLatin;
|
2020-06-27 07:36:00 +02:00
|
|
|
|
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;
|
2020-11-07 15:07:19 +01:00
|
|
|
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
|
|
|
|
2021-01-12 03:37:29 +01:00
|
|
|
public static boolean avatarBackgroundBlur;
|
|
|
|
public static boolean avatarBackgroundDarken;
|
2021-02-04 18:59:00 +01:00
|
|
|
public static boolean disableTrending;
|
2021-06-02 19:50:35 +02:00
|
|
|
public static boolean dontSendGreetingSticker;
|
2021-07-16 07:57:39 +02:00
|
|
|
public static boolean hideTimeForSticker;
|
2021-06-02 19:50:35 +02:00
|
|
|
public static boolean takeGIFasVideo;
|
2021-08-28 16:05:34 +02:00
|
|
|
public static int maxRecentStickerCount;
|
2021-09-02 04:53:37 +02:00
|
|
|
public static boolean disableSwipeToNext;
|
2021-09-20 15:30:57 +02:00
|
|
|
public static boolean disableRemoteEmojiInteractions;
|
|
|
|
public static boolean disableChoosingSticker;
|
2021-01-12 03:37:29 +01:00
|
|
|
|
2021-03-09 11:32:48 +01:00
|
|
|
public static boolean disableAutoDownloadingWin32Executable;
|
|
|
|
public static boolean disableAutoDownloadingArchive;
|
|
|
|
|
2021-06-27 15:32:12 +02:00
|
|
|
public static boolean enableStickerPin;
|
|
|
|
public static boolean useMediaStreamInVoip;
|
2021-08-20 22:23:27 +02:00
|
|
|
public static short customAudioBitrate = 320;
|
|
|
|
public static boolean disableGroupVoipAudioProcessing = false;
|
2021-06-02 12:05:07 +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);
|
2021-01-11 12:22:07 +01:00
|
|
|
|
|
|
|
boolean forceTablet = preferences.getBoolean("forceTablet", false);
|
|
|
|
if (forceTablet) {
|
|
|
|
tabletMode = 1;
|
|
|
|
preferences.edit()
|
|
|
|
.remove("forceTablet")
|
|
|
|
.putInt("tabletMode", 1)
|
|
|
|
.apply();
|
|
|
|
} else {
|
|
|
|
tabletMode = preferences.getInt("tabletMode", 0);
|
|
|
|
}
|
|
|
|
|
2020-06-25 17:25:17 +02:00
|
|
|
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);
|
2021-02-07 15:41:06 +01:00
|
|
|
showAddToSavedMessages = preferences.getBoolean("showAddToSavedMessages", true);
|
|
|
|
showReport = preferences.getBoolean("showReport", true);
|
2020-06-25 17:25:17 +02:00
|
|
|
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);
|
2021-02-07 15:41:06 +01:00
|
|
|
showRepeat = preferences.getBoolean("showRepeat", false);
|
2021-04-13 06:51:17 +02:00
|
|
|
showMessageHide = preferences.getBoolean("showMessageHide", false);
|
|
|
|
|
2020-06-25 17:25:17 +02:00
|
|
|
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);
|
2021-01-12 03:37:29 +01:00
|
|
|
avatarBackgroundBlur = preferences.getBoolean("avatarBackgroundBlur", false);
|
2021-03-09 11:32:48 +01:00
|
|
|
avatarBackgroundDarken = preferences.getBoolean("avatarBackgroundDarken", false);
|
|
|
|
useSystemEmoji = preferences.getBoolean("useSystemEmoji", false);
|
2020-06-26 10:48:53 +02:00
|
|
|
showTabsOnForward = preferences.getBoolean("showTabsOnForward", false);
|
2020-06-25 17:25:17 +02:00
|
|
|
rearVideoMessages = preferences.getBoolean("rearVideoMessages", false);
|
|
|
|
hideAllTab = preferences.getBoolean("hideAllTab", false);
|
2021-04-23 18:40:35 +02:00
|
|
|
pressTitleToOpenAllChats = preferences.getBoolean("pressTitleToOpenAllChats", false);
|
2020-06-25 17:25:17 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2021-08-19 21:10:27 +02:00
|
|
|
useSystemDNS = preferences.getBoolean("useSystemDNS", false);
|
|
|
|
customDoH = preferences.getString("customDoH", "");
|
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
|
|
|
|
2020-06-27 07:36:00 +02:00
|
|
|
proxyAutoSwitch = preferences.getBoolean("proxy_auto_switch", false);
|
2021-04-01 04:06:54 +02:00
|
|
|
|
|
|
|
usePersianCalendar = preferences.getInt("persian_calendar", 0);
|
2021-04-02 16:25:34 +02:00
|
|
|
displayPersianCalendarByLatin = preferences.getBoolean("displayPersianCalendarByLatin", false);
|
2021-01-03 07:43:35 +01:00
|
|
|
openPGPApp = preferences.getString("openPGPApp", "");
|
|
|
|
openPGPKeyId = preferences.getLong("openPGPKeyId", 0L);
|
2020-06-27 07:36:00 +02:00
|
|
|
|
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
|
|
|
|
2021-04-19 14:25:33 +02:00
|
|
|
ignoreContentRestrictions = preferences.getBoolean("ignoreContentRestrictions", !BuildVars.isPlay);
|
2020-11-07 15:07:19 +01:00
|
|
|
useChatAttachMediaMenu = preferences.getBoolean("useChatAttachMediaMenu", true);
|
|
|
|
disableLinkPreviewByDefault = preferences.getBoolean("disableLinkPreviewByDefault", false);
|
2020-11-10 17:51:53 +01:00
|
|
|
sendCommentAfterForward = preferences.getBoolean("sendCommentAfterForward", true);
|
2020-08-02 05:33:21 +02:00
|
|
|
increaseVoiceMessageQuality = preferences.getBoolean("increaseVoiceMessageQuality", true);
|
2021-01-03 07:43:35 +01:00
|
|
|
acceptSecretChat = preferences.getBoolean("acceptSecretChat", true);
|
2021-02-04 18:59:00 +01:00
|
|
|
disableTrending = preferences.getBoolean("disableTrending", true);
|
2021-06-02 19:50:35 +02:00
|
|
|
dontSendGreetingSticker = preferences.getBoolean("dontSendGreetingSticker", false);
|
2021-07-16 07:57:39 +02:00
|
|
|
hideTimeForSticker = preferences.getBoolean("hideTimeForSticker", false);
|
2021-06-02 19:50:35 +02:00
|
|
|
takeGIFasVideo = preferences.getBoolean("takeGIFasVideo", false);
|
2021-08-28 16:05:34 +02:00
|
|
|
maxRecentStickerCount = preferences.getInt("maxRecentStickerCount", 20);
|
2021-09-20 15:31:40 +02:00
|
|
|
disableSwipeToNext = preferences.getBoolean("disableSwipeToNext", true);
|
|
|
|
disableRemoteEmojiInteractions = preferences.getBoolean("disableRemoteEmojiInteractions", true);
|
2021-09-20 15:30:57 +02:00
|
|
|
disableChoosingSticker = preferences.getBoolean("disableChoosingSticker", false);
|
2020-10-11 11:30:08 +02:00
|
|
|
|
2021-03-09 11:32:48 +01:00
|
|
|
disableAutoDownloadingWin32Executable = preferences.getBoolean("disableAutoDownloadingWin32Executable", true);
|
|
|
|
disableAutoDownloadingArchive = preferences.getBoolean("disableAutoDownloadingArchive", true);
|
|
|
|
|
2021-06-27 15:32:12 +02:00
|
|
|
enableStickerPin = preferences.getBoolean("enableStickerPin", false);
|
|
|
|
useMediaStreamInVoip = preferences.getBoolean("useMediaStreamInVoip", false);
|
2021-08-20 22:23:27 +02:00
|
|
|
customAudioBitrate = (short) preferences.getInt("customAudioBitrate", 32);
|
|
|
|
disableGroupVoipAudioProcessing = preferences.getBoolean("disableGroupVoipAudioProcessing", false);
|
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
|
|
|
}
|
|
|
|
|
2021-09-20 15:30:57 +02:00
|
|
|
|
2021-01-08 10:09:16 +01:00
|
|
|
private static final String EMOJI_FONT_AOSP = "NotoColorEmoji.ttf";
|
|
|
|
|
|
|
|
public static Typeface getSystemEmojiTypeface() {
|
|
|
|
if (!loadSystemEmojiFailed && systemEmojiTypeface == null) {
|
|
|
|
try {
|
|
|
|
Pattern p = Pattern.compile(">(.*emoji.*)</font>", Pattern.CASE_INSENSITIVE);
|
|
|
|
BufferedReader br = new BufferedReader(new FileReader("/system/etc/fonts.xml"));
|
|
|
|
String line;
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
Matcher m = p.matcher(line);
|
|
|
|
if (m.find()) {
|
|
|
|
systemEmojiTypeface = Typeface.createFromFile("/system/fonts/" + m.group(1));
|
|
|
|
FileLog.d("emoji font file fonts.xml = " + m.group(1));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
br.close();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e(e);
|
|
|
|
}
|
|
|
|
if (systemEmojiTypeface == null) {
|
|
|
|
try {
|
|
|
|
systemEmojiTypeface = Typeface.createFromFile("/system/fonts/" + EMOJI_FONT_AOSP);
|
|
|
|
FileLog.d("emoji font file = " + EMOJI_FONT_AOSP);
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e(e);
|
|
|
|
loadSystemEmojiFailed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return systemEmojiTypeface;
|
|
|
|
}
|
|
|
|
|
2021-04-11 02:53:15 +02:00
|
|
|
public static int getNotificationColor() {
|
|
|
|
int color = 0;
|
|
|
|
Configuration configuration = ApplicationLoader.applicationContext.getResources().getConfiguration();
|
|
|
|
boolean isDark = (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
|
|
|
|
if (isDark) {
|
|
|
|
color = 0xffffffff;
|
|
|
|
} else {
|
|
|
|
if (Theme.getActiveTheme().hasAccentColors()) {
|
|
|
|
color = Theme.getActiveTheme().getAccentColor(Theme.getActiveTheme().currentAccentId);
|
|
|
|
}
|
|
|
|
if (Theme.getActiveTheme().isDark() || color == 0) {
|
|
|
|
color = Theme.getColor(Theme.key_actionBarDefault);
|
|
|
|
}
|
|
|
|
// too bright
|
|
|
|
if (AndroidUtilities.computePerceivedBrightness(color) >= 0.721f) {
|
|
|
|
color = Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader) | 0xff000000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2020-06-25 17:25:17 +02:00
|
|
|
}
|