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