Added new icon
Fix bottom tabs showing rotating, coming notification or widgets
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 18 KiB |
|
@ -57,7 +57,6 @@ import code.name.monkey.retromusic.model.CategoryInfo
|
|||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.repository.PlaylistSongsLoader
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import code.name.monkey.retromusic.util.AppRater
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
|
@ -120,7 +119,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
|||
intent.getBooleanExtra(EXPAND_PANEL, false) &&
|
||||
PreferenceUtil.isExpandPanel
|
||||
) {
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.EXPAND)
|
||||
expandPanel()
|
||||
intent.removeExtra(EXPAND_PANEL)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ 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.dip
|
||||
import code.name.monkey.retromusic.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.peekHeightAnimate
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
|
@ -58,9 +59,9 @@ import code.name.monkey.retromusic.fragments.player.simple.SimplePlayerFragment
|
|||
import code.name.monkey.retromusic.fragments.player.tiny.TinyPlayerFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.CategoryInfo
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState.*
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.*
|
||||
import kotlinx.android.synthetic.main.sliding_music_panel_layout.*
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
@ -116,14 +117,13 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
chooseFragmentForTheme()
|
||||
setupSlidingUpPanel()
|
||||
setupBottomSheet()
|
||||
updatePanelState()
|
||||
updateColor()
|
||||
|
||||
val themeColor = ATHUtil.resolveColor(this, android.R.attr.windowBackground, Color.GRAY)
|
||||
dimBackground.setBackgroundColor(ColorUtil.withAlpha(themeColor, 0.5f))
|
||||
dimBackground.setOnClickListener {
|
||||
println("dimBackground")
|
||||
libraryViewModel.setPanelState(COLLAPSED_WITH)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,6 +137,9 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
if (nowPlayingScreen != PreferenceUtil.nowPlayingScreen) {
|
||||
postRecreate()
|
||||
}
|
||||
if (bottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
setMiniPlayerAlphaProgress(1f)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -160,6 +163,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
|
||||
fun expandPanel() {
|
||||
bottomSheetBehavior.state = STATE_EXPANDED
|
||||
setMiniPlayerAlphaProgress(1f)
|
||||
}
|
||||
|
||||
private fun setMiniPlayerAlphaProgress(progress: Float) {
|
||||
|
@ -214,12 +218,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
println("onServiceConnected")
|
||||
if (bottomNavigationView.isVisible) {
|
||||
libraryViewModel.setPanelState(COLLAPSED_WITH)
|
||||
} else {
|
||||
libraryViewModel.setPanelState(COLLAPSED_WITHOUT)
|
||||
}
|
||||
hideBottomBar(false)
|
||||
}
|
||||
})
|
||||
} // don't call hideBottomBar(true) here as it causes a bug with the SlidingUpPanelLayout
|
||||
|
@ -227,16 +226,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
|
||||
override fun onQueueChanged() {
|
||||
super.onQueueChanged()
|
||||
if (MusicPlayerRemote.playingQueue.isEmpty()) {
|
||||
libraryViewModel.setPanelState(HIDE)
|
||||
} else {
|
||||
if (bottomNavigationView.isVisible) {
|
||||
println("onQueueChanged")
|
||||
libraryViewModel.setPanelState(COLLAPSED_WITH)
|
||||
} else {
|
||||
libraryViewModel.setPanelState(COLLAPSED_WITHOUT)
|
||||
}
|
||||
}
|
||||
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
@ -339,54 +329,35 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
})
|
||||
}
|
||||
|
||||
private fun updatePanelState() {
|
||||
libraryViewModel.panelState.observe(this, { state ->
|
||||
val isQueueEmpty = MusicPlayerRemote.playingQueue.isEmpty()
|
||||
when (state) {
|
||||
EXPAND -> {
|
||||
println("EXPAND")
|
||||
expandPanel()
|
||||
bottomNavigationView.translateXAnimate(150f)
|
||||
}
|
||||
HIDE -> {
|
||||
println("HIDE")
|
||||
fun setBottomBarVisibility(visible: Int) {
|
||||
bottomNavigationView.visibility = visible
|
||||
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
||||
}
|
||||
|
||||
private fun hideBottomBar(hide: Boolean) {
|
||||
val heightOfBar = dip(R.dimen.mini_player_height)
|
||||
val heightOfBarWithTabs = dip(R.dimen.mini_player_height_expanded)
|
||||
val isVisible = bottomNavigationView.isVisible
|
||||
if (hide) {
|
||||
bottomSheetBehavior.isHideable = true
|
||||
bottomSheetBehavior.peekHeight = 0
|
||||
ViewCompat.setElevation(slidingPanel, 0f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
collapsePanel()
|
||||
} else {
|
||||
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
bottomSheetBehavior.isHideable = false
|
||||
if (isVisible) {
|
||||
bottomSheetBehavior.peekHeightAnimate(heightOfBarWithTabs)
|
||||
bottomNavigationView.translateXAnimate(0f)
|
||||
bottomSheetBehavior.isHideable = true
|
||||
bottomSheetBehavior.peekHeightAnimate(0)
|
||||
bottomSheetBehavior.state = STATE_COLLAPSED
|
||||
ViewCompat.setElevation(slidingPanel, 0f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
}
|
||||
COLLAPSED_WITH -> {
|
||||
println("COLLAPSED_WITH")
|
||||
val heightOfBar = bottomNavigationView.height
|
||||
val height = if (isQueueEmpty) 0 else (heightOfBar * 2) - 24
|
||||
ViewCompat.setElevation(bottomNavigationView, 20f)
|
||||
ViewCompat.setElevation(slidingPanel, 20f)
|
||||
bottomSheetBehavior.isHideable = false
|
||||
bottomSheetBehavior.peekHeightAnimate(height)
|
||||
bottomNavigationView.translateXAnimate(0f)
|
||||
}
|
||||
COLLAPSED_WITHOUT -> {
|
||||
println("COLLAPSED_WITHOUT")
|
||||
val heightOfBar = bottomNavigationView.height
|
||||
val height = if (isQueueEmpty) 0 else heightOfBar - 24
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
ViewCompat.setElevation(slidingPanel, 10f)
|
||||
bottomSheetBehavior.isHideable = false
|
||||
bottomSheetBehavior.peekHeightAnimate(height)
|
||||
bottomNavigationView.translateXAnimate(150f)
|
||||
}
|
||||
else -> {
|
||||
println("else")
|
||||
bottomSheetBehavior.isHideable = true
|
||||
bottomSheetBehavior.peekHeight = 0
|
||||
collapsePanel()
|
||||
ViewCompat.setElevation(slidingPanel, 0f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
} else {
|
||||
bottomSheetBehavior.peekHeightAnimate(heightOfBar)
|
||||
bottomNavigationView.translateXAnimate(500f)
|
||||
}
|
||||
ViewCompat.setElevation(slidingPanel, 10f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun chooseFragmentForTheme() {
|
||||
|
|
|
@ -14,10 +14,8 @@
|
|||
*/
|
||||
package code.name.monkey.retromusic.adapter.playlist
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.AsyncTask
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
|
@ -26,6 +24,7 @@ import android.view.ViewGroup
|
|||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -41,16 +40,17 @@ import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
|
|||
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.interfaces.IPlaylistClickListener
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.repository.PlaylistSongsLoader
|
||||
import code.name.monkey.retromusic.util.AutoGeneratedPlaylistBitmap
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class PlaylistAdapter(
|
||||
private val activity: FragmentActivity,
|
||||
var dataSet: List<PlaylistWithSongs>,
|
||||
private var dataSet: List<PlaylistWithSongs>,
|
||||
private var itemLayoutRes: Int,
|
||||
ICabHolder: ICabHolder?,
|
||||
private val listener: IPlaylistClickListener
|
||||
|
@ -102,7 +102,7 @@ class PlaylistAdapter(
|
|||
} else {
|
||||
holder.menu?.show()
|
||||
}
|
||||
// PlaylistBitmapLoader(this, holder, playlist).execute()
|
||||
//playlistBitmapLoader(activity, holder, playlist)
|
||||
}
|
||||
|
||||
private fun getIconRes(): Drawable = TintHelper.createTintedDrawable(
|
||||
|
@ -183,28 +183,35 @@ class PlaylistAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
class PlaylistBitmapLoader(
|
||||
private var adapter: PlaylistAdapter,
|
||||
private var viewHolder: ViewHolder,
|
||||
private var playlist: Playlist
|
||||
) : AsyncTask<Void, Void, Bitmap>() {
|
||||
private fun playlistBitmapLoader(
|
||||
activity: FragmentActivity,
|
||||
viewHolder: ViewHolder,
|
||||
playlist: PlaylistWithSongs
|
||||
) {
|
||||
|
||||
override fun doInBackground(vararg params: Void?): Bitmap {
|
||||
val songs = PlaylistSongsLoader.getPlaylistSongList(adapter.activity, playlist)
|
||||
return AutoGeneratedPlaylistBitmap.getBitmap(adapter.activity, songs, false, false)
|
||||
activity.lifecycleScope.launch(IO) {
|
||||
val songs = playlist.songs.toSongs()
|
||||
val bitmap = AutoGeneratedPlaylistBitmap.getBitmap(activity, songs, false, false)
|
||||
withContext(Main) { viewHolder.image?.setImageBitmap(bitmap) }
|
||||
}
|
||||
|
||||
override fun onPostExecute(result: Bitmap?) {
|
||||
super.onPostExecute(result)
|
||||
viewHolder.image?.setImageBitmap(result)
|
||||
val color = RetroColorUtil.getColor(
|
||||
RetroColorUtil.generatePalette(
|
||||
result
|
||||
),
|
||||
ATHUtil.resolveColor(adapter.activity, R.attr.colorSurface)
|
||||
)
|
||||
viewHolder.paletteColorContainer?.setBackgroundColor(color)
|
||||
}
|
||||
/*
|
||||
override fun doInBackground(vararg params: Void?): Bitmap {
|
||||
val songs = playlist.songs.toSongs()
|
||||
return AutoGeneratedPlaylistBitmap.getBitmap(activity, songs, false, false)
|
||||
}
|
||||
|
||||
override fun onPostExecute(result: Bitmap?) {
|
||||
super.onPostExecute(result)
|
||||
viewHolder.image?.setImageBitmap(result)
|
||||
val color = RetroColorUtil.getColor(
|
||||
RetroColorUtil.generatePalette(
|
||||
result
|
||||
),
|
||||
ATHUtil.resolveColor(activity, R.attr.colorSurface)
|
||||
)
|
||||
viewHolder.paletteColorContainer?.setBackgroundColor(color)
|
||||
}*/
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -30,6 +30,7 @@ import code.name.monkey.retromusic.appwidgets.base.BaseAppWidget
|
|||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.service.MusicService.*
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.animation.GlideAnimation
|
||||
|
@ -193,8 +194,11 @@ class AppWidgetBig : BaseAppWidget() {
|
|||
* Link up various button actions using [PendingIntent].
|
||||
*/
|
||||
private fun linkButtons(context: Context, views: RemoteViews) {
|
||||
val action =
|
||||
Intent(context, MainActivity::class.java).putExtra(MainActivity.EXPAND_PANEL, true)
|
||||
val action = Intent(context, MainActivity::class.java)
|
||||
.putExtra(
|
||||
MainActivity.EXPAND_PANEL,
|
||||
PreferenceUtil.isExpandPanel
|
||||
)
|
||||
var pendingIntent: PendingIntent
|
||||
|
||||
val serviceName = ComponentName(context, MusicService::class.java)
|
||||
|
|
|
@ -32,6 +32,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
|||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.service.MusicService.*
|
||||
import code.name.monkey.retromusic.util.ImageUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.animation.GlideAnimation
|
||||
|
@ -217,7 +218,11 @@ class AppWidgetCard : BaseAppWidget() {
|
|||
* Link up various button actions using [PendingIntent].
|
||||
*/
|
||||
private fun linkButtons(context: Context, views: RemoteViews) {
|
||||
val action: Intent = Intent(context, MainActivity::class.java).putExtra("expand", true)
|
||||
val action = Intent(context, MainActivity::class.java)
|
||||
.putExtra(
|
||||
MainActivity.EXPAND_PANEL,
|
||||
PreferenceUtil.isExpandPanel
|
||||
)
|
||||
var pendingIntent: PendingIntent
|
||||
|
||||
val serviceName = ComponentName(context, MusicService::class.java)
|
||||
|
|
|
@ -33,6 +33,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
|||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.service.MusicService.*
|
||||
import code.name.monkey.retromusic.util.ImageUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.animation.GlideAnimation
|
||||
|
@ -207,7 +208,11 @@ class AppWidgetClassic : BaseAppWidget() {
|
|||
* Link up various button actions using [PendingIntent].
|
||||
*/
|
||||
private fun linkButtons(context: Context, views: RemoteViews) {
|
||||
val action = Intent(context, MainActivity::class.java).putExtra("expand", true)
|
||||
val action = Intent(context, MainActivity::class.java)
|
||||
.putExtra(
|
||||
MainActivity.EXPAND_PANEL,
|
||||
PreferenceUtil.isExpandPanel
|
||||
)
|
||||
var pendingIntent: PendingIntent
|
||||
|
||||
val serviceName = ComponentName(context, MusicService::class.java)
|
||||
|
|
|
@ -31,6 +31,7 @@ import code.name.monkey.retromusic.glide.SongGlideRequest
|
|||
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.service.MusicService.*
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.animation.GlideAnimation
|
||||
|
@ -192,7 +193,11 @@ class AppWidgetSmall : BaseAppWidget() {
|
|||
* Link up various button actions using [PendingIntent].
|
||||
*/
|
||||
private fun linkButtons(context: Context, views: RemoteViews) {
|
||||
val action = Intent(context, MainActivity::class.java).putExtra("expand", true)
|
||||
val action = Intent(context, MainActivity::class.java)
|
||||
.putExtra(
|
||||
MainActivity.EXPAND_PANEL,
|
||||
PreferenceUtil.isExpandPanel
|
||||
)
|
||||
var pendingIntent: PendingIntent
|
||||
|
||||
val serviceName = ComponentName(context, MusicService::class.java)
|
||||
|
|
|
@ -28,6 +28,7 @@ import code.name.monkey.retromusic.activities.MainActivity
|
|||
import code.name.monkey.retromusic.appwidgets.base.BaseAppWidget
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.service.MusicService.*
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
|
||||
class AppWidgetText : BaseAppWidget() {
|
||||
|
@ -77,7 +78,11 @@ class AppWidgetText : BaseAppWidget() {
|
|||
* Link up various button actions using [PendingIntent].
|
||||
*/
|
||||
private fun linkButtons(context: Context, views: RemoteViews) {
|
||||
val action = Intent(context, MainActivity::class.java).putExtra("expand", true)
|
||||
val action = Intent(context, MainActivity::class.java)
|
||||
.putExtra(
|
||||
MainActivity.EXPAND_PANEL,
|
||||
PreferenceUtil.isExpandPanel
|
||||
)
|
||||
var pendingIntent: PendingIntent
|
||||
|
||||
val serviceName = ComponentName(context, MusicService::class.java)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package code.name.monkey.retromusic.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.annotation.DimenRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
|
@ -34,3 +35,7 @@ inline fun <reified T : Any> Activity.extraNotNull(key: String, default: T? = nu
|
|||
val value = intent?.extras?.get(key)
|
||||
requireNotNull(if (value is T) value else default) { key }
|
||||
}
|
||||
|
||||
fun Activity.dip(@DimenRes id: Int): Int {
|
||||
return resources.getDimensionPixelSize(id)
|
||||
}
|
|
@ -44,7 +44,7 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
|||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
mainActivity.setBottomBarVisibility(View.GONE)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
progressIndicator.hide()
|
||||
when (args.type) {
|
||||
|
|
|
@ -60,11 +60,6 @@ class LibraryViewModel(
|
|||
private val genres = MutableLiveData<List<Genre>>()
|
||||
private val searchResults = MutableLiveData<List<Any>>()
|
||||
val paletteColor: LiveData<Int> = _paletteColor
|
||||
val panelState: MutableLiveData<NowPlayingPanelState> = MutableLiveData<NowPlayingPanelState>()
|
||||
|
||||
fun setPanelState(state: NowPlayingPanelState) {
|
||||
panelState.postValue(state)
|
||||
}
|
||||
|
||||
init {
|
||||
loadLibraryContent()
|
||||
|
|
|
@ -17,7 +17,11 @@ package code.name.monkey.retromusic.fragments.albums
|
|||
import android.app.ActivityOptions
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.SubMenu
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.text.HtmlCompat
|
||||
|
@ -59,14 +63,12 @@ import code.name.monkey.retromusic.model.Artist
|
|||
import code.name.monkey.retromusic.network.Result
|
||||
import code.name.monkey.retromusic.network.model.LastFmAlbum
|
||||
import code.name.monkey.retromusic.repository.RealRepository
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.android.material.transition.MaterialContainerTransform
|
||||
import java.util.*
|
||||
import kotlinx.android.synthetic.main.fragment_album_content.*
|
||||
import kotlinx.android.synthetic.main.fragment_album_details.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -75,6 +77,7 @@ import kotlinx.coroutines.withContext
|
|||
import org.koin.android.ext.android.get
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import java.util.*
|
||||
|
||||
class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_details),
|
||||
IAlbumClickListener {
|
||||
|
@ -90,11 +93,6 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
private val savedSortOrder: String
|
||||
get() = PreferenceUtil.albumDetailSongSortOrder
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
}
|
||||
|
||||
private fun setUpTransitions() {
|
||||
val transform = MaterialContainerTransform()
|
||||
transform.setAllContainerColors(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface))
|
||||
|
@ -109,6 +107,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
mainActivity.setBottomBarVisibility(View.GONE)
|
||||
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
toolbar.title = " "
|
||||
|
|
|
@ -51,14 +51,11 @@ import code.name.monkey.retromusic.model.Artist
|
|||
import code.name.monkey.retromusic.network.Result
|
||||
import code.name.monkey.retromusic.network.model.LastFmArtist
|
||||
import code.name.monkey.retromusic.repository.RealRepository
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import code.name.monkey.retromusic.util.CustomArtistImageUtil
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.android.material.transition.MaterialContainerTransform
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlinx.android.synthetic.main.fragment_artist_content.*
|
||||
import kotlinx.android.synthetic.main.fragment_artist_details.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -67,6 +64,8 @@ import kotlinx.coroutines.withContext
|
|||
import org.koin.android.ext.android.get
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_details),
|
||||
IAlbumClickListener {
|
||||
|
@ -91,22 +90,21 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d
|
|||
super.onCreate(savedInstanceState)
|
||||
setUpTransitions()
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
mainActivity.setBottomBarVisibility(View.GONE)
|
||||
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
|
||||
toolbar.title = null
|
||||
|
||||
setupRecyclerView()
|
||||
|
||||
ViewCompat.setTransitionName(container, "artist")
|
||||
postponeEnterTransition()
|
||||
detailsViewModel.getArtist().observe(viewLifecycleOwner, Observer {
|
||||
startPostponedEnterTransition()
|
||||
showArtist(it)
|
||||
})
|
||||
setupRecyclerView()
|
||||
|
||||
playAction.apply {
|
||||
setOnClickListener { MusicPlayerRemote.openQueue(artist.songs, 0, true) }
|
||||
|
|
|
@ -61,8 +61,7 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
println("AbsRecyclerViewFragment")
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITH)
|
||||
mainActivity.setBottomBarVisibility(View.VISIBLE)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
mainActivity.supportActionBar?.title = null
|
||||
initLayoutManager()
|
||||
|
|
|
@ -75,7 +75,6 @@ import code.name.monkey.retromusic.misc.DialogAsyncTask;
|
|||
import code.name.monkey.retromusic.misc.UpdateToastMediaScannerCompletionListener;
|
||||
import code.name.monkey.retromusic.misc.WrappedAsyncTaskLoader;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState;
|
||||
import code.name.monkey.retromusic.util.DensityUtil;
|
||||
import code.name.monkey.retromusic.util.FileUtil;
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||
|
@ -166,7 +165,7 @@ public class FoldersFragment extends AbsMainActivityFragment
|
|||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
getMainActivity().addMusicServiceEventListener(getLibraryViewModel());
|
||||
getLibraryViewModel().setPanelState(NowPlayingPanelState.COLLAPSED_WITH);
|
||||
getMainActivity().setBottomBarVisibility(View.VISIBLE);
|
||||
getMainActivity().setSupportActionBar(toolbar);
|
||||
getMainActivity().getSupportActionBar().setTitle(null);
|
||||
setStatusBarColorAuto(view);
|
||||
|
|
|
@ -47,9 +47,9 @@ class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_
|
|||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
mainActivity.setBottomBarVisibility(View.GONE)
|
||||
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
progressIndicator.hide()
|
||||
setupRecyclerView()
|
||||
detailsViewModel.getSongs().observe(viewLifecycleOwner, androidx.lifecycle.Observer {
|
||||
|
|
|
@ -52,8 +52,7 @@ class HomeFragment :
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
println("AbsMainActivityFragment")
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITH)
|
||||
mainActivity.setBottomBarVisibility(View.VISIBLE)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
mainActivity.supportActionBar?.title = null
|
||||
setStatusBarColorAuto(view)
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.os.Bundle
|
|||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
|
@ -40,8 +41,7 @@ class LibraryFragment : AbsMainActivityFragment(R.layout.fragment_library) {
|
|||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
retainInstance = true
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITH)
|
||||
mainActivity.setBottomBarVisibility(View.VISIBLE)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
mainActivity.supportActionBar?.title = null
|
||||
toolbar.setNavigationOnClickListener {
|
||||
|
|
|
@ -48,14 +48,12 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
mainActivity.setBottomBarVisibility(View.GONE)
|
||||
mainActivity.addMusicServiceEventListener(viewModel)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
|
||||
ViewCompat.setTransitionName(container, "playlist")
|
||||
playlist = arguments.extraPlaylist
|
||||
toolbar.title = playlist.playlistEntity.playlistName
|
||||
|
||||
setUpRecyclerView()
|
||||
viewModel.getSongs().observe(viewLifecycleOwner, {
|
||||
songs(it.toSongs())
|
||||
|
|
|
@ -61,7 +61,7 @@ class PlaylistsFragment :
|
|||
return PlaylistAdapter(
|
||||
requireActivity(),
|
||||
ArrayList(),
|
||||
R.layout.item_list,
|
||||
itemLayoutRes(),
|
||||
null,
|
||||
this
|
||||
)
|
||||
|
|
|
@ -22,7 +22,6 @@ import android.text.Editable
|
|||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat.getSystemService
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
|
@ -35,11 +34,10 @@ import code.name.monkey.retromusic.extensions.accentColor
|
|||
import code.name.monkey.retromusic.extensions.dipToPix
|
||||
import code.name.monkey.retromusic.extensions.showToast
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import kotlinx.android.synthetic.main.fragment_search.*
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlinx.android.synthetic.main.fragment_search.*
|
||||
|
||||
class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWatcher {
|
||||
companion object {
|
||||
|
@ -52,7 +50,7 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
mainActivity.setBottomBarVisibility(View.GONE)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
libraryViewModel.clearSearchResult()
|
||||
setupRecyclerView()
|
||||
|
@ -86,7 +84,7 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
searchAdapter = SearchAdapter(requireActivity() as AppCompatActivity, emptyList())
|
||||
searchAdapter = SearchAdapter(requireActivity(), emptyList())
|
||||
searchAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onChanged() {
|
||||
super.onChanged()
|
||||
|
|
|
@ -55,7 +55,7 @@ class PlayingNotificationImpl : PlayingNotification() {
|
|||
if (isFavorite) R.drawable.ic_favorite else R.drawable.ic_favorite_border
|
||||
|
||||
val action = Intent(service, MainActivity::class.java)
|
||||
action.putExtra(MainActivity.EXPAND_PANEL, true)
|
||||
action.putExtra(MainActivity.EXPAND_PANEL, PreferenceUtil.isExpandPanel)
|
||||
action.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
val clickIntent =
|
||||
PendingIntent.getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
|
|
@ -73,7 +73,7 @@ class PlayingNotificationOreo : PlayingNotification() {
|
|||
val notificationLayoutBig = getCombinedRemoteViews(false, song)
|
||||
|
||||
val action = Intent(service, MainActivity::class.java)
|
||||
action.putExtra(MainActivity.EXPAND_PANEL, true)
|
||||
action.putExtra(MainActivity.EXPAND_PANEL, PreferenceUtil.isExpandPanel)
|
||||
action.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
|
||||
val clickIntent = PendingIntent
|
||||
|
|
|
@ -8,43 +8,47 @@ import android.graphics.Paint;
|
|||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
|
||||
public class AutoGeneratedPlaylistBitmap {
|
||||
private static final String TAG = "AutoGeneratedPB";
|
||||
private static final String TAG = "AutoGeneratedPB";
|
||||
|
||||
/*
|
||||
public static Bitmap getBitmapWithCollectionFrame(Context context, List<Song> songPlaylist, boolean round, boolean blur) {
|
||||
Bitmap bitmap = getBitmap(context,songPlaylist,round,blur);
|
||||
int w = bitmap.getWidth();
|
||||
Bitmap ret = Bitmap.createBitmap(w,w,Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
*/
|
||||
public static Bitmap getBitmap(
|
||||
Context context, List<Song> songPlaylist, boolean round, boolean blur) {
|
||||
if (songPlaylist == null) return null;
|
||||
long start = System.currentTimeMillis();
|
||||
// lấy toàn bộ album id, loại bỏ trùng nhau
|
||||
List<Long> albumID = new ArrayList<>();
|
||||
for (Song song : songPlaylist) {
|
||||
if (!albumID.contains(song.getAlbumId())) albumID.add(song.getAlbumId());
|
||||
/*
|
||||
public static Bitmap getBitmapWithCollectionFrame(Context context, List<Song> songPlaylist, boolean round, boolean blur) {
|
||||
Bitmap bitmap = getBitmap(context,songPlaylist,round,blur);
|
||||
int w = bitmap.getWidth();
|
||||
Bitmap ret = Bitmap.createBitmap(w,w,Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
*/
|
||||
public static Bitmap getBitmap(
|
||||
Context context, List<Song> songPlaylist, boolean round, boolean blur) {
|
||||
if (songPlaylist == null || songPlaylist.isEmpty()) return null;
|
||||
long start = System.currentTimeMillis();
|
||||
// lấy toàn bộ album id, loại bỏ trùng nhau
|
||||
List<Long> albumID = new ArrayList<>();
|
||||
for (Song song : songPlaylist) {
|
||||
if (!albumID.contains(song.getAlbumId())) albumID.add(song.getAlbumId());
|
||||
}
|
||||
|
||||
long start2 = System.currentTimeMillis() - start;
|
||||
long start2 = System.currentTimeMillis() - start;
|
||||
|
||||
// lấy toàn bộ art tồn tại
|
||||
List<Bitmap> art = new ArrayList<Bitmap>();
|
||||
for (Long id : albumID) {
|
||||
Bitmap bitmap = getBitmapWithAlbumId(context, id);
|
||||
if (bitmap != null) art.add(bitmap);
|
||||
if (art.size() == 6) break;
|
||||
}
|
||||
return MergedImageUtils.INSTANCE.joinImages(art);
|
||||
// lấy toàn bộ art tồn tại
|
||||
List<Bitmap> art = new ArrayList<Bitmap>();
|
||||
for (Long id : albumID) {
|
||||
Bitmap bitmap = getBitmapWithAlbumId(context, id);
|
||||
if (bitmap != null) art.add(bitmap);
|
||||
if (art.size() == 6) break;
|
||||
}
|
||||
return MergedImageUtils.INSTANCE.joinImages(art);
|
||||
/*
|
||||
|
||||
long start3 = System.currentTimeMillis() - start2 - start;
|
||||
|
@ -70,119 +74,119 @@ public class AutoGeneratedPlaylistBitmap {
|
|||
|
||||
Log.d(TAG, "getBitmap: time = " + (System.currentTimeMillis() - start) + ", start2 = " + start2 + ", start3 = " + start3);
|
||||
return ret;*/
|
||||
}
|
||||
}
|
||||
|
||||
private static Bitmap getBitmapCollection(ArrayList<Bitmap> art, boolean round) {
|
||||
long start = System.currentTimeMillis();
|
||||
// lấy kích thước là kích thước của bitmap lớn nhất
|
||||
int max_width = art.get(0).getWidth();
|
||||
for (Bitmap b : art) if (max_width < b.getWidth()) max_width = b.getWidth();
|
||||
Bitmap bitmap = Bitmap.createBitmap(max_width, max_width, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
Paint paint = new Paint();
|
||||
paint.setAntiAlias(false);
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(max_width / 100);
|
||||
paint.setColor(0xffffffff);
|
||||
switch (art.size()) {
|
||||
case 2:
|
||||
canvas.drawBitmap(art.get(1), null, new Rect(0, 0, max_width, max_width), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(0), null, new Rect(-max_width / 2, 0, max_width / 2, max_width), null);
|
||||
canvas.drawLine(max_width / 2, 0, max_width / 2, max_width, paint);
|
||||
break;
|
||||
case 3:
|
||||
canvas.drawBitmap(
|
||||
art.get(0), null, new Rect(-max_width / 4, 0, 3 * max_width / 4, max_width), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(1), null, new Rect(max_width / 2, 0, max_width, max_width / 2), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(2), null, new Rect(max_width / 2, max_width / 2, max_width, max_width), null);
|
||||
canvas.drawLine(max_width / 2, 0, max_width / 2, max_width, paint);
|
||||
canvas.drawLine(max_width / 2, max_width / 2, max_width, max_width / 2, paint);
|
||||
break;
|
||||
case 4:
|
||||
canvas.drawBitmap(art.get(0), null, new Rect(0, 0, max_width / 2, max_width / 2), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(1), null, new Rect(max_width / 2, 0, max_width, max_width / 2), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(2), null, new Rect(0, max_width / 2, max_width / 2, max_width), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(3), null, new Rect(max_width / 2, max_width / 2, max_width, max_width), null);
|
||||
canvas.drawLine(max_width / 2, 0, max_width / 2, max_width, paint);
|
||||
canvas.drawLine(0, max_width / 2, max_width, max_width / 2, paint);
|
||||
break;
|
||||
// default: canvas.drawBitmap(art.get(0),null,new Rect(0,0,max_width,max_width),null);
|
||||
default:
|
||||
|
||||
// độ rộng của des bitmap
|
||||
float w = (float) (Math.sqrt(2) / 2 * max_width);
|
||||
float b = (float) (max_width / Math.sqrt(5));
|
||||
// khoảng cách định nghĩa, dùng để tính vị trí tâm của 4 bức hình xung quanh
|
||||
float d = (float) (max_width * (0.5f - 1 / Math.sqrt(10)));
|
||||
float deg = 45;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
canvas.save();
|
||||
switch (i) {
|
||||
case 0:
|
||||
canvas.translate(max_width / 2, max_width / 2);
|
||||
canvas.rotate(deg);
|
||||
// b = (float) (max_width*Math.sqrt(2/5f));
|
||||
canvas.drawBitmap(art.get(0), null, new RectF(-b / 2, -b / 2, b / 2, b / 2), null);
|
||||
break;
|
||||
case 1:
|
||||
canvas.translate(d, 0);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(w / 2, -w / 2, w / 2, w / 2, paint);
|
||||
break;
|
||||
private static Bitmap getBitmapCollection(ArrayList<Bitmap> art, boolean round) {
|
||||
long start = System.currentTimeMillis();
|
||||
// lấy kích thước là kích thước của bitmap lớn nhất
|
||||
int max_width = art.get(0).getWidth();
|
||||
for (Bitmap b : art) if (max_width < b.getWidth()) max_width = b.getWidth();
|
||||
Bitmap bitmap = Bitmap.createBitmap(max_width, max_width, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
Paint paint = new Paint();
|
||||
paint.setAntiAlias(false);
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(max_width / 100);
|
||||
paint.setColor(0xffffffff);
|
||||
switch (art.size()) {
|
||||
case 2:
|
||||
canvas.translate(max_width, d);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(-w / 2, w / 2, w / 2, w / 2, paint);
|
||||
break;
|
||||
canvas.drawBitmap(art.get(1), null, new Rect(0, 0, max_width, max_width), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(0), null, new Rect(-max_width / 2, 0, max_width / 2, max_width), null);
|
||||
canvas.drawLine(max_width / 2, 0, max_width / 2, max_width, paint);
|
||||
break;
|
||||
case 3:
|
||||
canvas.translate(max_width - d, max_width);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(-w / 2, -w / 2, -w / 2, w / 2, paint);
|
||||
break;
|
||||
canvas.drawBitmap(
|
||||
art.get(0), null, new Rect(-max_width / 4, 0, 3 * max_width / 4, max_width), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(1), null, new Rect(max_width / 2, 0, max_width, max_width / 2), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(2), null, new Rect(max_width / 2, max_width / 2, max_width, max_width), null);
|
||||
canvas.drawLine(max_width / 2, 0, max_width / 2, max_width, paint);
|
||||
canvas.drawLine(max_width / 2, max_width / 2, max_width, max_width / 2, paint);
|
||||
break;
|
||||
case 4:
|
||||
canvas.translate(0, max_width - d);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(-w / 2, -w / 2, w / 2, -w / 2, paint);
|
||||
break;
|
||||
}
|
||||
canvas.restore();
|
||||
canvas.drawBitmap(art.get(0), null, new Rect(0, 0, max_width / 2, max_width / 2), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(1), null, new Rect(max_width / 2, 0, max_width, max_width / 2), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(2), null, new Rect(0, max_width / 2, max_width / 2, max_width), null);
|
||||
canvas.drawBitmap(
|
||||
art.get(3), null, new Rect(max_width / 2, max_width / 2, max_width, max_width), null);
|
||||
canvas.drawLine(max_width / 2, 0, max_width / 2, max_width, paint);
|
||||
canvas.drawLine(0, max_width / 2, max_width, max_width / 2, paint);
|
||||
break;
|
||||
// default: canvas.drawBitmap(art.get(0),null,new Rect(0,0,max_width,max_width),null);
|
||||
default:
|
||||
|
||||
// độ rộng của des bitmap
|
||||
float w = (float) (Math.sqrt(2) / 2 * max_width);
|
||||
float b = (float) (max_width / Math.sqrt(5));
|
||||
// khoảng cách định nghĩa, dùng để tính vị trí tâm của 4 bức hình xung quanh
|
||||
float d = (float) (max_width * (0.5f - 1 / Math.sqrt(10)));
|
||||
float deg = 45;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
canvas.save();
|
||||
switch (i) {
|
||||
case 0:
|
||||
canvas.translate(max_width / 2, max_width / 2);
|
||||
canvas.rotate(deg);
|
||||
// b = (float) (max_width*Math.sqrt(2/5f));
|
||||
canvas.drawBitmap(art.get(0), null, new RectF(-b / 2, -b / 2, b / 2, b / 2), null);
|
||||
break;
|
||||
case 1:
|
||||
canvas.translate(d, 0);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(w / 2, -w / 2, w / 2, w / 2, paint);
|
||||
break;
|
||||
case 2:
|
||||
canvas.translate(max_width, d);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(-w / 2, w / 2, w / 2, w / 2, paint);
|
||||
break;
|
||||
case 3:
|
||||
canvas.translate(max_width - d, max_width);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(-w / 2, -w / 2, -w / 2, w / 2, paint);
|
||||
break;
|
||||
case 4:
|
||||
canvas.translate(0, max_width - d);
|
||||
canvas.rotate(deg);
|
||||
canvas.drawBitmap(art.get(i), null, new RectF(-w / 2, -w / 2, w / 2, w / 2), null);
|
||||
paint.setAntiAlias(true);
|
||||
canvas.drawLine(-w / 2, -w / 2, w / 2, -w / 2, paint);
|
||||
break;
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "getBitmapCollection: smalltime = " + (System.currentTimeMillis() - start));
|
||||
if (round) return BitmapEditor.getRoundedCornerBitmap(bitmap, bitmap.getWidth() / 40);
|
||||
else return bitmap;
|
||||
}
|
||||
|
||||
private static Bitmap getBitmapWithAlbumId(@NonNull Context context, Long id) {
|
||||
try {
|
||||
return Glide.with(context)
|
||||
.load(MusicUtil.INSTANCE.getMediaStoreAlbumCoverUri(id))
|
||||
.asBitmap()
|
||||
.into(200, 200)
|
||||
.get();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "getBitmapCollection: smalltime = " + (System.currentTimeMillis() - start));
|
||||
if (round) return BitmapEditor.getRoundedCornerBitmap(bitmap, bitmap.getWidth() / 40);
|
||||
else return bitmap;
|
||||
}
|
||||
|
||||
private static Bitmap getBitmapWithAlbumId(@NonNull Context context, Long id) {
|
||||
try {
|
||||
return Glide.with(context)
|
||||
.load(MusicUtil.INSTANCE.getMediaStoreAlbumCoverUri(id))
|
||||
.asBitmap()
|
||||
.into(200, 200)
|
||||
.get();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
public static Bitmap getDefaultBitmap(@NonNull Context context, boolean round) {
|
||||
if (round)
|
||||
return BitmapFactory.decodeResource(context.getResources(), R.drawable.default_album_art);
|
||||
return BitmapFactory.decodeResource(context.getResources(), R.drawable.default_album_art);
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap getDefaultBitmap(@NonNull Context context, boolean round) {
|
||||
if (round)
|
||||
return BitmapFactory.decodeResource(context.getResources(), R.drawable.default_album_art);
|
||||
return BitmapFactory.decodeResource(context.getResources(), R.drawable.default_album_art);
|
||||
}
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 12 KiB |
|
@ -1,67 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="276dp"
|
||||
android:height="350dp"
|
||||
android:viewportWidth="276"
|
||||
android:viewportHeight="350">
|
||||
<path
|
||||
android:pathData="M10.256,0L265.4,0C268.967,0 270.26,0.371 271.563,1.069C272.867,1.766 273.89,2.789 274.587,4.093C275.285,5.396 275.656,6.689 275.656,10.256L275.656,177.191C275.656,180.757 275.285,182.05 274.587,183.353C273.89,184.657 272.867,185.68 271.563,186.378C270.26,187.075 268.967,187.446 265.4,187.446L10.256,187.446C6.689,187.446 5.396,187.075 4.093,186.378C2.789,185.68 1.766,184.657 1.069,183.353C0.371,182.05 0,180.757 -0,177.191L0,10.256C-0,6.689 0.371,5.396 1.069,4.093C1.766,2.789 2.789,1.766 4.093,1.069C5.396,0.371 6.689,0 10.256,0Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:gradientRadius="236.10738"
|
||||
android:centerX="0"
|
||||
android:centerY="0"
|
||||
android:type="radial">
|
||||
<item
|
||||
android:offset="0"
|
||||
android:color="#FF3D5AFE" />
|
||||
<item
|
||||
android:offset="1"
|
||||
android:color="#FF651FFF" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:pathData="M262.814,336.03L0.163,75.53L0.006,183.375C0.002,185.781 0.962,188.088 2.67,189.781L161.703,347.393C163.201,348.877 165.225,349.711 167.334,349.711L257.18,349.711C261.598,349.711 265.18,346.129 265.18,341.711C265.18,339.577 264.328,337.533 262.814,336.03Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:gradientRadius="250.9684"
|
||||
android:centerX="-32.788143"
|
||||
android:centerY="67.34283"
|
||||
android:type="radial">
|
||||
<item
|
||||
android:offset="0"
|
||||
android:color="#FF3D5AFE" />
|
||||
<item
|
||||
android:offset="1"
|
||||
android:color="#FF651FFF" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:pathData="M8.035,349.71L59.204,349.71C63.623,349.71 67.204,346.128 67.204,341.71C67.204,339.608 66.377,337.59 64.901,336.093L13.732,284.191C10.63,281.045 5.565,281.009 2.418,284.111C0.894,285.614 0.035,287.666 0.035,289.808L0.035,341.71C0.035,346.128 3.617,349.71 8.035,349.71Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillType="evenOdd"
|
||||
android:strokeColor="#00000000">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:gradientRadius="95.39285"
|
||||
android:centerX="-268.79202"
|
||||
android:centerY="57.347355"
|
||||
android:type="radial">
|
||||
<item
|
||||
android:offset="0"
|
||||
android:color="#FF3D5AFE" />
|
||||
<item
|
||||
android:offset="1"
|
||||
android:color="#FF651FFF" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
</vector>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 1.8 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.3 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 2.5 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 7 KiB After Width: | Height: | Size: 3.9 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 5 KiB |
Before Width: | Height: | Size: 7 KiB After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 5.5 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 12 KiB |
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#1C1C1C</color>
|
||||
<color name="ic_launcher_background">#FFFFFF</color>
|
||||
</resources>
|