804 Commits

Author SHA1 Message Date
Daniel Martí
0fba2c255e Add START_OF to LayoutCompat.RelativeLayout 2014-02-21 00:11:58 +01:00
Daniel Martí
a3024bc837 Don't crash RepoDetailsFragment if nfc is not available 2014-02-21 00:10:52 +01:00
Daniel Martí
2c9d8ab7fc Merge commit 'refs/merge-requests/66' of gitorious.org:f-droid/fdroidclient
Conflicts:
	test/src/org/fdroid/fdroid/ApkProviderTest.java
2014-02-20 08:00:12 +01:00
Peter Serwylo
2dcd87cd41 Almost 100% test coverage of ApkProvider and ApkProvider.Helper
Removed unused code from ApkProvider.Helper, made it throw proper
exceptions when trying unsupported operations. Refactored tests
a little bit to facilitate separate test cases for the provider
and its helper.
2014-02-20 16:13:37 +11:00
Peter Serwylo
3240faf7f2 Fix "duplicate column: maxage" (issue #445)
The bug is explained in detail in the issue tracker.
This change added guard condition to check for existence of the field
before adding.

While I was at it, I also guarded a bunch of other ALTER statements
with the if (!columnExists()) check. It turns out that many of them
break, but we only saw the first one because it threw an exception
before getting to the others.
2014-02-20 15:55:29 +11:00
Hans-Christoph Steiner
576208d3aa Exception subclasses are supposed to have a serial number
This warning in Eclipse tells me so:

"The serializable class UpdateException does not declare a static final
serialVersionUID field of type long"
2014-02-19 20:11:30 -05:00
Hans-Christoph Steiner
27874b3a9e parameterize CategoryObserver.adapter
Helps Java do its error checking... and gets rid of a few warnings...
2014-02-19 20:06:17 -05:00
Hans-Christoph Steiner
dd3562c00f remove unnecessary cast
This is pretty cosmetic, but Eclipse did it for me, so why not? :-)
2014-02-19 20:06:17 -05:00
Hans-Christoph Steiner
888d28aed6 @Override decorator on every method that overrides
This marks a method as overriding another method, and makes sure that it
matches the signature of the method it is supposed to be overriding,
otherwise it gives a warning.

Its a bit verbose, but can catch mistakes and save time. And the default
Android profile for Eclipse always adds them automatically...
2014-02-19 20:06:05 -05:00
Hans-Christoph Steiner
301ac10515 remove trailing white space... 2014-02-19 19:59:31 -05:00
Hans-Christoph Steiner
3a0d40d86d remove all unused variables
This reduces the number of warnings so that we can see the useful ones!
2014-02-19 19:53:38 -05:00
Hans-Christoph Steiner
5d828e2341 remove all unused imports
This reduces the number of warnings so that we can see the useful ones!
2014-02-19 19:52:36 -05:00
Daniel Martí
231fb3dd8a Merge commit 'refs/merge-requests/65' of gitorious.org:f-droid/fdroidclient
Conflicts:
	src/org/fdroid/fdroid/views/fragments/RepoListFragment.java
2014-02-19 23:12:19 +01:00
Hans-Christoph Steiner
94fb0c8a02 prevent crash when clicking on the header in "Repositories" view
Here's the crash dump:

java.lang.NullPointerException
at org.fdroid.fdroid.data.ValueObject.checkCursorPosition(ValueObject.java:13)
at org.fdroid.fdroid.data.Repo.<init>(Repo.java:37)
at org.fdroid.fdroid.views.fragments.RepoListFragment.onListItemClick(RepoListFragment.java:269)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:299)
at android.widget.AbsListView.performItemClick(AbsListView.java:1113)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:2904)
at android.widget.AbsListView$3.run(AbsListView.java:3638)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
2014-02-20 08:58:58 +11:00
Peter Serwylo
4d5fd98ae5 Fixed two NPE.
Categories can technically be null, so need to guard for that
when getting them from the ContentProvider. This occurred because
I had an old index from before the change from "category" to
"categories", so it indeed was null.

The other one was from when I added a new repo without a fingerprint.
The fingerprint gets changed to upper case, but if null, causes
a NPE.
2014-02-20 08:55:44 +11:00
Daniel McCarney
3223e20e33 Add support for Network Service Discovery of FDroid repos.
If the device supports API level 16 (Android 4.1) then add a menu item
on the repository management screen to "Find Local Repos". Activating
this menu item will initiate NSD service discovery with the NsdHelper
class looking for 'fdroidrepo' and 'fdroidrepos' service types on the
local network. When one is found, the service is resolved and the name
& IP are populated into a list of discovered repositories. Clicking an
NSD discovered repo will prompt the user to add the repo.
2014-02-19 15:32:44 -05:00
Daniel Martí
e6ec5ee242 Add support for filtering apk compatibility by maxSdkVersion
For now it's enforced like minSdkVersion. It is possible to try and install
incompatible apks by enabling "Incompatible Versions" and agreeing to the
warning shown when clicking on such a version.
2014-02-19 18:11:32 +01:00
Daniel Martí
dc1bdc2f3b Make the incompatible reasons textview stand out
In other words, don't disable the view with the others when marking an apk as
incompatible
2014-02-19 18:07:34 +01:00
Hans-Christoph Steiner
a4de616b7a make ApkProvider.Helper take Context rather than ContentResolver
This makes the code a bit neater, and passing the Context around is a
common pattern.

https://dev.guardianproject.info/issues/2926
refs #2926
2014-02-18 19:04:05 -05:00
Hans-Christoph Steiner
ab6166c36d make RepoProvider.Helper take Context rather than ContentResolver
This makes the code a bit neater, and passing the Context around is a
common pattern.

https://dev.guardianproject.info/issues/2926
refs #2926
2014-02-18 19:04:05 -05:00
Peter Serwylo
5877af55ae Merge branch 'master' into improvements/apk-tests
Conflicts:
	test/src/org/fdroid/fdroid/AppProviderTest.java
2014-02-19 09:38:40 +11:00
Peter Serwylo
4860e06af3 Improved apk tests (test deleting). 2014-02-19 08:12:21 +11:00
Peter Serwylo
68a719f48a Don't overwrite "ignore updates" settings on update.
For now, the UpdateService ignores these fields when updating from
the index. There is no time that the index should specify what
versions to be ignored.

In the future, this will be done with a join table that stores
info about what to ignore. Another future improvement should also be
to make "App.toContentValues()" smarter. That is, make it only return
values which have been set since the object was created. However this
will add an overhead which may or may not be noticable.
2014-02-18 08:11:02 +11:00
Peter Serwylo
85f3232de0 Started implementing ApkProvider tests.
Refactored a couple of common things from AppProviderTest to either
FDroidProviderTest (baseclass) or TestUtils (static methods) where
relevant.
2014-02-18 02:52:02 +11:00
Daniel Martí
799be52224 Fix regression: Don't count apps which we don't want to update 2014-02-17 16:09:57 +01:00
Daniel Martí
4e26c77327 Don't crash on startup if NFC is not available 2014-02-15 11:23:30 +01:00
Hans-Christoph Steiner
c0cd0d33bf send the FDroid.apk via bluetooth on devices that support it
This is another easy method to send FDroid to a device that doesn't have it
yet.  Unfortunately, stock Android blocks the receiving of APKs, but many
ROMs and even some Samsung devices do not have this block.

You can find the lengthy backstory on this work here:
https://dev.guardianproject.info/issues/2084
2014-02-14 22:45:48 -05:00
Hans-Christoph Steiner
9c9c0a4819 setup main FDroid screen to NFC Beam the FDroid.apk
This pre-configures a file:// URI that points to the installed location of
the FDroid.apk.  When users put two devices together, and touch the screen
on the device with FDroid on it, it will "beam" over the APK, and prompt
the user to install it.
2014-02-12 21:19:19 -05:00
Hans-Christoph Steiner
ceed2c31d7 prevent crash when using back button after screen rotate
To reproduce the crash:
0. click a fdroidrepo:// URI to bring up the "app repo" dialog
1. rotate the device
2. click back to make the keyboard go away
3. click back to make the dialog go away
4. click back on Manage Repos screen
5. boom!
2014-02-12 21:19:19 -05:00
Hans-Christoph Steiner
ba8de64686 split out RepoListFragment from ManageRepo, Fragments need to be public
Otherwise we get errors like this upon rotation:

"android.support.v4.app.Fragment$InstantiationException: Unable to
instantiate fragment org.fdroid.fdroid.RepoListFragment: make sure class
name exists, is public, and has an empty constructor that is public"
2014-02-12 21:19:19 -05:00
Hans-Christoph Steiner
ea7f82ed1a add menu item to enable NFC to RepoDetails view
It is now possible to beam a repo config via NFC but just selecting the
repo in FDroid, then touching two NFC devices together, and clicking on the
FDroid one.  There is no indication that NFC is off, so this commit adds a
menu item that makes it easy to enable the required NFC settings for
sending a repo to another device via NFC.
2014-02-12 21:19:19 -05:00
Hans-Christoph Steiner
4489037619 NFC beam the repo in RepoDetailsActivity
This is the framework for easily swapping repos.  The idea is that a user
can send the URL with the fingerprint for trusted bootstrapping of the repo
on a new user's device.  This will be essential for p2p repos provided
by Bazaar/Kerplapp.

The required NFC APIs were introduced in android-14. So android-14 and below
skip the NFC stuff.
2014-02-12 21:19:19 -05:00
Hans-Christoph Steiner
220b3d1441 ensure repo fingerprints are always stored in all upper case
this makes sure that the repo fingerprints are always going to have the
same case, no matter how they were added.  Repo.fingerprint probably should
be converted to a BigInteger so that the comparison can be numeric rather
than String.  Then when the fingerprint needs to be displayed, it can be
formatted appropriately.
2014-02-12 21:19:19 -05:00
Hans-Christoph Steiner
ae10cd0db4 save/restore current category in Available view
This saves the currently selected category in the Available apps view, and
restores that category when the user returns to the Available screen. It
drives me totally nuts that it always forgets the category when I nav away
from that screen, always returning to What's New.
2014-02-12 21:19:19 -05:00
Daniel Martí
2f6a812fdc Fix db rewrite regression, filtering pref used the wrong way 2014-02-12 20:53:26 +01:00
Daniel Martí
81359f929e Place top categories in the original order 2014-02-11 09:06:36 +01:00
Peter Serwylo
1083f57ec1 Case insensitive sort of app list, if sorting by name. 2014-02-11 10:19:32 +11:00
Peter Serwylo
7ca6db9555 Added ArrayAdapterCompat so addAll doesn't need to be wrapped in a guard condition. 2014-02-11 10:12:29 +11:00
Peter Serwylo
ef784dffa8 Update categories list after app list update. 2014-02-11 09:02:03 +11:00
Peter Serwylo
e4d106a298 Fixed incorrect size of category spinner. 2014-02-11 08:30:36 +11:00
Daniel Martí
292cc40bc4 Tabbing fixes 2014-02-09 16:35:02 +01:00
Peter Serwylo
da8e41249b Removed DB, implemented AppProvider.
Yay!

As expected, a lot of the stuff in DB class is due to UpdateService
requiring it to process the downloaded indexes and insert data into
the database. Thus, this change is about removing that stuff from
the DB class and migrating to ContentProviders.

This required a bit of a change to the way that UpdateService decides
what to do with the data from indexes, but I hope it will make
understanding and changing UpdateService easier in the long term.
For example, it used to read the app details from database, then
if a repo wasn't updated (due to unchanged index) then it would take
the app details for that repo from the list of apps, and re-update
the database (or something like that).

Now, it has been refactored into the following methods:
 * updateOrInsertApps(appsToUpdate);
 * updateOrInsertApks(apksToUpdate);
 * removeApksFromRepos(disabledRepos);
 * removeApksNoLongerInRepo(appsToUpdate, updatedRepos);
 * removeAppsWithoutApks();
 * and probably some others...
Which hopefully are self-explanitory.

The recent change to implement single repo updates was re-implemented
with in light of the methods above. The interface to UpdateService for
scheduling a single repo update is the same as it was before, but
the implementation is completely different. Still works though.

Using batch content provider operations for repo updates,
but they suffer from the problem of not all being under the same
transaction, so if an insert/update stuffs up half way through, we
are left with only half of the update being complete. In the future,
if there is some way to implement notifications from the content provider's
applyBatch method, then we can do it all in the one transaction, and
still have notifications. Currently we break it into several calls
to applyBatch (and hence several transactions) to inform the user
of the progress.

Also adding the beginnings of some tests for AppProvider. In the future, I'll
work on adding better coverage, including instrumentation to test UI features.

==========================
Below is a list of many of the minor changes that also happened along the way
==========================

Make "Can update" tab stay up to date using content observer, rather
than manually deciding when to refresh the tab label as before.

The installed app list is now cached in Utils, because it is invoked
quite a few times, especially when rendering the app lists. The cache is
invalidated when PackageReceiver is notified of new apps.

The content providers don't notify changes if we are in batch mode.
I've left the notification at the end of the batch updates as the
responsibility of the UpdateService. However, it would be nice if this
was somehow handled by the content, as they are really the ones who
should worry about it.

Made curVersion, curVercode and curApk work with providers.
This was done by removing curApk (otherwise we'd need to query the db each
time we fetched one app to get a reference to that apk (resulting in hundreds
of queries). Instead, UpdateService now calculates curVercode and curVersion
and saves them to the database. We then use these where possible. If we really
need curApk (because we want info other than its version and code) we still have
the option of ApkProvider.Helper.find(app.id, app.curVercode). I considered
putting this inside the app value object, e.g. in getCurApk() but thought
better of it as it will likely result in people invoking it all the time,
without realising it causes a DB query.

incompatibleReasons required a minor UI tweak, removing the "min sdk"
ui element from the Apk list. It is replaced by the "Requires: %s" view
(which only appears when the app is incompatible). In the process, and in
response to some feedback from mvdan, I left the min sdk in there, but
only made it show when in "expert mode", just like the architecture.

In order to make the "installed apps" query work under test conditions,
needed to change the way the InstalledApkCache be replaceable with a
mock object.

Pause UIL loading on fast scroll of list, as the list was very choppy for
some reason.

Re-added "Last repo scan" info to the Manage Repo list view.

Fixed up some misc TODO's, removed some unused/empty functions.
2014-02-08 11:29:59 +11:00
Peter Serwylo
b3773a1561 Refactoring Apk references into content provider.
Removed DB.Apk in favour of stand-alone Apk class.

Conflicts:
	src/org/fdroid/fdroid/DB.java
2014-02-01 21:40:15 +11:00
Daniel Martí
c8016e9af2 Merge commit 'refs/merge-requests/52' of gitorious.org:f-droid/fdroidclient 2014-01-29 23:29:27 +01:00
Peter Serwylo
f098b9c6d8 Trim search string before querying for apps.
Fixes issue #452. It turns out that recent versions of android do
this automatically, but my gingerbread emulator didn't.

In the process, I also refactored the getQuery method. It was previously
a void method that modified the state of the search view, which is a
bit counter-intuitive given it's name. Instead, I made it just a getter,
which calculates the query and returns it. That way, I was able to remove
mQuery from the fields in the search view. Generally, the less state we
need to worry about (e.g. fields in an object), the less assumptions we
need to make about whether that field has been set or not.
2014-01-30 20:22:35 +11:00
Peter Serwylo
4a7f0ef9a2 Resolve memory issue when updating repo.
Solves issue # 453. Previously, it was reading one line at
a time of the index file. Turns out that the entire index is
only on about 5 lines, thus the 5th line is about 2mb. The
solution here is to switch to reading a fixed length of 4096
characters at a time rather than entire lines. This ends up
a bit more complex (because I wrote a custom tokenizer rather
than being able to use Java String methods such as indexOf).

There are still other memory issues on low memory devices,
to do with trying to parse ~1000 app value objects into memory,
each with numerous string objects associated with them. But
that particular issue will be solved in the future, with
the ContentProvider stuff.
2014-01-30 10:18:29 +11:00
Hans-Christoph Steiner
772004756e handle new signed repo with only fingerprint, no pubkey yet
A new repo can be added with only the fingerprint of the signing key, while
the regular tests are based on the entire public key (repo.pubkey). This
checks for the case when a repo only has the fingerprint and no pubkey yet.
In that case, it the pubkey presented by the index.jar file against the
stored fingerprint.  If they match, then the whole pubkey in the index.jar
is stored.
2014-01-28 20:31:47 -05:00
Hans-Christoph Steiner
04b5db1f4c update display of signing key fingerprint
Update Utils.formatFingerprint() to create a more readible version of the
SHA-256 fingerprint of the signing key of the repo.
2014-01-28 20:31:47 -05:00
Hans-Christoph Steiner
a02f985efa for signed repo with public key, guarantee fingerprint is also set
The stored fingerprint is checked when a repo URI is received by FDroid to
prevent bad actors from overriding repo configs with other keys. So if the
fingerprint is not stored yet, calculate it and store it. If the fingerprint
is stored, then check it against the calculated fingerprint just to make sure
it is correct. If the fingerprint is empty, then store the calculated one.

This was in place before, but it needed to be updated for the new Repo
ContentProvider.
2014-01-28 20:31:46 -05:00
Hans-Christoph Steiner
7b7da9a110 when receiving a repo URI with wifi info, warn user if on different wifi
A repo URI can include info such as the current wifi SSID and BSSID that
the repo is hosted on.  This is for when local repos are transmitted via
QRCode, NFC, etc.  The receiver of this URI then checks to make sure it is
on the same wifi access point, and warns the user if not.

In the future, it should do more than just warn the user, but instead give
concrete actions for the user to take, like associating to that wifi.
2014-01-28 20:31:46 -05:00