diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index c3bff6d7..b45c7e16 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -12,7 +12,7 @@ "filters": [], "properties": [], "versionCode": 10438, - "versionName": "3.5.650_0810", + "versionName": "3.5.650_0812", "enabled": true, "outputFile": "app-release.apk" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 16a51f6b..bb4f033d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -106,6 +106,7 @@ + @@ -257,5 +258,8 @@ + diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png index 991844b5..6f15eaae 100644 Binary files a/app/src/main/ic_launcher-playstore.png and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/code/name/monkey/retromusic/HomeSection.kt b/app/src/main/java/code/name/monkey/retromusic/HomeSection.kt new file mode 100644 index 00000000..80574b8a --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/HomeSection.kt @@ -0,0 +1,25 @@ +package code.name.monkey.retromusic + +import androidx.annotation.IntDef + +@IntDef( + RECENT_ALBUMS, + TOP_ALBUMS, + RECENT_ARTISTS, + TOP_ARTISTS, + SUGGESTIONS, + FAVOURITES, + GENRES, + PLAYLISTS +) +@Retention(AnnotationRetention.SOURCE) +annotation class HomeSection + +const val RECENT_ALBUMS = 3 +const val TOP_ALBUMS = 1 +const val RECENT_ARTISTS = 2 +const val TOP_ARTISTS = 0 +const val SUGGESTIONS = 5 +const val FAVOURITES = 4 +const val GENRES = 6 +const val PLAYLISTS = 7 \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/Result.kt b/app/src/main/java/code/name/monkey/retromusic/Result.kt new file mode 100644 index 00000000..4c241a14 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/Result.kt @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Fatih Giris. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package code.name.monkey.retromusic + +/** + * Generic class that holds the network state + */ +sealed class Result { + data class Success(val data: T) : Result() + object Loading : Result() + object Error : Result() +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt index 65577758..a9fbbee6 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt @@ -2,16 +2,13 @@ package code.name.monkey.retromusic.activities import android.content.Intent import android.content.SharedPreferences +import android.content.SharedPreferences.OnSharedPreferenceChangeListener import android.os.Bundle import android.provider.MediaStore import android.util.Log import android.view.View -import code.name.monkey.appthemehelper.ThemeStore -import code.name.monkey.appthemehelper.util.ATHUtil -import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.retromusic.* import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity -import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager import code.name.monkey.retromusic.extensions.findNavController import code.name.monkey.retromusic.fragments.LibraryViewModel import code.name.monkey.retromusic.helper.MusicPlayerRemote.openAndShuffleQueue @@ -19,7 +16,6 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote.openQueue import code.name.monkey.retromusic.helper.MusicPlayerRemote.playFromUri import code.name.monkey.retromusic.helper.MusicPlayerRemote.shuffleMode import code.name.monkey.retromusic.helper.SearchQueryHelper.getSongs -import code.name.monkey.retromusic.interfaces.CabHolder import code.name.monkey.retromusic.loaders.AlbumLoader.getAlbum import code.name.monkey.retromusic.loaders.ArtistLoader.getArtist import code.name.monkey.retromusic.loaders.PlaylistSongsLoader.getPlaylistSongList @@ -27,15 +23,10 @@ import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.util.AppRater.appLaunched import code.name.monkey.retromusic.util.PreferenceUtil -import code.name.monkey.retromusic.util.RetroColorUtil -import com.afollestad.materialcab.MaterialCab -import com.afollestad.materialdialogs.color.ColorChooserDialog import org.koin.android.ext.android.inject import java.util.* -class MainActivity : AbsSlidingMusicPanelActivity(), - SharedPreferences.OnSharedPreferenceChangeListener, CabHolder, - ColorChooserDialog.ColorCallback { +class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeListener { companion object { const val TAG = "MainActivity" const val EXPAND_PANEL = "expand_panel" @@ -44,7 +35,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), private val libraryViewModel: LibraryViewModel by inject() - private var cab: MaterialCab? = null + private var blockRequestPermissions = false override fun createContentView(): View { @@ -59,7 +50,6 @@ class MainActivity : AbsSlidingMusicPanelActivity(), setLightNavigationBar(true) setTaskDescriptionColorAuto() hideStatusBar() - setBottomBarVisibility(View.VISIBLE) appLaunched(this) addMusicServiceEventListener(libraryViewModel) updateTabs() @@ -177,46 +167,4 @@ class MainActivity : AbsSlidingMusicPanelActivity(), } return id } - - override fun handleBackPress(): Boolean { - if (cab != null && cab!!.isActive) { - cab?.finish() - return true - } - return super.handleBackPress() - } - - override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab { - cab?.let { - if (it.isActive) it.finish() - } - cab = MaterialCab(this, R.id.cab_stub) - .setMenu(menuRes) - .setCloseDrawableRes(R.drawable.ic_close) - .setBackgroundColor( - RetroColorUtil.shiftBackgroundColorForLightText( - ATHUtil.resolveColor( - this, - R.attr.colorSurface - ) - ) - ) - .start(callback) - return cab as MaterialCab - } - - override fun onColorSelection(dialog: ColorChooserDialog, selectedColor: Int) { - when (dialog.title) { - R.string.accent_color -> { - ThemeStore.editTheme(this).accentColor(selectedColor).commit() - if (VersionUtils.hasNougatMR()) - DynamicShortcutManager(this).updateDynamicShortcuts() - } - } - recreate() - } - - override fun onColorChooserDismissed(dialog: ColorChooserDialog) { - - } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt index ef9ffbe3..e15d4e15 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt @@ -14,6 +14,7 @@ import code.name.monkey.retromusic.extensions.accentColor import code.name.monkey.retromusic.extensions.surfaceColor import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.util.MusicUtil +import code.name.monkey.retromusic.util.ThemedFastScroller import com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager @@ -103,7 +104,7 @@ open class PlayingQueueActivity : AbsMusicServiceActivity() { } } }) - //ViewUtil.setUpFastScrollRecyclerViewColor(this, recyclerView) + val fastScroller = ThemedFastScroller.create(recyclerView) } private fun checkForPadding() { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt new file mode 100644 index 00000000..2e138452 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt @@ -0,0 +1,61 @@ +package code.name.monkey.retromusic.activities + +import android.os.Bundle +import android.view.MenuItem +import androidx.navigation.NavController +import code.name.monkey.appthemehelper.ThemeStore +import code.name.monkey.appthemehelper.util.VersionUtils +import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.activities.base.AbsBaseActivity +import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager +import code.name.monkey.retromusic.extensions.applyToolbar +import code.name.monkey.retromusic.extensions.findNavController +import com.afollestad.materialdialogs.color.ColorChooserDialog +import kotlinx.android.synthetic.main.activity_settings.* + +class SettingsActivity : AbsBaseActivity(), ColorChooserDialog.ColorCallback { + override fun onCreate(savedInstanceState: Bundle?) { + setDrawUnderStatusBar() + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_settings) + setStatusbarColorAuto() + setNavigationbarColorAuto() + setLightNavigationBar(true) + setupToolbar() + } + + private fun setupToolbar() { + setTitle(R.string.action_settings) + applyToolbar(toolbar) + val navController: NavController = findNavController(R.id.contentFrame) + navController.addOnDestinationChangedListener { _, _, _ -> + toolbar.title = navController.currentDestination?.label + } + } + + override fun onSupportNavigateUp(): Boolean { + return findNavController(R.id.contentFrame).navigateUp() || super.onSupportNavigateUp() + } + + override fun onColorSelection(dialog: ColorChooserDialog, selectedColor: Int) { + when (dialog.title) { + R.string.accent_color -> { + ThemeStore.editTheme(this).accentColor(selectedColor).commit() + if (VersionUtils.hasNougatMR()) + DynamicShortcutManager(this).updateDynamicShortcuts() + } + } + recreate() + } + + override fun onColorChooserDismissed(dialog: ColorChooserDialog) { + + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + if (item.itemId == android.R.id.home) { + onBackPressed() + } + return super.onOptionsItemSelected(item) + } +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt index 1bcd78ef..904f48ff 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt @@ -10,7 +10,6 @@ import android.text.TextUtils import android.view.MenuItem import android.widget.Toast import code.name.monkey.appthemehelper.util.ColorUtil -import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.retromusic.Constants.USER_BANNER import code.name.monkey.retromusic.Constants.USER_PROFILE @@ -49,7 +48,7 @@ class UserInfoActivity : AbsBaseActivity() { setLightNavigationBar(true) applyToolbar(toolbar) - MaterialUtil.setTint(nameContainer, false) + nameContainer.accentColor() name.setText(PreferenceUtil.userName) userImage.setOnClickListener { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt index b14b44bd..13b0727e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt @@ -7,12 +7,17 @@ import android.view.ViewGroup import android.view.ViewTreeObserver import android.widget.FrameLayout import androidx.annotation.LayoutRes +import androidx.core.view.ViewCompat +import androidx.core.view.isVisible import androidx.lifecycle.Observer import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.retromusic.R import code.name.monkey.retromusic.RetroBottomSheetBehavior -import code.name.monkey.retromusic.extensions.* +import code.name.monkey.retromusic.extensions.dimToPixel +import code.name.monkey.retromusic.extensions.hide +import code.name.monkey.retromusic.extensions.show +import code.name.monkey.retromusic.extensions.whichFragment import code.name.monkey.retromusic.fragments.LibraryViewModel import code.name.monkey.retromusic.fragments.MiniPlayerFragment import code.name.monkey.retromusic.fragments.NowPlayingScreen @@ -132,9 +137,7 @@ abstract class AbsSlidingMusicPanelActivity() : AbsMusicServiceActivity() { if (miniPlayerFragment?.view == null) return val alpha = 1 - progress miniPlayerFragment?.view?.alpha = alpha - // necessary to make the views below clickable miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE - bottomNavigationView.translationY = progress * 500 bottomNavigationView.alpha = alpha } @@ -171,32 +174,25 @@ abstract class AbsSlidingMusicPanelActivity() : AbsMusicServiceActivity() { return bottomNavigationView } - fun setBottomBarVisibility(visible: Int) { - bottomNavigationView.visibility = visible + fun hideBottomBarVisibility(visible: Boolean) { + bottomNavigationView.isVisible = visible hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty()) } private fun hideBottomBar(hide: Boolean) { val heightOfBar = dimToPixel(R.dimen.mini_player_height) - val heightOfBarWithTabs = dimToPixel(R.dimen.mini_player_height_expanded) + val isBottomBarVisible = bottomNavigationView.isVisible if (hide) { behavior.isHideable = true behavior.peekHeight = 0 - bottomNavigationView.elevation = dipToPix(10f) collapsePanel() + ViewCompat.setElevation(bottomNavigationView, 10f) } else { - if (MusicPlayerRemote.playingQueue.isNotEmpty()) { - slidingPanel.elevation = dipToPix(10f) - bottomNavigationView.elevation = dipToPix(10f) - behavior.isHideable = false - behavior.peekHeight = - if (bottomNavigationView.visibility == View.VISIBLE) { - heightOfBarWithTabs - } else { - heightOfBar - } - } + ViewCompat.setElevation(bottomNavigationView, 10f) + ViewCompat.setElevation(slidingPanel, 10f) + behavior.isHideable = false + behavior.peekHeight = if (isBottomBarVisible) heightOfBar * 2 else heightOfBar } } @@ -304,7 +300,7 @@ abstract class AbsSlidingMusicPanelActivity() : AbsMusicServiceActivity() { fun hideBottomNavigation() { behavior.isHideable = true behavior.peekHeight = 0 - setBottomBarVisibility(View.GONE) + hideBottomBarVisibility(false) } fun updateTabs() { diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt index 1e385502..d33067bd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt @@ -3,8 +3,8 @@ package code.name.monkey.retromusic.adapter import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.ImageView import android.widget.TextView -import androidx.annotation.IntDef import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.AppCompatTextView import androidx.core.os.bundleOf @@ -13,22 +13,17 @@ import androidx.navigation.fragment.FragmentNavigatorExtras import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import androidx.recyclerview.widget.RecyclerView.HORIZONTAL import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.util.ColorUtil -import code.name.monkey.retromusic.EXTRA_ALBUM_ID -import code.name.monkey.retromusic.EXTRA_ARTIST_ID -import code.name.monkey.retromusic.PeekingLinearLayoutManager -import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.* import code.name.monkey.retromusic.adapter.album.AlbumAdapter import code.name.monkey.retromusic.adapter.artist.ArtistAdapter import code.name.monkey.retromusic.adapter.song.SongAdapter -import code.name.monkey.retromusic.extensions.show +import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.fragments.albums.AlbumClickListener import code.name.monkey.retromusic.fragments.artists.ArtistClickListener import code.name.monkey.retromusic.glide.SongGlideRequest import code.name.monkey.retromusic.helper.MusicPlayerRemote -import code.name.monkey.retromusic.loaders.PlaylistSongsLoader import code.name.monkey.retromusic.model.* import code.name.monkey.retromusic.util.PreferenceUtil import com.bumptech.glide.Glide @@ -36,7 +31,7 @@ import com.google.android.material.card.MaterialCardView class HomeAdapter( private val activity: AppCompatActivity -) : RecyclerView.Adapter() { +) : RecyclerView.Adapter(), ArtistClickListener, AlbumClickListener { private var list = listOf() @@ -49,14 +44,9 @@ class HomeAdapter( .inflate(R.layout.section_recycler_view, parent, false) return when (viewType) { RECENT_ARTISTS, TOP_ARTISTS -> ArtistViewHolder(layout) - TOP_ALBUMS, RECENT_ALBUMS -> { - AlbumViewHolder( - LayoutInflater.from(activity) - .inflate(R.layout.metal_section_recycler_view, parent, false) - ) - } GENRES -> GenreViewHolder(layout) FAVOURITES -> PlaylistViewHolder(layout) + TOP_ALBUMS, RECENT_ALBUMS -> AlbumViewHolder(layout) else -> { SuggestionsViewHolder( LayoutInflater.from(activity).inflate( @@ -70,55 +60,62 @@ class HomeAdapter( } override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { + val home = list[position] when (getItemViewType(position)) { RECENT_ALBUMS -> { val viewHolder = holder as AlbumViewHolder - viewHolder.bindView( - list[position].arrayList as List, - R.string.recent_albums, - "Most recently added albums" - ) + viewHolder.bindView(home.arrayList as List, R.string.recent_albums) + viewHolder.clickableArea.setOnClickListener { + activity.findNavController(R.id.fragment_container).navigate( + R.id.detailListFragment, + bundleOf("type" to RECENT_ALBUMS) + ) + } } TOP_ALBUMS -> { val viewHolder = holder as AlbumViewHolder - viewHolder.bindView( - list[position].arrayList as List, - R.string.top_albums, - "Most played albums" - ) + viewHolder.bindView(home.arrayList as List, R.string.top_albums) + viewHolder.clickableArea.setOnClickListener { + activity.findNavController(R.id.fragment_container).navigate( + R.id.detailListFragment, + bundleOf("type" to TOP_ALBUMS) + ) + } } RECENT_ARTISTS -> { val viewHolder = holder as ArtistViewHolder - viewHolder.bindView( - list[position].arrayList as List, - R.string.recent_artists, - "Most recently added artists" - ) + viewHolder.bindView(home.arrayList, R.string.recent_artists) + viewHolder.clickableArea.setOnClickListener { + activity.findNavController(R.id.fragment_container).navigate( + R.id.detailListFragment, + bundleOf("type" to RECENT_ARTISTS) + ) + } } TOP_ARTISTS -> { val viewHolder = holder as ArtistViewHolder - viewHolder.bindView( - list[position].arrayList as List, - R.string.top_artists, - "Most played artists" - ) + viewHolder.bindView(home.arrayList, R.string.top_artists) + viewHolder.clickableArea.setOnClickListener { + activity.findNavController(R.id.fragment_container).navigate( + R.id.detailListFragment, + bundleOf("type" to TOP_ARTISTS) + ) + } } SUGGESTIONS -> { val viewHolder = holder as SuggestionsViewHolder - viewHolder.bindView( - list[position].arrayList as List - ) + viewHolder.bindView(home.arrayList) } FAVOURITES -> { val viewHolder = holder as PlaylistViewHolder - viewHolder.bindView( - list[position].arrayList as List, - R.string.favorites - ) + viewHolder.bindView(home.arrayList, R.string.favorites) } GENRES -> { val viewHolder = holder as GenreViewHolder - viewHolder.bind(list[position].arrayList as List, R.string.genres) + viewHolder.bind(home.arrayList, R.string.genres) + } + PLAYLISTS -> { + } } } @@ -132,79 +129,23 @@ class HomeAdapter( notifyDataSetChanged() } - companion object { - - @IntDef( - RECENT_ALBUMS, - TOP_ALBUMS, - RECENT_ARTISTS, - TOP_ARTISTS, - SUGGESTIONS, - FAVOURITES, - GENRES - ) - @Retention(AnnotationRetention.SOURCE) - annotation class HomeSection - - const val RECENT_ALBUMS = 3 - const val TOP_ALBUMS = 1 - const val RECENT_ARTISTS = 2 - const val TOP_ARTISTS = 0 - const val SUGGESTIONS = 5 - const val FAVOURITES = 4 - const val GENRES = 6 - } - - private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view), AlbumClickListener { - fun bindView(list: List, titleRes: Int, message: String) { - if (list.isNotEmpty()) { - val albumAdapter = AlbumAdapter(activity, list, R.layout.pager_item, null, this) - recyclerView.apply { - show() - adapter = albumAdapter - layoutManager = PeekingLinearLayoutManager(activity, HORIZONTAL, false) - } - title.text = activity.getString(titleRes) + private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) { + fun bindView(albums: List, titleRes: Int) { + title.text = activity.getString(titleRes) + recyclerView.apply { + adapter = albumAdapter(albums) + layoutManager = gridLayoutManager() } } - - override fun onAlbumClick(albumId: Int, view: View) { - activity.findNavController(R.id.fragment_container).navigate( - R.id.albumDetailsFragment, - bundleOf(EXTRA_ALBUM_ID to albumId), - null, - FragmentNavigatorExtras( - view to activity.getString(R.string.transition_album_art) - ) - ) - } } - private inner class ArtistViewHolder(view: View) : AbsHomeViewItem(view), ArtistClickListener { - fun bindView(list: List, titleRes: Int, message: String) { - if (list.isNotEmpty()) { - val manager = LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false) - val artistAdapter = ArtistAdapter( - activity, - list, - PreferenceUtil.homeGridStyle, - null, - this - ) - recyclerView.apply { - show() - layoutManager = manager - adapter = artistAdapter - } - title.text = activity.getString(titleRes) + private inner class ArtistViewHolder(view: View) : AbsHomeViewItem(view) { + fun bindView(artists: List, titleRes: Int) { + recyclerView.apply { + layoutManager = linearLayoutManager() + adapter = artistsAdapter(artists as List) } - } - - override fun onArtist(artistId: Int) { - activity.findNavController(R.id.fragment_container).navigate( - R.id.artistDetailsFragment, - bundleOf(EXTRA_ARTIST_ID to artistId) - ) + title.text = activity.getString(titleRes) } } @@ -220,18 +161,19 @@ class HomeAdapter( R.id.image8 ) - fun bindView(arrayList: List) { + fun bindView(songs: List) { + songs as List val color = ThemeStore.accentColor(activity) itemView.findViewById(R.id.message).setTextColor(color) itemView.findViewById(R.id.card6).apply { setCardBackgroundColor(ColorUtil.withAlpha(color, 0.2f)) } - if (arrayList.size > 9) + if (songs.size > 9) images.forEachIndexed { index, i -> itemView.findViewById(i).setOnClickListener { - MusicPlayerRemote.playNext(arrayList[index]) + MusicPlayerRemote.playNext(songs[index]) } - SongGlideRequest.Builder.from(Glide.with(activity), arrayList[index]) + SongGlideRequest.Builder.from(Glide.with(activity), songs[index]) .asBitmap() .build() .into(itemView.findViewById(i)) @@ -241,33 +183,29 @@ class HomeAdapter( } private inner class PlaylistViewHolder(view: View) : AbsHomeViewItem(view) { - fun bindView(arrayList: List, titleRes: Int) { - text.text = "You're all time favorites" - if (arrayList.isNotEmpty()) { - val songs = PlaylistSongsLoader.getPlaylistSongList(activity, arrayList[0]) - if (songs.isNotEmpty()) { - recyclerView.apply { - show() - val songAdapter = - SongAdapter(activity, songs, R.layout.item_album_card, null) - layoutManager = - GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false) - adapter = songAdapter - } - title.text = activity.getString(titleRes) - } + fun bindView(songs: List, titleRes: Int) { + arrow.hide() + recyclerView.apply { + val songAdapter = SongAdapter( + activity, + songs as MutableList, + R.layout.item_album_card, null + ) + layoutManager = linearLayoutManager() + adapter = songAdapter } + title.text = activity.getString(titleRes) } } private inner class GenreViewHolder(itemView: View) : AbsHomeViewItem(itemView) { - fun bind(genres: List, titleRes: Int) { + fun bind(genres: List, titleRes: Int) { + arrow.hide() title.text = activity.getString(titleRes) - text.text = "Genres for you" recyclerView.apply { - show() - layoutManager = GridLayoutManager(activity, 2, GridLayoutManager.HORIZONTAL, false) - val genreAdapter = GenreAdapter(activity, genres, R.layout.item_grid_genre) + layoutManager = GridLayoutManager(activity, 3, GridLayoutManager.HORIZONTAL, false) + val genreAdapter = + GenreAdapter(activity, genres as List, R.layout.item_grid_genre) adapter = genreAdapter } } @@ -276,6 +214,38 @@ class HomeAdapter( open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) { val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView) val title: AppCompatTextView = itemView.findViewById(R.id.title) - val text: AppCompatTextView = itemView.findViewById(R.id.text) + val arrow: ImageView = itemView.findViewById(R.id.arrow) + val clickableArea: ViewGroup = itemView.findViewById(R.id.clickable_area) + } + + fun artistsAdapter(artists: List) = + ArtistAdapter(activity, artists, PreferenceUtil.homeGridStyle, null, this) + + fun albumAdapter(albums: List) = + AlbumAdapter(activity, albums, R.layout.item_image, null, this) + + fun gridLayoutManager() = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false) + fun linearLayoutManager() = LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false) + + override fun onArtist(artistId: Int, imageView: ImageView) { + activity.findNavController(R.id.fragment_container).navigate( + R.id.artistDetailsFragment, + bundleOf(EXTRA_ARTIST_ID to artistId), + null, + FragmentNavigatorExtras( + imageView to activity.getString(R.string.transition_album_art) + ) + ) + } + + override fun onAlbumClick(albumId: Int, view: View) { + activity.findNavController(R.id.fragment_container).navigate( + R.id.albumDetailsFragment, + bundleOf(EXTRA_ALBUM_ID to albumId), + null, + FragmentNavigatorExtras( + view to activity.getString(R.string.transition_album_art) + ) + ) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt index 1d6b020b..28505826 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt @@ -1,12 +1,12 @@ package code.name.monkey.retromusic.adapter.artist -import android.app.ActivityOptions import android.content.res.ColorStateList import android.content.res.Resources import android.view.LayoutInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup +import androidx.core.view.ViewCompat import androidx.fragment.app.FragmentActivity import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter @@ -131,7 +131,6 @@ class ArtistAdapter( inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) { init { - setImageTransitionName(activity.getString(R.string.transition_artist_image)) menu?.visibility = View.GONE } @@ -140,15 +139,13 @@ class ArtistAdapter( if (isInQuickSelectMode) { toggleChecked(layoutPosition) } else { - val activityOptions = ActivityOptions.makeSceneTransitionAnimation( - activity, - imageContainerCard ?: image, - activity.getString(R.string.transition_artist_image) - ) - artistClickListener.onArtist(dataSet[layoutPosition].id) - /*NavigationUtil.goToArtistOptions( - activity, dataSet[layoutPosition].id, activityOptions - )*/ + image?.let { + ViewCompat.setTransitionName( + it, + activity.getString(R.string.transition_artist_image) + ) + artistClickListener.onArtist(dataSet[layoutPosition].id, it) + } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt index c2d27315..6f416f23 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt @@ -148,7 +148,6 @@ open class SongAdapter( return "" } } - return MusicUtil.getSectionName(sectionName) } diff --git a/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt b/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt index 0e1892b3..368cb0bf 100644 --- a/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt +++ b/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt @@ -33,6 +33,8 @@ import code.name.monkey.retromusic.App import code.name.monkey.retromusic.R import com.google.android.material.button.MaterialButton import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton +import com.google.android.material.textfield.TextInputEditText +import com.google.android.material.textfield.TextInputLayout fun Int.ripAlpha(): Int { return ColorUtil.stripAlpha(this) @@ -116,4 +118,15 @@ fun MaterialButton.applyColor(color: Int) { backgroundTintList = backgroundColorStateList setTextColor(textColorColorStateList) iconTint = textColorColorStateList +} + +fun TextInputLayout.accentColor() { + val accentColor = ThemeStore.accentColor(context) + val colorState = ColorStateList.valueOf(accentColor) + boxStrokeColor = accentColor + defaultHintTextColor = colorState + isHintAnimationEnabled = true +} +fun TextInputEditText.accentColor(){ + } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/DetailListFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/DetailListFragment.kt new file mode 100644 index 00000000..57d4e9bb --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/DetailListFragment.kt @@ -0,0 +1,130 @@ +package code.name.monkey.retromusic.fragments + +import android.os.Bundle +import android.view.View +import android.widget.ImageView +import androidx.navigation.fragment.navArgs +import androidx.recyclerview.widget.GridLayoutManager +import androidx.recyclerview.widget.LinearLayoutManager +import code.name.monkey.retromusic.* +import code.name.monkey.retromusic.adapter.album.AlbumAdapter +import code.name.monkey.retromusic.adapter.artist.ArtistAdapter +import code.name.monkey.retromusic.adapter.song.SongAdapter +import code.name.monkey.retromusic.fragments.albums.AlbumClickListener +import code.name.monkey.retromusic.fragments.artists.ArtistClickListener +import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment +import code.name.monkey.retromusic.model.Album +import code.name.monkey.retromusic.model.Artist +import code.name.monkey.retromusic.model.Song +import code.name.monkey.retromusic.providers.RepositoryImpl +import kotlinx.android.synthetic.main.fragment_playlist_detail.* +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers.IO +import kotlinx.coroutines.Dispatchers.Main +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import org.koin.android.ext.android.inject + +class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_detail), + ArtistClickListener, AlbumClickListener { + private val args by navArgs() + private val repository by inject() + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + mainActivity.setSupportActionBar(toolbar) + mainActivity.hideBottomBarVisibility(false) + when (args.type) { + TOP_ARTISTS -> { + loadArtists(R.string.top_artists, TOP_ARTISTS) + } + RECENT_ARTISTS -> { + loadArtists(R.string.recent_artists, RECENT_ARTISTS) + } + TOP_ALBUMS -> { + loadAlbums(R.string.top_albums, TOP_ALBUMS) + } + RECENT_ALBUMS -> { + loadAlbums(R.string.recent_albums, RECENT_ALBUMS) + } + FAVOURITES -> { + loadFavorite() + } + } + } + + private fun loadFavorite() { + toolbar.setTitle(R.string.favorites) + CoroutineScope(IO).launch { + val songs = repository.favoritePlaylistHome() + withContext(Main) { + recyclerView.apply { + adapter = SongAdapter( + requireActivity(), + songs.arrayList as MutableList, + R.layout.item_list, null + ) + layoutManager = linearLayoutManager() + } + } + } + } + + private fun loadArtists(title: Int, type: Int) { + toolbar.setTitle(title) + CoroutineScope(IO).launch { + val artists = + if (type == TOP_ARTISTS) repository.topArtists() else repository.recentArtists() + withContext(Main) { + recyclerView.apply { + adapter = artistAdapter(artists) + layoutManager = gridLayoutManager() + } + } + } + } + + private fun loadAlbums(title: Int, type: Int) { + toolbar.setTitle(title) + CoroutineScope(IO).launch { + val albums = + if (type == TOP_ALBUMS) repository.topAlbums() else repository.recentAlbums() + withContext(Main) { + recyclerView.apply { + adapter = albumAdapter(albums) + layoutManager = gridLayoutManager() + + } + } + } + } + + private fun artistAdapter(artists: List): ArtistAdapter = ArtistAdapter( + requireActivity(), + artists, + R.layout.item_grid_circle, + null, this@DetailListFragment + ) + + private fun albumAdapter(albums: List): AlbumAdapter = AlbumAdapter( + requireActivity(), + albums, + R.layout.item_grid, + null, this@DetailListFragment + ) + + private fun linearLayoutManager(): LinearLayoutManager = + LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + + private fun gridLayoutManager(): GridLayoutManager = + GridLayoutManager(requireContext(), 2, GridLayoutManager.VERTICAL, false) + + + override fun onArtist(artistId: Int, imageView: ImageView) { + + } + + override fun onAlbumClick(albumId: Int, view: View) { + + } +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt index e0a5498c..8f514c5a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt @@ -4,7 +4,6 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import code.name.monkey.retromusic.adapter.HomeAdapter import code.name.monkey.retromusic.fragments.ReloadType.* import code.name.monkey.retromusic.interfaces.MusicServiceEventListener import code.name.monkey.retromusic.model.* @@ -18,13 +17,13 @@ class LibraryViewModel( private val repository: RepositoryImpl ) : ViewModel(), MusicServiceEventListener { + private val paletteColor = MutableLiveData() private val albums = MutableLiveData>() private val songs = MutableLiveData>() private val artists = MutableLiveData>() private val playlists = MutableLiveData>() private val genres = MutableLiveData>() private val home = MutableLiveData>() - private val paletteColor = MutableLiveData() val paletteColorLiveData: LiveData = paletteColor val homeLiveData: LiveData> = home @@ -46,38 +45,14 @@ class LibraryViewModel( artists.value = loadArtists.await() playlists.value = loadPlaylists.await() genres.value = loadGenres.await() - loadHomeSections() + home.value = loadHome.await() } - private fun loadHomeSections() = viewModelScope.launch { - val list = mutableListOf() - val result = listOf( - repository.topArtists(), - repository.topAlbums(), - repository.recentArtists(), - repository.recentAlbums()/*, - repository.suggestions(), - repository.favoritePlaylist(), - repository.homeGenres()*/ - ) - result.forEach { - if (it != null && it.arrayList.isNotEmpty()) { - if (it.homeSection == HomeAdapter.SUGGESTIONS) { - if (it.arrayList.size > 9) { - list.add(it) - } - } else { - list.add(it) - } - } - } - home.value = list - } + private val loadHome: Deferred> + get() = viewModelScope.async { repository.homeSections() } private val loadSongs: Deferred> - get() = viewModelScope.async(IO) { - repository.allSongs() - } + get() = viewModelScope.async(IO) { repository.allSongs() } private val loadAlbums: Deferred> get() = viewModelScope.async(IO) { @@ -99,6 +74,7 @@ class LibraryViewModel( repository.allGenres() } + fun forceReload(reloadType: ReloadType) = viewModelScope.launch { when (reloadType) { Songs -> songs.value = loadSongs.await() @@ -114,15 +90,37 @@ class LibraryViewModel( override fun onMediaStoreChanged() { loadLibraryContent() + println("onMediaStoreChanged") } - override fun onServiceConnected() {} - override fun onServiceDisconnected() {} - override fun onQueueChanged() {} - override fun onPlayingMetaChanged() {} - override fun onPlayStateChanged() {} - override fun onRepeatModeChanged() {} - override fun onShuffleModeChanged() {} + + override fun onServiceConnected() { + println("onServiceConnected") + } + + override fun onServiceDisconnected() { + println("onServiceDisconnected") + } + + override fun onQueueChanged() { + println("onQueueChanged") + } + + override fun onPlayingMetaChanged() { + println("onPlayingMetaChanged") + } + + override fun onPlayStateChanged() { + println("onPlayStateChanged") + } + + override fun onRepeatModeChanged() { + println("onRepeatModeChanged") + } + + override fun onShuffleModeChanged() { + println("onShuffleModeChanged") + } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/about/AboutFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/about/AboutFragment.kt index 4f030ac0..5cbe0b76 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/about/AboutFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/about/AboutFragment.kt @@ -6,13 +6,13 @@ import android.net.Uri import android.os.Bundle import android.view.View import androidx.core.app.ShareCompat +import androidx.fragment.app.Fragment import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.LinearLayoutManager import code.name.monkey.retromusic.App import code.name.monkey.retromusic.Constants import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.ContributorAdapter -import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment import code.name.monkey.retromusic.model.Contributor import code.name.monkey.retromusic.util.NavigationUtil import com.google.gson.Gson @@ -24,7 +24,7 @@ import kotlinx.android.synthetic.main.card_social.* import java.io.IOException import java.nio.charset.StandardCharsets -class AboutFragment : AbsMainActivityFragment(R.layout.fragment_about), View.OnClickListener { +class AboutFragment : Fragment(R.layout.fragment_about), View.OnClickListener { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) version.setSummary(getAppVersion()) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt index c8398f63..d5d485a2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumDetailsFragment.kt @@ -62,17 +62,15 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) setHasOptionsMenu(true) + mainActivity.hideBottomBarVisibility(false) + mainActivity.addMusicServiceEventListener(detailsViewModel) mainActivity.setSupportActionBar(toolbar) - mainActivity.setBottomBarVisibility(View.GONE) toolbar.title = null - image.transitionName = getString(R.string.transition_album_art) - postponeEnterTransition() - playerActivity?.addMusicServiceEventListener(detailsViewModel) detailsViewModel.getAlbum().observe(viewLifecycleOwner, Observer { - startPostponedEnterTransition() showAlbum(it) + startPostponedEnterTransition() }) detailsViewModel.getArtist().observe(viewLifecycleOwner, Observer { loadArtistImage(it) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt index 5c4b5aa6..47c060da 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt @@ -5,6 +5,7 @@ import android.view.View import androidx.core.os.bundleOf import androidx.lifecycle.Observer import androidx.navigation.findNavController +import androidx.navigation.fragment.FragmentNavigatorExtras import androidx.recyclerview.widget.GridLayoutManager import code.name.monkey.retromusic.EXTRA_ALBUM_ID import code.name.monkey.retromusic.R @@ -19,13 +20,12 @@ class AlbumsFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - libraryViewModel.albumsLiveData - .observe(viewLifecycleOwner, Observer { albums -> - if (albums.isNotEmpty()) - adapter?.swapDataSet(albums) - else - adapter?.swapDataSet(listOf()) - }) + libraryViewModel.albumsLiveData.observe(viewLifecycleOwner, Observer { + if (it.isNotEmpty()) + adapter?.swapDataSet(it) + else + adapter?.swapDataSet(listOf()) + }) } override val emptyMessage: Int @@ -98,7 +98,11 @@ class AlbumsFragment : val controller = requireActivity().findNavController(R.id.fragment_container) controller.navigate( R.id.albumDetailsFragment, - bundleOf(EXTRA_ALBUM_ID to albumId) + bundleOf(EXTRA_ALBUM_ID to albumId), + null, + FragmentNavigatorExtras( + view to getString(R.string.transition_album_art) + ) ) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistDetailsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistDetailsFragment.kt index 38dec7c6..8fc574eb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistDetailsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistDetailsFragment.kt @@ -56,17 +56,19 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d private var lang: String? = null private var biography: Spanned? = null + override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) setHasOptionsMenu(true) mainActivity.setSupportActionBar(toolbar) - mainActivity.setBottomBarVisibility(View.GONE) + mainActivity.hideBottomBarVisibility(false) toolbar.title = null setupRecyclerView() postponeEnterTransition() detailsViewModel.getArtist().observe(viewLifecycleOwner, Observer { - startPostponedEnterTransition() + showArtist(it) + startPostponedEnterTransition() }) detailsViewModel.getArtistInfo().observe(viewLifecycleOwner, Observer { artistInfo(it) @@ -129,7 +131,7 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d ) songTitle.text = songText albumTitle.text = albumText - songAdapter.swapDataSet(artist.songs) + songAdapter.swapDataSet(artist.songs.sortedBy { it.trackNumber }) artist.albums?.let { albumAdapter.swapDataSet(it) } } @@ -175,6 +177,7 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d .generatePalette(requireContext()).build() .dontAnimate().into(object : RetroMusicColoredTarget(image) { override fun onColorReady(colors: MediaNotificationProcessor) { + startPostponedEnterTransition() setColors(colors) } }) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt index aaf03234..6f2d91a1 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt @@ -2,6 +2,7 @@ package code.name.monkey.retromusic.fragments.artists import android.os.Bundle import android.view.View +import android.widget.ImageView import androidx.core.os.bundleOf import androidx.lifecycle.Observer import androidx.recyclerview.widget.GridLayoutManager @@ -25,14 +26,12 @@ class ArtistsFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - libraryViewModel.artistsLiveData - .observe(viewLifecycleOwner, Observer { artists -> - if (artists.isNotEmpty()) { - adapter?.swapDataSet(artists) - } else { - adapter?.swapDataSet(listOf()) - } - }) + libraryViewModel.artistsLiveData.observe(viewLifecycleOwner, Observer { + if (it.isNotEmpty()) + adapter?.swapDataSet(it) + else + adapter?.swapDataSet(listOf()) + }) } override val emptyMessage: Int @@ -101,12 +100,12 @@ class ArtistsFragment : } } - override fun onArtist(artistId: Int) { + override fun onArtist(artistId: Int, imageView: ImageView) { val controller = findActivityNavController(R.id.fragment_container) controller.navigate(R.id.artistDetailsFragment, bundleOf(EXTRA_ARTIST_ID to artistId)) } } interface ArtistClickListener { - fun onArtist(artistId: Int) + fun onArtist(artistId: Int, imageView: ImageView) } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt index 2ba05ce7..a78f1618 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsRecyclerViewFragment.kt @@ -18,12 +18,13 @@ import me.zhanghai.android.fastscroll.FastScroller import me.zhanghai.android.fastscroll.FastScrollerBuilder import org.koin.androidx.viewmodel.ext.android.sharedViewModel + abstract class AbsRecyclerViewFragment, LM : RecyclerView.LayoutManager> : AbsMusicServiceFragment(R.layout.fragment_main_activity_recycler_view), AppBarLayout.OnOffsetChangedListener { val libraryViewModel: LibraryViewModel by sharedViewModel() - + override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) setHasOptionsMenu(true) @@ -41,15 +42,17 @@ abstract class AbsRecyclerViewFragment, LM : Recycle } private fun setUpRecyclerView() { - recyclerView.layoutManager = layoutManager - recyclerView.adapter = adapter - val fastScroller = create(recyclerView) - recyclerView.setOnApplyWindowInsetsListener( - ScrollingViewOnApplyWindowInsetsListener( - recyclerView, - fastScroller + recyclerView.apply { + layoutManager = this@AbsRecyclerViewFragment.layoutManager + adapter = this@AbsRecyclerViewFragment.adapter + val fastScroller = create(this) + setOnApplyWindowInsetsListener( + ScrollingViewOnApplyWindowInsetsListener( + recyclerView, + fastScroller + ) ) - ) + } checkForPadding() } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreDetailsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreDetailsFragment.kt index 0cbeed7b..8924ffd9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreDetailsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreDetailsFragment.kt @@ -35,7 +35,7 @@ class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_ setHasOptionsMenu(true) mainActivity.addMusicServiceEventListener(detailsViewModel) mainActivity.setSupportActionBar(toolbar) - mainActivity.setBottomBarVisibility(View.GONE) + mainActivity.hideBottomBarVisibility(false) setupRecyclerView() detailsViewModel.getSongs().observe(viewLifecycleOwner, androidx.lifecycle.Observer { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt index 7610476c..e4017e57 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenresFragment.kt @@ -32,14 +32,12 @@ class GenresFragment : AbsRecyclerViewFragment - if (genres.isNotEmpty()) { - adapter?.swapDataSet(genres) - } else { - adapter?.swapDataSet(listOf()) - } - }) + libraryViewModel.genresLiveData.observe(viewLifecycleOwner, Observer { + if (it.isNotEmpty()) + adapter?.swapDataSet(it) + else + adapter?.swapDataSet(listOf()) + }) } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/home/HomeFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/home/HomeFragment.kt index 6c0d9881..01128bb9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/home/HomeFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/home/HomeFragment.kt @@ -25,6 +25,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import code.name.monkey.retromusic.EXTRA_PLAYLIST import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.HomeAdapter +import code.name.monkey.retromusic.extensions.findActivityNavController import code.name.monkey.retromusic.fragments.LibraryViewModel import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment import code.name.monkey.retromusic.glide.ProfileBannerGlideRequest @@ -57,9 +58,7 @@ class HomeFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - setStatusBarColorAuto(view) - bannerImage?.setOnClickListener { val options = ActivityOptions.makeSceneTransitionAnimation( mainActivity, @@ -70,14 +69,14 @@ class HomeFragment : } lastAdded.setOnClickListener { - requireActivity().findNavController(R.id.fragment_container).navigate( + findActivityNavController(R.id.fragment_container).navigate( R.id.playlistDetailsFragment, bundleOf(EXTRA_PLAYLIST to LastAddedPlaylist(requireActivity())) ) } topPlayed.setOnClickListener { - requireActivity().findNavController(R.id.fragment_container).navigate( + findActivityNavController(R.id.fragment_container).navigate( R.id.playlistDetailsFragment, bundleOf(EXTRA_PLAYLIST to MyTopTracksPlaylist(requireActivity())) ) @@ -110,9 +109,8 @@ class HomeFragment : adapter = homeAdapter } - libraryViewModel.homeLiveData - .observe(viewLifecycleOwner, Observer { sections -> - homeAdapter.swapData(sections) + libraryViewModel.homeLiveData.observe(viewLifecycleOwner, Observer { + homeAdapter.swapData(it) }) loadProfile() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/library/LibraryFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/library/LibraryFragment.kt index 93859b58..1c743f92 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/library/LibraryFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/library/LibraryFragment.kt @@ -4,7 +4,6 @@ import android.os.Bundle import android.view.Menu import android.view.MenuInflater import android.view.MenuItem -import android.view.View import androidx.navigation.fragment.findNavController import code.name.monkey.appthemehelper.common.ATHToolbarActivity.getToolbarBackgroundColor import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper @@ -17,11 +16,21 @@ import com.google.android.material.appbar.AppBarLayout import kotlinx.android.synthetic.main.fragment_library.* class LibraryFragment : AbsMainActivityFragment(R.layout.fragment_library) { - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) + + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) setHasOptionsMenu(true) - mainActivity.setBottomBarVisibility(View.VISIBLE) + mainActivity.hideBottomBarVisibility(true) mainActivity.setSupportActionBar(toolbar) + mainActivity.supportActionBar?.title = null + toolbar.setNavigationOnClickListener { + findNavController().navigate( + R.id.searchFragment, + null, + navOptions + ) + } setupNavigationController() } @@ -67,13 +76,8 @@ class LibraryFragment : AbsMainActivityFragment(R.layout.fragment_library) { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { - R.id.action_search -> findNavController().navigate( - R.id.searchFragment, - null, - navOptions - ) R.id.action_settings -> findNavController().navigate( - R.id.settingsFragment, + R.id.settingsActivity, null, navOptions ) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistDetailsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistDetailsFragment.kt index 474df7dd..5c2d989b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistDetailsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistDetailsFragment.kt @@ -43,7 +43,7 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli setHasOptionsMenu(true) mainActivity.addMusicServiceEventListener(viewModel) mainActivity.setSupportActionBar(toolbar) - mainActivity.setBottomBarVisibility(View.GONE) + mainActivity.hideBottomBarVisibility(false) playlist = arguments.extraPlaylist diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt index 2ab2d3c0..22681715 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/playlists/PlaylistsFragment.kt @@ -19,12 +19,11 @@ class PlaylistsFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - libraryViewModel.playlisitsLiveData.observe(viewLifecycleOwner, Observer { playlists -> - if (playlists.isNotEmpty()) { - adapter?.swapDataSet(playlists) - } else { + libraryViewModel.playlisitsLiveData.observe(viewLifecycleOwner, Observer { + if (it.isNotEmpty()) + adapter?.swapDataSet(it) + else adapter?.swapDataSet(listOf()) - } }) } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/search/SearchFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/search/SearchFragment.kt index a53f4e13..c83dab44 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/search/SearchFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/search/SearchFragment.kt @@ -39,7 +39,7 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa super.onViewCreated(view, savedInstanceState) mainActivity.setSupportActionBar(toolbar) mainActivity.hideBottomNavigation() - mainActivity.setBottomBarVisibility(View.GONE) + mainActivity.hideBottomBarVisibility(false) setupRecyclerView() setupSearchView() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/SettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/SettingsFragment.kt deleted file mode 100644 index 72355ec9..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/SettingsFragment.kt +++ /dev/null @@ -1,23 +0,0 @@ -package code.name.monkey.retromusic.fragments.settings - -import android.os.Bundle -import android.view.View -import androidx.navigation.NavController -import code.name.monkey.retromusic.R -import code.name.monkey.retromusic.extensions.findNavController -import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment -import kotlinx.android.synthetic.main.fragment_settings.* - -class SettingsFragment : AbsMainActivityFragment(R.layout.fragment_settings) { - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - mainActivity.setSupportActionBar(toolbar) - mainActivity.hideBottomNavigation() - mainActivity.setBottomBarVisibility(View.GONE) - val navController: NavController = findNavController(R.id.contentFrame) - navController.addOnDestinationChangedListener { _, _, _ -> - toolbar.title = navController.currentDestination?.label - } - } -} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt index 0d28c804..3db01eb7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt @@ -23,11 +23,10 @@ class SongsFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) libraryViewModel.songsLiveData.observe(viewLifecycleOwner, Observer { - if (it.isNotEmpty()) { + if (it.isNotEmpty()) adapter?.swapDataSet(it) - } else { + else adapter?.swapDataSet(listOf()) - } }) } diff --git a/app/src/main/java/code/name/monkey/retromusic/model/Home.kt b/app/src/main/java/code/name/monkey/retromusic/model/Home.kt index 3c015e1a..e848d25c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/model/Home.kt +++ b/app/src/main/java/code/name/monkey/retromusic/model/Home.kt @@ -14,13 +14,10 @@ package code.name.monkey.retromusic.model -import androidx.annotation.DrawableRes -import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.HomeSection +import code.name.monkey.retromusic.HomeSection class Home( - val arrayList: List<*>, + val arrayList: List, @HomeSection - val homeSection: Int, - @DrawableRes - val icon: Int + val homeSection: Int ) \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.kt b/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.kt index 8a1dbf11..c2fd7aeb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.kt +++ b/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.kt @@ -15,8 +15,7 @@ package code.name.monkey.retromusic.providers import android.content.Context -import code.name.monkey.retromusic.R -import code.name.monkey.retromusic.adapter.HomeAdapter +import code.name.monkey.retromusic.* import code.name.monkey.retromusic.loaders.* import code.name.monkey.retromusic.model.* import code.name.monkey.retromusic.model.smartplaylist.NotRecentlyPlayedPlaylist @@ -24,6 +23,10 @@ import code.name.monkey.retromusic.network.LastFMService import code.name.monkey.retromusic.network.model.LastFmAlbum import code.name.monkey.retromusic.network.model.LastFmArtist import code.name.monkey.retromusic.providers.interfaces.Repository +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.flow class RepositoryImpl( private val context: Context, @@ -39,41 +42,24 @@ class RepositoryImpl( override suspend fun artistById(artistId: Int): Artist = ArtistLoader.getArtist(context, artistId) + override suspend fun recentArtists(): List = + LastAddedSongsLoader.getLastAddedArtists(context) + + override suspend fun topArtists(): List = + TopAndRecentlyPlayedTracksLoader.getTopArtists(context) + + override suspend fun topAlbums(): List = + TopAndRecentlyPlayedTracksLoader.getTopAlbums(context) + + override suspend fun recentAlbums(): List = + LastAddedSongsLoader.getLastAddedAlbums(context) + override suspend fun allPlaylists(): List = PlaylistLoader.getAllPlaylists(context) override suspend fun allGenres(): List = GenreLoader.getAllGenres(context) override suspend fun allSongs(): List = SongLoader.getAllSongs(context) - override suspend fun suggestions(): Home? { - val songs = NotRecentlyPlayedPlaylist(context).getSongs(context).shuffled().apply { - if (size > 9) subList(0, 9) - } - if (songs.isNotEmpty()) { - return Home( - songs, - HomeAdapter.SUGGESTIONS, - R.drawable.ic_audiotrack - ) - } - return null - } - - override suspend fun homeGenres(): Home? { - val genres = - GenreLoader.getAllGenres(context) - .shuffled() - .filter { it.name.length in 5..10 } - - if (genres.isNotEmpty()) { - return Home( - genres, - HomeAdapter.GENRES, - R.drawable.ic_guitar - ) - } - return null - } override suspend fun search(query: String?): MutableList = SearchLoader.searchAll(context, query) @@ -89,52 +75,6 @@ class RepositoryImpl( override suspend fun getGenre(genreId: Int): ArrayList = GenreLoader.getSongs(context, genreId) - override suspend fun recentArtists(): Home? { - val artists = LastAddedSongsLoader.getLastAddedArtists(context) - return if (artists.isNotEmpty()) Home( - artists, - HomeAdapter.RECENT_ARTISTS, - R.drawable.ic_artist - ) else null - } - - override suspend fun recentAlbums(): Home? { - val albums = LastAddedSongsLoader.getLastAddedAlbums(context) - return if (albums.isNotEmpty()) Home( - albums, - HomeAdapter.RECENT_ALBUMS, - R.drawable.ic_album - ) else null - } - - override suspend fun topAlbums(): Home? { - val albums = TopAndRecentlyPlayedTracksLoader.getTopAlbums(context) - return if (albums.isNotEmpty()) Home( - albums, - HomeAdapter.TOP_ALBUMS, - R.drawable.ic_album - ) else null - } - - override suspend fun topArtists(): Home? { - - val artists = TopAndRecentlyPlayedTracksLoader.getTopArtists(context) - return if (artists.isNotEmpty()) Home( - artists, - HomeAdapter.TOP_ARTISTS, - R.drawable.ic_artist - ) else null - - } - - override suspend fun favoritePlaylist(): Home? { - val playlists = PlaylistLoader.getFavoritePlaylist(context) - return if (playlists.isNotEmpty()) Home( - playlists, - HomeAdapter.FAVOURITES, - R.drawable.ic_favorite - ) else null - } override suspend fun artistInfo( name: String, @@ -148,4 +88,149 @@ class RepositoryImpl( album: String ): LastFmAlbum = lastFMService.albumInfo(artist, album) + @ExperimentalCoroutinesApi + override suspend fun homeSectionsFlow(): Flow>> { + val homes = MutableStateFlow>>(value = Result.Loading) + println("homeSections:Loading") + val homeSections = mutableListOf() + val sections = listOf( + topArtistsHome(), + topAlbumsHome(), + recentArtistsHome(), + recentAlbumsHome(), + suggestionsHome(), + favoritePlaylistHome(), + genresHome() + ) + for (section in sections) { + if (section.arrayList.isNotEmpty()) { + println("${section.homeSection} -> ${section.arrayList.size}") + homeSections.add(section) + } + } + if (homeSections.isEmpty()) { + homes.value = Result.Error + } else { + homes.value = Result.Success(homeSections) + } + return homes + } + + override suspend fun homeSections(): List { + val homeSections = mutableListOf() + val sections = listOf( + topArtistsHome(), + topAlbumsHome(), + recentArtistsHome(), + recentAlbumsHome(), + suggestionsHome(), + favoritePlaylistHome(), + genresHome() + ) + for (section in sections) { + if (section.arrayList.isNotEmpty()) { + println("${section.homeSection} -> ${section.arrayList.size}") + homeSections.add(section) + } + } + return homeSections + } + + suspend fun playlists(): Home { + val playlist = PlaylistLoader.getAllPlaylists(context) + return Home(playlist, TOP_ALBUMS) + } + + override suspend fun suggestionsHome(): Home { + val songs = + NotRecentlyPlayedPlaylist(context).getSongs(context).shuffled().takeUnless { + it.size > 9 + }?.take(9) ?: emptyList() + return Home(songs, SUGGESTIONS) + } + + override suspend fun genresHome(): Home { + val genres = GenreLoader.getAllGenres(context).shuffled() + return Home(genres, GENRES) + } + + + override suspend fun recentArtistsHome(): Home { + val artists = LastAddedSongsLoader.getLastAddedArtists(context).take(5) + return Home(artists, RECENT_ARTISTS) + } + + override suspend fun recentAlbumsHome(): Home { + val albums = LastAddedSongsLoader.getLastAddedAlbums(context).take(5) + return Home(albums, RECENT_ALBUMS) + } + + override suspend fun topAlbumsHome(): Home { + val albums = TopAndRecentlyPlayedTracksLoader.getTopAlbums(context).take(5) + return Home(albums, TOP_ALBUMS) + } + + override suspend fun topArtistsHome(): Home { + val artists = TopAndRecentlyPlayedTracksLoader.getTopArtists(context).take(5) + return Home(artists, TOP_ARTISTS) + } + + override suspend fun favoritePlaylistHome(): Home { + val playlists = PlaylistLoader.getFavoritePlaylist(context).take(5) + val songs = if (playlists.isNotEmpty()) + PlaylistSongsLoader.getPlaylistSongList(context, playlists[0]) + else emptyList() + + return Home(songs, FAVOURITES) + } + + override fun songsFlow(): Flow>> = flow { + emit(Result.Loading) + val data = SongLoader.getAllSongs(context) + if (data.isEmpty()) { + emit(Result.Error) + } else { + emit(Result.Success(data)) + } + } + + override fun albumsFlow(): Flow>> = flow { + emit(Result.Loading) + val data = AlbumLoader.getAllAlbums(context) + if (data.isEmpty()) { + emit(Result.Error) + } else { + emit(Result.Success(data)) + } + } + + override fun artistsFlow(): Flow>> = flow { + emit(Result.Loading) + val data = ArtistLoader.getAllArtists(context) + if (data.isEmpty()) { + emit(Result.Error) + } else { + emit(Result.Success(data)) + } + } + + override fun playlistsFlow(): Flow>> = flow { + emit(Result.Loading) + val data = PlaylistLoader.getAllPlaylists(context) + if (data.isEmpty()) { + emit(Result.Error) + } else { + emit(Result.Success(data)) + } + } + + override fun genresFlow(): Flow>> = flow { + emit(Result.Loading) + val data = GenreLoader.getAllGenres(context) + if (data.isEmpty()) { + emit(Result.Error) + } else { + emit(Result.Success(data)) + } + } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.kt b/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.kt index 984960df..2f5fc2a1 100644 --- a/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.kt +++ b/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.kt @@ -14,9 +14,11 @@ package code.name.monkey.retromusic.providers.interfaces +import code.name.monkey.retromusic.Result import code.name.monkey.retromusic.model.* import code.name.monkey.retromusic.network.model.LastFmAlbum import code.name.monkey.retromusic.network.model.LastFmArtist +import kotlinx.coroutines.flow.Flow /** * Created by hemanths on 11/08/17. @@ -47,17 +49,41 @@ interface Repository { suspend fun albumInfo(artist: String, album: String): LastFmAlbum suspend fun artistById(artistId: Int): Artist - suspend fun recentArtists(): Home? - suspend fun topArtists(): Home? + suspend fun recentArtists(): List - suspend fun topAlbums(): Home? + suspend fun topArtists(): List - suspend fun recentAlbums(): Home? + suspend fun topAlbums(): List - suspend fun favoritePlaylist(): Home? + suspend fun recentAlbums(): List - suspend fun suggestions(): Home? + suspend fun recentArtistsHome(): Home + + suspend fun topArtistsHome(): Home + + suspend fun topAlbumsHome(): Home + + suspend fun recentAlbumsHome(): Home + + suspend fun favoritePlaylistHome(): Home + + suspend fun suggestionsHome(): Home + + suspend fun genresHome(): Home + + suspend fun homeSections(): List + + suspend fun homeSectionsFlow(): Flow>> + + fun songsFlow(): Flow>> + + fun albumsFlow(): Flow>> + + fun artistsFlow(): Flow>> + + fun playlistsFlow(): Flow>> + + fun genresFlow(): Flow>> - suspend fun homeGenres(): Home? } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt b/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt index 91cb5d53..c09801b8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt +++ b/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt @@ -66,5 +66,5 @@ class BottomNavigationBarTinted @JvmOverloads constructor( } fun Int.addAlpha(): Int { - return ColorUtil.withAlpha(this, 0.12f) + return ColorUtil.withAlpha(this, 0.38f) } diff --git a/app/src/main/res/font/pacifico.xml b/app/src/main/res/font/pacifico.xml new file mode 100644 index 00000000..6cff80c8 --- /dev/null +++ b/app/src/main/res/font/pacifico.xml @@ -0,0 +1,7 @@ + + + diff --git a/app/src/main/res/layout/activity_main_content.xml b/app/src/main/res/layout/activity_main_content.xml index ffd74617..aee8d3b0 100644 --- a/app/src/main/res/layout/activity_main_content.xml +++ b/app/src/main/res/layout/activity_main_content.xml @@ -1,11 +1,28 @@ - + android:background="?colorSurface" + android:orientation="vertical"> + + + + + + + + diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml new file mode 100644 index 00000000..72796a35 --- /dev/null +++ b/app/src/main/res/layout/activity_settings.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_album_details.xml b/app/src/main/res/layout/fragment_album_details.xml index f84cb563..b81d1c65 100644 --- a/app/src/main/res/layout/fragment_album_details.xml +++ b/app/src/main/res/layout/fragment_album_details.xml @@ -1,140 +1,125 @@ - + android:layout_height="match_parent"> - + android:layout_height="wrap_content" + app:liftOnScroll="true"> - - - - - - + android:layout_height="wrap_content"> - + + + android:layout_height="48dp" /> + - + - - + - - - + android:orientation="vertical"> - + + + + + + + + + + + + + android:layout_marginTop="12dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/albumText" /> - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_artist_details.xml b/app/src/main/res/layout/fragment_artist_details.xml index 88b51edd..817c0003 100644 --- a/app/src/main/res/layout/fragment_artist_details.xml +++ b/app/src/main/res/layout/fragment_artist_details.xml @@ -1,125 +1,110 @@ - + android:layout_height="match_parent"> - + android:layout_height="wrap_content" + app:liftOnScroll="true"> - - - - - - + android:layout_height="wrap_content"> - + + + android:layout_height="48dp" /> + + - + - - - - - + android:orientation="vertical"> - + + + + + + + + + + - - - - - - - - - - - - + android:layout_marginTop="16dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/text" /> - - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_library.xml b/app/src/main/res/layout/fragment_library.xml index 844a8c1d..bc0ec2a8 100644 --- a/app/src/main/res/layout/fragment_library.xml +++ b/app/src/main/res/layout/fragment_library.xml @@ -1,63 +1,54 @@ - + android:layout_height="match_parent"> - + app:liftOnScroll="true"> - - - - - - - + app:layout_scrollFlags="scroll|enterAlways"> - + android:background="?attr/colorSurface" + app:navigationIcon="@drawable/ic_search" + app:popupTheme="?attr/toolbarPopupTheme" + app:title="@null" + tools:ignore="UnusedAttribute"> - + android:layout_gravity="center" + android:text="@string/app_name" + android:textStyle="bold" + android:textAppearance="@style/TextViewHeadline6" /> + - - - + + + - - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_main_settings.xml b/app/src/main/res/layout/fragment_main_settings.xml index cd2f3c29..421dc3da 100644 --- a/app/src/main/res/layout/fragment_main_settings.xml +++ b/app/src/main/res/layout/fragment_main_settings.xml @@ -1,6 +1,7 @@ + app:tint="?colorOnSecondary" + tools:tint="?attr/colorAccent" /> - + android:layout_height="match_parent"> - + android:layout_height="wrap_content" + app:liftOnScroll="true"> - - - - - - + app:layout_scrollFlags="scroll|enterAlways"> - + android:background="?attr/colorSurface" + app:navigationIcon="@drawable/ic_keyboard_backspace_black" + app:titleTextAppearance="@style/ToolbarTextAppearanceNormal" /> - + - + + - - + - + + + android:layout_marginBottom="16dp" + android:text="@string/empty_text_emoji" + android:textAppearance="@style/TextViewHeadline3" /> - - - - - - - - \ No newline at end of file + android:text="@string/no_songs" + android:textAppearance="@style/TextViewHeadline5" + android:textColor="?android:attr/textColorSecondary" + tools:visibility="visible" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_album_card.xml b/app/src/main/res/layout/item_album_card.xml index 403d512b..21ebef3d 100644 --- a/app/src/main/res/layout/item_album_card.xml +++ b/app/src/main/res/layout/item_album_card.xml @@ -9,10 +9,11 @@ @@ -24,21 +25,23 @@ android:scaleType="centerCrop" app:srcCompat="@drawable/default_album_art" tools:src="@tools:sample/avatars" /> + + - - - \ No newline at end of file diff --git a/app/src/main/res/layout/item_grid_genre.xml b/app/src/main/res/layout/item_grid_genre.xml index 408c8869..41771f35 100644 --- a/app/src/main/res/layout/item_grid_genre.xml +++ b/app/src/main/res/layout/item_grid_genre.xml @@ -12,7 +12,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:padding="16dp" - android:textAppearance="@style/TextViewHeadline6" + android:textAppearance="@style/TextViewSubtitle1" tools:text="@tools:sample/full_names" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_image.xml b/app/src/main/res/layout/item_image.xml index e6fdad1e..abd2797e 100644 --- a/app/src/main/res/layout/item_image.xml +++ b/app/src/main/res/layout/item_image.xml @@ -35,7 +35,9 @@ android:ellipsize="end" android:maxLines="1" android:padding="8dp" - android:textAppearance="@style/TextViewNormal" + android:textAppearance="@style/TextViewBody1" + android:textColor="?android:attr/textColorPrimary" + android:textStyle="bold" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/imageContainer" diff --git a/app/src/main/res/layout/item_suggestions.xml b/app/src/main/res/layout/item_suggestions.xml index 34042ea3..e506fd46 100644 --- a/app/src/main/res/layout/item_suggestions.xml +++ b/app/src/main/res/layout/item_suggestions.xml @@ -10,8 +10,7 @@ android:id="@+id/title" android:layout_width="0dp" android:layout_height="wrap_content" - android:paddingHorizontal="16dp" - android:paddingTop="16dp" + android:padding="16dp" android:text="@string/suggestion_songs" android:textAppearance="@style/TextViewHeadline6" android:textStyle="bold" @@ -20,18 +19,6 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - + app:layout_constraintTop_toBottomOf="@id/title"> + app:layout_constraintTop_toTopOf="@id/card6"> + app:layout_constraintTop_toTopOf="@id/card7"> - - \ No newline at end of file diff --git a/app/src/main/res/layout/section_recycler_view.xml b/app/src/main/res/layout/section_recycler_view.xml index 9107539b..852c6c48 100644 --- a/app/src/main/res/layout/section_recycler_view.xml +++ b/app/src/main/res/layout/section_recycler_view.xml @@ -5,47 +5,49 @@ android:id="@+id/recentArtistContainer" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical"> + android:orientation="vertical" + android:paddingBottom="12dp"> - - + app:layout_constraintTop_toTopOf="parent"> - + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/sliding_music_panel_layout.xml b/app/src/main/res/layout/sliding_music_panel_layout.xml index d0d7c7bf..24566b4f 100644 --- a/app/src/main/res/layout/sliding_music_panel_layout.xml +++ b/app/src/main/res/layout/sliding_music_panel_layout.xml @@ -49,7 +49,6 @@ android:layout_height="wrap_content" android:layout_gravity="bottom" android:elevation="0dp" - android:visibility="gone" app:itemHorizontalTranslationEnabled="false" app:itemIconTint="@drawable/bottom_navigation_item_colors" app:itemTextAppearanceActive="@style/BottomSheetItemTextAppearance" diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 3ee85b08..1458c415 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -16,11 +16,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".DrawerActivity"> - - - + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index eca70cfe..036d09bc 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index 2cbb8842..2e943031 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png index 912c27f2..7c57cfba 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png index 2cbb8842..2e943031 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index 7f7b6d05..7fd5e167 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png index 129090fc..293d6e10 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png index 7f7b6d05..7fd5e167 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 6e0f844e..975309b0 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png index c18aa6c8..26e875c9 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png index 6e0f844e..975309b0 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 5b423cb7..a20a78c2 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png index 4678e702..5c34c133 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png index 5b423cb7..a20a78c2 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 544a56bf..7b1f6de2 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png index 02a7dc5e..614c8a81 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png index 544a56bf..7b1f6de2 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/navigation/library_graph.xml b/app/src/main/res/navigation/library_graph.xml index 9749f4d2..d95d705c 100644 --- a/app/src/main/res/navigation/library_graph.xml +++ b/app/src/main/res/navigation/library_graph.xml @@ -8,7 +8,7 @@ + tools:layout="@layout/fragment_main_activity_recycler_view" /> + android:label="" + tools:layout="@layout/fragment_banner_home"/> \ No newline at end of file diff --git a/app/src/main/res/navigation/main_graph.xml b/app/src/main/res/navigation/main_graph.xml index 999edefa..beead4b8 100644 --- a/app/src/main/res/navigation/main_graph.xml +++ b/app/src/main/res/navigation/main_graph.xml @@ -52,7 +52,7 @@ + + + + - + + \ No newline at end of file diff --git a/app/src/main/res/navigation/settings_graph.xml b/app/src/main/res/navigation/settings_graph.xml index 513b5670..9e8ddbcc 100644 --- a/app/src/main/res/navigation/settings_graph.xml +++ b/app/src/main/res/navigation/settings_graph.xml @@ -69,7 +69,12 @@ + app:destination="@id/aboutActivity" + app:enterAnim="@anim/retro_fragment_open_enter" + app:exitAnim="@anim/retro_fragment_open_exit" + app:launchSingleTop="true" + app:popEnterAnim="@anim/retro_fragment_close_enter" + app:popExitAnim="@anim/retro_fragment_close_exit" /> - - - + - + + \ No newline at end of file diff --git a/app/src/main/res/transition/grid_exit_transition.xml b/app/src/main/res/transition/grid_exit_transition.xml new file mode 100644 index 00000000..6ff14dad --- /dev/null +++ b/app/src/main/res/transition/grid_exit_transition.xml @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-night-v27/styles.xml b/app/src/main/res/values-night-v27/styles.xml index 70132899..87c77add 100644 --- a/app/src/main/res/values-night-v27/styles.xml +++ b/app/src/main/res/values-night-v27/styles.xml @@ -15,11 +15,9 @@ \ No newline at end of file diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml index 5313087d..99e61bb2 100644 --- a/app/src/main/res/values-night/styles.xml +++ b/app/src/main/res/values-night/styles.xml @@ -15,11 +15,9 @@ diff --git a/app/src/main/res/values-v23/styles.xml b/app/src/main/res/values-v23/styles.xml index dee5c9fd..c70057ac 100644 --- a/app/src/main/res/values-v23/styles.xml +++ b/app/src/main/res/values-v23/styles.xml @@ -21,7 +21,6 @@ \ No newline at end of file diff --git a/app/src/main/res/values-v27/styles_parents.xml b/app/src/main/res/values-v27/styles_parents.xml index ca42d097..d346f69c 100644 --- a/app/src/main/res/values-v27/styles_parents.xml +++ b/app/src/main/res/values-v27/styles_parents.xml @@ -15,20 +15,18 @@