TunnelEditorFragment: move backwards using fragment manager instead of hack

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2020-09-16 11:03:47 +02:00
parent 52a2ae36f6
commit c56065fcfe
2 changed files with 5 additions and 7 deletions

View File

@ -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 {

View File

@ -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)