Skip to content

Commit

Permalink
Merge pull request #112 from HLCaptain/111-upgrade-to-kotlin-19-try-o…
Browse files Browse the repository at this point in the history
…ut-k2-compiler-refactor-upgrade-dependencies

Bumped version number. Refactors, added labels on animations, upgrade…
  • Loading branch information
HLCaptain authored Jul 7, 2023
2 parents dc200c7 + c9482b9 commit ea75840
Show file tree
Hide file tree
Showing 26 changed files with 96 additions and 62 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ android {
applicationId = "illyan.jay"
minSdk = 21
targetSdk = 34
versionCode = 15
versionName = "0.3.4-alpha"
versionCode = 16
versionName = "0.3.5-alpha"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -241,4 +241,4 @@ kapt {

hilt {
enableAggregatingTask = true
}
}
2 changes: 0 additions & 2 deletions app/src/main/java/illyan/jay/data/firestore/Mapping.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ fun DomainPreferences.toFirestoreModel() = FirestoreUserPreferences(
lastUpdateToAnalytics = lastUpdateToAnalytics?.toTimestamp(),
)

@OptIn(ExperimentalSerializationApi::class)
fun List<DomainLocation>.toPath(
sessionUUID: String,
ownerUUID: String
Expand Down Expand Up @@ -143,7 +142,6 @@ fun List<DomainLocation>.toPath(
return path
}

@OptIn(ExperimentalSerializationApi::class)
private fun testCompressions(domainLocations: List<DomainLocation>) {
// Size comparison between raw location data path and compressed data structures.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ class SensorDataSource @Inject constructor(
fun removeLocationUpdates(callback: LocationCallback) =
fusedLocationProviderClient.removeLocationUpdates(callback)

fun getSensors(type: Int = Sensor.TYPE_ALL) = sensorManager.getSensorList(type)
fun getSensors(type: Int = Sensor.TYPE_ALL): List<Sensor> = sensorManager.getSensorList(type)
}
3 changes: 2 additions & 1 deletion app/src/main/java/illyan/jay/ui/about/About.kt
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ fun AboutAdScreen(
targetValue = if (isAdLoaded) 1f else 0f,
animationSpec = spring(
stiffness = Spring.StiffnessLow
)
),
label = "Ad Fade In"
)
AndroidView(
modifier = Modifier
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/illyan/jay/ui/about/AboutViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import javax.inject.Inject
@HiltViewModel
class AboutViewModel @Inject constructor(
private val settingsInteractor: SettingsInteractor,
private val remoteConfig: FirebaseRemoteConfig,
remoteConfig: FirebaseRemoteConfig,
) : ViewModel() {

val showAds = settingsInteractor.userPreferences.map {
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/illyan/jay/ui/freedrive/FreeDrive.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import illyan.jay.ui.theme.JayTheme
import illyan.jay.ui.theme.statefulColorScheme
import illyan.jay.util.plus

private const val paddingRatio = 0.25f
private const val PaddingRatio = 0.25f

val DefaultScreenOnSheetPadding = PaddingValues(
start = MenuItemPadding * 2,
Expand All @@ -82,7 +82,7 @@ fun calculatePaddingOffset(): PaddingValues {
val layoutHeight = absoluteBottom.value - absoluteTop.value
val freeSpace = layoutHeight - cameraPadding.value.calculateBottomPadding()
return PaddingValues(
bottom = freeSpace * paddingRatio
bottom = freeSpace * PaddingRatio
)
}

Expand Down Expand Up @@ -174,7 +174,8 @@ fun FreeDriveScreenWithPermission(
) {
Crossfade(
modifier = Modifier.animateContentSize(),
targetState = isServiceRunning
targetState = isServiceRunning,
label = "Free drive button"
) {
Text(
modifier = Modifier.animateContentSize(),
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/illyan/jay/ui/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,8 @@ private fun SheetNavHost(
animationSpec = SpringSpec(
dampingRatio = Spring.DampingRatioNoBouncy,
stiffness = Spring.StiffnessMedium
)
),
label = "Sheet fade in/out"
)
val density = LocalDensity.current.density
DestinationsNavHost(
Expand Down Expand Up @@ -1072,14 +1073,16 @@ private fun SearchNavHost(
animationSpec = SpringSpec(
dampingRatio = Spring.DampingRatioNoBouncy,
stiffness = Spring.StiffnessVeryLow
)
),
label = "Search screen fade in/out"
)
val searchFraction by animateFloatAsState(
targetValue = if (isSearching) {
fullScreenFraction
} else {
0f
}
},
label = "Search screen expand/collapse"
)
DestinationsNavHost(
navGraph = NavGraphs.search,
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/illyan/jay/ui/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ import javax.inject.Inject
@HiltViewModel
class HomeViewModel @Inject constructor(
private val mapboxInteractor: MapboxInteractor,
private val authInteractor: AuthInteractor,
private val sessionInteractor: SessionInteractor,
private val performance: FirebasePerformance,
authInteractor: AuthInteractor,
performance: FirebasePerformance,
@CoroutineDispatcherIO private val dispatcherIO: CoroutineDispatcher,
) : ViewModel() {

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/illyan/jay/ui/libraries/Libraries.kt
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ fun LibraryItem(
color = AlertDialogDefaults.titleContentColor,
)
Crossfade(
targetState = library.repositoryUrl to library.moreInfoUrl
targetState = library.repositoryUrl to library.moreInfoUrl,
label = "Library URLs"
) { repositoryAndMoreInfoUrls ->
val shownText = repositoryAndMoreInfoUrls.run {
// Show Repo URL, then More Info URL, then null
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/illyan/jay/ui/library/Library.kt
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ fun LibraryScreen(
}
Crossfade(
modifier = Modifier.animateContentSize(),
targetState = library.license?.url
targetState = library.license?.url,
label = "License"
) {
if (it != null) {
MenuButton(
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/illyan/jay/ui/login/Login.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ fun LoginDialogContent(
) {
Crossfade(
modifier = modifier,
targetState = isUserSigningIn
targetState = isUserSigningIn,
label = "Login Dialog Content"
) {
if (it) {
JayDialogContent(
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/illyan/jay/ui/menu/Menu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ fun MenuItemCard(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Crossfade(targetState = icon) {
Crossfade(
targetState = icon,
label = "Menu item icon",
) {
if (it != null) {
Icon(
modifier = Modifier.padding(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/illyan/jay/ui/poi/model/Place.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ data class Place(
val latitude: Double
) : Parcelable

fun Place.toPoint() = Point.fromLngLat(longitude, latitude)
fun Place.toPoint(): Point = Point.fromLngLat(longitude, latitude)
5 changes: 4 additions & 1 deletion app/src/main/java/illyan/jay/ui/profile/Profile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,10 @@ fun UserInfo(
text = infoName,
style = nameStyle
)
Crossfade(targetState = show) {
Crossfade(
targetState = show,
label = "User info"
) {
Text(
text = if (it) info else stringResource(R.string.hidden_field_string),
style = style
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/java/illyan/jay/ui/search/Search.kt
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ fun LazyListScope.suggestionItems(
list = items,
emptyListPlaceholder = {
AnimatedVisibility(visible = isLoadingSuggestions || items.isNotEmpty()) {
Crossfade(targetState = isLoadingSuggestions) {
Crossfade(
targetState = isLoadingSuggestions,
label = "Suggestion initial loading animation",
) {
if (it) {
SearchCard(
shape = RoundedCornerShape(SearchItemsCornerRadius),
Expand Down Expand Up @@ -387,7 +390,10 @@ fun FavoriteButton(
modifier = modifier.padding(horizontal = 4.dp),
onClick = onToggleFavorite
) {
Crossfade(targetState = isFavorite) {
Crossfade(
targetState = isFavorite,
label = "Favorite button animation",
) {
Icon(
modifier = Modifier.size(32.dp),
imageVector = if (it) {
Expand Down
17 changes: 10 additions & 7 deletions app/src/main/java/illyan/jay/ui/session/Session.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
Expand Down Expand Up @@ -224,8 +225,8 @@ fun SessionScreen(
viewModel.load(sessionUUID)
}
val gradientFilter by viewModel.gradientFilter.collectAsStateWithLifecycle()
var previousOffset by rememberSaveable { mutableStateOf<Float?>(null) }
var currentOffset by rememberSaveable { mutableStateOf(sheetState.requireOffset()) }
var previousOffset by rememberSaveable { mutableFloatStateOf(0f) }
var currentOffset by rememberSaveable { mutableFloatStateOf(sheetState.requireOffset()) }
var noMoreOffsetChanges by rememberSaveable { mutableStateOf(false) }
LaunchedEffect(sheetState.requireOffset()) {
previousOffset = currentOffset
Expand All @@ -236,7 +237,7 @@ fun SessionScreen(
val sheetHeightNotSet by remember {
derivedStateOf {
val isAnimationRunning = sheetState.progress != 1f
val almostReachedTargetHeight = abs(currentOffset - (previousOffset ?: 0f)) < 2f
val almostReachedTargetHeight = abs(currentOffset - previousOffset) < 2f
isAnimationRunning || !almostReachedTargetHeight || !noMoreOffsetChanges
}
}
Expand Down Expand Up @@ -384,7 +385,8 @@ fun SessionDetailsScreen(
) {
Crossfade(
modifier = Modifier.animateContentSize(),
targetState = session?.startLocationName
targetState = session?.startLocationName,
label = "Start location appear animation",
) {
Text(
text = it ?: stringResource(R.string.unknown),
Expand All @@ -398,7 +400,8 @@ fun SessionDetailsScreen(
)
Crossfade(
modifier = Modifier.animateContentSize(),
targetState = (session?.endDateTime == null) to session?.endLocationName
targetState = (session?.endDateTime == null) to session?.endLocationName,
label = "End location appear animation",
) {
if (it.first) {
Icon(
Expand Down Expand Up @@ -503,7 +506,7 @@ fun SessionDetailsScreen(
divider = {},
selectedTabIndex = selectedTabIndex,
indicator = {
TabRowDefaults.Indicator(
TabRowDefaults.SecondaryIndicator(
Modifier
.tabIndicatorOffset(it[selectedTabIndex])
.padding(horizontal = MenuItemPadding)
Expand Down Expand Up @@ -579,4 +582,4 @@ private fun SessionDetailsScreenPreview(
}
}

fun LatLng.toMapboxPoint() = Point.fromLngLat(longitude, latitude)
fun LatLng.toMapboxPoint(): Point = Point.fromLngLat(longitude, latitude)
6 changes: 4 additions & 2 deletions app/src/main/java/illyan/jay/ui/sessions/Sessions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,8 @@ fun SessionCard(
) {
Crossfade(
modifier = Modifier.animateContentSize(),
targetState = session?.startLocationName
targetState = session?.startLocationName,
label = "Start location name",
) {
Text(
text = it ?: stringResource(R.string.unknown),
Expand All @@ -691,7 +692,8 @@ fun SessionCard(
)
Crossfade(
modifier = Modifier.animateContentSize(),
targetState = (session?.endDateTime == null) to session?.endLocationName
targetState = (session?.endDateTime == null) to session?.endLocationName,
label = "End location name",
) {
if (it.first) {
Icon(
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/illyan/jay/ui/sessions/SessionsViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ import kotlin.coroutines.cancellation.CancellationException
class SessionsViewModel @Inject constructor(
private val sessionInteractor: SessionInteractor,
private val locationInteractor: LocationInteractor,
private val authInteractor: AuthInteractor,
private val appSettingsDataSource: AppSettingsDataSource,
authInteractor: AuthInteractor,
appSettingsDataSource: AppSettingsDataSource,
@CoroutineDispatcherIO private val dispatcherIO: CoroutineDispatcher
) : ViewModel() {
private val sessionStateFlows = mutableMapOf<String, MutableStateFlow<UiSession?>>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ fun DataSettingsButtons(
verticalAlignment = Alignment.Bottom
) {
val byteString = stringResource(R.string.bytes)
Crossfade(targetState = cachedDataSizeInBytes) {
Crossfade(
targetState = cachedDataSizeInBytes,
label = "Cached data size"
) {
when (it != null) {
true -> {
Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import javax.inject.Inject

@HiltViewModel
class DataSettingsViewModel @Inject constructor(
private val authInteractor: AuthInteractor,
private val userInteractor: UserInteractor,
authInteractor: AuthInteractor,
@CoroutineDispatcherIO private val dispatcherIO: CoroutineDispatcher
) : ViewModel() {

Expand Down
Loading

0 comments on commit ea75840

Please sign in to comment.