4673 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
86e8df852e Merge branch 'fix-index-v1-repo-commiting' into 'master'
Fix index-v1 repo commiting

Closes #1016

See merge request !559
2017-07-07 19:00:14 +00:00
Hans-Christoph Steiner
dcf395ad9a add test to update index.xml using index-v1.json 2017-07-07 18:06:49 +02:00
Hans-Christoph Steiner
6c247e3201 Jackson gives us {"repo": {"mirrors": ["foo", "bar"] as ArrayList
I was optimistic and guessed it was a String[], since that's what is needed.

Found by @cde while working on #35
2017-07-07 18:06:49 +02:00
Hans-Christoph Steiner
2a7fe78483 split IndexV1Updater's repo saving into working code
RepoUpdater.prepareRepoDetailsForSaving() was broken here because the Repo
properties were being set before calling it, and then the Repo instance was
passed to it for comparison.  So the comparison was always saying the value
was unchanged.  In IndexV1Updater, the flow doesn't need those checks.

This also fixes the bug where added repos never had their name/description/
icon/etc show up in ManageRepos and RepoDetails.

@cde found this bug working on mirror support, thanks!

related to #35
closes #1016
2017-07-07 18:06:49 +02:00
Hans-Christoph Steiner
0180e754fe remove needlessly scary sentence from otherwise friendly Updates screen
This is not really a useful way to tell the user that the index might be
out of date.  It just adds confusion and makes people think that F-Droid
isn't quite smart enough to know what's going on.
2017-07-07 18:05:53 +02:00
Hans-Christoph Steiner
a430c17950 Merge branch 'non-apk' into 'master'
Add support for non-apk files

Closes #1023

See merge request !541
2017-07-07 12:12:17 +00:00
Hans-Christoph Steiner
7dbf03c435 Apk.isMediaInstalled() needs to check using sanitized file names
The install process automatically sanitizes filenames to avoid exploits
that put attack code in the filename.  Media files are also installed using
this logic, so the installed check needs to use sanitized file names to be
accurate.
2017-07-07 17:09:14 +05:30
Hans-Christoph Steiner
c5a1b11315 allow spaces in file names
This will be more important as people work with media, since it is quite
common to use spaces in filenames generated by humans.  Media files will
not be built by fdroid, so most likely, they will have human-generated
names.
2017-07-07 12:10:52 +05:30
Hans-Christoph Steiner
06bcf75f9b put the faster check first in App.isInstalled()
A > is much faster than all the stuff that isMediaInstalled() has to do,
so put > first, so that if it is true, isMediaInstalled() is not executed.
2017-07-07 12:10:51 +05:30
Chirayu Desai
0d8b0c7fd4 Introduce FileInstaller, a way to handle media files from F-Droid
* This installer is invoked when for non-apk/media files, and
  copies them to an appropriate folder on the sdcard.
* We also introduce a FileInstallerActivity to ask for storage
  permissions at runtime, as needed by Android 6.0 and above,
  and handle the install/uninstall process.
* A toast is shown with the install path after installation.

TODO:
* Manage Installed Apps screen doesn't show media files.
2017-07-07 12:10:48 +05:30
Chirayu Desai
cbf3133e43 AppProvider: Use IS instead of = for suggestedApk calculation
* For non apk files, the signature column would be NULL always,
and in SQLite NULL = NULL is false, but NULL IS NULL is true.

See http://www.sqlite.org/lang_expr.html Operators
2017-07-07 11:41:02 +05:30
Hans-Christoph Steiner
339deb97d9 Merge branch 'issue-1093--reduce-ci-verbosity' into 'master'
Reduce verbosity of CI logging

See merge request !557
2017-07-06 22:19:56 +00:00
Hans-Christoph Steiner
8f680bc1aa Merge branch 'improve-updates-tab-stability' into 'master'
Refactor `AppListItemController` to improve updates tab stability

See merge request !549
2017-07-06 22:15:41 +00:00
Hans-Christoph Steiner
89001ac1f5 Merge branch 'fix-fdroid-notifying-itself' into 'master'
Don't try to notify the user for apks which are already installed.

See merge request !547
2017-07-06 09:51:38 +00:00
Peter Serwylo
2fc8060a5d Check file size first before checking hash to save cycles. 2017-07-06 14:09:17 +10:00
Peter Serwylo
2a40e082e6 Don't try to notify the user for apks which are already installed.
If an app is downloaded into our cache, but an app with the same hash is
already installed, don't bother notifying people about it.

Extracted the logic for finding the path to an apk on disk (given a
PackageInfo object) to also be used by AppUpdateStatusSerice.

Change logging so that if we discard a downloaded file we Log.i instead
of Utils.debugLog. This is so that when debugging a release build we can
see what is happening, because this specific problem was easier to debug
with release builds (rather than setting up a custom fdroid repo).
2017-07-06 13:56:01 +10:00
Peter Serwylo
acbf563724 Reduce verbosity of logging 2017-07-06 11:25:17 +10:00
Peter Serwylo
d37e25db21 Merge branch 'issue-1059--preferred-sig' into 'master'
Support for " preferred sig"

See merge request !552
2017-07-05 23:58:18 +00:00
Peter Serwylo
9acc5a2310 Make pre-multi-sig tests work again.
Before mult-signature support, the process of marking an app as
installed in the `InstalledAppProvider` didn't have any side effects
beyond its own table. Now, it is also responsible for calculating the
`suggestedVersionCode` of the associated app as well.

This means old tests around suggested versions no longer work. This is
because they would insert an App, and set the
`Cols.SUGGESTED_VERSION_CODE` using a `ContentValues`. This was then
overwritten by the `InstalledAppProvider` asking for the real
calculation for suggested versions. That is - it would check for
relevant apks and figure out which was best.

To make the old tests correct, they need:
 * To be able to "install" apps with the correct signature.
 * To insert the relevant apks into the database, not just depend on the
   presence  of an `app`.
2017-07-06 09:22:23 +10:00
Peter Serwylo
bf4b0d89a1 Ensure that the suggestedVersionCode is updated after [un]installing.
Previously, it was only done on repo update.

Now it is done whenever an app is installed or unisntalled. The query to
update the suggested version for each app is quite slow when run at the
end of a repo update. However in this change, we are limiting the query
to only update a single app, which means that performance should not be
a problem.
2017-07-06 09:22:23 +10:00
Peter Serwylo
677fd3a522 Use signature as well as version code in app details for suggested apk. 2017-07-06 09:22:23 +10:00
Peter Serwylo
41f85f3c9d Correctly check for 'suggestedApk' in app details.
Take into account the preferred/installed signature instead of just the
version code.
2017-07-06 09:22:23 +10:00
Peter Serwylo
caac895442 Add "preferredSigner" field to App.
At present, this is chosen from the first package in the index-v1
metadata.
db-version/72
2017-07-06 09:22:21 +10:00
Peter Serwylo
6b42b802b3 Tests for preferred multi sig choice.
When a single repo provides apks with multiple signatures, then we need
to be able to select the preferred one. This adds tests for this which
fail, because that feature has not yet been implemented.
2017-07-06 09:20:45 +10:00
Peter Serwylo
b7b8865325 Extract useful test functions into TestUtils
These will be used by a "preferred sig" test soon.
2017-07-06 09:20:45 +10:00
Hans-Christoph Steiner
ba84bbb9ea reduce massive verbosity of org.fdroid.fdroid.data.AppProviderTest 2017-07-05 17:42:18 +02:00
Hans-Christoph Steiner
ee398167bb fix LocalizationTest for new format pattern: (%1$d/%2$d) from %3$s
added in df20d2df8d5bf15f03df4797caf07502422ced36
2017-07-05 17:42:18 +02:00
Hans-Christoph Steiner
8ba7882a98 Merge branch 'issue-1054--index-v1-progress-via-broadcasts' into 'master'
Add progress reporting for index-v1 (using `LocalBroadcastManager`)

Closes #1054

See merge request !550
2017-07-05 15:41:33 +00:00
Hans-Christoph Steiner
b9277f52e7 Merge branch 'issue-938--feature-graphic-priority' into 'master'
Order apps in main screen by date, new, then presence of feature graphic

Closes #938

See merge request !555
2017-07-04 20:48:02 +00:00
Peter Serwylo
5b52835097 Order apps in main screen by date, new, then presence of feature graphic
This is a conservative fix. If we wanted to really highlight the
feature graphic functionality and reward upstream devs for keeping
metadata up to date, then we could also take apps which were recently
updated, and prioritise them over new apps if they have a feature
graphic.

Fixes #938.

Also fixed display of feature graphic in main screen by getting full
path to image, not the relative path (e.g. "en-US/featureGraphic.png").
2017-07-04 13:09:22 +10:00
Hans-Christoph Steiner
4096c1e1b6 Merge branch 'merge-weblate' into 'master'
Merge weblate

See merge request !554
2017-07-03 19:02:05 +00:00
Hans-Christoph Steiner
b9334e4507 Merge weblate 2017-07-03 19:02:04 +00:00
Peter Serwylo
3d195c9dc0 Report progress correctly
Was previously sending an indeterminate progress event, when we actually knew
how long was remaining.
2017-07-03 15:41:08 +10:00
Peter Serwylo
b7a20bbf01 Remove one layer of indirection in LocalBraodcasts for updating repo.
This creates a hard dependence between `RepoUpdater` and
`UpdateService`. However this could be trivially extracted by moving the
helper methods from `UpdateService` to `RepoUpdater`, and making the
broadcasts more "repo updater" oriented. That would also require
changing the broadcasts which `UpdateService` listens for.
2017-07-03 15:41:05 +10:00
Peter Serwylo
df20d2df8d Add progress reporting for index-v1.
Reuses the "commiting" message to indicate how many apps have been
processed so far.

Refactors existing progress handling between `RepoUpdater` and
`UpdateService` to use `LocalBroadcastManager` in preference to
`ProgressListener`. Still needs to use `ProgressListener` to talk
between `RepoUpdater` and the `Downloader` +
`ProgressBufferedInputStream`.

The only change that is related to something more important than
notifications is the fact that now `IndexV1Updater` makes use of the
`indexUrl`. To do so, because it is final, the base class constructor
delegates to `getIndexUrl()` which is overriden by the v1 updater.
This is required because we want to differentiate between broadcasts
coming from different repo update processes.

Fixes #1054.
2017-07-03 09:31:48 +10:00
Peter Serwylo
827235b6d7 Merge branch 'merge-weblate' into 'master'
Merge weblate

See merge request !553
2017-07-02 22:20:29 +00:00
Hans-Christoph Steiner
66d3a50564 Merge weblate 2017-07-02 22:20:23 +00:00
Hans-Christoph Steiner
5de66eae15 Merge branch 'fix-1028--update-ui-when-db-changes' into 'master'
Don't show apps/categories after disabling repo.

Closes #1028

See merge request !551
2017-06-30 14:17:12 +00:00
Peter Serwylo
b658c0b44e Don't show apps/categories after disabling repo.
This was setup to work correctly, but for two problems:

 * The `cursor.close()` in `CategoriesViewBinder` stops the cursor from
   being requeried when required.

 * The `AppProvider` was not notifying correctly after deleting apps
   belonging to a repo.

Fixes #1028.
2017-06-29 17:33:52 +10:00
Peter Serwylo
945c6f24e6 Formatting, comments, checkstyle.
Moved methods around so the class is more coherent when reading from top
to bottom.

Added some comments.

Formatted lines to be under 120 chars. No longer suppress line length checkstyle messages.
2017-06-29 11:33:42 +10:00
Peter Serwylo
427d7bcbfa Further refactor the AppListItemController for readability and predictability.
This breaks out subclasses for each specific type of app list item,
allowing for code reuse, but also letting the specific business logic
belonging to each different app list item to be separate.

This is particularly helpful in the following situation:

 * In the search results, it is great to be able to render "App
   downloaded, ready to install" in the same manner as the update tab.

 * In the installed app list, this is not desired. Indeed, the status
   text which should be shown should reference the currently installed
   version and whether the user has ignored any updates.

By separating the AppListItemController into subclasses, it reduced the
need to handle several different types of text view (e.g.
"installedStatus", "status", "ignoredStatus", "downloadReady"), and
replace them all with a "status" and "secondaryStatus" TextView. What is
displayed in status and secondaryStatus is up to the individual
subclasses of AppListItemController.
2017-06-29 11:14:57 +10:00
Peter Serwylo
ef230f749c Added "Successfully Installed" status text to updates tab.
Also:
 * Extracted common styles into `@Style/AppListItemStatusText`.
 * Fixed left margin on older devices (where `layout_marginStart` doesn't
   exist).
2017-06-28 17:29:54 +10:00
Peter Serwylo
d0cf621314 Refactor the AppListItemControler to be more predictable.
Previously, there were different pieces of business logic, invoked at
different times, which would touch subsets of the UI.

This change rips that out, and replaces it with a single place where the
UI is setup. This can always be called safely, and it will render the
correct data for the current state of the app (e.g. downloading, waiting
for install, etc).

The AppListItemState class is a dumb object which keeps track of what is
supposed to be displayed in the UI. The AppListItemController now
creates a different AppListItemState depending on what state the list
item is in. This AppListItemState is then used to bind the values of
each UI widget.

All of the binding code is now in the single `resetView()` method, but
all of the business logic for what the view should look like is
separated into different `getViewState*()` methods.

This separation should make it easier to make sense of the UI code, and
hopefully should be testable should somebody choose to write tests for
it in the future.
2017-06-28 17:08:16 +10:00
Hans-Christoph Steiner
61ab88f8ea Merge branch 'acra-fixes' into 'master'
ACRA fixes

Closes #1074

See merge request !544
2017-06-26 10:13:54 +00:00
Hans-Christoph Steiner
2fbb102f62 Merge branch 'add-ml-locale' into 'master'
Add Malayalam (ml) to language list

Closes #1077

See merge request !545
2017-06-26 07:34:37 +00:00
Shanavas
1b75a4fd3a Add Malayalam (ml) to language list 2017-06-23 23:19:57 +00:00
Peter Serwylo
b1ac0ff351 Prevent crash on categories screen when rotating.
The docs say that initLoader tries to reuse existing cursors.
The error message was "IllegalStateException: attempt to re-open an
already-closed object: SQLiteQuery: ...".
2017-06-23 17:06:45 +10:00
Peter Serwylo
79ede18259 Fix crash due to unknown suggested version.
There may be a bigger problem around suggested versions being null at
all, but that is getting looked at in a different feature set (i.e.
multi signature support) and will come in time. This fixes the immediate
problem some people were having and sending crash reports for in 0.104.

STACK_TRACE=java.lang.NullPointerException: Attempt to read from field 'java.lang.String org.fdroid.fdroid.data.Apk.versionName' on a null object reference
	at org.fdroid.fdroid.views.AppDetailsRecyclerViewAdapter$HeaderViewHolder.bindModel(AppDetailsRecyclerViewAdapter.java:425)
	at org.fdroid.fdroid.views.AppDetailsRecyclerViewAdapter.onBindViewHolder(AppDetailsRecyclerViewAdapter.java:244)
	at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6310)
	at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6343)
	...

Introduced in 97fd3f0.
2017-06-23 16:14:09 +10:00
Hans-Christoph Steiner
41d7e830d3 Merge branch 'new-ui/uninstall-fixes' into 'master'
System app uninstall prevention, fixes crash.

See merge request !478
2017-06-22 12:21:42 +00:00
Chirayu Desai
7ac3ff293e Don't allow uninstalling system apps.
* F-Droid cannnot uninstall system apps, only their updates,
  but even with the privileged extension, that can get complicated.
* Let's just not allow uninstalling system apps, the phone's settings
  app can happily disable/re-enable system apps, and also uninstalls
  their updates on disabling.
2017-06-22 15:04:23 +05:30