1042 Commits

Author SHA1 Message Date
Peter Serwylo
d0444dafca Clarify comments in response to CR. 2017-06-12 14:22:07 +10:00
Peter Serwylo
aa472ba764 Drop the composite vercode + repo primary key from apk table
We expect repos to serve multiple apks with the same version code but
different signing certificates in the future.
2017-06-12 13:48:36 +10:00
Peter Serwylo
b95a330ccf Restrict suggested versions to those with the same sig as installed.
Only if there is actually a version installed.
2017-06-12 13:48:36 +10:00
Peter Serwylo
44ffaa37d6 Add suggested version tests.
Some are failing as expected, but should define the correct behaviour.

Still needs support for multi-repo tests.
2017-06-12 13:48:35 +10:00
Peter Serwylo
aae0a57dfe Improve performance of suggested version calculation.
The history of this is that #974 identified a problem, which was fixed
in !497. That MR added test coverage for the bug.

However, the fix for it actually added a huge performance hit, on the
order of 30 seconds or so when calculating the suggested version.

This fixes that performance problem by removing the need for a sub
query. The end goal is to take the following query:

```
UPDATE app
SET suggestedVersion = (
  SELECT MAX(apk.version)
  FROM apk
  WHERE ...
)
```

and the `WHERE` clause needs to somehow join the outer `app` table with
the inner `apk` table, such that the repo in question does not matter.
It can't just join directly from `apk.appId -> app.rowid`, because the
`app` is specific to a given repository, but we want to select the
`MAX(apk.version)` from every related apk, regardless of repo.

This commit solves it by joining the inner `apk` table onto an
intermediate `app` table, which is used purely so that we can select
apks where their `packageId` is the same as the `packageId` of the app
being updated.
2017-06-12 13:47:41 +10:00
Peter Serwylo
833ae329e4 Merge branch 'enforce-max-length-118' into 'master'
enforce max line length set by Android Studio, gitlab, etc.

See merge request !532
2017-06-11 20:53:44 +00:00
Hans-Christoph Steiner
72d7d902e0 Merge branch 'fix-fdroid-update-prompt' into 'master'
Fix incorrect persistent + annoying notification to update F-Droid.

Closes #1027 and #776

See merge request !530
2017-06-08 10:46:45 +00:00
Peter Serwylo
5b6e515a06 Add final artwork and correctly read colours.
Carrie specified colours earlier, and they were added to the code.
However they were not being read correctly. This changes that so that
lowercase resource names (e.g. "category_games") are used instead.

It also adds the final category artwork, for "Games" which was
missed prior.

The rest still generate colours and patterns if they don't have a colour
or an image specified.
2017-06-08 17:24:12 +10:00
Peter Serwylo
9e33dcf0db Wait 3 seconds before refreshing the view.
With a 1 second debounce, I was getting the view to refresh
several times in response to large apps being processed (e.g.
Firefox, OSMAnd, etc). This was on a (relatively) recent Moto X
2nd Gen, so it would be even more visible on an older device.

The side effect of updating frequently is that the main list
of apps flashes regularly in front of the user (see #986).

This "update the view" is only in response to a background
task that is expected to take several seconds (e.g. 30 seconds)
anyway, so waiting 3 seconds instead of 1 is not particularly
problematic.
2017-06-08 09:12:52 +10:00
Peter Serwylo
1dbf5704b6 Don't remove ourselves from the installed app cache.
If F-Droid was actually removed, then we wouldn't even
have an installed app cache (we aren't even on the device
any more). As such, ignore all requests to remove F-Droid
because it complicates the installed apk cache. Specifically,
there is a race condition between the "compare apk cache to
package manager" and the "package removed receiver", where
the later was overriding the former.
2017-06-08 08:59:07 +10:00
Peter Serwylo
116cb88b81 Fix incorrect persistent + annoying notification to update F-Droid.
There is a persistent shared preference which dictates whether apps
have been successfully downloaded and are ready to install. When
the `InstallManagerService` used to receive an `ACTION_INSTALL_COMPLETE`
broadcast, it would update this preference to no longer be installing.
However, this never got received in the case of F-Droid updating itself.
In that case, we need to instead wait for the system to broadcast an
`Intent.ACTION_PACKAGE_ADDED` intent. This change waits until that
point before removing the preference.

Fixes #1027.
2017-06-08 08:59:05 +10:00
Hans-Christoph Steiner
48fd6d287d enforce max line length at 118
gitlab's diff views wrap badly when lines are longer than 118.  Android
Studio places a grey line in the UI at 120.

@SuppressWarnings("LineLength") is added to a bunch of files to prevent
making this commit huge.  People can remove that as they work on those
files, and fix the issues then.

I also ran Android Studio's default Ctrl-Alt-L code formatter, where it was
easy to do, and I was already in the file.
2017-06-06 16:12:23 +02:00
Hans-Christoph Steiner
a0015cda32 correct method name: getLocalizedListEntry()
This gets the data, it does not set it.  And it matches the other
getLocalized*() methods.
2017-06-06 16:12:23 +02:00
Hans-Christoph Steiner
087e86b312 Merge branch 'fix-notifications' into 'master'
Fix notification problems

Closes #1013

See merge request !523
2017-05-31 09:09:08 +00:00
Peter Serwylo
f617402f32 Remove PendingDownload in favour of Downloading
The response to receiving PendingDownload was always a more specific
case of the Downloading event. By removing it, the code which was listening
for Downloading events is capable of doing everything that the PendingDownloading
listeners were doing.
2017-05-31 11:47:10 +10:00
Peter Serwylo
a656e8e133 Remove dead code.
Fixes #1013.
2017-05-31 11:47:10 +10:00
Peter Serwylo
b3ed64ddaf Simplify and clean up updates view logic.
Same as how AppDetails2 was recently cleaned up to depend more on
AppUpdateStatusManager.

In addition, it also removes items from the "X apps can be updated"
lower part of the "Updates" view when they are present in the upper half
(i.e. the half showing feedback about the current download/install
progress).
2017-05-31 11:47:10 +10:00
Peter Serwylo
2a9fefd54e Simplify logic in UpdatesAdapter.
No longer do we try to nicely maintain the state of the adapter in "Updates"
in order to notify the recycler view about changes to its underlying data.
Instead, we just rebuild the entire structure each time a new thing needs
to be shown/removed.

This means no more smooth scrolling to the relevant item after it is
changed, but it results in a far less buggy interface.
2017-05-31 11:47:10 +10:00
Peter Serwylo
b69587ca65 Make contract about nullable currentApp explicit.
This identified a couple of places where it needed to be guarded
against.
2017-05-31 11:47:10 +10:00
Peter Serwylo
7d1fac2729 Extract isDownloading check into method of status class.
This is also going to be used elsewhere.
2017-05-31 11:47:10 +10:00
Peter Serwylo
8e2a099e51 Make app status updates include parcelized version of status.
This means that we no longer need to receive an APK_URL and then
directly ask the status manager for the relevant status object.
This causes problems when consecutive updates happen in the same event
loop, e.g. download started + download complete. In this case, the
receiver will receive two events for the same app. When it asks for the
associated status object for the first (download started) event, it will
receive a status that says "download complete ready to install". This is
because the status object has already been updated by the second event.

Furthermore, the broadcast manager must receive a copy of the status
object, not the original object. This is because the broadcast manager
doesn't parcel the relevant extras until the end of the event loop. This
means that if the status is changed twice in one frame, then both
parcels will end up looking the same. By sending through a copy instead,
this ensures that any listener receives the statuses in the correct
order, rather than two parceled versions of the same status
notification.
2017-05-31 11:47:10 +10:00
Peter Serwylo
ee7055e118 Listen to AppUpdateStatusManager events instead of DownloadManager events.
Also, make sure to correctly update the app details view when te user
leaves then returns to the view. Prior to this, the user would need to
wait for a download event to be received. However even that was broken,
because the download listener was not being added correctly once the
user returned to the app details screen.
2017-05-31 11:47:10 +10:00
Peter Serwylo
be727ae7c0 Fix missing category images.
Even though the categoyr mage loader explicitly says not to cache
images on disk (because they are not coming from the network anyway),
UIL still uses the `FilenameGenerator` to come up with a disk cache name.

Because the file name generator takes the "path" of the URL being
downloaded, and the categories are loaded like "drawable://2134234",
there is no path. As such, the file name ends up being meaningless.

This results in the image loader testing for the existance of the file
on disk (even though we asked not to cache on disk), and then failing
with an IOException (that gets swallowed).

By providing a meaningful name from the file name generator, it now
works as expected.

Fixes #1039.
2017-05-31 09:27:29 +10:00
Hans-Christoph Steiner
c5f5eb6a05 Merge branch 'transitions' into 'master'
Fixed shared element transitions

See merge request !524
2017-05-29 18:55:48 +00:00
ByteHamster
ecf0b88c65 Fixed shared element transitions 2017-05-29 18:02:31 +02:00
Peter Serwylo
e46fccce95 Merge branch 'text-all-caps' into 'master'
Use proper way to set text all caps on old api

See merge request !521
2017-05-26 02:57:05 +00:00
Felix Ableitner
05b4a55c0a Use proper way to set text all caps on old api 2017-05-26 11:32:29 +09:00
Peter Serwylo
18bf71a149 Merge branch 'updates-tab' into 'master'
Displaying background in updates fragment

See merge request !522
2017-05-26 01:50:37 +00:00
Hans-Christoph Steiner
35df6afa53 move "by AuthorName" to a proper format for translations
The string was forcing English grammar on other languages.
2017-05-25 19:16:11 +02:00
ByteHamster
2c31b9f793 Displaying background in updates fragment 2017-05-24 20:06:14 +02:00
Felix Ableitner
371d8ede77 Improve display of last updated time 2017-05-22 18:59:09 +00:00
Hans-Christoph Steiner
e07e4fc223 convert strings to plurals, and make lint enforces this
Lots of languages really need the <plurals> tags to make sense, so
this also makes lint exit with an error when it finds strings that
should be <plurals>

closes #883
2017-05-16 10:39:16 +02:00
Hans-Christoph Steiner
d71514d628 Merge branch 'fix-1011-stacked-update-notifications' into 'master'
Force each stacked notification to have a different `requestCode`

Closes #1021

See merge request !518
2017-05-16 08:38:20 +00:00
Peter Serwylo
91eb408280 Use app name and version when bluetoothing to peer.
Previously, it would either send "base.apk" (in earlier versions of
F-Droid when bluetoothing an apk from the /data/app/... dirs), or
"install-[random].apk" (if recent F-Droid when copying file to a safe
place to expose via a FileProvider.

This now writes the file to, e.g. "F-Droid-0.103.1.apk" before sending.

Note that this means files are more likely to be overridden when being
sent, if the same apk from two different repositories is either:
 * Sent via bluetooth
 * Prompted to install via the system package manager

However this should still never let malicious people write to that
folder.
2017-05-16 08:40:54 +10:00
Peter Serwylo
e965e97623 Force each stacked notification to have a different requestCode.
This ensures that the `PendingIntent.FLAG_UPDATE_CURRENT` doesn't
continually override earlier intents with the last app to be notified.
This could probably equally be done by leaving the request code as 0 and
removing the FLAG_UPDATE_CURRENT out, however it seems much more
semantic to have a separate request code for each different pending
intent.

Fixes #1021.
2017-05-16 07:58:38 +10:00
Stephen Michel
1f3271d72d remove refresh action from repo management screen 2017-05-15 11:52:28 -04:00
Hans-Christoph Steiner
b848766436 remove translation auto-detect hack, it is too hacky
The hack that goes through and checks whether a language is present in
the APK seems to cause random strings to switch to English when the
app is running.  So this removes that hack, and instead switches the
Languages menu to a hard-coded list.  Languages that are not present
or close to complete were removed from the old list.

closes #943
closes #1010
2017-05-12 23:33:10 +02:00
Hans-Christoph Steiner
2d9e1ecd4f remove unused arguments to Languages.setLanguage() 2017-05-12 23:33:10 +02:00
Peter Serwylo
0df1f765e9 Don't die when failing to bluetooth apk. 2017-05-12 09:23:01 +10:00
Peter Serwylo
09ad7fe3d0 Use FileProvider when bluetoothing apks on API >= 24.
Reuses the code that the installer uses, when it broadcasts to
the relevant installer that an Apk is available for install.

This used to do the following:
 * Copy file to a private directory
 * Make the file world readable (so that PM can access it)
 * Send a file:// URI to the installer

The file:// URI is no longer supported for reasons explained in
the support lib FileProvider class. Now a content:// URI is required,
and that must explicitly grant permission to certain packages.

The existing code here used to grant permission to
org.fdroid.fdroid.privileged, and this code now also grants it to
com.android.bluetooth. I see no security threat with exposing these
files to both applications, because the .apk files only ever:
 * Were downloaded from the public internet into a (potentially public)
   cache dir.
 * Were sourced from an `ApplicationInfo#publicSourceDir, in which
   case any app can access that anyway.

Fises #837.
2017-05-12 09:22:57 +10:00
Peter Serwylo
2f4b00dc75 Formatting 2017-05-12 09:16:58 +10:00
Hans-Christoph Steiner
1b390cceca clear language setting if it matches the system-wide setting
If the user can set the language using the Setting app, then there is
not reason to use the Languages hack.  This then clears the preference
if it matches the language of the system-wide locale.  This also
removes the current system-wide language from the Languages menu.

closes #943
2017-05-11 09:39:00 +02:00
Hans-Christoph Steiner
d1014f7b1f fix "Number formatting does not take into account locale settings."
lint says "Consider using String.format instead."
2017-05-11 09:38:59 +02:00
Hans-Christoph Steiner
186d1dbabb fix SetTextI18n lint warnings and set as error 2017-05-11 09:38:59 +02:00
Hans-Christoph Steiner
151c83218c do not crash if there are no cached APKs
closes #1012
2017-05-11 09:38:59 +02:00
Peter Serwylo
67a29bae8f Include an images full URL in the cache path.
All feature graphics are called `featureGraphic.png`, and so our cache
was presuming all feature graphics were the same image. By including
the full path from the server in the cached name, we don't overwrite
images any more.
2017-05-09 16:03:27 +10:00
Peter Serwylo
bd5503b4cd Rename method as icons are no longer the only thing stored here. 2017-05-09 16:02:08 +10:00
Hans-Christoph Steiner
4e375ca7f8 prevent crash if installing app without icon (closes #1006)
Right now, org.fdroid.fdroid.privileged.ota and FFupdater do not
provide any icons and it seems that that triggers this crash:

ACRA caught a NullPointerException for org.fdroid.fdroid
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.lastIndexOf(int)' on a null object reference
    at org.fdroid.fdroid.FDroidApp$5.generate(FDroidApp.java:282)
    at com.nostra13.universalimageloader.cache.disc.impl.BaseDiskCache.getFile(BaseDiskCache.java:167)
    at com.nostra13.universalimageloader.cache.disc.impl.BaseDiskCache.get(BaseDiskCache.java:98)
    at com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiskCache.get(LimitedAgeDiskCache.java:74)
    at com.nostra13.universalimageloader.utils.DiskCacheUtils.findInCache(DiskCacheUtils.java:36)
    at org.fdroid.fdroid.NotificationHelper.getLargeIconForEntry(NotificationHelper.java:506)
    at org.fdroid.fdroid.NotificationHelper.createUpdateNotification(NotificationHelper.java:300)
    at org.fdroid.fdroid.NotificationHelper.createNotification(NotificationHelper.java:191)
    at org.fdroid.fdroid.NotificationHelper.access$400(NotificationHelper.java:37)
    at org.fdroid.fdroid.NotificationHelper$1.onReceive(NotificationHelper.java:106)
    at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
    at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
    at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
2017-05-08 20:16:39 +02:00
Hans-Christoph Steiner
2e2a6bd419 show Toast when file type cannot be installed
This is just a placeholder until we implement proper "installing" for
non-APK files.

!504
#982
2017-05-02 22:00:48 +02:00
Hans-Christoph Steiner
676b2b9093 correct SPDX links when the License: tag contains a +
The "+" is syntax on top of the license name:
https://spdx.org/spdx-specification-21-web-version#h.jxpfx0ykyb60
2017-05-02 21:53:11 +02:00