Skip to content

Commit

Permalink
Take IME padding into account when managing insets
Browse files Browse the repository at this point in the history
Closes #175
  • Loading branch information
Bartuzen committed Jan 23, 2025
1 parent ff7f769 commit dfcb54a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 3 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@

<activity
android:name=".ui.settings.SettingsActivity"
android:exported="false"
android:windowSoftInputMode="adjustResize">
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />
Expand All @@ -42,8 +41,7 @@

<activity
android:name=".ui.addtorrent.AddTorrentActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

Expand Down Expand Up @@ -82,8 +80,7 @@

<activity
android:name=".ui.rss.RssActivity"
android:exported="false"
android:windowSoftInputMode="adjustResize" />
android:exported="false" />

<activity
android:name=".ui.search.SearchActivity"
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/dev/bartuzen/qbitcontroller/utils/Insets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ fun View.applyInsets(top: Boolean, bottom: Boolean, start: Boolean, end: Boolean
val isLtr = layoutDirection == View.LAYOUT_DIRECTION_LTR

val topPadding = if (top) insets.top else 0
val bottomPadding = if (bottom) insets.bottom else 0
val bottomPadding = if (bottom) {
if (windowInsets.isVisible(WindowInsetsCompat.Type.ime())) {
windowInsets.getInsets(WindowInsetsCompat.Type.ime()).bottom
} else {
insets.bottom
}
} else {
0
}

val startPadding = if (start) {
if (isLtr) insets.left else insets.right
Expand Down

0 comments on commit dfcb54a

Please sign in to comment.