2027 Commits

Author SHA1 Message Date
Peter Serwylo
4d11c97d51 Cleanup misc TODO's that are floating around (swap and general f-droid)
`SwapService`: Remove unneccesary TODO's and unused constant. Also
added other TODO's there which will need to be done before swap is
stable. Can make them into issues in gitlab, but will leave there for
now.

`SwapWorkflowActivity`: Clarified TODO's, fixed issue with cancelling
swap when in the "connecting" state (before it would not show the
right view again, now it goes back to the first view).

`WifiQrView`: Make scanning of QR code initiated by `SwapActivity`.
This is because the activity is actually the one who is able to listen
for a response anyway.

`BluetoothFinder`: Cleaned up TODO's in  but didn't actually address
them.

`BluetoothPeer`: Removed TODO about fingerprints, because TOFO is
probably the way to go with Bluetooth anyhow.

`BonjourFinder`: Remove dead code, prevent NPE by using final local
variable rather than member variable (the member variable gets set
to null in a different thread).

`BonjourPeer`: Fix bug with prompting other device to swap back.

`BluetoothDownloader`: Fix typo in comment.

`Downloader`: Removed TODO that was left over from a refactor, and
was never actually correct. The code after refactoring was broken
because it created an `InputStream` which was never closed. Now it
doesn't do that, because it was fixed in an earlier commit in this
branch.

`HttpDownloader`: Remove TODO, but clarify that the downloader does
not follow 30x redirects.
2015-07-27 17:19:51 +10:00
Peter Serwylo
9180c9f5c0 WIP: Bluetooth can actually transfer indexes and apks over HTTPish!
It is very hacky, and I did it through the non-swap interface, and it
only works once then the state stuffs up and it no longer accepts incomming
connections, but it worked! Now to smooth out all the things.
2015-07-26 07:44:12 +10:00
Peter Serwylo
9da6893ac3 Added verbose debugging to diagnose swap state. Foreground/background service correctly. 2015-07-19 23:52:47 +10:00
Peter Serwylo
240bcce445 Remove bonjour preference. Separate bluetooth and wifi more clearly.
Before, you could "Enable swapping" without specifying which type
of protocol to enable. Now, the two switches are clearly delimited
between bluetooth and wifi.
2015-07-18 01:48:56 +10:00
Peter Serwylo
4f4310c0ca Clean up after merging swap stuff. 2015-07-18 00:08:25 +10:00
Peter Serwylo
0a373de7a4 Merge branch 'nathan-bluetooth-swap' into nearby-peers-with-bluetooth 2015-07-15 17:42:03 +10:00
n8fr8
2a6b514232 change BT request handling to operate directly on files
We don't want to depend on HTTP being active in case there is
no wifi that exists at all. In some cases, local 127.0.0.1 does not
exist if the Wifi is not connected. This commit takes the code
from LocalHTTPD and repurposes it for the BluetoothServer needs.
2015-07-13 16:45:53 -04:00
n8fr8
e930e03378 improvement on scan/re-scan logic to avoid failure 2015-07-13 16:05:13 -04:00
n8fr8
c53df989b8 small UI clean-up of header display 2015-07-13 16:05:00 -04:00
n8fr8
c399a17369 add more checks for possible NPE and simplify the UI 2015-07-13 15:04:38 -04:00
n8fr8
cc6b2736ce add logic for setting/re-setting "Fdroid" name tag for bluetooth device 2015-07-13 14:41:21 -04:00
n8fr8
d662c15fb8 list background should be white 2015-07-13 14:40:22 -04:00
n8fr8
99a86c4080 handle null adapter case 2015-07-13 14:40:11 -04:00
Peter Serwylo
a8dedd8ac2 Removed SwapAppListActivity, implemented UI mockup for swap app list.
Still need to hook up the buttons in the app list, but this change
shows the correct status and/or buttons for installable/upgradable/
incompatible/installed apps in the swap list. This change also hooks
up UIL to download icons for apps and thus display them in the list.
2015-07-13 22:52:51 +10:00
Peter Serwylo
f236dc3d3e Removed ConnectSwapActivity, refactored into SwapWorkflowActivity.
Involved creating another view/state for which the swap workflow can
be in. It is not explicitly stated by setting the state of the SwapService,
as is the case with other views. Rather, it is inferred based on the
presence of a `NewRepoConfig` crafted from the incoming intent in
`onResume()`.

Also gave me an idea of how to move more logic out of individual views,
and into the SwapWorkflowActivity. That is, inflateInnerView should
return the inflated view, to be cast into the specific subclass. From
there, the activity can call methods directly on the view to set it
up, rather than having the view do that stuff itself. In the future,
may consider doing this with other views too.
2015-07-12 23:18:09 +10:00
Peter Serwylo
4e4d3ec3f9 WIP: More cleaning up of swap process, unbinding service, and investigating getting rid of ConnectSwapActivity. 2015-07-10 01:14:32 +10:00
Peter Serwylo
0b1e2732c2 Refactored SwapService + SwapManager into single SwapService 2015-07-09 11:43:34 +10:00
Peter Serwylo
a3af6b8b9f WIP: Serialize bonjour peers correctly. Refactor mini-service APIs.
The reference to mini-services above are not full blown Android
services. Rather, they are utility classes which can be started,
stopped, and send broadcasts about their status.

Made the list of apps to install better, with buttons for install
or upgrade, and statuses for incompatible and installed.
2015-06-30 19:04:06 +10:00
Peter Serwylo
22b072962e WIP: Don't show self in Bonjour peer list. Implement UI for peer list.
Peers are shown as proper list items now, subject to feedback from Carrie.
TODO: Need to figure out how to combine bluetooth and bonjour with same
fingerprint.
2015-06-27 10:12:26 +10:00
Peter Serwylo
30669f8058 WIP: Hooking up specific peers from the "nearby peers".
Touching the peers will prompt app selection for swap, then skip the
wifi and NFC screens, then show updating info, then a list of apps to
swap.
2015-06-26 00:13:52 +10:00
Peter Serwylo
5e9931fa03 WIP: Make bluetooth/bonjour peers parcelable.
The Bluetooth peer need only parcel up the BluetoothDevice, which
itself is parcelable. The wifi peer requires the JmDNS ServiceInfo
class to be parcelled. For this, I took the most full on looking
constructor, and parcelled up each individual property of the service
info object which is required by that constructor.

Also made the scan qr button hooked up to the swap process, and fixed
minor bugs with the "visible via wifi" TextView setup.
2015-06-24 07:16:49 +10:00
Peter Serwylo
8ae3ae3e80 WIP: Start initial swap repo instantly, with only F-Droid...
... then when the swap process is setup properly, setup a real swap
repo with all of the apps that were selected.
2015-06-23 23:17:35 +10:00
Peter Serwylo
e343918ef9 WIP: Moving from listener to broadcasts for discovered peers. 2015-06-23 23:12:57 +10:00
Peter Serwylo
ff93f96959 WIP: MOre ui stuff for "Start Swap" screen. 2015-06-23 22:46:52 +10:00
Peter Serwylo
0100415e3e WIP: Refactoring Bonjour from manage repos to swap.
Implementing the bare bones of a generic "peer finder" framework. This
may or may not eventuate to something which can live in its own library
and be used by other projects. Might go hand in hand with Carries idea
of having a common UI to be shared among projects.

Got Bluetooth and Bonjour kinda working, but the UI is crud,
and it doesn't remove items and ends up with duplicates. Otherwise,
on our way to a proper "nearby peers" screen.
2015-06-22 08:59:37 +10:00
Peter Serwylo
a30ec646b2 WIP: Refactoring Bonjour from manage repos to swap.
Implementing the bare bones of a generic "peer finder" framework. This
may or may not eventuate to something which can live in its own library
and be used by other projects. Might go hand in hand with Carries idea
of having a common UI to be shared among projects.
2015-06-22 08:55:46 +10:00
Peter Serwylo
593aaf3894 WIP: I18n of start swap screen, colouring of text, add header.
Styled "send fdroid" and "qr code" buttons correctly.
2015-06-22 08:54:23 +10:00
Peter Serwylo
2645b2bfd4 Script to convert SVG's into (many different res) drawables.
Adapted from 3ee3b4aad8/original/convert.sh
2015-06-21 10:40:38 +10:00
Peter Serwylo
a48deb9160 WIP: More work on UI for initial swap screen. 2015-06-21 10:05:38 +10:00
Peter Serwylo
b0b285bc1f Merge branch 'swap/bluetooth' into swap-demolition-material-mockups 2015-06-17 00:41:37 +10:00
Peter Serwylo
4a8ff47fce WIP: Implementing mockups from Carrie, added "Toolbar"
The Toolbar is the new thing from Google which acts as an ActionBar.
It is not a special view like the action bar is, it is
implemented and added to your layout the same as any view.

The InnerView classes of the swap workflow have the choice of what
colour to make the toolbar, so that they can distinguish themselves
as per the mockups (some deep blue, others bright blue).

Added icons for close, but they don't do anything yet.

Minor tweaks to layout so that it looks more like the latest mockups.
2015-06-12 22:45:55 +10:00
Peter Serwylo
0d4c61df96 WIP: Implementing UI mockup, different "selected" indicator for swap.
Using stock icons from Google Material Icons. Need to use the actual
icons provided by carrie, but will do so in the future.
2015-06-11 08:21:10 +10:00
Peter Serwylo
c6bc8b5e37 Merge branch 'material-design' into swap-demolition-material 2015-06-04 08:26:46 +10:00
Peter Serwylo
f9bcf33d50 WIP: Fixed minor UI issues.
"Confirm swap" background was white but should have been blue.

SwapWorkflowActivity now extends ActionBarActivity instead of
FragmentActivity so older devices have an action bar (though it is
not styled with blue action buttons on android-10 devices).
2015-06-03 23:55:11 +10:00
Peter Serwylo
d9f91da9a6 WIP: Added logging, removed dead code, fixed minor bugs.
Logging to help understand when the service is started, stopped,
restarted, and when individual components (e.g. web server, bonjour)
are started/stopped.

Fixed bug where service was moved to foreground during "restartIfEnabled"
because that is unneccesary if it is already in the foreground.
2015-06-03 23:41:51 +10:00
Peter Serwylo
2553b8520c WIP: Move swap starting/stopping to async task.
There is now a private [en|dis]ableSwappingSynchronous() method, to go
along with the public [en|dis]ableSwapping() method. The public method
knows about not spinning up tasks if already enabled, and also about
pushing the invocation to a background task. The private method just
blindly does what it is asked, without checking if it should be done,
and without running on a background task.

The same goes for the restartIfEnabled() method, it is responsible for
creating a single background task which runs in order: disable, and
then enable. This is actually the reason for having the synchronous
methods, rather than having, e.g., the public [en|dis]ableSwapping()
method know about threads. If that was the case, then restarting would
consist of starting, waiting for some form of notification that the
background task has completed, and then scheduling the enable task.
Now, it is a matter of calling both *SwappingSynchronous methods in
succession.
2015-06-03 17:55:36 +10:00
Peter Serwylo
7c9492e6b4 WIP: Refactoring swap service.
Removed LocalRepoService, replaced with SwapService.

Still TODO:
  Manage threads. Currently everything is called from the
  UI thread, which is a regression from the previous behaviour.
  I'd like to manage this so that the code interacting with the
  SwapManager doesn't need to bother itself with whether it is calling
  from the UI thread or not.

The local repo service had many different methods and properties for
dealing with starting and stopping various things (webserver, bonjour,
in the future it will also need to know about bluetooth and Wifi AP).

The SwapService handles this stuff by delegating to specific classes
that are only responsible for one of these. Hopefully this will make
the process of enabling and disabling swap repos easier to reason
about.

The local repo service was also stopped and started quite regularly.
This meant it was up to the code making use of the service to know if
it was running or not, and to enable it if required.
The new SwapService is only started once (when the singleton
SwapManager is created for the first time). It should not use any more
resources, because it is a background service most the time, and it
is responsible for moving itself to the foreground when required (the
burden is not on the code consuming this service to know when to do
this).

By having the service running more often, it doesn't need to'
continually figure out if it  needs to register or unregister listeners
for various properties (e.g. https enabled) or wifi broadcasts. The
listeners can stay active, and do nothing once notified if swapping is
not enabled.

Moved the timeout timer (which cancels the swap service after 15 mins)
into the SwapService, rather than being managed by the
SwapWorkflowActivity. Seems more appropriate for the service to know to
time itself out rather than the Activity, seeing as the Activity can
die and get GC'ed while the service is still running.

Finally, although there is nothing stopping code in F-Droid from
talking to the service directly, it is now handled by the SwapManager
singleton. This means that details such as using a Messenger or Handler
object in order to communicate via arg1 and arg2 is no longer required,
and instead methods with proper type signatures can be used. This is
similar (but not exactly the same) to how Android system services work.
That is, ask for a "Manager" object using getSystemService(), and then
use that to perform functionality and query state via that object,
which delegates to the service. Then we get the best of both worlds:

 * Reasonable and type safe method signatures
 * Services that are not tied to activity lifecycles, which persist
   beyond the closing of the swap activity.
2015-06-02 00:18:37 +10:00
Peter Serwylo
0e16eae5bc Minor fixes to swap after refactor.
List views need to have their header view set _before_ an adapter is
assigned to them.

Was incorrectly passing an application context instead of an Activity
context to the progress dialog for swap.

Extend ActionBarActivity rather than FragmentActivity.

Don't persist swap workflow state to disk, only store it in the
singleton.
2015-05-28 23:34:03 +10:00
Peter Serwylo
ea61e8f2d3 Organised SwapState class, moved methods around to make more sense.
Put all of the step handling code in one place, added some comments to
make sense of the different parts of the claass and their
responsibilities.
2015-05-25 16:20:56 +10:00
Peter Serwylo
c26c6b9e89 Removed old SwapActivity + Fragments.
All the code from the activity and the fragments has been successfully
ported to the SwapWorkflowActivity + Views. Thus, the code is no longer
useful, as it was only kept over the previous WIP commits so that it
can be referred to to help re-implement fragments with views.
2015-05-25 16:07:49 +10:00
Peter Serwylo
f325e9d057 WIP: Moved start/stop local repo code from static FDroidApp to SwapState
Didn't change any behaviour, but wanted to start unifying swap state
management in one location.
2015-05-25 08:39:31 +10:00
Peter Serwylo
68c6648da5 WIP: Store selected apps in SwapState. Handle back presses for swap.
Currently the view to show after pressing the back button is defined
by individual InnerView classes. For example, the JoinWifiView always
says its previous step is the SelectAppsView. This works for the most
part, but doesn't work for:

 * The first StartSwapView class (instead handled by a special case in
   the Activity).

 * WifiQrView which could either be going back to the NfcView or the
   JoinWifiView, depending on a few cases, which the WifiQrView probably
   shouldn't care about.
2015-05-25 08:17:09 +10:00
Peter Serwylo
38059ec324 WIP: Initial state handling for swap process.
The state is saved to a preference file, but that is abstracted from
the SwapWorkflowActivity. It interacts with a SwapState object, which
is relatively safe in that you should not be able to save it into an
invalid state.

Note: At this point it is not tied to any service. I'm not sure it will
ever have to be either, as the service needs to persist state somewhere
anyway, so that will probably also end up saving to a preferences file
too.
2015-05-23 13:17:33 +10:00
Peter Serwylo
1b2678d6ed WIP: Applying styles correctly to views refactored from fragments. 2015-05-23 01:25:06 +10:00
Peter Serwylo
38eafdeedd WIP: Refactored wifi QR fragment into view.
As per the select apps list, there is quite a bit of business logic
in this class, which is now spread between the activity and the view.
The activity needs to handle some stuff, because the zxing library
routes intents to either an activity or a fragment.
2015-05-23 01:11:16 +10:00
Peter Serwylo
97994c5e43 WIP: Refactored NFC fragment to view. 2015-05-23 00:55:39 +10:00
Peter Serwylo
1fd6e447af WIP: Refactored join wifi fragment into view.
There is quite a lot of business logic that was moved directly from
the fragment to the view. Before this feature is complete, that logic
should either be moved into the activity, or into some sort of
associated Presenter class for the JoinWifiView.
2015-05-23 00:46:40 +10:00
Peter Serwylo
4f7f7b2cb5 WIP: Refactored select apps to swap into view.
Not worrying about styling yet, just functionality. Added an InnerView
interface that these views can implement. Currently it asks them to
populate the menu. It may be slightly inefficient if we end up with a
popup menu, because it is called onPrepareOptionsMenu, but expects the
inner view to inflate the menu. However, for swap this shouldn't be an
issue, as all the menus pretty much fit in the action bar of most screen
sizes.
2015-05-23 00:10:50 +10:00
Peter Serwylo
b6415dadb4 WIP: Refactored start swap fragment into a view.
Added a SwapWorkflowActivity to re-implement the SwapActivity.
Once all the fragments have been refactored into views, then the
SwapActivity will be removed.
2015-05-23 00:10:07 +10:00
Peter Serwylo
f298ed7156 Merge branch 'fix-263/explicitly-add-swap-repo' into integration 2015-05-21 07:52:35 +10:00