summaryrefslogtreecommitdiffhomepage
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/MainActivity.kt14
-rw-r--r--ui/src/main/res/layout-sw600dp/main_activity.xml1
-rw-r--r--ui/src/main/res/layout/main_activity.xml2
3 files changed, 9 insertions, 8 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 237a75f4..f567e763 100644
--- a/ui/src/main/java/com/wireguard/android/activity/MainActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/MainActivity.kt
@@ -9,8 +9,9 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
-import android.widget.LinearLayout
import androidx.appcompat.app.ActionBar
+import androidx.core.view.ViewCompat
+import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import com.wireguard.android.R
@@ -55,16 +56,15 @@ class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener
super.onCreate(savedInstanceState)
setContentView(R.layout.main_activity)
actionBar = supportActionBar
- isTwoPaneLayout = findViewById<View>(R.id.master_detail_wrapper) is LinearLayout
+ isTwoPaneLayout = findViewById<View?>(R.id.master_detail_wrapper) != null
supportFragmentManager.addOnBackStackChangedListener(this)
onBackStackChanged()
// Dispatch insets on back stack change
// This is required to ensure replaced fragments are also able to consume insets
- findViewById<View>(R.id.master_detail_wrapper).setOnApplyWindowInsetsListener { _, insets ->
- val fragmentManager = supportFragmentManager
- fragmentManager.addOnBackStackChangedListener {
- fragmentManager.fragments.forEach {
- it.requireView().dispatchApplyWindowInsets(insets)
+ findViewById<View>(R.id.main_activity_container).setOnApplyWindowInsetsListener { _, insets ->
+ supportFragmentManager.addOnBackStackChangedListener {
+ supportFragmentManager.fragments.forEach {
+ ViewCompat.dispatchApplyWindowInsets(it.requireView(), WindowInsetsCompat.toWindowInsetsCompat(insets))
}
}
insets
diff --git a/ui/src/main/res/layout-sw600dp/main_activity.xml b/ui/src/main/res/layout-sw600dp/main_activity.xml
index 00fa1c49..b5ce34a4 100644
--- a/ui/src/main/res/layout-sw600dp/main_activity.xml
+++ b/ui/src/main/res/layout-sw600dp/main_activity.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/main_activity_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.MainActivity">
diff --git a/ui/src/main/res/layout/main_activity.xml b/ui/src/main/res/layout/main_activity.xml
index 89be4fe4..a970d8e2 100644
--- a/ui/src/main/res/layout/main_activity.xml
+++ b/ui/src/main/res/layout/main_activity.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/master_detail_wrapper"
+ android:id="@+id/main_activity_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"