| 1 | package tw.nekomimi.nekogram; |
| 2 | |
| 3 | import android.annotation.SuppressLint; |
| 4 | import android.app.Activity; |
| 5 | import android.content.Context; |
| 6 | import android.content.SharedPreferences; |
| 7 | |
| 8 | import org.telegram.messenger.ApplicationLoader; |
| 9 | import org.telegram.messenger.BuildVars; |
| 10 | |
| 11 | import java.io.ByteArrayInputStream; |
| 12 | import java.io.ObjectInputStream; |
| 13 | import java.util.ArrayList; |
| 14 | import android.util.Base64; |
| 15 | |
| 16 | import java.util.HashMap; |
| 17 | import java.util.HashSet; |
| 18 | import java.util.Set; |
| 19 | |
| 20 | import tw.nekomimi.nekogram.config.ConfigItem; |
| 21 | import tw.nekomimi.nekogram.helpers.CloudSettingsHelper; |
| 22 | |
| 23 | import static tw.nekomimi.nekogram.config.ConfigItem.*; |
| 24 | |
| 25 | @SuppressLint("ApplySharedPref") |
| 26 | public class NekoConfig { |
| 27 | |
| 28 | public static final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nkmrcfg", Context.MODE_PRIVATE); |
| 29 | public static final Object sync = new Object(); |
| 30 | public static final String channelAliasPrefix = "channelAliasPrefix_"; |
| 31 | |
| 32 | private static boolean configLoaded = false; |
| 33 | private static final ArrayList<ConfigItem> configs = new ArrayList<>(); |
| 34 | public static final ArrayList<DatacenterInfo> datacenterInfos = new ArrayList<>(5); |
| 35 | |
| 36 | // Configs |
| 37 | public static ConfigItem migrate = addConfig("NekoConfigMigrate", configTypeBool, false); |
| 38 | public static ConfigItem largeAvatarInDrawer = addConfig("AvatarAsBackground", configTypeInt, 0); // 0:TG Default 1:NekoX Default 2:Large Avatar |
| 39 | public static ConfigItem unreadBadgeOnBackButton = addConfig("unreadBadgeOnBackButton", configTypeBool, false); |
| 40 | // public static ConfigItem customPublicProxyIP = addConfig("customPublicProxyIP", configTypeString, ""); |
| 41 | public static ConfigItem update_download_soucre = addConfig("update_download_soucre", configTypeInt, 0); // 0: Github 1: Channel 2:CDNDrive, removed |
| 42 | public static ConfigItem useCustomEmoji = addConfig("useCustomEmoji", configTypeBool, false); |
| 43 | public static ConfigItem repeatConfirm = addConfig("repeatConfirm", configTypeBool, false); |
| 44 | public static ConfigItem disableInstantCamera = addConfig("DisableInstantCamera", configTypeBool, false); |
| 45 | public static ConfigItem showSeconds = addConfig("showSeconds", configTypeBool, false); |
| 46 | |
| 47 | public static ConfigItem enablePublicProxy = addConfig("enablePublicProxy", configTypeBool, true); |
| 48 | public static ConfigItem autoUpdateSubInfo = addConfig("autoUpdateSubInfo", configTypeBool, true); |
| 49 | public static ConfigItem lastUpdateCheckTime = addConfig("lastUpdateCheckTime", configTypeLong, 0L); |
| 50 | |
| 51 | // From NekoConfig |
| 52 | public static ConfigItem useIPv6 = addConfig("IPv6", configTypeBool, false); |
| 53 | public static ConfigItem hidePhone = addConfig("HidePhone", configTypeBool, true); |
| 54 | public static ConfigItem ignoreBlocked = addConfig("IgnoreBlocked", configTypeBool, false); |
| 55 | public static ConfigItem tabletMode = addConfig("TabletMode", configTypeInt, 0); |
| 56 | public static ConfigItem inappCamera = addConfig("DebugMenuEnableCamera", configTypeBool, true); // fake |
| 57 | public static ConfigItem smoothKeyboard = addConfig("DebugMenuEnableSmoothKeyboard", configTypeBool, false);// fake |
| 58 | |
| 59 | public static ConfigItem typeface = addConfig("TypefaceUseDefault", configTypeBool, false); |
| 60 | public static ConfigItem nameOrder = addConfig("NameOrder", configTypeInt, 1); |
| 61 | public static ConfigItem mapPreviewProvider = addConfig("MapPreviewProvider", configTypeInt, 0); |
| 62 | public static ConfigItem transparentStatusBar = addConfig("TransparentStatusBar", configTypeBool, true); |
| 63 | public static ConfigItem forceBlurInChat = addConfig("forceBlurInChat", configTypeBool, false); |
| 64 | public static ConfigItem chatBlueAlphaValue = addConfig("forceBlurInChatAlphaValue", configTypeInt, 127); |
| 65 | public static ConfigItem hideProxySponsorChannel = addConfig("HideProxySponsorChannel", configTypeBool, false); |
| 66 | public static ConfigItem showAddToSavedMessages = addConfig("showAddToSavedMessages", configTypeBool, true); |
| 67 | public static ConfigItem showReport = addConfig("showReport", configTypeBool, true); |
| 68 | public static ConfigItem showViewHistory = addConfig("showViewHistory", configTypeBool, true); |
| 69 | public static ConfigItem showAdminActions = addConfig("showAdminActions", configTypeBool, true); |
| 70 | public static ConfigItem showChangePermissions = addConfig("showChangePermissions", configTypeBool, true); |
| 71 | public static ConfigItem showDeleteDownloadedFile = addConfig("showDeleteDownloadedFile", configTypeBool, true); |
| 72 | public static ConfigItem showMessageDetails = addConfig("showMessageDetails", configTypeBool, false); |
| 73 | public static ConfigItem showTranslate = addConfig("showTranslate", configTypeBool, true); |
| 74 | public static ConfigItem showRepeat = addConfig("showRepeat", configTypeBool, false); |
| 75 | public static ConfigItem showShareMessages = addConfig("showShareMessages", configTypeBool, false); |
| 76 | public static ConfigItem showMessageHide = addConfig("showMessageHide", configTypeBool, false); |
| 77 | |
| 78 | public static ConfigItem eventType = addConfig("eventType", configTypeInt, 0); |
| 79 | public static ConfigItem actionBarDecoration = addConfig("ActionBarDecoration", configTypeInt, 0); |
| 80 | public static ConfigItem newYear = addConfig("ChristmasHat", configTypeBool, false); |
| 81 | public static ConfigItem stickerSize = addConfig("stickerSize", configTypeFloat, 14.0f); |
| 82 | public static ConfigItem unlimitedFavedStickers = addConfig("UnlimitedFavoredStickers", configTypeBool, false); |
| 83 | public static ConfigItem unlimitedPinnedDialogs = addConfig("UnlimitedPinnedDialogs", configTypeBool, false); |
| 84 | public static ConfigItem disablePhotoSideAction = addConfig("DisablePhotoViewerSideAction", configTypeBool, false); |
| 85 | public static ConfigItem openArchiveOnPull = addConfig("OpenArchiveOnPull", configTypeBool, false); |
| 86 | public static ConfigItem hideKeyboardOnChatScroll = addConfig("HideKeyboardOnChatScroll", configTypeBool, false); |
| 87 | public static ConfigItem avatarBackgroundBlur = addConfig("BlurAvatarBackground", configTypeBool, false); |
| 88 | public static ConfigItem avatarBackgroundDarken = addConfig("DarkenAvatarBackground", configTypeBool, false); |
| 89 | public static ConfigItem useSystemEmoji = addConfig("EmojiUseDefault", configTypeBool, false); |
| 90 | public static ConfigItem rearVideoMessages = addConfig("RearVideoMessages", configTypeBool, false); |
| 91 | public static ConfigItem hideAllTab = addConfig("HideAllTab", configTypeBool, false); |
| 92 | // public static ConfigItem pressTitleToOpenAllChats = addConfig("pressTitleToOpenAllChats", configTypeBool, false); |
| 93 | |
| 94 | public static ConfigItem disableChatAction = addConfig("DisableChatAction", configTypeBool, false); |
| 95 | public static ConfigItem sortByUnread = addConfig("sort_by_unread", configTypeBool, false); |
| 96 | public static ConfigItem sortByUnmuted = addConfig("sort_by_unmuted", configTypeBool, true); |
| 97 | public static ConfigItem sortByUser = addConfig("sort_by_user", configTypeBool, true); |
| 98 | public static ConfigItem sortByContacts = addConfig("sort_by_contacts", configTypeBool, true); |
| 99 | |
| 100 | public static ConfigItem disableUndo = addConfig("DisableUndo", configTypeBool, false); |
| 101 | |
| 102 | public static ConfigItem filterUsers = addConfig("filter_users", configTypeBool, true); |
| 103 | public static ConfigItem filterContacts = addConfig("filter_contacts", configTypeBool, true); |
| 104 | public static ConfigItem filterGroups = addConfig("filter_groups", configTypeBool, true); |
| 105 | public static ConfigItem filterChannels = addConfig("filter_channels", configTypeBool, true); |
| 106 | public static ConfigItem filterBots = addConfig("filter_bots", configTypeBool, true); |
| 107 | public static ConfigItem filterAdmins = addConfig("filter_admins", configTypeBool, true); |
| 108 | public static ConfigItem filterUnmuted = addConfig("filter_unmuted", configTypeBool, true); |
| 109 | public static ConfigItem filterUnread = addConfig("filter_unread", configTypeBool, true); |
| 110 | public static ConfigItem filterUnmutedAndUnread = addConfig("filter_unmuted_and_unread", configTypeBool, true); |
| 111 | |
| 112 | public static ConfigItem disableSystemAccount = addConfig("DisableSystemAccount", configTypeBool, false); |
| 113 | // public static ConfigItem disableProxyWhenVpnEnabled = addConfig("DisableProxyWhenVpnEnabled", configTypeBool, false); |
| 114 | public static ConfigItem skipOpenLinkConfirm = addConfig("SkipOpenLinkConfirm", configTypeBool, false); |
| 115 | |
| 116 | public static ConfigItem ignoreMutedCount = addConfig("IgnoreMutedCount", configTypeBool, true); |
| 117 | // public static ConfigItem useDefaultTheme = addConfig("UseDefaultTheme", configTypeBool, false); |
| 118 | public static ConfigItem showIdAndDc = addConfig("ShowIdAndDc", configTypeBool, false); |
| 119 | |
| 120 | public static ConfigItem cachePath = addConfig("cache_path", configTypeString, ""); |
| 121 | public static ConfigItem customSavePath = addConfig("customSavePath", configTypeString, "Nagram"); |
| 122 | |
| 123 | public static ConfigItem translationProvider = addConfig("translationProvider", configTypeInt, 1); |
| 124 | public static ConfigItem translateToLang = addConfig("TransToLang", configTypeString, ""); // "" -> translate to current language (MessageTrans.kt & Translator.kt) |
| 125 | public static ConfigItem translateInputLang = addConfig("TransInputToLang", configTypeString, "en"); |
| 126 | public static ConfigItem useTelegramTranslateInChat = addConfig("useTelegramTranslateInChat", configTypeBool, false); |
| 127 | public static ConfigItem googleCloudTranslateKey = addConfig("GoogleCloudTransKey", configTypeString, ""); |
| 128 | |
| 129 | |
| 130 | public static ConfigItem disableNotificationBubbles = addConfig("disableNotificationBubbles", configTypeBool, false); |
| 131 | |
| 132 | public static ConfigItem ccToLang = addConfig("opencc_to_lang", configTypeString, ""); |
| 133 | public static ConfigItem ccInputLang = addConfig("opencc_input_to_lang", configTypeString, ""); |
| 134 | |
| 135 | public static ConfigItem tabsTitleType = addConfig("TabTitleType", configTypeInt, NekoXConfig.TITLE_TYPE_TEXT); |
| 136 | public static ConfigItem confirmAVMessage = addConfig("ConfirmAVMessage", configTypeBool, false); |
| 137 | public static ConfigItem askBeforeCall = addConfig("AskBeforeCalling", configTypeBool, false); |
| 138 | public static ConfigItem disableNumberRounding = addConfig("DisableNumberRounding", configTypeBool, false); |
| 139 | |
| 140 | public static ConfigItem useSystemDNS = addConfig("useSystemDNS", configTypeBool, false); |
| 141 | public static ConfigItem customDoH = addConfig("customDoH", configTypeString, ""); |
| 142 | public static ConfigItem hideProxyByDefault = addConfig("HideProxyByDefault", configTypeBool, false); |
| 143 | public static ConfigItem useProxyItem = addConfig("UseProxyItem", configTypeBool, true); |
| 144 | |
| 145 | public static ConfigItem disableAppBarShadow = addConfig("DisableAppBarShadow", configTypeBool, false); |
| 146 | public static ConfigItem mediaPreview = addConfig("MediaPreview", configTypeBool, true); |
| 147 | |
| 148 | public static ConfigItem proxyAutoSwitch = addConfig("ProxyAutoSwitch", configTypeBool, false); |
| 149 | |
| 150 | public static ConfigItem usePersianCalendar = addConfig("UsePersiancalendar", configTypeBool, false); |
| 151 | public static ConfigItem displayPersianCalendarByLatin = addConfig("DisplayPersianCalendarByLatin", configTypeBool, false); |
| 152 | public static ConfigItem openPGPApp = addConfig("OpenPGPApp", configTypeString, ""); |
| 153 | public static ConfigItem openPGPKeyId = addConfig("OpenPGPKey", configTypeLong, 0L); |
| 154 | |
| 155 | public static ConfigItem disableVibration = addConfig("DisableVibration", configTypeBool, false); |
| 156 | public static ConfigItem autoPauseVideo = addConfig("AutoPauseVideo", configTypeBool, false); |
| 157 | public static ConfigItem disableProximityEvents = addConfig("DisableProximityEvents", configTypeBool, false); |
| 158 | |
| 159 | public static ConfigItem ignoreContentRestrictions = addConfig("ignoreContentRestrictions", configTypeBool, true); |
| 160 | public static ConfigItem useChatAttachMediaMenu = addConfig("UseChatAttachEnterMenu", configTypeBool, true); |
| 161 | public static ConfigItem disableLinkPreviewByDefault = addConfig("DisableLinkPreviewByDefault", configTypeBool, false); |
| 162 | public static ConfigItem sendCommentAfterForward = addConfig("SendCommentAfterForward", configTypeBool, true); |
| 163 | // public static ConfigItem increaseVoiceMessageQuality = addConfig("IncreaseVoiceMessageQuality", configTypeBool, true); |
| 164 | public static ConfigItem disableTrending = addConfig("DisableTrending", configTypeBool, true); |
| 165 | public static ConfigItem dontSendGreetingSticker = addConfig("DontSendGreetingSticker", configTypeBool, false); |
| 166 | public static ConfigItem hideTimeForSticker = addConfig("HideTimeForSticker", configTypeBool, false); |
| 167 | public static ConfigItem takeGIFasVideo = addConfig("TakeGIFasVideo", configTypeBool, false); |
| 168 | public static ConfigItem maxRecentStickerCount = addConfig("maxRecentStickerCount", configTypeInt, 20); |
| 169 | public static ConfigItem disableSwipeToNext = addConfig("disableSwipeToNextChannel", configTypeBool, true); |
| 170 | public static ConfigItem disableRemoteEmojiInteractions = addConfig("disableRemoteEmojiInteractions", configTypeBool, true); |
| 171 | public static ConfigItem disableChoosingSticker = addConfig("disableChoosingSticker", configTypeBool, false); |
| 172 | public static ConfigItem hideGroupSticker = addConfig("hideGroupSticker", configTypeBool, false); |
| 173 | public static ConfigItem disablePremiumStickerAnimation = addConfig("disablePremiumStickerAnimation", configTypeBool, false); |
| 174 | public static ConfigItem hideSponsoredMessage = addConfig("hideSponsoredMessage", configTypeBool, false); |
| 175 | public static ConfigItem rememberAllBackMessages = addConfig("rememberAllBackMessages", configTypeBool, false); |
| 176 | public static ConfigItem hideSendAsChannel = addConfig("hideSendAsChannel", configTypeBool, false); |
| 177 | public static ConfigItem showSpoilersDirectly = addConfig("showSpoilersDirectly", configTypeBool, false); |
| 178 | public static ConfigItem reactions = addConfig("reactions", configTypeInt, 0); |
| 179 | public static ConfigItem disableReactionsWhenSelecting = addConfig("disableReactionsWhenSelecting", configTypeBool, true); |
| 180 | public static ConfigItem showBottomActionsWhenSelecting = addConfig("showBottomActionsWhenSelecting", configTypeBool, false); |
| 181 | |
| 182 | public static ConfigItem labelChannelUser = addConfig("labelChannelUser", configTypeBool, false); |
| 183 | public static ConfigItem channelAlias = addConfig("channelAlias", configTypeBool, false); |
| 184 | |
| 185 | public static ConfigItem disableAutoDownloadingWin32Executable = addConfig("Win32ExecutableFiles", configTypeBool, true); |
| 186 | public static ConfigItem disableAutoDownloadingArchive = addConfig("ArchiveFiles", configTypeBool, true); |
| 187 | |
| 188 | public static ConfigItem enableStickerPin = addConfig("EnableStickerPin", configTypeBool, false); |
| 189 | public static ConfigItem useMediaStreamInVoip = addConfig("UseMediaStreamInVoip", configTypeBool, false); |
| 190 | public static ConfigItem customAudioBitrate = addConfig("customAudioBitrate", configTypeInt, 32); |
| 191 | public static ConfigItem disableGroupVoipAudioProcessing = addConfig("disableGroupVoipAudioProcessing", configTypeBool, false); |
| 192 | public static ConfigItem enhancedFileLoader = addConfig("enhancedFileLoader", configTypeBool, false); |
| 193 | public static ConfigItem useOSMDroidMap = addConfig("useOSMDroidMap", configTypeBool, false); |
| 194 | public static ConfigItem mapDriftingFixForGoogleMaps = addConfig("mapDriftingFixForGoogleMaps", configTypeBool, true); |
| 195 | |
| 196 | // priv branch changes |
| 197 | public static ConfigItem localPremium = addConfig("localPremium", configTypeBool, false); |
| 198 | |
| 199 | public static ConfigItem localeToDBC = addConfig("LocaleToDBC", configTypeBool, false); |
| 200 | |
| 201 | static { |
| 202 | loadConfig(false); |
| 203 | checkMigrate(false); |
| 204 | } |
| 205 | |
| 206 | public static ConfigItem addConfig(String k, int t, Object d) { |
| 207 | ConfigItem a = new ConfigItem(k, t, d); |
| 208 | configs.add(a); |
| 209 | return a; |
| 210 | } |
| 211 | |
| 212 | public static void loadConfig(boolean force) { |
| 213 | synchronized (sync) { |
| 214 | if (configLoaded && !force) { |
| 215 | return; |
| 216 | } |
| 217 | for (int i = 0; i < configs.size(); i++) { |
| 218 | ConfigItem o = configs.get(i); |
| 219 | |
| 220 | if (o.type == configTypeBool) { |
| 221 | o.value = preferences.getBoolean(o.key, (boolean) o.defaultValue); |
| 222 | } |
| 223 | if (o.type == configTypeInt) { |
| 224 | o.value = preferences.getInt(o.key, (int) o.defaultValue); |
| 225 | } |
| 226 | if (o.type == configTypeLong) { |
| 227 | o.value = preferences.getLong(o.key, (Long) o.defaultValue); |
| 228 | } |
| 229 | if (o.type == configTypeFloat) { |
| 230 | o.value = preferences.getFloat(o.key, (Float) o.defaultValue); |
| 231 | } |
| 232 | if (o.type == configTypeString) { |
| 233 | o.value = preferences.getString(o.key, (String) o.defaultValue); |
| 234 | } |
| 235 | if (o.type == configTypeSetInt) { |
| 236 | Set<String> ss = preferences.getStringSet(o.key, new HashSet<>()); |
| 237 | HashSet<Integer> si = new HashSet<>(); |
| 238 | for (String s : ss) { |
| 239 | si.add(Integer.parseInt(s)); |
| 240 | } |
| 241 | o.value = si; |
| 242 | } |
| 243 | if (o.type == configTypeMapIntInt) { |
| 244 | String cv = preferences.getString(o.key, ""); |
| 245 | // Log.e("NC", String.format("Getting pref %s val %s", o.key, cv)); |
| 246 | if (cv.length() == 0) { |
| 247 | o.value = new HashMap<Integer, Integer>(); |
| 248 | } else { |
| 249 | try { |
| 250 | byte[] data = Base64.decode(cv, Base64.DEFAULT); |
| 251 | ObjectInputStream ois = new ObjectInputStream( |
| 252 | new ByteArrayInputStream(data)); |
| 253 | o.value = (HashMap<Integer, Integer>) ois.readObject(); |
| 254 | if (o.value == null) { |
| 255 | o.value = new HashMap<Integer, Integer>(); |
| 256 | } |
| 257 | ois.close(); |
| 258 | } catch (Exception e) { |
| 259 | o.value = new HashMap<Integer, Integer>(); |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | if (!configLoaded) |
| 265 | preferences.registerOnSharedPreferenceChangeListener(CloudSettingsHelper.listener); |
| 266 | for (int a = 1; a <= 5; a++) { |
| 267 | datacenterInfos.add(new DatacenterInfo(a)); |
| 268 | } |
| 269 | configLoaded = true; |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | public static void checkMigrate(boolean force) { |
| 274 | // TODO remove this after some versions. |
| 275 | if (migrate.Bool() || force) |
| 276 | return; |
| 277 | |
| 278 | migrate.setConfigBool(true); |
| 279 | |
| 280 | // NekoConfig.java read & migrate |
| 281 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 282 | |
| 283 | if (preferences.contains("typeface")) |
| 284 | typeface.setConfigBool(preferences.getInt("typeface", 0) != 0); |
| 285 | if (preferences.contains("nameOrder")) |
| 286 | nameOrder.setConfigInt(preferences.getInt("nameOrder", 1)); |
| 287 | if (preferences.contains("mapPreviewProvider")) |
| 288 | mapPreviewProvider.setConfigInt(preferences.getInt("mapPreviewProvider", 0)); |
| 289 | if (preferences.contains("transparentStatusBar")) |
| 290 | transparentStatusBar.setConfigBool(preferences.getBoolean("transparentStatusBar", false)); |
| 291 | if (preferences.contains("hideProxySponsorChannel")) |
| 292 | hideProxySponsorChannel.setConfigBool(preferences.getBoolean("hideProxySponsorChannel", false)); |
| 293 | if (preferences.contains("showAddToSavedMessages")) |
| 294 | showAddToSavedMessages.setConfigBool(preferences.getBoolean("showAddToSavedMessages", true)); |
| 295 | if (preferences.contains("showReport")) |
| 296 | showReport.setConfigBool(preferences.getBoolean("showReport", true)); |
| 297 | if (preferences.contains("showViewHistory")) |
| 298 | showViewHistory.setConfigBool(preferences.getBoolean("showViewHistory", true)); |
| 299 | if (preferences.contains("showAdminActions")) |
| 300 | showAdminActions.setConfigBool(preferences.getBoolean("showAdminActions", true)); |
| 301 | if (preferences.contains("showChangePermissions")) |
| 302 | showChangePermissions.setConfigBool(preferences.getBoolean("showChangePermissions", true)); |
| 303 | if (preferences.contains("showDeleteDownloadedFile")) |
| 304 | showDeleteDownloadedFile.setConfigBool(preferences.getBoolean("showDeleteDownloadedFile", true)); |
| 305 | if (preferences.contains("showMessageDetails")) |
| 306 | showMessageDetails.setConfigBool(preferences.getBoolean("showMessageDetails", false)); |
| 307 | if (preferences.contains("showTranslate")) |
| 308 | showTranslate.setConfigBool(preferences.getBoolean("showTranslate", true)); |
| 309 | if (preferences.contains("showRepeat")) |
| 310 | showRepeat.setConfigBool(preferences.getBoolean("showRepeat", false)); |
| 311 | if (preferences.contains("showShareMessages")) |
| 312 | showShareMessages.setConfigBool(preferences.getBoolean("showShareMessages", false)); |
| 313 | if (preferences.contains("showMessageHide")) |
| 314 | showMessageHide.setConfigBool(preferences.getBoolean("showMessageHide", false)); |
| 315 | |
| 316 | if (preferences.contains("eventType")) |
| 317 | eventType.setConfigInt(preferences.getInt("eventType", 0)); |
| 318 | if (preferences.contains("actionBarDecoration")) |
| 319 | actionBarDecoration.setConfigInt(preferences.getInt("actionBarDecoration", 0)); |
| 320 | if (preferences.contains("newYear")) |
| 321 | newYear.setConfigBool(preferences.getBoolean("newYear", false)); |
| 322 | if (preferences.contains("stickerSize")) |
| 323 | stickerSize.setConfigFloat(preferences.getFloat("stickerSize", 14.0f)); |
| 324 | if (preferences.contains("unlimitedFavedStickers")) |
| 325 | unlimitedFavedStickers.setConfigBool(preferences.getBoolean("unlimitedFavedStickers", false)); |
| 326 | if (preferences.contains("unlimitedPinnedDialogs")) |
| 327 | unlimitedPinnedDialogs.setConfigBool(preferences.getBoolean("unlimitedPinnedDialogs", false)); |
| 328 | if (preferences.contains("translationProvider")) |
| 329 | translationProvider.setConfigInt(preferences.getInt("translationProvider", 1)); |
| 330 | if (preferences.contains("disablePhotoSideAction")) |
| 331 | disablePhotoSideAction.setConfigBool(preferences.getBoolean("disablePhotoSideAction", true)); |
| 332 | if (preferences.contains("openArchiveOnPull")) |
| 333 | openArchiveOnPull.setConfigBool(preferences.getBoolean("openArchiveOnPull", false)); |
| 334 | if (preferences.contains("showHiddenFeature")) //showHiddenFeature.setConfigBool(preferences.getBoolean("showHiddenFeature", false)); |
| 335 | if (preferences.contains("hideKeyboardOnChatScroll")) |
| 336 | hideKeyboardOnChatScroll.setConfigBool(preferences.getBoolean("hideKeyboardOnChatScroll", false)); |
| 337 | if (preferences.contains("avatarBackgroundBlur")) |
| 338 | avatarBackgroundBlur.setConfigBool(preferences.getBoolean("avatarBackgroundBlur", false)); |
| 339 | if (preferences.contains("avatarBackgroundDarken")) |
| 340 | avatarBackgroundDarken.setConfigBool(preferences.getBoolean("avatarBackgroundDarken", false)); |
| 341 | if (preferences.contains("useSystemEmoji")) |
| 342 | useSystemEmoji.setConfigBool(preferences.getBoolean("useSystemEmoji", false)); |
| 343 | if (preferences.contains("rearVideoMessages")) |
| 344 | rearVideoMessages.setConfigBool(preferences.getBoolean("rearVideoMessages", false)); |
| 345 | if (preferences.contains("hideAllTab")) |
| 346 | hideAllTab.setConfigBool(preferences.getBoolean("hideAllTab", false)); |
| 347 | if (preferences.contains("disable_chat_action")) |
| 348 | disableChatAction.setConfigBool(preferences.getBoolean("disable_chat_action", false)); |
| 349 | if (preferences.contains("sort_by_unread")) |
| 350 | sortByUnread.setConfigBool(preferences.getBoolean("sort_by_unread", false)); |
| 351 | if (preferences.contains("sort_by_unmuted")) |
| 352 | sortByUnmuted.setConfigBool(preferences.getBoolean("sort_by_unmuted", true)); |
| 353 | if (preferences.contains("sort_by_user")) |
| 354 | sortByUser.setConfigBool(preferences.getBoolean("sort_by_user", true)); |
| 355 | if (preferences.contains("sort_by_contacts")) |
| 356 | sortByContacts.setConfigBool(preferences.getBoolean("sort_by_contacts", true)); |
| 357 | |
| 358 | if (preferences.contains("disable_undo")) |
| 359 | disableUndo.setConfigBool(preferences.getBoolean("disable_undo", false)); |
| 360 | |
| 361 | if (preferences.contains("filter_users")) |
| 362 | filterUsers.setConfigBool(preferences.getBoolean("filter_users", true)); |
| 363 | if (preferences.contains("filter_contacts")) |
| 364 | filterContacts.setConfigBool(preferences.getBoolean("filter_contacts", true)); |
| 365 | if (preferences.contains("filter_groups")) |
| 366 | filterGroups.setConfigBool(preferences.getBoolean("filter_groups", true)); |
| 367 | if (preferences.contains("filter_channels")) |
| 368 | filterChannels.setConfigBool(preferences.getBoolean("filter_channels", true)); |
| 369 | if (preferences.contains("filter_bots")) |
| 370 | filterBots.setConfigBool(preferences.getBoolean("filter_bots", true)); |
| 371 | if (preferences.contains("filter_admins")) |
| 372 | filterAdmins.setConfigBool(preferences.getBoolean("filter_admins", true)); |
| 373 | if (preferences.contains("filter_unmuted")) |
| 374 | filterUnmuted.setConfigBool(preferences.getBoolean("filter_unmuted", true)); |
| 375 | if (preferences.contains("filter_unread")) |
| 376 | filterUnread.setConfigBool(preferences.getBoolean("filter_unread", true)); |
| 377 | if (preferences.contains("filter_unmuted_and_unread")) |
| 378 | filterUnmutedAndUnread.setConfigBool(preferences.getBoolean("filter_unmuted_and_unread", true)); |
| 379 | |
| 380 | if (preferences.contains("disable_system_account")) |
| 381 | disableSystemAccount.setConfigBool(preferences.getBoolean("disable_system_account", false)); |
| 382 | if (preferences.contains("skip_open_link_confirm")) |
| 383 | skipOpenLinkConfirm.setConfigBool(preferences.getBoolean("skip_open_link_confirm", false)); |
| 384 | |
| 385 | if (preferences.contains("ignore_muted_count")) |
| 386 | ignoreMutedCount.setConfigBool(preferences.getBoolean("ignore_muted_count", true)); |
| 387 | // if (preferences.contains("use_default_theme")) |
| 388 | // useDefaultTheme.setConfigBool(preferences.getBoolean("use_default_theme", false)); |
| 389 | if (preferences.contains("show_id_and_dc")) |
| 390 | showIdAndDc.setConfigBool(preferences.getBoolean("show_id_and_dc", false)); |
| 391 | |
| 392 | if (preferences.contains("google_cloud_translate_key")) |
| 393 | googleCloudTranslateKey.setConfigString(preferences.getString("google_cloud_translate_key", null)); |
| 394 | if (preferences.contains("cache_path")) |
| 395 | cachePath.setConfigString(preferences.getString("cache_path", null)); |
| 396 | |
| 397 | if (preferences.contains("trans_to_lang")) |
| 398 | translateToLang.setConfigString(preferences.getString("trans_to_lang", "")); |
| 399 | if (preferences.contains("trans_input_to_lang")) |
| 400 | translateInputLang.setConfigString(preferences.getString("trans_input_to_lang", "en")); |
| 401 | |
| 402 | if (preferences.contains("opencc_to_lang")) |
| 403 | ccToLang.setConfigString(preferences.getString("opencc_to_lang", null)); |
| 404 | if (preferences.contains("opencc_input_to_lang")) |
| 405 | ccInputLang.setConfigString(preferences.getString("opencc_input_to_lang", null)); |
| 406 | |
| 407 | if (preferences.contains("tabsTitleType")) |
| 408 | tabsTitleType.setConfigInt(preferences.getInt("tabsTitleType", NekoXConfig.TITLE_TYPE_TEXT)); |
| 409 | if (preferences.contains("confirmAVMessage")) |
| 410 | confirmAVMessage.setConfigBool(preferences.getBoolean("confirmAVMessage", false)); |
| 411 | if (preferences.contains("askBeforeCall")) |
| 412 | askBeforeCall.setConfigBool(preferences.getBoolean("askBeforeCall", false)); |
| 413 | if (preferences.contains("disableNumberRounding")) |
| 414 | disableNumberRounding.setConfigBool(preferences.getBoolean("disableNumberRounding", false)); |
| 415 | |
| 416 | if (preferences.contains("useSystemDNS")) |
| 417 | useSystemDNS.setConfigBool(preferences.getBoolean("useSystemDNS", false)); |
| 418 | if (preferences.contains("customDoH")) |
| 419 | customDoH.setConfigString(preferences.getString("customDoH", "")); |
| 420 | if (preferences.contains("hide_proxy_by_default")) |
| 421 | hideProxyByDefault.setConfigBool(preferences.getBoolean("hide_proxy_by_default", false)); |
| 422 | if (preferences.contains("use_proxy_item")) |
| 423 | useProxyItem.setConfigBool(preferences.getBoolean("use_proxy_item", true)); |
| 424 | |
| 425 | if (preferences.contains("disableAppBarShadow")) |
| 426 | disableAppBarShadow.setConfigBool(preferences.getBoolean("disableAppBarShadow", false)); |
| 427 | if (preferences.contains("mediaPreview")) |
| 428 | mediaPreview.setConfigBool(preferences.getBoolean("mediaPreview", true)); |
| 429 | |
| 430 | if (preferences.contains("proxy_auto_switch")) |
| 431 | proxyAutoSwitch.setConfigBool(preferences.getBoolean("proxy_auto_switch", false)); |
| 432 | |
| 433 | if (preferences.contains("openPGPApp")) |
| 434 | openPGPApp.setConfigString(preferences.getString("openPGPApp", "")); |
| 435 | if (preferences.contains("openPGPKeyId")) |
| 436 | openPGPKeyId.setConfigLong(preferences.getLong("openPGPKeyId", 0L)); |
| 437 | |
| 438 | if (preferences.contains("disableVibration")) |
| 439 | disableVibration.setConfigBool(preferences.getBoolean("disableVibration", false)); |
| 440 | if (preferences.contains("autoPauseVideo")) |
| 441 | autoPauseVideo.setConfigBool(preferences.getBoolean("autoPauseVideo", false)); |
| 442 | if (preferences.contains("disableProximityEvents")) |
| 443 | disableProximityEvents.setConfigBool(preferences.getBoolean("disableProximityEvents", false)); |
| 444 | |
| 445 | if (preferences.contains("ignoreContentRestrictions")) |
| 446 | ignoreContentRestrictions.setConfigBool(preferences.getBoolean("ignoreContentRestrictions", true)); |
| 447 | if (preferences.contains("useChatAttachMediaMenu")) |
| 448 | useChatAttachMediaMenu.setConfigBool(preferences.getBoolean("useChatAttachMediaMenu", true)); |
| 449 | if (preferences.contains("disableLinkPreviewByDefault")) |
| 450 | disableLinkPreviewByDefault.setConfigBool(preferences.getBoolean("disableLinkPreviewByDefault", false)); |
| 451 | if (preferences.contains("sendCommentAfterForward")) |
| 452 | sendCommentAfterForward.setConfigBool(preferences.getBoolean("sendCommentAfterForward", true)); |
| 453 | // if (preferences.contains("increaseVoiceMessageQuality")) |
| 454 | // increaseVoiceMessageQuality.setConfigBool(preferences.getBoolean("increaseVoiceMessageQuality", true)); |
| 455 | if (preferences.contains("disableTrending")) |
| 456 | disableTrending.setConfigBool(preferences.getBoolean("disableTrending", true)); |
| 457 | if (preferences.contains("dontSendGreetingSticker")) |
| 458 | dontSendGreetingSticker.setConfigBool(preferences.getBoolean("dontSendGreetingSticker", false)); |
| 459 | if (preferences.contains("hideTimeForSticker")) |
| 460 | hideTimeForSticker.setConfigBool(preferences.getBoolean("hideTimeForSticker", false)); |
| 461 | if (preferences.contains("takeGIFasVideo")) |
| 462 | takeGIFasVideo.setConfigBool(preferences.getBoolean("takeGIFasVideo", false)); |
| 463 | if (preferences.contains("maxRecentStickerCount")) |
| 464 | maxRecentStickerCount.setConfigInt(preferences.getInt("maxRecentStickerCount", 20)); |
| 465 | if (preferences.contains("disableSwipeToNext")) |
| 466 | disableSwipeToNext.setConfigBool(preferences.getBoolean("disableSwipeToNext", true)); |
| 467 | if (preferences.contains("disableRemoteEmojiInteractions")) |
| 468 | disableRemoteEmojiInteractions.setConfigBool(preferences.getBoolean("disableRemoteEmojiInteractions", true)); |
| 469 | if (preferences.contains("disableChoosingSticker")) |
| 470 | disableChoosingSticker.setConfigBool(preferences.getBoolean("disableChoosingSticker", false)); |
| 471 | |
| 472 | if (preferences.contains("disableAutoDownloadingWin32Executable")) |
| 473 | disableAutoDownloadingWin32Executable.setConfigBool(preferences.getBoolean("disableAutoDownloadingWin32Executable", true)); |
| 474 | if (preferences.contains("disableAutoDownloadingArchive")) |
| 475 | disableAutoDownloadingArchive.setConfigBool(preferences.getBoolean("disableAutoDownloadingArchive", true)); |
| 476 | |
| 477 | if (preferences.contains("enableStickerPin")) |
| 478 | enableStickerPin.setConfigBool(preferences.getBoolean("enableStickerPin", false)); |
| 479 | if (preferences.contains("useMediaStreamInVoip")) |
| 480 | useMediaStreamInVoip.setConfigBool(preferences.getBoolean("useMediaStreamInVoip", false)); |
| 481 | if (preferences.contains("customAudioBitrate")) |
| 482 | customAudioBitrate.setConfigInt(preferences.getInt("customAudioBitrate", 32)); |
| 483 | if (preferences.contains("disableGroupVoipAudioProcessing")) |
| 484 | disableGroupVoipAudioProcessing.setConfigBool(preferences.getBoolean("disableGroupVoipAudioProcessing", false)); |
| 485 | } |
| 486 | |
| 487 | public static class DatacenterInfo { |
| 488 | |
| 489 | public int id; |
| 490 | |
| 491 | public long pingId; |
| 492 | public long ping; |
| 493 | public boolean checking; |
| 494 | public boolean available; |
| 495 | public long availableCheckTime; |
| 496 | |
| 497 | public DatacenterInfo(int i) { |
| 498 | id = i; |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | public static boolean fixDriftingForGoogleMaps() { |
| 503 | return !useOSMDroidMap.Bool() && mapDriftingFixForGoogleMaps.Bool(); |
| 504 | } |
| 505 | } |
| 506 | |