all: reformat
This commit is contained in:
@@ -27,7 +27,6 @@ import androidx.activity.result.contract.ActivityResultContracts
|
|||||||
import androidx.core.view.MenuCompat
|
import androidx.core.view.MenuCompat
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updatePadding
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
@@ -41,7 +40,6 @@ import com.google.android.material.tabs.TabLayoutMediator
|
|||||||
import com.google.android.material.transition.MaterialSharedAxis
|
import com.google.android.material.transition.MaterialSharedAxis
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
import kotlin.math.abs
|
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.databinding.FragmentHomeBinding
|
import org.oxycblt.auxio.databinding.FragmentHomeBinding
|
||||||
import org.oxycblt.auxio.detail.DetailViewModel
|
import org.oxycblt.auxio.detail.DetailViewModel
|
||||||
@@ -82,8 +80,7 @@ import timber.log.Timber as L
|
|||||||
* @author Alexander Capehart (OxygenCobalt)
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
*/
|
*/
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class HomeFragment :
|
class HomeFragment : SelectionFragment<FragmentHomeBinding>() {
|
||||||
SelectionFragment<FragmentHomeBinding>() {
|
|
||||||
override val listModel: ListViewModel by activityViewModels()
|
override val listModel: ListViewModel by activityViewModels()
|
||||||
override val musicModel: MusicViewModel by activityViewModels()
|
override val musicModel: MusicViewModel by activityViewModels()
|
||||||
override val playbackModel: PlaybackViewModel by activityViewModels()
|
override val playbackModel: PlaybackViewModel by activityViewModels()
|
||||||
@@ -130,10 +127,7 @@ class HomeFragment :
|
|||||||
// --- UI SETUP ---
|
// --- UI SETUP ---
|
||||||
|
|
||||||
binding.homeAppbar.addOnOffsetChangedListener(
|
binding.homeAppbar.addOnOffsetChangedListener(
|
||||||
FadingToolbarOffsetListener(
|
FadingToolbarOffsetListener(binding.homeToolbar, binding.homeContent)
|
||||||
binding.homeToolbar,
|
|
||||||
binding.homeContent
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
binding.homeNormalToolbar.apply {
|
binding.homeNormalToolbar.apply {
|
||||||
setOnMenuItemClickListener(this@HomeFragment)
|
setOnMenuItemClickListener(this@HomeFragment)
|
||||||
|
|||||||
@@ -47,10 +47,14 @@ import coil3.request.ImageRequest
|
|||||||
import coil3.request.target
|
import coil3.request.target
|
||||||
import coil3.request.transformations
|
import coil3.request.transformations
|
||||||
import coil3.util.CoilUtils
|
import coil3.util.CoilUtils
|
||||||
|
import com.google.android.material.R as MR
|
||||||
import com.google.android.material.shape.MaterialShapeDrawable
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
import com.google.android.material.shape.RelativeCornerSize
|
import com.google.android.material.shape.RelativeCornerSize
|
||||||
import com.google.android.material.shape.ShapeAppearanceModel
|
import com.google.android.material.shape.ShapeAppearanceModel
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import javax.inject.Inject
|
||||||
|
import kotlin.math.min
|
||||||
|
import kotlin.random.Random
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.image.coil.GalleryCoverCollection
|
import org.oxycblt.auxio.image.coil.GalleryCoverCollection
|
||||||
import org.oxycblt.auxio.image.coil.RoundedRectTransformation
|
import org.oxycblt.auxio.image.coil.RoundedRectTransformation
|
||||||
@@ -70,10 +74,6 @@ import org.oxycblt.musikr.Genre
|
|||||||
import org.oxycblt.musikr.Playlist
|
import org.oxycblt.musikr.Playlist
|
||||||
import org.oxycblt.musikr.Song
|
import org.oxycblt.musikr.Song
|
||||||
import org.oxycblt.musikr.covers.CoverCollection
|
import org.oxycblt.musikr.covers.CoverCollection
|
||||||
import javax.inject.Inject
|
|
||||||
import kotlin.math.min
|
|
||||||
import kotlin.random.Random
|
|
||||||
import com.google.android.material.R as MR
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auxio's extension of [ImageView] that enables cover art loading and playing indicator and
|
* Auxio's extension of [ImageView] that enables cover art loading and playing indicator and
|
||||||
@@ -121,18 +121,14 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
@SuppressLint("CustomViewStyleable")
|
@SuppressLint("CustomViewStyleable")
|
||||||
val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.CoverView)
|
val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.CoverView)
|
||||||
|
|
||||||
val shapeAppearanceRes = styledAttrs.getResourceId(
|
val shapeAppearanceRes =
|
||||||
R.styleable.CoverView_shapeAppearance,
|
styledAttrs.getResourceId(
|
||||||
MR.style.ShapeAppearance_Material3_Corner_Medium
|
R.styleable.CoverView_shapeAppearance,
|
||||||
)
|
MR.style.ShapeAppearance_Material3_Corner_Medium,
|
||||||
|
)
|
||||||
squareishShapeAppearance =
|
squareishShapeAppearance =
|
||||||
if (uiSettings.roundMode) {
|
if (uiSettings.roundMode) {
|
||||||
ShapeAppearanceModel.builder(
|
ShapeAppearanceModel.builder(context, shapeAppearanceRes, -1).build()
|
||||||
context,
|
|
||||||
shapeAppearanceRes,
|
|
||||||
-1,
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
} else {
|
} else {
|
||||||
ShapeAppearanceModel.builder().build()
|
ShapeAppearanceModel.builder().build()
|
||||||
}
|
}
|
||||||
@@ -311,7 +307,6 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun invalidateRootAlpha() {
|
private fun invalidateRootAlpha() {
|
||||||
alpha = if (isEnabled || isSelected) 1f else 0.5f
|
alpha = if (isEnabled || isSelected) 1f else 0.5f
|
||||||
}
|
}
|
||||||
@@ -355,7 +350,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
{ song.cover },
|
{ song.cover },
|
||||||
context.getString(R.string.desc_album_cover, song.album.name),
|
context.getString(R.string.desc_album_cover, song.album.name),
|
||||||
R.drawable.ic_album_24,
|
R.drawable.ic_album_24,
|
||||||
squareishShapeAppearance
|
squareishShapeAppearance,
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -378,7 +373,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
},
|
},
|
||||||
context.getString(R.string.desc_album_cover, album.name),
|
context.getString(R.string.desc_album_cover, album.name),
|
||||||
R.drawable.ic_album_24,
|
R.drawable.ic_album_24,
|
||||||
squareishShapeAppearance
|
squareishShapeAppearance,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +400,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
},
|
},
|
||||||
context.getString(R.string.desc_artist_image, artist.name),
|
context.getString(R.string.desc_artist_image, artist.name),
|
||||||
R.drawable.ic_artist_24,
|
R.drawable.ic_artist_24,
|
||||||
circularShapeAppearance
|
circularShapeAppearance,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,7 +423,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
},
|
},
|
||||||
context.getString(R.string.desc_genre_image, genre.name),
|
context.getString(R.string.desc_genre_image, genre.name),
|
||||||
R.drawable.ic_genre_24,
|
R.drawable.ic_genre_24,
|
||||||
squareishShapeAppearance
|
squareishShapeAppearance,
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -450,7 +445,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
},
|
},
|
||||||
context.getString(R.string.desc_playlist_image, playlist.name),
|
context.getString(R.string.desc_playlist_image, playlist.name),
|
||||||
R.drawable.ic_playlist_24,
|
R.drawable.ic_playlist_24,
|
||||||
squareishShapeAppearance
|
squareishShapeAppearance,
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -478,14 +473,14 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
},
|
},
|
||||||
desc,
|
desc,
|
||||||
errorRes,
|
errorRes,
|
||||||
squareishShapeAppearance
|
squareishShapeAppearance,
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun bindImpl(
|
private fun bindImpl(
|
||||||
img: (RectF) -> Any?,
|
img: (RectF) -> Any?,
|
||||||
desc: String,
|
desc: String,
|
||||||
@DrawableRes errorRes: Int,
|
@DrawableRes errorRes: Int,
|
||||||
shapeAppearanceModel: ShapeAppearanceModel
|
shapeAppearanceModel: ShapeAppearanceModel,
|
||||||
) {
|
) {
|
||||||
// prep proper shape to use if necessary. be safe and do it now
|
// prep proper shape to use if necessary. be safe and do it now
|
||||||
// idk if doing it at layout time will cause issues
|
// idk if doing it at layout time will cause issues
|
||||||
@@ -497,7 +492,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
img: (RectF) -> Any?,
|
img: (RectF) -> Any?,
|
||||||
desc: String,
|
desc: String,
|
||||||
@DrawableRes errorRes: Int,
|
@DrawableRes errorRes: Int,
|
||||||
shapeAppearanceModel: ShapeAppearanceModel
|
shapeAppearanceModel: ShapeAppearanceModel,
|
||||||
) {
|
) {
|
||||||
// for some reason randomly corner radii started breaking on menus
|
// for some reason randomly corner radii started breaking on menus
|
||||||
// fix this by waiting until we are laid out instead
|
// fix this by waiting until we are laid out instead
|
||||||
@@ -505,9 +500,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
if (cornerBounds != null) {
|
if (cornerBounds != null) {
|
||||||
bindWithCorners(img, desc, errorRes, cornerBounds, shapeAppearanceModel)
|
bindWithCorners(img, desc, errorRes, cornerBounds, shapeAppearanceModel)
|
||||||
} else {
|
} else {
|
||||||
doOnLayout {
|
doOnLayout { bindImpl(img, desc, errorRes, shapeAppearanceModel) }
|
||||||
bindImpl(img, desc, errorRes, shapeAppearanceModel)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,14 +509,13 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
desc: String,
|
desc: String,
|
||||||
@DrawableRes errorRes: Int,
|
@DrawableRes errorRes: Int,
|
||||||
cornerBounds: RectF,
|
cornerBounds: RectF,
|
||||||
shapeAppearanceModel: ShapeAppearanceModel
|
shapeAppearanceModel: ShapeAppearanceModel,
|
||||||
) {
|
) {
|
||||||
val request =
|
val request =
|
||||||
ImageRequest.Builder(context)
|
ImageRequest.Builder(context)
|
||||||
.data(img(cornerBounds))
|
.data(img(cornerBounds))
|
||||||
.error(
|
.error(
|
||||||
StyledDrawable(context, context.getDrawableCompat(errorRes), iconSize)
|
StyledDrawable(context, context.getDrawableCompat(errorRes), iconSize).asImage()
|
||||||
.asImage()
|
|
||||||
)
|
)
|
||||||
.target(image)
|
.target(image)
|
||||||
|
|
||||||
@@ -574,8 +566,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
return random.nextFloat() * 20f - 10f // -10 to +10 degrees
|
return random.nextFloat() * 20f - 10f // -10 to +10 degrees
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun backgroundColor(): Int =
|
private fun backgroundColor(): Int = context.getColorCompat(R.color.sel_cover_bg).defaultColor
|
||||||
context.getColorCompat(R.color.sel_cover_bg).defaultColor
|
|
||||||
|
|
||||||
private fun resolveCurrentBoundsForCorners(): RectF? {
|
private fun resolveCurrentBoundsForCorners(): RectF? {
|
||||||
val widthPx = firstNonZeroOrNull(width, measuredWidth, layoutParams?.width)
|
val widthPx = firstNonZeroOrNull(width, measuredWidth, layoutParams?.width)
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package org.oxycblt.auxio.search
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.MenuItem
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
@@ -120,10 +119,7 @@ class SearchFragment : ListFragment<Music, FragmentSearchBinding>() {
|
|||||||
// --- UI SETUP ---
|
// --- UI SETUP ---
|
||||||
|
|
||||||
binding.searchAppbar.addOnOffsetChangedListener(
|
binding.searchAppbar.addOnOffsetChangedListener(
|
||||||
FadingToolbarOffsetListener(
|
FadingToolbarOffsetListener(binding.searchToolbar, binding.searchContent)
|
||||||
binding.searchToolbar,
|
|
||||||
binding.searchContent
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.searchNormalToolbar.apply {
|
binding.searchNormalToolbar.apply {
|
||||||
@@ -159,16 +155,17 @@ class SearchFragment : ListFragment<Music, FragmentSearchBinding>() {
|
|||||||
binding.searchFilterPlaylists.isChecked = MusicType.PLAYLISTS in filters
|
binding.searchFilterPlaylists.isChecked = MusicType.PLAYLISTS in filters
|
||||||
binding.searchFilters.apply {
|
binding.searchFilters.apply {
|
||||||
setOnCheckedStateChangeListener { group, ids ->
|
setOnCheckedStateChangeListener { group, ids ->
|
||||||
val types = ids.mapNotNullTo(mutableSetOf()) {
|
val types =
|
||||||
when (it) {
|
ids.mapNotNullTo(mutableSetOf()) {
|
||||||
R.id.search_filter_songs -> MusicType.SONGS
|
when (it) {
|
||||||
R.id.search_filter_albums -> MusicType.ALBUMS
|
R.id.search_filter_songs -> MusicType.SONGS
|
||||||
R.id.search_filter_artists -> MusicType.ARTISTS
|
R.id.search_filter_albums -> MusicType.ALBUMS
|
||||||
R.id.search_filter_genres -> MusicType.GENRES
|
R.id.search_filter_artists -> MusicType.ARTISTS
|
||||||
R.id.search_filter_playlists -> MusicType.PLAYLISTS
|
R.id.search_filter_genres -> MusicType.GENRES
|
||||||
else -> null
|
R.id.search_filter_playlists -> MusicType.PLAYLISTS
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
searchModel.filters = types
|
searchModel.filters = types
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,17 +40,15 @@ class SearchSettingsImpl @Inject constructor(@ApplicationContext context: Contex
|
|||||||
Settings.Impl<Nothing>(context), SearchSettings {
|
Settings.Impl<Nothing>(context), SearchSettings {
|
||||||
override var filters: Set<MusicType>
|
override var filters: Set<MusicType>
|
||||||
get() =
|
get() =
|
||||||
sharedPreferences.getStringSet(
|
sharedPreferences
|
||||||
getString(R.string.set_key_search_filters),
|
.getStringSet(getString(R.string.set_key_search_filters), null)
|
||||||
null
|
?.mapNotNull { it.toIntOrNull()?.let(MusicType::fromIntCode) }
|
||||||
)?.mapNotNull {
|
?.toSet() ?: setOf()
|
||||||
it.toIntOrNull()?.let(MusicType::fromIntCode)
|
|
||||||
}?.toSet() ?: setOf()
|
|
||||||
set(value) {
|
set(value) {
|
||||||
sharedPreferences.edit {
|
sharedPreferences.edit {
|
||||||
putStringSet(
|
putStringSet(
|
||||||
getString(R.string.set_key_search_filters),
|
getString(R.string.set_key_search_filters),
|
||||||
value.map { it.intCode.toString() }.toSet()
|
value.map { it.intCode.toString() }.toSet(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
package org.oxycblt.auxio.search
|
package org.oxycblt.auxio.search
|
||||||
|
|
||||||
import androidx.annotation.IdRes
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
|
import javax.inject.Inject
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
@@ -33,13 +33,11 @@ import org.oxycblt.auxio.list.Item
|
|||||||
import org.oxycblt.auxio.list.PlainDivider
|
import org.oxycblt.auxio.list.PlainDivider
|
||||||
import org.oxycblt.auxio.list.sort.Sort
|
import org.oxycblt.auxio.list.sort.Sort
|
||||||
import org.oxycblt.auxio.music.MusicRepository
|
import org.oxycblt.auxio.music.MusicRepository
|
||||||
import org.oxycblt.auxio.music.MusicSettings
|
|
||||||
import org.oxycblt.auxio.music.MusicType
|
import org.oxycblt.auxio.music.MusicType
|
||||||
import org.oxycblt.auxio.playback.PlaySong
|
import org.oxycblt.auxio.playback.PlaySong
|
||||||
import org.oxycblt.auxio.playback.PlaybackSettings
|
import org.oxycblt.auxio.playback.PlaybackSettings
|
||||||
import org.oxycblt.musikr.Library
|
import org.oxycblt.musikr.Library
|
||||||
import org.oxycblt.musikr.Song
|
import org.oxycblt.musikr.Song
|
||||||
import javax.inject.Inject
|
|
||||||
import timber.log.Timber as L
|
import timber.log.Timber as L
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,23 +111,24 @@ constructor(
|
|||||||
private suspend fun searchImpl(library: Library, query: String): List<Item> {
|
private suspend fun searchImpl(library: Library, query: String): List<Item> {
|
||||||
val filters = searchSettings.filters
|
val filters = searchSettings.filters
|
||||||
|
|
||||||
val items = if (!filters.isEmpty()) {
|
val items =
|
||||||
SearchEngine.Items(
|
if (!filters.isEmpty()) {
|
||||||
songs = if (MusicType.SONGS in filters) library.songs else null,
|
SearchEngine.Items(
|
||||||
albums = if (MusicType.ALBUMS in filters) library.albums else null,
|
songs = if (MusicType.SONGS in filters) library.songs else null,
|
||||||
artists = if (MusicType.ARTISTS in filters) library.artists else null,
|
albums = if (MusicType.ALBUMS in filters) library.albums else null,
|
||||||
genres = if (MusicType.GENRES in filters) library.genres else null,
|
artists = if (MusicType.ARTISTS in filters) library.artists else null,
|
||||||
playlists = if (MusicType.PLAYLISTS in filters) library.playlists else null,
|
genres = if (MusicType.GENRES in filters) library.genres else null,
|
||||||
)
|
playlists = if (MusicType.PLAYLISTS in filters) library.playlists else null,
|
||||||
} else {
|
)
|
||||||
SearchEngine.Items(
|
} else {
|
||||||
songs = library.songs,
|
SearchEngine.Items(
|
||||||
albums = library.albums,
|
songs = library.songs,
|
||||||
artists = library.artists,
|
albums = library.albums,
|
||||||
genres = library.genres,
|
artists = library.artists,
|
||||||
playlists = library.playlists
|
genres = library.genres,
|
||||||
)
|
playlists = library.playlists,
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val results = searchEngine.search(items, query)
|
val results = searchEngine.search(items, query)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2026 Auxio Project
|
||||||
|
* FadingToolbarOffsetListener.kt is part of Auxio.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package org.oxycblt.auxio.ui
|
package org.oxycblt.auxio.ui
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -5,10 +23,8 @@ import androidx.core.view.updatePadding
|
|||||||
import com.google.android.material.appbar.AppBarLayout
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
class FadingToolbarOffsetListener(
|
class FadingToolbarOffsetListener(private val toolbar: View, private val content: View) :
|
||||||
private val toolbar: View,
|
AppBarLayout.OnOffsetChangedListener {
|
||||||
private val content: View
|
|
||||||
) : AppBarLayout.OnOffsetChangedListener {
|
|
||||||
override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) {
|
override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) {
|
||||||
val range = appBarLayout.totalScrollRange
|
val range = appBarLayout.totalScrollRange
|
||||||
// Fade out the toolbar as the AppBarLayout collapses. To prevent status bar overlap,
|
// Fade out the toolbar as the AppBarLayout collapses. To prevent status bar overlap,
|
||||||
@@ -17,4 +33,4 @@ class FadingToolbarOffsetListener(
|
|||||||
toolbar.alpha = 1f - (abs(verticalOffset.toFloat()) / (range.toFloat() / 2))
|
toolbar.alpha = 1f - (abs(verticalOffset.toFloat()) / (range.toFloat() / 2))
|
||||||
content.updatePadding(bottom = range + verticalOffset)
|
content.updatePadding(bottom = range + verticalOffset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user