| 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 cn.hutool.core.date.DatePattern; |
| 10 | import cn.hutool.core.date.DateTime; |
| 11 | import tw.nekomimi.nekogram.database.NitritesKt; |
| 12 | |
| 13 | public class NekoXConfig { |
| 14 | |
| 15 | // public static String FAQ_URL = "https://telegra.ph/NekoX-FAQ-03-31"; |
| 16 | public static String FAQ_URL = "https://github.com/NekoX-Dev/NekoX#faq"; |
| 17 | public static long[] officialChats = { |
| 18 | 1305127566, // NekoX Updates |
| 19 | 1151172683, // NekoX Chat |
| 20 | 1299578049, // NekoX Chat Channel |
| 21 | 1137038259, // NekoX APKs |
| 22 | }; |
| 23 | |
| 24 | public static long[] developers = { |
| 25 | 896711046, // nekohasekai |
| 26 | 380570774, // Haruhi |
| 27 | 601890953, // Nekomura Aoi |
| 28 | }; |
| 29 | |
| 30 | public static SharedPreferences preferences = NitritesKt.openMainSharedPreference("nekox_config"); |
| 31 | |
| 32 | public static boolean developerModeEntrance; |
| 33 | public static boolean developerMode = preferences.getBoolean("developer_mode", false); |
| 34 | |
| 35 | public static boolean disableFlagSecure = preferences.getBoolean("disable_flag_secure", false); |
| 36 | public static boolean disableScreenshotDetection = preferences.getBoolean("disable_screenshot_detection", false); |
| 37 | |
| 38 | public static boolean disableStatusUpdate = preferences.getBoolean("disable_status_update", false); |
| 39 | public static boolean keepOnlineStatus = preferences.getBoolean("keepOnlineStatus", false); |
| 40 | |
| 41 | public static int autoUpdateReleaseChannel = preferences.getInt("autoUpdateReleaseChannel", 2); |
| 42 | public static String ignoredUpdateTag = preferences.getString("ignoredUpdateTag", ""); |
| 43 | public static long nextUpdateCheck = preferences.getLong("nextUpdateCheckTimestamp", 0); |
| 44 | |
| 45 | |
| 46 | public static void toggleDeveloperMode() { |
| 47 | |
| 48 | preferences.edit().putBoolean("developer_mode", developerMode = !developerMode).apply(); |
| 49 | |
| 50 | if (!developerMode) { |
| 51 | |
| 52 | preferences.edit() |
| 53 | .putBoolean("disable_flag_secure", disableFlagSecure = false) |
| 54 | .putBoolean("disable_screenshot_detection", disableScreenshotDetection = false) |
| 55 | .putBoolean("disable_status_update", disableStatusUpdate = false) |
| 56 | .apply(); |
| 57 | |
| 58 | |
| 59 | } |
| 60 | |
| 61 | } |
| 62 | |
| 63 | public static void toggleDisableFlagSecure() { |
| 64 | |
| 65 | preferences.edit().putBoolean("disable_flag_secure", disableFlagSecure = !disableFlagSecure).apply(); |
| 66 | |
| 67 | } |
| 68 | |
| 69 | public static void toggleDisableScreenshotDetection() { |
| 70 | |
| 71 | preferences.edit().putBoolean("disable_screenshot_detection", disableScreenshotDetection = !disableScreenshotDetection).apply(); |
| 72 | |
| 73 | } |
| 74 | |
| 75 | public static int customApi = preferences.getInt("custom_api", 0); |
| 76 | public static int customAppId = preferences.getInt("custom_app_id", 0); |
| 77 | public static String customAppHash = preferences.getString("custom_app_hash", ""); |
| 78 | |
| 79 | public static int currentAppId() { |
| 80 | |
| 81 | switch (customApi) { |
| 82 | |
| 83 | case 0: |
| 84 | return BuildConfig.APP_ID; |
| 85 | case 1: |
| 86 | return BuildVars.OFFICAL_APP_ID; |
| 87 | case 2: |
| 88 | return BuildVars.TGX_APP_ID; |
| 89 | default: |
| 90 | return customAppId; |
| 91 | |
| 92 | } |
| 93 | |
| 94 | } |
| 95 | |
| 96 | public static String currentAppHash() { |
| 97 | |
| 98 | switch (customApi) { |
| 99 | |
| 100 | case 0: |
| 101 | return BuildConfig.APP_HASH; |
| 102 | case 1: |
| 103 | return BuildVars.OFFICAL_APP_HASH; |
| 104 | case 2: |
| 105 | return BuildVars.TGX_APP_HASH; |
| 106 | default: |
| 107 | return customAppHash; |
| 108 | |
| 109 | } |
| 110 | |
| 111 | } |
| 112 | |
| 113 | public static void saveCustomApi() { |
| 114 | |
| 115 | preferences.edit() |
| 116 | .putInt("custom_api", customApi) |
| 117 | .putInt("custom_app_id", customAppId) |
| 118 | .putString("custom_app_hash", customAppHash) |
| 119 | .apply(); |
| 120 | |
| 121 | } |
| 122 | |
| 123 | public static String customDcIpv4 = preferences.getString("custom_dc_v4", ""); |
| 124 | public static String customDcIpv6 = preferences.getString("custom_dc_v6", ""); |
| 125 | public static int customDcPort = preferences.getInt("custom_dc_port", 0); |
| 126 | public static int customDcLayer = preferences.getInt("custom_dc_layer", 0); |
| 127 | |
| 128 | public static String customDcPublicKey = preferences.getString("custom_dc_public_key", ""); |
| 129 | public static long customDcFingerprint = preferences.getLong("custom_dc_fingerprint", 0L); |
| 130 | |
| 131 | public static void saveCustomDc() { |
| 132 | |
| 133 | preferences.edit() |
| 134 | .putString("custom_dc_v4", customDcIpv4) |
| 135 | .putString("custom_dc_v6", customDcIpv6) |
| 136 | .putInt("custom_dc_port", customDcPort) |
| 137 | .putInt("custom_dc_layer", customDcLayer) |
| 138 | .putString("custom_dc_public_key", customDcPublicKey) |
| 139 | .putLong("custom_dc_fingerprint", customDcFingerprint) |
| 140 | .apply(); |
| 141 | |
| 142 | } |
| 143 | |
| 144 | public static void toggleDisableStatusUpdate() { |
| 145 | |
| 146 | preferences.edit().putBoolean("disable_status_update", disableStatusUpdate = !disableStatusUpdate).apply(); |
| 147 | |
| 148 | NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.updateUserStatus, (Object) null); |
| 149 | |
| 150 | } |
| 151 | |
| 152 | public static void toggleKeepOnlineStatus() { |
| 153 | |
| 154 | preferences.edit().putBoolean("keepOnlineStatus", keepOnlineStatus = !keepOnlineStatus).apply(); |
| 155 | |
| 156 | NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.updateUserStatus, (Object) null); |
| 157 | |
| 158 | } |
| 159 | |
| 160 | public static void setAutoUpdateReleaseChannel(int channel) { |
| 161 | preferences.edit().putInt("autoUpdateReleaseChannel", autoUpdateReleaseChannel = channel).apply(); |
| 162 | } |
| 163 | |
| 164 | public static void setIgnoredUpdateTag(String ignored) { |
| 165 | preferences.edit().putString("ignoredUpdateTag", ignoredUpdateTag = ignored).apply(); |
| 166 | } |
| 167 | |
| 168 | public static void setNextUpdateCheck(long timestamp) { |
| 169 | preferences.edit().putLong("nextUpdateCheckTimestamp", nextUpdateCheck = timestamp).apply(); |
| 170 | } |
| 171 | |
| 172 | } |