| 1 | package tw.nekomimi.nekogram; |
| 2 | |
| 3 | import android.app.Activity; |
| 4 | import android.content.Intent; |
| 5 | import android.content.SharedPreferences; |
| 6 | import android.content.pm.ApplicationInfo; |
| 7 | import android.content.pm.PackageManager; |
| 8 | |
| 9 | import org.telegram.messenger.ApplicationLoader; |
| 10 | import org.telegram.messenger.LocaleController; |
| 11 | import org.telegram.messenger.NotificationCenter; |
| 12 | import org.telegram.messenger.NotificationsService; |
| 13 | import org.telegram.messenger.R; |
| 14 | |
| 15 | import java.util.Locale; |
| 16 | |
| 17 | import cn.hutool.core.util.StrUtil; |
| 18 | |
| 19 | public class NekoConfig { |
| 20 | |
| 21 | public static final int TITLE_TYPE_TEXT = 0; |
| 22 | public static final int TITLE_TYPE_ICON = 1; |
| 23 | public static final int TITLE_TYPE_MIX = 2; |
| 24 | |
| 25 | public static SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 26 | |
| 27 | public static boolean useIPv6; |
| 28 | |
| 29 | public static boolean useSystemEmoji; |
| 30 | public static boolean ignoreBlocked; |
| 31 | public static boolean hideProxySponsorChannel; |
| 32 | public static boolean disablePhotoSideAction; |
| 33 | public static boolean hideKeyboardOnChatScroll; |
| 34 | public static boolean rearVideoMessages; |
| 35 | public static boolean hideAllTab; |
| 36 | public static boolean confirmAVMessage; |
| 37 | public static boolean askBeforeCall; |
| 38 | public static boolean disableNumberRounding; |
| 39 | public static int mapPreviewProvider; |
| 40 | public static float stickerSize; |
| 41 | public static int translationProvider; |
| 42 | public static int tabsTitleType; |
| 43 | |
| 44 | public static boolean showAddToSavedMessages; |
| 45 | public static boolean showReport; |
| 46 | public static boolean showViewHistory; |
| 47 | public static boolean showAdminActions; |
| 48 | public static boolean showChangePermissions; |
| 49 | public static boolean showDeleteDownloadedFile; |
| 50 | public static boolean showMessageDetails; |
| 51 | public static boolean showTranslate; |
| 52 | public static boolean showRepeat; |
| 53 | |
| 54 | public static boolean hidePhone; |
| 55 | public static int typeface; |
| 56 | public static boolean transparentStatusBar; |
| 57 | public static boolean forceTablet; |
| 58 | public static boolean openArchiveOnPull; |
| 59 | public static boolean avatarAsDrawerBackground; |
| 60 | public static boolean showTabsOnForward; |
| 61 | public static int nameOrder; |
| 62 | public static int eventType; |
| 63 | public static boolean newYear; |
| 64 | public static int actionBarDecoration; |
| 65 | public static boolean unlimitedFavedStickers; |
| 66 | public static boolean unlimitedPinnedDialogs; |
| 67 | public static boolean residentNotification; |
| 68 | |
| 69 | public static boolean disableChatAction; |
| 70 | public static boolean sortByUnread; |
| 71 | public static boolean sortByUnmuted; |
| 72 | public static boolean sortByUser; |
| 73 | public static boolean sortByContacts; |
| 74 | |
| 75 | public static boolean disableUndo; |
| 76 | |
| 77 | public static boolean filterUsers; |
| 78 | public static boolean filterContacts; |
| 79 | public static boolean filterGroups; |
| 80 | public static boolean filterChannels; |
| 81 | public static boolean filterBots; |
| 82 | public static boolean filterAdmins; |
| 83 | public static boolean filterUnmuted; |
| 84 | public static boolean filterUnread; |
| 85 | public static boolean filterUnmutedAndUnread; |
| 86 | |
| 87 | public static boolean ignoreMutedCount; |
| 88 | |
| 89 | public static boolean disableSystemAccount; |
| 90 | public static boolean disableProxyWhenVpnEnabled; |
| 91 | public static boolean skipOpenLinkConfirm; |
| 92 | |
| 93 | public static boolean removeTitleEmoji; |
| 94 | public static boolean useDefaultTheme; |
| 95 | public static boolean showIdAndDc; |
| 96 | |
| 97 | public static String googleCloudTranslateKey; |
| 98 | |
| 99 | public static String cachePath; |
| 100 | |
| 101 | public static String translateToLang; |
| 102 | public static String translateInputLang; |
| 103 | |
| 104 | public static String ccToLang; |
| 105 | public static String ccInputLang; |
| 106 | |
| 107 | public static boolean hideProxyByDefault; |
| 108 | public static boolean useProxyItem; |
| 109 | |
| 110 | public static boolean disableAppBarShadow; |
| 111 | public static boolean mediaPreview; |
| 112 | |
| 113 | public static boolean proxyAutoSwitch; |
| 114 | |
| 115 | public static String openPGPApp; |
| 116 | public static long openPGPKeyId; |
| 117 | |
| 118 | public static boolean disableVibration; |
| 119 | public static boolean autoPauseVideo; |
| 120 | public static boolean disableProximityEvents; |
| 121 | |
| 122 | public static boolean ignoreContentRestrictions; |
| 123 | public static boolean useChatAttachMediaMenu; |
| 124 | public static boolean disableLinkPreviewByDefault; |
| 125 | public static boolean sendCommentAfterForward; |
| 126 | |
| 127 | public static String getOpenPGPAppName() { |
| 128 | |
| 129 | if (StrUtil.isNotBlank(openPGPApp)) { |
| 130 | |
| 131 | try { |
| 132 | PackageManager manager = ApplicationLoader.applicationContext.getPackageManager(); |
| 133 | ApplicationInfo info = manager.getApplicationInfo(openPGPApp, PackageManager.GET_META_DATA); |
| 134 | return (String) manager.getApplicationLabel(info); |
| 135 | } catch (PackageManager.NameNotFoundException e) { |
| 136 | openPGPApp = ""; |
| 137 | } |
| 138 | |
| 139 | } |
| 140 | |
| 141 | return LocaleController.getString("None",R.string.None); |
| 142 | |
| 143 | } |
| 144 | |
| 145 | public static String formatLang(String name) { |
| 146 | |
| 147 | if (name == null) { |
| 148 | |
| 149 | return LocaleController.getString("Default", R.string.Default); |
| 150 | |
| 151 | } else { |
| 152 | |
| 153 | if (name.contains("-")) { |
| 154 | |
| 155 | return new Locale(StrUtil.subBefore(name, "-", false), StrUtil.subAfter(name, "-", false)).getDisplayName(LocaleController.getInstance().currentLocale); |
| 156 | |
| 157 | } else { |
| 158 | |
| 159 | return new Locale(name).getDisplayName(LocaleController.getInstance().currentLocale); |
| 160 | |
| 161 | } |
| 162 | |
| 163 | } |
| 164 | |
| 165 | } |
| 166 | |
| 167 | static { |
| 168 | |
| 169 | useIPv6 = preferences.getBoolean("useIPv6", false); |
| 170 | hidePhone = preferences.getBoolean("hidePhone", true); |
| 171 | ignoreBlocked = preferences.getBoolean("ignoreBlocked", false); |
| 172 | forceTablet = preferences.getBoolean("forceTablet", false); |
| 173 | typeface = preferences.getInt("typeface", 0); |
| 174 | nameOrder = preferences.getInt("nameOrder", 1); |
| 175 | mapPreviewProvider = preferences.getInt("mapPreviewProvider", 0); |
| 176 | transparentStatusBar = preferences.getBoolean("transparentStatusBar", false); |
| 177 | residentNotification = preferences.getBoolean("residentNotification", false); |
| 178 | hideProxySponsorChannel = preferences.getBoolean("hideProxySponsorChannel", false); |
| 179 | showAddToSavedMessages = preferences.getBoolean("showAddToSavedMessages", false); |
| 180 | showReport = preferences.getBoolean("showReport", false); |
| 181 | showViewHistory = preferences.getBoolean("showViewHistory", true); |
| 182 | showAdminActions = preferences.getBoolean("showAdminActions", true); |
| 183 | showChangePermissions = preferences.getBoolean("showChangePermissions", true); |
| 184 | showDeleteDownloadedFile = preferences.getBoolean("showDeleteDownloadedFile", true); |
| 185 | showMessageDetails = preferences.getBoolean("showMessageDetails", false); |
| 186 | showTranslate = preferences.getBoolean("showTranslate", true); |
| 187 | showRepeat = preferences.getBoolean("showRepeat", true); |
| 188 | eventType = preferences.getInt("eventType", 0); |
| 189 | actionBarDecoration = preferences.getInt("actionBarDecoration", 0); |
| 190 | newYear = preferences.getBoolean("newYear", false); |
| 191 | stickerSize = preferences.getFloat("stickerSize", 14.0f); |
| 192 | unlimitedFavedStickers = preferences.getBoolean("unlimitedFavedStickers", false); |
| 193 | unlimitedPinnedDialogs = preferences.getBoolean("unlimitedPinnedDialogs", false); |
| 194 | translationProvider = preferences.getInt("translationProvider", 1); |
| 195 | disablePhotoSideAction = preferences.getBoolean("disablePhotoSideAction", true); |
| 196 | openArchiveOnPull = preferences.getBoolean("openArchiveOnPull", false); |
| 197 | //showHiddenFeature = preferences.getBoolean("showHiddenFeature", false); |
| 198 | hideKeyboardOnChatScroll = preferences.getBoolean("hideKeyboardOnChatScroll", false); |
| 199 | avatarAsDrawerBackground = preferences.getBoolean("avatarAsDrawerBackground", true); |
| 200 | useSystemEmoji = preferences.getBoolean("useSystemEmoji", false); |
| 201 | showTabsOnForward = preferences.getBoolean("showTabsOnForward", false); |
| 202 | rearVideoMessages = preferences.getBoolean("rearVideoMessages", false); |
| 203 | hideAllTab = preferences.getBoolean("hideAllTab", false); |
| 204 | |
| 205 | disableChatAction = preferences.getBoolean("disable_chat_action", false); |
| 206 | sortByUnread = preferences.getBoolean("sort_by_unread", false); |
| 207 | sortByUnmuted = preferences.getBoolean("sort_by_unmuted", true); |
| 208 | sortByUser = preferences.getBoolean("sort_by_user", true); |
| 209 | sortByContacts = preferences.getBoolean("sort_by_contacts", true); |
| 210 | |
| 211 | disableUndo = preferences.getBoolean("disable_undo", false); |
| 212 | |
| 213 | filterUsers = preferences.getBoolean("filter_users", true); |
| 214 | filterContacts = preferences.getBoolean("filter_contacts", true); |
| 215 | filterGroups = preferences.getBoolean("filter_groups", true); |
| 216 | filterChannels = preferences.getBoolean("filter_channels", true); |
| 217 | filterBots = preferences.getBoolean("filter_bots", true); |
| 218 | filterAdmins = preferences.getBoolean("filter_admins", true); |
| 219 | filterUnmuted = preferences.getBoolean("filter_unmuted", true); |
| 220 | filterUnread = preferences.getBoolean("filter_unread", true); |
| 221 | filterUnmutedAndUnread = preferences.getBoolean("filter_unmuted_and_unread", true); |
| 222 | |
| 223 | disableSystemAccount = preferences.getBoolean("disable_system_account", false); |
| 224 | disableProxyWhenVpnEnabled = preferences.getBoolean("disable_proxy_when_vpn_enabled", false); |
| 225 | skipOpenLinkConfirm = preferences.getBoolean("skip_open_link_confirm", false); |
| 226 | |
| 227 | removeTitleEmoji = preferences.getBoolean("remove_title_emoji", true); |
| 228 | ignoreMutedCount = preferences.getBoolean("ignore_muted_count", true); |
| 229 | useDefaultTheme = preferences.getBoolean("use_default_theme", false); |
| 230 | showIdAndDc = preferences.getBoolean("show_id_and_dc", false); |
| 231 | |
| 232 | googleCloudTranslateKey = preferences.getString("google_cloud_translate_key", null); |
| 233 | cachePath = preferences.getString("cache_path", null); |
| 234 | |
| 235 | translateToLang = preferences.getString("trans_to_lang", null); |
| 236 | translateInputLang = preferences.getString("trans_input_to_lang", "en"); |
| 237 | |
| 238 | ccToLang = preferences.getString("opencc_to_lang", null); |
| 239 | ccInputLang = preferences.getString("opencc_input_to_lang", null); |
| 240 | |
| 241 | tabsTitleType = preferences.getInt("tabsTitleType", TITLE_TYPE_TEXT); |
| 242 | confirmAVMessage = preferences.getBoolean("confirmAVMessage", false); |
| 243 | askBeforeCall = preferences.getBoolean("askBeforeCall", false); |
| 244 | disableNumberRounding = preferences.getBoolean("disableNumberRounding", false); |
| 245 | |
| 246 | hideProxyByDefault = preferences.getBoolean("hide_proxy_by_default", false); |
| 247 | useProxyItem = preferences.getBoolean("use_proxy_item", true); |
| 248 | |
| 249 | disableAppBarShadow = preferences.getBoolean("disableAppBarShadow", false); |
| 250 | mediaPreview = preferences.getBoolean("mediaPreview", false); |
| 251 | |
| 252 | proxyAutoSwitch = preferences.getBoolean("proxy_auto_switch", false); |
| 253 | //preferences.getBoolean("usePersianCalender", false); |
| 254 | openPGPApp = preferences.getString("openPGPApp",""); |
| 255 | openPGPKeyId = preferences.getLong("openPGPKeyId",0L); |
| 256 | |
| 257 | disableVibration = preferences.getBoolean("disableVibration", false); |
| 258 | autoPauseVideo = preferences.getBoolean("autoPauseVideo", false); |
| 259 | disableProximityEvents = preferences.getBoolean("disableProximityEvents", false); |
| 260 | |
| 261 | ignoreContentRestrictions = preferences.getBoolean("ignoreContentRestrictions", false); |
| 262 | useChatAttachMediaMenu = preferences.getBoolean("useChatAttachMediaMenu", true); |
| 263 | disableLinkPreviewByDefault = preferences.getBoolean("disableLinkPreviewByDefault", false); |
| 264 | sendCommentAfterForward = preferences.getBoolean("sendCommentAfterForward", true); |
| 265 | |
| 266 | } |
| 267 | |
| 268 | public static void toggleShowAddToSavedMessages() { |
| 269 | showAddToSavedMessages = !showAddToSavedMessages; |
| 270 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 271 | SharedPreferences.Editor editor = preferences.edit(); |
| 272 | editor.putBoolean("showAddToSavedMessages", showAddToSavedMessages); |
| 273 | editor.apply(); |
| 274 | } |
| 275 | |
| 276 | public static void toggleShowReport() { |
| 277 | showReport = !showReport; |
| 278 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 279 | SharedPreferences.Editor editor = preferences.edit(); |
| 280 | editor.putBoolean("showReport", showReport); |
| 281 | editor.apply(); |
| 282 | } |
| 283 | |
| 284 | public static void toggleShowViewHistory() { |
| 285 | showViewHistory = !showViewHistory; |
| 286 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 287 | SharedPreferences.Editor editor = preferences.edit(); |
| 288 | editor.putBoolean("showViewHistory", showViewHistory); |
| 289 | editor.apply(); |
| 290 | } |
| 291 | |
| 292 | public static void toggleShowAdminActions() { |
| 293 | showAdminActions = !showAdminActions; |
| 294 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 295 | SharedPreferences.Editor editor = preferences.edit(); |
| 296 | editor.putBoolean("showAdminActions", showAdminActions); |
| 297 | editor.apply(); |
| 298 | } |
| 299 | |
| 300 | public static void toggleShowChangePermissions() { |
| 301 | showChangePermissions = !showChangePermissions; |
| 302 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 303 | SharedPreferences.Editor editor = preferences.edit(); |
| 304 | editor.putBoolean("showChangePermissions", showChangePermissions); |
| 305 | editor.apply(); |
| 306 | } |
| 307 | |
| 308 | public static void toggleShowDeleteDownloadedFile() { |
| 309 | showDeleteDownloadedFile = !showDeleteDownloadedFile; |
| 310 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 311 | SharedPreferences.Editor editor = preferences.edit(); |
| 312 | editor.putBoolean("showDeleteDownloadedFile", showDeleteDownloadedFile); |
| 313 | editor.apply(); |
| 314 | } |
| 315 | |
| 316 | public static void toggleShowMessageDetails() { |
| 317 | showMessageDetails = !showMessageDetails; |
| 318 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 319 | SharedPreferences.Editor editor = preferences.edit(); |
| 320 | editor.putBoolean("showMessageDetails", showMessageDetails); |
| 321 | editor.apply(); |
| 322 | } |
| 323 | |
| 324 | public static void toggleShowRepeat() { |
| 325 | showRepeat = !showRepeat; |
| 326 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 327 | SharedPreferences.Editor editor = preferences.edit(); |
| 328 | editor.putBoolean("showRepeat", showRepeat); |
| 329 | editor.apply(); |
| 330 | } |
| 331 | |
| 332 | public static void toggleIPv6() { |
| 333 | useIPv6 = !useIPv6; |
| 334 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 335 | SharedPreferences.Editor editor = preferences.edit(); |
| 336 | editor.putBoolean("useIPv6", useIPv6); |
| 337 | editor.apply(); |
| 338 | } |
| 339 | |
| 340 | public static void toggleHidePhone() { |
| 341 | hidePhone = !hidePhone; |
| 342 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 343 | SharedPreferences.Editor editor = preferences.edit(); |
| 344 | editor.putBoolean("hidePhone", hidePhone); |
| 345 | editor.apply(); |
| 346 | } |
| 347 | |
| 348 | public static void toggleIgnoreBlocked() { |
| 349 | ignoreBlocked = !ignoreBlocked; |
| 350 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 351 | SharedPreferences.Editor editor = preferences.edit(); |
| 352 | editor.putBoolean("ignoreBlocked", ignoreBlocked); |
| 353 | editor.apply(); |
| 354 | } |
| 355 | |
| 356 | public static void toggleForceTablet() { |
| 357 | forceTablet = !forceTablet; |
| 358 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 359 | SharedPreferences.Editor editor = preferences.edit(); |
| 360 | editor.putBoolean("forceTablet", forceTablet); |
| 361 | editor.apply(); |
| 362 | } |
| 363 | |
| 364 | public static void toggleTypeface() { |
| 365 | typeface = typeface == 0 ? 1 : 0; |
| 366 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 367 | SharedPreferences.Editor editor = preferences.edit(); |
| 368 | editor.putInt("typeface", typeface); |
| 369 | editor.apply(); |
| 370 | } |
| 371 | |
| 372 | public static void setNameOrder(int order) { |
| 373 | nameOrder = order; |
| 374 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 375 | SharedPreferences.Editor editor = preferences.edit(); |
| 376 | editor.putInt("nameOrder", nameOrder); |
| 377 | editor.apply(); |
| 378 | |
| 379 | LocaleController.getInstance().recreateFormatters(); |
| 380 | } |
| 381 | |
| 382 | public static void setMapPreviewProvider(int provider) { |
| 383 | mapPreviewProvider = provider; |
| 384 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 385 | SharedPreferences.Editor editor = preferences.edit(); |
| 386 | editor.putInt("mapPreviewProvider", mapPreviewProvider); |
| 387 | editor.apply(); |
| 388 | } |
| 389 | |
| 390 | public static void toggleTransparentStatusBar() { |
| 391 | transparentStatusBar = !transparentStatusBar; |
| 392 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 393 | SharedPreferences.Editor editor = preferences.edit(); |
| 394 | editor.putBoolean("transparentStatusBar", transparentStatusBar); |
| 395 | editor.apply(); |
| 396 | } |
| 397 | |
| 398 | public static void toggleResidentNotification() { |
| 399 | residentNotification = !residentNotification; |
| 400 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 401 | SharedPreferences.Editor editor = preferences.edit(); |
| 402 | editor.putBoolean("residentNotification", residentNotification); |
| 403 | editor.apply(); |
| 404 | ApplicationLoader.applicationContext.stopService(new Intent(ApplicationLoader.applicationContext, NotificationsService.class)); |
| 405 | ApplicationLoader.startPushService(); |
| 406 | } |
| 407 | |
| 408 | public static void toggleHideProxySponsorChannel() { |
| 409 | hideProxySponsorChannel = !hideProxySponsorChannel; |
| 410 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 411 | SharedPreferences.Editor editor = preferences.edit(); |
| 412 | editor.putBoolean("hideProxySponsorChannel", hideProxySponsorChannel); |
| 413 | editor.apply(); |
| 414 | } |
| 415 | |
| 416 | public static void setEventType(int type) { |
| 417 | eventType = type; |
| 418 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 419 | SharedPreferences.Editor editor = preferences.edit(); |
| 420 | editor.putInt("eventType", eventType); |
| 421 | editor.apply(); |
| 422 | } |
| 423 | |
| 424 | public static void setActionBarDecoration(int decoration) { |
| 425 | actionBarDecoration = decoration; |
| 426 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 427 | SharedPreferences.Editor editor = preferences.edit(); |
| 428 | editor.putInt("actionBarDecoration", actionBarDecoration); |
| 429 | editor.apply(); |
| 430 | } |
| 431 | |
| 432 | public static void toggleNewYear() { |
| 433 | newYear = !newYear; |
| 434 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 435 | SharedPreferences.Editor editor = preferences.edit(); |
| 436 | editor.putBoolean("newYear", newYear); |
| 437 | editor.apply(); |
| 438 | } |
| 439 | |
| 440 | public static void toggleUnlimitedFavedStickers() { |
| 441 | unlimitedFavedStickers = !unlimitedFavedStickers; |
| 442 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 443 | SharedPreferences.Editor editor = preferences.edit(); |
| 444 | editor.putBoolean("unlimitedFavedStickers", unlimitedFavedStickers); |
| 445 | editor.apply(); |
| 446 | } |
| 447 | |
| 448 | public static void toggleUnlimitedPinnedDialogs() { |
| 449 | unlimitedPinnedDialogs = !unlimitedPinnedDialogs; |
| 450 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 451 | SharedPreferences.Editor editor = preferences.edit(); |
| 452 | editor.putBoolean("unlimitedPinnedDialogs", unlimitedPinnedDialogs); |
| 453 | editor.apply(); |
| 454 | } |
| 455 | |
| 456 | public static void toggleShowTranslate() { |
| 457 | showTranslate = !showTranslate; |
| 458 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 459 | SharedPreferences.Editor editor = preferences.edit(); |
| 460 | editor.putBoolean("showTranslate", showTranslate); |
| 461 | editor.apply(); |
| 462 | } |
| 463 | |
| 464 | public static void setStickerSize(float size) { |
| 465 | stickerSize = size; |
| 466 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 467 | SharedPreferences.Editor editor = preferences.edit(); |
| 468 | editor.putFloat("stickerSize", stickerSize); |
| 469 | editor.apply(); |
| 470 | } |
| 471 | |
| 472 | public static void setTranslationProvider(int provider) { |
| 473 | translationProvider = provider; |
| 474 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 475 | SharedPreferences.Editor editor = preferences.edit(); |
| 476 | editor.putInt("translationProvider", translationProvider); |
| 477 | editor.apply(); |
| 478 | } |
| 479 | |
| 480 | public static void toggleDisablePhotoSideAction() { |
| 481 | disablePhotoSideAction = !disablePhotoSideAction; |
| 482 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 483 | SharedPreferences.Editor editor = preferences.edit(); |
| 484 | editor.putBoolean("disablePhotoSideAction", disablePhotoSideAction); |
| 485 | editor.apply(); |
| 486 | } |
| 487 | |
| 488 | public static void toggleOpenArchiveOnPull() { |
| 489 | openArchiveOnPull = !openArchiveOnPull; |
| 490 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 491 | SharedPreferences.Editor editor = preferences.edit(); |
| 492 | editor.putBoolean("openArchiveOnPull", openArchiveOnPull); |
| 493 | editor.apply(); |
| 494 | } |
| 495 | |
| 496 | /*public static void toggleShowHiddenFeature() { |
| 497 | showHiddenFeature = !showHiddenFeature; |
| 498 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 499 | SharedPreferences.Editor editor = preferences.edit(); |
| 500 | editor.putBoolean("showHiddenFeature", showHiddenFeature); |
| 501 | editor.commit(); |
| 502 | } */ |
| 503 | |
| 504 | public static void toggleHideKeyboardOnChatScroll() { |
| 505 | hideKeyboardOnChatScroll = !hideKeyboardOnChatScroll; |
| 506 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 507 | SharedPreferences.Editor editor = preferences.edit(); |
| 508 | editor.putBoolean("hideKeyboardOnChatScroll", hideKeyboardOnChatScroll); |
| 509 | editor.apply(); |
| 510 | } |
| 511 | |
| 512 | public static void toggleAvatarAsDrawerBackground() { |
| 513 | avatarAsDrawerBackground = !avatarAsDrawerBackground; |
| 514 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 515 | SharedPreferences.Editor editor = preferences.edit(); |
| 516 | editor.putBoolean("avatarAsDrawerBackground", avatarAsDrawerBackground); |
| 517 | editor.apply(); |
| 518 | } |
| 519 | |
| 520 | public static void toggleUseSystemEmoji() { |
| 521 | preferences.edit().putBoolean("useSystemEmoji", useSystemEmoji = !useSystemEmoji).apply(); |
| 522 | } |
| 523 | |
| 524 | public static void toggleDisableChatAction() { |
| 525 | preferences.edit().putBoolean("disable_chat_action", disableChatAction = !disableChatAction).apply(); |
| 526 | } |
| 527 | |
| 528 | public static void toggleSortByUnread() { |
| 529 | |
| 530 | preferences.edit().putBoolean("sort_by_unread", sortByUnread = !sortByUnread).apply(); |
| 531 | |
| 532 | } |
| 533 | |
| 534 | public static void toggleShowTabsOnForward() { |
| 535 | showTabsOnForward = !showTabsOnForward; |
| 536 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 537 | SharedPreferences.Editor editor = preferences.edit(); |
| 538 | editor.putBoolean("showTabsOnForward", showTabsOnForward); |
| 539 | editor.apply(); |
| 540 | } |
| 541 | |
| 542 | public static void toggleRearVideoMessages() { |
| 543 | rearVideoMessages = !rearVideoMessages; |
| 544 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 545 | SharedPreferences.Editor editor = preferences.edit(); |
| 546 | editor.putBoolean("rearVideoMessages", rearVideoMessages); |
| 547 | editor.apply(); |
| 548 | } |
| 549 | |
| 550 | public static void toggleHideAllTab() { |
| 551 | hideAllTab = !hideAllTab; |
| 552 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 553 | SharedPreferences.Editor editor = preferences.edit(); |
| 554 | editor.putBoolean("hideAllTab", hideAllTab); |
| 555 | editor.apply(); |
| 556 | } |
| 557 | |
| 558 | public static void toggleSortByUnmuted() { |
| 559 | |
| 560 | preferences.edit().putBoolean("sort_by_unmuted", sortByUnmuted = !sortByUnmuted).apply(); |
| 561 | |
| 562 | } |
| 563 | |
| 564 | public static void toggleSortByUser() { |
| 565 | |
| 566 | preferences.edit().putBoolean("sort_by_user", sortByUser = !sortByUser).apply(); |
| 567 | |
| 568 | } |
| 569 | |
| 570 | public static void toggleSortByContacts() { |
| 571 | |
| 572 | preferences.edit().putBoolean("sort_by_contacts", sortByContacts = !sortByContacts).apply(); |
| 573 | |
| 574 | } |
| 575 | |
| 576 | public static void toggleDisableUndo() { |
| 577 | |
| 578 | preferences.edit().putBoolean("disable_undo", disableUndo = !disableUndo).apply(); |
| 579 | |
| 580 | } |
| 581 | |
| 582 | public static void toggleFilterUsers() { |
| 583 | |
| 584 | preferences.edit().putBoolean("filter_users", filterUsers = !filterUsers).apply(); |
| 585 | |
| 586 | } |
| 587 | |
| 588 | public static void toggleFilterContacts() { |
| 589 | |
| 590 | preferences.edit().putBoolean("filter_contacts", filterContacts = !filterContacts).apply(); |
| 591 | |
| 592 | } |
| 593 | |
| 594 | public static void toggleFilterGroups() { |
| 595 | |
| 596 | preferences.edit().putBoolean("filterGroups", filterGroups = !filterGroups).apply(); |
| 597 | |
| 598 | } |
| 599 | |
| 600 | public static void toggleFilterChannels() { |
| 601 | |
| 602 | preferences.edit().putBoolean("filter_channels", filterChannels = !filterChannels).apply(); |
| 603 | |
| 604 | } |
| 605 | |
| 606 | public static void toggleFilterBots() { |
| 607 | |
| 608 | preferences.edit().putBoolean("filter_bots", filterBots = !filterBots).apply(); |
| 609 | |
| 610 | } |
| 611 | |
| 612 | public static void toggleFilterAdmins() { |
| 613 | |
| 614 | preferences.edit().putBoolean("filter_admins", filterAdmins = !filterAdmins).apply(); |
| 615 | |
| 616 | } |
| 617 | |
| 618 | public static void toggleFilterUnmuted() { |
| 619 | |
| 620 | preferences.edit().putBoolean("filter_unmuted", filterUnmuted = !filterUnmuted).apply(); |
| 621 | |
| 622 | } |
| 623 | |
| 624 | public static void toggleDisableFilterUnread() { |
| 625 | |
| 626 | preferences.edit().putBoolean("filter_unread", filterUnread = !filterUnread).apply(); |
| 627 | |
| 628 | } |
| 629 | |
| 630 | public static void toggleFilterUnmutedAndUnread() { |
| 631 | |
| 632 | preferences.edit().putBoolean("filter_unmuted_and_unread", filterUnmutedAndUnread = !filterUnmutedAndUnread).apply(); |
| 633 | |
| 634 | } |
| 635 | |
| 636 | public static void toggleDisableSystemAccount() { |
| 637 | |
| 638 | preferences.edit().putBoolean("disable_system_account", disableSystemAccount = !disableSystemAccount).apply(); |
| 639 | |
| 640 | } |
| 641 | |
| 642 | public static void toggleDisableProxyWhenVpnEnabled() { |
| 643 | |
| 644 | preferences.edit().putBoolean("disable_proxy_when_vpn_enabled", disableProxyWhenVpnEnabled = !disableProxyWhenVpnEnabled).apply(); |
| 645 | |
| 646 | } |
| 647 | |
| 648 | public static void toggleSkipOpenLinkConfirm() { |
| 649 | |
| 650 | preferences.edit().putBoolean("skip_open_link_confirm", skipOpenLinkConfirm = !skipOpenLinkConfirm).apply(); |
| 651 | |
| 652 | } |
| 653 | |
| 654 | public static void toggleRemoveTitleEmoji() { |
| 655 | |
| 656 | preferences.edit().putBoolean("remove_title_emoji", removeTitleEmoji = !removeTitleEmoji).apply(); |
| 657 | |
| 658 | } |
| 659 | |
| 660 | public static void toggleIgnoredMutedCount() { |
| 661 | |
| 662 | preferences.edit().putBoolean("ignore_muted_count", ignoreMutedCount = !ignoreMutedCount).apply(); |
| 663 | |
| 664 | } |
| 665 | |
| 666 | public static void toggleUseDefaultTheme() { |
| 667 | |
| 668 | preferences.edit().putBoolean("use_default_theme", useDefaultTheme = !useDefaultTheme).apply(); |
| 669 | |
| 670 | } |
| 671 | |
| 672 | public static void toggleShowIdAndDc() { |
| 673 | |
| 674 | preferences.edit().putBoolean("show_id_and_dc", showIdAndDc = !showIdAndDc).apply(); |
| 675 | |
| 676 | } |
| 677 | |
| 678 | public static void setGoogleTranslateKey(String key) { |
| 679 | |
| 680 | preferences.edit().putString("google_cloud_translate_key", googleCloudTranslateKey = key).apply(); |
| 681 | |
| 682 | } |
| 683 | |
| 684 | public static void setCachePath(String cachePath) { |
| 685 | |
| 686 | preferences.edit().putString("cache_path", NekoConfig.cachePath = cachePath).apply(); |
| 687 | |
| 688 | } |
| 689 | |
| 690 | public static void setTranslateToLang(String toLang) { |
| 691 | |
| 692 | preferences.edit().putString("trans_to_lang", translateToLang = toLang).apply(); |
| 693 | |
| 694 | } |
| 695 | |
| 696 | public static void setTranslateInputToLang(String toLang) { |
| 697 | |
| 698 | preferences.edit().putString("trans_input_to_lang", translateInputLang = toLang).apply(); |
| 699 | |
| 700 | } |
| 701 | |
| 702 | public static void setTabsTitleType(int type) { |
| 703 | |
| 704 | preferences.edit().putInt("tabsTitleType", tabsTitleType = type).apply(); |
| 705 | |
| 706 | } |
| 707 | |
| 708 | public static void toggleConfirmAVMessage() { |
| 709 | |
| 710 | preferences.edit().putBoolean("confirmAVMessage", confirmAVMessage = !confirmAVMessage).apply(); |
| 711 | |
| 712 | } |
| 713 | |
| 714 | public static void toggleAskBeforeCall() { |
| 715 | |
| 716 | preferences.edit().putBoolean("askBeforeCall", askBeforeCall = !askBeforeCall).apply(); |
| 717 | |
| 718 | } |
| 719 | |
| 720 | public static void toggleHideProxyByDefault() { |
| 721 | |
| 722 | preferences.edit().putBoolean("hide_proxy_by_default", hideProxyByDefault = !hideProxyByDefault).apply(); |
| 723 | |
| 724 | NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxySettingsChanged); |
| 725 | |
| 726 | } |
| 727 | |
| 728 | public static void toggleUseProxyItem() { |
| 729 | |
| 730 | preferences.edit().putBoolean("use_proxy_item",useProxyItem = !useProxyItem).apply(); |
| 731 | |
| 732 | NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxySettingsChanged); |
| 733 | |
| 734 | } |
| 735 | |
| 736 | public static void toggleDisableNumberRounding() { |
| 737 | |
| 738 | preferences.edit().putBoolean("disableNumberRounding",disableNumberRounding = !disableNumberRounding).apply(); |
| 739 | |
| 740 | } |
| 741 | |
| 742 | public static void toggleDisableAppBarShadow() { |
| 743 | |
| 744 | preferences.edit().putBoolean("disableAppBarShadow",disableAppBarShadow = !disableAppBarShadow).apply(); |
| 745 | |
| 746 | } |
| 747 | |
| 748 | public static void toggleMediaPreview() { |
| 749 | |
| 750 | preferences.edit().putBoolean("mediaPreview",mediaPreview = !mediaPreview).apply(); |
| 751 | |
| 752 | } |
| 753 | |
| 754 | public static void toggleProxyAutoSwitch() { |
| 755 | |
| 756 | preferences.edit().putBoolean("proxy_auto_switch",proxyAutoSwitch = !proxyAutoSwitch).apply(); |
| 757 | |
| 758 | } |
| 759 | |
| 760 | public static void setOpenPGPApp(String packageName) { |
| 761 | |
| 762 | preferences.edit().putString("openPGPApp",openPGPApp = packageName).apply(); |
| 763 | |
| 764 | } |
| 765 | |
| 766 | public static void setOpenPGPKeyId(long keyId) { |
| 767 | |
| 768 | preferences.edit().putLong("openPGPKeyId",openPGPKeyId = keyId).apply(); |
| 769 | |
| 770 | } |
| 771 | |
| 772 | public static void toggleDisableVibration() { |
| 773 | |
| 774 | preferences.edit().putBoolean("disableVibration",disableVibration = !disableVibration).apply(); |
| 775 | |
| 776 | } |
| 777 | |
| 778 | public static void toggleAutoPauseVideo() { |
| 779 | |
| 780 | preferences.edit().putBoolean("autoPauseVideo",autoPauseVideo = !autoPauseVideo).apply(); |
| 781 | |
| 782 | } |
| 783 | |
| 784 | public static void toggleDisableProximityEvents() { |
| 785 | |
| 786 | preferences.edit().putBoolean("disableProximityEvents",disableProximityEvents = !disableProximityEvents).apply(); |
| 787 | |
| 788 | } |
| 789 | |
| 790 | public static void toggleIgnoreContentRestrictions() { |
| 791 | |
| 792 | preferences.edit().putBoolean("ignoreContentRestrictions",ignoreContentRestrictions = !ignoreContentRestrictions).apply(); |
| 793 | |
| 794 | } |
| 795 | |
| 796 | public static void toggleUseChatAttachMediaMenu() { |
| 797 | |
| 798 | preferences.edit().putBoolean("useChatAttachMediaMenu",useChatAttachMediaMenu = !useChatAttachMediaMenu).apply(); |
| 799 | |
| 800 | } |
| 801 | |
| 802 | public static void toggleDisableLinkPreviewByDefault() { |
| 803 | |
| 804 | preferences.edit().putBoolean("disableLinkPreviewByDefault", disableLinkPreviewByDefault = !disableLinkPreviewByDefault).apply(); |
| 805 | |
| 806 | } |
| 807 | |
| 808 | public static void toggleSendCommentAfterForward() { |
| 809 | |
| 810 | preferences.edit().putBoolean("sendCommentAfterForward", sendCommentAfterForward = !sendCommentAfterForward).apply(); |
| 811 | |
| 812 | } |
| 813 | |
| 814 | public static void setCCToLang(String toLang) { |
| 815 | |
| 816 | preferences.edit().putString("opencc_to_lang", ccToLang = toLang).apply(); |
| 817 | |
| 818 | } |
| 819 | |
| 820 | public static void setCCInputToLang(String toLang) { |
| 821 | |
| 822 | preferences.edit().putString("opencc_input_to_lang", ccInputLang = toLang).apply(); |
| 823 | |
| 824 | } |
| 825 | |
| 826 | |
| 827 | } |