680 Commits

Author SHA1 Message Date
Daniel Martí
4f065492ef Unify the usage of cursors
Safer and less error-prone because:

* Always checks for null
* Checks for sizes
* Inits App/Apk lists at known capacity
* Properly closes all cursors

There are still one or two cursors that are not closed correctly and show
things like these:

W/CursorWrapperInner(19973): Cursor finalized without prior close()
2014-03-22 00:11:56 +01:00
Daniel Martí
fc4a96acd8 Don't break when updating the Apk table on devices before 3.0 2014-03-21 23:22:23 +01:00
Peter Serwylo
9c9ecc5140 Fixed issue 472, NPE on android 3.1 (and 3.0).
The Activity.getActionBar() method can only be called after
setContentView() has been invoked, as described here:

  http://blog.perpetumdesign.com/2011/08/strange-case-of-dr-action-and-mr-bar.html

I couldn't think of any way to enforce this safely
(i.e. make the compiler kick up a stink if we didn't do it). As such,
I just put a comment above each usage of the ActionBarCompat class.

Another outstanding issue is a duplicate of 474, where it crashes when you
press the "Up" button from ManageRepos, but I'll create a different issue
for that.
2014-03-22 08:29:13 +11:00
Daniel Martí
0e47ac6900 Slightly speed up getAndroidVersionName by using a static array 2014-03-21 18:18:12 +01:00
Daniel Martí
ee38ff3eea Merge commit 'refs/merge-requests/69' of gitorious.org:f-droid/fdroidclient 2014-03-20 00:03:47 +01:00
Daniel McCarney
7dd216d212 Apply Google CSRNG fixes.
The cryptographically secure random number generator exposed to Android
through the Java Cryptography Architecture is not properly initialized
on some older unpatched versions of Android. Google provides
a PRNGFixes.java class to force secure seeding of the CSRNG on all
platform versions. This comment adds the PRNGFixes class & and a call to
invoke the fixes from the FDroidApp class.

More detail is available from the Google Android Developers blogpost on
the subject:
  http://android-developers.blogspot.ca/2013/08/some-securerandom-thoughts.html
2014-03-19 18:56:42 -04:00
Daniel Martí
ddb1cfd659 Only set NOT_UNKNOWN_SOURCE if available 2014-03-19 12:46:17 +01:00
Peter Serwylo
94300592d9 Fix missing resource issue.
When adding "default_repo_priority", it was copy/pasted from
"default_repo_pubkey" without changing the name, and so
tried to cast the string value into an int and failed.
2014-03-19 07:02:00 +11:00
Peter Serwylo
fa8052611e Don't reset "transient" tables from now on.
Instead, use:

if (oldVersion < ... && !columnExists(...))
	db.execSQL("ALTER TABLE ...")

to add/modify columns as required.
2014-03-19 06:22:09 +11:00
Daniel Martí
5e30d0d218 Remove "Android App:" when sharing an application
Reasons to do so:
* Redundant
* Often noisy
* Not properly translated
2014-03-18 08:15:04 +01:00
Daniel Martí
a184ce7268 Make priorities configurable too 2014-03-17 09:38:11 +01:00
Daniel Martí
6284811fec Merge commit 'refs/merge-requests/68' of gitorious.org:f-droid/fdroidclient 2014-03-17 09:29:13 +01:00
Peter Serwylo
0ec4e3756d Don't show update option in list if ignored.
Related to the last bug with the update notify count. This one is
also due to the fact we didn't ask for the right data from the
provider. If these bugs keep coming in over time, I will seriously
consider guarding access to each variable with a check, and throwing
an exception if the variable hasn't been initialized. For now I'll
see if it was a once off. Hopefullly tests will catch these issues
in the future.
2014-03-17 17:43:45 +11:00
Rene Treffer
67e1020684 Add missed occurance of old repo address R.string 2014-03-16 14:20:44 +01:00
Rene Treffer
1f799d1ef1 Say that f-droid is not an unknown source.
This property will be ignored if f-droid is not installed as priv-app,
but it _will_ skip the "you have to enable unknown sources" dialog if
f-droid is installed as priv-app.

There is thus no gain in keeping it as is (false).
2014-03-16 13:52:05 +01:00
Rene Treffer
61bbbf442d Make the list of default repos dynamic
This patch iterates over the configured list of repos and adds them to
the db on create. This means that the initial list of repositories is
now fully configurable. Added the guardian project repo (disabled) as a
testcase.
2014-03-16 13:50:17 +01:00
Daniel Martí
49a3c3370f Don't finish the whole Repositores activity when cancelling "New Repository" 2014-03-10 18:36:35 +01:00
Daniel Martí
54d7849191 Get rid of lint TargetApi warnings 2014-03-10 18:30:42 +01:00
Daniel Martí
4454c0d261 No need to reset views in the app lists 2014-03-10 17:56:49 +01:00
Peter Serwylo
9fd8da42a1 Adding test coverage for "AppProvider.Helper.findIgnored()"
Also added tests for canAndWantToUpdate() while I was at it.
2014-03-06 23:31:26 +11:00
Peter Serwylo
81fcd44b66 Fixed update notification count
The update notification was not taking ignored apps into account.
This is the first manifestation of a class of bug I feared whereby
the properties of an App object are not initialized, but no error
is thrown. It occured because we were iterating over apps that were
created from the index file, rather than our database. Hence, they
had no knowledge about whether they should be ignored or not.

Also took the chance to perform a minor refactor of UpdateService
class. The onHandleIntent method was getting huge, so I extracted
two methods: verifyIsTimeForScheduledRun() and
performUpdateNotification(), as well as removing the unused "success"
flag.

The two methods should theoretically make the class more testable
later, as we can test the scheduled run code, and the update notification
code in separate tests, but we'll wait and see if that eventuates.
2014-03-06 23:31:26 +11:00
Peter Serwylo
aa9bfefd55 Fixed bug with only one apk being added from index for each app. 2014-02-28 10:32:32 +11:00
Peter Serwylo
4004b6251f Fixed issue 474 - crash on "Up" button from ManageRepos.
Not sure that the "parent" activity of ManageRepos is required in
the manifest any more, due to the fact that the main use seems
to be to direct the "NavUtils.navigateUpSameTask" method uses it,
but this change switches to "NavUtils.navigateUpTo" and specifies
the activity explicitly.
2014-02-27 22:56:16 +11:00
Peter Serwylo
45d046b445 Fix unique key violation in update service.
When two repos both add an apk with same version and id, then
it would break.
2014-02-24 11:01:56 +11:00
Peter Serwylo
87f2da7e2f Fix 'Number of apps' sql exception in repo details. 2014-02-24 10:45:25 +11:00
Peter Serwylo
568224ba78 s/curVersion/upstreamVersion/g, added suggestedVersion. Refactored QueryBuilder.
In order to support suggested version, I didn't want to have both
suggested version + versionCode in the App table. Rather, just the
code, and then use that (and the apps id) to join onto the apk table.
This is something we wanted to do elsewhere, so I refactored the
QueryBuilder class from the ApkProvider so that it can also be used
by the AppProvider.
2014-02-24 10:45:13 +11:00
Daniel Martí
2a03c51207 Use LayoutCompat in RepoAdapter 2014-02-21 00:11:58 +01:00
Daniel Martí
5d0074d821 Add ALIGN_PARENT_* to LayoutCompat.RelativeLayout 2014-02-21 00:11:58 +01:00
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