1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-11 20:29:26 +01:00

refine Internal Updater

This commit is contained in:
luvletter2333 2022-07-27 17:51:45 +08:00
parent 0462fe9875
commit 0a5c733149
No known key found for this signature in database
GPG Key ID: A26A8880836E1978
3 changed files with 5 additions and 12 deletions

View File

@ -4288,15 +4288,15 @@ public class LaunchActivity extends BasePermissionsActivity implements ActionBar
public void checkAppUpdate(boolean force) {
if (BuildVars.isFdroid || BuildVars.isPlay) return;
if (NekoXConfig.autoUpdateReleaseChannel == 0) return;
if (!force && System.currentTimeMillis() < SharedConfig.lastUpdateCheckTime + 1000L * 60 * 60) return;
SharedConfig.lastUpdateCheckTime = System.currentTimeMillis();
SharedConfig.saveConfig();
if (!force && System.currentTimeMillis() < NekoConfig.lastUpdateCheckTime.Long() + 48 * 60 * 60 * 1000L) return;
NekoConfig.lastUpdateCheckTime.setConfigLong(System.currentTimeMillis());
FileLog.d("checking update");
final int accountNum = currentAccount;
InternalUpdater.checkUpdate((res, error) -> AndroidUtilities.runOnUIThread(() -> {
if (res != null) {
SharedConfig.setNewAppVersionAvailable(res);
SharedConfig.saveConfig();
if (res.can_not_skip) {
showUpdateActivity(accountNum, res, false);
} else {

View File

@ -44,6 +44,7 @@ public class NekoConfig {
public static ConfigItem enablePublicProxy = addConfig("enablePublicProxy", configTypeBool, true);
public static ConfigItem autoUpdateSubInfo = addConfig("autoUpdateSubInfo", configTypeBool, true);
public static ConfigItem lastUpdateCheckTime = addConfig("lastUpdateCheckTime", configTypeLong, 0L);
// From NekoConfig
public static ConfigItem useIPv6 = addConfig("IPv6", configTypeBool, false);

View File

@ -69,7 +69,7 @@ public class NekoXConfig {
public static boolean keepOnlineStatus = preferences.getBoolean("keepOnlineStatus", false);
public static int autoUpdateReleaseChannel = preferences.getInt("autoUpdateReleaseChannel", 2);
public static String ignoredUpdateTag = preferences.getString("ignoredUpdateTag", "");
// public static String ignoredUpdateTag = preferences.getString("ignoredUpdateTag", "");
// public static long nextUpdateCheck = preferences.getLong("nextUpdateCheckTimestamp", 0);
// public static int customApi = preferences.getInt("custom_api", 0);
@ -115,18 +115,10 @@ public class NekoXConfig {
preferences.edit().putInt("autoUpdateReleaseChannel", autoUpdateReleaseChannel = channel).apply();
}
public static void setIgnoredUpdateTag(String ignored) {
preferences.edit().putString("ignoredUpdateTag", ignoredUpdateTag = ignored).apply();
}
public static String currentAppHash() {
return BuildConfig.APP_HASH;
}
// public static void setNextUpdateCheck(long timestamp) {
// preferences.edit().putLong("nextUpdateCheckTimestamp", nextUpdateCheck = timestamp).apply();
// }
public static boolean isDeveloper() {
if (hasDeveloper != null)
return hasDeveloper;