Merge pull request #1322 from TacoTheDank/ktxExtensions

Utilize KTX extensions
This commit is contained in:
Prathamesh More 2022-04-08 20:15:10 +05:30 committed by GitHub
commit 8b100b4a17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 241 additions and 364 deletions

View file

@ -18,12 +18,12 @@ import android.Manifest
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.provider.Settings import android.provider.Settings
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.core.text.HtmlCompat import androidx.core.net.toUri
import androidx.core.text.parseAsHtml
import androidx.core.view.isVisible import androidx.core.view.isVisible
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.appthemehelper.util.VersionUtils
@ -54,7 +54,7 @@ class PermissionActivity : AbsMusicServiceActivity() {
binding.audioPermission.setButtonClick { binding.audioPermission.setButtonClick {
if (RingtoneManager.requiresDialog(this@PermissionActivity)) { if (RingtoneManager.requiresDialog(this@PermissionActivity)) {
val intent = Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS) val intent = Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS)
intent.data = Uri.parse("package:" + applicationContext.packageName) intent.data = ("package:" + applicationContext.packageName).toUri()
startActivity(intent) startActivity(intent)
} }
} }
@ -77,10 +77,8 @@ class PermissionActivity : AbsMusicServiceActivity() {
private fun setupTitle() { private fun setupTitle() {
val color = ThemeStore.accentColor(this) val color = ThemeStore.accentColor(this)
val hexColor = String.format("#%06X", 0xFFFFFF and color) val hexColor = String.format("#%06X", 0xFFFFFF and color)
val appName = HtmlCompat.fromHtml( val appName = "Hello there! <br>Welcome to <b>Retro <span style='color:$hexColor';>Music</span></b>"
"Hello there! <br>Welcome to <b>Retro <span style='color:$hexColor';>Music</span></b>", .parseAsHtml()
HtmlCompat.FROM_HTML_MODE_COMPACT
)
binding.appNameText.text = appName binding.appNameText.text = appName
} }

View file

@ -18,10 +18,10 @@ import android.content.res.ColorStateList
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.provider.MediaStore.Images.Media import android.provider.MediaStore.Images.Media
import android.view.MenuItem import android.view.MenuItem
import androidx.core.net.toUri
import androidx.core.view.drawToBitmap import androidx.core.view.drawToBitmap
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
@ -87,10 +87,9 @@ class ShareInstagramStory : AbsBaseActivity() {
binding.mainContent.drawToBitmap(Bitmap.Config.ARGB_8888), binding.mainContent.drawToBitmap(Bitmap.Config.ARGB_8888),
"Design", null "Design", null
) )
val uri = Uri.parse(path)
Share.shareStoryToSocial( Share.shareStoryToSocial(
this@ShareInstagramStory, this@ShareInstagramStory,
uri path.toUri()
) )
} }
} }

View file

@ -25,10 +25,7 @@ import android.view.ViewTreeObserver
import android.view.animation.PathInterpolator import android.view.animation.PathInterpolator
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.core.animation.doOnEnd import androidx.core.animation.doOnEnd
import androidx.core.view.ViewCompat import androidx.core.view.*
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.commit import androidx.fragment.app.commit
import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.appthemehelper.util.VersionUtils
@ -238,9 +235,9 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
override fun onGlobalLayout() { override fun onGlobalLayout() {
binding.slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this) binding.slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
if (nowPlayingScreen != Peek) { if (nowPlayingScreen != Peek) {
val params = binding.slidingPanel.layoutParams as ViewGroup.LayoutParams binding.slidingPanel.updateLayoutParams<ViewGroup.LayoutParams> {
params.height = ViewGroup.LayoutParams.MATCH_PARENT height = ViewGroup.LayoutParams.MATCH_PARENT
binding.slidingPanel.layoutParams = params }
} }
when (panelState) { when (panelState) {
STATE_EXPANDED -> onPanelExpanded() STATE_EXPANDED -> onPanelExpanded()

View file

@ -17,15 +17,14 @@ package code.name.monkey.retromusic.activities.bugreport
import android.content.ClipData import android.content.ClipData
import android.content.ClipboardManager import android.content.ClipboardManager
import android.content.Intent import android.content.Intent
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils
import android.view.MenuItem import android.view.MenuItem
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import android.widget.Toast import android.widget.Toast
import androidx.annotation.StringDef import androidx.annotation.StringDef
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.core.content.getSystemService import androidx.core.content.getSystemService
import androidx.core.net.toUri
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.appthemehelper.util.MaterialUtil
@ -81,7 +80,7 @@ open class BugReportActivity : AbsThemeActivity() {
initViews() initViews()
if (TextUtils.isEmpty(title)) setTitle(R.string.report_an_issue) if (title.isNullOrEmpty()) setTitle(R.string.report_an_issue)
deviceInfo = DeviceInfo(this) deviceInfo = DeviceInfo(this)
binding.cardDeviceInfo.airTextDeviceInfo.text = deviceInfo.toString() binding.cardDeviceInfo.airTextDeviceInfo.text = deviceInfo.toString()
@ -154,7 +153,7 @@ open class BugReportActivity : AbsThemeActivity() {
copyDeviceInfoToClipBoard() copyDeviceInfoToClipBoard()
val i = Intent(Intent.ACTION_VIEW) val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(ISSUE_TRACKER_LINK) i.data = ISSUE_TRACKER_LINK.toUri()
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(i) startActivity(i)
} }
@ -175,14 +174,14 @@ open class BugReportActivity : AbsThemeActivity() {
var hasErrors = false var hasErrors = false
if (binding.cardReport.optionUseAccount.isChecked) { if (binding.cardReport.optionUseAccount.isChecked) {
if (TextUtils.isEmpty(binding.cardReport.inputUsername.text)) { if (binding.cardReport.inputUsername.text.isNullOrEmpty()) {
setError(binding.cardReport.inputLayoutUsername, R.string.bug_report_no_username) setError(binding.cardReport.inputLayoutUsername, R.string.bug_report_no_username)
hasErrors = true hasErrors = true
} else { } else {
removeError(binding.cardReport.inputLayoutUsername) removeError(binding.cardReport.inputLayoutUsername)
} }
if (TextUtils.isEmpty(binding.cardReport.inputPassword.text)) { if (binding.cardReport.inputPassword.text.isNullOrEmpty()) {
setError(binding.cardReport.inputLayoutPassword, R.string.bug_report_no_password) setError(binding.cardReport.inputLayoutPassword, R.string.bug_report_no_password)
hasErrors = true hasErrors = true
} else { } else {
@ -190,14 +189,14 @@ open class BugReportActivity : AbsThemeActivity() {
} }
} }
if (TextUtils.isEmpty(binding.cardReport.inputTitle.text)) { if (binding.cardReport.inputTitle.text.isNullOrEmpty()) {
setError(binding.cardReport.inputLayoutTitle, R.string.bug_report_no_title) setError(binding.cardReport.inputLayoutTitle, R.string.bug_report_no_title)
hasErrors = true hasErrors = true
} else { } else {
removeError(binding.cardReport.inputLayoutTitle) removeError(binding.cardReport.inputLayoutTitle)
} }
if (TextUtils.isEmpty(binding.cardReport.inputDescription.text)) { if (binding.cardReport.inputDescription.text.isNullOrEmpty()) {
setError(binding.cardReport.inputLayoutDescription, R.string.bug_report_no_description) setError(binding.cardReport.inputLayoutDescription, R.string.bug_report_no_description)
hasErrors = true hasErrors = true
} else { } else {
@ -225,7 +224,7 @@ open class BugReportActivity : AbsThemeActivity() {
onSaveExtraInfo() onSaveExtraInfo()
val report = Report(bugTitle, bugDescription, deviceInfo, extraInfo) val report = Report(bugTitle, bugDescription, deviceInfo, extraInfo)
val target = GithubTarget("prathameshmm02", "RetroMusicPlayer") val target = GithubTarget("RetroMusicPlayer", "RetroMusicPlayer")
reportIssue(report, target, login) reportIssue(report, target, login)
} }
@ -315,6 +314,6 @@ open class BugReportActivity : AbsThemeActivity() {
private const val STATUS_BAD_CREDENTIALS = 401 private const val STATUS_BAD_CREDENTIALS = 401
private const val STATUS_ISSUES_NOT_ENABLED = 410 private const val STATUS_ISSUES_NOT_ENABLED = 410
private const val ISSUE_TRACKER_LINK = "https://github.com/prathameshmm02/RetroMusicPlayer" private const val ISSUE_TRACKER_LINK = "https://github.com/RetroMusicPlayer/RetroMusicPlayer"
} }
} }

View file

@ -22,12 +22,11 @@ import android.graphics.Color
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.transition.Slide import android.transition.Slide
import android.view.LayoutInflater import android.view.LayoutInflater
import android.widget.ImageView import android.widget.ImageView
import android.widget.Toast import android.widget.Toast
import androidx.core.widget.doAfterTextChanged
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.ActivityAlbumTagEditorBinding import code.name.monkey.retromusic.databinding.ActivityAlbumTagEditorBinding
@ -50,7 +49,7 @@ import com.google.android.material.shape.MaterialShapeDrawable
import org.jaudiotagger.tag.FieldKey import org.jaudiotagger.tag.FieldKey
import java.util.* import java.util.*
class AlbumTagEditorActivity : AbsTagEditorActivity<ActivityAlbumTagEditorBinding>(), TextWatcher { class AlbumTagEditorActivity : AbsTagEditorActivity<ActivityAlbumTagEditorBinding>() {
override val bindingInflater: (LayoutInflater) -> ActivityAlbumTagEditorBinding = override val bindingInflater: (LayoutInflater) -> ActivityAlbumTagEditorBinding =
ActivityAlbumTagEditorBinding::inflate ActivityAlbumTagEditorBinding::inflate
@ -91,10 +90,10 @@ class AlbumTagEditorActivity : AbsTagEditorActivity<ActivityAlbumTagEditorBindin
binding.albumTitleContainer.setTint(false) binding.albumTitleContainer.setTint(false)
binding.albumArtistContainer.setTint(false) binding.albumArtistContainer.setTint(false)
binding.albumText.appHandleColor().addTextChangedListener(this) binding.albumText.appHandleColor().doAfterTextChanged { dataChanged() }
binding.albumArtistText.appHandleColor().addTextChangedListener(this) binding.albumArtistText.appHandleColor().doAfterTextChanged { dataChanged() }
binding.genreTitle.appHandleColor().addTextChangedListener(this) binding.genreTitle.appHandleColor().doAfterTextChanged { dataChanged() }
binding.yearTitle.appHandleColor().addTextChangedListener(this) binding.yearTitle.appHandleColor().doAfterTextChanged { dataChanged() }
} }
private fun fillViewsWithFileTags() { private fun fillViewsWithFileTags() {
@ -198,17 +197,6 @@ class AlbumTagEditorActivity : AbsTagEditorActivity<ActivityAlbumTagEditorBindin
MusicUtil.getSongFileUri(it.id) MusicUtil.getSongFileUri(it.id)
} }
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
}
override fun afterTextChanged(s: Editable) {
dataChanged()
}
override fun setColors(color: Int) { override fun setColors(color: Int) {
super.setColors(color) super.setColors(color)
saveFab.backgroundTintList = ColorStateList.valueOf(color) saveFab.backgroundTintList = ColorStateList.valueOf(color)

View file

@ -23,11 +23,10 @@ import android.graphics.Color
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater import android.view.LayoutInflater
import android.widget.ImageView import android.widget.ImageView
import android.widget.Toast import android.widget.Toast
import androidx.core.widget.doAfterTextChanged
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.ActivitySongTagEditorBinding import code.name.monkey.retromusic.databinding.ActivitySongTagEditorBinding
@ -50,7 +49,7 @@ import org.jaudiotagger.tag.FieldKey
import org.koin.android.ext.android.inject import org.koin.android.ext.android.inject
import java.util.* import java.util.*
class SongTagEditorActivity : AbsTagEditorActivity<ActivitySongTagEditorBinding>(), TextWatcher { class SongTagEditorActivity : AbsTagEditorActivity<ActivitySongTagEditorBinding>() {
override val bindingInflater: (LayoutInflater) -> ActivitySongTagEditorBinding = override val bindingInflater: (LayoutInflater) -> ActivitySongTagEditorBinding =
ActivitySongTagEditorBinding::inflate ActivitySongTagEditorBinding::inflate
@ -83,16 +82,16 @@ class SongTagEditorActivity : AbsTagEditorActivity<ActivitySongTagEditorBinding>
binding.discNumberContainer.setTint(false) binding.discNumberContainer.setTint(false)
binding.lyricsContainer.setTint(false) binding.lyricsContainer.setTint(false)
binding.songText.appHandleColor().addTextChangedListener(this) binding.songText.appHandleColor().doAfterTextChanged { dataChanged() }
binding.albumText.appHandleColor().addTextChangedListener(this) binding.albumText.appHandleColor().doAfterTextChanged { dataChanged() }
binding.albumArtistText.appHandleColor().addTextChangedListener(this) binding.albumArtistText.appHandleColor().doAfterTextChanged { dataChanged() }
binding.artistText.appHandleColor().addTextChangedListener(this) binding.artistText.appHandleColor().doAfterTextChanged { dataChanged() }
binding.genreText.appHandleColor().addTextChangedListener(this) binding.genreText.appHandleColor().doAfterTextChanged { dataChanged() }
binding.yearText.appHandleColor().addTextChangedListener(this) binding.yearText.appHandleColor().doAfterTextChanged { dataChanged() }
binding.trackNumberText.appHandleColor().addTextChangedListener(this) binding.trackNumberText.appHandleColor().doAfterTextChanged { dataChanged() }
binding.discNumberText.appHandleColor().addTextChangedListener(this) binding.discNumberText.appHandleColor().doAfterTextChanged { dataChanged() }
binding.lyricsText.appHandleColor().addTextChangedListener(this) binding.lyricsText.appHandleColor().doAfterTextChanged { dataChanged() }
binding.songComposerText.appHandleColor().addTextChangedListener(this) binding.songComposerText.appHandleColor().doAfterTextChanged { dataChanged() }
} }
private fun fillViewsWithFileTags() { private fun fillViewsWithFileTags() {
@ -205,16 +204,6 @@ class SongTagEditorActivity : AbsTagEditorActivity<ActivitySongTagEditorBinding>
}) })
} }
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
}
override fun afterTextChanged(s: Editable) {
dataChanged()
}
companion object { companion object {
val TAG: String = SongTagEditorActivity::class.java.simpleName val TAG: String = SongTagEditorActivity::class.java.simpleName
} }

View file

@ -19,6 +19,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -205,9 +206,7 @@ class AlbumCoverPagerAdapter(
fun newInstance(song: Song): AlbumCoverFragment { fun newInstance(song: Song): AlbumCoverFragment {
val frag = AlbumCoverFragment() val frag = AlbumCoverFragment()
val args = Bundle() frag.arguments = bundleOf(SONG_ARG to song)
args.putParcelable(SONG_ARG, song)
frag.arguments = args
return frag return frag
} }
} }

View file

@ -15,12 +15,12 @@
package code.name.monkey.retromusic.adapter.playlist package code.name.monkey.retromusic.adapter.playlist
import android.graphics.Color import android.graphics.Color
import android.text.TextUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import androidx.core.view.isGone
import androidx.core.view.setPadding import androidx.core.view.setPadding
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -30,8 +30,6 @@ import code.name.monkey.retromusic.db.PlaylistEntity
import code.name.monkey.retromusic.db.PlaylistWithSongs import code.name.monkey.retromusic.db.PlaylistWithSongs
import code.name.monkey.retromusic.db.toSongs import code.name.monkey.retromusic.db.toSongs
import code.name.monkey.retromusic.extensions.dipToPix import code.name.monkey.retromusic.extensions.dipToPix
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.glide.GlideApp import code.name.monkey.retromusic.glide.GlideApp
import code.name.monkey.retromusic.glide.playlistPreview.PlaylistPreview import code.name.monkey.retromusic.glide.playlistPreview.PlaylistPreview
import code.name.monkey.retromusic.helper.SortOrder.PlaylistSortOrder import code.name.monkey.retromusic.helper.SortOrder.PlaylistSortOrder
@ -79,7 +77,7 @@ class PlaylistAdapter(
} }
private fun getPlaylistTitle(playlist: PlaylistEntity): String { private fun getPlaylistTitle(playlist: PlaylistEntity): String {
return if (TextUtils.isEmpty(playlist.playlistName)) "-" else playlist.playlistName return playlist.playlistName.ifEmpty { "-" }
} }
private fun getPlaylistText(playlist: PlaylistWithSongs): String { private fun getPlaylistText(playlist: PlaylistWithSongs): String {
@ -102,12 +100,7 @@ class PlaylistAdapter(
holder.itemView.isActivated = isChecked(playlist) holder.itemView.isActivated = isChecked(playlist)
holder.title?.text = getPlaylistTitle(playlist.playlistEntity) holder.title?.text = getPlaylistTitle(playlist.playlistEntity)
holder.text?.text = getPlaylistText(playlist) holder.text?.text = getPlaylistText(playlist)
val isChecked = isChecked(playlist) holder.menu?.isGone = isChecked(playlist)
if (isChecked) {
holder.menu?.hide()
} else {
holder.menu?.show()
}
GlideApp.with(activity) GlideApp.with(activity)
.load( .load(
if (itemLayoutRes == R.layout.item_list) { if (itemLayoutRes == R.layout.item_list) {

View file

@ -21,6 +21,7 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.view.isGone
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import androidx.navigation.findNavController import androidx.navigation.findNavController
@ -28,8 +29,6 @@ import code.name.monkey.retromusic.EXTRA_ALBUM_ID
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.glide.GlideApp import code.name.monkey.retromusic.glide.GlideApp
import code.name.monkey.retromusic.glide.RetroGlideExtension import code.name.monkey.retromusic.glide.RetroGlideExtension
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
@ -96,11 +95,7 @@ open class SongAdapter(
val song = dataSet[position] val song = dataSet[position]
val isChecked = isChecked(song) val isChecked = isChecked(song)
holder.itemView.isActivated = isChecked holder.itemView.isActivated = isChecked
if (isChecked) { holder.menu?.isGone = isChecked
holder.menu?.hide()
} else {
holder.menu?.show()
}
holder.title?.text = getSongTitle(song) holder.title?.text = getSongTitle(song)
holder.text?.text = getSongText(song) holder.text?.text = getSongText(song)
holder.text2?.text = getSongText(song) holder.text2?.text = getSongText(song)

View file

@ -16,13 +16,14 @@ package code.name.monkey.retromusic.appshortcuts
import android.content.Context import android.content.Context
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.graphics.drawable.Icon import android.graphics.drawable.Icon
import android.graphics.drawable.LayerDrawable import android.graphics.drawable.LayerDrawable
import android.os.Build import android.os.Build
import android.util.TypedValue import android.util.TypedValue
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.core.graphics.applyCanvas
import androidx.core.graphics.createBitmap
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
@ -79,12 +80,9 @@ object AppShortcutIconGenerator {
} }
private fun drawableToBitmap(drawable: Drawable): Bitmap { private fun drawableToBitmap(drawable: Drawable): Bitmap {
val bitmap = Bitmap.createBitmap( return createBitmap(drawable.intrinsicWidth, drawable.intrinsicHeight).applyCanvas {
drawable.intrinsicWidth, drawable.intrinsicHeight, Bitmap.Config.ARGB_8888 drawable.setBounds(0, 0, width, height)
) drawable.draw(this)
val canvas = Canvas(bitmap) }
drawable.setBounds(0, 0, canvas.width, canvas.height)
drawable.draw(canvas)
return bitmap
} }
} }

View file

@ -17,6 +17,7 @@ package code.name.monkey.retromusic.appshortcuts
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.core.os.bundleOf
import code.name.monkey.retromusic.appshortcuts.shortcuttype.LastAddedShortcutType import code.name.monkey.retromusic.appshortcuts.shortcuttype.LastAddedShortcutType
import code.name.monkey.retromusic.appshortcuts.shortcuttype.ShuffleAllShortcutType import code.name.monkey.retromusic.appshortcuts.shortcuttype.ShuffleAllShortcutType
import code.name.monkey.retromusic.appshortcuts.shortcuttype.TopTracksShortcutType import code.name.monkey.retromusic.appshortcuts.shortcuttype.TopTracksShortcutType
@ -63,9 +64,10 @@ class AppShortcutLauncherActivity : Activity() {
val intent = Intent(this, MusicService::class.java) val intent = Intent(this, MusicService::class.java)
intent.action = ACTION_PLAY_PLAYLIST intent.action = ACTION_PLAY_PLAYLIST
val bundle = Bundle() val bundle = bundleOf(
bundle.putParcelable(INTENT_EXTRA_PLAYLIST, playlist) INTENT_EXTRA_PLAYLIST to playlist,
bundle.putInt(INTENT_EXTRA_SHUFFLE_MODE, shuffleMode) INTENT_EXTRA_SHUFFLE_MODE to shuffleMode
)
intent.putExtras(bundle) intent.putExtras(bundle)

View file

@ -19,7 +19,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.ShortcutInfo import android.content.pm.ShortcutInfo
import android.os.Build import android.os.Build
import android.os.Bundle import androidx.core.os.bundleOf
import code.name.monkey.retromusic.appshortcuts.AppShortcutLauncherActivity import code.name.monkey.retromusic.appshortcuts.AppShortcutLauncherActivity
@TargetApi(Build.VERSION_CODES.N_MR1) @TargetApi(Build.VERSION_CODES.N_MR1)
@ -36,8 +36,7 @@ abstract class BaseShortcutType(internal var context: Context) {
internal fun getPlaySongsIntent(shortcutType: Long): Intent { internal fun getPlaySongsIntent(shortcutType: Long): Intent {
val intent = Intent(context, AppShortcutLauncherActivity::class.java) val intent = Intent(context, AppShortcutLauncherActivity::class.java)
intent.action = Intent.ACTION_VIEW intent.action = Intent.ACTION_VIEW
val b = Bundle() val b = bundleOf(AppShortcutLauncherActivity.KEY_SHORTCUT_TYPE to shortcutType)
b.putLong(AppShortcutLauncherActivity.KEY_SHORTCUT_TYPE, shortcutType)
intent.putExtras(b) intent.putExtras(b)
return intent return intent
} }

View file

@ -20,7 +20,6 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.text.TextUtils
import android.view.View import android.view.View
import android.widget.RemoteViews import android.widget.RemoteViews
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
@ -102,7 +101,7 @@ class AppWidgetBig : BaseAppWidget() {
val song = service.currentSong val song = service.currentSong
// Set the titles and artwork // Set the titles and artwork
if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) { if (song.title.isEmpty() && song.artistName.isEmpty()) {
appWidgetView.setViewVisibility( appWidgetView.setViewVisibility(
R.id.media_titles, R.id.media_titles,
View.INVISIBLE View.INVISIBLE

View file

@ -20,7 +20,6 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.text.TextUtils
import android.view.View import android.view.View
import android.widget.RemoteViews import android.widget.RemoteViews
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
@ -98,7 +97,7 @@ class AppWidgetCard : BaseAppWidget() {
val song = service.currentSong val song = service.currentSong
// Set the titles and artwork // Set the titles and artwork
if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) { if (song.title.isEmpty() && song.artistName.isEmpty()) {
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE) appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
} else { } else {
appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE) appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE)

View file

@ -21,7 +21,6 @@ import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.text.TextUtils
import android.view.View import android.view.View
import android.widget.RemoteViews import android.widget.RemoteViews
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
@ -101,7 +100,7 @@ class AppWidgetClassic : BaseAppWidget() {
val song = service.currentSong val song = service.currentSong
// Set the titles and artwork // Set the titles and artwork
if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) { if (song.title.isEmpty() && song.artistName.isEmpty()) {
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE) appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
} else { } else {
appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE) appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE)

View file

@ -20,7 +20,6 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.text.TextUtils
import android.view.View import android.view.View
import android.widget.RemoteViews import android.widget.RemoteViews
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
@ -99,7 +98,7 @@ class AppWidgetMD3 : BaseAppWidget() {
val song = service.currentSong val song = service.currentSong
// Set the titles and artwork // Set the titles and artwork
if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) { if (song.title.isEmpty() && song.artistName.isEmpty()) {
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE) appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
} else { } else {
appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE) appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE)

View file

@ -20,7 +20,6 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.text.TextUtils
import android.view.View import android.view.View
import android.widget.RemoteViews import android.widget.RemoteViews
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
@ -99,10 +98,10 @@ class AppWidgetSmall : BaseAppWidget() {
val song = service.currentSong val song = service.currentSong
// Set the titles and artwork // Set the titles and artwork
if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) { if (song.title.isEmpty() && song.artistName.isEmpty()) {
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE) appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
} else { } else {
if (TextUtils.isEmpty(song.title) || TextUtils.isEmpty(song.artistName)) { if (song.title.isEmpty() || song.artistName.isEmpty()) {
appWidgetView.setTextViewText(R.id.text_separator, "") appWidgetView.setTextViewText(R.id.text_separator, "")
} else { } else {
appWidgetView.setTextViewText(R.id.text_separator, "") appWidgetView.setTextViewText(R.id.text_separator, "")

View file

@ -18,7 +18,6 @@ import android.app.PendingIntent
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.text.TextUtils
import android.view.View import android.view.View
import android.widget.RemoteViews import android.widget.RemoteViews
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
@ -119,7 +118,7 @@ class AppWidgetText : BaseAppWidget() {
val song = service.currentSong val song = service.currentSong
// Set the titles and artwork // Set the titles and artwork
if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) { if (song.title.isEmpty() && song.artistName.isEmpty()) {
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE) appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
} else { } else {
appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE) appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE)

View file

@ -24,9 +24,10 @@ import android.content.res.Resources
import android.graphics.* import android.graphics.*
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.text.TextUtils
import android.widget.RemoteViews import android.widget.RemoteViews
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.graphics.applyCanvas
import androidx.core.graphics.createBitmap
import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.App import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -126,7 +127,7 @@ abstract class BaseAppWidget : AppWidgetProvider() {
protected fun getSongArtistAndAlbum(song: Song): String { protected fun getSongArtistAndAlbum(song: Song): String {
val builder = StringBuilder() val builder = StringBuilder()
builder.append(song.artistName) builder.append(song.artistName)
if (!TextUtils.isEmpty(song.artistName) && !TextUtils.isEmpty(song.albumName)) { if (song.artistName.isNotEmpty() && song.albumName.isNotEmpty()) {
builder.append("") builder.append("")
} }
builder.append(song.albumName) builder.append(song.albumName)
@ -171,15 +172,13 @@ abstract class BaseAppWidget : AppWidgetProvider() {
} }
fun createBitmap(drawable: Drawable, sizeMultiplier: Float): Bitmap { fun createBitmap(drawable: Drawable, sizeMultiplier: Float): Bitmap {
val bitmap = Bitmap.createBitmap( return createBitmap(
(drawable.intrinsicWidth * sizeMultiplier).toInt(), (drawable.intrinsicWidth * sizeMultiplier).toInt(),
(drawable.intrinsicHeight * sizeMultiplier).toInt(), (drawable.intrinsicHeight * sizeMultiplier).toInt(),
Bitmap.Config.ARGB_8888 ).applyCanvas {
) drawable.setBounds(0, 0, this.width, this.height)
val c = Canvas(bitmap) drawable.draw(this)
drawable.setBounds(0, 0, c.width, c.height) }
drawable.draw(c)
return bitmap
} }
protected fun composeRoundedRectPath( protected fun composeRoundedRectPath(

View file

@ -2,9 +2,9 @@ package code.name.monkey.retromusic.auto
import android.content.Context import android.content.Context
import android.net.Uri import android.net.Uri
import android.os.Bundle
import android.support.v4.media.MediaBrowserCompat import android.support.v4.media.MediaBrowserCompat
import android.support.v4.media.MediaDescriptionCompat import android.support.v4.media.MediaDescriptionCompat
import androidx.core.os.bundleOf
import code.name.monkey.retromusic.util.ImageUtil import code.name.monkey.retromusic.util.ImageUtil
@ -55,15 +55,14 @@ internal object AutoMediaItem {
fun gridLayout(isGrid: Boolean): Builder { fun gridLayout(isGrid: Boolean): Builder {
val hints = Bundle() val hints = bundleOf(
hints.putBoolean(CONTENT_STYLE_SUPPORTED, true) CONTENT_STYLE_SUPPORTED to true,
hints.putInt( CONTENT_STYLE_BROWSABLE_HINT to
CONTENT_STYLE_BROWSABLE_HINT, if (isGrid) CONTENT_STYLE_GRID_ITEM_HINT_VALUE
if (isGrid) CONTENT_STYLE_GRID_ITEM_HINT_VALUE else CONTENT_STYLE_LIST_ITEM_HINT_VALUE else CONTENT_STYLE_LIST_ITEM_HINT_VALUE,
) CONTENT_STYLE_PLAYABLE_HINT to
hints.putInt( if (isGrid) CONTENT_STYLE_GRID_ITEM_HINT_VALUE
CONTENT_STYLE_PLAYABLE_HINT, else CONTENT_STYLE_LIST_ITEM_HINT_VALUE
if (isGrid) CONTENT_STYLE_GRID_ITEM_HINT_VALUE else CONTENT_STYLE_LIST_ITEM_HINT_VALUE
) )
mBuilder?.setExtras(hints) mBuilder?.setExtras(hints)
return this return this

View file

@ -17,7 +17,7 @@ package code.name.monkey.retromusic.dialogs
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.text.HtmlCompat import androidx.core.text.parseAsHtml
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import code.name.monkey.retromusic.EXTRA_PLAYLIST import code.name.monkey.retromusic.EXTRA_PLAYLIST
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -55,16 +55,10 @@ class DeletePlaylistDialog : DialogFragment() {
//noinspection ConstantConditions //noinspection ConstantConditions
if (playlists.size > 1) { if (playlists.size > 1) {
title = R.string.delete_playlists_title title = R.string.delete_playlists_title
message = HtmlCompat.fromHtml( message = String.format(getString(R.string.delete_x_playlists), playlists.size).parseAsHtml()
String.format(getString(R.string.delete_x_playlists), playlists.size),
HtmlCompat.FROM_HTML_MODE_LEGACY
)
} else { } else {
title = R.string.delete_playlist_title title = R.string.delete_playlist_title
message = HtmlCompat.fromHtml( message = String.format(getString(R.string.delete_playlist_x), playlists[0].playlistName).parseAsHtml()
String.format(getString(R.string.delete_playlist_x), playlists[0].playlistName),
HtmlCompat.FROM_HTML_MODE_LEGACY
)
} }
return materialDialog(title) return materialDialog(title)

View file

@ -22,7 +22,7 @@ import android.provider.MediaStore
import androidx.activity.result.IntentSenderRequest import androidx.activity.result.IntentSenderRequest
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.text.HtmlCompat import androidx.core.text.parseAsHtml
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.EXTRA_SONG import code.name.monkey.retromusic.EXTRA_SONG
@ -87,18 +87,12 @@ class DeleteSongsDialog : DialogFragment() {
val pair = if (songs.size > 1) { val pair = if (songs.size > 1) {
Pair( Pair(
R.string.delete_songs_title, R.string.delete_songs_title,
HtmlCompat.fromHtml( String.format(getString(R.string.delete_x_songs), songs.size).parseAsHtml()
String.format(getString(R.string.delete_x_songs), songs.size),
HtmlCompat.FROM_HTML_MODE_LEGACY
)
) )
} else { } else {
Pair( Pair(
R.string.delete_song_title, R.string.delete_song_title,
HtmlCompat.fromHtml( String.format(getString(R.string.delete_song_x), songs[0].title).parseAsHtml()
String.format(getString(R.string.delete_song_x), songs[0].title),
HtmlCompat.FROM_HTML_MODE_LEGACY
)
) )
} }

View file

@ -17,7 +17,7 @@ package code.name.monkey.retromusic.dialogs
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.text.HtmlCompat import androidx.core.text.parseAsHtml
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import code.name.monkey.retromusic.EXTRA_SONG import code.name.monkey.retromusic.EXTRA_SONG
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -52,21 +52,16 @@ class RemoveSongFromPlaylistDialog : DialogFragment() {
val pair = if (songs.size > 1) { val pair = if (songs.size > 1) {
Pair( Pair(
R.string.remove_songs_from_playlist_title, R.string.remove_songs_from_playlist_title,
HtmlCompat.fromHtml( String.format(getString(R.string.remove_x_songs_from_playlist), songs.size)
String.format(getString(R.string.remove_x_songs_from_playlist), songs.size), .parseAsHtml()
HtmlCompat.FROM_HTML_MODE_LEGACY
)
) )
} else { } else {
Pair( Pair(
R.string.remove_song_from_playlist_title, R.string.remove_song_from_playlist_title,
HtmlCompat.fromHtml(
String.format( String.format(
getString(R.string.remove_song_x_from_playlist), getString(R.string.remove_song_x_from_playlist),
songs[0].title songs[0].title
), ).parseAsHtml()
HtmlCompat.FROM_HTML_MODE_LEGACY
)
) )
} }
return materialDialog(pair.first) return materialDialog(pair.first)

View file

@ -23,7 +23,7 @@ import android.view.LayoutInflater
import android.widget.TextView import android.widget.TextView
import androidx.annotation.NonNull import androidx.annotation.NonNull
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.text.HtmlCompat import androidx.core.text.parseAsHtml
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import code.name.monkey.retromusic.EXTRA_SONG import code.name.monkey.retromusic.EXTRA_SONG
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -167,10 +167,8 @@ class SongDetailDialog : DialogFragment() {
} }
private fun makeTextWithTitle(context: Context, titleResId: Int, text: String?): Spanned { private fun makeTextWithTitle(context: Context, titleResId: Int, text: String?): Spanned {
return HtmlCompat.fromHtml( return ("<b>" + context.resources.getString(titleResId) + ": " + "</b>" + text)
"<b>" + context.resources.getString(titleResId) + ": " + "</b>" + text, .parseAsHtml()
HtmlCompat.FROM_HTML_MODE_LEGACY
)
} }
private fun getFileSizeString(sizeInBytes: Long): String { private fun getFileSizeString(sizeInBytes: Long): String {

View file

@ -1,7 +1,7 @@
package code.name.monkey.retromusic.extensions package code.name.monkey.retromusic.extensions
import android.net.Uri
import android.webkit.MimeTypeMap import android.webkit.MimeTypeMap
import androidx.core.net.toUri
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import org.jaudiotagger.audio.AudioFileIO import org.jaudiotagger.audio.AudioFileIO
@ -14,7 +14,7 @@ fun getSongInfo(song: Song): String {
return try { return try {
val audioHeader = AudioFileIO.read(File(song.data)).audioHeader val audioHeader = AudioFileIO.read(File(song.data)).audioHeader
val string: StringBuilder = StringBuilder() val string: StringBuilder = StringBuilder()
val uriFile = Uri.fromFile(file) val uriFile = file.toUri()
string.append(getMimeType(uriFile.toString())).append("") string.append(getMimeType(uriFile.toString())).append("")
string.append(audioHeader.bitRate).append(" kb/s").append("") string.append(audioHeader.bitRate).append(" kb/s").append("")
string.append(RetroUtil.frequencyCount(audioHeader.sampleRate.toInt())) string.append(RetroUtil.frequencyCount(audioHeader.sampleRate.toInt()))

View file

@ -67,11 +67,7 @@ fun View.translateYAnimate(value: Float): Animator {
bringToFront() bringToFront()
} }
doOnEnd { doOnEnd {
if (value != 0f) { isGone = (value != 0f)
hide()
} else {
show()
}
} }
start() start()
} }

View file

@ -16,10 +16,10 @@ package code.name.monkey.retromusic.fragments.about
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.core.app.ShareCompat import androidx.core.app.ShareCompat
import androidx.core.net.toUri
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.DefaultItemAnimator
@ -55,7 +55,7 @@ class AboutFragment : Fragment(R.layout.fragment_about), View.OnClickListener {
private fun openUrl(url: String) { private fun openUrl(url: String) {
val i = Intent(Intent.ACTION_VIEW) val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url) i.data = url.toUri()
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(i) startActivity(i)
} }

View file

@ -22,7 +22,7 @@ import android.view.*
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.text.HtmlCompat import androidx.core.text.parseAsHtml
import androidx.core.view.doOnPreDraw import androidx.core.view.doOnPreDraw
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.FragmentNavigatorExtras import androidx.navigation.fragment.FragmentNavigatorExtras
@ -282,10 +282,8 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
binding.fragmentAlbumContent.aboutAlbumTitle.show() binding.fragmentAlbumContent.aboutAlbumTitle.show()
binding.fragmentAlbumContent.aboutAlbumTitle.text = binding.fragmentAlbumContent.aboutAlbumTitle.text =
String.format(getString(R.string.about_album_label), lastFmAlbum.album.name) String.format(getString(R.string.about_album_label), lastFmAlbum.album.name)
binding.fragmentAlbumContent.aboutAlbumText.text = HtmlCompat.fromHtml( binding.fragmentAlbumContent.aboutAlbumText.text =
lastFmAlbum.album.wiki.content, lastFmAlbum.album.wiki.content.parseAsHtml()
HtmlCompat.FROM_HTML_MODE_LEGACY
)
} }
if (lastFmAlbum.album.listeners.isNotEmpty()) { if (lastFmAlbum.album.listeners.isNotEmpty()) {
binding.fragmentAlbumContent.listeners.show() binding.fragmentAlbumContent.listeners.show()

View file

@ -12,7 +12,7 @@ import android.view.View
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.text.HtmlCompat import androidx.core.text.parseAsHtml
import androidx.core.view.doOnPreDraw import androidx.core.view.doOnPreDraw
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -194,7 +194,7 @@ abstract class AbsArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragm
binding.fragmentArtistContent.run { binding.fragmentArtistContent.run {
biographyText.isVisible = true biographyText.isVisible = true
biographyTitle.isVisible = true biographyTitle.isVisible = true
biography = HtmlCompat.fromHtml(bioContent, HtmlCompat.FROM_HTML_MODE_LEGACY) biography = bioContent.parseAsHtml()
biographyText.text = biography biographyText.text = biography
if (lastFmArtist.artist.stats.listeners.isNotEmpty()) { if (lastFmArtist.artist.stats.listeners.isNotEmpty()) {
listeners.show() listeners.show()

View file

@ -27,6 +27,8 @@ import android.widget.SeekBar
import android.widget.TextView import android.widget.TextView
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.commit
import androidx.fragment.app.replace
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.fragments.MusicSeekSkipTouchListener import code.name.monkey.retromusic.fragments.MusicSeekSkipTouchListener
import code.name.monkey.retromusic.fragments.other.VolumeFragment import code.name.monkey.retromusic.fragments.other.VolumeFragment
@ -217,8 +219,9 @@ abstract class AbsPlayerControlsFragment(@LayoutRes layout: Int) : AbsMusicServi
private fun hideVolumeIfAvailable() { private fun hideVolumeIfAvailable() {
if (PreferenceUtil.isVolumeVisibilityMode) { if (PreferenceUtil.isVolumeVisibilityMode) {
childFragmentManager.beginTransaction() childFragmentManager.commit {
.replace(R.id.volumeFragmentContainer, VolumeFragment()).commit() replace<VolumeFragment>(R.id.volumeFragmentContainer)
}
childFragmentManager.executePendingTransactions() childFragmentManager.executePendingTransactions()
} }
volumeFragment = volumeFragment =

View file

@ -22,7 +22,7 @@ import android.view.MenuItem.SHOW_AS_ACTION_IF_ROOM
import android.view.View import android.view.View
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.text.HtmlCompat import androidx.core.text.parseAsHtml
import androidx.core.view.doOnLayout import androidx.core.view.doOnLayout
import androidx.core.view.doOnPreDraw import androidx.core.view.doOnPreDraw
import androidx.core.view.isVisible import androidx.core.view.isVisible
@ -171,10 +171,7 @@ class HomeFragment :
findNavController().navigate(R.id.action_search, null, navOptions) findNavController().navigate(R.id.action_search, null, navOptions)
} }
val hexColor = String.format("#%06X", 0xFFFFFF and accentColor()) val hexColor = String.format("#%06X", 0xFFFFFF and accentColor())
val appName = HtmlCompat.fromHtml( val appName = "Retro <span style='color:$hexColor';>Music</span>".parseAsHtml()
"Retro <span style='color:$hexColor';>Music</span>",
HtmlCompat.FROM_HTML_MODE_COMPACT
)
binding.appNameText.text = appName binding.appNameText.text = appName
} }

View file

@ -19,7 +19,7 @@ import android.view.Menu
import android.view.MenuInflater import android.view.MenuInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.core.text.HtmlCompat import androidx.core.text.parseAsHtml
import androidx.navigation.fragment.NavHostFragment import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import androidx.navigation.ui.NavigationUI import androidx.navigation.ui.NavigationUI
@ -66,10 +66,7 @@ class LibraryFragment : AbsMainActivityFragment(R.layout.fragment_library) {
private fun setupTitle() { private fun setupTitle() {
val color = ThemeStore.accentColor(requireContext()) val color = ThemeStore.accentColor(requireContext())
val hexColor = String.format("#%06X", 0xFFFFFF and color) val hexColor = String.format("#%06X", 0xFFFFFF and color)
val appName = HtmlCompat.fromHtml( val appName = "Retro <span style='color:$hexColor';>Music</span>".parseAsHtml()
"Retro <span style='color:$hexColor';>Music</span>",
HtmlCompat.FROM_HTML_MODE_COMPACT
)
binding.appNameText.text = appName binding.appNameText.text = appName
} }

View file

@ -2,7 +2,6 @@ package code.name.monkey.retromusic.fragments.other
import android.content.SharedPreferences import android.content.SharedPreferences
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils
import android.view.View import android.view.View
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.TextView import android.widget.TextView
@ -92,9 +91,7 @@ class CoverLyricsFragment : AbsMusicServiceFragment(R.layout.fragment_cover_lyri
val lrcFile: File? = LyricUtil.getSyncedLyricsFile(song) val lrcFile: File? = LyricUtil.getSyncedLyricsFile(song)
val data: String = LyricUtil.getStringFromLrc(lrcFile) val data: String = LyricUtil.getStringFromLrc(lrcFile)
Lyrics.parse(song, Lyrics.parse(song,
if (!TextUtils.isEmpty(data)) { data.ifEmpty {
data
} else {
// Get Embedded Lyrics // Get Embedded Lyrics
LyricUtil.getEmbeddedSyncedLyrics(song.data) LyricUtil.getEmbeddedSyncedLyrics(song.data)
} }

View file

@ -18,13 +18,14 @@ import android.animation.ObjectAnimator
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.text.SpannableString
import android.text.SpannableStringBuilder import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan import android.text.style.ForegroundColorSpan
import android.view.GestureDetector import android.view.GestureDetector
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
import android.view.animation.DecelerateInterpolator import android.view.animation.DecelerateInterpolator
import androidx.core.text.toSpannable
import androidx.core.view.isVisible
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentMiniPlayerBinding import code.name.monkey.retromusic.databinding.FragmentMiniPlayerBinding
import code.name.monkey.retromusic.extensions.accentColor import code.name.monkey.retromusic.extensions.accentColor
@ -70,10 +71,8 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(R.layout.fragment_mini_p
binding.actionNext.show() binding.actionNext.show()
binding.actionPrevious.show() binding.actionPrevious.show()
} else { } else {
binding.actionNext.visibility = binding.actionNext.isVisible = PreferenceUtil.isExtraControls
if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE binding.actionPrevious.isVisible = PreferenceUtil.isExtraControls
binding.actionPrevious.visibility =
if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE
} }
binding.actionNext.setOnClickListener(this) binding.actionNext.setOnClickListener(this)
binding.actionPrevious.setOnClickListener(this) binding.actionPrevious.setOnClickListener(this)
@ -94,10 +93,10 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(R.layout.fragment_mini_p
val builder = SpannableStringBuilder() val builder = SpannableStringBuilder()
val title = SpannableString(song.title) val title = song.title.toSpannable()
title.setSpan(ForegroundColorSpan(textColorPrimary()), 0, title.length, 0) title.setSpan(ForegroundColorSpan(textColorPrimary()), 0, title.length, 0)
val text = SpannableString(song.artistName) val text = song.artistName.toSpannable()
text.setSpan(ForegroundColorSpan(textColorSecondary()), 0, text.length, 0) text.setSpan(ForegroundColorSpan(textColorSecondary()), 0, text.length, 0)
builder.append(title).append("").append(text) builder.append(title).append("").append(text)

View file

@ -20,7 +20,6 @@ import android.graphics.Bitmap
import android.graphics.Color import android.graphics.Color
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
@ -98,10 +97,10 @@ class UserInfoFragment : Fragment() {
binding.next.setOnClickListener { binding.next.setOnClickListener {
val nameString = binding.name.text.toString().trim { it <= ' ' } val nameString = binding.name.text.toString().trim { it <= ' ' }
if (TextUtils.isEmpty(nameString)) { if (nameString.isEmpty()) {
Toast.makeText( Toast.makeText(
requireContext(), requireContext(),
"Umm you're name can't be empty!", "Your name can't be empty!",
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
).show() ).show()
return@setOnClickListener return@setOnClickListener

View file

@ -25,6 +25,7 @@ import android.view.animation.LinearInterpolator
import android.widget.SeekBar import android.widget.SeekBar
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.commit
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
@ -168,9 +169,9 @@ class ClassicPlayerFragment : AbsPlayerFragment(R.layout.fragment_classic_player
private fun hideVolumeIfAvailable() { private fun hideVolumeIfAvailable() {
if (PreferenceUtil.isVolumeVisibilityMode) { if (PreferenceUtil.isVolumeVisibilityMode) {
childFragmentManager.beginTransaction() childFragmentManager.commit {
.replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance()) replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance())
.commit() }
childFragmentManager.executePendingTransactions() childFragmentManager.executePendingTransactions()
volumeFragment = volumeFragment =
childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment? childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?

View file

@ -31,6 +31,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import androidx.fragment.app.commit
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -303,9 +304,9 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
private fun hideVolumeIfAvailable() { private fun hideVolumeIfAvailable() {
if (PreferenceUtil.isVolumeVisibilityMode) { if (PreferenceUtil.isVolumeVisibilityMode) {
childFragmentManager.beginTransaction() childFragmentManager.commit {
.replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance()) replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance())
.commit() }
childFragmentManager.executePendingTransactions() childFragmentManager.executePendingTransactions()
volumeFragment = volumeFragment =
childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment? childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?

View file

@ -20,13 +20,12 @@ import android.content.Intent
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.os.Bundle import android.os.Bundle
import android.speech.RecognizerIntent import android.speech.RecognizerIntent
import android.text.Editable
import android.text.TextWatcher
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import androidx.core.content.getSystemService import androidx.core.content.getSystemService
import androidx.core.view.* import androidx.core.view.*
import androidx.core.widget.doAfterTextChanged
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.transition.TransitionManager import androidx.transition.TransitionManager
@ -51,7 +50,7 @@ import net.yslibrary.android.keyboardvisibilityevent.KeyboardVisibilityEvent
import java.util.* import java.util.*
class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWatcher, class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search),
ChipGroup.OnCheckedStateChangeListener { ChipGroup.OnCheckedStateChangeListener {
companion object { companion object {
const val QUERY = "query" const val QUERY = "query"
@ -81,7 +80,10 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
searchAdapter.swapDataSet(listOf()) searchAdapter.swapDataSet(listOf())
} }
binding.searchView.apply { binding.searchView.apply {
addTextChangedListener(this@SearchFragment) doAfterTextChanged {
if (!it.isNullOrEmpty())
search(it.toString())
}
focusAndShowKeyboard() focusAndShowKeyboard()
} }
binding.keyboardPopup.apply { binding.keyboardPopup.apply {
@ -171,16 +173,6 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
} }
} }
override fun afterTextChanged(newText: Editable?) {
if (!newText.isNullOrEmpty()) search(newText.toString())
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
private fun search(query: String) { private fun search(query: String) {
this.query = query this.query = query
TransitionManager.beginDelayedTransition(binding.appBarLayout) TransitionManager.beginDelayedTransition(binding.appBarLayout)

View file

@ -19,6 +19,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.isGone
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
@ -26,8 +27,6 @@ import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentMainSettingsBinding import code.name.monkey.retromusic.databinding.FragmentMainSettingsBinding
import code.name.monkey.retromusic.extensions.drawAboveSystemBarsWithPadding import code.name.monkey.retromusic.extensions.drawAboveSystemBarsWithPadding
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
class MainSettingsFragment : Fragment(), View.OnClickListener { class MainSettingsFragment : Fragment(), View.OnClickListener {
@ -76,7 +75,7 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
binding.backupRestoreSettings.setOnClickListener(this) binding.backupRestoreSettings.setOnClickListener(this)
binding.buyProContainer.apply { binding.buyProContainer.apply {
if (App.isProVersion()) hide() else show() isGone = App.isProVersion()
setOnClickListener { setOnClickListener {
NavigationUtil.goToProVersion(requireContext()) NavigationUtil.goToProVersion(requireContext())
} }

View file

@ -16,6 +16,7 @@ package code.name.monkey.retromusic.fragments.settings
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import androidx.core.content.edit
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.TwoStatePreference import androidx.preference.TwoStatePreference
import code.name.monkey.appthemehelper.ACCENT_COLORS import code.name.monkey.appthemehelper.ACCENT_COLORS
@ -93,10 +94,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
val desaturatedColor: ATESwitchPreference? = findPreference(DESATURATED_COLOR) val desaturatedColor: ATESwitchPreference? = findPreference(DESATURATED_COLOR)
desaturatedColor?.setOnPreferenceChangeListener { _, value -> desaturatedColor?.setOnPreferenceChangeListener { _, value ->
val desaturated = value as Boolean val desaturated = value as Boolean
ThemeStore.prefs(requireContext()) ThemeStore.prefs(requireContext()).edit {
.edit() putBoolean("desaturated_color", desaturated)
.putBoolean("desaturated_color", desaturated) }
.apply()
PreferenceUtil.isDesaturatedColor = desaturated PreferenceUtil.isDesaturatedColor = desaturated
restartActivity() restartActivity()
true true

View file

@ -24,7 +24,6 @@ import android.os.Looper
import android.text.Layout import android.text.Layout
import android.text.StaticLayout import android.text.StaticLayout
import android.text.TextPaint import android.text.TextPaint
import android.text.TextUtils
import android.text.format.DateUtils import android.text.format.DateUtils
import android.util.AttributeSet import android.util.AttributeSet
import android.view.GestureDetector import android.view.GestureDetector
@ -34,6 +33,7 @@ import android.view.View
import android.view.animation.LinearInterpolator import android.view.animation.LinearInterpolator
import android.widget.Scroller import android.widget.Scroller
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.graphics.withSave
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import java.io.File import java.io.File
import kotlin.math.abs import kotlin.math.abs
@ -208,7 +208,7 @@ class CoverLrcView @JvmOverloads constructor(
) )
mDefaultLabel = ta.getString(R.styleable.LrcView_lrcLabel) mDefaultLabel = ta.getString(R.styleable.LrcView_lrcLabel)
mDefaultLabel = mDefaultLabel =
if (TextUtils.isEmpty(mDefaultLabel)) context.getString(R.string.empty) else mDefaultLabel if (mDefaultLabel.isNullOrEmpty()) context.getString(R.string.empty) else mDefaultLabel
mLrcPadding = ta.getDimension(R.styleable.LrcView_lrcPadding, 0f) mLrcPadding = ta.getDimension(R.styleable.LrcView_lrcPadding, 0f)
mTimelineColor = ta.getColor( mTimelineColor = ta.getColor(
R.styleable.LrcView_lrcTimelineColor, R.styleable.LrcView_lrcTimelineColor,
@ -522,10 +522,10 @@ class CoverLrcView @JvmOverloads constructor(
* @param y 歌词中心 Y 坐标 * @param y 歌词中心 Y 坐标
*/ */
private fun drawText(canvas: Canvas, staticLayout: StaticLayout, y: Float) { private fun drawText(canvas: Canvas, staticLayout: StaticLayout, y: Float) {
canvas.save() canvas.withSave {
canvas.translate(mLrcPadding, y - (staticLayout.height shr 1)) translate(mLrcPadding, y - (staticLayout.height shr 1))
staticLayout.draw(canvas) staticLayout.draw(this)
canvas.restore() }
} }
fun animateCurrentTextSize() { fun animateCurrentTextSize() {

View file

@ -21,7 +21,7 @@ import android.util.AttributeSet
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.graphics.BlendModeColorFilterCompat import androidx.core.graphics.BlendModeColorFilterCompat
import androidx.core.graphics.BlendModeCompat.SRC_IN import androidx.core.graphics.BlendModeCompat.SRC_IN
import androidx.core.text.HtmlCompat import androidx.core.text.parseAsHtml
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
import code.name.monkey.retromusic.App import code.name.monkey.retromusic.App
@ -84,15 +84,10 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
.setItems(paths.toTypedArray()) { _, which -> .setItems(paths.toTypedArray()) { _, which ->
materialDialog(R.string.remove_from_blacklist) materialDialog(R.string.remove_from_blacklist)
.setMessage( .setMessage(
HtmlCompat.fromHtml(
String.format( String.format(
getString( getString(R.string.do_you_want_to_remove_from_the_blacklist),
R.string.do_you_want_to_remove_from_the_blacklist
),
paths[which] paths[which]
), ).parseAsHtml()
HtmlCompat.FROM_HTML_MODE_LEGACY
)
) )
.setPositiveButton(R.string.remove_action) { _, _ -> .setPositiveButton(R.string.remove_action) { _, _ ->
BlacklistStore.getInstance(App.getContext()) BlacklistStore.getInstance(App.getContext())

View file

@ -7,10 +7,10 @@ import android.media.AudioAttributes
import android.media.AudioManager import android.media.AudioManager
import android.media.MediaPlayer import android.media.MediaPlayer
import android.media.audiofx.AudioEffect import android.media.audiofx.AudioEffect
import android.net.Uri
import android.os.PowerManager import android.os.PowerManager
import android.util.Log import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.core.net.toUri
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.service.AudioFader.Companion.createFadeAnimator import code.name.monkey.retromusic.service.AudioFader.Companion.createFadeAnimator
@ -160,7 +160,7 @@ class CrossFadePlayer(val context: Context) : Playback, MediaPlayer.OnCompletion
player.setOnPreparedListener(null) player.setOnPreparedListener(null)
try { try {
if (path.startsWith("content://")) { if (path.startsWith("content://")) {
player.setDataSource(context, Uri.parse(path)) player.setDataSource(context, path.toUri())
} else { } else {
player.setDataSource(path) player.setDataSource(path)
} }

View file

@ -540,10 +540,9 @@ class MusicService : MediaBrowserServiceCompat(),
} }
fun setShuffleMode(shuffleMode: Int) { fun setShuffleMode(shuffleMode: Int) {
PreferenceManager.getDefaultSharedPreferences(this) PreferenceManager.getDefaultSharedPreferences(this).edit {
.edit() putInt(SAVED_SHUFFLE_MODE, shuffleMode)
.putInt(SAVED_SHUFFLE_MODE, shuffleMode) }
.apply()
when (shuffleMode) { when (shuffleMode) {
SHUFFLE_MODE_SHUFFLE -> { SHUFFLE_MODE_SHUFFLE -> {
this.shuffleMode = shuffleMode this.shuffleMode = shuffleMode

View file

@ -26,7 +26,7 @@ import android.graphics.drawable.Drawable
import android.os.Build import android.os.Build
import android.support.v4.media.session.MediaSessionCompat import android.support.v4.media.session.MediaSessionCompat
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.text.HtmlCompat import androidx.core.text.parseAsHtml
import androidx.media.app.NotificationCompat.MediaStyle import androidx.media.app.NotificationCompat.MediaStyle
import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -120,19 +120,9 @@ class PlayingNotificationImpl24(
} }
override fun updateMetadata(song: Song, onUpdate: () -> Unit) { override fun updateMetadata(song: Song, onUpdate: () -> Unit) {
setContentTitle( setContentTitle(("<b>" + song.title + "</b>").parseAsHtml())
HtmlCompat.fromHtml(
"<b>" + song.title + "</b>",
HtmlCompat.FROM_HTML_MODE_LEGACY
)
)
setContentText(song.artistName) setContentText(song.artistName)
setSubText( setSubText(("<b>" + song.albumName + "</b>").parseAsHtml())
HtmlCompat.fromHtml(
"<b>" + song.albumName + "</b>",
HtmlCompat.FROM_HTML_MODE_LEGACY
)
)
val bigNotificationImageSize = context.resources val bigNotificationImageSize = context.resources
.getDimensionPixelSize(R.dimen.notification_big_image_size) .getDimensionPixelSize(R.dimen.notification_big_image_size)
GlideApp.with(context).asBitmapPalette().songCoverOptions(song) GlideApp.with(context).asBitmapPalette().songCoverOptions(song)

View file

@ -23,6 +23,7 @@ import android.net.Uri
import android.os.AsyncTask import android.os.AsyncTask
import android.provider.MediaStore import android.provider.MediaStore
import android.widget.Toast import android.widget.Toast
import androidx.core.content.edit
import code.name.monkey.retromusic.App import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.model.Artist import code.name.monkey.retromusic.model.Artist
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
@ -79,7 +80,7 @@ class CustomArtistImageUtil private constructor(context: Context) {
} }
if (succesful) { if (succesful) {
mPreferences.edit().putBoolean(getFileName(artist), true).apply() mPreferences.edit { putBoolean(getFileName(artist), true) }
ArtistSignatureUtil.getInstance(App.getContext()) ArtistSignatureUtil.getInstance(App.getContext())
.updateArtistSignature(artist.name) .updateArtistSignature(artist.name)
App.getContext().contentResolver.notifyChange( App.getContext().contentResolver.notifyChange(
@ -99,7 +100,7 @@ class CustomArtistImageUtil private constructor(context: Context) {
object : AsyncTask<Void, Void, Void>() { object : AsyncTask<Void, Void, Void>() {
@SuppressLint("ApplySharedPref") @SuppressLint("ApplySharedPref")
override fun doInBackground(vararg params: Void): Void? { override fun doInBackground(vararg params: Void): Void? {
mPreferences.edit().putBoolean(getFileName(artist), false).commit() mPreferences.edit(commit = true) { putBoolean(getFileName(artist), false) }
ArtistSignatureUtil.getInstance(App.getContext()).updateArtistSignature(artist.name) ArtistSignatureUtil.getInstance(App.getContext()).updateArtistSignature(artist.name)
App.getContext().contentResolver.notifyChange( App.getContext().contentResolver.notifyChange(
MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,

View file

@ -132,27 +132,14 @@ object LyricUtil {
} }
@Throws(Exception::class) @Throws(Exception::class)
private fun convertStreamToString(`is`: InputStream): String { private fun convertStreamToString(inputStream: InputStream): String {
val reader = BufferedReader(InputStreamReader(`is`)) return inputStream.bufferedReader().readLines().joinToString(separator = "\n")
val sb = StringBuilder()
var line: String?
while (reader.readLine().also { line = it } != null) {
sb.append(line).append("\n")
}
reader.close()
return sb.toString()
} }
fun getStringFromLrc(file: File?): String { fun getStringFromLrc(file: File?): String {
try { try {
val reader = BufferedReader(FileReader(file)) val reader = BufferedReader(FileReader(file))
val sb = StringBuilder() return reader.readLines().joinToString(separator = "\n")
var line: String?
while (reader.readLine().also { line = it } != null) {
sb.append(line).append("\n")
}
reader.close()
return sb.toString()
} catch (e: Exception) { } catch (e: Exception) {
Log.i("Error", "Error Occurred") Log.i("Error", "Error Occurred")
} }

View file

@ -4,6 +4,7 @@ import android.graphics.Bitmap
import android.graphics.Canvas import android.graphics.Canvas
import android.graphics.Matrix import android.graphics.Matrix
import android.graphics.Paint import android.graphics.Paint
import androidx.core.graphics.scale
import com.bumptech.glide.util.Util.assertBackgroundThread import com.bumptech.glide.util.Util.assertBackgroundThread
@ -75,7 +76,7 @@ internal object MergedImageUtils {
val onePartSize = imageSize / parts val onePartSize = imageSize / parts
images.forEachIndexed { i, bitmap -> images.forEachIndexed { i, bitmap ->
val bit = Bitmap.createScaledBitmap(bitmap, onePartSize, onePartSize, true) val bit = bitmap.scale(onePartSize, onePartSize)
canvas.drawBitmap( canvas.drawBitmap(
bit, bit,
(onePartSize * (i % parts)).toFloat() + (i % 3) * 50, (onePartSize * (i % parts)).toFloat() + (i % 3) * 50,

View file

@ -1,7 +1,6 @@
package code.name.monkey.retromusic.util package code.name.monkey.retromusic.util
import android.content.ContentUris import android.content.ContentUris
import android.content.ContentValues
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.database.Cursor import android.database.Cursor
@ -9,10 +8,11 @@ import android.net.Uri
import android.os.Environment import android.os.Environment
import android.provider.BaseColumns import android.provider.BaseColumns
import android.provider.MediaStore import android.provider.MediaStore
import android.text.TextUtils
import android.util.Log import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.core.content.FileProvider import androidx.core.content.FileProvider
import androidx.core.content.contentValuesOf
import androidx.core.net.toUri
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -99,7 +99,7 @@ object MusicUtil : KoinComponent {
fun deleteAlbumArt(context: Context, albumId: Long) { fun deleteAlbumArt(context: Context, albumId: Long) {
val contentResolver = context.contentResolver val contentResolver = context.contentResolver
val localUri = Uri.parse("content://media/external/audio/albumart") val localUri = "content://media/external/audio/albumart".toUri()
contentResolver.delete(ContentUris.withAppendedId(localUri, albumId), null, null) contentResolver.delete(ContentUris.withAppendedId(localUri, albumId), null, null)
contentResolver.notifyChange(localUri, null) contentResolver.notifyChange(localUri, null)
} }
@ -189,7 +189,7 @@ object MusicUtil : KoinComponent {
@JvmStatic @JvmStatic
fun getMediaStoreAlbumCoverUri(albumId: Long): Uri { fun getMediaStoreAlbumCoverUri(albumId: Long): Uri {
val sArtworkUri = Uri.parse("content://media/external/audio/albumart") val sArtworkUri = "content://media/external/audio/albumart".toUri()
return ContentUris.withAppendedId(sArtworkUri, albumId) return ContentUris.withAppendedId(sArtworkUri, albumId)
} }
@ -238,10 +238,10 @@ object MusicUtil : KoinComponent {
fun getSectionName(mediaTitle: String?): String { fun getSectionName(mediaTitle: String?): String {
var musicMediaTitle = mediaTitle var musicMediaTitle = mediaTitle
return try { return try {
if (TextUtils.isEmpty(musicMediaTitle)) { if (musicMediaTitle.isNullOrEmpty()) {
return "-" return "-"
} }
musicMediaTitle = musicMediaTitle!!.trim { it <= ' ' }.lowercase() musicMediaTitle = musicMediaTitle.trim { it <= ' ' }.lowercase()
if (musicMediaTitle.startsWith("the ")) { if (musicMediaTitle.startsWith("the ")) {
musicMediaTitle = musicMediaTitle.substring(4) musicMediaTitle = musicMediaTitle.substring(4)
} else if (musicMediaTitle.startsWith("a ")) { } else if (musicMediaTitle.startsWith("a ")) {
@ -309,28 +309,29 @@ object MusicUtil : KoinComponent {
path: String? path: String?
) { ) {
val contentResolver = context.contentResolver val contentResolver = context.contentResolver
val artworkUri = Uri.parse("content://media/external/audio/albumart") val artworkUri = "content://media/external/audio/albumart".toUri()
contentResolver.delete(ContentUris.withAppendedId(artworkUri, albumId), null, null) contentResolver.delete(ContentUris.withAppendedId(artworkUri, albumId), null, null)
val values = ContentValues() val values = contentValuesOf(
values.put("album_id", albumId) "album_id" to albumId,
values.put("_data", path) "_data" to path
)
contentResolver.insert(artworkUri, values) contentResolver.insert(artworkUri, values)
contentResolver.notifyChange(artworkUri, null) contentResolver.notifyChange(artworkUri, null)
} }
fun isArtistNameUnknown(artistName: String?): Boolean { fun isArtistNameUnknown(artistName: String?): Boolean {
if (TextUtils.isEmpty(artistName)) { if (artistName.isNullOrEmpty()) {
return false return false
} }
if (artistName == Artist.UNKNOWN_ARTIST_DISPLAY_NAME) { if (artistName == Artist.UNKNOWN_ARTIST_DISPLAY_NAME) {
return true return true
} }
val tempName = artistName!!.trim { it <= ' ' }.lowercase() val tempName = artistName.trim { it <= ' ' }.lowercase()
return tempName == "unknown" || tempName == "<unknown>" return tempName == "unknown" || tempName == "<unknown>"
} }
fun isVariousArtists(artistName: String?): Boolean { fun isVariousArtists(artistName: String?): Boolean {
if (TextUtils.isEmpty(artistName)) { if (artistName.isNullOrEmpty()) {
return false return false
} }
if (artistName == Artist.VARIOUS_ARTISTS_DISPLAY_NAME) { if (artistName == Artist.VARIOUS_ARTISTS_DISPLAY_NAME) {
@ -454,7 +455,7 @@ object MusicUtil : KoinComponent {
} catch (ignored: SecurityException) { } catch (ignored: SecurityException) {
} }
activity.contentResolver.notifyChange(Uri.parse("content://media"), null) activity.contentResolver.notifyChange("content://media".toUri(), null)
activity.runOnUiThread { activity.runOnUiThread {
Toast.makeText( Toast.makeText(
activity, activity,

View file

@ -16,11 +16,11 @@ package code.name.monkey.retromusic.util
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri
import android.provider.BaseColumns import android.provider.BaseColumns
import android.provider.MediaStore import android.provider.MediaStore
import android.provider.Settings import android.provider.Settings
import android.widget.Toast import android.widget.Toast
import androidx.core.net.toUri
import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
@ -69,7 +69,7 @@ class RingtoneManager(val context: Context) {
.setMessage(R.string.dialog_message_set_ringtone) .setMessage(R.string.dialog_message_set_ringtone)
.setPositiveButton(android.R.string.ok) { _, _ -> .setPositiveButton(android.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 = ("package:" + context.applicationContext.packageName).toUri()
context.startActivity(intent) context.startActivity(intent)
} }
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)

View file

@ -20,6 +20,7 @@ import android.graphics.Color
import android.util.AttributeSet import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.AppCompatImageView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.content.withStyledAttributes
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
@ -38,12 +39,10 @@ class ColorIconsImageView @JvmOverloads constructor(
init { init {
// Load the styled attributes and set their properties // Load the styled attributes and set their properties
val attributes = context.withStyledAttributes(attrs, R.styleable.ColorIconsImageView, 0, 0) {
context.obtainStyledAttributes(attrs, R.styleable.ColorIconsImageView, 0, 0) val color = getColor(R.styleable.ColorIconsImageView_iconBackgroundColor, Color.RED)
val color =
attributes.getColor(R.styleable.ColorIconsImageView_iconBackgroundColor, Color.RED)
setIconBackgroundColor(color) setIconBackgroundColor(color)
attributes.recycle() }
} }
fun setIconBackgroundColor(color: Int) { fun setIconBackgroundColor(color: Int) {

View file

@ -18,6 +18,7 @@ import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.view.LayoutInflater import android.view.LayoutInflater
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.core.content.withStyledAttributes
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.ListItemViewNoCardBinding import code.name.monkey.retromusic.databinding.ListItemViewNoCardBinding
import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.hide
@ -49,20 +50,20 @@ class ListItemView : FrameLayout {
private fun init(context: Context, attrs: AttributeSet?) { private fun init(context: Context, attrs: AttributeSet?) {
binding = ListItemViewNoCardBinding.inflate(LayoutInflater.from(context), this, true) binding = ListItemViewNoCardBinding.inflate(LayoutInflater.from(context), this, true)
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ListItemView) context.withStyledAttributes(attrs, R.styleable.ListItemView) {
if (typedArray.hasValue(R.styleable.ListItemView_listItemIcon)) { if (hasValue(R.styleable.ListItemView_listItemIcon)) {
binding.icon.setImageDrawable(typedArray.getDrawable(R.styleable.ListItemView_listItemIcon)) binding.icon.setImageDrawable(getDrawable(R.styleable.ListItemView_listItemIcon))
} else { } else {
binding.icon.hide() binding.icon.hide()
} }
binding.title.text = typedArray.getText(R.styleable.ListItemView_listItemTitle) binding.title.text = getText(R.styleable.ListItemView_listItemTitle)
if (typedArray.hasValue(R.styleable.ListItemView_listItemSummary)) { if (hasValue(R.styleable.ListItemView_listItemSummary)) {
binding.summary.text = typedArray.getText(R.styleable.ListItemView_listItemSummary) binding.summary.text = getText(R.styleable.ListItemView_listItemSummary)
} else { } else {
binding.summary.hide() binding.summary.hide()
} }
typedArray.recycle() }
} }
fun setSummary(appVersion: String) { fun setSummary(appVersion: String) {

View file

@ -5,6 +5,7 @@ import android.content.res.ColorStateList
import android.util.AttributeSet import android.util.AttributeSet
import android.view.LayoutInflater import android.view.LayoutInflater
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.core.content.withStyledAttributes
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -21,16 +22,15 @@ class PermissionItem @JvmOverloads constructor(
val checkImage get() = binding.checkImage val checkImage get() = binding.checkImage
init { init {
val attributes = context.obtainStyledAttributes(attrs, R.styleable.PermissionItem, 0, 0)
binding = ItemPermissionBinding.inflate(LayoutInflater.from(context), this, true) binding = ItemPermissionBinding.inflate(LayoutInflater.from(context), this, true)
binding.title.text = attributes.getText(R.styleable.PermissionItem_permissionTitle) context.withStyledAttributes(attrs, R.styleable.PermissionItem, 0, 0) {
binding.summary.text = binding.title.text = getText(R.styleable.PermissionItem_permissionTitle)
attributes.getText(R.styleable.PermissionItem_permissionTitleSubTitle) binding.summary.text = getText(R.styleable.PermissionItem_permissionTitleSubTitle)
binding.number.text = attributes.getText(R.styleable.PermissionItem_permissionTitleNumber) binding.number.text = getText(R.styleable.PermissionItem_permissionTitleNumber)
binding.button.text = attributes.getText(R.styleable.PermissionItem_permissionButtonTitle) binding.button.text = getText(R.styleable.PermissionItem_permissionButtonTitle)
binding.button.setIconResource( binding.button.setIconResource(
attributes.getResourceId( getResourceId(
R.styleable.PermissionItem_permissionIcon, R.styleable.PermissionItem_permissionIcon,
R.drawable.ic_album R.drawable.ic_album
) )
@ -40,7 +40,7 @@ class PermissionItem @JvmOverloads constructor(
ColorStateList.valueOf(ColorUtil.withAlpha(color, 0.22f)) ColorStateList.valueOf(ColorUtil.withAlpha(color, 0.22f))
binding.button.accentOutlineColor() binding.button.accentOutlineColor()
attributes.recycle() }
} }
fun setButtonClick(callBack: () -> Unit) { fun setButtonClick(callBack: () -> Unit) {

View file

@ -18,6 +18,7 @@ import android.graphics.Color
import android.util.AttributeSet import android.util.AttributeSet
import android.view.LayoutInflater import android.view.LayoutInflater
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.core.content.withStyledAttributes
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.ListSettingItemViewBinding import code.name.monkey.retromusic.databinding.ListSettingItemViewBinding
@ -33,21 +34,15 @@ class SettingListItemView @JvmOverloads constructor(
init { init {
val binding: ListSettingItemViewBinding = val binding: ListSettingItemViewBinding =
ListSettingItemViewBinding.inflate(LayoutInflater.from(context), this, true) ListSettingItemViewBinding.inflate(LayoutInflater.from(context), this, true)
val typedArray = context.withStyledAttributes(attrs, R.styleable.SettingListItemView) {
context.obtainStyledAttributes(attrs, R.styleable.SettingListItemView) if (hasValue(R.styleable.SettingListItemView_settingListItemIcon)) {
binding.icon binding.icon.setImageDrawable(getDrawable(R.styleable.SettingListItemView_settingListItemIcon))
if (typedArray.hasValue(R.styleable.SettingListItemView_settingListItemIcon)) {
binding.icon.setImageDrawable(typedArray.getDrawable(R.styleable.SettingListItemView_settingListItemIcon))
} }
binding.icon.setIconBackgroundColor( binding.icon.setIconBackgroundColor(
typedArray.getColor( getColor(R.styleable.SettingListItemView_settingListItemIconColor, Color.WHITE)
R.styleable.SettingListItemView_settingListItemIconColor,
Color.WHITE
) )
) binding.title.text = getText(R.styleable.SettingListItemView_settingListItemTitle)
binding.title.text = binding.text.text = getText(R.styleable.SettingListItemView_settingListItemText)
typedArray.getText(R.styleable.SettingListItemView_settingListItemTitle) }
binding.text.text = typedArray.getText(R.styleable.SettingListItemView_settingListItemText)
typedArray.recycle()
} }
} }

View file

@ -6,6 +6,7 @@ import android.graphics.Color
import androidx.annotation.* import androidx.annotation.*
import androidx.annotation.IntRange import androidx.annotation.IntRange
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import code.name.monkey.appthemehelper.util.ATHUtil.isWindowBackgroundDark import code.name.monkey.appthemehelper.util.ATHUtil.isWindowBackgroundDark
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
@ -336,7 +337,7 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
val prefs = prefs(context) val prefs = prefs(context)
val lastVersion = prefs.getInt(ThemeStorePrefKeys.IS_CONFIGURED_VERSION_KEY, -1) val lastVersion = prefs.getInt(ThemeStorePrefKeys.IS_CONFIGURED_VERSION_KEY, -1)
if (version > lastVersion) { if (version > lastVersion) {
prefs.edit().putInt(ThemeStorePrefKeys.IS_CONFIGURED_VERSION_KEY, version).apply() prefs.edit { putInt(ThemeStorePrefKeys.IS_CONFIGURED_VERSION_KEY, version) }
return false return false
} }
return true return true

View file

@ -5,6 +5,7 @@ import android.text.Editable
import android.util.AttributeSet import android.util.AttributeSet
import android.widget.SeekBar import android.widget.SeekBar
import android.widget.TextView import android.widget.TextView
import androidx.core.content.withStyledAttributes
import androidx.core.graphics.BlendModeColorFilterCompat import androidx.core.graphics.BlendModeColorFilterCompat
import androidx.core.graphics.BlendModeCompat import androidx.core.graphics.BlendModeCompat
import androidx.core.widget.doAfterTextChanged import androidx.core.widget.doAfterTextChanged
@ -26,13 +27,11 @@ class ATESeekBarPreference @JvmOverloads constructor(
var unit: String = "" var unit: String = ""
init { init {
val attributes = context.withStyledAttributes(attrs, R.styleable.ATESeekBarPreference, 0, 0) {
context.obtainStyledAttributes(attrs, R.styleable.ATESeekBarPreference, 0, 0) getString(R.styleable.ATESeekBarPreference_ateKey_pref_unit)?.let {
attributes.getString(R.styleable.ATESeekBarPreference_ateKey_pref_unit)?.let {
unit = it unit = it
} }
attributes.recycle() }
icon?.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat( icon?.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
ATHUtil.resolveColor( ATHUtil.resolveColor(
context, context,