The APK files are downloaded to the public Download directory, and the default APK install
+ * screen is launched after downloading.
+ */
+public class UpdateManager {
+ public static final long DEFAULT_UPDATE_CHECK_INTERVAL_MS = 1000 * 60 * 60 * 24 * 5; // 5 days
+
+ private static final String TAG = "UpdateManager";
+
+ private static final String DOWNLOAD_FILE = "Clover_update.apk";
+
+ private UpdateCallback callback;
+
+ public UpdateManager(UpdateCallback callback) {
+ this.callback = callback;
+ }
+
+ public boolean isUpdatingAvailable() {
+ return !TextUtils.isEmpty(BuildConfig.UPDATE_API_ENDPOINT);
+ }
+
+ public void runUpdateApi(final boolean manual) {
+ if (!manual) {
+ long lastUpdateTime = ChanSettings.updateCheckTime.get();
+ long interval = ChanSettings.updateCheckInterval.get();
+ long now = Time.get();
+ long delta = (lastUpdateTime + interval) - now;
+ if (delta > 0) {
+ return;
+ } else {
+ ChanSettings.updateCheckTime.set(now);
+ }
+ }
+
+ Logger.d(TAG, "Calling update API");
+ Chan.getVolleyRequestQueue().add(new UpdateApiRequest(new Response.ListenerClover v2.2.0 is available
A new version of Clover is available.
This release fixes stuff.
- aaa
- bbb",
+
+ "apk": {
+ "default": {
+ "url": "https://github.com/Floens/Clover/releases/download/v2.2.0/Clover_v2.2.0.apk"
+ },
+ "fdroid": {
+ "url": "https://f-droid.org/repo/org.floens.chan_56.apk"
+ }
+ }
+ }
+ ],
+ "check_interval": 432000000
+}
diff --git a/docs/update_api.txt b/docs/update_api.txt
new file mode 100644
index 00000000..23652dca
--- /dev/null
+++ b/docs/update_api.txt
@@ -0,0 +1,29 @@
+update_api.json describes the update check api that Clover loads periodically.
+
+api_version
+Version of this api, always 1.
+
+check_interval
+the interval of loading the file, overrides the default interval of 5 days if set.
+
+messages
+array of messages
+
+ type:
+ type of the message, only "update" is supported
+
+ code:
+ code of the new version. if this is higher than the code of the calling app then the message will be processed.
+
+ date:
+ ISO8601 date, parsed but not used for now.
+
+ message_html:
+ message shown to the user, parsed with Html.fromHtml()
+
+ apk:
+ set of apks for each flavor. each key is only parsed if it equals to the flavor name that the app is compiled for.
+
+ url:
+ url of the apk file to download and install.
+