Skip to content

Commit aa68b51

Browse files
committed
ui: set fitsSystemWindows=true for EdgeToEdge on API 35+
Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 67db72a commit aa68b51

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

ui/src/main/java/com/wireguard/android/activity/SettingsActivity.kt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ import android.view.MenuItem
1212
import android.view.View
1313
import android.view.ViewGroup
1414
import androidx.appcompat.app.AppCompatActivity
15-
import androidx.core.view.ViewCompat
16-
import androidx.core.view.WindowInsetsCompat
17-
import androidx.core.view.updateLayoutParams
1815
import androidx.fragment.app.commit
1916
import androidx.lifecycle.lifecycleScope
2017
import androidx.preference.Preference
@@ -56,16 +53,7 @@ class SettingsActivity : AppCompatActivity() {
5653
// which is enabled everywhere for API 35. So handle the insets manually here.
5754
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
5855
val view = super.onCreateView(inflater, container, savedInstanceState)
59-
ViewCompat.setOnApplyWindowInsetsListener(view) { v, windowInsets ->
60-
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
61-
v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
62-
leftMargin = insets.left
63-
bottomMargin = insets.bottom
64-
rightMargin = insets.right
65-
topMargin = insets.top
66-
}
67-
WindowInsetsCompat.CONSUMED
68-
}
56+
view.fitsSystemWindows = true
6957
return view
7058
}
7159

ui/src/main/java/com/wireguard/android/activity/TunnelCreatorActivity.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
package com.wireguard.android.activity
66

77
import android.os.Bundle
8+
import android.view.View
9+
import android.view.ViewGroup
10+
import androidx.core.view.children
811
import androidx.fragment.app.commit
912
import com.wireguard.android.fragment.TunnelEditorFragment
1013
import com.wireguard.android.model.ObservableTunnel
@@ -26,4 +29,9 @@ class TunnelCreatorActivity : BaseActivity() {
2629
finish()
2730
return true
2831
}
32+
33+
override fun onAttachedToWindow() {
34+
super.onAttachedToWindow()
35+
(findViewById<View?>(android.R.id.content) as? ViewGroup)?.children?.firstOrNull()?.fitsSystemWindows = true
36+
}
2937
}

ui/src/main/res/layout-sw600dp/main_activity.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
android:id="@+id/main_activity_container"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7+
android:fitsSystemWindows="true"
78
tools:context=".activity.MainActivity">
89

910
<LinearLayout

ui/src/main/res/layout/log_viewer_activity.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
xmlns:app="http://schemas.android.com/apk/res-auto"
88
xmlns:tools="http://schemas.android.com/tools"
99
android:layout_width="match_parent"
10-
android:layout_height="match_parent">
10+
android:layout_height="match_parent"
11+
android:fitsSystemWindows="true">
1112

1213
<androidx.recyclerview.widget.RecyclerView
1314
android:id="@+id/recycler_view"

0 commit comments

Comments
 (0)