| 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.Intent; |
| 7 | import android.content.SharedPreferences; |
| 8 | import android.os.Build; |
| 9 | |
| 10 | import org.telegram.messenger.ApplicationLoader; |
| 11 | import org.telegram.messenger.FileLog; |
| 12 | import org.telegram.messenger.NotificationsService; |
| 13 | import org.telegram.messenger.SharedConfig; |
| 14 | |
| 15 | @SuppressLint("ApplySharedPref") |
| 16 | public class NekoConfig { |
| 17 | |
| 18 | public static final int TITLE_TYPE_TEXT = 0; |
| 19 | public static final int TITLE_TYPE_ICON = 1; |
| 20 | public static final int TITLE_TYPE_MIX = 2; |
| 21 | |
| 22 | private static final Object sync = new Object(); |
| 23 | public static boolean useIPv6 = false; |
| 24 | public static boolean showHiddenFeature = false; |
| 25 | |
| 26 | public static boolean useSystemEmoji = SharedConfig.useSystemEmoji; |
| 27 | public static boolean ignoreBlocked = false; |
| 28 | public static boolean hideProxySponsorChannel = false; |
| 29 | public static boolean saveCacheToPrivateDirectory = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N; |
| 30 | public static boolean disablePhotoSideAction = true; |
| 31 | public static boolean hideKeyboardOnChatScroll = false; |
| 32 | public static boolean rearVideoMessages = false; |
| 33 | public static boolean hideAllTab = false; |
| 34 | public static boolean confirmAVMessage = true; |
| 35 | public static boolean askBeforeCall = true; |
| 36 | public static boolean disableNumberRounding = false; |
| 37 | public static int mapPreviewProvider = 0; |
| 38 | public static float stickerSize = 14.0f; |
| 39 | public static int translationProvider = 1; |
| 40 | public static int tabsTitleType = TITLE_TYPE_TEXT; |
| 41 | |
| 42 | public static boolean showAddToSavedMessages = true; |
| 43 | public static boolean showReport = false; |
| 44 | public static boolean showPrPr = false; |
| 45 | public static boolean showViewHistory = true; |
| 46 | public static boolean showAdminActions = true; |
| 47 | public static boolean showChangePermissions = true; |
| 48 | public static boolean showDeleteDownloadedFile = true; |
| 49 | public static boolean showMessageDetails = false; |
| 50 | public static boolean showTranslate = true; |
| 51 | public static boolean showRepeat = true; |
| 52 | |
| 53 | public static boolean hidePhone = true; |
| 54 | public static int typeface = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? 1 : 0; |
| 55 | public static boolean transparentStatusBar = false; |
| 56 | public static boolean forceTablet = false; |
| 57 | public static boolean openArchiveOnPull = false; |
| 58 | public static boolean avatarAsDrawerBackground = false; |
| 59 | public static boolean showTabsOnForward = false; |
| 60 | public static int nameOrder = 1; |
| 61 | public static int eventType = 0; |
| 62 | public static boolean newYear = false; |
| 63 | public static int actionBarDecoration = 0; |
| 64 | public static boolean unlimitedFavedStickers = false; |
| 65 | public static boolean unlimitedPinnedDialogs = false; |
| 66 | public static boolean disableAppBarShadow = false; |
| 67 | public static boolean mediaPreview = false; |
| 68 | |
| 69 | public static boolean residentNotification = false; |
| 70 | |
| 71 | public static boolean shouldNOTTrustMe = false; |
| 72 | |
| 73 | private static boolean configLoaded; |
| 74 | |
| 75 | static { |
| 76 | loadConfig(); |
| 77 | } |
| 78 | |
| 79 | public static void saveConfig() { |
| 80 | synchronized (sync) { |
| 81 | try { |
| 82 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfing", Context.MODE_PRIVATE); |
| 83 | SharedPreferences.Editor editor = preferences.edit(); |
| 84 | editor.putBoolean("useIPv6", useIPv6); |
| 85 | editor.putBoolean("hidePhone", hidePhone); |
| 86 | editor.putBoolean("ignoreBlocked", ignoreBlocked); |
| 87 | editor.putBoolean("forceTablet", forceTablet); |
| 88 | editor.putBoolean("transparentStatusBar", transparentStatusBar); |
| 89 | editor.putBoolean("residentNotification", residentNotification); |
| 90 | editor.putBoolean("hideProxySponsorChannel", hideProxySponsorChannel); |
| 91 | editor.putBoolean("saveCacheToPrivateDirectory", saveCacheToPrivateDirectory); |
| 92 | editor.putBoolean("showAddToSavedMessages", showAddToSavedMessages); |
| 93 | editor.putBoolean("showReport", showReport); |
| 94 | editor.putBoolean("showPrPr", showPrPr); |
| 95 | editor.putBoolean("showViewHistory", showViewHistory); |
| 96 | editor.putBoolean("showAdminActions", showAdminActions); |
| 97 | editor.putBoolean("showChangePermissions", showChangePermissions); |
| 98 | editor.putBoolean("showDeleteDownloadedFile", showDeleteDownloadedFile); |
| 99 | editor.putBoolean("showMessageDetails", showMessageDetails); |
| 100 | editor.putBoolean("showTranslate", showTranslate); |
| 101 | editor.putBoolean("showRepeat", showRepeat); |
| 102 | editor.putBoolean("newYear", newYear); |
| 103 | editor.putBoolean("unlimitedFavedStickers", unlimitedFavedStickers); |
| 104 | editor.putBoolean("unlimitedPinnedDialogs", unlimitedPinnedDialogs); |
| 105 | editor.putBoolean("disablePhotoSideAction", disablePhotoSideAction); |
| 106 | editor.putBoolean("hideKeyboardOnChatScroll", hideKeyboardOnChatScroll); |
| 107 | editor.putBoolean("openArchiveOnPull", openArchiveOnPull); |
| 108 | editor.putBoolean("showHiddenFeature2", showHiddenFeature); |
| 109 | editor.putBoolean("avatarAsDrawerBackground", avatarAsDrawerBackground); |
| 110 | editor.putBoolean("useSystemEmoji", useSystemEmoji); |
| 111 | editor.putBoolean("showTabsOnForward", showTabsOnForward); |
| 112 | editor.putBoolean("rearVideoMessages", rearVideoMessages); |
| 113 | editor.putBoolean("hideAllTab", hideAllTab); |
| 114 | editor.putBoolean("confirmAVMessage", confirmAVMessage); |
| 115 | editor.putBoolean("askBeforeCall", askBeforeCall); |
| 116 | editor.putBoolean("shouldNOTTrustMe", shouldNOTTrustMe); |
| 117 | editor.putBoolean("disableNumberRounding", disableNumberRounding); |
| 118 | editor.putBoolean("disableAppBarShadow", disableAppBarShadow); |
| 119 | editor.putBoolean("mediaPreview", mediaPreview); |
| 120 | editor.putFloat("stickerSize", stickerSize); |
| 121 | editor.putInt("typeface", typeface); |
| 122 | editor.putInt("nameOrder", nameOrder); |
| 123 | editor.putInt("mapPreviewProvider", mapPreviewProvider); |
| 124 | editor.putInt("translationProvider", translationProvider); |
| 125 | editor.putInt("eventType", eventType); |
| 126 | editor.putInt("actionBarDecoration", actionBarDecoration); |
| 127 | editor.putInt("tabsTitleType", tabsTitleType); |
| 128 | editor.commit(); |
| 129 | } catch (Exception e) { |
| 130 | FileLog.e(e); |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | public static void loadConfig() { |
| 136 | synchronized (sync) { |
| 137 | if (configLoaded) { |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 142 | useIPv6 = preferences.getBoolean("useIPv6", false); |
| 143 | hidePhone = preferences.getBoolean("hidePhone", true); |
| 144 | ignoreBlocked = preferences.getBoolean("ignoreBlocked", false); |
| 145 | forceTablet = preferences.getBoolean("forceTablet", false); |
| 146 | typeface = preferences.getInt("typeface", Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? 1 : 0); |
| 147 | nameOrder = preferences.getInt("nameOrder", 1); |
| 148 | mapPreviewProvider = preferences.getInt("mapPreviewProvider", 0); |
| 149 | transparentStatusBar = preferences.getBoolean("transparentStatusBar", false); |
| 150 | residentNotification = preferences.getBoolean("residentNotification", false); |
| 151 | hideProxySponsorChannel = preferences.getBoolean("hideProxySponsorChannel", false); |
| 152 | saveCacheToPrivateDirectory = preferences.getBoolean("saveCacheToPrivateDirectory", Build.VERSION.SDK_INT >= Build.VERSION_CODES.N); |
| 153 | showAddToSavedMessages = preferences.getBoolean("showAddToSavedMessages", true); |
| 154 | showReport = preferences.getBoolean("showReport", false); |
| 155 | showPrPr = preferences.getBoolean("showPrPr", false); |
| 156 | showViewHistory = preferences.getBoolean("showViewHistory", true); |
| 157 | showAdminActions = preferences.getBoolean("showAdminActions", true); |
| 158 | showChangePermissions = preferences.getBoolean("showChangePermissions", true); |
| 159 | showDeleteDownloadedFile = preferences.getBoolean("showDeleteDownloadedFile", true); |
| 160 | showMessageDetails = preferences.getBoolean("showMessageDetails", false); |
| 161 | showTranslate = preferences.getBoolean("showTranslate", true); |
| 162 | showRepeat = preferences.getBoolean("showRepeat", true); |
| 163 | eventType = preferences.getInt("eventType", 0); |
| 164 | actionBarDecoration = preferences.getInt("actionBarDecoration", 0); |
| 165 | newYear = preferences.getBoolean("newYear", false); |
| 166 | stickerSize = preferences.getFloat("stickerSize", 14.0f); |
| 167 | unlimitedFavedStickers = preferences.getBoolean("unlimitedFavedStickers", false); |
| 168 | unlimitedPinnedDialogs = preferences.getBoolean("unlimitedPinnedDialogs", false); |
| 169 | translationProvider = preferences.getInt("translationProvider", 1); |
| 170 | disablePhotoSideAction = preferences.getBoolean("disablePhotoSideAction", true); |
| 171 | openArchiveOnPull = preferences.getBoolean("openArchiveOnPull", false); |
| 172 | showHiddenFeature = preferences.getBoolean("showHiddenFeature2", false); |
| 173 | hideKeyboardOnChatScroll = preferences.getBoolean("hideKeyboardOnChatScroll", false); |
| 174 | avatarAsDrawerBackground = preferences.getBoolean("avatarAsDrawerBackground", false); |
| 175 | useSystemEmoji = preferences.getBoolean("useSystemEmoji", SharedConfig.useSystemEmoji); |
| 176 | showTabsOnForward = preferences.getBoolean("showTabsOnForward", false); |
| 177 | rearVideoMessages = preferences.getBoolean("rearVideoMessages", false); |
| 178 | hideAllTab = preferences.getBoolean("hideAllTab", false); |
| 179 | tabsTitleType = preferences.getInt("tabsTitleType", TITLE_TYPE_TEXT); |
| 180 | confirmAVMessage = preferences.getBoolean("confirmAVMessage", true); |
| 181 | askBeforeCall = preferences.getBoolean("askBeforeCall", true); |
| 182 | shouldNOTTrustMe = preferences.getBoolean("shouldNOTTrustMe", false); |
| 183 | disableNumberRounding = preferences.getBoolean("disableNumberRounding", false); |
| 184 | disableAppBarShadow = preferences.getBoolean("disableAppBarShadow", false); |
| 185 | mediaPreview = preferences.getBoolean("mediaPreview", false); |
| 186 | configLoaded = true; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | public static void toggleShowAddToSavedMessages() { |
| 191 | showAddToSavedMessages = !showAddToSavedMessages; |
| 192 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 193 | SharedPreferences.Editor editor = preferences.edit(); |
| 194 | editor.putBoolean("showAddToSavedMessages", showAddToSavedMessages); |
| 195 | editor.commit(); |
| 196 | } |
| 197 | |
| 198 | public static void toggleShowReport() { |
| 199 | showReport = !showReport; |
| 200 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 201 | SharedPreferences.Editor editor = preferences.edit(); |
| 202 | editor.putBoolean("showReport", showReport); |
| 203 | editor.commit(); |
| 204 | } |
| 205 | |
| 206 | |
| 207 | public static void toggleShowViewHistory() { |
| 208 | showViewHistory = !showViewHistory; |
| 209 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 210 | SharedPreferences.Editor editor = preferences.edit(); |
| 211 | editor.putBoolean("showViewHistory", showViewHistory); |
| 212 | editor.commit(); |
| 213 | } |
| 214 | |
| 215 | public static void toggleShowPrPr() { |
| 216 | showPrPr = !showPrPr; |
| 217 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 218 | SharedPreferences.Editor editor = preferences.edit(); |
| 219 | editor.putBoolean("showPrPr", showPrPr); |
| 220 | editor.commit(); |
| 221 | } |
| 222 | |
| 223 | public static void toggleShowAdminActions() { |
| 224 | showAdminActions = !showAdminActions; |
| 225 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 226 | SharedPreferences.Editor editor = preferences.edit(); |
| 227 | editor.putBoolean("showAdminActions", showAdminActions); |
| 228 | editor.commit(); |
| 229 | } |
| 230 | |
| 231 | public static void toggleShowChangePermissions() { |
| 232 | showChangePermissions = !showChangePermissions; |
| 233 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 234 | SharedPreferences.Editor editor = preferences.edit(); |
| 235 | editor.putBoolean("showChangePermissions", showChangePermissions); |
| 236 | editor.commit(); |
| 237 | } |
| 238 | |
| 239 | public static void toggleShowDeleteDownloadedFile() { |
| 240 | showDeleteDownloadedFile = !showDeleteDownloadedFile; |
| 241 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 242 | SharedPreferences.Editor editor = preferences.edit(); |
| 243 | editor.putBoolean("showDeleteDownloadedFile", showDeleteDownloadedFile); |
| 244 | editor.commit(); |
| 245 | } |
| 246 | |
| 247 | public static void toggleShowMessageDetails() { |
| 248 | showMessageDetails = !showMessageDetails; |
| 249 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 250 | SharedPreferences.Editor editor = preferences.edit(); |
| 251 | editor.putBoolean("showMessageDetails", showMessageDetails); |
| 252 | editor.commit(); |
| 253 | } |
| 254 | |
| 255 | public static void toggleShowRepeat() { |
| 256 | showRepeat = !showRepeat; |
| 257 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 258 | SharedPreferences.Editor editor = preferences.edit(); |
| 259 | editor.putBoolean("showRepeat", showRepeat); |
| 260 | editor.commit(); |
| 261 | } |
| 262 | |
| 263 | public static void toggleIPv6() { |
| 264 | useIPv6 = !useIPv6; |
| 265 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 266 | SharedPreferences.Editor editor = preferences.edit(); |
| 267 | editor.putBoolean("useIPv6", useIPv6); |
| 268 | editor.commit(); |
| 269 | } |
| 270 | |
| 271 | public static void toggleHidePhone() { |
| 272 | hidePhone = !hidePhone; |
| 273 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 274 | SharedPreferences.Editor editor = preferences.edit(); |
| 275 | editor.putBoolean("hidePhone", hidePhone); |
| 276 | editor.commit(); |
| 277 | } |
| 278 | |
| 279 | public static void toggleIgnoreBlocked() { |
| 280 | ignoreBlocked = !ignoreBlocked; |
| 281 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 282 | SharedPreferences.Editor editor = preferences.edit(); |
| 283 | editor.putBoolean("ignoreBlocked", ignoreBlocked); |
| 284 | editor.commit(); |
| 285 | } |
| 286 | |
| 287 | public static void toggleForceTablet() { |
| 288 | forceTablet = !forceTablet; |
| 289 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 290 | SharedPreferences.Editor editor = preferences.edit(); |
| 291 | editor.putBoolean("forceTablet", forceTablet); |
| 292 | editor.commit(); |
| 293 | } |
| 294 | |
| 295 | public static void toggleTypeface() { |
| 296 | typeface = typeface == 0 ? 1 : 0; |
| 297 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 298 | SharedPreferences.Editor editor = preferences.edit(); |
| 299 | editor.putInt("typeface", typeface); |
| 300 | editor.commit(); |
| 301 | } |
| 302 | |
| 303 | public static void setNameOrder(int order) { |
| 304 | nameOrder = order; |
| 305 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 306 | SharedPreferences.Editor editor = preferences.edit(); |
| 307 | editor.putInt("nameOrder", nameOrder); |
| 308 | editor.commit(); |
| 309 | } |
| 310 | |
| 311 | public static void setMapPreviewProvider(int provider) { |
| 312 | mapPreviewProvider = provider; |
| 313 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 314 | SharedPreferences.Editor editor = preferences.edit(); |
| 315 | editor.putInt("mapPreviewProvider", mapPreviewProvider); |
| 316 | editor.commit(); |
| 317 | } |
| 318 | |
| 319 | public static void toggleTransparentStatusBar() { |
| 320 | transparentStatusBar = !transparentStatusBar; |
| 321 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 322 | SharedPreferences.Editor editor = preferences.edit(); |
| 323 | editor.putBoolean("transparentStatusBar", transparentStatusBar); |
| 324 | editor.commit(); |
| 325 | } |
| 326 | |
| 327 | public static void toggleResidentNotification() { |
| 328 | residentNotification = !residentNotification; |
| 329 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 330 | SharedPreferences.Editor editor = preferences.edit(); |
| 331 | editor.putBoolean("residentNotification", residentNotification); |
| 332 | editor.commit(); |
| 333 | ApplicationLoader.applicationContext.stopService(new Intent(ApplicationLoader.applicationContext, NotificationsService.class)); |
| 334 | ApplicationLoader.startPushService(); |
| 335 | } |
| 336 | |
| 337 | public static void toggleHideProxySponsorChannel() { |
| 338 | hideProxySponsorChannel = !hideProxySponsorChannel; |
| 339 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 340 | SharedPreferences.Editor editor = preferences.edit(); |
| 341 | editor.putBoolean("hideProxySponsorChannel", hideProxySponsorChannel); |
| 342 | editor.commit(); |
| 343 | } |
| 344 | |
| 345 | public static void toggleSaveCacheToPrivateDirectory() { |
| 346 | saveCacheToPrivateDirectory = !saveCacheToPrivateDirectory; |
| 347 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 348 | SharedPreferences.Editor editor = preferences.edit(); |
| 349 | editor.putBoolean("saveCacheToPrivateDirectory", saveCacheToPrivateDirectory); |
| 350 | editor.commit(); |
| 351 | } |
| 352 | |
| 353 | public static void setEventType(int type) { |
| 354 | eventType = type; |
| 355 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 356 | SharedPreferences.Editor editor = preferences.edit(); |
| 357 | editor.putInt("eventType", eventType); |
| 358 | editor.commit(); |
| 359 | } |
| 360 | |
| 361 | public static void setActionBarDecoration(int decoration) { |
| 362 | actionBarDecoration = decoration; |
| 363 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 364 | SharedPreferences.Editor editor = preferences.edit(); |
| 365 | editor.putInt("actionBarDecoration", actionBarDecoration); |
| 366 | editor.commit(); |
| 367 | } |
| 368 | |
| 369 | public static void toggleNewYear() { |
| 370 | newYear = !newYear; |
| 371 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 372 | SharedPreferences.Editor editor = preferences.edit(); |
| 373 | editor.putBoolean("newYear", newYear); |
| 374 | editor.commit(); |
| 375 | } |
| 376 | |
| 377 | public static void toggleUnlimitedFavedStickers() { |
| 378 | unlimitedFavedStickers = !unlimitedFavedStickers; |
| 379 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 380 | SharedPreferences.Editor editor = preferences.edit(); |
| 381 | editor.putBoolean("unlimitedFavedStickers", unlimitedFavedStickers); |
| 382 | editor.commit(); |
| 383 | } |
| 384 | |
| 385 | public static void toggleUnlimitedPinnedDialogs() { |
| 386 | unlimitedPinnedDialogs = !unlimitedPinnedDialogs; |
| 387 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 388 | SharedPreferences.Editor editor = preferences.edit(); |
| 389 | editor.putBoolean("unlimitedPinnedDialogs", unlimitedPinnedDialogs); |
| 390 | editor.commit(); |
| 391 | } |
| 392 | |
| 393 | public static void toggleShowTranslate() { |
| 394 | showTranslate = !showTranslate; |
| 395 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 396 | SharedPreferences.Editor editor = preferences.edit(); |
| 397 | editor.putBoolean("showTranslate", showTranslate); |
| 398 | editor.commit(); |
| 399 | } |
| 400 | |
| 401 | public static void setStickerSize(float size) { |
| 402 | stickerSize = size; |
| 403 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 404 | SharedPreferences.Editor editor = preferences.edit(); |
| 405 | editor.putFloat("stickerSize", stickerSize); |
| 406 | editor.commit(); |
| 407 | } |
| 408 | |
| 409 | public static void setTranslationProvider(int provider) { |
| 410 | translationProvider = provider; |
| 411 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 412 | SharedPreferences.Editor editor = preferences.edit(); |
| 413 | editor.putInt("translationProvider", translationProvider); |
| 414 | editor.commit(); |
| 415 | } |
| 416 | |
| 417 | public static void toggleDisablePhotoSideAction() { |
| 418 | disablePhotoSideAction = !disablePhotoSideAction; |
| 419 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 420 | SharedPreferences.Editor editor = preferences.edit(); |
| 421 | editor.putBoolean("disablePhotoSideAction", disablePhotoSideAction); |
| 422 | editor.commit(); |
| 423 | } |
| 424 | |
| 425 | public static void toggleOpenArchiveOnPull() { |
| 426 | openArchiveOnPull = !openArchiveOnPull; |
| 427 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 428 | SharedPreferences.Editor editor = preferences.edit(); |
| 429 | editor.putBoolean("openArchiveOnPull", openArchiveOnPull); |
| 430 | editor.commit(); |
| 431 | } |
| 432 | |
| 433 | public static void toggleShowHiddenFeature() { |
| 434 | showHiddenFeature = !showHiddenFeature; |
| 435 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 436 | SharedPreferences.Editor editor = preferences.edit(); |
| 437 | editor.putBoolean("showHiddenFeature2", showHiddenFeature); |
| 438 | editor.commit(); |
| 439 | } |
| 440 | |
| 441 | public static void toggleHideKeyboardOnChatScroll() { |
| 442 | hideKeyboardOnChatScroll = !hideKeyboardOnChatScroll; |
| 443 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 444 | SharedPreferences.Editor editor = preferences.edit(); |
| 445 | editor.putBoolean("hideKeyboardOnChatScroll", hideKeyboardOnChatScroll); |
| 446 | editor.commit(); |
| 447 | } |
| 448 | |
| 449 | public static void toggleAvatarAsDrawerBackground() { |
| 450 | avatarAsDrawerBackground = !avatarAsDrawerBackground; |
| 451 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 452 | SharedPreferences.Editor editor = preferences.edit(); |
| 453 | editor.putBoolean("avatarAsDrawerBackground", avatarAsDrawerBackground); |
| 454 | editor.commit(); |
| 455 | } |
| 456 | |
| 457 | public static void toggleUseSystemEmoji() { |
| 458 | useSystemEmoji = !useSystemEmoji; |
| 459 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 460 | SharedPreferences.Editor editor = preferences.edit(); |
| 461 | editor.putBoolean("useSystemEmoji", useSystemEmoji); |
| 462 | editor.commit(); |
| 463 | } |
| 464 | |
| 465 | public static void toggleShowTabsOnForward() { |
| 466 | showTabsOnForward = !showTabsOnForward; |
| 467 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 468 | SharedPreferences.Editor editor = preferences.edit(); |
| 469 | editor.putBoolean("showTabsOnForward", showTabsOnForward); |
| 470 | editor.commit(); |
| 471 | } |
| 472 | |
| 473 | public static void toggleRearVideoMessages() { |
| 474 | rearVideoMessages = !rearVideoMessages; |
| 475 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 476 | SharedPreferences.Editor editor = preferences.edit(); |
| 477 | editor.putBoolean("rearVideoMessages", rearVideoMessages); |
| 478 | editor.commit(); |
| 479 | } |
| 480 | |
| 481 | public static void toggleHideAllTab() { |
| 482 | hideAllTab = !hideAllTab; |
| 483 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 484 | SharedPreferences.Editor editor = preferences.edit(); |
| 485 | editor.putBoolean("hideAllTab", hideAllTab); |
| 486 | editor.commit(); |
| 487 | } |
| 488 | |
| 489 | public static void setTabsTitleType(int type) { |
| 490 | tabsTitleType = type; |
| 491 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 492 | SharedPreferences.Editor editor = preferences.edit(); |
| 493 | editor.putInt("tabsTitleType", tabsTitleType); |
| 494 | editor.commit(); |
| 495 | } |
| 496 | |
| 497 | public static void toggleConfirmAVMessage() { |
| 498 | confirmAVMessage = !confirmAVMessage; |
| 499 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 500 | SharedPreferences.Editor editor = preferences.edit(); |
| 501 | editor.putBoolean("confirmAVMessage", confirmAVMessage); |
| 502 | editor.commit(); |
| 503 | } |
| 504 | |
| 505 | public static void toggleAskBeforeCall() { |
| 506 | askBeforeCall = !askBeforeCall; |
| 507 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 508 | SharedPreferences.Editor editor = preferences.edit(); |
| 509 | editor.putBoolean("askBeforeCall", askBeforeCall); |
| 510 | editor.commit(); |
| 511 | } |
| 512 | |
| 513 | public static void toggleShouldNOTTrustMe() { |
| 514 | shouldNOTTrustMe = !shouldNOTTrustMe; |
| 515 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 516 | SharedPreferences.Editor editor = preferences.edit(); |
| 517 | editor.putBoolean("shouldNOTTrustMe", shouldNOTTrustMe); |
| 518 | editor.commit(); |
| 519 | } |
| 520 | |
| 521 | public static void toggleDisableNumberRounding() { |
| 522 | disableNumberRounding = !disableNumberRounding; |
| 523 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 524 | SharedPreferences.Editor editor = preferences.edit(); |
| 525 | editor.putBoolean("disableNumberRounding", disableNumberRounding); |
| 526 | editor.commit(); |
| 527 | } |
| 528 | |
| 529 | public static void toggleDisableAppBarShadow() { |
| 530 | disableAppBarShadow = !disableAppBarShadow; |
| 531 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 532 | SharedPreferences.Editor editor = preferences.edit(); |
| 533 | editor.putBoolean("disableAppBarShadow", disableAppBarShadow); |
| 534 | editor.commit(); |
| 535 | } |
| 536 | |
| 537 | public static void toggleMediaPreview() { |
| 538 | mediaPreview = !mediaPreview; |
| 539 | SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); |
| 540 | SharedPreferences.Editor editor = preferences.edit(); |
| 541 | editor.putBoolean("mediaPreview", mediaPreview); |
| 542 | editor.commit(); |
| 543 | } |
| 544 | } |
| 545 | |