diff --git a/app/build.gradle b/app/build.gradle index 5a880777..ad77453c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { vectorDrawables.useSupportLibrary = true applicationId "code.name.monkey.retromusic" - versionCode 391 - versionName '3.4.700' + versionCode 392 + versionName '3.4.800' multiDexEnabled true diff --git a/app/src/main/assets/retro-changelog.html b/app/src/main/assets/retro-changelog.html index ce86756c..5ca12ddd 100644 --- a/app/src/main/assets/retro-changelog.html +++ b/app/src/main/assets/retro-changelog.html @@ -1 +1 @@ -

v3.4.700

v3.4.600

v3.4.500

v3.3.200

v.3.3.100

v3.3.000

v3.2.240

v3.2.220

v3.2.203

v3.2.135

v3.2.125

v3.2.120

v3.2.105

v3.2.100

v3.2.000

v3.1.900

v3.1.850

v3.1.800

v3.1.700

v3.1.400

v3.1.300

If you see entire app white or dark or black select same theme in settings to fix

FAQ's

*If you face any UI related issues you clear app data and cache, if its not working try to uninstall and install again.

\ No newline at end of file +

v3.4.800

v3.4.700

v3.4.600

v3.4.500

v3.3.200

v.3.3.100

v3.3.000

v3.2.240

v3.2.220

v3.2.203

v3.2.135

v3.2.125

v3.2.120

v3.2.105

v3.2.100

v3.2.000

v3.1.900

v3.1.850

v3.1.800

v3.1.700

v3.1.400

v3.1.300

If you see entire app white or dark or black select same theme in settings to fix

FAQ's

*If you face any UI related issues you clear app data and cache, if its not working try to uninstall and install again.

\ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt index 0e70274c..9980d85b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt @@ -24,6 +24,7 @@ import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog import code.name.monkey.retromusic.dialogs.DeleteSongsDialog +import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.glide.ArtistGlideRequest import code.name.monkey.retromusic.glide.RetroMusicColoredTarget @@ -57,7 +58,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C cab = MaterialCab(this, R.id.cab_stub) .setMenu(menuRes) .setCloseDrawableRes(R.drawable.ic_close_white_24dp) - .setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorPrimary))) + .setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorSurface))) .start(callback) return cab as MaterialCab } @@ -187,16 +188,16 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C } private fun setColors(color: Int) { - val themeColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color + val themeColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color.ripAlpha() else ThemeStore.accentColor(this) songTitle.setTextColor(themeColor) moreTitle.setTextColor(themeColor) val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor) - color + color.ripAlpha() else - ATHUtil.resolveColor(this, R.attr.colorControlNormal) + ATHUtil.resolveColor(this, R.attr.colorSurface) MaterialUtil.setTint(button = shuffleAction, color = buttonColor) MaterialUtil.setTint(button = playAction, color = buttonColor) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt index 585ebe56..7627bd2a 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt @@ -24,6 +24,7 @@ import code.name.monkey.retromusic.adapter.album.AlbumAdapter import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog +import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.glide.ArtistGlideRequest import code.name.monkey.retromusic.glide.RetroMusicColoredTarget import code.name.monkey.retromusic.helper.MusicPlayerRemote @@ -50,7 +51,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView, cab = MaterialCab(this, R.id.cab_stub) .setMenu(menuRes) .setCloseDrawableRes(R.drawable.ic_close_white_24dp) - .setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorPrimary))) + .setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorSurface))) .start(callback) return cab as MaterialCab } @@ -224,21 +225,23 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView, } private fun setColors(color: Int) { - - val textColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color - else ThemeStore.accentColor(this) + val textColor = if (PreferenceUtil.getInstance(this).adaptiveColor) + color.ripAlpha() + else + ThemeStore.accentColor(this) albumTitle.setTextColor(textColor) songTitle.setTextColor(textColor) biographyTitle.setTextColor(textColor) - val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color - else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor) + val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor) + color.ripAlpha() + else + ATHUtil.resolveColor(this, R.attr.colorSurface) MaterialUtil.setTint(button = shuffleAction, color = buttonColor) MaterialUtil.setTint(button = playAction, color = buttonColor) - val toolbarColor = ATHUtil.resolveColor(this, R.attr.colorSurface) status_bar.setBackgroundColor(toolbarColor) toolbar.setBackgroundColor(toolbarColor) @@ -272,21 +275,12 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView, R.id.action_set_artist_image -> { val intent = Intent(Intent.ACTION_GET_CONTENT) intent.type = "image/*" - startActivityForResult( - Intent.createChooser( - intent, getString(R.string.pick_from_local_storage) - ), REQUEST_CODE_SELECT_IMAGE - ) + startActivityForResult(Intent.createChooser(intent, getString(R.string.pick_from_local_storage)), REQUEST_CODE_SELECT_IMAGE) return true } R.id.action_reset_artist_image -> { - Toast.makeText( - this@ArtistDetailActivity, - resources.getString(R.string.updating), - Toast.LENGTH_SHORT - ).show() - CustomArtistImageUtil.getInstance(this@ArtistDetailActivity) - .resetCustomArtistImage(artist) + Toast.makeText(this@ArtistDetailActivity, resources.getString(R.string.updating), Toast.LENGTH_SHORT).show() + CustomArtistImageUtil.getInstance(this@ArtistDetailActivity).resetCustomArtistImage(artist) forceDownload = true return true } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt index 4497cc5e..8ed66be5 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt @@ -39,7 +39,12 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet private lateinit var songAdapter: ShuffleButtonSongAdapter private var cab: MaterialCab? = null + private fun getEmojiByUnicode(unicode: Int): String { + return String(Character.toChars(unicode)) + } + private fun checkIsEmpty() { + emptyEmoji.text = getEmojiByUnicode(0x1F631) empty?.visibility = if (songAdapter.itemCount == 0) View.VISIBLE else View.GONE } 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 988b8841..0a88458f 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 @@ -12,263 +12,263 @@ import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment import code.name.monkey.retromusic.fragments.mainactivity.folders.FoldersFragment import code.name.monkey.retromusic.fragments.mainactivity.home.BannerHomeFragment -import code.name.monkey.retromusic.helper.* +import code.name.monkey.retromusic.helper.MusicPlayerRemote +import code.name.monkey.retromusic.helper.SearchQueryHelper import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks -import code.name.monkey.retromusic.loaders.* +import code.name.monkey.retromusic.loaders.AlbumLoader +import code.name.monkey.retromusic.loaders.ArtistLoader +import code.name.monkey.retromusic.loaders.PlaylistSongsLoader import code.name.monkey.retromusic.service.MusicService -import code.name.monkey.retromusic.util.* +import code.name.monkey.retromusic.util.AppRater +import code.name.monkey.retromusic.util.PreferenceUtil import io.reactivex.disposables.CompositeDisposable import java.util.* class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedPreferenceChangeListener { - private lateinit var currentFragment: MainActivityFragmentCallbacks + private lateinit var currentFragment: MainActivityFragmentCallbacks - private var blockRequestPermissions: Boolean = false - private val disposable = CompositeDisposable() - private val broadcastReceiver = object : BroadcastReceiver() { - override fun onReceive(context: Context, intent: Intent) { - val action = intent.action - if (action != null && action == Intent.ACTION_SCREEN_OFF) { - if (PreferenceUtil.getInstance(this@MainActivity).lockScreen && MusicPlayerRemote.isPlaying) { - val activity = Intent(context, LockScreenActivity::class.java) - activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) - ActivityCompat.startActivity(context, activity, null) - } - } - } - } + private var blockRequestPermissions: Boolean = false + private val disposable = CompositeDisposable() + private val broadcastReceiver = object : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + val action = intent.action + if (action != null && action == Intent.ACTION_SCREEN_OFF) { + if (PreferenceUtil.getInstance(this@MainActivity).lockScreen && MusicPlayerRemote.isPlaying) { + val activity = Intent(context, LockScreenActivity::class.java) + activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) + ActivityCompat.startActivity(context, activity, null) + } + } + } + } - override fun createContentView(): View { - return wrapSlidingMusicPanel(R.layout.activity_main_content) - } + override fun createContentView(): View { + return wrapSlidingMusicPanel(R.layout.activity_main_content) + } - override fun onCreate( - savedInstanceState: Bundle? - ) { - setDrawUnderStatusBar() - super.onCreate(savedInstanceState) + override fun onCreate( + savedInstanceState: Bundle? + ) { + setDrawUnderStatusBar() + super.onCreate(savedInstanceState) + getBottomNavigationView().selectedItemId = PreferenceUtil.getInstance(this).lastPage + getBottomNavigationView().setOnNavigationItemSelectedListener { + PreferenceUtil.getInstance(this).lastPage = it.itemId + selectedFragment(it.itemId) + true + } - getBottomNavigationView().selectedItemId = PreferenceUtil.getInstance(this).lastPage + if (savedInstanceState == null) { + setMusicChooser(PreferenceUtil.getInstance(this).lastMusicChooser) + } else { + restoreCurrentFragment() + } - getBottomNavigationView().setOnNavigationItemSelectedListener { - PreferenceUtil.getInstance(this).lastPage = it.itemId - selectedFragment(it.itemId) - true - } + checkShowChangelog() + AppRater.appLaunched(this) + } - if (savedInstanceState == null) { - setMusicChooser(PreferenceUtil.getInstance(this).lastMusicChooser) - } else { - restoreCurrentFragment() - } + private fun checkShowChangelog() { + try { + val pInfo = packageManager.getPackageInfo(packageName, 0) + val currentVersion = pInfo.versionCode + if (currentVersion != PreferenceUtil.getInstance(this).lastChangelogVersion) { + startActivityForResult( + Intent(this, WhatsNewActivity::class.java), + APP_INTRO_REQUEST + ) + } + } catch (e: Throwable) { + e.printStackTrace() + } - checkShowChangelog() - AppRater.appLaunched(this); - } + } - private fun checkShowChangelog() { - try { - val pInfo = packageManager.getPackageInfo(packageName, 0) - val currentVersion = pInfo.versionCode - if (currentVersion != PreferenceUtil.getInstance(this).lastChangelogVersion) { - startActivityForResult( - Intent(this, WhatsNewActivity::class.java), - APP_INTRO_REQUEST - ) - } - } catch (e: Throwable) { - e.printStackTrace() - } + override fun onResume() { + super.onResume() + val screenOnOff = IntentFilter() + screenOnOff.addAction(Intent.ACTION_SCREEN_OFF) + registerReceiver(broadcastReceiver, screenOnOff) - } + PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this) - override fun onResume() { - super.onResume() - val screenOnOff = IntentFilter() - screenOnOff.addAction(Intent.ACTION_SCREEN_OFF) - registerReceiver(broadcastReceiver, screenOnOff) + if (intent.hasExtra("expand")) { + if (intent.getBooleanExtra("expand", false)) { + expandPanel() + intent.putExtra("expand", false) + } + } + } - PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this) + override fun onDestroy() { + super.onDestroy() + disposable.clear() + unregisterReceiver(broadcastReceiver) + PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this) + } - if (intent.hasExtra("expand")) { - if (intent.getBooleanExtra("expand", false)) { - expandPanel() - intent.putExtra("expand", false) - } - } - } + private fun setCurrentFragment(fragment: Fragment, tag: String) { + if (tag != supportFragmentManager.findFragmentById(R.id.fragment_container)?.tag) { + supportFragmentManager.beginTransaction() + .replace(R.id.fragment_container, fragment, tag).commit() + currentFragment = fragment as MainActivityFragmentCallbacks + } + } - override fun onDestroy() { - super.onDestroy() - disposable.clear() - unregisterReceiver(broadcastReceiver) - PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this) - } + private fun restoreCurrentFragment() { + currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) as MainActivityFragmentCallbacks + } - private fun setCurrentFragment(fragment: Fragment, tag: String) { - println("setCurrentFragment -> $tag -> ${supportFragmentManager.findFragmentById(R.id.fragment_container)?.tag}") - if (tag != supportFragmentManager.findFragmentById(R.id.fragment_container)?.tag) { - supportFragmentManager.beginTransaction() - .replace(R.id.fragment_container, fragment, tag).commit() - currentFragment = fragment as MainActivityFragmentCallbacks - } - } + private fun handlePlaybackIntent(intent: Intent?) { + if (intent == null) { + return + } + val uri = intent.data + val mimeType = intent.type + var handled = false + if (intent.action != null && intent.action == MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH) { + val songs = SearchQueryHelper.getSongs(this, intent.extras!!) + if (MusicPlayerRemote.shuffleMode == MusicService.SHUFFLE_MODE_SHUFFLE) { + MusicPlayerRemote.openAndShuffleQueue(songs, true) + } else { + MusicPlayerRemote.openQueue(songs, 0, true) + } + handled = true + } - private fun restoreCurrentFragment() { - currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) as MainActivityFragmentCallbacks - } + if (uri != null && uri.toString().isNotEmpty()) { + MusicPlayerRemote.playFromUri(uri) + handled = true + } else if (MediaStore.Audio.Playlists.CONTENT_TYPE == mimeType) { + val id = parseIdFromIntent(intent, "playlistId", "playlist").toInt() + if (id >= 0) { + val position = intent.getIntExtra("position", 0) + val songs = ArrayList(PlaylistSongsLoader.getPlaylistSongList(this, id)) + MusicPlayerRemote.openQueue(songs, position, true) + handled = true + } + } else if (MediaStore.Audio.Albums.CONTENT_TYPE == mimeType) { + val id = parseIdFromIntent(intent, "albumId", "album").toInt() + if (id >= 0) { + val position = intent.getIntExtra("position", 0) + MusicPlayerRemote.openQueue(AlbumLoader.getAlbum(this, id).songs!!, position, true) + handled = true + } + } else if (MediaStore.Audio.Artists.CONTENT_TYPE == mimeType) { + val id = parseIdFromIntent(intent, "artistId", "artist").toInt() + if (id >= 0) { + val position = intent.getIntExtra("position", 0) + MusicPlayerRemote.openQueue(ArtistLoader.getArtist(this, id).songs, position, true) + handled = true + } + } + if (handled) { + setIntent(Intent()) + } + } - private fun handlePlaybackIntent(intent: Intent?) { - if (intent == null) { - return - } + private fun parseIdFromIntent(intent: Intent, longKey: String, stringKey: String): Long { + var id = intent.getLongExtra(longKey, -1) + if (id < 0) { + val idString = intent.getStringExtra(stringKey) + if (idString != null) { + try { + id = java.lang.Long.parseLong(idString) + } catch (e: NumberFormatException) { + Log.e(TAG, e.message) + } + } + } + return id + } - val uri = intent.data - val mimeType = intent.type - var handled = false - if (intent.action != null && intent.action == MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH) { - val songs = SearchQueryHelper.getSongs(this, intent.extras!!) - if (MusicPlayerRemote.shuffleMode == MusicService.SHUFFLE_MODE_SHUFFLE) { - MusicPlayerRemote.openAndShuffleQueue(songs, true) - } else { - MusicPlayerRemote.openQueue(songs, 0, true) - } - handled = true - } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + when (requestCode) { + APP_INTRO_REQUEST -> { + blockRequestPermissions = false + if (!hasPermissions()) { + requestPermissions() + } + } + REQUEST_CODE_THEME, APP_USER_INFO_REQUEST -> postRecreate() + PURCHASE_REQUEST -> { + if (resultCode == RESULT_OK) { + //checkSetUpPro(); + } + } + } - if (uri != null && uri.toString().isNotEmpty()) { - MusicPlayerRemote.playFromUri(uri) - handled = true - } else if (MediaStore.Audio.Playlists.CONTENT_TYPE == mimeType) { - val id = parseIdFromIntent(intent, "playlistId", "playlist").toInt() - if (id >= 0) { - val position = intent.getIntExtra("position", 0) - val songs = ArrayList(PlaylistSongsLoader.getPlaylistSongList(this, id)) - MusicPlayerRemote.openQueue(songs, position, true) - handled = true - } - } else if (MediaStore.Audio.Albums.CONTENT_TYPE == mimeType) { - val id = parseIdFromIntent(intent, "albumId", "album").toInt() - if (id >= 0) { - val position = intent.getIntExtra("position", 0) - MusicPlayerRemote.openQueue(AlbumLoader.getAlbum(this, id).songs!!, position, true) - handled = true - } - } else if (MediaStore.Audio.Artists.CONTENT_TYPE == mimeType) { - val id = parseIdFromIntent(intent, "artistId", "artist").toInt() - if (id >= 0) { - val position = intent.getIntExtra("position", 0) - MusicPlayerRemote.openQueue(ArtistLoader.getArtist(this, id).songs, position, true) - handled = true - } - } - if (handled) { - setIntent(Intent()) - } - } + } - private fun parseIdFromIntent(intent: Intent, longKey: String, stringKey: String): Long { - var id = intent.getLongExtra(longKey, -1) - if (id < 0) { - val idString = intent.getStringExtra(stringKey) - if (idString != null) { - try { - id = java.lang.Long.parseLong(idString) - } catch (e: NumberFormatException) { - Log.e(TAG, e.message) - } - } - } - return id - } + override fun handleBackPress(): Boolean { + return super.handleBackPress() || currentFragment.handleBackPress() + } - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) - when (requestCode) { - APP_INTRO_REQUEST -> { - blockRequestPermissions = false - if (!hasPermissions()) { - requestPermissions() - } - } - REQUEST_CODE_THEME, APP_USER_INFO_REQUEST -> postRecreate() - PURCHASE_REQUEST -> { - if (resultCode == RESULT_OK) { - //checkSetUpPro(); - } - } - } + override fun onServiceConnected() { + super.onServiceConnected() + handlePlaybackIntent(intent) + } - } + override fun requestPermissions() { + if (!blockRequestPermissions) { + super.requestPermissions() + } + } - override fun handleBackPress(): Boolean { - return super.handleBackPress() || currentFragment.handleBackPress() - } + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + if (key == PreferenceUtil.GENERAL_THEME || key == PreferenceUtil.BLACK_THEME || key == PreferenceUtil.ADAPTIVE_COLOR_APP || key == PreferenceUtil.DOMINANT_COLOR || key == PreferenceUtil.USER_NAME || key == PreferenceUtil.TOGGLE_FULL_SCREEN || key == PreferenceUtil.TOGGLE_VOLUME || key == PreferenceUtil.ROUND_CORNERS || key == PreferenceUtil.CAROUSEL_EFFECT || key == PreferenceUtil.NOW_PLAYING_SCREEN_ID || key == PreferenceUtil.TOGGLE_GENRE || key == PreferenceUtil.BANNER_IMAGE_PATH || key == PreferenceUtil.PROFILE_IMAGE_PATH || key == PreferenceUtil.CIRCULAR_ALBUM_ART || key == PreferenceUtil.KEEP_SCREEN_ON || key == PreferenceUtil.TOGGLE_SEPARATE_LINE || key == PreferenceUtil.ALBUM_GRID_STYLE || key == PreferenceUtil.ARTIST_GRID_STYLE || key == PreferenceUtil.TOGGLE_HOME_BANNER || key == PreferenceUtil.TOGGLE_ADD_CONTROLS || key == PreferenceUtil.ALBUM_COVER_STYLE || key == PreferenceUtil.HOME_ARTIST_GRID_STYLE || key == PreferenceUtil.ALBUM_COVER_TRANSFORM || key == PreferenceUtil.DESATURATED_COLOR || key == PreferenceUtil.TAB_TEXT_MODE || key == PreferenceUtil.LIBRARY_CATEGORIES) postRecreate() - override fun onServiceConnected() { - super.onServiceConnected() - handlePlaybackIntent(intent) - } + } - override fun requestPermissions() { - if (!blockRequestPermissions) { - super.requestPermissions() - } - } + private fun showPromotionalOffer() { + /*MaterialDialog(this).show { + positiveButton(text = "Buy") { startActivity(Intent(this@MainActivity, PurchaseActivity::class.java)) } + negativeButton(android.R.string.cancel) + customView(R.layout.dialog_promotional_offer) + onDismiss { + PreferenceManager.getDefaultSharedPreferences(this@MainActivity) + .edit() + .putBoolean("shown", true) + .apply() + } + }*/ + } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { - if (key == PreferenceUtil.GENERAL_THEME || key == PreferenceUtil.BLACK_THEME || key == PreferenceUtil.ADAPTIVE_COLOR_APP || key == PreferenceUtil.DOMINANT_COLOR || key == PreferenceUtil.USER_NAME || key == PreferenceUtil.TOGGLE_FULL_SCREEN || key == PreferenceUtil.TOGGLE_VOLUME || key == PreferenceUtil.ROUND_CORNERS || key == PreferenceUtil.CAROUSEL_EFFECT || key == PreferenceUtil.NOW_PLAYING_SCREEN_ID || key == PreferenceUtil.TOGGLE_GENRE || key == PreferenceUtil.BANNER_IMAGE_PATH || key == PreferenceUtil.PROFILE_IMAGE_PATH || key == PreferenceUtil.CIRCULAR_ALBUM_ART || key == PreferenceUtil.KEEP_SCREEN_ON || key == PreferenceUtil.TOGGLE_SEPARATE_LINE || key == PreferenceUtil.ALBUM_GRID_STYLE || key == PreferenceUtil.ARTIST_GRID_STYLE || key == PreferenceUtil.TOGGLE_HOME_BANNER || key == PreferenceUtil.TOGGLE_ADD_CONTROLS || key == PreferenceUtil.ALBUM_COVER_STYLE || key == PreferenceUtil.HOME_ARTIST_GRID_STYLE || key == PreferenceUtil.ALBUM_COVER_TRANSFORM || key == PreferenceUtil.DESATURATED_COLOR || key == PreferenceUtil.TAB_TEXT_MODE || key == PreferenceUtil.LIBRARY_CATEGORIES) postRecreate() + private fun selectedFragment(itemId: Int) { + when (itemId) { + R.id.action_album, R.id.action_artist, R.id.action_playlist, R.id.action_genre, R.id.action_song -> setCurrentFragment( + LibraryFragment.newInstance(itemId), + itemId.toString() + ) + R.id.action_home -> setCurrentFragment( + BannerHomeFragment.newInstance(), + BannerHomeFragment.TAG + ) + else -> { + setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG) + } + } + } - } + fun setMusicChooser(key: Int) { + PreferenceUtil.getInstance(this).lastMusicChooser = key + when (key) { + FOLDER -> setCurrentFragment(FoldersFragment.newInstance(this), FoldersFragment.TAG) + else -> selectedFragment(PreferenceUtil.getInstance(this).lastPage) + } + } - private fun showPromotionalOffer() { - /*MaterialDialog(this).show { - positiveButton(text = "Buy") { startActivity(Intent(this@MainActivity, PurchaseActivity::class.java)) } - negativeButton(android.R.string.cancel) - customView(R.layout.dialog_promotional_offer) - onDismiss { - PreferenceManager.getDefaultSharedPreferences(this@MainActivity) - .edit() - .putBoolean("shown", true) - .apply() - } - }*/ - } - - private fun selectedFragment(itemId: Int) { - when (itemId) { - R.id.action_album, R.id.action_artist, R.id.action_playlist, R.id.action_genre, R.id.action_song -> setCurrentFragment( - LibraryFragment.newInstance(itemId), - itemId.toString() - ) - R.id.action_home -> setCurrentFragment( - BannerHomeFragment.newInstance(), - BannerHomeFragment.TAG - ) - else -> { - setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG) - } - } - } - - fun setMusicChooser(key: Int) { - PreferenceUtil.getInstance(this).lastMusicChooser = key - when (key) { - FOLDER -> setCurrentFragment(FoldersFragment.newInstance(this), FoldersFragment.TAG) - else -> selectedFragment(PreferenceUtil.getInstance(this).lastPage) - } - } - - companion object { - const val APP_INTRO_REQUEST = 2323 - const val HOME = 0 - const val FOLDER = 1 - const val LIBRARY = 2 - private const val TAG = "MainActivity" - private const val APP_USER_INFO_REQUEST = 9003 - private const val REQUEST_CODE_THEME = 9002 - private const val PURCHASE_REQUEST = 101 - } + companion object { + const val APP_INTRO_REQUEST = 2323 + const val HOME = 0 + const val FOLDER = 1 + const val LIBRARY = 2 + private const val TAG = "MainActivity" + private const val APP_USER_INFO_REQUEST = 9003 + private const val REQUEST_CODE_THEME = 9002 + private const val PURCHASE_REQUEST = 101 + } } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt index 822ad499..b41acf11 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt @@ -190,10 +190,15 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli private fun checkIsEmpty() { checkForPadding() + emptyEmoji.text = getEmojiByUnicode(0x1F631) empty.visibility = if (adapter.itemCount == 0) View.VISIBLE else View.GONE emptyText.visibility = if (adapter.itemCount == 0) View.VISIBLE else View.GONE } + private fun getEmojiByUnicode(unicode: Int): String { + return String(Character.toChars(unicode)) + } + public override fun onPause() { if (recyclerViewDragDropManager != null) { recyclerViewDragDropManager!!.cancelDrag() diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt index d5b7dcf6..082adc6b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt @@ -79,7 +79,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch keyboardPopup.iconTint = this } if (savedInstanceState != null) { - query = savedInstanceState.getString(QUERY); + query = savedInstanceState.getString(QUERY) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java index b03ee721..176114cb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java @@ -60,9 +60,7 @@ public class WhatsNewActivity extends AbsBaseActivity { toolbar = findViewById(R.id.toolbar); appBarLayout = findViewById(R.id.appBarLayout); - int primaryColor = INSTANCE.resolveColor(this, R.attr.colorSurface); - toolbar.setBackgroundColor(primaryColor); - appBarLayout.setBackgroundColor(primaryColor); + toolbar.setBackgroundColor(INSTANCE.resolveColor(this, R.attr.colorSurface)); //setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(v -> onBackPressed()); @@ -79,7 +77,7 @@ public class WhatsNewActivity extends AbsBaseActivity { // Inject color values for WebView body background and links final boolean isDark = INSTANCE.isWindowBackgroundDark(this); - final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, android.R.attr.windowBackground, Color.parseColor(isDark ? "#424242" : "#ffffff"))); + final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff"))); final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000")); final String changeLog = buf.toString() .replace("{style-placeholder}", String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor)) 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 8c39307b..cc72372d 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 @@ -2,9 +2,7 @@ package code.name.monkey.retromusic.activities.base import android.animation.ValueAnimator import android.graphics.Color -import android.graphics.Rect import android.os.Bundle -import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.view.ViewTreeObserver @@ -338,12 +336,13 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay bottomNavigationView.menu.add(0, menu.id, 0, menu.stringRes).setIcon(menu.icon) } } + print("Tabs -> ${currentTabs.size}") if (currentTabs.size <= 1) { toggleBottomNavigationView(true) } } - override fun dispatchTouchEvent(ev: MotionEvent?): Boolean { + /*override fun dispatchTouchEvent(ev: MotionEvent?): Boolean { if (ev?.action == MotionEvent.ACTION_DOWN) { if (panelState == BottomSheetBehavior.STATE_EXPANDED) { val outRect = Rect() @@ -354,5 +353,5 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay } } return super.dispatchTouchEvent(ev) - } + }*/ } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/GenreAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/GenreAdapter.kt index 4a2dc873..d8166e4f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/GenreAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/GenreAdapter.kt @@ -1,7 +1,9 @@ package code.name.monkey.retromusic.adapter import android.app.Activity -import android.view.* +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder @@ -14,49 +16,39 @@ import java.util.* */ class GenreAdapter( - private val activity: Activity, dataSet: ArrayList, private val mItemLayoutRes: Int + private val activity: Activity, dataSet: ArrayList, private val mItemLayoutRes: Int ) : RecyclerView.Adapter() { - var dataSet = ArrayList() - private set + var dataSet = ArrayList() + private set - init { - this.dataSet = dataSet - } + init { + this.dataSet = dataSet + } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return ViewHolder(LayoutInflater.from(activity).inflate(mItemLayoutRes, parent, false)) - } + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + return ViewHolder(LayoutInflater.from(activity).inflate(mItemLayoutRes, parent, false)) + } - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val genre = dataSet[position] - if (holder.title != null) { - holder.title!!.text = genre.name - } - if (holder.text != null) { - holder.text!!.text = String.format( - Locale.getDefault(), - "%d %s", - genre.songCount, - if (genre.songCount > 1) activity.getString(R.string.songs) - else activity.getString(R.string.song) - ) - } - } + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + val genre = dataSet[position] + holder.title?.text = genre.name + holder.text?.text = String.format(Locale.getDefault(), "%d %s", genre.songCount, if (genre.songCount > 1) activity.getString(R.string.songs) else activity.getString(R.string.song)) + } - override fun getItemCount(): Int { - return dataSet.size - } + override fun getItemCount(): Int { + return dataSet.size + } - fun swapDataSet(list: ArrayList) { - dataSet = list - notifyDataSetChanged() - } + fun swapDataSet(list: ArrayList) { + dataSet = list + notifyDataSetChanged() + } - inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) { - override fun onClick(v: View?) { - super.onClick(v) - val genre = dataSet[adapterPosition] - NavigationUtil.goToGenre(activity, genre) - } - } + inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) { + override fun onClick(v: View?) { + super.onClick(v) + val genre = dataSet[adapterPosition] + NavigationUtil.goToGenre(activity, genre) + } + } } diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/SearchAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/SearchAdapter.kt index a699fb54..266c6bee 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/SearchAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/SearchAdapter.kt @@ -1,140 +1,140 @@ package code.name.monkey.retromusic.adapter import android.app.ActivityOptions -import android.view.* +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.RecyclerView import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder -import code.name.monkey.retromusic.glide.* +import code.name.monkey.retromusic.glide.ArtistGlideRequest +import code.name.monkey.retromusic.glide.SongGlideRequest import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.menu.SongMenuHelper -import code.name.monkey.retromusic.model.* -import code.name.monkey.retromusic.util.* +import code.name.monkey.retromusic.model.Album +import code.name.monkey.retromusic.model.Artist +import code.name.monkey.retromusic.model.Genre +import code.name.monkey.retromusic.model.Song +import code.name.monkey.retromusic.util.MusicUtil +import code.name.monkey.retromusic.util.NavigationUtil import com.bumptech.glide.Glide +import java.util.* +import kotlin.collections.ArrayList import android.util.Pair as UtilPair class SearchAdapter( - private val activity: AppCompatActivity, private var dataSet: List? + private val activity: AppCompatActivity, private var dataSet: List? ) : RecyclerView.Adapter() { - fun swapDataSet(dataSet: MutableList) { - this.dataSet = dataSet - notifyDataSetChanged() - } + fun swapDataSet(dataSet: MutableList) { + this.dataSet = dataSet + notifyDataSetChanged() + } - override fun getItemViewType(position: Int): Int { - if (dataSet!![position] is Album) return ALBUM - if (dataSet!![position] is Artist) return ARTIST - return if (dataSet!![position] is Song) SONG else HEADER - } + override fun getItemViewType(position: Int): Int { + if (dataSet!![position] is Album) return ALBUM + if (dataSet!![position] is Artist) return ARTIST + if (dataSet!![position] is Genre) return GENRE + return if (dataSet!![position] is Song) SONG else HEADER + } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return if (viewType == HEADER) ViewHolder( - LayoutInflater.from(activity).inflate( - R.layout.sub_header, - parent, - false - ), viewType - ) else ViewHolder( - LayoutInflater.from(activity).inflate(R.layout.item_list, parent, false), - viewType - ) - } + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + return if (viewType == HEADER) ViewHolder(LayoutInflater.from(activity).inflate(R.layout.sub_header, parent, false), viewType) + else + ViewHolder(LayoutInflater.from(activity).inflate(R.layout.item_list, parent, false), viewType) + } - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - when (getItemViewType(position)) { - ALBUM -> { - val album = dataSet?.get(position) as Album - holder.title?.text = album.title - holder.text?.text = album.artistName - SongGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong()) - .checkIgnoreMediaStore(activity).build().into(holder.image) - } - ARTIST -> { - val artist = dataSet?.get(position) as Artist - holder.title?.text = artist.name - holder.text?.text = MusicUtil.getArtistInfoString(activity, artist) - ArtistGlideRequest.Builder.from(Glide.with(activity), artist).build() - .into(holder.image) - } - SONG -> { - val song = dataSet?.get(position) as Song - holder.title?.text = song.title - holder.text?.text = song.albumName - } - else -> { - holder.title?.text = dataSet?.get(position).toString() - holder.title?.setTextColor(ThemeStore.accentColor(activity)) - } - } - } + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + when (getItemViewType(position)) { + ALBUM -> { + val album = dataSet?.get(position) as Album + holder.title?.text = album.title + holder.text?.text = album.artistName + SongGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong()) + .checkIgnoreMediaStore(activity).build().into(holder.image) + } + ARTIST -> { + val artist = dataSet?.get(position) as Artist + holder.title?.text = artist.name + holder.text?.text = MusicUtil.getArtistInfoString(activity, artist) + ArtistGlideRequest.Builder.from(Glide.with(activity), artist).build() + .into(holder.image) + } + SONG -> { + val song = dataSet?.get(position) as Song + holder.title?.text = song.title + holder.text?.text = song.albumName + } + GENRE -> { + val genre = dataSet?.get(position) as Genre + holder.title?.text = genre.name + holder.text?.text = String.format(Locale.getDefault(), "%d %s", genre.songCount, if (genre.songCount > 1) activity.getString(R.string.songs) else activity.getString(R.string.song)) + } + else -> { + holder.title?.text = dataSet?.get(position).toString() + holder.title?.setTextColor(ThemeStore.accentColor(activity)) + } + } + } - override fun getItemCount(): Int { - return dataSet!!.size - } + override fun getItemCount(): Int { + return dataSet!!.size + } - inner class ViewHolder(itemView: View, itemViewType: Int) : MediaEntryViewHolder(itemView) { - init { - itemView.setOnLongClickListener(null) + inner class ViewHolder(itemView: View, itemViewType: Int) : MediaEntryViewHolder(itemView) { + init { + itemView.setOnLongClickListener(null) - if (itemViewType == SONG) { - menu?.visibility = View.VISIBLE - menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) { - override val song: Song - get() = dataSet!![adapterPosition] as Song - }) - } else { - menu?.visibility = View.GONE - } + if (itemViewType == SONG) { + menu?.visibility = View.VISIBLE + menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) { + override val song: Song + get() = dataSet!![adapterPosition] as Song + }) + } else { + menu?.visibility = View.GONE + } - when (itemViewType) { - ALBUM -> setImageTransitionName(activity.getString(R.string.transition_album_art)) - ARTIST -> setImageTransitionName(activity.getString(R.string.transition_artist_image)) - else -> { - val container = itemView.findViewById(R.id.imageContainer) - container?.visibility = View.GONE - } - } - } + when (itemViewType) { + ALBUM -> setImageTransitionName(activity.getString(R.string.transition_album_art)) + ARTIST -> setImageTransitionName(activity.getString(R.string.transition_artist_image)) + else -> { + val container = itemView.findViewById(R.id.imageContainer) + container?.visibility = View.GONE + } + } + } - override fun onClick(v: View?) { - val item = dataSet!![adapterPosition] - when (itemViewType) { - ALBUM -> { - val options = ActivityOptions.makeSceneTransitionAnimation( - activity, - UtilPair.create( - image, - activity.getString(R.string.transition_album_art) - ) - ) - NavigationUtil.goToAlbumOptions(activity, (item as Album).id, options) - } - ARTIST -> { - val options = ActivityOptions.makeSceneTransitionAnimation( - activity, - UtilPair.create( - image, - activity.getString(R.string.transition_artist_image) - ) - ) - NavigationUtil.goToArtistOptions(activity, (item as Artist).id, options) - } - SONG -> { - val playList = ArrayList() - playList.add(item as Song) - MusicPlayerRemote.openQueue(playList, 0, true) - } - } - } - } + override fun onClick(v: View?) { + val item = dataSet!![adapterPosition] + when (itemViewType) { + ALBUM -> { + val options = ActivityOptions.makeSceneTransitionAnimation(activity, UtilPair.create(image, activity.getString(R.string.transition_album_art))) + NavigationUtil.goToAlbumOptions(activity, (item as Album).id, options) + } + ARTIST -> { + val options = ActivityOptions.makeSceneTransitionAnimation(activity, UtilPair.create(image, activity.getString(R.string.transition_artist_image))) + NavigationUtil.goToArtistOptions(activity, (item as Artist).id, options) + } + GENRE -> { + NavigationUtil.goToGenre(activity, item as Genre) + } + SONG -> { + val playList = ArrayList() + playList.add(item as Song) + MusicPlayerRemote.openQueue(playList, 0, true) + } + } + } + } - companion object { - private const val HEADER = 0 - private const val ALBUM = 1 - private const val ARTIST = 2 - private const val SONG = 3 - } + companion object { + private const val HEADER = 0 + private const val ALBUM = 1 + private const val ARTIST = 2 + private const val SONG = 3 + private const val GENRE = 4 + } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt index 1c5f32c7..267f1df7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt @@ -60,14 +60,14 @@ class SimplePlayerFragment : AbsPlayerFragment() { } override fun toolbarIconColor(): Int { - return ATHUtil.resolveColor(requireContext(), R.attr.iconColor) + return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) } override fun onColorChanged(color: Int) { lastColor = color callbacks?.onPaletteColorChanged() simplePlaybackControlsFragment.setDark(color) - ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.iconColor), requireActivity()) + ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity()) } @@ -87,7 +87,7 @@ class SimplePlayerFragment : AbsPlayerFragment() { inflateMenu(R.menu.menu_player) setNavigationOnClickListener { requireActivity().onBackPressed() } setOnMenuItemClickListener(this@SimplePlayerFragment) - ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.iconColor), requireActivity()) + ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity()) } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt index 4f0e79fb..7e5ab582 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt @@ -19,34 +19,21 @@ import android.database.Cursor import android.net.Uri import android.provider.BaseColumns import android.provider.MediaStore.Audio.Genres -import code.name.monkey.retromusic.Constants.baseProjection import code.name.monkey.retromusic.Constants.BASE_SELECTION +import code.name.monkey.retromusic.Constants.baseProjection import code.name.monkey.retromusic.model.Genre import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.PreferenceUtil -import io.reactivex.Observable import java.util.* object GenreLoader { - fun getAllGenresFlowable(context: Context): Observable> { - return getGenresFromCursorFlowable(context, makeGenreCursor(context)) - } fun getAllGenres(context: Context): ArrayList { return getGenresFromCursor(context, makeGenreCursor(context)) } - fun getSongsFlowable(context: Context, genreId: Int): Observable> { - // The genres table only stores songs that have a genre specified, - // so we need to get songs without a genre a different way. - return if (genreId == -1) { - getSongsWithNoGenreFlowable(context) - } else SongLoader.getSongsFlowable(makeGenreSongCursor(context, genreId)) - - } - fun getSongs(context: Context, genreId: Int): ArrayList { // The genres table only stores songs that have a genre specified, // so we need to get songs without a genre a different way. @@ -64,12 +51,6 @@ object GenreLoader { } - private fun getSongsWithNoGenreFlowable(context: Context): Observable> { - val selection = BaseColumns._ID + " NOT IN " + - "(SELECT " + Genres.Members.AUDIO_ID + " FROM audio_genres_map)" - return SongLoader.getSongsFlowable(SongLoader.makeSongCursor(context, selection, null)) - } - private fun getSongsWithNoGenre(context: Context): ArrayList { val selection = BaseColumns._ID + " NOT IN " + "(SELECT " + Genres.Members.AUDIO_ID + " FROM audio_genres_map)" @@ -112,34 +93,6 @@ object GenreLoader { } - private fun getGenresFromCursorFlowable(context: Context, cursor: Cursor?): Observable> { - return Observable.create { e -> - val genres = ArrayList() - if (cursor != null) { - if (cursor.moveToFirst()) { - do { - val genre = getGenreFromCursor(context, cursor) - if (genre.songCount > 0) { - genres.add(genre) - } else { - // try to remove the empty genre from the media store - try { - context.contentResolver.delete(Genres.EXTERNAL_CONTENT_URI, Genres._ID + " == " + genre.id, null) - } catch (ex: Exception) { - ex.printStackTrace() - // nothing we can do then - } - - } - } while (cursor.moveToNext()) - } - cursor.close() - } - e.onNext(genres) - e.onComplete() - } - } - private fun getGenresFromCursor(context: Context, cursor: Cursor?): ArrayList { val genres = arrayListOf() if (cursor != null) { diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/SearchLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/SearchLoader.kt index 80708e11..1f5c494d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/SearchLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/SearchLoader.kt @@ -16,31 +16,40 @@ package code.name.monkey.retromusic.loaders import android.content.Context import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.model.Genre +import java.util.* object SearchLoader { fun searchAll(context: Context, query: String?): MutableList { val results = mutableListOf() - query?.let { - val songs = SongLoader.getSongs(context, it) + query?.let { searchString -> + val songs = SongLoader.getSongs(context, searchString) if (songs.isNotEmpty()) { results.add(context.resources.getString(R.string.songs)) results.addAll(songs) } - val artists = ArtistLoader.getArtists(context, it) + val artists = ArtistLoader.getArtists(context, searchString) if (artists.isNotEmpty()) { results.add(context.resources.getString(R.string.artists)) results.addAll(artists) } - val albums = AlbumLoader.getAlbums(context, it) + val albums = AlbumLoader.getAlbums(context, searchString) if (albums.isNotEmpty()) { results.add(context.resources.getString(R.string.albums)) results.addAll(albums) } + val genres: List = GenreLoader.getAllGenres(context).filter { genre -> genre.name.toLowerCase(Locale.getDefault()).contains(searchString.toLowerCase(Locale.getDefault())) } + genres.forEach { + println(it.name) + } + if (genres.isNotEmpty()) { + results.add(context.resources.getString(R.string.genres)) + results.addAll(genres) + } } return results - } } diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SearchPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SearchPresenter.kt index 1fd78208..994040b6 100644 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SearchPresenter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SearchPresenter.kt @@ -53,9 +53,7 @@ interface SearchPresenter : Presenter { override fun search(query: String?) { launch { when (val result = repository.search(query)) { - is Success -> withContext(Dispatchers.Main) { - view?.showData(result.data) - } + is Success -> withContext(Dispatchers.Main) { view?.showData(result.data) } is Error -> withContext(Dispatchers.Main) { view?.showEmptyView() } } } 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 cfea68ef..2b3757a4 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 @@ -247,12 +247,6 @@ class RepositoryImpl(private val context: Context) : Repository { } } - override fun getSongFlowable(id: Int): Observable { - return SongLoader.getSongFlowable(context, id) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - } - override fun getAlbumFlowable(albumId: Int): Observable { return AlbumLoader.getAlbumFlowable(context, albumId) .subscribeOn(Schedulers.io()) @@ -271,70 +265,12 @@ class RepositoryImpl(private val context: Context) : Repository { .observeOn(AndroidSchedulers.mainThread()) } - override fun getGenreFlowable(genreId: Int): Observable> { - return GenreLoader.getSongsFlowable(context, genreId) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - } - - override val favoritePlaylistFlowable: Observable> get() = PlaylistLoader.getFavoritePlaylistFlowable(context) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - override val allSongsFlowable: Observable> - get() = SongLoader.getAllSongsFlowable(context) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - - override val suggestionSongsFlowable: Observable> - get() = SongLoader.suggestSongs(context) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - - override val allAlbumsFlowable: Observable> - get() = AlbumLoader.getAllAlbumsFlowable(context) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - - override val recentAlbumsFlowable: Observable> - get() = LastAddedSongsLoader.getLastAddedAlbumsFlowable(context) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - - override val topAlbumsFlowable: Observable> - get() = TopAndRecentlyPlayedTracksLoader.getTopAlbumsFlowable(context) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - - override val allArtistsFlowable: Observable> - get() = ArtistLoader.getAllArtistsFlowable(context) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - - override val recentArtistsFlowable: Observable> - get() = LastAddedSongsLoader.getLastAddedArtistsFlowable(context) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - - override val topArtistsFlowable: Observable> - get() = TopAndRecentlyPlayedTracksLoader.getTopArtistsFlowable(context) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - - override val allPlaylistsFlowable: Observable> - get() = PlaylistLoader.getAllPlaylistsFlowoable(context) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - - - override val allGenresFlowable: Observable> - get() = GenreLoader.getAllGenresFlowable(context) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - override fun getSong(id: Int): Song { return SongLoader.getSong(context, id) } @@ -347,11 +283,10 @@ class RepositoryImpl(private val context: Context) : Repository { return ArtistLoader.getArtist(context, artistId.toInt()) } - } suspend fun safeApiCall(call: suspend () -> Result, errorMessage: String): Result = try { call.invoke() } catch (e: Exception) { - Result.Error(IOException(errorMessage, e)) + Error(IOException(errorMessage, e)) } 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 11222725..d8ce2363 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 @@ -55,28 +55,6 @@ interface Repository { suspend fun artistById(artistId: Int): Result - val allSongsFlowable: Observable> - - val suggestionSongsFlowable: Observable> - - val allAlbumsFlowable: Observable> - - val recentAlbumsFlowable: Observable> - - val topAlbumsFlowable: Observable> - - val allArtistsFlowable: Observable> - - val recentArtistsFlowable: Observable> - - val topArtistsFlowable: Observable> - - val allPlaylistsFlowable: Observable> - - val allGenresFlowable: Observable> - - fun getSongFlowable(id: Int): Observable - fun getSong(id: Int): Song fun getAlbumFlowable(albumId: Int): Observable @@ -89,10 +67,6 @@ interface Repository { fun getPlaylistSongsFlowable(playlist: Playlist): Observable> - fun getGenreFlowable(genreId: Int): Observable> - - val favoritePlaylistFlowable: Observable> - } \ 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 33b78ffe..cb964c39 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 @@ -16,6 +16,7 @@ package code.name.monkey.retromusic.views import android.content.Context import android.content.res.ColorStateList +import android.graphics.drawable.ColorDrawable import android.graphics.drawable.RippleDrawable import android.util.AttributeSet import androidx.core.content.ContextCompat @@ -45,7 +46,7 @@ class BottomNavigationBarTinted @JvmOverloads constructor( itemBackground = RippleDrawable(RippleUtils.convertToRippleDrawableColor(ColorStateList.valueOf(ThemeStore.accentColor(context).addAlpha())), ContextCompat.getDrawable(context, R.drawable.bottom_navigation_item_background), ContextCompat.getDrawable(context, R.drawable.bottom_navigation_item_background_mask)) setOnApplyWindowInsetsListener(null) //itemRippleColor = ColorStateList.valueOf(accentColor) - backgroundTintList = ColorStateList.valueOf(ATHUtil.resolveColor(context, android.R.attr.windowBackground)) + background = ColorDrawable(ATHUtil.resolveColor(context, R.attr.colorSurface)) } } diff --git a/app/src/main/res/layout/activity_playlist_detail.xml b/app/src/main/res/layout/activity_playlist_detail.xml index 22ed0a09..2ea2b31f 100644 --- a/app/src/main/res/layout/activity_playlist_detail.xml +++ b/app/src/main/res/layout/activity_playlist_detail.xml @@ -65,21 +65,22 @@ android:visibility="gone" tools:visibility="visible"> - + diff --git a/app/src/main/res/layout/activity_user_info.xml b/app/src/main/res/layout/activity_user_info.xml index 6c5ac19a..a082ac74 100644 --- a/app/src/main/res/layout/activity_user_info.xml +++ b/app/src/main/res/layout/activity_user_info.xml @@ -105,8 +105,8 @@ android:layout_margin="16dp" android:gravity="center" android:padding="12dp" - android:src="@drawable/ic_add_photo_white_24dp" - app:tint="?iconColor" /> + app:tint="?attr/colorControlNormal" + android:src="@drawable/ic_add_photo_white_24dp" /> \ 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 d550ee75..00b8ce7d 100644 --- a/app/src/main/res/layout/fragment_library.xml +++ b/app/src/main/res/layout/fragment_library.xml @@ -39,6 +39,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" + android:elevation="0dp" + app:elevation="0dp" app:liftOnScroll="true"> diff --git a/app/src/main/res/layout/item_list_quick_actions.xml b/app/src/main/res/layout/item_list_quick_actions.xml index f65ff5cb..5e53b9f7 100644 --- a/app/src/main/res/layout/item_list_quick_actions.xml +++ b/app/src/main/res/layout/item_list_quick_actions.xml @@ -28,6 +28,7 @@ android:layout_marginEnd="4dp" android:layout_weight="1" android:text="@string/action_play_all" + app:backgroundTint="?attr/colorSurface" app:icon="@drawable/ic_play_arrow_white_24dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_song.xml b/app/src/main/res/layout/item_song.xml index 3638a1c9..7bb5a74d 100755 --- a/app/src/main/res/layout/item_song.xml +++ b/app/src/main/res/layout/item_song.xml @@ -29,7 +29,7 @@ android:maxLines="1" android:minHeight="40dp" android:textAppearance="@style/TextViewNormal" - android:textColor="?attr/colorOnSecondary" + android:textColor="?android:attr/textColorSecondary" tools:text="@tools:sample/date/hhmm" /> @@ -55,7 +55,7 @@ android:layout_weight="0" android:fontFeatureSettings="onum" android:padding="4dp" - android:textColor="?attr/colorOnSecondary" + android:textColor="?android:attr/textColorSecondary" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/menu" app:layout_constraintTop_toTopOf="parent" 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 101b121f..6bb77230 100644 --- a/app/src/main/res/layout/sliding_music_panel_layout.xml +++ b/app/src/main/res/layout/sliding_music_panel_layout.xml @@ -53,7 +53,6 @@ android:layout_gravity="bottom" android:elevation="0dp" android:visibility="gone" - app:backgroundTint="?android:attr/windowBackground" app:itemHorizontalTranslationEnabled="false" app:itemIconTint="@drawable/bottom_navigation_item_colors" app:itemTextAppearanceActive="@style/BottomSheetItemTextAppearanceActive" diff --git a/app/src/main/res/values/styles_parents.xml b/app/src/main/res/values/styles_parents.xml index f9fe252d..ba4afaa2 100644 --- a/app/src/main/res/values/styles_parents.xml +++ b/app/src/main/res/values/styles_parents.xml @@ -5,7 +5,7 @@ @font/circular @font/circular @font/circular - + @color/md_red_500 true true @font/circular @@ -20,6 +20,7 @@ @drawable/rect_selector @drawable/rect_selector_strong +