Skip to content

Commit

Permalink
feat: add window insets handling to AboutActivity #339 (#340)
Browse files Browse the repository at this point in the history
Added support for handling window insets in AboutActivity. The code now applies system bar insets as margins to the view for better UI adjustments. Also updated patch version to 5.

# GENERATE BY https://aicommit.app
  • Loading branch information
rosuH authored Sep 15, 2024
1 parent 7e77cae commit 5f47982
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions app/src/main/java/me/rosuh/easywatermark/ui/about/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.TextView
import android.widget.Toast
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.children
import androidx.core.view.updateLayoutParams
import androidx.core.widget.TextViewCompat
import androidx.palette.graphics.Palette
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -63,6 +67,21 @@ class AboutActivity : AppCompatActivity() {

private fun initView() {
with(binding) {
// WindowInsets.Companion.navigationBars: WindowInsets
ViewCompat.setOnApplyWindowInsetsListener(nsv) { v, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
// Apply the insets as a margin to the view. This solution sets
// only the bottom, left, and right dimensions, but you can apply whichever
// insets are appropriate to your layout. You can also update the view padding
// if that's more appropriate.
v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = insets.bottom
}

// Return CONSUMED if you don't want want the window insets to keep passing
// down to descendant views.
WindowInsetsCompat.CONSUMED
}
bgDrawable = ContextCompat.getDrawable(
this@AboutActivity,
me.rosuh.easywatermark.R.drawable.bg_gradient_about_page
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
app:layout_constraintTop_toTopOf="parent" />

<androidx.core.widget.NestedScrollView
android:id="@+id/nsv"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ android.nonFinalResIds=false

majorVersion=2
minorVersion=9
patchVersion=4
patchVersion=5

0 comments on commit 5f47982

Please sign in to comment.