Commit Graph

244 Commits

Author SHA1 Message Date
Gabriele M
c6a60d78f5 Use a localized string as default content description 2017-07-17 14:48:59 +02:00
Gabriele M
d3436c37e9 Use Compat theme for the AppBar title 2017-07-17 13:17:48 +02:00
Gabriele M
61f9bb8f30 Get the height of the ToolBar from the current theme 2017-07-17 12:51:40 +02:00
Gabriele M
d0f9c4be22 Don't use the filename as notification title
Be consistent with the rest of the app and use "version - date".
2017-07-17 12:27:15 +02:00
Gabriele M
c1f0aab382 Show snackbar for some download status changes 2017-07-17 12:27:15 +02:00
Gabriele M
b337452eeb Show download button if a download fails immediately
If the download fails without downloading any data, treat it as a
new file.
2017-07-17 12:27:15 +02:00
Gabriele M
f496f0d0e7 Don't set status of download to unknown when download fail
The controller should report the actual status of the downloads, let
the clients handle the special cases. Also, don't try to resume
downloads whose destination doesn't exist.

This partially reverts 7369e9cea9
("Set the status of paused downloads to unknown if no file exists").
2017-07-17 12:27:15 +02:00
Gabriele M
fcce65d4ed Improve D-pad navigation 2017-07-17 12:27:11 +02:00
Gabriele M
1f0aa4e79b Collapse header if the device has no touchscreen
The header can't be collpased without a touchscreen, so collapse
it if we detect that the current device has no touchscreen.
2017-07-17 12:26:18 +02:00
Gabriele M
1af40da839 Send the notification and then start the download
In this way if the download fails immediately, it will fail after the
notification.
2017-07-17 12:26:08 +02:00
Gabriele M
75befd1738 Always cleanup the download directory
This shouldn't really be necessary since the cleanup is needed after
the application data has been wiped, which by default has the
automatic updates check enabled.
2017-07-17 00:33:19 +02:00
Gabriele M
c3515644b6 Ask for confirmation before installing updates
Since there's no quick and clean way to show a dialog from a
serivice, don't allow to install updates from the notification.
2017-07-16 22:52:45 +02:00
Gabriele M
12688ba761 Allow to check if an update is of type AB from anywhere 2017-07-16 22:52:45 +02:00
Gabriele M
4182e3d30e Allow to delete updates on card long press 2017-07-16 22:52:45 +02:00
Gabriele M
e51be80f6a Initial UI work
Look and feel based on CMUpdater.
2017-07-16 22:52:45 +02:00
Gabriele M
a455c95e0c Install updates from UpdaterService
This allows to easily handle AB updates.
2017-07-16 22:52:45 +02:00
Gabriele M
fd856dce70 Allow to disable the automatic updates check 2017-07-16 22:52:45 +02:00
Gabriele M
f94846674f Allow to check if an AB update is being installed 2017-07-16 21:24:07 +02:00
Gabriele M
601823dfc7 Allow to check if an update is being verified 2017-07-16 21:24:07 +02:00
Gabriele M
7369e9cea9 Set the status of paused downloads to unknown if no file exists
This is useful in case the download is stopped before it could start.
2017-07-16 21:24:06 +02:00
Gabriele M
40f15b1fb3 Reset speed and ETA when pausing downloads 2017-07-15 02:10:34 +02:00
Gabriele M
c7f4c48a67 Allow to re-install the current update 2017-07-15 02:10:32 +02:00
Gabriele M
d30ba00a7b Update download size only if it was unknown
The returned content-length depends on the requested range, therefore
when resuming download the reported size is smaller than the actual
file size and we should not update it.
2017-07-15 02:10:31 +02:00
Gabriele M
66ca7a79df Sort the updates, not their IDs
Also, use a comparator to sort the updates and stop using the
Comparable interface. There are different ways to sort updates,
so don't define one.
2017-07-10 01:32:19 +02:00
Gabriele M
7d55cd93ee Add missing @Override annotation 2017-07-10 01:32:19 +02:00
Gabriele M
e34334a1d7 Pass the destination File to the callback
The current argument is unused and it should have been removed
with commit 81229329f1
("Generate download clients using a builder class"). Instead of
removing it completely, use it to pass the File of the download.
2017-07-10 01:31:35 +02:00
Gabriele M
e1dd2a8d73 Fix the download path of CMUpdater 2017-07-08 22:18:15 +02:00
Gabriele M
79b44602e0 Allow to have different updates using the same filename 2017-07-08 22:18:15 +02:00
Gabriele M
4979c4d78d Increase number of veryfing updates immediately
Or we might notify the listeners too early.
2017-07-08 22:11:01 +02:00
Gabriele M
c0bf32c097 Don't allow to install older builds
In some cases, installing an update older than the one currently
installed requires a data wipe, so don't allow it. However, allow
to verify old updates if not verified yet (e.g. when imported).
2017-07-08 22:11:00 +02:00
Gabriele M
1c1bac67b4 Protect the data of UpdaterController
Create copies of the objects not to allow other classes change them,
excluding those of controller package.
2017-07-08 22:10:59 +02:00
Gabriele M
e4d32bc04f Add copy constructors to Update and UpdateDownload 2017-07-08 22:10:59 +02:00
Gabriele M
a2919a8947 Don't modify the objects of the controller directly
Add a method to the controller that allows to set a list of
downloads as not available online.
2017-07-08 22:10:58 +02:00
Gabriele M
b4b8409766 Remove some useless method arguments 2017-07-08 22:10:56 +02:00
Gabriele M
e413510093 Document the methods of DownloadClient 2017-07-08 17:43:56 +02:00
Gabriele M
1c212075f1 Allow to resume downloads only if the destination file exists 2017-07-08 17:43:56 +02:00
Gabriele M
b4f0abd97d Cancel partial downloads if the server doesn't fulfil them
If the server doesn't fulfil a partial content request, bail out.
While at it, fix a typo.
2017-07-08 17:43:56 +02:00
Gabriele M
81229329f1 Generate download clients using a builder class
This change allows to define a proper interface for the download
client and keep its implementation completely separate. It also
allows to create clients without starting the download right away,
which could be useful when defining callbacks that require a
reference to the client.

Note that this change also drops the unused methods of DownloadClient.
2017-07-08 17:43:56 +02:00
Gabriele M
5b0e37ea22 Don't use a static object as download tag
Otherwise all the downloads will use the same tag and cancelling a
download will actually cancel all the downloads.
2017-07-08 17:20:47 +02:00
Gabriele M
efa829358d Remove unknwon files that are in the downloads dir
The files are supposed to be downloaded in a privileged location
that the user can't access. If the user wipes the data of the
application, the updates downloaded are not removed. Perform a
one-time cleanup so that our downloads dir doesn't grow without
control.
2017-07-08 14:07:05 +02:00
Gabriele M
6534932b20 Show "verify" for complete INCOMPLETE updates
INCOMPLETE is used for any update that isn't verified, even if the
file has been completed. This change is mostly needed to support
imported downloads, which we take as complete, but unverified.
2017-07-08 14:05:36 +02:00
Gabriele M
26f149bef1 Import updates downloaded with CMUpdater 2017-07-08 14:05:19 +02:00
Gabriele M
b8a769eeab Remove "update name" column from the database
It's useless since it's just the name of the file and we also stores
the full path.
2017-07-07 23:23:19 +02:00
Gabriele M
cb089aa445 Don't save the URL of the update in the database
Each update must now be in updates.json to be downloaded. Since this
file already stores the URL of each update and that the URL is not
needed after the download, the URL entry can be removed from the
database.
2017-07-07 22:57:54 +02:00
Gabriele M
e6a061c090 Use a single config to define the download path
There's no point in using a bool, just define the path.
2017-07-07 22:05:23 +02:00
Gabriele M
89cb51e3dd Replace error message with debug message
Trying to add an already added download is not error and it's
actually a way to mark an update as available online.
2017-07-07 22:05:23 +02:00
Gabriele M
c90700d3d2 Remove no longer available updates when refreshing the list 2017-07-07 22:05:23 +02:00
Gabriele M
d327d61cc6 Send an event when update are canceled
This allows to properly update the status of the application.
In particular, when an update is deleted:
 - Cancel the associated notification, if any.
 - Remove the entry from the controller if the update is no longer
   available online.
 - Disable the resume button if download is partially downloaded
   and is no longer available online.
2017-07-07 22:05:22 +02:00
Gabriele M
08a7dfade9 Track "online updates" rather than "local updates"
This is a preparation commit with no actual changes.
2017-07-07 22:05:22 +02:00
Gabriele M
ab9ac395f0 Use deleteUpdateAsync() even if we know the file doesn't exist
deleteUpdateAsync() is safe and it makes the code more readable at
the expense of an extra File.exists() call.
2017-07-07 22:05:22 +02:00