aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/main/java/com/wireguard
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-09-30 22:42:05 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-09-30 22:42:05 +0530
commit5d7ce139bcfd3725feb0c30a84eca6887d59d331 (patch)
tree3a22100715eee159f8cfa4d20904795fd86e842b /ui/src/main/java/com/wireguard
parentui: account for binding disappearing on detail fragment (diff)
downloadwireguard-android-5d7ce139bcfd3725feb0c30a84eca6887d59d331.tar.xz
wireguard-android-5d7ce139bcfd3725feb0c30a84eca6887d59d331.zip
ui: use commit extension from fragment-ktx
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/java/com/wireguard')
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/MainActivity.kt21
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt7
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.kt7
3 files changed, 19 insertions, 16 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/MainActivity.kt b/ui/src/main/java/com/wireguard/android/activity/MainActivity.kt
index 336cda8..c5f5857 100644
--- a/ui/src/main/java/com/wireguard/android/activity/MainActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/MainActivity.kt
@@ -12,6 +12,7 @@ import android.view.View
import androidx.appcompat.app.ActionBar
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
+import androidx.fragment.app.commit
import com.wireguard.android.R
import com.wireguard.android.fragment.TunnelDetailFragment
import com.wireguard.android.fragment.TunnelEditorFragment
@@ -72,11 +73,11 @@ class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener
true
}
R.id.menu_action_edit -> {
- supportFragmentManager.beginTransaction()
- .replace(R.id.detail_container, TunnelEditorFragment())
- .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
- .addToBackStack(null)
- .commit()
+ supportFragmentManager.commit {
+ replace(R.id.detail_container, TunnelEditorFragment())
+ setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
+ addToBackStack(null)
+ }
true
}
// This menu item is handled by the editor fragment.
@@ -104,11 +105,11 @@ class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener
fragmentManager.popBackStackImmediate()
} else if (backStackEntries == 0) {
// Create and show a new detail fragment.
- fragmentManager.beginTransaction()
- .add(R.id.detail_container, TunnelDetailFragment())
- .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
- .addToBackStack(null)
- .commit()
+ fragmentManager.commit {
+ add(R.id.detail_container, TunnelDetailFragment())
+ setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
+ addToBackStack(null)
+ }
}
}
}
diff --git a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
index 0ece6f4..06091ca 100644
--- a/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt
@@ -8,6 +8,7 @@ import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.MenuItem
+import androidx.fragment.app.commit
import androidx.lifecycle.lifecycleScope
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
@@ -28,9 +29,9 @@ class SettingsActivity : ThemeChangeAwareActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (supportFragmentManager.findFragmentById(android.R.id.content) == null) {
- supportFragmentManager.beginTransaction()
- .add(android.R.id.content, SettingsFragment())
- .commit()
+ supportFragmentManager.commit {
+ add(android.R.id.content, SettingsFragment())
+ }
}
}
diff --git a/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.kt b/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.kt
index d3d4d4f..f93c1a1 100644
--- a/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.kt
@@ -5,6 +5,7 @@
package com.wireguard.android.activity
import android.os.Bundle
+import androidx.fragment.app.commit
import com.wireguard.android.fragment.TunnelEditorFragment
import com.wireguard.android.model.ObservableTunnel
@@ -15,9 +16,9 @@ class TunnelCreatorActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (supportFragmentManager.findFragmentById(android.R.id.content) == null) {
- supportFragmentManager.beginTransaction()
- .add(android.R.id.content, TunnelEditorFragment())
- .commit()
+ supportFragmentManager.commit {
+ add(android.R.id.content, TunnelEditorFragment())
+ }
}
}