| 6 | import org.telegram.messenger.BuildVars; |
| 7 | import org.telegram.messenger.NotificationCenter; |
| 8 |
| 9 | import tw.nekomimi.nekogram.database.NitritesKt; |
| 10 |
| 11 | public class NekoXConfig { |
| 12 |
| 13 | public static String FAQ_URL = "https://telegra.ph/NekoX-FAQ-03-31"; |
| 14 |
| 15 | public static SharedPreferences preferences = NitritesKt.openMainSharedPreference("nekox_config"); |
| 16 |
| 17 | public static boolean developerModeEntrance; |
| 18 | public static boolean developerMode = preferences.getBoolean("developer_mode", false); |
| 19 |
| 20 | public static boolean disableFlagSecure = preferences.getBoolean("disable_flag_secure", false); |
| 21 | public static boolean disableScreenshotDetection = preferences.getBoolean("disable_screenshot_detection", false); |
| 22 |
| 23 | public static boolean disableStatusUpdate = preferences.getBoolean("disable_status_update", false); |
| 24 | public static boolean keepOnlineStatus = preferences.getBoolean("keepOnlineStatus", false); |
| 25 |
| 26 |
| 27 | public static void toggleDeveloperMode() { |
| 28 |
| 29 | preferences.edit().putBoolean("developer_mode", developerMode = !developerMode).apply(); |
| 30 |
| 31 | if (!developerMode) { |
| 32 |
| 33 | preferences.edit() |
| 34 | .putBoolean("disable_flag_secure", disableFlagSecure = false) |
| 35 | .putBoolean("disable_screenshot_detection", disableScreenshotDetection = false) |
| 36 | .putBoolean("disable_status_update", disableStatusUpdate = false) |
| 37 | .apply(); |
| 38 |
| 39 |
| 40 | } |
| 41 |
| 42 | } |
| 43 |
| 44 | public static void toggleDisableFlagSecure() { |
| 45 |
| 46 | preferences.edit().putBoolean("disable_flag_secure", disableFlagSecure = !disableFlagSecure).apply(); |
| 47 |
| 48 | } |
| 49 |
| 50 | public static void toggleDisableScreenshotDetection() { |
| 51 |
| 52 | preferences.edit().putBoolean("disable_screenshot_detection", disableScreenshotDetection = !disableScreenshotDetection).apply(); |
| 53 |
| 54 | } |
| 55 |
| 56 | public static int customApi = preferences.getInt("custom_api", 0); |
| 57 | public static int customAppId = preferences.getInt("custom_app_id", 0); |
| 58 | public static String customAppHash = preferences.getString("custom_app_hash", ""); |
| 59 |
| 60 | public static int currentAppId() { |
| 61 |
| 62 | switch (customApi) { |
| 63 |
| 64 | case 0: |
| 65 | return BuildConfig.APP_ID; |
| 66 | case 1: |
| 67 | return BuildVars.OFFICAL_APP_ID; |
| 68 | case 2: |
| 69 | return BuildVars.TGX_APP_ID; |
| 70 | default: |
| 71 | return customAppId; |
| 72 |
| 73 | } |
| 74 |
| 75 | } |
| 76 |
| 77 | public static String currentAppHash() { |
| 78 |
| 79 | switch (customApi) { |
| 80 |
| 81 | case 0: |
| 82 | return BuildConfig.APP_HASH; |
| 83 | case 1: |
| 84 | return BuildVars.OFFICAL_APP_HASH; |
| 85 | case 2: |
| 86 | return BuildVars.TGX_APP_HASH; |
| 87 | default: |
| 88 | return customAppHash; |
| 89 |
| 90 | } |
| 91 |
| 92 | } |
| 93 |
| 94 | public static void saveCustomApi() { |
| 95 |
| 96 | preferences.edit() |
| 97 | .putInt("custom_api", customApi) |
| 98 | .putInt("custom_app_id", customAppId) |
| 99 | .putString("custom_app_hash", customAppHash) |
| 100 | .apply(); |
| 101 |
| 102 | } |
| 103 |
| 104 | public static String customDcIpv4 = preferences.getString("custom_dc_v4", ""); |
| 105 | public static String customDcIpv6 = preferences.getString("custom_dc_v6", ""); |
| 106 | public static int customDcPort = preferences.getInt("custom_dc_port", 0); |
| 107 | public static int customDcLayer = preferences.getInt("custom_dc_layer", 0); |
| 108 |
| 109 | public static String customDcPublicKey = preferences.getString("custom_dc_public_key", ""); |
| 110 | public static long customDcFingerprint = preferences.getLong("custom_dc_fingerprint", 0L); |
| 111 |
| 112 | public static void saveCustomDc() { |
| 113 |
| 114 | preferences.edit() |
| 115 | .putString("custom_dc_v4", customDcIpv4) |
| 116 | .putString("custom_dc_v6", customDcIpv6) |
| 117 | .putInt("custom_dc_port", customDcPort) |
| 118 | .putInt("custom_dc_layer", customDcLayer) |
| 119 | .putString("custom_dc_public_key", customDcPublicKey) |
| 120 | .putLong("custom_dc_fingerprint", customDcFingerprint) |
| 121 | .apply(); |
| 122 |
| 123 | } |
| 124 |
| 125 | public static void toggleDisableStatusUpdate() { |
| 126 |
| 127 | preferences.edit().putBoolean("disable_status_update", disableStatusUpdate = !disableStatusUpdate).apply(); |
| 128 |
| 129 | NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.updateUserStatus, (Object) null); |
| 130 |
| 131 | } |
| 132 |
| 133 | public static void toggleKeepOnlineStatus() { |
| 134 |
| 135 | preferences.edit().putBoolean("keepOnlineStatus", keepOnlineStatus = !keepOnlineStatus).apply(); |
| 136 |
| 137 | NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.updateUserStatus, (Object) null); |
| 138 |
| 139 | } |
| 140 |
| 141 |
| 142 | } |