Code refactor 🧑💻
This commit is contained in:
parent
2817dc1db5
commit
543893adba
26 changed files with 77 additions and 111 deletions
|
@ -34,7 +34,7 @@ android {
|
||||||
}
|
}
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
release {
|
release {
|
||||||
Properties properties = getProperties('/Users/h4h13/Documents/Github/retro.properties')
|
Properties properties = getProperties('/Users/apple/Documents/Github/retro.properties ')
|
||||||
storeFile file(getProperty(properties, 'storeFile'))
|
storeFile file(getProperty(properties, 'storeFile'))
|
||||||
keyAlias getProperty(properties, 'keyAlias')
|
keyAlias getProperty(properties, 'keyAlias')
|
||||||
storePassword getProperty(properties, 'storePassword')
|
storePassword getProperty(properties, 'storePassword')
|
||||||
|
@ -130,7 +130,7 @@ dependencies {
|
||||||
implementation "com.afollestad.material-dialogs:commons:$material_dialog_version"
|
implementation "com.afollestad.material-dialogs:commons:$material_dialog_version"
|
||||||
implementation 'com.afollestad:material-cab:0.1.12'
|
implementation 'com.afollestad:material-cab:0.1.12'
|
||||||
implementation 'com.afollestad:recyclical:1.1.1'
|
implementation 'com.afollestad:recyclical:1.1.1'
|
||||||
|
|
||||||
implementation 'com.github.bumptech.glide:glide:3.8.0'
|
implementation 'com.github.bumptech.glide:glide:3.8.0'
|
||||||
implementation 'com.github.bumptech.glide:okhttp3-integration:1.5.0'
|
implementation 'com.github.bumptech.glide:okhttp3-integration:1.5.0'
|
||||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
|
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
|
||||||
|
|
|
@ -218,7 +218,7 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
|
||||||
.build()
|
.build()
|
||||||
.transform(BlurTransformation.Builder(this).build())
|
.transform(BlurTransformation.Builder(this).build())
|
||||||
.into(object : RetroMusicColoredTarget(image) {
|
.into(object : RetroMusicColoredTarget(image) {
|
||||||
override fun onColorReady(color: MediaNotificationProcessor) {
|
override fun onColorReady(colors: MediaNotificationProcessor) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.SharedPreferences
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.util.Log
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import code.name.monkey.retromusic.*
|
import code.name.monkey.retromusic.*
|
||||||
|
@ -112,7 +111,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
||||||
if (intent.action != null && (intent.action == MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)
|
if (intent.action != null && (intent.action == MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)
|
||||||
) {
|
) {
|
||||||
val songs: List<Song> =
|
val songs: List<Song> =
|
||||||
getSongs(this, intent.extras!!)
|
getSongs(intent.extras!!)
|
||||||
if (shuffleMode == MusicService.SHUFFLE_MODE_SHUFFLE) {
|
if (shuffleMode == MusicService.SHUFFLE_MODE_SHUFFLE) {
|
||||||
openAndShuffleQueue(songs, true)
|
openAndShuffleQueue(songs, true)
|
||||||
} else {
|
} else {
|
||||||
|
@ -167,7 +166,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
||||||
try {
|
try {
|
||||||
id = idString.toLong()
|
id = idString.toLong()
|
||||||
} catch (e: NumberFormatException) {
|
} catch (e: NumberFormatException) {
|
||||||
Log.e(TAG, e.message)
|
//Log.e(TAG, e.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ open class PlayingQueueActivity : AbsMusicServiceActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
val fastScroller = ThemedFastScroller.create(recyclerView)
|
ThemedFastScroller.create(recyclerView)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForPadding() {
|
private fun checkForPadding() {
|
||||||
|
|
|
@ -110,7 +110,7 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
|
||||||
}
|
}
|
||||||
if (requestCode == TEZ_REQUEST_CODE) {
|
if (requestCode == TEZ_REQUEST_CODE) {
|
||||||
// Process based on the data in response.
|
// Process based on the data in response.
|
||||||
Log.d("result", data!!.getStringExtra("Status"))
|
//Log.d("result", data!!.getStringExtra("Status"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,22 +280,22 @@ open class BugReportActivity : AbsThemeActivity() {
|
||||||
RESULT_BAD_CREDENTIALS -> MaterialAlertDialogBuilder(context)
|
RESULT_BAD_CREDENTIALS -> MaterialAlertDialogBuilder(context)
|
||||||
.setTitle(R.string.bug_report_failed)
|
.setTitle(R.string.bug_report_failed)
|
||||||
.setMessage(R.string.bug_report_failed_wrong_credentials)
|
.setMessage(R.string.bug_report_failed_wrong_credentials)
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.show()
|
.show()
|
||||||
RESULT_INVALID_TOKEN -> MaterialAlertDialogBuilder(context)
|
RESULT_INVALID_TOKEN -> MaterialAlertDialogBuilder(context)
|
||||||
.setTitle(R.string.bug_report_failed)
|
.setTitle(R.string.bug_report_failed)
|
||||||
.setMessage(R.string.bug_report_failed_invalid_token)
|
.setMessage(R.string.bug_report_failed_invalid_token)
|
||||||
.setPositiveButton(android.R.string.ok, null).show()
|
.setPositiveButton(R.string.ok, null).show()
|
||||||
RESULT_ISSUES_NOT_ENABLED -> MaterialAlertDialogBuilder(context)
|
RESULT_ISSUES_NOT_ENABLED -> MaterialAlertDialogBuilder(context)
|
||||||
.setTitle(R.string.bug_report_failed)
|
.setTitle(R.string.bug_report_failed)
|
||||||
.setMessage(R.string.bug_report_failed_issues_not_available)
|
.setMessage(R.string.bug_report_failed_issues_not_available)
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
|
|
||||||
else -> MaterialAlertDialogBuilder(context)
|
else -> MaterialAlertDialogBuilder(context)
|
||||||
.setTitle(R.string.bug_report_failed)
|
.setTitle(R.string.bug_report_failed)
|
||||||
.setMessage(R.string.bug_report_failed_unknown)
|
.setMessage(R.string.bug_report_failed_unknown)
|
||||||
.setPositiveButton(android.R.string.ok) { _, _ -> tryToFinishActivity() }
|
.setPositiveButton(R.string.ok) { _, _ -> tryToFinishActivity() }
|
||||||
.setNegativeButton(android.R.string.cancel) { _, _ -> { tryToFinishActivity() } }
|
.setNegativeButton(android.R.string.cancel) { _, _ -> tryToFinishActivity() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,9 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
||||||
window.enterTransition = slide
|
window.enterTransition = slide
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadImageFromFile(selectedFileUri: Uri?) {
|
override fun loadImageFromFile(selectedFile: Uri?) {
|
||||||
|
|
||||||
Glide.with(this@AlbumTagEditorActivity).load(selectedFileUri).asBitmap()
|
Glide.with(this@AlbumTagEditorActivity).load(selectedFile).asBitmap()
|
||||||
.transcode(BitmapPaletteTranscoder(this), BitmapPaletteWrapper::class.java)
|
.transcode(BitmapPaletteTranscoder(this), BitmapPaletteWrapper::class.java)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true)
|
.diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true)
|
||||||
.into(object : SimpleTarget<BitmapPaletteWrapper>() {
|
.into(object : SimpleTarget<BitmapPaletteWrapper>() {
|
||||||
|
|
|
@ -169,7 +169,7 @@ class PlayingQueueAdapter(
|
||||||
holder: ViewHolder?,
|
holder: ViewHolder?,
|
||||||
position: Int, @SwipeableItemResults result: Int
|
position: Int, @SwipeableItemResults result: Int
|
||||||
): SwipeResultAction {
|
): SwipeResultAction {
|
||||||
return if (result === SwipeableItemConstants.RESULT_CANCELED) {
|
return if (result == SwipeableItemConstants.RESULT_CANCELED) {
|
||||||
SwipeResultActionDefault()
|
SwipeResultActionDefault()
|
||||||
} else {
|
} else {
|
||||||
SwipedResultActionRemoveItem(this, position, activity)
|
SwipedResultActionRemoveItem(this, position, activity)
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class BlacklistFolderChooserDialog extends DialogFragment implements Mate
|
||||||
return new MaterialDialog.Builder(requireActivity())
|
return new MaterialDialog.Builder(requireActivity())
|
||||||
.title(R.string.md_error_label)
|
.title(R.string.md_error_label)
|
||||||
.content(R.string.md_storage_perm_error)
|
.content(R.string.md_storage_perm_error)
|
||||||
.positiveText(android.R.string.ok)
|
.positiveText(R.string.ok)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
|
|
|
@ -42,24 +42,25 @@ class DeleteSongsDialog : DialogFragment() {
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val songs = extraNotNull<List<Song>>(EXTRA_SONG).value
|
val songs = extraNotNull<List<Song>>(EXTRA_SONG).value
|
||||||
var title = 0
|
val pair = if (songs.size > 1) {
|
||||||
var message: CharSequence = ""
|
Pair(
|
||||||
if (songs.size > 1) {
|
R.string.delete_songs_title, HtmlCompat.fromHtml(
|
||||||
title = R.string.delete_songs_title
|
String.format(getString(R.string.delete_x_songs), songs.size),
|
||||||
message = HtmlCompat.fromHtml(
|
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||||
String.format(getString(R.string.delete_x_songs), songs.size),
|
)
|
||||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
title = R.string.delete_song_title
|
Pair(
|
||||||
message = HtmlCompat.fromHtml(
|
R.string.delete_song_title,
|
||||||
String.format(getString(R.string.delete_song_x), songs[0].title),
|
HtmlCompat.fromHtml(
|
||||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
String.format(getString(R.string.delete_song_x), songs[0].title),
|
||||||
|
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return materialDialog(title)
|
return materialDialog(pair.first)
|
||||||
.setMessage(message)
|
.setMessage(pair.second)
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.setPositiveButton(R.string.action_delete) { _, _ ->
|
.setPositiveButton(R.string.action_delete) { _, _ ->
|
||||||
|
|
|
@ -21,8 +21,6 @@ import android.os.Bundle
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.NonNull
|
import androidx.annotation.NonNull
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
|
@ -41,12 +39,6 @@ import org.jaudiotagger.tag.TagException
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
inline fun ViewGroup.forEach(action: (View) -> Unit) {
|
|
||||||
for (i in 0 until childCount) {
|
|
||||||
action(getChildAt(i))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SongDetailDialog : DialogFragment() {
|
class SongDetailDialog : DialogFragment() {
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
|
@ -152,7 +144,7 @@ class SongDetailDialog : DialogFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return materialDialog(R.string.action_details)
|
return materialDialog(R.string.action_details)
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setView(dialogView)
|
.setView(dialogView)
|
||||||
.create()
|
.create()
|
||||||
.colorButtons()
|
.colorButtons()
|
||||||
|
|
|
@ -15,13 +15,8 @@
|
||||||
package code.name.monkey.retromusic.extensions
|
package code.name.monkey.retromusic.extensions
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import androidx.annotation.IdRes
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
|
||||||
import androidx.fragment.app.FragmentTransaction
|
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
import code.name.monkey.retromusic.R
|
|
||||||
import com.google.android.material.appbar.MaterialToolbar
|
import com.google.android.material.appbar.MaterialToolbar
|
||||||
|
|
||||||
fun AppCompatActivity.applyToolbar(toolbar: MaterialToolbar) {
|
fun AppCompatActivity.applyToolbar(toolbar: MaterialToolbar) {
|
||||||
|
@ -30,41 +25,6 @@ fun AppCompatActivity.applyToolbar(toolbar: MaterialToolbar) {
|
||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun FragmentActivity?.addFragment(
|
|
||||||
@IdRes idRes: Int = R.id.container,
|
|
||||||
fragment: Fragment,
|
|
||||||
tag: String? = null,
|
|
||||||
addToBackStack: Boolean = false
|
|
||||||
) {
|
|
||||||
val compatActivity = this as? AppCompatActivity ?: return
|
|
||||||
compatActivity.supportFragmentManager.beginTransaction()
|
|
||||||
.apply {
|
|
||||||
add(fragment, tag)
|
|
||||||
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
|
||||||
if (addToBackStack) {
|
|
||||||
addToBackStack(null)
|
|
||||||
}
|
|
||||||
commitNow()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun AppCompatActivity.replaceFragment(
|
|
||||||
@IdRes id: Int = R.id.container,
|
|
||||||
fragment: Fragment,
|
|
||||||
tag: String? = null,
|
|
||||||
addToBackStack: Boolean = false
|
|
||||||
) {
|
|
||||||
val compatActivity = this
|
|
||||||
compatActivity.supportFragmentManager.beginTransaction()
|
|
||||||
.apply {
|
|
||||||
replace(id, fragment, tag)
|
|
||||||
if (addToBackStack) {
|
|
||||||
addToBackStack(null)
|
|
||||||
}
|
|
||||||
commit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fun <reified T : Any> Activity.extra(key: String, default: T? = null) = lazy {
|
inline fun <reified T : Any> Activity.extra(key: String, default: T? = null) = lazy {
|
||||||
val value = intent?.extras?.get(key)
|
val value = intent?.extras?.get(key)
|
||||||
if (value is T) value else default
|
if (value is T) value else default
|
||||||
|
|
|
@ -51,7 +51,7 @@ class LibraryViewModel(
|
||||||
artists.value = loadArtists.await()
|
artists.value = loadArtists.await()
|
||||||
playlists.value = loadPlaylists.await()
|
playlists.value = loadPlaylists.await()
|
||||||
roomPlaylists.value = loadPlaylistsWithSongs.await()
|
roomPlaylists.value = loadPlaylistsWithSongs.await()
|
||||||
//genres.value = loadGenres.await()
|
genres.value = loadGenres.await()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val loadHome: Deferred<List<Home>>
|
private val loadHome: Deferred<List<Home>>
|
||||||
|
|
|
@ -36,7 +36,7 @@ class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_
|
||||||
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
||||||
mainActivity.setSupportActionBar(toolbar)
|
mainActivity.setSupportActionBar(toolbar)
|
||||||
mainActivity.hideBottomBarVisibility(false)
|
mainActivity.hideBottomBarVisibility(false)
|
||||||
|
progressIndicator.hide()
|
||||||
setupRecyclerView()
|
setupRecyclerView()
|
||||||
detailsViewModel.getSongs().observe(viewLifecycleOwner, androidx.lifecycle.Observer {
|
detailsViewModel.getSongs().observe(viewLifecycleOwner, androidx.lifecycle.Observer {
|
||||||
songs(it)
|
songs(it)
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
package code.name.monkey.retromusic.helper
|
package code.name.monkey.retromusic.helper
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import code.name.monkey.retromusic.model.Playlist
|
import code.name.monkey.retromusic.model.Playlist
|
||||||
import java.io.BufferedWriter
|
import java.io.BufferedWriter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -24,14 +23,13 @@ object M3UWriter : M3UConstants {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun write(
|
fun write(
|
||||||
context: Context,
|
|
||||||
dir: File,
|
dir: File,
|
||||||
playlist: Playlist
|
playlist: Playlist
|
||||||
): File? {
|
): File? {
|
||||||
if (!dir.exists()) dir.mkdirs()
|
if (!dir.exists()) dir.mkdirs()
|
||||||
val file = File(dir, playlist.name + "." + M3UConstants.EXTENSION)
|
val file = File(dir, playlist.name + "." + M3UConstants.EXTENSION)
|
||||||
val songs = playlist.getSongs()
|
val songs = playlist.getSongs()
|
||||||
if (songs.size > 0) {
|
if (songs.isNotEmpty()) {
|
||||||
val bw = BufferedWriter(FileWriter(file))
|
val bw = BufferedWriter(FileWriter(file))
|
||||||
bw.write(M3UConstants.HEADER)
|
bw.write(M3UConstants.HEADER)
|
||||||
for (song in songs) {
|
for (song in songs) {
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
package code.name.monkey.retromusic.helper
|
package code.name.monkey.retromusic.helper
|
||||||
|
|
||||||
import android.app.SearchManager
|
import android.app.SearchManager
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
@ -33,7 +32,7 @@ object SearchQueryHelper : KoinComponent {
|
||||||
var songs = ArrayList<Song>()
|
var songs = ArrayList<Song>()
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getSongs(context: Context, extras: Bundle): List<Song> {
|
fun getSongs(extras: Bundle): List<Song> {
|
||||||
val query = extras.getString(SearchManager.QUERY, null)
|
val query = extras.getString(SearchManager.QUERY, null)
|
||||||
val artistName = extras.getString(MediaStore.EXTRA_MEDIA_ARTIST, null)
|
val artistName = extras.getString(MediaStore.EXTRA_MEDIA_ARTIST, null)
|
||||||
val albumName = extras.getString(MediaStore.EXTRA_MEDIA_ALBUM, null)
|
val albumName = extras.getString(MediaStore.EXTRA_MEDIA_ALBUM, null)
|
||||||
|
@ -45,9 +44,9 @@ object SearchQueryHelper : KoinComponent {
|
||||||
songRepository.makeSongCursor(
|
songRepository.makeSongCursor(
|
||||||
ARTIST_SELECTION + AND + ALBUM_SELECTION + AND + TITLE_SELECTION,
|
ARTIST_SELECTION + AND + ALBUM_SELECTION + AND + TITLE_SELECTION,
|
||||||
arrayOf(
|
arrayOf(
|
||||||
artistName.toLowerCase(),
|
artistName.toLowerCase(Locale.getDefault()),
|
||||||
albumName.toLowerCase(),
|
albumName.toLowerCase(Locale.getDefault()),
|
||||||
titleName.toLowerCase()
|
titleName.toLowerCase(Locale.getDefault())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -59,7 +58,10 @@ object SearchQueryHelper : KoinComponent {
|
||||||
songs = songRepository.songs(
|
songs = songRepository.songs(
|
||||||
songRepository.makeSongCursor(
|
songRepository.makeSongCursor(
|
||||||
ARTIST_SELECTION + AND + TITLE_SELECTION,
|
ARTIST_SELECTION + AND + TITLE_SELECTION,
|
||||||
arrayOf(artistName.toLowerCase(), titleName.toLowerCase())
|
arrayOf(
|
||||||
|
artistName.toLowerCase(Locale.getDefault()),
|
||||||
|
titleName.toLowerCase(Locale.getDefault())
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -70,7 +72,10 @@ object SearchQueryHelper : KoinComponent {
|
||||||
songs = songRepository.songs(
|
songs = songRepository.songs(
|
||||||
songRepository.makeSongCursor(
|
songRepository.makeSongCursor(
|
||||||
ALBUM_SELECTION + AND + TITLE_SELECTION,
|
ALBUM_SELECTION + AND + TITLE_SELECTION,
|
||||||
arrayOf(albumName.toLowerCase(), titleName.toLowerCase())
|
arrayOf(
|
||||||
|
albumName.toLowerCase(Locale.getDefault()),
|
||||||
|
titleName.toLowerCase(Locale.getDefault())
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -81,7 +86,7 @@ object SearchQueryHelper : KoinComponent {
|
||||||
songs = songRepository.songs(
|
songs = songRepository.songs(
|
||||||
songRepository.makeSongCursor(
|
songRepository.makeSongCursor(
|
||||||
ARTIST_SELECTION,
|
ARTIST_SELECTION,
|
||||||
arrayOf(artistName.toLowerCase())
|
arrayOf(artistName.toLowerCase(Locale.getDefault()))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -92,7 +97,7 @@ object SearchQueryHelper : KoinComponent {
|
||||||
songs = songRepository.songs(
|
songs = songRepository.songs(
|
||||||
songRepository.makeSongCursor(
|
songRepository.makeSongCursor(
|
||||||
ALBUM_SELECTION,
|
ALBUM_SELECTION,
|
||||||
arrayOf(albumName.toLowerCase())
|
arrayOf(albumName.toLowerCase(Locale.getDefault()))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -103,7 +108,7 @@ object SearchQueryHelper : KoinComponent {
|
||||||
songs = songRepository.songs(
|
songs = songRepository.songs(
|
||||||
songRepository.makeSongCursor(
|
songRepository.makeSongCursor(
|
||||||
TITLE_SELECTION,
|
TITLE_SELECTION,
|
||||||
arrayOf(titleName.toLowerCase())
|
arrayOf(titleName.toLowerCase(Locale.getDefault()))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -113,7 +118,7 @@ object SearchQueryHelper : KoinComponent {
|
||||||
songs = songRepository.songs(
|
songs = songRepository.songs(
|
||||||
songRepository.makeSongCursor(
|
songRepository.makeSongCursor(
|
||||||
ARTIST_SELECTION,
|
ARTIST_SELECTION,
|
||||||
arrayOf(query.toLowerCase())
|
arrayOf(query.toLowerCase(Locale.getDefault()))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -123,7 +128,7 @@ object SearchQueryHelper : KoinComponent {
|
||||||
songs = songRepository.songs(
|
songs = songRepository.songs(
|
||||||
songRepository.makeSongCursor(
|
songRepository.makeSongCursor(
|
||||||
ALBUM_SELECTION,
|
ALBUM_SELECTION,
|
||||||
arrayOf(query.toLowerCase())
|
arrayOf(query.toLowerCase(Locale.getDefault()))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if (songs.isNotEmpty()) {
|
if (songs.isNotEmpty()) {
|
||||||
|
@ -132,7 +137,7 @@ object SearchQueryHelper : KoinComponent {
|
||||||
songs = songRepository.songs(
|
songs = songRepository.songs(
|
||||||
songRepository.makeSongCursor(
|
songRepository.makeSongCursor(
|
||||||
TITLE_SELECTION,
|
TITLE_SELECTION,
|
||||||
arrayOf(query.toLowerCase())
|
arrayOf(query.toLowerCase(Locale.getDefault()))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return if (songs.isNotEmpty()) {
|
return if (songs.isNotEmpty()) {
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
package code.name.monkey.retromusic.helper.menu
|
package code.name.monkey.retromusic.helper.menu
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
@ -90,7 +89,6 @@ object PlaylistMenuHelper : KoinComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPlaylistSongs(
|
private fun getPlaylistSongs(
|
||||||
activity: Activity,
|
|
||||||
playlist: Playlist
|
playlist: Playlist
|
||||||
): List<Song> {
|
): List<Song> {
|
||||||
return if (playlist is AbsCustomPlaylist) {
|
return if (playlist is AbsCustomPlaylist) {
|
||||||
|
|
|
@ -72,9 +72,7 @@ class LibraryPreferenceDialog : DialogFragment() {
|
||||||
categoryAdapter.categoryInfos = PreferenceUtil.defaultCategories
|
categoryAdapter.categoryInfos = PreferenceUtil.defaultCategories
|
||||||
}
|
}
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.setPositiveButton(
|
.setPositiveButton(R.string.ok) { _, _ -> updateCategories(categoryAdapter.categoryInfos) }
|
||||||
android.R.string.ok
|
|
||||||
) { _, _ -> updateCategories(categoryAdapter.categoryInfos) }
|
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.create()
|
.create()
|
||||||
.colorButtons()
|
.colorButtons()
|
||||||
|
|
|
@ -22,8 +22,8 @@ import android.graphics.BitmapFactory
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.text.Html
|
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
import androidx.core.text.HtmlCompat
|
||||||
import androidx.media.app.NotificationCompat.MediaStyle
|
import androidx.media.app.NotificationCompat.MediaStyle
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.MainActivity
|
import code.name.monkey.retromusic.activities.MainActivity
|
||||||
|
@ -132,9 +132,19 @@ class PlayingNotificationImpl : PlayingNotification() {
|
||||||
.setLargeIcon(bitmapFinal)
|
.setLargeIcon(bitmapFinal)
|
||||||
.setContentIntent(clickIntent)
|
.setContentIntent(clickIntent)
|
||||||
.setDeleteIntent(deleteIntent)
|
.setDeleteIntent(deleteIntent)
|
||||||
.setContentTitle(Html.fromHtml("<b>" + song.title + "</b>"))
|
.setContentTitle(
|
||||||
|
HtmlCompat.fromHtml(
|
||||||
|
"<b>" + song.title + "</b>",
|
||||||
|
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||||
|
)
|
||||||
|
)
|
||||||
.setContentText(song.artistName)
|
.setContentText(song.artistName)
|
||||||
.setSubText(Html.fromHtml("<b>" + song.albumName + "</b>"))
|
.setSubText(
|
||||||
|
HtmlCompat.fromHtml(
|
||||||
|
"<b>" + song.albumName + "</b>",
|
||||||
|
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||||
|
)
|
||||||
|
)
|
||||||
.setOngoing(isPlaying)
|
.setOngoing(isPlaying)
|
||||||
.setShowWhen(false)
|
.setShowWhen(false)
|
||||||
.addAction(toggleFavorite)
|
.addAction(toggleFavorite)
|
||||||
|
|
|
@ -310,7 +310,7 @@ object MusicUtil : KoinComponent {
|
||||||
context: Context,
|
context: Context,
|
||||||
playlist: Playlist
|
playlist: Playlist
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return playlist.name != null && playlist.name == context.getString(R.string.favorites)
|
return playlist.name == context.getString(R.string.favorites)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleFavorite(context: Context, song: Song) {
|
fun toggleFavorite(context: Context, song: Song) {
|
||||||
|
@ -349,7 +349,7 @@ object MusicUtil : KoinComponent {
|
||||||
BaseColumns._ID, MediaStore.MediaColumns.DATA
|
BaseColumns._ID, MediaStore.MediaColumns.DATA
|
||||||
)
|
)
|
||||||
// Split the query into multiple batches, and merge the resulting cursors
|
// Split the query into multiple batches, and merge the resulting cursors
|
||||||
var batchStart = 0
|
var batchStart: Int
|
||||||
var batchEnd = 0
|
var batchEnd = 0
|
||||||
val batchSize =
|
val batchSize =
|
||||||
1000000 / 10 // 10^6 being the SQLite limite on the query lenth in bytes, 10 being the max number of digits in an int, used to store the track ID
|
1000000 / 10 // 10^6 being the SQLite limite on the query lenth in bytes, 10 being the max number of digits in an int, used to store the track ID
|
||||||
|
|
|
@ -247,7 +247,7 @@ public class PlaylistsUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File savePlaylist(Context context, Playlist playlist) throws IOException {
|
public static File savePlaylist(Context context, Playlist playlist) throws IOException {
|
||||||
return M3UWriter.write(context, new File(Environment.getExternalStorageDirectory(), "Playlists"), playlist);
|
return M3UWriter.write(new File(Environment.getExternalStorageDirectory(), "Playlists"), playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean doesPlaylistExist(@NonNull final Context context, final int playlistId) {
|
public static boolean doesPlaylistExist(@NonNull final Context context, final int playlistId) {
|
||||||
|
|
|
@ -93,7 +93,7 @@ object PreferenceUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val languageCode get() = sharedPreferences.getString(LANGUAGE_NAME, "auto")
|
val languageCode: String get() = sharedPreferences.getString(LANGUAGE_NAME, "auto") ?: "auto"
|
||||||
|
|
||||||
var userName
|
var userName
|
||||||
get() = sharedPreferences.getString(
|
get() = sharedPreferences.getString(
|
||||||
|
|
|
@ -77,7 +77,7 @@ class RingtoneManager(val context: Context) {
|
||||||
return MaterialAlertDialogBuilder(context)
|
return MaterialAlertDialogBuilder(context)
|
||||||
.setTitle(R.string.dialog_title_set_ringtone)
|
.setTitle(R.string.dialog_title_set_ringtone)
|
||||||
.setMessage(R.string.dialog_message_set_ringtone)
|
.setMessage(R.string.dialog_message_set_ringtone)
|
||||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
.setPositiveButton(R.string.ok) { _, _ ->
|
||||||
val intent = Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS)
|
val intent = Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS)
|
||||||
intent.data = Uri.parse("package:" + context.applicationContext.packageName)
|
intent.data = Uri.parse("package:" + context.applicationContext.packageName)
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:maxLines="3"
|
android:maxLines="3"
|
||||||
android:textAppearance="@style/TextViewHeadline4.Compress"
|
android:textAppearance="@style/TextViewHeadline4"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constrainedWidth="true"
|
app:layout_constrainedWidth="true"
|
||||||
|
|
|
@ -883,4 +883,5 @@
|
||||||
<!-- TODO: Remove or change this placeholder text -->
|
<!-- TODO: Remove or change this placeholder text -->
|
||||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
<string name="done">Done</string>
|
<string name="done">Done</string>
|
||||||
|
<string name="ok">Ok</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -109,6 +109,10 @@
|
||||||
<item name="android:textSize">14sp</item>
|
<item name="android:textSize">14sp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TextViewHeadline4.Compress" parent="TextAppearance.MaterialComponents.Headline4">
|
||||||
|
<item name="android:textSize">32sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="TextViewHeadline4" parent="TextAppearance.MaterialComponents.Headline4" />
|
<style name="TextViewHeadline4" parent="TextAppearance.MaterialComponents.Headline4" />
|
||||||
|
|
||||||
<style name="TextViewHeadline5" parent="TextAppearance.MaterialComponents.Headline5" />
|
<style name="TextViewHeadline5" parent="TextAppearance.MaterialComponents.Headline5" />
|
||||||
|
|
Loading…
Reference in a new issue