290 Commits

Author SHA1 Message Date
Daniel Martí
8239f12ff7 Add support for play.google.com search urls 2015-03-30 18:36:32 +02:00
Daniel Martí
53aa7ec849 Add support for play.google.com app links
As requested in #154
2015-03-30 18:07:03 +02:00
Daniel Martí
d22c714dbd Ignore leading and trailing whitespaces in search keywords
As reported in #58
2015-03-30 17:41:35 +02:00
Daniel Martí
85d7752d0a Use the same logging tag scheme everywhere
We were using different methods and violating the correctness error
"Log tags are only allowed to be at most 23 tag characters long." as reported
by lint.

Changes:

* Always start tags by "fdroid." (even though it's a bit redundant)
* Replace "org.fdroid.fdroid." by "fdroid."
* Don't include "compat.", "data." "views.fragments." et al (these didn't and
  shouldn't be namespaces really, only for file/code organisation)
* Do include parent classes for subclasses, e.g. "fdroid.RepoProvider.Helper"
  since these can conflict
2015-03-30 17:16:56 +02:00
Daniel Martí
cd667371e6 Merge branch 'fix-85/remove-downloaded-index-files' of https://gitlab.com/pserwylo/fdroidclient 2015-03-30 16:39:45 +02:00
Peter Serwylo
eaea0e2c23 Fix #85: Remove downloaded index files that hang around.
If the download process is interrupted, a "dl-" file hangs around in
F-Droid's cache directory. If the download succeeds, extracts an xml
file from the downloaded .jar file, and then the rest of the process
is interrupted, then a "index-*.xml" file hangs around in F-Droids
files directory.

This fix removes these two types of left over files when F-Droid
is started. In addition, it also makes it so that the downloaded
repo indexes are now more clearly named "index-*-downloaded" (with no
extension, because the code which does it doesn't know whether it is
a .jar or .xml file, and it doesn't matter anyway). Also, it extracts
the .xml files to the cache directory too (instead of the files dir)
and names them "index-*-extracted.xml".

There is some code which removes the old "dl-" files that will become
redundant after the first time it is executed on a users device after
upgrading F-Droid. It is a very small amount of code run on startup,
so I am not concerned about the performance implications of leaving it
there, but I put a comment explaining that it can be removed in the
future.

Includes minor formatting changes, and a few annotations.
2015-03-19 07:38:54 +11:00
Peter Serwylo
3abb426fc3 Added a message when any of the app lists are empty.
Previously, a few people have been confused by an empty list when they first
open F-Droid (e.g. if they are not connected to the internet, and repos didn't
update). This provides some feedback so that there is never a blank screen.

Fixes Issue #34.
2015-03-16 21:42:10 +11:00
Daniel Martí
680a468b6c Don't use fragment adapter if it's null (fixes #82) 2015-03-15 17:13:42 +01:00
Daniel Martí
06ae1bc044 Merge branch 'fix/issue-5-guess-repo-path' of https://gitlab.com/pserwylo/fdroidclient 2015-03-15 16:58:06 +01:00
Romain Vimont
cb3b2e0d8e Refresh AppDetails header on package state change
Update the application details to display the correct state on
application install/uninstall.

Should fix issue #161
https://gitlab.com/fdroid/fdroidclient/issues/161
2015-03-13 14:48:58 +01:00
Peter Serwylo
74b285a77f Fix Issue #5: Guess at common repo paths (/, /fdroid/repo, /repo)
When adding repositories using the Manage Repos activity, firstly look
for an /index.jar appended on the URL provided by the user. If that
doesn't work (HTTP status code other than 200) then it will try
/fdroid/repo/index.jar, then /repo/index.jar. If it can't establish a
connection to the server, or if none of the above attempts results
in a 200, then the path provided by the user is kept (even though we
have a hunch it might be wrong).

This is to cover for the case where people arn't connected to the net.
Another way to deal with no internet connectivity is provided by a
"Skip" button on the dialog while searching for the index.jar.

The searching for index.jar is done by doing a HTTP HEAD request, so
the entire jar needn't be downloaded.

Finally, to make this happen in a clean sort of way, I refactored the
ManageReposActivity a little bit to encapsulate all of the add repo
dialog handling into a subclass. This way, the outer class doesn't
need to know things like: Is the dialog showing, what state is it in,
is the background task to search for index.jar files running, how and
when to cancel that task, etc.
2015-03-14 00:44:17 +11:00
Romain Vimont
eef1e0a406 Externalize application changed actions
When we receive notifications indicating that the app has changed, the
App object needs to be changed and the view updated.

These notifications can be received from two sources:
 - the ContentObserver;
 - onActivityResult().

Thus, the implementation should not be related to the ContentObserver
(in theory, we might want to keep only the onActivityResult()
notification). Therefore, move it to a separate method in AppDetails.

This also preventively avoids bugs when the ContentObserver is null.
2015-03-13 10:57:29 +01:00
Romain Vimont
578084ff96 Revert "Do not manually call onChange() (fix NPE)"
This reverts commit 47e065442edc108d4bb38f9daaa7cdb3fff26b49.

Now that the ContentObserver is created when activity is started (even if not
resumed), then it will be non-null during onActivityResult(). Therefore,
the calls to onChange() will not lead to NullPointerException anymore.

The reason why we want to manually call onChange() is that the
ContentObserver notifications may happen several seconds later:
https://gitlab.com/fdroid/fdroidclient/merge_requests/58#note_948719
2015-03-13 10:26:42 +01:00
Romain Vimont
cda80f5de6 Register ContentObserver when activity is started
The ContentObserver was registered only when the activity was in resumed
state. However, in started but paused state (when the activity is
visible but not in focus), we still want to receive these notifications
to update the view.

Therefore, register it on start and unregister it on stop.

As a consequence, myAppObserver will be non-null during
onActivityResult().
2015-03-13 10:22:06 +01:00
Romain Vimont
4e2ab4c048 Call super.onPause() first
super.onPause() should always be called first:
http://developer.android.com/training/basics/activity-lifecycle/pausing.html#Pause
2015-03-13 10:18:26 +01:00
Romain Vimont
47e065442e Do not manually call onChange() (fix NPE)
If the AppDetails activity has been destroyed by the system during an
application installation/remove, it is recreated once it should be
displayed again (this behavior can be forced by enabling "Don't keep
activities" in Android developer options).

In onCreate(), it passes its instance of myInstallerCallback to an
Installer. In onActivityResult() (which is called before onResume()),
this installer calls a method (onSuccess() or onError()) on this
callback. The implementation of these methods (the anonymous inner class
assigned to myInstallerCallback) dereference myAppObserver, which is
still null, because it will be initialized in onResume(), so a
NullPointerException is thrown.

However, the problem is not only that myAppObserver.onChange() is called
when myAppObserver is null, but that it should not be called manually at
all: it is a ContentObserver, so it is automatically called when
registered to the content resolver. As a consequence, this callback was
called twice.

Removing these calls fix both problems.

Should fix issue #135
https://gitlab.com/fdroid/fdroidclient/issues/135
2015-03-12 16:21:19 +01:00
Romain Vimont
89bedfda13 Do not crash on app uninstall
Immediately after an app uninstall, the associated App will be updated
by a call to reset() in the AppObserver.onChange().

But before receiving this event, the activity and the fragments resume,
leading to a call to getInstalledStatus(…). At this stage, we don't know
that the app has been removed yet, but the package manager already
removed it. Therefore, PackageManager.getInstallerPackageName(…) throws
an IllegalArgumentException.

In that case, consider that the application has been uninstalled.

Should fix issue #167
https://gitlab.com/fdroid/fdroidclient/issues/167
2015-03-11 20:32:15 +01:00
Daniel Martí
c09708a09e Get rid of "on/off" descriptions for checkbox prefs
Closes #149
2015-02-25 19:52:11 +01:00
Peter Serwylo
2fe91bc35e Prevent VerifyError when loading FileCompat.
Classes which contain calls to platform specific methods cause
problems, because the dexer will go looking for that method even
if you put a guard condition checking the build number. However,
if you lazily load a class depdending on the version number, then
older API devices wont try and load it, and no VerifyError occurs.
2015-01-27 23:24:00 +11:00
Peter Serwylo
08af7ee157 Change symlink implementation to use best available impl per platform.
* Android-21 introduced an API for symlinking.
 * Android-19 has an API which can be used via reflection.
 * Earlier versions use Runtime.exec('/system/bin/ln')

This also extends the SanitizedFile stuff so that the android < 19 can
safely use Runtime.exec() with less fear of command injection vulnerabilities.

Finally, some tests for the SanitizedFile and symlink stuff was added.
2015-01-27 22:47:32 +11:00
Peter Serwylo
afef5ea233 Added test for SanitizedFile class. 2015-01-26 13:53:16 +11:00
Peter Serwylo
37b3f1ff57 Cache .apks in internal storage before installing.
This prevents an app with "write external storage" permission from
being able to switch the legit app with a dodgey one between F-Droid
requesting an install, and the package manager actually showing the
install dialog to the user.

In order to make the file in private internal storage readable by
the package manager, its parent directories need to be world-executable,
and the file itself needs to be world-readable. It seems that the
"/data/data/org.fdroid.fdroid/cache" dir provided by the Context is
already world executable, but the "apks" subdirectory does not default
to this.

Also, to be compatible with android-8, a Runtime.getRuntime().exec()
call was added for such devices, which invokes /system/bin/chmod.
The effect of this was to require some level of file sanitization to
be made available using the Java type system to prevent command injection
attacks from weird apk names (as people are free to download metadata
from random internet people).
2015-01-26 09:36:56 +11:00
Daniel Martí
85b7e77324 Some code formatting fixes in AppDetails 2015-01-20 11:37:16 -05:00
Dominik Schürmann
2392507634 Accept same set of characters for apk file names for 'pm install' like for package names 2015-01-19 19:47:18 +01:00
Dominik Schürmann
d941ac5eb0 Only accept valid package names as parameter for 'pm uninstall' 2015-01-19 19:47:16 +01:00
Dominik Schürmann
1f2fe25cd4 RootInstaller: Put quotes around filenames and package names 2015-01-19 19:47:13 +01:00
Dominik Schürmann
521218a45c Code cleanup and simplifications 2015-01-19 19:47:10 +01:00
Daniel Martí
7e7f0fe6f2 Fix some indentations in AppDetails 2015-01-04 00:24:55 +01:00
Daniel Martí
2bd05dec38 Remove unnecessary spaces 2015-01-04 00:23:19 +01:00
Daniel Martí
c6c472402d More final keywords 2015-01-03 20:46:31 +01:00
Daniel Martí
d2ade5c69b Don't show "not installed" for apks installed from someplace else
Fixes #107.
2015-01-03 20:27:28 +01:00
Daniel Martí
1405705fd5 Add some final keywords 2015-01-03 19:38:54 +01:00
Daniel Martí
bfc79f3a79 Supress deprecation warnings of compat CPU_ABI* usage 2015-01-03 18:05:04 +01:00
Daniel Martí
55c1bd0572 Support devices with more than two ABIs on >=21
Also, start using String[] like Android's SUPPORTED_ABIS instead of
Set<String>. Said list of ABIs will always be very short, at most containing a
handful of elements.
2015-01-03 17:53:36 +01:00
Daniel Martí
a03053e80a Replace the deprecated FILL_PARENT by MATCH_PARENT 2015-01-03 17:35:01 +01:00
Daniel Martí
b42de49cb4 Fix default locale lint warning 2014-12-31 00:25:27 +01:00
Daniel Martí
5dd4b8de1c Fix lone tabbed line 2014-12-31 00:10:09 +01:00
Daniel Martí
5af7cac4b7 Remove all trailing whitespaces in source files 2014-12-30 23:48:36 +01:00
Hans-Christoph Steiner
8a06aa1c9b remove newlines and extra spaces when parsing repo name and description
The formatting of these texts should happen in the Android layouts, not
with inline whitespace characters.
2014-12-11 13:49:56 +01:00
Daniel Martí
06dd4c8dcb Move F-Droid project into subdir, keeping a root gradle project
Also improved .gitignore a tad
2014-12-09 15:36:07 +01:00