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