Browse Source

Added links to artist and album on Now Playing view. Partially covers #30.

housekeeping/remove-warnings
Antoine POPINEAU 5 years ago
parent
commit
b554678500
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 26
      app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt
  2. 2
      app/src/main/java/com/github/apognu/otter/adapters/AlbumsAdapter.kt
  3. 2
      app/src/main/java/com/github/apognu/otter/adapters/AlbumsGridAdapter.kt
  4. 2
      app/src/main/java/com/github/apognu/otter/adapters/ArtistsAdapter.kt
  5. 2
      app/src/main/java/com/github/apognu/otter/adapters/TracksAdapter.kt
  6. 62
      app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt
  7. 42
      app/src/main/java/com/github/apognu/otter/fragments/ArtistsFragment.kt
  8. 10
      app/src/main/res/layout/partial_now_playing.xml
  9. 12
      app/src/main/res/menu/track_info.xml
  10. 4
      app/src/main/res/values-fr/strings.xml
  11. 4
      app/src/main/res/values/strings.xml
  12. 2
      app/src/main/res/values/styles.xml

26
app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt

@ -13,14 +13,13 @@ import android.view.* @@ -13,14 +13,13 @@ import android.view.*
import android.view.animation.AccelerateDecelerateInterpolator
import android.widget.SeekBar
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.PopupMenu
import androidx.core.graphics.drawable.toDrawable
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import com.github.apognu.otter.R
import com.github.apognu.otter.fragments.BrowseFragment
import com.github.apognu.otter.fragments.LandscapeQueueFragment
import com.github.apognu.otter.fragments.QueueFragment
import com.github.apognu.otter.fragments.*
import com.github.apognu.otter.playback.MediaControlsManager
import com.github.apognu.otter.playback.PlayerService
import com.github.apognu.otter.repositories.FavoritedRepository
@ -301,6 +300,27 @@ class MainActivity : AppCompatActivity() { @@ -301,6 +300,27 @@ class MainActivity : AppCompatActivity() {
}
}
now_playing_details_info?.let { now_playing_details_info ->
now_playing_details_info.setOnClickListener {
PopupMenu(this@MainActivity, now_playing_details_info, Gravity.START, R.attr.actionOverflowMenuStyle, 0).apply {
inflate(R.menu.track_info)
setOnMenuItemClickListener {
when (it.itemId) {
R.id.go_to_artist -> ArtistsFragment.openAlbums(this@MainActivity, track.artist, art = track.album.cover.original)
R.id.go_to_album -> AlbumsFragment.openTracks(this@MainActivity, track.album)
}
now_playing.close()
true
}
show()
}
}
}
now_playing_details_favorite?.let { now_playing_details_favorite ->
favoriteCheckRepository.fetch().untilNetwork(IO) { favorites, _, _ ->
GlobalScope.launch(Main) {

2
app/src/main/java/com/github/apognu/otter/adapters/AlbumsAdapter.kt

@ -36,7 +36,7 @@ class AlbumsAdapter(val context: Context?, val listener: OnAlbumClickListener) : @@ -36,7 +36,7 @@ class AlbumsAdapter(val context: Context?, val listener: OnAlbumClickListener) :
Picasso.get()
.maybeLoad(maybeNormalizeUrl(album.cover.original))
.fit()
.transform(RoundedCornersTransformation(16, 0))
.transform(RoundedCornersTransformation(8, 0))
.into(holder.art)
holder.title.text = album.title

2
app/src/main/java/com/github/apognu/otter/adapters/AlbumsGridAdapter.kt

@ -36,7 +36,7 @@ class AlbumsGridAdapter(val context: Context?, private val listener: OnAlbumClic @@ -36,7 +36,7 @@ class AlbumsGridAdapter(val context: Context?, private val listener: OnAlbumClic
.maybeLoad(maybeNormalizeUrl(album.cover.original))
.fit()
.placeholder(R.drawable.cover)
.transform(RoundedCornersTransformation(24, 0))
.transform(RoundedCornersTransformation(16, 0))
.into(holder.cover)
holder.title.text = album.title

2
app/src/main/java/com/github/apognu/otter/adapters/ArtistsAdapter.kt

@ -39,7 +39,7 @@ class ArtistsAdapter(val context: Context?, private val listener: OnArtistClickL @@ -39,7 +39,7 @@ class ArtistsAdapter(val context: Context?, private val listener: OnArtistClickL
Picasso.get()
.maybeLoad(maybeNormalizeUrl(albums[0].cover.original))
.fit()
.transform(RoundedCornersTransformation(16, 0))
.transform(RoundedCornersTransformation(8, 0))
.into(holder.art)
}
}

2
app/src/main/java/com/github/apognu/otter/adapters/TracksAdapter.kt

@ -58,7 +58,7 @@ class TracksAdapter(private val context: Context?, private val favoriteListener: @@ -58,7 +58,7 @@ class TracksAdapter(private val context: Context?, private val favoriteListener:
Picasso.get()
.maybeLoad(maybeNormalizeUrl(track.album.cover.original))
.fit()
.transform(RoundedCornersTransformation(16, 0))
.transform(RoundedCornersTransformation(8, 0))
.into(holder.cover)
holder.title.text = track.title

62
app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
package com.github.apognu.otter.fragments
import android.content.Context
import android.graphics.Bitmap
import android.os.Bundle
import android.util.DisplayMetrics
@ -8,6 +9,7 @@ import android.view.View @@ -8,6 +9,7 @@ import android.view.View
import android.view.animation.AccelerateDecelerateInterpolator
import androidx.core.graphics.drawable.toDrawable
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
import androidx.transition.Fade
import androidx.transition.Slide
@ -32,15 +34,47 @@ class AlbumsFragment : FunkwhaleFragment<Album, AlbumsAdapter>() { @@ -32,15 +34,47 @@ class AlbumsFragment : FunkwhaleFragment<Album, AlbumsAdapter>() {
var artistArt = ""
companion object {
fun new(artist: Artist): AlbumsFragment {
fun new(artist: Artist, art: String? = null): AlbumsFragment {
val art = art ?: if (artist.albums?.isNotEmpty() == true) artist.albums[0].cover.original else ""
return AlbumsFragment().apply {
arguments = bundleOf(
"artistId" to artist.id,
"artistName" to artist.name,
"artistArt" to if (artist.albums?.isNotEmpty() == true) artist.albums[0].cover.original else ""
"artistArt" to art
)
}
}
fun openTracks(context: Context?, album: Album, fragment: Fragment? = null) {
(context as? MainActivity)?.let { activity ->
fragment?.let { fragment ->
fragment.onViewPager {
exitTransition = Fade().apply {
duration = AppContext.TRANSITION_DURATION
interpolator = AccelerateDecelerateInterpolator()
view?.let {
addTarget(it)
}
}
}
}
val fragment = TracksFragment.new(album).apply {
enterTransition = Slide().apply {
duration = AppContext.TRANSITION_DURATION
interpolator = AccelerateDecelerateInterpolator()
}
}
activity.supportFragmentManager
.beginTransaction()
.replace(R.id.container, fragment)
.addToBackStack(null)
.commit()
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
@ -97,29 +131,7 @@ class AlbumsFragment : FunkwhaleFragment<Album, AlbumsAdapter>() { @@ -97,29 +131,7 @@ class AlbumsFragment : FunkwhaleFragment<Album, AlbumsAdapter>() {
inner class OnAlbumClickListener : AlbumsAdapter.OnAlbumClickListener {
override fun onClick(view: View?, album: Album) {
(context as? MainActivity)?.let { activity ->
exitTransition = Fade().apply {
duration = AppContext.TRANSITION_DURATION
interpolator = AccelerateDecelerateInterpolator()
view?.let {
addTarget(it)
}
}
val fragment = TracksFragment.new(album).apply {
enterTransition = Slide().apply {
duration = AppContext.TRANSITION_DURATION
interpolator = AccelerateDecelerateInterpolator()
}
}
activity.supportFragmentManager
.beginTransaction()
.replace(R.id.container, fragment)
.addToBackStack(null)
.commit()
}
openTracks(context, album, fragment = this@AlbumsFragment)
}
}
}

42
app/src/main/java/com/github/apognu/otter/fragments/ArtistsFragment.kt

@ -1,8 +1,10 @@ @@ -1,8 +1,10 @@
package com.github.apognu.otter.fragments
import android.content.Context
import android.os.Bundle
import android.view.View
import android.view.animation.AccelerateDecelerateInterpolator
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
import androidx.transition.Fade
import androidx.transition.Slide
@ -19,28 +21,23 @@ class ArtistsFragment : FunkwhaleFragment<Artist, ArtistsAdapter>() { @@ -19,28 +21,23 @@ class ArtistsFragment : FunkwhaleFragment<Artist, ArtistsAdapter>() {
override val viewRes = R.layout.fragment_artists
override val recycler: RecyclerView get() = artists
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
adapter = ArtistsAdapter(context, OnArtistClickListener())
repository = ArtistsRepository(context)
}
inner class OnArtistClickListener : ArtistsAdapter.OnArtistClickListener {
override fun onClick(holder: View?, artist: Artist) {
companion object {
fun openAlbums(context: Context?, artist: Artist, fragment: Fragment? = null, art: String? = null) {
(context as? MainActivity)?.let { activity ->
onViewPager {
exitTransition = Fade().apply {
duration = AppContext.TRANSITION_DURATION
interpolator = AccelerateDecelerateInterpolator()
fragment?.let { fragment ->
fragment.onViewPager {
exitTransition = Fade().apply {
duration = AppContext.TRANSITION_DURATION
interpolator = AccelerateDecelerateInterpolator()
view?.let {
addTarget(it)
view?.let {
addTarget(it)
}
}
}
}
val fragment = AlbumsFragment.new(artist).apply {
val fragment = AlbumsFragment.new(artist, art).apply {
enterTransition = Slide().apply {
duration = AppContext.TRANSITION_DURATION
interpolator = AccelerateDecelerateInterpolator()
@ -55,4 +52,17 @@ class ArtistsFragment : FunkwhaleFragment<Artist, ArtistsAdapter>() { @@ -55,4 +52,17 @@ class ArtistsFragment : FunkwhaleFragment<Artist, ArtistsAdapter>() {
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
adapter = ArtistsAdapter(context, OnArtistClickListener())
repository = ArtistsRepository(context)
}
inner class OnArtistClickListener : ArtistsAdapter.OnArtistClickListener {
override fun onClick(holder: View?, artist: Artist) {
openAlbums(context, artist, fragment = this@ArtistsFragment)
}
}
}

10
app/src/main/res/layout/partial_now_playing.xml

@ -115,6 +115,16 @@ @@ -115,6 +115,16 @@
android:src="@drawable/ottershape"
tools:src="@tools:sample/avatars" />
<ImageButton
android:id="@+id/now_playing_details_info"
style="@style/IconButton"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="top|end"
android:layout_margin="8dp"
android:contentDescription="@string/alt_track_info"
android:src="@drawable/more" />
<ImageButton
android:id="@+id/now_playing_details_favorite"
style="@style/IconButton"

12
app/src/main/res/menu/track_info.xml

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/go_to_artist"
android:title="@string/go_to_artist" />
<item
android:id="@+id/go_to_album"
android:title="@string/go_to_album" />
</menu>

4
app/src/main/res/values-fr/strings.xml

@ -84,6 +84,10 @@ @@ -84,6 +84,10 @@
<string name="alt_artist_art">Image de l\'artiste</string>
<string name="alt_album_cover">Couverture de l\'album</string>
<string name="alt_more_options">Plus d\'options</string>
<string name="alt_track_info">Informations sur cette piste</string>
<string name="go_to_artist">Voir l\'artist</string>
<string name="go_to_album">Voir l\'album</string>
<string name="logout_title">Déconnexion</string>
<string name="logout_content">Etes-vous certains de vouloir vous déconnecter de votre instance Funkwhale ?</string>

4
app/src/main/res/values/strings.xml

@ -84,6 +84,10 @@ @@ -84,6 +84,10 @@
<string name="alt_artist_art">Artist art</string>
<string name="alt_album_cover">Album cover</string>
<string name="alt_more_options">More options</string>
<string name="alt_track_info">Information about track</string>
<string name="go_to_artist">Go to artist</string>
<string name="go_to_album">Go to album</string>
<string name="logout_title">Sign out</string>
<string name="logout_content">Are you sure you want to sign out of your Funkwhale instance?</string>

2
app/src/main/res/values/styles.xml

@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
<style name="AppTheme.Title">
<item name="android:fontFamily">sans-serif-light</item>
<item name="android:textSize">24sp</item>
<item name="android:textSize">32sp</item>
<item name="android:textColor">@color/itemTitle</item>
<item name="android:textStyle">bold</item>
</style>

Loading…
Cancel
Save