716 Commits

Author SHA1 Message Date
Daniel Martí
a028b3f6a2 Avoid NPE in Uri.getPath().replaceAll()
Fixes #533.
2016-02-02 21:55:45 +00:00
Daniel Martí
ff3cd9fb11 Drop visibility on some fields and classes
As suggested by Android Studio.
2016-02-01 15:07:14 +00:00
Daniel Martí
c198736cd1 Update ACRA to 4.8.0 2016-02-01 14:21:49 +00:00
Peter Serwylo
97cc279d99 Fix unit tests to work with a singleton DBHelper instance.
The fix for the database locking bug was to have a singleton
`DBHelper` instance. This breaks tests because multiple tests
share the same database. The solution is to:

 * Hack together a static method which clears the singleton,
   then invoke it in the `setUp()` method for relevant test cases.

 * Ensure the mock context provided to the providers during
   the tests is able to provide a context via `getApplicationContext()`.
   Without this, the mock context throws an `UnsupportedOperationException`
   when invoking this method.
2016-01-26 22:23:41 +11:00
Peter Serwylo
f7bbf0e282 Use getApplicationContext() instead of getContext() to prevent memory leaks.
Using whatever `Activity` as the `Context` used to construct the first content
provider means that it will be help onto in memory until the application is GC'ed.
2016-01-25 18:02:22 +11:00
Peter Serwylo
63d3006ba8 Fixed yellow in Android studio by adding annotations matching subclass. 2016-01-25 17:55:24 +11:00
Peter Serwylo
4957bcb812 Singleton database instance to prevent locking exceptions.
Previously, all of the various subclasses of FDroidProvider would create
their own database open helper in their respective `onCreate()` methods.
This seemed to be the cause of the multiple database locked exceptions.

Various online articles/SO posts/etc helped come to this conclusion:
 * http://stackoverflow.com/a/3689883
 * http://stackoverflow.com/a/8888606
 * https://web.archive.org/web/20150709074733/http://www.dmytrodanylyk.com/pages/blog/concurrent-database.html

This should fix #265.

In the process, also did away with the two `read()` and `write()` methods
that returned a "readable" and "writeable" database respectively. It turns
out that it doesn't quite do what I originally thought. There is not much
benefit to specifying to the database helper that you want a readable/writeable
database. In fact, it is often the case that a call to `read()` would most
likely have returned the same instance that is returned by `write()`. The
semantics of them were therefore broken, and they've been replaced with
`db()`.
2016-01-25 17:53:45 +11:00
Peter Serwylo
d23e68be6b Finish main activity after navigating to AppDetails activity.
This is what used to happen before the recent refactor to the search UI.
Finishing the main activity means that it never comes back to handle the
"View this app" intent again. Instead, the main Activity just becomes an
entry point for redirecting the UI to the correct place.

Incidentally, I don't particularly like the current solution even though
it should work, and hope to come up with a better one in the future. The
reason is because the behaviour of some methods (`onCreate()` +
`handleIntent()`) is what defines the behaviour of other methods
(`checkForAddRepoIntent()`). This means it is hard to reason about the
state of the activity at any point in time. Developers need to be careful
when making changes to the `onCreate()` method because modifying it has
unintended consequences. That is what caused the problem in issue #541.

Fixes #541.
2016-01-18 20:24:39 +11:00
Daniel Martí
bb1c551cb8 Merge branch 'master' into 'master'
Add author/email/license display capabilities to app. (Closes: #532)

![Screenshot_2016-01-06-20-10-18](/uploads/c15a5e59624113e9e83914914cd9c6a9/Screenshot_2016-01-06-20-10-18.png)
![Screenshot_2016-01-06-20-18-31](/uploads/0f6c15b6c0646a3336460a91a2a04e42/Screenshot_2016-01-06-20-18-31.png)


See merge request !189
2016-01-09 13:45:13 +00:00
Peter Serwylo
9aca7da375 Merge branch 'simplify-crash-activity' into 'master'
Fix crash report activity theme and behavior

Use proper theme, fix crash on sending and comment loss on device rotation.

See merge request !191
2016-01-08 02:44:31 +00:00
Peter Serwylo
315f1fa932 Use a better name than "handled" for swap activity.
Before, both the swap activity and the fdroid activity would use
the "handled" key to check if an intent had been handled. This caused
problems, because by the time we got to handling the add repo intent,
it had already been "handled" by the swap activity so we bailed.
2016-01-07 21:54:32 +11:00
Peter Serwylo
b4bf5d6daf Remove unused constant. 2016-01-07 21:54:32 +11:00
Peter Serwylo
16b765a6b8 Handle add repo intents after F-Droid is already open.
Before, it only happened in onResume(). Now, it happens in onNewIntent()
too (but ensures to only handle the same intent once).

Note the onResume() only ever handles the original intent, not the new
intent.

Fixes #524.
2016-01-07 21:54:17 +11:00
relan
e09e1dba0a Properly handle CrashReportActivity recreation
Retain comment text on device rotation.
2016-01-07 11:45:49 +03:00
relan
16170c0901 Fix null pointer exception on crash report sending
EditText with comment is in the dialog, not in the activity.
2016-01-07 11:42:25 +03:00
Daniel Martí
e3b29f9613 Fix regression in prefix/suffix file deletion
This partyally reverts ea3c95832ea733bb4e928772772b13638d243032.

Fixes #537.
2016-01-06 20:48:07 +01:00
Peter Serwylo
db1f54c352 Create fragments appropriately in main view.
The approach to creating fragments in the constructor of the `AppListFragmentPagerAdapter`
was incorrect. Fragments are a special kind of magic, so this commit uses the approach
documented at http://stackoverflow.com/a/15261142 to make sure that the correct
fragment instances are always retrieved.

Fixes #521.
2016-01-06 21:18:41 +11:00
Dominik George
0df829034c
Add author/email/license display capabilities to app. (Closes: #532) 2016-01-05 13:18:38 +01:00
Daniel Martí
ea3c95832e Simplify some ifs
Sometimes joining them, removing unnecessary checks and removing
unnecessary levels of indentation.
2016-01-04 11:03:00 +01:00
Daniel Martí
8e193cecff Apk: Don't create Integer object just to compare 2016-01-03 18:55:15 +01:00
Daniel Martí
87fb293348 Merge branch 'acra-dialog-styles' into 'master'
Use custom layout for ACRA report dialog, not default one.

Styling the default dialog was difficult and it doesn't obey some
of the guidelines provided by the Android design docs:

 https://www.google.com/design/spec/components/dialogs.html#dialogs-specs
 (see "Content Guidelines")

This change introduces a custom dialog extending the base ACRA reporting
activity. Specifically, it introduces a padding of 24dp around the dialog
contents.

I couldn't find design specs on the specific spacing between different elements _within_ the dialog, so I used the same spacing of 20dp suggested to use between the title and the main body of the dialog.

At the very least, this change should make it easier to update styles in the future if somebody suggests improvements to the layout of the dialog.

### Before

![acra-dialog.1](/uploads/9540290fcbe245f8b573506c6a982332/acra-dialog.1.png)

### After

![acra-dialog.2](/uploads/2cad0213101f53edfd32dab69cafa757/acra-dialog.2.png)


See merge request !186
2016-01-03 17:42:17 +00:00
Peter Serwylo
a99767f3a6 Remove icon, add scroll view to crash report dialog.
Scroll view helps with smaller screens. Alert dialog icons are not
part of the material design spec so that was removed.
2016-01-03 15:48:44 +11:00
Daniel Martí
c2c8c55862 Merge branch 'fix-519--crash-during-swap' into 'master'
Partially revert f2212e33. Make some constructors public again.

There is some code in the Android SDK using reflection to find the constructor
of one of our custom views. As such, a previous change in f2212e33 broke this
code because it made constructors package local. This partially reverts the bit
of f2212e33 which pertains to the constructors accessed using reflection.

Fixes #519.

See merge request !187
2016-01-03 01:03:14 +00:00
Peter Serwylo
d24a6b71b9 Partially revert f2212e33. Make some constructors public again.
There is some code in the Android SDK using reflection to find the constructor
of one of our custom views. As such, a previous change in f2212e33 broke this
code because it made constructors package local. This partially reverts the bit
of f2212e33 which pertains to the constructors accessed using reflection.
2016-01-03 11:06:52 +11:00
Daniel Martí
03c0ef5f65 Make checkstyle happy again 2016-01-02 20:00:16 +01:00
Daniel Martí
e1058ba46d Remove unused classes
These were useful at some point, but stopped being used some time ago.
Should have been removed then.
2016-01-02 19:19:16 +01:00
Daniel Martí
d0c8fecfd3 Remove some public fields and methods 2016-01-02 19:13:11 +01:00
Daniel Martí
e34192573d Remove some unused code 2016-01-02 19:04:11 +01:00
Daniel Martí
ae5fb8e8fc Run Studio's imports optimizer 2016-01-02 18:47:59 +01:00
Peter Serwylo
49d01e0ca3 Use custom layout for ACRA report dialog, not default one.
Styling the default dialog was difficult and it doesn't obey some
of the guidelines provided by the Android design docs:

 https://www.google.com/design/spec/components/dialogs.html#dialogs-specs
 (see "Content Guidelines")

This change introduces a custom dialog extending the base ACRA reporting
activity. Specifically, it introduces a padding of 24dp around the dialog
contents.
2016-01-02 13:42:57 +11:00
Daniel Martí
e29b6cbdaf Remove code that worked around #334 (now fixed) 2015-12-29 22:42:49 +01:00
Daniel Martí
3a8051898a checkstyle: be more strict with curly rules 2015-12-29 22:18:38 +01:00
Daniel Martí
c1d4248723 checkstyle: Check comment indentation too 2015-12-29 22:10:19 +01:00
Daniel Martí
9efe173380 checkstyle: Finally add proper indentation checks
Somewhat painful conversion, but should go much smoother from here
onward.
2015-12-29 22:00:23 +01:00
Daniel Martí
0f27374452 checkstyle: forbid inner assignments 2015-12-29 12:55:29 +01:00
Daniel Martí
6a0c230493 Add NonFreeAssets anti-feature 2015-12-29 12:36:15 +01:00
Daniel Martí
0a0dc0d596 AppDetails: don't hide unknown anti-features
This is thinking of the future, when new AFs are added and the installed
client doens't know about them yet. Showing the name is better than not
showing anything at all.
2015-12-29 12:32:21 +01:00
Daniel Martí
209ed1dc62 ACRA: use reports@f-droid.org 2015-12-29 12:10:51 +01:00
Daniel Martí
b22466ee66 Add opt-in crash reporting via ACRA
Fixes #398.
2015-12-26 23:35:48 +01:00
Peter Serwylo
c36529f445 Renaming id -> packageName in local variables/method args/comments/etc. 2015-12-26 15:12:58 +11:00
Peter Serwylo
038816e32a Renamed Apk.id to Apk.packageName 2015-12-25 08:04:52 +11:00
Peter Serwylo
5779736913 Renamed App.id to App.packageName 2015-12-25 08:04:48 +11:00
Peter Serwylo
756df4d635 Renamed Java constant APP_ID to PACKAGE_NAME
In both the ApkProvider and the AppProvider.

Left the underlying database name as 'id' for now because it is
not as important or visible.
2015-12-25 08:04:41 +11:00
Peter Serwylo
60a3804c5a Make sure to insert, rather than update apks when updating repo.
Fixes #517.

The problem was that again, only the `vercode`s of apks were being
compared to see if they were the same, rather than `vercode` and `id`.
The result is that some new apks will incorrectly be asked to execute
an `UPDATE` query rather than an `INSERT`. As such, they don't end
up in our database at all because the `UPDATE` will not run against
any row at all.
2015-12-24 09:59:33 +11:00
Peter Serwylo
b7eb30a69b Merge branch 'fix-517--repo-update-sadness' into 'master'
Correctly purge removed apks.

There were two bugs in this code that have been fixed. Both were
introduced while moving to a lower memory consumption version of
the repo updater for #324.

They were found while investigating #517, although I'm not confident
that they are to do with the specific problem in that issue. It is
possible, because it is part of the code to do with purging apks
from the database, but I'd like to do further investigations into
the code before declaring that this is actually related to that issue.

In the mean time, this includes important fixes, and should probably
go out in an alpha once merged.

The first is that for each app which is updated by a particular repo,
it was not correctly asking the question: "Which apks belonging to
this apk, and provided by this repo, are no longer provided by this
repo?". It was accidentally only comparing the version number of
existing apks in the DB and new apks from the index. This ensures
that the apks being checked to see if they need to be removed or
not are those with the same package name AND the same version code
(provided by the same repo).

The second bug is that when it was persisting a set of apps + apks
to the database, it would ask for existing apks already in the
database for these apps. In this case, there was a bug where of
the 50 apps being persisted, it would only retrieve the first of
these 50 apps from the database to decide if it needed to be
cleaned up or not. Now, it correctly retrieves data from the DB
belonging to all 50 apps.

See merge request !181
2015-12-22 20:34:44 +00:00
Peter Serwylo
70bf49c3ac Correctly purge removed apks.
There were two bugs in this code that have been fixed. Both were
introduced while moving to a lower memory consumption version of
the repo updater.

The first is that for each app which is updated by a particular repo,
it was not correctly asking the question: "Which apks belonging to
this apk, and provided by this repo, are no longer provided by this
repo?". It was accidentally only comparing the version number of
existing apks in the DB and new apks from the index. This ensures
that the apks being checked to see if they need to be removed or
not are those with the same package name AND the same version code
(provided by the same repo).

The second bug is that when it was persisting a set of apps + apks
to the database, it would ask for existing apks already in the
database for these apps. In this case, there was a bug where of
the 50 apps being persisted, it would only retrieve the first of
these 50 apps from the database to decide if it needed to be
cleaned up or not. Now, it correctly retrieves data from the DB
belonging to all 50 apps.
2015-12-22 22:53:01 +11:00
Peter Serwylo
07eb633f0f Merge branch 'master' into 'master'
Add HTTP Basic Authentication to ApkDownloader

In order to download protected files, the APKDownloader must be able to supply HTTP Basic Authentication headers to the server.

See merge request !178
2015-12-22 08:40:08 +00:00
Christian Morgner
25cbf98390 Fixed checkstyle errors. 2015-12-21 10:25:29 +01:00
Christian Morgner
a29bf3d9c8 Added HTTP Basic Authentication to ApkDownloader, added Credentials interface
and HttpBasicCredentials implementation to prepare HttpDownloader for other
authentication methods.
2015-12-20 22:49:15 +01:00
relan
8b89b52d2b Show appropriate message when search results are empty
Closes #512.
2015-12-19 15:35:15 +03:00