Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta Release 2.7.3 #499

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ android {
applicationId = "org.listenbrainz.android"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = 54
versionName = "2.7.2"
versionCode = 55
versionName = "2.7.3"
multiDexEnabled = true
testInstrumentationRunner = "org.listenbrainz.android.di.CustomTestRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import androidx.compose.material3.FloatingActionButtonDefaults
import androidx.compose.material3.LargeFloatingActionButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
Expand Down Expand Up @@ -98,7 +99,6 @@ import org.listenbrainz.android.viewmodel.PlaylistViewModel
import kotlin.math.absoluteValue
import kotlin.math.max

@OptIn(ExperimentalFoundationApi::class)
@ExperimentalMaterialApi
@Composable
fun BrainzPlayerBackDropScreen(
Expand Down Expand Up @@ -136,8 +136,11 @@ fun BrainzPlayerBackDropScreen(
appBar = {},
persistentAppBar = false,
frontLayerContent = {
val delta by backdropScaffoldState.offset
maxDelta = max(delta, maxDelta)
LaunchedEffect(Unit) {
val delta = backdropScaffoldState.requireOffset()
maxDelta = max(delta, maxDelta)
}

PlayerScreen(
currentlyPlayingSong = currentlyPlayingSong,
isShuffled = isShuffled,
Expand All @@ -146,7 +149,7 @@ fun BrainzPlayerBackDropScreen(
val songList = brainzPlayerViewModel.mediaItem.collectAsState().value.data ?: listOf()
SongViewPager(
modifier = Modifier.graphicsLayer {
alpha = ( delta / (maxDelta - headerHeight.toPx()) )
alpha = ( backdropScaffoldState.requireOffset() / (maxDelta - headerHeight.toPx()) )
},
songList = songList,
backdropScaffoldState = backdropScaffoldState,
Expand Down Expand Up @@ -511,7 +514,7 @@ fun AlbumArtViewPager(currentlyPlayingSong: Song, pagerState: PagerState) {
// Calculate the absolute offset for the current page from the
// scroll position. We use the absolute value which allows us to mirror
// any effects for both directions
val pageOffset = pagerState.getOffsetFractionForPage(page).absoluteValue
val pageOffset = pagerState.getOffsetDistanceInPages(page).absoluteValue

// We animate the scaleX + scaleY, between 85% and 100%
lerp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fun FeedScreen(
}


@OptIn(ExperimentalMaterialApi::class, ExperimentalFoundationApi::class)
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun FeedScreen(
uiState: FeedUiState,
Expand Down Expand Up @@ -221,7 +221,7 @@ fun FeedScreen(

HorizontalPager(
state = pagerState,
beyondBoundsPageCount = 1
beyondViewportPageCount = 1
) { position ->
when (position) {
0 -> MyFeed(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.listenbrainz.android.ui.screens.feed

import androidx.compose.runtime.Stable
import androidx.paging.PagingData
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
import org.listenbrainz.android.model.ResponseError
import org.listenbrainz.android.model.feed.FeedEvent
import org.listenbrainz.android.model.feed.FeedEventType


/** Top most state wrapper for Feed Screen.*/
@Stable
data class FeedUiState(
val myFeedState: FeedUiEventData = FeedUiEventData(),
val followListensFeedState: FeedUiEventData = FeedUiEventData(),
Expand All @@ -18,13 +19,15 @@ data class FeedUiState(
)

/** Data held by each screen.*/
@Stable
data class FeedUiEventData(
val isHiddenMap: Map<Int, Boolean> = emptyMap(),
val isDeletedMap: Map<Int, Boolean> = emptyMap(),
var eventList: Flow<PagingData<FeedUiEventItem>> = emptyFlow()
val eventList: Flow<PagingData<FeedUiEventItem>> = emptyFlow()
)

/** UI representation for one feed event.*/
@Stable
data class FeedUiEventItem(
val eventType: FeedEventType,
val event: FeedEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import org.listenbrainz.android.ui.theme.ListenBrainzTheme
import org.listenbrainz.android.ui.theme.offWhite
import org.listenbrainz.android.ui.theme.onScreenUiModeIsDark

@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
@Composable
fun UserData(
preferencesUiState: PreferencesUiState,
Expand Down Expand Up @@ -141,9 +140,9 @@ fun UserData(
color = if (onScreenUiModeIsDark()) Color.White else Color.Black
)
},
colors = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = if (onScreenUiModeIsDark()) Color.White else Color.Black,
unfocusedBorderColor = if (onScreenUiModeIsDark()) Color.White else Color.Black,
colors = TextFieldDefaults.colors(
focusedIndicatorColor = if (onScreenUiModeIsDark()) Color.White else Color.Black,
unfocusedIndicatorColor = if (onScreenUiModeIsDark()) Color.White else Color.Black,
cursorColor = if (onScreenUiModeIsDark()) Color.White else Color.Black
)
)
Expand Down
13 changes: 9 additions & 4 deletions app/src/main/java/org/listenbrainz/android/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,15 @@ private lateinit var LocalUiMode: ProvidableCompositionLocal<UiMode>
* what theme the device is using. Different from [isSystemInDarkTheme].*/
@Composable
fun onScreenUiModeIsDark() : Boolean {
return when (LocalUiMode.current){
UiMode.DARK -> true
UiMode.LIGHT -> false
else -> isSystemInDarkTheme()
val uiMode = LocalUiMode.current
val isSystemInDarkTheme = isSystemInDarkTheme()

return remember(uiMode, isSystemInDarkTheme) {
when (uiMode){
UiMode.DARK -> true
UiMode.LIGHT -> false
else -> isSystemInDarkTheme
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand Down Expand Up @@ -101,28 +102,6 @@ class FeedViewModel @Inject constructor(
// Exposed UI state
override val uiState = createUiStateFlow()

init {
viewModelScope.launch(defaultDispatcher) {
searchFollowerQuery.collectLatest { query ->
if (query.isEmpty()) return@collectLatest

val result = socialRepository.getFollowers(appPreferences.username.get())
if (result.status == Resource.Status.SUCCESS){
searchFollowerResult.emit(
result.data?.followers?.filter {
it.startsWith(query, ignoreCase = true) || it.contains(query, ignoreCase = true)
} ?: emptyList()
)
println(searchFollowerResult.value)
} else {
emitError(error = result.error)
}

}
}

}

override fun createUiStateFlow(): StateFlow<FeedUiState> {
return combine(
myFeedFlow,
Expand All @@ -132,11 +111,15 @@ class FeedViewModel @Inject constructor(
errorFlow
){ feedScreenState, followListensState, similarListensState, searchResult, error ->
FeedUiState(feedScreenState, followListensState, similarListensState, searchResult, error)
}.stateIn(
viewModelScope,
SharingStarted.Eagerly,
FeedUiState()
)
}
.onStart {
observeSearchFollowerQuery()
}
.stateIn(
viewModelScope,
SharingStarted.Eagerly,
FeedUiState()
)
}

private fun createNewMyFeedPagingSource(): MyFeedPagingSource =
Expand Down Expand Up @@ -320,5 +303,23 @@ class FeedViewModel @Inject constructor(
e.printStackTrace()
}
}


private fun observeSearchFollowerQuery() {
viewModelScope.launch(defaultDispatcher) {
searchFollowerQuery.collectLatest { query ->
if (query.isEmpty()) return@collectLatest

val result = socialRepository.getFollowers(appPreferences.username.get())
if (result.status == Resource.Status.SUCCESS){
searchFollowerResult.emit(
result.data?.followers?.filter {
it.startsWith(query, ignoreCase = true) || it.contains(query, ignoreCase = true)
} ?: emptyList()
)
} else {
emitError(error = result.error)
}
}
}
}
}
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/55.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bug fixes and improvements
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kotlin = "2.0.0"
navigation = "2.7.7"
hilt = "2.52"
compose = "1.6.8"
compose = "1.7.5"
room = "2.6.1"
accompanist = "0.34.0"
work = "2.9.1"
Expand All @@ -11,9 +11,9 @@ paging = "3.3.2"
androidGradlePlugin = "8.5.2"
sentry = "4.10.0"
ksp = "2.0.0-1.0.23"
composeBom = "2024.08.00"
composeBom = "2024.11.00"
appcompat = "1.7.0"
lifecycle = "2.8.4"
lifecycle = "2.8.7"
browser = "1.8.0"
preference = "1.2.1"
coreSplashscreen = "1.0.1"
Expand Down