From d1e85633fbe8d871355d2b9feb51e2c9983d8a21 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Wed, 5 Sep 2018 20:17:14 -0500 Subject: [PATCH] Remodel the Model - The configuration and crypto model is now entirely independent of Android classes other than Nullable and TextUtils. - Model classes are immutable and use builders that enforce the appropriate optional/required attributes. - The Android config proxies (for Parcelable and databinding) are moved to the Android side of the codebase, and are designed to be safe for two-way databinding. This allows proper observability in TunnelDetailFragment. - Various robustness fixes and documentation updates to helper classes. Signed-off-by: Jason A. Donenfeld --- .idea/copyright/Default.xml | 2 +- .idea/copyright/profiles_settings.xml | 4 +- .idea/inspectionProfiles/Default.xml | 1 - app/build.gradle | 12 +- .../wireguard/android/backend/GoBackend.java | 36 +- .../android/backend/WgQuickBackend.java | 2 +- .../android/configStore/FileConfigStore.java | 9 +- .../android/databinding/BindingAdapters.java | 52 +- .../ObservableKeyedRecyclerViewAdapter.java | 2 +- .../fragment/AppListDialogFragment.java | 17 +- .../fragment/ConfigNamingDialogFragment.java | 7 +- .../fragment/TunnelDetailFragment.java | 9 +- .../fragment/TunnelEditorFragment.java | 115 +--- .../android/fragment/TunnelListFragment.java | 14 +- .../android/model/ApplicationData.java | 1 - .../com/wireguard/android/model/Tunnel.java | 6 +- .../android/model/TunnelManager.java | 4 +- .../android/preference/VersionPreference.java | 3 +- .../android/util/ExceptionLoggers.java | 41 +- .../wireguard/android/util/FragmentUtils.java | 1 - .../util/ObservableKeyedArrayList.java | 6 +- .../util/ObservableSortedKeyedArrayList.java | 3 +- .../android/viewmodel/ConfigProxy.java | 93 +++ .../android/viewmodel/InterfaceProxy.java | 189 +++++ .../android/viewmodel/PeerProxy.java | 379 ++++++++++ .../android/widget/KeyInputFilter.java | 11 +- .../android/widget/NameInputFilter.java | 3 +- .../widget/fab/FloatingActionsMenu.java | 2 +- .../java/com/wireguard/config/Attribute.java | 91 +-- .../java/com/wireguard/config/Config.java | 265 +++---- .../com/wireguard/config/InetAddresses.java | 29 +- .../com/wireguard/config/InetEndpoint.java | 111 ++- .../com/wireguard/config/InetNetwork.java | 30 +- .../java/com/wireguard/config/Interface.java | 646 ++++++++---------- .../com/wireguard/config/ParseException.java | 41 ++ .../main/java/com/wireguard/config/Peer.java | 570 +++++++--------- .../main/java/com/wireguard/crypto/Key.java | 255 +++++++ .../com/wireguard/crypto/KeyEncoding.java | 161 ----- .../java/com/wireguard/crypto/KeyPair.java | 81 +++ .../java/com/wireguard/crypto/Keypair.java | 55 -- .../res/layout/tunnel_detail_fragment.xml | 6 +- .../main/res/layout/tunnel_detail_peer.xml | 6 +- .../res/layout/tunnel_editor_fragment.xml | 28 +- .../main/res/layout/tunnel_editor_peer.xml | 13 +- .../main/res/layout/tunnel_list_fragment.xml | 3 +- app/src/main/res/values/strings.xml | 5 +- build.gradle | 2 +- 47 files changed, 2082 insertions(+), 1340 deletions(-) create mode 100644 app/src/main/java/com/wireguard/android/viewmodel/ConfigProxy.java create mode 100644 app/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.java create mode 100644 app/src/main/java/com/wireguard/android/viewmodel/PeerProxy.java create mode 100644 app/src/main/java/com/wireguard/config/ParseException.java create mode 100644 app/src/main/java/com/wireguard/crypto/Key.java delete mode 100644 app/src/main/java/com/wireguard/crypto/KeyEncoding.java create mode 100644 app/src/main/java/com/wireguard/crypto/KeyPair.java delete mode 100644 app/src/main/java/com/wireguard/crypto/Keypair.java diff --git a/.idea/copyright/Default.xml b/.idea/copyright/Default.xml index 9149bd43..cb646393 100644 --- a/.idea/copyright/Default.xml +++ b/.idea/copyright/Default.xml @@ -1,6 +1,6 @@ - diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml index 53146971..eb839538 100644 --- a/.idea/copyright/profiles_settings.xml +++ b/.idea/copyright/profiles_settings.xml @@ -1,3 +1,3 @@ - - \ No newline at end of file + + diff --git a/.idea/inspectionProfiles/Default.xml b/.idea/inspectionProfiles/Default.xml index 6dd07e6e..f048a118 100644 --- a/.idea/inspectionProfiles/Default.xml +++ b/.idea/inspectionProfiles/Default.xml @@ -385,7 +385,6 @@