From 74b285a77fd536e6b3f524dd99f668e1c28c422c Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Thu, 12 Mar 2015 21:54:32 +1100 Subject: [PATCH] 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. --- F-Droid/res/layout/addrepo.xml | 85 ++-- F-Droid/res/values/strings.xml | 2 + .../fdroid/views/ManageReposActivity.java | 363 ++++++++++++------ 3 files changed, 299 insertions(+), 151 deletions(-) diff --git a/F-Droid/res/layout/addrepo.xml b/F-Droid/res/layout/addrepo.xml index 50f3b2971..1fa9ae01f 100644 --- a/F-Droid/res/layout/addrepo.xml +++ b/F-Droid/res/layout/addrepo.xml @@ -1,50 +1,67 @@ - - + android:orientation="vertical"> - + + + + + + + + + + + + tools:text="Searching for repository at\nhttps://www.example.com/fdroid/repo/" /> - - - - -