| 1 | package tw.nekomimi.nekogram; |
| 2 | |
| 3 | import android.content.SharedPreferences; |
| 4 | |
| 5 | import org.telegram.messenger.BuildConfig; |
| 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 | public static boolean enableStickerPin = preferences.getBoolean("enableStickerPin", false); |
| 27 | |
| 28 | |
| 29 | public static void toggleDeveloperMode() { |
| 30 | |
| 31 | preferences.edit().putBoolean("developer_mode", developerMode = !developerMode).apply(); |
| 32 | |
| 33 | if (!developerMode) { |
| 34 | |
| 35 | preferences.edit() |
| 36 | .putBoolean("disable_flag_secure", disableFlagSecure = false) |
| 37 | .putBoolean("disable_screenshot_detection", disableScreenshotDetection = false) |
| 38 | .putBoolean("disable_status_update", disableStatusUpdate = false) |
| 39 | .apply(); |
| 40 | |
| 41 | |
| 42 | } |
| 43 | |
| 44 | } |
| 45 | |
| 46 | public static void toggleDisableFlagSecure() { |
| 47 | |
| 48 | preferences.edit().putBoolean("disable_flag_secure", disableFlagSecure = !disableFlagSecure).apply(); |
| 49 | |
| 50 | } |
| 51 | |
| 52 | public static void toggleDisableScreenshotDetection() { |
| 53 | |
| 54 | preferences.edit().putBoolean("disable_screenshot_detection", disableScreenshotDetection = !disableScreenshotDetection).apply(); |
| 55 | |
| 56 | } |
| 57 | |
| 58 | public static int customApi = preferences.getInt("custom_api", 0); |
| 59 | public static int customAppId = preferences.getInt("custom_app_id", 0); |
| 60 | public static String customAppHash = preferences.getString("custom_app_hash", ""); |
| 61 | |
| 62 | public static int currentAppId() { |
| 63 | |
| 64 | switch (customApi) { |
| 65 | |
| 66 | case 0: |
| 67 | return BuildConfig.APP_ID; |
| 68 | case 1: |
| 69 | return BuildVars.OFFICAL_APP_ID; |
| 70 | case 2: |
| 71 | return BuildVars.TGX_APP_ID; |
| 72 | default: |
| 73 | return customAppId; |
| 74 | |
| 75 | } |
| 76 | |
| 77 | } |
| 78 | |
| 79 | public static String currentAppHash() { |
| 80 | |
| 81 | switch (customApi) { |
| 82 | |
| 83 | case 0: |
| 84 | return BuildConfig.APP_HASH; |
| 85 | case 1: |
| 86 | return BuildVars.OFFICAL_APP_HASH; |
| 87 | case 2: |
| 88 | return BuildVars.TGX_APP_HASH; |
| 89 | default: |
| 90 | return customAppHash; |
| 91 | |
| 92 | } |
| 93 | |
| 94 | } |
| 95 | |
| 96 | public static void saveCustomApi() { |
| 97 | |
| 98 | preferences.edit() |
| 99 | .putInt("custom_api", customApi) |
| 100 | .putInt("custom_app_id", customAppId) |
| 101 | .putString("custom_app_hash", customAppHash) |
| 102 | .apply(); |
| 103 | |
| 104 | } |
| 105 | |
| 106 | public static String customDcIpv4 = preferences.getString("custom_dc_v4", ""); |
| 107 | public static String customDcIpv6 = preferences.getString("custom_dc_v6", ""); |
| 108 | public static int customDcPort = preferences.getInt("custom_dc_port", 0); |
| 109 | public static int customDcLayer = preferences.getInt("custom_dc_layer", 0); |
| 110 | |
| 111 | public static String customDcPublicKey = preferences.getString("custom_dc_public_key", ""); |
| 112 | public static long customDcFingerprint = preferences.getLong("custom_dc_fingerprint", 0L); |
| 113 | |
| 114 | public static void saveCustomDc() { |
| 115 | |
| 116 | preferences.edit() |
| 117 | .putString("custom_dc_v4", customDcIpv4) |
| 118 | .putString("custom_dc_v6", customDcIpv6) |
| 119 | .putInt("custom_dc_port", customDcPort) |
| 120 | .putInt("custom_dc_layer", customDcLayer) |
| 121 | .putString("custom_dc_public_key", customDcPublicKey) |
| 122 | .putLong("custom_dc_fingerprint", customDcFingerprint) |
| 123 | .apply(); |
| 124 | |
| 125 | } |
| 126 | |
| 127 | public static void toggleDisableStatusUpdate() { |
| 128 | |
| 129 | preferences.edit().putBoolean("disable_status_update", disableStatusUpdate = !disableStatusUpdate).apply(); |
| 130 | |
| 131 | NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.updateUserStatus, (Object) null); |
| 132 | |
| 133 | } |
| 134 | |
| 135 | public static void toggleKeepOnlineStatus() { |
| 136 | |
| 137 | preferences.edit().putBoolean("keepOnlineStatus", keepOnlineStatus = !keepOnlineStatus).apply(); |
| 138 | |
| 139 | NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.updateUserStatus, (Object) null); |
| 140 | |
| 141 | } |
| 142 | |
| 143 | public static void toggleEnableStickerPin() { |
| 144 | |
| 145 | preferences.edit().putBoolean("enableStickerPin", enableStickerPin = !enableStickerPin).apply(); |
| 146 | |
| 147 | } |
| 148 | |
| 149 | |
| 150 | } |