From 82698937867519d7e05b4e7e75385bea830e55a1 Mon Sep 17 00:00:00 2001 From: iKirby <6316115+iKirby@users.noreply.github.com> Date: Tue, 25 Feb 2025 21:18:17 +0800 Subject: [PATCH] Apply bottom inset to RecyclerView --- .../io/nekohasekai/sfa/ui/debug/VPNScanActivity.kt | 11 +++++++++++ .../sfa/ui/profileoverride/PerAppProxyActivity.kt | 9 +++++++++ app/src/main/res/layout/activity_per_app_proxy.xml | 1 + 3 files changed, 21 insertions(+) diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/debug/VPNScanActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/debug/VPNScanActivity.kt index f56717c..8439d19 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/debug/VPNScanActivity.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/debug/VPNScanActivity.kt @@ -7,7 +7,10 @@ import android.os.Build import android.os.Bundle import android.util.Log import android.view.ViewGroup +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat import androidx.core.view.isVisible +import androidx.core.view.updatePadding import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -16,6 +19,7 @@ import io.nekohasekai.libbox.Libbox import io.nekohasekai.sfa.R import io.nekohasekai.sfa.databinding.ActivityVpnScanBinding import io.nekohasekai.sfa.databinding.ViewVpnAppItemBinding +import io.nekohasekai.sfa.ktx.dp2px import io.nekohasekai.sfa.ktx.toStringIterator import io.nekohasekai.sfa.ui.shared.AbstractActivity import kotlinx.coroutines.Dispatchers @@ -33,6 +37,13 @@ class VPNScanActivity : AbstractActivity() { super.onCreate(savedInstanceState) 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 { adapter = it } diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/profileoverride/PerAppProxyActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/profileoverride/PerAppProxyActivity.kt index ea5cd09..7868fcb 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/profileoverride/PerAppProxyActivity.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/profileoverride/PerAppProxyActivity.kt @@ -16,7 +16,10 @@ import android.view.ViewGroup import android.widget.Toast import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.SearchView +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat import androidx.core.view.isVisible +import androidx.core.view.updatePadding import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.RecyclerView import com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile @@ -86,6 +89,12 @@ class PerAppProxyActivity : AbstractActivity() { 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 { withContext(Dispatchers.IO) { proxyMode = if (Settings.perAppProxyMode == Settings.PER_APP_PROXY_INCLUDE) { diff --git a/app/src/main/res/layout/activity_per_app_proxy.xml b/app/src/main/res/layout/activity_per_app_proxy.xml index 8cdc36e..bfb4312 100644 --- a/app/src/main/res/layout/activity_per_app_proxy.xml +++ b/app/src/main/res/layout/activity_per_app_proxy.xml @@ -47,6 +47,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical" + android:clipToPadding="false" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:listitem="@layout/view_app_list_item" />