Commit Graph

69 Commits

Author SHA1 Message Date
Samuel Holland
de53a1b50a ProfileEdit: Finish writing code-behind
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-10 01:05:20 -05:00
Samuel Holland
87d3200b29 ProfileActivity: Do menus correctly
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-10 01:04:46 -05:00
Samuel Holland
d6d6f34088 ProfileFragment: Make good use of the cached profile
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-10 00:57:44 -05:00
Samuel Holland
d00480a3a5 Settings: Add empty activity
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:34:28 -05:00
Samuel Holland
af8e013e33 Hook up editing to the layout and menus
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:31:12 -05:00
Samuel Holland
c199827b58 ProfileEdit: Add empty activity/fragment
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:30:25 -05:00
Samuel Holland
671aae7489 ProfileActivity: Do not use onClick for menus
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:28:04 -05:00
Samuel Holland
7d2d9f0cb3 ProfileActivity: Also remember editing state
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:25:11 -05:00
Samuel Holland
2c4f605b66 ProfileFragment: Helper class to remember a fragment's profile
Caching the actual profile object is important when the fragment is on
an activity's back stack: when it is shown again, onCreateView will be
called with profile already set and the service already connected. In
this case, there is no later notification from which to bind the
profile, so the existing object needs to be bound there.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 07:18:31 -05:00
Samuel Holland
39ed03f758 ProfileList: Add the list fragment in code so it knows the layout
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 06:19:37 -05:00
Samuel Holland
52cdf3e7e5 ProfileActivity: Replace fragments instead of hiding
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 05:12:00 -05:00
Samuel Holland
2e3daa8913 ProfileActivity: Extract base class for fixing fragments
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 03:23:25 -05:00
Samuel Holland
529e320e3f Interface: Correctly handle setting a null or empty key
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 02:51:54 -05:00
Samuel Holland
f0f9192aed KeyEncoding: Clean up and reorganize to match style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 02:51:08 -05:00
Samuel Holland
c3afe5be2c Keypair: Convert to java-style array declarations
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-09 02:44:46 -05:00
Jason A. Donenfeld
f6b864d4e7 Constant time base64
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-08 18:22:41 +02:00
Samuel Holland
f8d8e5e23e res: Add icons for quick settings tile
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-08 05:55:27 -05:00
Samuel Holland
99973a4b08 Profile: Add helper to check name validity
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-08 05:54:35 -05:00
Samuel Holland
c59b3e1230 Profile: Make name modifiable
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-08 05:54:12 -05:00
Samuel Holland
0685d4a159 ProfileActivity: Refactor into clean layers of functionality
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-08 05:51:38 -05:00
Samuel Holland
3076fd8c41 ProfileServiceInterface: Update for map-based collection
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 20:19:29 -05:00
Samuel Holland
01524c0dbf ProfileService: Use a map to store profile data
This has no visible changes at the moment, but will allow most functions
to pass around strings instead of Profile objects, obviating the need to
implement serialization for them. It also trades some naive linear
searches for the binary search in SimpleArrayMap.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 19:55:11 -05:00
Samuel Holland
7d3e796842 ObservableArrayMapAdapter: Copy ObservableListAdapter
Since the conversion to a sequential list (to implement ListAdapter)
depends on the implementation detail that ObservableArrayMap is backed
by an array, we can't use the ObservableMap interface here.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 19:46:19 -05:00
Samuel Holland
2df899eae5 ProfileActivity: Add two-pane master-detail layout
This is designed for tablets, but for testing purposes, it is currently
enabled for all devices in landscape orientation.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 18:51:47 -05:00
Samuel Holland
2154306fcb PlaceholderFragment: Simple fragment that shows a message
This is used for the detail pane when no profile is selected.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 18:48:46 -05:00
Samuel Holland
4c96e55b49 ProfileActivity: Make local variables final
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 18:43:52 -05:00
Samuel Holland
00a755f46f ProfileActivityFragment: Fix service connection tracking
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 18:42:38 -05:00
Samuel Holland
372477d0e0 ProfileList: Load fragment programmatically
This is necessary to replace it with the profile detail fragment later.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-07 16:55:02 -05:00
Samuel Holland
93e304ba2d ProfileList: Extract service management into a base class
It will be shared with other fragments.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 12:39:56 -05:00
Samuel Holland
81ab643d2b ProfileList: Convert to a fragment
This is required for a future two-fragment tablet layout, and simplifies
the code a bit since the profile detail (view/edit) will be implemented
as fragments anyway.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 12:24:18 -05:00
Samuel Holland
d0bf3b6b32 ProfileList: remove generated config from UI
It was only there for developing the parser.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 00:40:43 -05:00
Samuel Holland
4b401a368f RootShell: Make shell command configurable
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 00:37:58 -05:00
Samuel Holland
f0ac53e29b icon: Remove transparency inside non-round dragon
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 00:35:02 -05:00
Samuel Holland
6c71b88abd ProfileList: Remove "Add" menu action, to be replaced by a FAB
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-01 02:06:17 -05:00
Samuel Holland
5d5cdf54fa ProfileService: Rework profile updating
This should help discourage editing a Profile without making a copy
first, since the caller has to keep track of the old Profile as well.

ProfileAdder has been updated to prevent adding duplicate profiles. It
checks once in the constructor, so the caller can catch the exception
and pass the error back to the UI. It checks again in the worker thread
to prevent any race from happening if a profile is added twice quickly.
Either the file exists, or it doesn't.

Additionally, this change solves the race condition when the old
profile is removed before it is updated; previously this would lead
to the profile being re-added. Now, ProfileRemover will fail and the
profile will stay removed.

Finally, updating a profile's name should now work correctly. There were
previously multiple bugs with that (the old profile wasn't removed, the
new one could duplicate a name, the new one could overwrite some random
other one, etc.).

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-01 01:38:39 -05:00
Samuel Holland
874db0b95e Interface: Convert to using Keypair class
This allows retrieving the public key and generating keypairs, both of
which will be exposed in the UI.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-01 01:12:59 -05:00
Samuel Holland
19e8087642 Keypair: Create class for generating/storing keys
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-01 01:08:56 -05:00
Samuel Holland
4208d524b1 Curve25519: Import class from noise-java
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-01 01:06:34 -05:00
Samuel Holland
1e0a437c3b RootShell: rename SETUP to SETUP_TEMPLATE
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-08-04 00:37:29 -05:00
Samuel Holland
e718a7c03c RootShell: Use the application cache dir as TMPDIR
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 23:21:59 -05:00
Samuel Holland
544812b2a7 ProfileService: Use wg to enumerate interfaces
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 23:11:18 -05:00
Samuel Holland
b324e7b7f1 BootCompletedReceiver: Enforce receiving the correct broadcast
This satisfies an Android security lint.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 22:15:50 -05:00
Samuel Holland
84e19d6c72 ProfileList: Add a simple menu
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-29 06:39:37 -05:00
Samuel Holland
411b0716f2 ProfileList: Toggle connection state on click
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:30:51 -05:00
Samuel Holland
b6653fd7f0 ProfileService: Implement the rest of its interface
As per the FIXMEs, the list of profiles should eventually become a map.
Since it can only be modified on the main thread anyway, the current
code is still safe, and it works, it's just not optimal.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:22:02 -05:00
Samuel Holland
0ea5ae605c ProfileService: Use deep copy to clone profiles
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:20:04 -05:00
Samuel Holland
ca708ba382 Profile: Implement deep copying
This is a simple, naive implementation that {,de}serializes the
profile's state, but it does not depend on the internal representation
of Profile or its contained classes.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:14:42 -05:00
Samuel Holland
c3b42b85cc Copyable: New utility interface for deep-copyable classes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:11:33 -05:00
Samuel Holland
465a969a70 ProfileList: Add indicator of profile connection state
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:29:29 -05:00
Samuel Holland
0451370caf ProfileService: Check for existing interfaces when loading profiles
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-07-31 21:18:14 -05:00