1263 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
eed0070d4b do not bail out of wifi settings if there is no DhcpInfo
There is still much useful information to be had without DhcpInfo.
2016-02-27 11:04:08 +01:00
Peter Serwylo
db120133b9 Don't try to start bonjour without an IP.
Although not reproduced, it looks very much like this would be related
to, and should subsequently fix #556.
2016-02-27 09:28:17 +11:00
Peter Serwylo
3dd0589b08 Don't say wifi is connected until both wifi + bonjour are ready.
Although I can't reproduce reliably, I am hopeful that this will resolve
a lot of the errors such as #557.
2016-02-27 09:28:17 +11:00
Peter Serwylo
cd3a064a5a Don't call unregisterService(...) then unregisterAllSerivces().
The later will unregister the service we were explicitly unregistering anyway.
2016-02-27 09:28:17 +11:00
Peter Serwylo
1505d21781 Set connected status after disconnecting from wifi swap. 2016-02-27 09:28:17 +11:00
Peter Serwylo
2ed6110ae5 Cleanup looper after shutting down. 2016-02-27 09:28:17 +11:00
Peter Serwylo
18f97602e8 Don't start swap wifi when there is no network.
Not sure if we should be here or not in this situation, so this is
a little bit defensive. Can't bind to an IP address of `null`, so
don't bother starting LocalHTTP server unless we have an IP.
2016-02-27 09:28:17 +11:00
Peter Serwylo
ddbd9e2ea9 Actually run thread in background.
`Thread.run()` is not the correct call, changed to the correct `Thread.start()`.
Also, explicitly indicate that we want the stopping of wifi to happen in the
background.
2016-02-27 09:28:17 +11:00
Peter Serwylo
1eae135929 Add user feedback for when WiFi is being disabled.
On some devices this can take some time (i.e. a second) and the UI needs
to be disabled for that time. This should stop users quickly stopping and
starting regularly, queuing up many "start jmdns, stop jmdns, start jmdns"
calls.
2016-02-27 09:28:17 +11:00
Peter Serwylo
8364aa15f1 Don't try to start swap again if we have gone from network -> no network. 2016-02-27 09:27:57 +11:00
Daniel Martí
b08b97466f Fix a single rogue ellipsis 2016-02-26 15:00:50 +00:00
Daniel Martí
91c3278920 Take RTL suggestions from lint (warnings) 2016-02-26 14:57:42 +00:00
Daniel Martí
e390561c7c install_confirm: remove useless lines
These are already in its layout-v11 version. And as lint points out,
these need v11:

	?android:attr/buttonBarStyle requires API level 11 (current min is 8)
	?android:attr/buttonBarButtonStyle requires API level 11 (current min is 8)
2016-02-26 14:48:45 +00:00
Daniel Martí
1b6fc3da7c Move app_permission_item_money to layout-v17
Since it's only ever used on android-17 or later, move it there to keep
lint happy with all the NewApi errors.
2016-02-26 14:47:09 +00:00
Daniel Martí
5179e032db Fix NewApi bug introduced in 8e193cec 2016-02-26 14:39:02 +00:00
Daniel Martí
43a3c2b042 Remove useless app:backgroundTint from layouts
app:backgroundTint only works on AppCompatButton from v7-appcompat.
We're using a regular Button in these, so this attribute is useless and
makes lint error.

More info:

	https://stackoverflow.com/questions/27735890/lollipops-backgroundtint-has-no-effect-on-a-button
2016-02-26 14:26:05 +00:00
Daniel Martí
cdecc1604c Add all missing Left/Right attributes in RTL
This improves support on older Android releases.
2016-02-25 16:56:23 +00:00
Daniel Martí
073052f5cc Move app_description to donottranslate.xml
As lint points out, only the original string is used in the
AndroidManifest.xml. So having it translated is useless.
2016-02-25 16:40:58 +00:00
Daniel Martí
54c4714b9d Fix string format issues 2016-02-25 13:56:06 +00:00
Daniel Martí
6b9d6b6be5 Add a py script to check for bad string formats
Lint finds these, but it's very slow and currently we're not taking lint
errors as fatal. So for now this script will be useful, as nearly every
time I pull from weblate there are at least a couple of these.
2016-02-25 13:56:01 +00:00
Daniel Martí
7e86dc5e48 Convert existing py tools to python3 2016-02-25 13:39:39 +00:00
F-Droid Translatebot
d79fccb2da Pull translation updates from Weblate
Translators:

agilob                 Polish
Hsiu-Ming Chang        Chinese (Taiwan)
Nathan Follens         Dutch
Perry Verheij          Dutch
Robin van der Vliet    Dutch
Robin van der Vliet    Esperanto
Verdulo                Esperanto
Wathiq Qajar           Arabic
2016-02-25 12:38:43 +00:00
Daniel Martí
5cca8102d7 Update commons-io test dep to 2.4
Ran the tests locally, all still pass.
2016-02-22 18:47:25 +01:00
Daniel Martí
9fe6545654 Update ACRA to 4.8.2 2016-02-22 18:45:21 +01:00
Daniel Martí
17c731ef1d checkstyle: obey ConstantName 2016-02-17 15:59:04 +00:00
Daniel Martí
a6b804e93a checkstyle: obey NeedBraces on multi-line stmts
We still allow them in single-line statements, like:

	if (foo) bar;
	for (int i : ints) bar;

Everything else should use braces to help readability and avoid silly
human mistakes that might result in bugs.

These changes were completely automated via a python script.
2016-02-17 12:04:36 +00:00
F-Droid Translatebot
6d6aa98c6b Pull translation updates from Weblate
Translators:

Hsiu-Ming Chang    Chinese (Taiwan)
Verdulo            Esperanto
2016-02-16 11:58:04 +00:00
Daniel Martí
e066ed04dc Search: clear focus when enter/return is pressed
Fixes #572.
2016-02-15 16:47:25 +00:00
Daniel Martí
247dfc5ecf Run remove-unused-trans.py 2016-02-14 15:15:15 +00:00
F-Droid Translatebot
6a6a37c42e Pull translation updates from Weblate
Translators:

Coucouf           French
Danial Behzadi    Persian
Green Lunar       Hebrew
Licaon Kter       Romanian
M2ck              French
Marian Hanzel     Slovak
Verdulo           Esperanto
Verdulo           Polish
2016-02-14 15:14:22 +00:00
Peter Serwylo
88b4e1ff31 Merge branch 'fix-554' into 'master'
Work around dead activity issue in AppDetails

It seems like install() sometimes runs when the AppDetails activity is
finished or finishing. This results in the windows (dialogs) failing to
show, and a BadTokenException to fire:

    android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@d6e3570 is not valid; is your activity running?

This seems to be the culprit:

    at org.fdroid.fdroid.AppDetails.install(AppDetails.java:840)
    at org.fdroid.fdroid.AppDetails$AppDetailsListFragment.install(AppDetails.java:1657)
    at org.fdroid.fdroid.AppDetails$AppDetailsListFragment.onListItemClick(AppDetails.java:1721)

Apparently, you can check whether an activity/context is being finished:

https://stackoverflow.com/questions/7811993/error-binderproxy45d459c0-is-not-valid-is-your-activity-running

I cannot reproduce this issue, thus can't say whether this fixes it or
not. Either way, it can't hurt to try. This can be reverted if we see
ACRA reports of this in the future, and the issue reopened.

Fixes #565.

See merge request !204
2016-02-13 21:49:22 +00:00
Daniel Martí
f6724413b0 WifiStateChangeService: Avoid DhcpInfo NPE
Fixes #569.
2016-02-12 13:04:28 +00:00
Daniel Martí
1a1ece16cf Work around dead activity issue in AppDetails
It seems like install() sometimes runs when the AppDetails activity is
finished or finishing. This results in the windows (dialogs) failing to
show, and a BadTokenException to fire:

    android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@d6e3570 is not valid; is your activity running?

This seems to be the culprit:

    at org.fdroid.fdroid.AppDetails.install(AppDetails.java:840)
    at org.fdroid.fdroid.AppDetails$AppDetailsListFragment.install(AppDetails.java:1657)
    at org.fdroid.fdroid.AppDetails$AppDetailsListFragment.onListItemClick(AppDetails.java:1721)

Apparently, you can check whether an activity/context is being finished:

https://stackoverflow.com/questions/7811993/error-binderproxy45d459c0-is-not-valid-is-your-activity-running

I cannot reproduce this issue, thus can't say whether this fixes it or
not. Either way, it can't hurt to try. This can be reverted if we see
ACRA reports of this in the future, and the issue reopened.

Fixes #565.
2016-02-09 20:48:42 +00:00
Daniel Martí
9195e3c614 Bump to 0.99-alpha1 2016-02-09 16:04:29 +00:00
F-Droid Translatebot
4148edeccd Pull translation updates from Weblate
Translators:

Allan Nordhøy    Norwegian Bokmål
Licaon Kter      Romanian
2016-02-09 16:00:10 +00:00
Daniel Martí
401a1d473d Drop unnecessary elses after returns 2016-02-09 15:59:47 +00:00
Daniel Martí
9997b0f448 Merge branch 'fix-555--content-provider-invalid-uri' into 'master'
Fix 555  content provider invalid uri

Was not correctly encoding "/" characters when searching. This caused the Uri used by the Content Providers to include a slash, which makes it look like a separate segment of the path which was wrong. Now correctly encodes "/" characters. Also noticed one other place incorrectly encoding characters, where they would've been double encoded when added as query parameters to a Uri.

See merge request !203
2016-02-09 15:55:38 +00:00
Peter Serwylo
c0d752cce3 Merge branch 'reactivex--swap--peer-finders' into 'master'
Refactor swap "peer finders" to use ReactiveX

*NOTE: This includes the commit specified by !197.*

In the old code, there is a _lot_ of procedual style "Is this peer finder running, if so, do this". In addition, the choice to do things on background threads or not is a little ad-hoc. Finally, the `SwapService` needs to know about both bluetooth and wifi peer finders, whereas really they are both only there to emit "Peers", regardless of the type.

As such, some improvements in this change are:
 * The choice to run peer finding on a background thread is made once, at a higher level when starting the peer finder.
 * No longer does the UI code ask "Am I searching for peers". It instead waits to be told whether it is or isn't.
 * The addition of new types of peers in the future is the job of the Peer finder itself. It quietly aggregates all of the Peer Finders it knows about into a single observable that emits different types of peers.

This code doesn't fix any particular issue, but rather it is about making the entire swap workflow easier to reason about. I plan on migrating more of this workflow to this functional style in the future, and hopefully that will have benefits in terms of stability and code understanding.

See merge request !198
2016-02-07 00:08:03 +00:00
Peter Serwylo
d939e9dac9 Minor fixes due to CR. 2016-02-07 10:39:01 +11:00
Daniel Martí
416c7aff82 Update ACRA to 4.8.1
Fixes nasty crash on android-19 and earlier.
2016-02-06 23:35:43 +00:00
F-Droid Translatebot
597e9c42a2 Pull translation updates from Weblate
Translators:

fabrizio maggi     Italian
Gabriele Pau       Italian
Irvan Kurniawan    Indonesian
Karola Marky       Latvian
Patrik Kretic      Slovenian
riotism            Chinese (Hong Kong)
2016-02-06 12:09:08 +00:00
Peter Serwylo
e57b034a62 Add test for searching for forward slashes. 2016-02-06 14:04:28 +11:00
Peter Serwylo
81b772c3fd Use appendPath(...) instead of appendEncodedPath(...).
I misread the documentation when first using the `appendEncodedPath` method,
because it expects the path to already be encoded. This causes a bug because
if you search for a '/'. The result is a malformed URI that has the path
'/search//' instead of '/search/%2F'.

Using `appendPath` will always encode the string given to it, which is desirable.

Also check for empty strings, and return a URI that gives all apps. This was
not strictly neccesary, because the code which invokes it checks for empty
strings, but if somewhere else in the future starts to use this code, they
would've had to know to check for empty strings first.

Fixes #555.
2016-02-06 14:02:54 +11:00
Peter Serwylo
46817b1893 Add tests for searching null or empty values.
Should help prevent abuse of the search API into the future.
2016-02-06 13:33:36 +11:00
Peter Serwylo
5f08181f7d Remove unused SearchResultsFragment.
This is left over from when the search functionality was updated recently.
2016-02-06 13:33:36 +11:00
Daniel Martí
0646b6473e Merge branch 'fix-286--refreshHeader-crash' into 'master'
Put null check around access of `R.id.header` fragment.

Please note I haven't reproduced the specific problem. Also, the stack
traces being reported are only marginally informative, because they are
in response to a content providers firing events, and thus don't have
any context about when or where the event was fired from.

However, my looking at the code seems to indicate that this will prevent
NPE when the Activity is no longer visible but an app is finished
installing. Also, the view should still update correctly on resuming the
Activity because the `onResumeFragments()` methods will be invoked
which invokes the `refreshHeaders()` method.

Fixes #286.

See merge request !202
2016-02-06 00:04:26 +00:00
Peter Serwylo
d9f0c86c2e Put null check around access of R.id.header fragment.
Please note I haven't reproduced the specific problem. Also, the stack
traces being reported are only marginally informative, because they are
in response to a content providers firing events, and thus don't have
any context about when or where the event was fired from.

However, my looking at the code seems to indicate that this will prevent
NPE when the Activity is no longer visible but an app is finished
installing. Also, the view should still update correctly on resuming the
Activity because the `onResumeFragments()` methods will be invoked
which invokes the `refreshHeaders()` method.

Fixes #286.
2016-02-05 22:50:11 +11:00
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