Skip to content

Commit

Permalink
Merge pull request #38 from musicorum-app/dev
Browse files Browse the repository at this point in the history
Update to 2.0
  • Loading branch information
MysteryMS authored Jan 3, 2024
2 parents 44f596d + aac6936 commit 3c5def6
Show file tree
Hide file tree
Showing 31 changed files with 1,540 additions and 782 deletions.
9 changes: 5 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ android {
applicationId "io.musicorum.mobile"
minSdk 28
targetSdk 34
versionCode 69
versionName "1.24"
versionCode 70
versionName "2.0"
//compileSdkPreview = "UpsideDownCake"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -170,10 +170,11 @@ dependencies {

implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.8.0-rc01'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation 'androidx.core:core-splashscreen:1.0.0'
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation 'androidx.compose.material3:material3:1.2.0-alpha11'
implementation 'androidx.compose.material3:material3:1.2.0-beta01'
implementation 'com.google.accompanist:accompanist-placeholder-material:0.26.5-rc'
implementation 'io.coil-kt:coil-compose:2.4.0'
implementation 'androidx.datastore:datastore-preferences:1.0.0'
Expand Down
4 changes: 2 additions & 2 deletions app/src/debug/res/drawable/splash_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</item>
<item
android:drawable="@drawable/ic_launcher_foreground"
android:width="512dp"
android:height="512dp"
android:width="288dp"
android:height="288dp"
android:gravity="center" />
</layer-list>
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:testOnly="false"
android:theme="@style/Theme.Musicorum"
android:theme="@style/Theme.Musicorum.Starting"
tools:targetApi="31">

<meta-data
Expand Down Expand Up @@ -102,7 +102,6 @@
android:exported="true"
android:hardwareAccelerated="true"
android:label="@string/app_name"
android:theme="@style/Theme.Musicorum.SplashScreenTheme"
android:windowSoftInputMode="adjustResize">

<intent-filter>
Expand Down
369 changes: 175 additions & 194 deletions app/src/main/java/io/musicorum/mobile/MainActivity.kt

Large diffs are not rendered by default.

54 changes: 52 additions & 2 deletions app/src/main/java/io/musicorum/mobile/components/FriendActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@ package io.musicorum.mobile.components
import android.text.format.DateUtils
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Close
import androidx.compose.material.icons.rounded.PushPin
import androidx.compose.material3.Icon
import androidx.compose.material3.ListItem
import androidx.compose.material3.ListItemDefaults
import androidx.compose.material3.Text
Expand All @@ -17,6 +31,7 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
Expand Down Expand Up @@ -45,7 +60,9 @@ import kotlinx.serialization.json.Json
fun FriendActivity(
track: Track,
friendImageUrl: String?,
friendUsername: String?
friendUsername: String?,
isPinned: Boolean,
onUnpin: (() -> Unit)? = null,
) {
val analytics = LocalAnalytics.current!!
val nav = LocalNavigation.current
Expand Down Expand Up @@ -78,6 +95,19 @@ fun FriendActivity(
}
}
)
if (isPinned) {
ListItem(
colors = colors,
headlineContent = { Text("Unpin $friendUsername") },
leadingContent = {
Icon(Icons.Rounded.Close, null)
},
modifier = Modifier.clickable {
showSheet.value = false
onUnpin?.invoke()
}
)
}
}
}

Expand Down Expand Up @@ -122,6 +152,26 @@ fun FriendActivity(
nav?.navigate("user/$friendUsername")
}
)
if (isPinned) {
Box(
modifier = Modifier
.align(Alignment.TopEnd)
.offset(5.dp, (-10).dp)
.size(30.dp)
.clip(CircleShape)
.background(color = LighterGray, shape = CircleShape)
.border(3.dp, KindaBlack, CircleShape)
.padding(7.dp)
) {
Icon(
imageVector = Icons.Rounded.PushPin,
contentDescription = null,
modifier = Modifier
.rotate((30f))
.align(Alignment.Center)
)
}
}
}
Spacer(Modifier.height(10.dp))
Row {
Expand Down
49 changes: 16 additions & 33 deletions app/src/main/java/io/musicorum/mobile/components/TrackSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@ package io.musicorum.mobile.components

import android.app.SearchManager
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.provider.MediaStore
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.OpenInNew
import androidx.compose.material.icons.rounded.Album
import androidx.compose.material.icons.rounded.Favorite
import androidx.compose.material.icons.rounded.FavoriteBorder
import androidx.compose.material.icons.rounded.PlayArrow
import androidx.compose.material.icons.rounded.Share
import androidx.compose.material.icons.rounded.Star
import androidx.compose.material3.ExperimentalMaterial3Api
Expand All @@ -43,11 +40,9 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.core.graphics.drawable.toBitmap
import coil.compose.AsyncImage
import io.musicorum.mobile.LocalNavigation
import io.musicorum.mobile.coil.defaultImageRequestBuilder
Expand All @@ -68,7 +63,7 @@ import kotlinx.serialization.json.Json
fun TrackSheet(
track: Track,
show: MutableState<Boolean>,
additionalSheetItems: (@Composable () -> Unit)? = null
additionalSheetItems: (@Composable (ColumnScope.() -> Unit))? = null
) {
val coroutine = rememberCoroutineScope()
val trackLoved = rememberSaveable { mutableStateOf(track.loved) }
Expand All @@ -78,17 +73,19 @@ fun TrackSheet(
containerColor = LighterGray
)
val sheetState = rememberModalBottomSheetState()
val spotifyIntent = ctx.packageManager.getLaunchIntentForPackage("com.spotify.music")
?.setAction(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)
?.putExtra(SearchManager.QUERY, "${track.artist.name} ${track.name}")
val playIntent = Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH).apply {
putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "vnd.android.cursor.item/audio")
putExtra(MediaStore.EXTRA_MEDIA_TITLE, track.name)
putExtra(MediaStore.EXTRA_MEDIA_ARTIST, track.artist.name)
putExtra(SearchManager.QUERY, track.name)
}

ModalBottomSheet(
onDismissRequest = { show.value = false },
containerColor = LighterGray,
sheetState = sheetState,

) {

modifier = Modifier.safeDrawingPadding()
) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
Expand Down Expand Up @@ -184,30 +181,16 @@ fun TrackSheet(
leadingContent = { Icon(Icons.Rounded.Album, null) }
)

val spotify = try {
ctx.packageManager.getApplicationIcon("com.spotify.music")
.toBitmap()
.asImageBitmap()
} catch (_: PackageManager.NameNotFoundException) {
null
}

spotify?.let {
ListItem(
modifier = Modifier
.fillMaxWidth()
.clickable { ctx.startActivity(spotifyIntent) },
headlineContent = { Text(text = "Play on Spotify") },
.clickable { ctx.startActivity(playIntent) },
headlineContent = { Text(text = "Play") },
leadingContent = {
Image(
bitmap = it,
contentDescription = null,
modifier = Modifier.size(24.dp)
)
Icon(imageVector = Icons.Rounded.PlayArrow, contentDescription = null)
},
colors = listColors
)
}

ListItem(
modifier = Modifier
Expand All @@ -228,6 +211,6 @@ fun TrackSheet(
leadingContent = { Icon(Icons.Rounded.Share, null) },
colors = listColors
)
Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars))
//Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars))
}
}
2 changes: 2 additions & 0 deletions app/src/main/java/io/musicorum/mobile/datastore/UserData.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package io.musicorum.mobile.datastore

import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.core.stringSetPreferencesKey

object UserData {
const val DataStoreName = "userdata"
val SESSION_KEY = stringPreferencesKey("session_key")
val PINNED_USERS = stringSetPreferencesKey("pinned_users")
}
51 changes: 23 additions & 28 deletions app/src/main/java/io/musicorum/mobile/router/BottomNavbar.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.musicorum.mobile.router

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.QueueMusic
import androidx.compose.material.icons.rounded.BarChart
Expand All @@ -14,20 +12,19 @@ import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationBarItemDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.navigation.NavDestination.Companion.hierarchy
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.NavHostController
import androidx.navigation.compose.currentBackStackEntryAsState
import io.musicorum.mobile.LocalNavigation
import io.musicorum.mobile.ui.theme.LighterGray
import io.musicorum.mobile.ui.theme.MostlyRed
import java.util.Locale

@Composable
fun BottomNavBar(nav: NavHostController) {
fun BottomNavBar() {
val items = listOf("Home", "Discover", "Scrobbling", "Charts", "Profile")
val nav = LocalNavigation.current!!
val icons = listOf(
Icons.Rounded.Home,
Icons.Rounded.Search,
Expand All @@ -41,30 +38,28 @@ fun BottomNavBar(nav: NavHostController) {
selectedTextColor = Color.White
)

val navBackStackEntry by nav.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
val navBackStackEntry = nav.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry.value?.destination

Box(modifier = Modifier.background(LighterGray)) {
NavigationBar(containerColor = Color.Transparent) {
items.forEachIndexed { index, s ->
NavigationBarItem(
selected = currentDestination?.hierarchy?.any { it.route?.lowercase() == s.lowercase() } == true,
label = { Text(text = s, maxLines = 1) },
onClick = {
nav.navigate(s.lowercase(Locale.ROOT))
{
launchSingleTop = true
restoreState = true
popUpTo(nav.graph.findStartDestination().id) {
saveState = true
}
NavigationBar(containerColor = LighterGray) {
items.forEachIndexed { index, s ->
NavigationBarItem(
selected = currentDestination?.hierarchy?.any { it.route?.lowercase() == s.lowercase() } == true,
label = { Text(text = s, maxLines = 1) },
onClick = {
nav.navigate(s.lowercase(Locale.ROOT))
{
launchSingleTop = true
restoreState = true
popUpTo(nav.graph.findStartDestination().id) {
saveState = true
}
},
icon = { Icon(icons[index], contentDescription = "nav icon") },
alwaysShowLabel = false,
colors = navItemColors
)
}
}
},
icon = { Icon(icons[index], contentDescription = "nav icon") },
alwaysShowLabel = false,
colors = navItemColors
)
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/io/musicorum/mobile/router/Controller.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import io.musicorum.mobile.views.charts.Charts
import io.musicorum.mobile.views.home.Home
import io.musicorum.mobile.views.individual.Album
import io.musicorum.mobile.views.individual.Track
import io.musicorum.mobile.views.individual.User
import io.musicorum.mobile.views.individual.user.User
import io.musicorum.mobile.views.login.loginGraph
import io.musicorum.mobile.views.scrobbling.Scrobbling

Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/io/musicorum/mobile/router/Routes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ object Routes {
val entityString = entity?.entityName ?: "ARTIST"
return "collage?period=$periodString&entity=$entityString"
}
const val friends = "friends"
}
Loading

0 comments on commit 3c5def6

Please sign in to comment.