diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-16 11:03:47 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-16 18:01:06 +0200 |
commit | c56065fcfe9fb887cb7ccec23a7af22111f352bc (patch) | |
tree | eced7c5f2b684829ca53590d2d904768d55e7a6d /ui/src/main | |
parent | 52a2ae36f611db3a7a0246910f64f9f48a725efc (diff) |
TunnelEditorFragment: move backwards using fragment manager instead of hack
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt | 10 | ||||
-rw-r--r-- | ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt | 2 |
2 files changed, 5 insertions, 7 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt index b7912175..bb09c5eb 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt @@ -117,13 +117,11 @@ class TunnelEditorFragment : BaseFragment(), AppSelectionListener { inputManager?.hideSoftInputFromWindow(focusedView.windowToken, InputMethodManager.HIDE_NOT_ALWAYS) } + parentFragmentManager.popBackStackImmediate() - // Tell the activity to finish itself or go back to the detail view. - // TODO(smaeul): Remove this hack when fixing the Config ViewModel - // The selected tunnel has to actually change, but we have to remember this one. - val savedTunnel = tunnel - if (savedTunnel === selectedTunnel) selectedTunnel = null - selectedTunnel = savedTunnel + // If we just made a new one, save it to select the details page. + if (selectedTunnel != tunnel) + selectedTunnel = tunnel } override fun onOptionsItemSelected(item: MenuItem): Boolean { diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt index 0d56edd3..8b43e1f7 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt @@ -221,7 +221,7 @@ class TunnelListFragment : BaseFragment() { override fun onSelectedTunnelChanged(oldTunnel: ObservableTunnel?, newTunnel: ObservableTunnel?) { binding ?: return - lifecycleScope.launch(Dispatchers.Main) { + lifecycleScope.launch { val tunnels = Application.getTunnelManager().getTunnels() if (newTunnel != null) viewForTunnel(newTunnel, tunnels).setSingleSelected(true) if (oldTunnel != null) viewForTunnel(oldTunnel, tunnels).setSingleSelected(false) |