pull/1129/head
deniscerri 5 months ago
parent 00469962bb
commit 46bc8e7c13
No known key found for this signature in database
GPG Key ID: 95C43D517D830350

@ -92,7 +92,9 @@ class SettingsActivity : BaseActivity(), SettingHost {
}
onBackPressedDispatcher.addCallback(this) {
if (navController.currentDestination?.id == R.id.mainSettingsFragment) {
if (binding.searchView.isShowing) {
binding.searchView.hide()
} else if (navController.currentDestination?.id == R.id.mainSettingsFragment) {
navController.popBackStack()
finishAndRemoveTask()
}else{
@ -113,26 +115,30 @@ class SettingsActivity : BaseActivity(), SettingHost {
if (binding.collapsingToolbar.title != getString(R.string.settings)) return@addOnOffsetChangedListener
val totalScrollRange = appBarLayout.totalScrollRange
// Avoid division by zero
if (totalScrollRange == 0) return@addOnOffsetChangedListener
val percentage = Math.abs(verticalOffset).toFloat() / totalScrollRange
val isCollapsed = percentage > 0.8f
// 1. Handle Menu Icon Visibility
val isCollapsed = percentage > 0.8f
toolbar.menu.findItem(R.id.search)?.isVisible = isCollapsed
// 2. Handle SearchBar Visibility and Space
if (isCollapsed) {
if (searchBar.visibility != View.GONE) {
searchBar.visibility = View.GONE
// 2. Handle SearchBar
when {
percentage >= 1f -> {
// Fully collapsed — safe to GONE now, jump isn't visible
if (searchBar.visibility != View.GONE) searchBar.visibility = View.GONE
}
percentage > 0.8f -> {
// Mid-collapse — hide visually but keep space to avoid jump
searchBar.visibility = View.INVISIBLE
searchBar.alpha = 0f
}
} else {
if (searchBar.visibility != View.VISIBLE) {
searchBar.visibility = View.VISIBLE
else -> {
// Expanding — restore and fade in/out
if (searchBar.visibility != View.VISIBLE) searchBar.visibility = View.VISIBLE
searchBar.alpha = 1f - (percentage * 1.2f).coerceAtMost(1f)
}
// Fade it out as we scroll up
searchBar.alpha = 1f - (percentage * 1.2f).coerceAtMost(1f)
}
}

@ -8,6 +8,23 @@
android:fitsSystemWindows="true"
tools:context=".ui.more.settings.SettingsActivity">
<com.google.android.material.search.SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/search"
app:layout_anchor="@id/search_bar"
android:layout_marginBottom="-100dp"
android:paddingBottom="30dp"
app:layout_behavior="com.google.android.material.search.SearchView$Behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/search_suggestions_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.search.SearchView>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/frame_layout"
android:name="androidx.navigation.fragment.NavHostFragment"
@ -50,6 +67,7 @@
</com.google.android.material.appbar.CollapsingToolbarLayout>
<FrameLayout
android:id="@+id/search_bar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways|snap">
@ -65,18 +83,4 @@
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.search.SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/search"
app:layout_anchor="@id/search_bar">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/search_suggestions_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.search.SearchView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

@ -92,12 +92,11 @@
<TextView
android:id="@+id/downloadedChip"
style="@style/Widget.Material3.FloatingActionButton.Large.Secondary"
style="@style/Widget.Material3.FloatingActionButton.Large.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:background="@drawable/rounded_corner"
android:backgroundTint="?attr/colorSecondary"
android:clickable="false"
android:gravity="center"
android:outlineProvider="none"
@ -108,7 +107,7 @@
android:layout_marginStart="5dp"
android:textStyle="bold"
app:cornerRadius="10dp"
android:text="@string/downloaded"
android:text="@string/installed"
tools:visibility="gone"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
@ -122,7 +121,6 @@
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:background="@drawable/rounded_corner"
android:backgroundTint="?attr/colorSecondary"
android:clickable="false"
android:gravity="center"
android:minWidth="30dp"

@ -514,4 +514,5 @@
<string name="not_installed">Not installed</string>
<string name="bundled">Bundled</string>
<string name="use_app_language_for_metadata_summary">If enabled, metadata fields will follow your app language and even affect format selection by preferring dubbed versions instead of original</string>
<string name="installed">Installed</string>
</resources>

Loading…
Cancel
Save