3187 Commits

Author SHA1 Message Date
Peter Serwylo
10ccd5c503 Reimplement "peer finder" logic using funcitonal ReactiveX style.
The benefits of this are as follows:

No longer need to worry about how many types of `Peer`s exist.
There is a single publicly accessible `PeerFinder` which aggregates
the results of both the Bluetooth and Bonjour peer finders. In the
future if another is added, the consumer of the peer finder
(i.e. `StartSwapView`) doesn't need to be aware of this. Neither does
the `SwapService` or `SwapActivity` or any other code.

Never ask "Are we searching" but instead receive push notifications
from the peer finder when it stops searching.

Don't worry about receiving the same peer multiple times, it will
automatically get filtered out.

Less concern about doing things in `AsyncTasks` (and knowing what to
do in an `AsyncTask`). The RXJava + RXAndroid libraries deal with this
by allowing the client consuming the `PeerFinder` to specify which
thread to perform the background task on, and also that the found
`Peer`s should be emitted on the UI thread.

In the future, can play with caching the results of a particular
sequence of found peers. However right now using the `Observable.cache()`
method means we can no longer unsubscribe from the peer finders
and thus they run longer than they need to when we move on from
the initial swap screen.
2016-02-05 15:39:40 +11:00
Peter Serwylo
73d24d987e Add exception for rxjava in Proguard.
The rxjava library depends on sun.misc.Unsafe, which is unavailable on Android
The rxjava team is aware of this, and mention in the docs that they only use
the unsafe functionality if the platform supports it.
 - https://github.com/ReactiveX/RxJava/issues/1415#issuecomment-48390883
 - https://github.com/ReactiveX/RxJava/blob/1.x/src/main/java/rx/internal/util/unsafe/UnsafeAccess.java#L23
2016-02-05 14:21:13 +11:00
Peter Serwylo
5c85302928 Add ReactiveX (rxjava + rxandroid) as dependency
This is going to be used to make the managing of async tasks in
F-Droid easier to reason about. It does this by using a more
functional style to performing multiple different asynchronous tasks
as compared to the Android `AsyncTask` or `Service` or some other approach.
2016-02-05 11:50:54 +11:00
Daniel Martí
23612570a8 Merge branch 'build' into 'master'
fix AOSP build integration

The build isn't done from the top-level directory so the symlink needs
to use an absolute path.

Fixes #551.

See merge request !200
2016-02-03 22:07:39 +00:00
Daniel Martí
29b6b261a2 Merge branch 'fix-560--searching-only-whitespace' into 'master'
Fix 560  (searching only whitespace)

When no keywords to search, use an empty query selection that evaluates to "1".

This means that instead of building invalid SQL such as `WHERE (() OR ())` it
will build `WHERE((1) OR (1))` which, while non-optimal, is at least valid.
In fact, I'm not even sure that it is non optimal because I'd hope the sqlite
query optimizer is able to realise that `1 OR 1` is effectively a no-op.

Fixes issue #560.

See merge request !201
2016-02-03 21:31:15 +00:00
Peter Serwylo
8060ac88c3 Don't update search query unless it has changed meaningfully.
Changing the search query is quite an expensive operation, so this does some rudimentary
checking to see if the two queries are meaningfully different. At present, it trims the
strings and does a case insensitive comparison.

The query is eventually exploded based on whitespace, so leading and trailing white
space is not important. Also, sqlite `LIKE` clauses are case insensitive, so case
is unimportant. Having said that, I'm not sure how someone will be able to change
the queries case without first deleting and then adding characters (thus inducing
meaningfull changse).
2016-02-04 07:51:41 +11:00
Peter Serwylo
bd0e9e0a3c When no keywords to search, use an empty query selection that evaluates to "1".
This means that instead of building invalid SQL such as `WHERE (() OR ())` it
will build `WHERE((1) OR (1))` which, while non-optimal, is at least valid.

Fixes issue #560.
2016-02-04 07:51:37 +11:00
Daniel Micay
71c507bbfd fix AOSP build integration
The build isn't done from the top-level directory so the symlink needs
to use an absolute path.

Fixes #551.
2016-02-03 13:33:04 -05:00
Peter Serwylo
02c8fac906 Merge branch 'null-uri-path' into 'master'
Avoid NPE in Uri.getPath().replaceAll()

Fixes #533.

See merge request !199
2016-02-03 09:17:11 +00:00
Daniel Martí
a028b3f6a2 Avoid NPE in Uri.getPath().replaceAll()
Fixes #533.
2016-02-02 21:55:45 +00:00
Ciaran Gultnieks
1cd0bf721a Set date for 0.98 in changelog 2016-02-02 18:09:59 +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í
7f78b46664 Remove AndroidPinning dependency
Its use was removed long ago, and the dependency was left behind for
some reason. This commit can be reverted if it's needed in the future
again.

This of course slightly simplifies the build thus speeding it a little,
but what's more interesting is that the output apk is also ~100KB
smaller. So something is going on.
2016-02-01 14:31:44 +00:00
Daniel Martí
c198736cd1 Update ACRA to 4.8.0 2016-02-01 14:21:49 +00:00
Daniel Martí
a3d4c87101 Update libsuperuser to 1.0.0.201602011018 2016-02-01 14:16:49 +00:00
Daniel Martí
df6d1fe625 Bump checkstyle to 6.15 2016-02-01 14:08:59 +00:00
F-Droid Translatebot
bf435bce66 Pull translation updates from Weblate
Translators:

bd339                      Danish
Danial Behzadi             Persian
David Koňařík              Czech
Massimiliano Caniparoli    Italian
Olexandr Nesterenko        Ukrainian
Sebastiano Pistore         Italian
Tobias Bannert             German
Tong Hui                   Chinese (China)
2016-02-01 12:23:04 +00:00
Daniel Martí
f79d14a59c Bump to alpha0 after stable 2016-02-01 12:21:37 +00:00
Daniel Martí
10a8f349a1 CHANGELOG: Add note about db lock fix 2016-02-01 12:15:26 +00:00
Daniel Martí
b193a10e69 Bump to 0.98-alpha7 v0.98-alpha7 2016-01-29 12:11:16 +00:00
Daniel Martí
64c0950e76 Fix formatting in values-fa
As reported by a user via ACRA:

java.util.UnknownFormatConversionException: Conversion: I
        at java.util.Formatter$FormatToken.unknownFormatConversionException(Formatter.java:1399)
        at java.util.Formatter$FormatToken.checkFlags(Formatter.java:1336)
        at java.util.Formatter.transform(Formatter.java:1442)
        at java.util.Formatter.doFormat(Formatter.java:1081)
        at java.util.Formatter.format(Formatter.java:1042)
        at java.util.Formatter.format(Formatter.java:1011)
        at java.lang.String.format(String.java:1988)
        at android.content.res.Resources.getString(Resources.java:355)
        at android.content.Context.getString(Context.java:350)
        at org.fdroid.fdroid.UpdateService$1.onReceive(UpdateService.java:210)
        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:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5136)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:740)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
        at dalvik.system.NativeStart.main(Native Method)
2016-01-27 10:58:10 +00:00
Peter Serwylo
bf90cf7e9f Remove unused import to make checkstyle happy 2016-01-27 07:20:56 +11:00
Daniel Martí
ac0ab7e211 Merge branch 'fix-265--database-locked-crash' into 'master'
Fix 265  database locked crash (I'm pretty sure)

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()`.

See merge request !196
2016-01-26 11:38:34 +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
F-Droid Translatebot
5a03f6a786 Pull translation updates from Weblate
Translators:

Enol Puente       Asturian
nautilusx         German
Sérgio Marques    Portuguese (Portugal)
Саша Петровић     Serbian
2016-01-25 11:34:20 +00: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
Daniel Martí
426e3da139 README: Add FAQ section with privileged stuff
There's often a lot of confusion about this, so have it summarized here.
2016-01-19 15:36:54 +01:00
Daniel Martí
11a80ced6b Bump Privileged Extension to 0.1 2016-01-19 15:27:44 +01:00
Daniel Martí
fed9e8d103 Bump to 0.98-alpha6 v0.98-alpha6 2016-01-19 15:21:28 +01:00
Daniel Martí
31e99a1331 Merge branch 'fix-541--ignoring-malformed-uri' into 'master'
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.

See merge request !195
2016-01-19 11:32:13 +00: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
F-Droid Translatebot
05c6269d53 Pull translation updates from Weblate
Translators:

Adam Magnier               French
Adrià García-Alzórriz      Catalan
Adrià García-Alzórriz      Spanish
Ajeje Brazorf              Sardinian
Alberto Moshpirit          Spanish
Dominik george             French
Dominik george             German
Enol Puente                Asturian
Jean-Baptiste              French
M2ck                       French
Marcelo Santana            Portuguese (Brazil)
Massimiliano Caniparoli    Italian
Mladen Pejaković           Serbian
Nam Mai Hoang              Vietnamese
naofum                     Japanese
Nick Bishop                Greek
riotism                    Chinese (Hong Kong)
Sérgio Marques             Portuguese (Portugal)
tacsipacsi                 Hungarian
ultrapeer                  Turkish
Андрій Бандура             Ukrainian
Дмитрий Михирев            Russian
2016-01-14 22:56:44 +01:00
Daniel Martí
0e60886f14 Run optipng on new drawables 2016-01-11 01:49:58 +01: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
Daniel Martí
9b01f86fef Merge branch 'fix-524--fdroidrepos-urls' into 'master'
Handle  fdroidrepos:// urls better.

Before, it only handled the incoming `Intent` 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. See inline comments for why.

Fixes #524.

See merge request !192
2016-01-07 13:48:11 +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
relan
fea2f9b9cf Use proper theme for CrashReportActivity
It's an activity, not a dialog.
2016-01-07 11:11:01 +03:00
Daniel Martí
b22674e3e3 README: SDK and gradle are not the only build deps
There's also OpenJDK, the android target and build-tools, for example.
2016-01-06 21:55:33 +01:00
Daniel Martí
6ab5299e40 checkstyle: clean up modules we'll never use 2016-01-06 21:51:23 +01: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
Daniel Martí
dfa3ba2c99 Merge branch 'fix-521--search-after-activity-destroyed' into 'master'
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.

See merge request !190
2016-01-06 17:12:21 +00:00
Daniel Martí
06c7bb8286 Remove unused strings
These stopped being used after the search and repo update makeovers.
2016-01-06 18:07:43 +01:00
F-Droid Translatebot
26e0708573 Pull translation updates from Weblate
Translators:

Ajeje Brazorf                               Sardinian
Alberto Moshpirit                           Spanish
hrskrs                                      Albanian
Kalle Lampila                               Finnish
Mladen Pejaković                            Serbian
Persian: fix format strings Daniel Martí
Tobias Bannert                              German
2016-01-06 18:04:18 +01:00