726 Commits

Author SHA1 Message Date
Daniel Martí
d80eec031c Re-enable loading of icons with fling
Reduce their thread priority to try to avoid it from lagging the scrolling
2014-05-01 16:03:56 +02:00
Daniel Martí
fbf9d4b409 Merge branch 'fix/update-notification' into 'master'
Fix/update notification

In addition to making update notifications work again (fixing issue #20) I also removed an unused class, and made the update count easily accessible from the AppProvider.Helper class.
2014-04-30 23:10:35 +00:00
Peter Serwylo
826854592f Made app update notifications work again.
The update service now queries the app provider for installed
apps which can and want to be updated.
2014-05-01 07:05:14 +09:30
Peter Serwylo
3bca6d3f70 Merge branch 'package-broadcasts' into 'master'
Package broadcasts (fixes #19)
2014-04-30 20:05:04 +00:00
Daniel Martí
a0b39cd150 PREF_UPD_NOTIFY default is true, not false 2014-04-30 00:33:10 +02:00
Daniel Martí
663a95c7a9 Don't crash if a repo has zero apps/apks
Also, a couple of typo fixes
2014-04-29 23:56:06 +02:00
Daniel Martí
88285b0a6b Fix: Don't always use /icons/ due to wrong SQL param order 2014-04-29 20:06:56 +02:00
Daniel Martí
7a16bf4ce5 Fix broadcast receiving of package updates
* It is PACKAGE_REPLACED, not PACKAGE_CHANGED:
  http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_CHANGED

* REMOVED and then ADDED are fired as well as REPLACED when upgrading an
  application:
  http://stackoverflow.com/questions/5217237/package-removed-then-package-added-are-fired-along-with-package-replaced-inten
2014-04-29 18:18:38 +02:00
Hans-Christoph Steiner
527f649fc2 move getSharingUri() to Utils for easier reuse
This method will also be used by the local repo for swapping.
2014-04-28 11:59:36 -04:00
Hans-Christoph Steiner
4dc2c60863 add more checks on fingerprints fed to Utils.formatFingerprint()
This is the gateway to the user, so this should present trusted info!
2014-04-28 11:59:36 -04:00
Hans-Christoph Steiner
cce393de09 "unverified" repo state for repos w/ fingerprints but not yet pubkeys
If a repo was configured with a fingerprint, but it has not yet updated and
gotten the pubkey from the index.jar, then it will be in an "unverified"
state, i.e. the signing key fingerprint is stored, but it has not yet been
used to check against the pubkey in the index.jar
2014-04-28 11:59:36 -04:00
Hans-Christoph Steiner
a0970d0720 when adding a repo with fingerprint, make sure to store the pubkey
The logic here is crufty, so I slapped a flag in there to make sure that
the pubkey gets stored when someone configures a repo and includes the
fingerprint.  When the fingerprint is set, it will first download the
index.jar and verify it against that fingerprint.  The logic for storing
the pubkey permanently happens later in the XML parsing, so there needs to
be a flag to signal to store the pubkey in this case.

Before the flow was always index.xml -> get pubkey -> index.jar.  Really,
there should no longer be support for unsigned repos, then all of this
stuff can be dramatically simplified.

fixes #2924 https://dev.guardianproject.info/issues/2924
refs #2960 https://dev.guardianproject.info/issues/2960
2014-04-28 11:59:36 -04:00
Hans-Christoph Steiner
649bfa10b7 fix silly bug in signing key fingerprint calculation for display
This was causing the first byte of the signature to be chopped off, so
therefore it would not validate since the fingerprint of the cert from
the net connection had the right fingerprint, but it was compared to the
stored, truncated version.

This also means that the database version needs to be bumped to trigger an
upgrade so that the bad 62 char fingerprints are removed from the database.
2014-04-28 11:59:36 -04:00
Hans-Christoph Steiner
aa1b9e6696 allow incoming repos via Intent when on ManageRepo view
Since before, incoming repo Intents where handled in the Fragment's
onCreate(), an Intent that was received while the Fragment was visible was
just ignored.  Activities have onNewIntent() for that, but Fragments don't
so the repo Intent handling had to be moved to the ManageRepo Activity.
That makes for a more direct relationship anyway, since ManageRepo is what
is configured as receiving all those Intents in AndroidManifest.xml.
2014-04-28 11:59:36 -04:00
Peter Serwylo
d287dca854 Refactored SearchView into Activity + ListFragment (Fixes #11)
This allowed for the use of LoaderCallbacks which seem like a better
way at managing the lifecycle of the cursors which our ContentProviders
return.
2014-04-25 18:21:49 +09:30
Peter Serwylo
71db322b6d Don't implement 'update' for installed apps, use replace (Fixes #14)
There were some weird edge cases that couldn't quite be pinned down,
whereby installing an app would result in a unique key violation being
hit. One example was when somebody was installing an apk from a file
manager. It seems that this doesn't trigger a PACKAGE_CHANGED, but
rather a PACKAGE_INSTALLED. The end result is that it attempts to insert
a record that already exists in the installed apps table. Because we
have a unique key constraing on the appId, it breaks.

This commit changes the way that we insert installed app details.
Instead of inserting some times, and updating other times, we always
insert. If we hit a unique key violation, the row is deleted, and then
the new values are reinserted.
2014-04-24 13:07:16 +09:30
Hans-Christoph Steiner
4a55cdf938 option to send via bluetooth any installed app on the AppDetails page
This takes the code used for sending the FDroid.apk and applies it to any
installed app.  So the user can go to the AppDetails for any installed app
and select "Send via Bluetooth" from the menu, and send the app to another
phone.
2014-04-22 11:09:49 -04:00
Hans-Christoph Steiner
0db711c08d enable sending installed APKs via NFC/Android Beam on AppDetails
If you are viewing the AppDetails screen for an installed app, this code
configures Android Beam to send the APK for that installed app if the you
initiate via NFC.

Also move the SDK checks into each method so that they are easier to use
without doing the wrong thing.
2014-04-22 11:09:49 -04:00
Daniel Martí
87775be76c Update UIL, adapt to the changes 2014-04-20 12:51:50 +02:00
Peter Serwylo
4e24050760 Adding our own cache of currently installed apks in the database.
Previously the data was not stored anywhere, and each time we wanted
to know about all installed apps, we built a ridiculously long SQL
query. The query had essentially one "OR" clause for each installed
app. To make matters worse, it also required one parameter for each
of these, so we could bind the installed app name to a "?" in the query.
SQL has a limit of (usually) 999 parameters which can be provided to
a query, which meant it would fall over if the user had more than
1000 apps installed.

This change introduces a new table called "fdroid_installedApps".
It is initialized on first run, by iterating over the installed apps
as given by the PackageManager. It is subsequenty kept up to date
by a set of BroadcastReceivers, which listen for apps being
uninstalled/installed/upgraded.

It also includes tests to verify that queries of installed apps,
when there are more than 1000 apps installed, don't break.

Finally, tests are also now able to to insert into providers other
than the one under test. This is due to the fact that the providers
often join onto tables managed by other providers.
2014-04-20 16:50:22 +09:30
Peter Serwylo
de085f7e02 Added ApkProvider.get() to return a single apk.
This allows you to specify the Uri of a single apk, and
it will return it. Right now it is just used in a test, but
hopefully it will be useful in other situations too.
I forgot to commit this last time, and didn't review my patch
well enough before submitting.
2014-04-12 19:02:15 +00:00
Daniel Martí
8ed76f47ee More improvements to the app list layout
* Don't use a RelativeLayout for the whole thing
* Use more external paddings, not per-element paddings
* Center everything vertically
2014-04-10 16:33:15 +02:00
Daniel Martí
e7f76705c8 Move "receiver" and "address" into UpdateService.EXTRA_... 2014-04-10 15:56:10 +02:00
Daniel Martí
f6707490f8 Move "from" into AppDetails.EXTRA_FROM 2014-04-10 15:52:11 +02:00
Daniel Martí
7fd3ea236e Move "appid" into AppDetails.EXTRA_APPID 2014-04-10 15:49:02 +02:00
Daniel Martí
40d873551f A bit of extra cursor safety, avoid the last missing .close() 2014-04-10 15:11:00 +02:00
Daniel Martí
f04ac83ec9 Fix build without java 1.7 compatibility 2014-04-10 15:08:29 +02:00
Peter Serwylo
fe1806b016 Merge branch 'misc_fixes' into 'master'
Localized category list
2014-04-10 03:51:58 +00:00
James Clark
09ccf3d428 Fix bug introduced in last commit 2014-04-10 04:14:55 +01:00
James Clark
87638363b3 Set listview to top item after category refresh 2014-04-10 03:45:17 +01:00
Hans-Christoph Steiner
c1d0ec43c3 fix crasher when hopping around apps and adding repos
I triggered this a few times while trying various QR Code scanning apps
with FDroid.

fixes #3222 https://dev.guardianproject.info/issues/3222
2014-04-07 21:39:50 -04:00
Hans-Christoph Steiner
407e7662e9 support QR scanners that do not respect custom URI schemes
Some QR Code scanners don't respect custom schemes like fdroidrepo://, so
this is a workaround, since the local repo URI is all uppercase in the QR
Code for sending the local repo to another device.  This way, the QR Code
can still be all uppercase and use HTTP:// and Android will still route it
to FDroid, but via the Just Once/Always chooser (fdroidrepo:// goes
directly to FDroid with no prompt, when it works)
2014-04-07 21:07:01 -04:00
Daniel Martí
a477f421cb Greatly improve app list layout
* Don't hard-code ellipsis in the code
* Separate the two rows into two linear layouts
* Don't abuse relative layouts
* Use ellipsize with weights to achieve best results
2014-04-07 19:35:04 +02:00
Peter Serwylo
dcf3a9dae8 Fixed assumption that repo updates have all apps available.
Previously, I accidentally made the repo updater presume that it
had access to all apps in a big fat list. This meant that I was iterating
over that list, performing calculations, etc, rather than actually
querying the entire database.

The solution was to bundled all update-service related processing to one
process in AppProvider (I didn't want to have to pull every single app/apk
out of the database in order to perform the update, because that will become
more and more burdensom as the repo grows).

There is a method calcDetailsFromIndex() in the AppProvider.Helper class.
It now does three things:
 * updates compatibility flag.
 * updates suggested version (outstanding issue is documented in gitlab issue #1)
 * updates iconsUrl (fixed in this commit)

Icons from old repos will just have icons in an "icons" dir
in the same folder as the index.jar. New repos have density
specific icon dirs (e.g. "icons-240") which depend on the
device F-Droid is running on.
2014-04-06 12:34:47 +00:00
AlexanderR
04ea93cce8 Category list i18n 2014-04-05 17:08:29 +11:00
AlexanderR
c1daa99617 Use managedQuery to let Search Activity automatically dispose of it's Cursor.
Should be somehow done via Loaders someday.
2014-04-05 10:32:58 +11:00
AlexanderR
793bd618ac Fixed weird crash on emulator 2014-04-04 18:06:03 +11:00
Peter Serwylo
eded748ab8 Fixed the suggestedVersion calculation, now done via SQL.
The archive repo was getting updated after the regular repo.
In these situations, we didn't have every single app/apk in
memory in order to calculate the suggested version. As a
result, F-Droid ended up choosing a suggested version from
the archived versions, when terhere was actually a newer version
in the database.

This change does all of the calculations in two database queries
now. Although the implementation of the query is not hackey,
they way I get to the code in order to execute the query
is a bit hacky, so most of the implementation is private.
2014-04-03 00:32:56 +11:00
Peter Serwylo
468b6717ee After downloading index, remove apks no longer in the index.
It adds an extra 600ms on my Nexus 4 with ~2000 apks from the
F-Droid index. But I think it is the only way, as we really need
to iterate over every single installed apk, to see if it is still
wanted. The up side is that we can query for a large amount of
them, rather than quering individually for each apk.

NOTE: I haven't added a new status message yet, because we are
about to do a stable release. After the stable release, I'll
add a new status message to cover for this > half a second
(on my relatively fast device). This will probably be part of
an overhaul of the update process in general, including a
proper progress dialog.
2014-04-01 21:19:27 +11:00
Daniel Martí
abdd2fbb8e Bring back "Update repos" to the main menu
This can later be removed again if the user still has a way to easily update
repos manually without having to enter "Manage Repos" and exit again. A good
option would be a pull-to-refresh action.
2014-03-28 17:59:07 +01:00
Peter Serwylo
8efa9d609a Apps were not getting a current version when upstreamVersioncode not specified.
The problem was that they defaulted to 0 if not specified, however
the code checking for current version was looking for -1 for a "no upstream version".
2014-03-27 22:22:54 +11:00
Peter Serwylo
3ebad383d6 Refactored the recent MR for dynamicly adding default repos.
The idea was good: reduce the amount of copied/pasted code
where ContentValues were initialized, populated, then inserted.
I've kept the idea, by putting it in its own method which is
called twice. But the resources are not loaded dynamically any
more. This is so that the compiler will be able to pick up if
we reference a missing resource. Also, I took the opportunity
to replace the field name string literals with references to
RepoProvider.DataColumns.* constants.

Finally, changed the tests around because now we need to
have the "getInteger()" call mocked in resources correctly
(for priority/inUse).
2014-03-23 22:31:06 +11:00
Peter Serwylo
9703350f41 Update tab refreshes correctly now.
Before it was listening for changes, but we weren't notifying
of changes correctly. Now we use ContentResolver.notifyChange().
2014-03-23 21:20:03 +11:00
Peter Serwylo
bfdfb6d5ef Removed unused code from FDroidApp.
From before content providers, where we rolled our own update notification
system for when data changed in the database. I also removed the property
"ctx", because it is availble in getApplicationContext(). As a general rule,
it is usually safer to not use a member field if not neccesary. That way,
there doesn't need to be any assumptions about when it is set and what value
it has. In this case, it was only set half way through onCreate, and therefore
usage before then would break.
2014-03-23 21:20:03 +11:00
Daniel Martí
9f2de0abd7 Get rid of EXTRA_NOT_UNKNOWN_SOURCE target api warning 2014-03-22 11:22:03 +01:00
Daniel Martí
2cd17a904e Placed the TargetApis wrong 2014-03-22 11:18:42 +01:00
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