Check at most once every 24h hours for new update
This commit is contained in:
parent
9ec269c85f
commit
454a919eda
3 changed files with 25 additions and 10 deletions
|
@ -368,11 +368,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
|
|||
}
|
||||
} else {
|
||||
if (getResources().getBoolean(R.bool.check_for_update_when_app_starts)) {
|
||||
String url = LinphonePreferences.instance().getCheckReleaseUrl();
|
||||
if (url != null && !url.isEmpty()) {
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull()
|
||||
.checkForUpdate(BuildConfig.VERSION_NAME);
|
||||
}
|
||||
checkForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -620,11 +616,7 @@ public class LinphoneActivity extends LinphoneGenericActivity
|
|||
|
||||
// If permission was asked we wait here for the results so dialogs won't conflict
|
||||
if (getResources().getBoolean(R.bool.check_for_update_when_app_starts)) {
|
||||
String url = LinphonePreferences.instance().getCheckReleaseUrl();
|
||||
if (url != null && !url.isEmpty()) {
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull()
|
||||
.checkForUpdate(BuildConfig.VERSION_NAME);
|
||||
}
|
||||
checkForUpdate();
|
||||
}
|
||||
|
||||
if (permissions.length <= 0) return;
|
||||
|
@ -669,6 +661,20 @@ public class LinphoneActivity extends LinphoneGenericActivity
|
|||
}
|
||||
}
|
||||
|
||||
private void checkForUpdate() {
|
||||
String url = LinphonePreferences.instance().getCheckReleaseUrl();
|
||||
if (url != null && !url.isEmpty()) {
|
||||
int lastTimestamp = LinphonePreferences.instance().getLastCheckReleaseTimestamp();
|
||||
int currentTimeStamp = (int) System.currentTimeMillis();
|
||||
int interval = getResources().getInteger(R.integer.time_between_update_check); // 24h
|
||||
if (lastTimestamp == 0 || currentTimeStamp - lastTimestamp >= interval) {
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull()
|
||||
.checkForUpdate(BuildConfig.VERSION_NAME);
|
||||
LinphonePreferences.instance().setLastCheckReleaseTimestamp(currentTimeStamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initButtons() {
|
||||
mTabBar = findViewById(R.id.footer);
|
||||
mTopBar = findViewById(R.id.top_bar);
|
||||
|
|
|
@ -962,6 +962,14 @@ public class LinphonePreferences {
|
|||
return getConfig().getString("misc", "version_check_url_root", null);
|
||||
}
|
||||
|
||||
public int getLastCheckReleaseTimestamp() {
|
||||
return getConfig().getInt("app", "version_check_url_last_timestamp", 0);
|
||||
}
|
||||
|
||||
public void setLastCheckReleaseTimestamp(int timestamp) {
|
||||
getConfig().setInt("app", "version_check_url_last_timestamp", timestamp);
|
||||
}
|
||||
|
||||
public boolean isOverlayEnabled() {
|
||||
return getConfig().getBool("app", "display_overlay", false);
|
||||
}
|
||||
|
|
|
@ -130,6 +130,7 @@
|
|||
<bool name="enable_call_notification">true</bool>
|
||||
<bool name="kill_service_with_task_manager">true</bool>
|
||||
<bool name="check_for_update_when_app_starts">true</bool>
|
||||
<integer name="time_between_update_check">86400000</integer>
|
||||
<integer name="notification_ms_on">1000</integer>
|
||||
<integer name="notification_ms_off">7000</integer>
|
||||
|
||||
|
|
Loading…
Reference in a new issue