Skip to content

Commit

Permalink
Merge pull request #19 from icefields/dev
Browse files Browse the repository at this point in the history
fixed UX glitches found in 01-beta, new placeholders, license update
  • Loading branch information
icefields committed Jan 30, 2024
2 parents 200971d + 2a176a5 commit 281f8a1
Show file tree
Hide file tree
Showing 20 changed files with 889 additions and 109 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ android {
applicationId = "luci.sixsixsix.powerampache2"
minSdk = 28
targetSdk = 34
versionCode = 2
versionName = "0.1-beta"
versionCode = 3
versionName = "0.02-beta"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand All @@ -65,7 +65,7 @@ android {
buildConfigField("String", "API_KEY", "\"\"")
buildConfigField("String", "DOGMAZIC_PASSWORD", "\"\"")
buildConfigField("String", "DOGMAZIC_USER", "\"\"")
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 2,
"versionName": "0.1-beta",
"versionCode": 3,
"versionName": "0.02-beta",
"outputFile": "app-release.apk"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ class PlaylistsRepositoryImpl @Inject constructor(
}

for (song in songsToAdd) {
addSingleSongToPlaylist(playlistId = playlist.id, songId = song.mediaId)
try {
addSingleSongToPlaylist(playlistId = playlist.id, songId = song.mediaId)
}catch (e: Exception) {}
}

emit(Resource.Success(data = Any(), networkData = Any()))
Expand All @@ -322,7 +324,9 @@ class PlaylistsRepositoryImpl @Inject constructor(
).toPlaylist() // TODO no error check

for (song in songsToAdd) {
addSingleSongToPlaylist(playlistId = playlist.id, songId = song.mediaId)
try {
addSingleSongToPlaylist(playlistId = playlist.id, songId = song.mediaId)
}catch (e: Exception) {}
}

emit(Resource.Success(data = playlist, networkData = playlist))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package luci.sixsixsix.powerampache2.presentation.common

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.spring
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
Expand All @@ -12,7 +9,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.PlaylistAdd
import androidx.compose.material.icons.filled.Share
import androidx.compose.material3.DismissDirection
import androidx.compose.material3.DismissState
import androidx.compose.material3.DismissValue
Expand Down Expand Up @@ -56,13 +52,13 @@ fun <T> SwipeToDismissItem(
false
} else false
},
positionalThreshold = { 200.dp.toPx() }
positionalThreshold = { 250.dp.toPx() }
)

AnimatedVisibility(
visible = show && rightShow,
exit = fadeOut(spring())
) {
// AnimatedVisibility(
// visible = show,
// exit = fadeOut(spring())
// ) {
SwipeToDismiss(
state = dismissState,
modifier = Modifier,
Expand All @@ -71,9 +67,21 @@ fun <T> SwipeToDismissItem(
foregroundView()
}
)
//}
LaunchedEffect(show) {
if (!show) {
onRemove(currentItem)
show = true
}

}
LaunchedEffect(rightShow) {
if (!rightShow) {
onRightToLeftSwipe(currentItem)
rightShow = true
}
}
LaunchedEffect(show) { if (!show) { onRemove(currentItem) } }
LaunchedEffect(rightShow) { if (!rightShow) { onRightToLeftSwipe(currentItem) } }

} else {
foregroundView()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ class AuthViewModel @Inject constructor(
when (result) {
is Resource.Success -> {
result.data?.let { auth ->
state = state.copy(session = auth)
// clear credentials after login
state = state.copy(session = auth, username = "", authToken = "", password = "")
playlistManager.updateErrorMessage("")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun AlbumItem(album: Album, modifier: Modifier = Modifier) {
model = album.artUrl,
contentScale = ContentScale.Crop,
placeholder = painterResource(id = R.drawable.placeholder_album),
error = painterResource(id = R.drawable.ic_playlist),
error = painterResource(id = R.drawable.placeholder_album),
contentDescription = album.name,
)
// Box(modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fun ArtistItem(
.border(1.dp, MaterialTheme.colorScheme.tertiary, CircleShape),
model = artist.artUrl,
placeholder = painterResource(id = R.drawable.placeholder_album),
error = painterResource(id = R.drawable.ic_playlist),
error = painterResource(id = R.drawable.placeholder_album),
contentDescription = artist.name,
contentScale = ContentScale.Crop
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fun AlbumItemSquare(modifier: Modifier = Modifier, album: Album) {
model = album.artUrl,
contentScale = ContentScale.Crop,
placeholder = painterResource(id = R.drawable.placeholder_album),
error = painterResource(id = R.drawable.ic_playlist),
error = painterResource(id = R.drawable.placeholder_album),
contentDescription = album.name,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package luci.sixsixsix.powerampache2.presentation.screens.offline

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
Expand All @@ -14,7 +12,6 @@ import androidx.compose.material.icons.filled.Pause
import androidx.compose.material.icons.filled.PlayArrow
import androidx.compose.material.icons.filled.PlaylistAdd
import androidx.compose.material.icons.filled.PlaylistRemove
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
Expand All @@ -30,7 +27,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.nestedScroll
Expand All @@ -40,11 +36,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import luci.sixsixsix.powerampache2.R
import luci.sixsixsix.powerampache2.domain.models.FlaggedPlaylist
import luci.sixsixsix.powerampache2.domain.models.FrequentPlaylist
import luci.sixsixsix.powerampache2.domain.models.HighestPlaylist
import luci.sixsixsix.powerampache2.domain.models.Playlist
import luci.sixsixsix.powerampache2.domain.models.RecentPlaylist
import luci.sixsixsix.powerampache2.domain.models.Song
import luci.sixsixsix.powerampache2.presentation.common.CircleBackButton
import luci.sixsixsix.powerampache2.presentation.common.EmptyListView
import luci.sixsixsix.powerampache2.presentation.common.LoadingScreen
Expand All @@ -56,10 +48,10 @@ import luci.sixsixsix.powerampache2.presentation.destinations.ArtistDetailScreen
import luci.sixsixsix.powerampache2.presentation.dialogs.AddToPlaylistOrQueueDialog
import luci.sixsixsix.powerampache2.presentation.dialogs.AddToPlaylistOrQueueDialogOpen
import luci.sixsixsix.powerampache2.presentation.dialogs.AddToPlaylistOrQueueDialogViewModel
import luci.sixsixsix.powerampache2.presentation.dialogs.EraseConfirmDialog
import luci.sixsixsix.powerampache2.presentation.main.MainEvent
import luci.sixsixsix.powerampache2.presentation.main.MainViewModel
import luci.sixsixsix.powerampache2.presentation.navigation.Ampache2NavGraphs.navigator
import luci.sixsixsix.powerampache2.presentation.screens_detail.playlist_detail.PlaylistDetailState
import luci.sixsixsix.powerampache2.presentation.screens_detail.playlist_detail.PlaylistDetailEvent

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -178,6 +170,22 @@ fun OfflineSongsMainContent(
}
}

var showDeleteSongDialog by remember { mutableStateOf<Song?>(null) }
showDeleteSongDialog?.let { songToRemove ->
EraseConfirmDialog(
onDismissRequest = {
showDeleteSongDialog = null
},
onConfirmation = {
showDeleteSongDialog = null
// delete downloaded song, delete database entry
mainViewModel.onEvent(MainEvent.OnDownloadedSongDelete(songToRemove))
},
dialogTitle = "REMOVE SONG",
dialogText = "Delete \n${songToRemove.name} from downloaded songs?"
)
}

Box(modifier = modifier) {
if (state.isLoading && state.songs.isEmpty()) {
LoadingScreen()
Expand All @@ -194,9 +202,11 @@ fun OfflineSongsMainContent(
song = song,
songItemEventListener = { event ->
when(event) {
SongItemEvent.PLAY_NEXT -> {} // viewModel.onEvent(AlbumDetailEvent.OnAddSongToQueueNext(song))
SongItemEvent.SHARE_SONG -> {} // viewModel.onEvent(AlbumDetailEvent.OnShareSong(song))
SongItemEvent.DOWNLOAD_SONG -> {} // viewModel.onEvent(AlbumDetailEvent.OnDownloadSong(song))
SongItemEvent.PLAY_NEXT ->
mainViewModel.onEvent(MainEvent.OnAddSongToQueueNext(song))
SongItemEvent.SHARE_SONG ->
mainViewModel.onEvent(MainEvent.OnShareSong(song))
SongItemEvent.DOWNLOAD_SONG -> { } // DO NOTHING
SongItemEvent.GO_TO_ALBUM -> navigator.navigate(
AlbumDetailScreenDestination(albumId = song.album.id, album = null)
)
Expand All @@ -217,9 +227,8 @@ fun OfflineSongsMainContent(
mainViewModel.onEvent(MainEvent.Play(song))
},
enableSwipeToRemove = true,
onRemove = {
// delete downloaded song, delete database entry
mainViewModel.onEvent(MainEvent.OnDownloadedSongDelete(song))
onRemove = { songToRemove ->
showDeleteSongDialog = songToRemove
},
onRightToLeftSwipe = {
playlistsDialogOpen = AddToPlaylistOrQueueDialogOpen(true, listOf(song))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ fun PlaylistDetailScreen(
EraseConfirmDialog(
onDismissRequest = {
showDeleteSongDialog = null
// The song is dismissed automatically even when dismissing the dialog,
// refresh the song list automatically
viewModel.onEvent(PlaylistDetailEvent.OnRemoveSongDismiss)
},
onConfirmation = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fun MiniPlayerContent(
model = song.imageUrl,
contentScale = ContentScale.FillHeight,
placeholder = painterResource(id = R.drawable.placeholder_album),
error = painterResource(id = R.drawable.ic_playlist),
error = painterResource(id = R.drawable.placeholder_album),
contentDescription = song.title,
)
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/circle_drawable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<item>
<shape android:shape="oval">
<solid android:color="@color/colorAccent"/>
<solid android:color="@color/colorPrimary"/>
<corners android:radius="100dp" />
</shape>
</item>
Expand Down
Loading

0 comments on commit 281f8a1

Please sign in to comment.