Apply bottom inset to RecyclerView

This commit is contained in:
iKirby 2025-02-24 20:34:00 +08:00
parent 0576fd75a6
commit d45fc081dd
3 changed files with 21 additions and 0 deletions

View file

@ -7,7 +7,10 @@ import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.view.updatePadding
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -16,6 +19,7 @@ import io.nekohasekai.libbox.Libbox
import io.nekohasekai.sfa.R import io.nekohasekai.sfa.R
import io.nekohasekai.sfa.databinding.ActivityVpnScanBinding import io.nekohasekai.sfa.databinding.ActivityVpnScanBinding
import io.nekohasekai.sfa.databinding.ViewVpnAppItemBinding import io.nekohasekai.sfa.databinding.ViewVpnAppItemBinding
import io.nekohasekai.sfa.ktx.dp2px
import io.nekohasekai.sfa.ktx.toStringIterator import io.nekohasekai.sfa.ktx.toStringIterator
import io.nekohasekai.sfa.ui.shared.AbstractActivity import io.nekohasekai.sfa.ui.shared.AbstractActivity
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -33,6 +37,13 @@ class VPNScanActivity : AbstractActivity<ActivityVpnScanBinding>() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setTitle(R.string.title_scan_vpn) setTitle(R.string.title_scan_vpn)
ViewCompat.setOnApplyWindowInsetsListener(binding.scanVPNResult) { view, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
view.updatePadding(bottom = insets.bottom + dp2px(16))
WindowInsetsCompat.CONSUMED
}
binding.scanVPNResult.adapter = Adapter().also { binding.scanVPNResult.adapter = Adapter().also {
adapter = it adapter = it
} }

View file

@ -16,7 +16,10 @@ import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.view.updatePadding
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile import com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile
@ -86,6 +89,12 @@ class PerAppProxyActivity : AbstractActivity<ActivityPerAppProxyBinding>() {
setTitle(R.string.title_per_app_proxy) setTitle(R.string.title_per_app_proxy)
ViewCompat.setOnApplyWindowInsetsListener(binding.appList) { view, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
view.updatePadding(bottom = insets.bottom)
WindowInsetsCompat.CONSUMED
}
lifecycleScope.launch { lifecycleScope.launch {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
proxyMode = if (Settings.perAppProxyMode == Settings.PER_APP_PROXY_INCLUDE) { proxyMode = if (Settings.perAppProxyMode == Settings.PER_APP_PROXY_INCLUDE) {

View file

@ -47,6 +47,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scrollbars="vertical" android:scrollbars="vertical"
android:clipToPadding="false"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:listitem="@layout/view_app_list_item" /> tools:listitem="@layout/view_app_list_item" />