ui: set fitsSystemWindows=true for EdgeToEdge on API 35+
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -12,9 +12,6 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.fragment.app.commit
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.Preference
|
||||
@@ -56,16 +53,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||
// which is enabled everywhere for API 35. So handle the insets manually here.
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
val view = super.onCreateView(inflater, container, savedInstanceState)
|
||||
ViewCompat.setOnApplyWindowInsetsListener(view) { v, windowInsets ->
|
||||
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
leftMargin = insets.left
|
||||
bottomMargin = insets.bottom
|
||||
rightMargin = insets.right
|
||||
topMargin = insets.top
|
||||
}
|
||||
WindowInsetsCompat.CONSUMED
|
||||
}
|
||||
view.fitsSystemWindows = true
|
||||
return view
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
package com.wireguard.android.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.children
|
||||
import androidx.fragment.app.commit
|
||||
import com.wireguard.android.fragment.TunnelEditorFragment
|
||||
import com.wireguard.android.model.ObservableTunnel
|
||||
@@ -26,4 +29,9 @@ class TunnelCreatorActivity : BaseActivity() {
|
||||
finish()
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
(findViewById<View?>(android.R.id.content) as? ViewGroup)?.children?.firstOrNull()?.fitsSystemWindows = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
android:id="@+id/main_activity_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".activity.MainActivity">
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
|
||||
Reference in New Issue
Block a user