Skip to content

Commit

Permalink
Merge pull request #1350 from prathameshmm02/dev
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
Daksh777 committed May 12, 2022
2 parents 7913bf4 + c3e5397 commit b6294db
Show file tree
Hide file tree
Showing 38 changed files with 282 additions and 246 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {

applicationId "code.name.monkey.retromusic"
versionCode 10577
versionName '5.8.3'
versionName '5.8.4'

buildConfigField("String", "GOOGLE_PLAY_LICENSING_KEY", "\"${getProperty(getProperties('../public.properties'), 'GOOGLE_PLAY_LICENSE_KEY')}\"")
}
Expand Down Expand Up @@ -111,7 +111,7 @@ dependencies {
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"

def lifecycle_version = "2.5.0-beta01"
def lifecycle_version = "2.5.0-rc01"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
Expand Down Expand Up @@ -139,11 +139,11 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"

def koin_version = '3.2.0-beta-1'
def koin_version = '3.2.0'
implementation "io.insert-koin:koin-core:$koin_version"
implementation "io.insert-koin:koin-android:$koin_version"

def glide_version = '4.13.1'
def glide_version = '4.13.2'
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
implementation "com.github.bumptech.glide:okhttp3-integration:$glide_version"
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
xmlns:tools="http://schemas.android.com/tools"
package="code.name.monkey.retromusic">

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
Expand All @@ -19,15 +23,14 @@
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<application
android:name=".App"
android:allowBackup="@bool/allowBackup"
android:configChanges="locale|layoutDirection"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:restoreAnyVersion="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/assets/retro-changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@
</head>

<body>
<div>
<h5>May 13, 2022</h5>
<h2>v5.8.4</h2>
<h3>What's New</h3>
<ul>
<li>Added a toggle to enable/disable swipe down to dismiss mini player</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Fixed crash when adding folders to blacklist</li>
<li>Fix bugs in MD3 theme</li>
</ul>
</div>
<div>
<h5>May 07, 2022</h5>
<h2>v5.8.3</h2>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/code/name/monkey/retromusic/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,5 @@ const val SCREEN_ON_LYRICS = "screen_on_lyrics"
const val CIRCLE_PLAY_BUTTON = "circle_play_button"
const val SWIPE_ANYWHERE_NOW_PLAYING = "swipe_anywhere_now_playing"
const val PAUSE_HISTORY = "pause_history"
const val MANAGE_AUDIO_FOCUS = "manage_audio_focus"
const val MANAGE_AUDIO_FOCUS = "manage_audio_focus"
const val SWIPE_DOWN_DISMISS = "swipe_to_dismiss"
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class MainActivity : AbsCastActivity(), OnSharedPreferenceChangeListener {
}

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
if (key == GENERAL_THEME || key == MATERIAL_YOU || key == WALLPAPER_ACCENT || key == BLACK_THEME || key == ADAPTIVE_COLOR_APP || key == USER_NAME || key == TOGGLE_FULL_SCREEN || key == TOGGLE_VOLUME || key == ROUND_CORNERS || key == CAROUSEL_EFFECT || key == NOW_PLAYING_SCREEN_ID || key == TOGGLE_GENRE || key == BANNER_IMAGE_PATH || key == PROFILE_IMAGE_PATH || key == CIRCULAR_ALBUM_ART || key == KEEP_SCREEN_ON || key == TOGGLE_SEPARATE_LINE || key == TOGGLE_HOME_BANNER || key == TOGGLE_ADD_CONTROLS || key == ALBUM_COVER_STYLE || key == HOME_ARTIST_GRID_STYLE || key == ALBUM_COVER_TRANSFORM || key == DESATURATED_COLOR || key == EXTRA_SONG_INFO || key == TAB_TEXT_MODE || key == LANGUAGE_NAME || key == LIBRARY_CATEGORIES || key == CUSTOM_FONT || key == APPBAR_MODE || key == CIRCLE_PLAY_BUTTON) {
if (key == GENERAL_THEME || key == MATERIAL_YOU || key == WALLPAPER_ACCENT || key == BLACK_THEME || key == ADAPTIVE_COLOR_APP || key == USER_NAME || key == TOGGLE_FULL_SCREEN || key == TOGGLE_VOLUME || key == ROUND_CORNERS || key == CAROUSEL_EFFECT || key == NOW_PLAYING_SCREEN_ID || key == TOGGLE_GENRE || key == BANNER_IMAGE_PATH || key == PROFILE_IMAGE_PATH || key == CIRCULAR_ALBUM_ART || key == KEEP_SCREEN_ON || key == TOGGLE_SEPARATE_LINE || key == TOGGLE_HOME_BANNER || key == TOGGLE_ADD_CONTROLS || key == ALBUM_COVER_STYLE || key == HOME_ARTIST_GRID_STYLE || key == ALBUM_COVER_TRANSFORM || key == DESATURATED_COLOR || key == EXTRA_SONG_INFO || key == TAB_TEXT_MODE || key == LANGUAGE_NAME || key == LIBRARY_CATEGORIES || key == CUSTOM_FONT || key == APPBAR_MODE || key == CIRCLE_PLAY_BUTTON || key == SWIPE_DOWN_DISMISS) {
postRecreate()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import androidx.core.net.toUri
import androidx.core.text.parseAsHtml
import androidx.core.view.isVisible
import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
import code.name.monkey.retromusic.databinding.ActivityPermissionBinding
import code.name.monkey.retromusic.extensions.*
import code.name.monkey.retromusic.util.RingtoneManager

class PermissionActivity : AbsMusicServiceActivity() {
private lateinit var binding: ActivityPermissionBinding
Expand All @@ -49,7 +49,7 @@ class PermissionActivity : AbsMusicServiceActivity() {
if (VersionUtils.hasMarshmallow()) {
binding.audioPermission.show()
binding.audioPermission.setButtonClick {
if (RingtoneManager.requiresDialog(this@PermissionActivity)) {
if (hasAudioPermission()) {
val intent = Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS)
intent.data = ("package:" + applicationContext.packageName).toUri()
startActivity(intent)
Expand All @@ -75,7 +75,8 @@ class PermissionActivity : AbsMusicServiceActivity() {
val color = accentColor()
val hexColor = String.format("#%06X", 0xFFFFFF and color)
val appName =
"Hello there! <br>Welcome to <b>Retro <span style='color:$hexColor';>Music</span></b>"
getString(R.string.message_welcome,
"<b>Retro <span style='color:$hexColor';>Music</span></b>")
.parseAsHtml()
binding.appNameText.text = appName
}
Expand All @@ -97,7 +98,8 @@ class PermissionActivity : AbsMusicServiceActivity() {
}

private fun hasStoragePermission(): Boolean {
return ActivityCompat.checkSelfPermission(this , Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
return ActivityCompat.checkSelfPermission(this,
Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
}

@RequiresApi(Build.VERSION_CODES.M)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ abstract class AbsCastActivity : AbsSlidingMusicPanelActivity() {
mCastSession = castSession
webServer.start()
mCastSession?.remoteMediaClient?.let {
loadCastQueue(it.mediaQueue.indexOfItemWithId(it.currentItem?.itemId ?: 0), it.approximateStreamPosition)
loadCastQueue(it.mediaQueue.indexOfItemWithId(it.currentItem?.itemId ?: 0),
it.approximateStreamPosition)
}

MusicPlayerRemote.isCasting = true
Expand Down Expand Up @@ -126,7 +127,7 @@ abstract class AbsCastActivity : AbsSlidingMusicPanelActivity() {
progress: Long = MusicPlayerRemote.songProgressMillis.toLong(),
) {
mCastSession?.let {
if (!MusicPlayerRemote.playingQueue.isNullOrEmpty()) {
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
CastHelper.castQueue(
it,
MusicPlayerRemote.playingQueue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import android.content.*
import android.os.Bundle
import android.os.IBinder
import androidx.lifecycle.lifecycleScope
import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.db.toPlayCount
import code.name.monkey.retromusic.helper.MusicPlayerRemote
Expand Down Expand Up @@ -188,11 +189,15 @@ abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventLi
}

override fun getPermissionsToRequest(): Array<String> {
return arrayOf(
return mutableListOf(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.BLUETOOTH
)
if (VersionUtils.hasS()) Manifest.permission.BLUETOOTH_CONNECT
else Manifest.permission.BLUETOOTH
).apply {
if (!VersionUtils.hasQ()) {
add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
}
}.toTypedArray()
}

private class MusicStateReceiver(activity: AbsMusicServiceActivity) : BroadcastReceiver() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
private fun setupBottomSheet() {
bottomSheetBehavior = from(binding.slidingPanel)
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallbackList)
bottomSheetBehavior.isHideable = true
if (PreferenceUtil.swipeDownToDismiss) bottomSheetBehavior.isHideable = true
setMiniPlayerAlphaProgress(0F)
}

Expand Down Expand Up @@ -298,7 +298,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
navigationBarColor = surfaceColor()
setTaskDescColor(paletteColor)
val isColorLight = paletteColor.isColorLight
if (PreferenceUtil.isAdaptiveColor && (nowPlayingScreen == Normal || nowPlayingScreen == Flat || nowPlayingScreen == Material)) {
if (PreferenceUtil.isAdaptiveColor && (nowPlayingScreen == Normal || nowPlayingScreen == Flat || nowPlayingScreen == Material)) {
setLightNavigationBar(true)
setLightStatusBar(isColorLight)
} else if (nowPlayingScreen == Card || nowPlayingScreen == Blur || nowPlayingScreen == BlurCard) {
Expand Down Expand Up @@ -357,7 +357,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
fun setBottomNavVisibility(
visible: Boolean,
animate: Boolean = false,
hideBottomSheet: Boolean = MusicPlayerRemote.playingQueue.isEmpty()
hideBottomSheet: Boolean = MusicPlayerRemote.playingQueue.isEmpty(),
) {
if (isInOneTabMode) {
hideBottomSheet(
Expand Down Expand Up @@ -391,7 +391,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
fun hideBottomSheet(
hide: Boolean,
animate: Boolean = false,
isBottomNavVisible: Boolean = bottomNavigationView.isVisible
isBottomNavVisible: Boolean = bottomNavigationView.isVisible,
) {
val heightOfBar =
windowInsets.safeGetBottomInsets() +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import code.name.monkey.retromusic.extensions.*
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.theme.getNightMode
import code.name.monkey.retromusic.util.theme.getThemeResValue
import com.google.android.play.core.splitcompat.SplitCompat
import java.util.*

abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
Expand Down Expand Up @@ -122,5 +123,6 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
Locale.forLanguageTag(code)
}
super.attachBaseContext(LanguageContextWrapper.wrap(newBase, locale))
SplitCompat.install(this)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class AlbumTagEditorActivity : AbsTagEditorActivity<ActivityAlbumTagEditorBindin

override fun onLoadFailed(errorDrawable: Drawable?) {
super.onLoadFailed(errorDrawable)
showToast("Load Failed", Toast.LENGTH_LONG)
showToast(R.string.error_load_failed, Toast.LENGTH_LONG)
}

override fun setResource(resource: BitmapPaletteWrapper?) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class SongTagEditorActivity : AbsTagEditorActivity<ActivitySongTagEditorBinding>

override fun onLoadFailed(errorDrawable: Drawable?) {
super.onLoadFailed(errorDrawable)
showToast("Load Failed", Toast.LENGTH_LONG)
showToast(R.string.error_load_failed, Toast.LENGTH_LONG)
}

override fun setResource(resource: BitmapPaletteWrapper?) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object CastHelper {
val remoteMediaClient = castSession.remoteMediaClient
remoteMediaClient?.queueLoad(
songs.toMediaInfoList(),
position,
if (position != -1) position else 0,
MediaStatus.REPEAT_MODE_REPEAT_OFF,
progress,
JSONObject()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package code.name.monkey.retromusic.dialogs

import android.Manifest
import android.app.Dialog
import android.content.Context
import android.content.pm.PackageManager
import android.os.Bundle
import androidx.core.app.ActivityCompat
Expand Down Expand Up @@ -80,7 +81,7 @@ class BlacklistFolderChooserDialog : DialogFragment() {
}
.noAutoDismiss()
.positiveButton(res = R.string.add_action) {
callback?.onFolderSelection(this@BlacklistFolderChooserDialog, parentFolder!!)
callback?.onFolderSelection(requireContext(), parentFolder!!)
dismiss()
}
.negativeButton(res = android.R.string.cancel) { dismiss() }
Expand Down Expand Up @@ -128,7 +129,7 @@ class BlacklistFolderChooserDialog : DialogFragment() {
}

interface FolderCallback {
fun onFolderSelection(dialog: BlacklistFolderChooserDialog, folder: File)
fun onFolderSelection(context: Context, folder: File)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
package code.name.monkey.retromusic.extensions

import android.support.v4.media.MediaDescriptionCompat
import android.support.v4.media.session.MediaSessionCompat.QueueItem
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.MusicUtil

val Song.uri get() = MusicUtil.getSongFileUri(songId = id)
val Song.uri get() = MusicUtil.getSongFileUri(songId = id)


fun ArrayList<Song>.toMediaSessionQueue(): List<QueueItem> {
return map {
val mediaDescription = MediaDescriptionCompat.Builder()
.setMediaId(it.id.toString())
.setTitle(it.title)
.setSubtitle(it.artistName)
.build()
QueueItem(mediaDescription, it.hashCode().toLong())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class BackupFragment : Fragment(R.layout.fragment_backup), BackupAdapter.BackupC
try {
file.delete()
} catch (exception: SecurityException) {
showToast("Could not delete backup")
showToast(R.string.error_delete_backup)
}
backupViewModel.loadBackups()
return true
Expand All @@ -147,7 +147,7 @@ class BackupFragment : Fragment(R.layout.fragment_backup), BackupAdapter.BackupC
file.renameTo(renamedFile)
backupViewModel.loadBackups()
} else {
showToast("File already exists")
showToast(R.string.file_already_exists)
}
}
positiveButton(android.R.string.ok)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,14 @@ abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMusicServiceFragme
return true
}
R.id.action_set_as_ringtone -> {
if (RingtoneManager.requiresDialog(requireActivity())) {
RingtoneManager.getDialog(requireActivity())
requireContext().run {
if (RingtoneManager.requiresDialog(this)) {
RingtoneManager.showDialog(this)
} else {
RingtoneManager.setRingtone(this, song)
}
}
val ringtoneManager = RingtoneManager(requireActivity())
ringtoneManager.setRingtone(song)

return true
}
R.id.action_go_to_genre -> {
Expand Down Expand Up @@ -265,7 +268,7 @@ abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMusicServiceFragme
} else {
if (isFavorite) R.drawable.ic_favorite else R.drawable.ic_favorite_border
}
val drawable = requireContext().getTintedDrawable(
val drawable = requireContext().getTintedDrawable(
icon,
toolbarIconColor()
)
Expand Down Expand Up @@ -379,9 +382,7 @@ fun goToArtist(activity: Activity) {
findNavController(R.id.fragment_container).navigate(
R.id.artistDetailsFragment,
bundleOf(EXTRA_ARTIST_ID to song.artistId),
navOptions {
launchSingleTop = true
},
null,
null
)
}
Expand All @@ -402,9 +403,7 @@ fun goToAlbum(activity: Activity) {
findNavController(R.id.fragment_container).navigate(
R.id.albumDetailsFragment,
bundleOf(EXTRA_ALBUM_ID to song.albumId),
navOptions {
launchSingleTop = true
},
null,
null
)
}
Expand Down
Loading

0 comments on commit b6294db

Please sign in to comment.