Skip to content

Commit c4df3a9

Browse files
committed
Bump target sdk to 35
1 parent a2809cd commit c4df3a9

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313
defaultConfig {
1414
applicationId "com.klee.sapio"
1515
minSdk 21
16-
targetSdk 34
16+
targetSdk 35
1717
versionCode 61
1818
versionName "1.8.1"
1919

app/src/main/java/com/klee/sapio/ui/view/MainActivity.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import android.os.Bundle
66
import android.view.Menu
77
import android.view.MenuInflater
88
import android.view.MenuItem
9+
import android.view.ViewGroup
910
import androidx.appcompat.app.AppCompatActivity
11+
import androidx.core.view.ViewCompat
12+
import androidx.core.view.WindowInsetsCompat
13+
import androidx.core.view.updateLayoutParams
1014
import androidx.fragment.app.Fragment
1115
import com.klee.sapio.R
1216
import com.klee.sapio.databinding.ActivityMainBinding
@@ -29,6 +33,8 @@ class MainActivity : AppCompatActivity() {
2933

3034
displayFragment(FeedFragment())
3135

36+
handleEdgeToEdgeInsets()
37+
3238
mBinding.bottomNavigation.setOnItemSelectedListener { item ->
3339
when (item.itemId) {
3440
R.id.feed -> displayFragment(FeedFragment())
@@ -43,6 +49,23 @@ class MainActivity : AppCompatActivity() {
4349
supportFragmentManager.beginTransaction().replace(R.id.fragment_container, fragment).commit()
4450
}
4551

52+
private fun handleEdgeToEdgeInsets() {
53+
ViewCompat.setOnApplyWindowInsetsListener(mBinding.root) { v, windowInsets ->
54+
val bars = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()
55+
or WindowInsetsCompat.Type.displayCutout()
56+
)
57+
58+
v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
59+
bottomMargin = bars.bottom
60+
leftMargin = bars.left
61+
rightMargin = bars.right
62+
topMargin = bars.top
63+
}
64+
65+
WindowInsetsCompat.CONSUMED
66+
}
67+
}
68+
4669
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
4770
val inflater: MenuInflater = menuInflater
4871
inflater.inflate(R.menu.menu, menu)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11
package com.klee.sapio.ui.view
22

33
import android.os.Bundle
4+
import android.view.View
5+
import androidx.core.view.ViewCompat
6+
import androidx.core.view.WindowInsetsCompat
7+
import androidx.core.view.updatePadding
48
import androidx.preference.PreferenceFragmentCompat
59
import com.klee.sapio.R
610

711
class PreferencesFragment : PreferenceFragmentCompat() {
812
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
913
setPreferencesFromResource(R.xml.preferences, rootKey)
1014
}
15+
16+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
17+
super.onViewCreated(view, savedInstanceState)
18+
19+
ViewCompat.setOnApplyWindowInsetsListener(view) { v, windowInsets ->
20+
val bars = windowInsets.getInsets(
21+
WindowInsetsCompat.Type.systemBars()
22+
or WindowInsetsCompat.Type.displayCutout()
23+
)
24+
25+
v.updatePadding(
26+
left = bars.left,
27+
right = bars.right,
28+
top = bars.top,
29+
bottom = bars.bottom
30+
)
31+
32+
WindowInsetsCompat.CONSUMED
33+
}
34+
}
1135
}

0 commit comments

Comments
 (0)