Fix depricated issues
This commit is contained in:
parent
98ead185d5
commit
6966351113
13 changed files with 46 additions and 60 deletions
|
@ -12,6 +12,7 @@ import android.view.MenuItem
|
|||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@ -207,13 +208,8 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
if (bioContent != null && bioContent.trim { it <= ' ' }.isNotEmpty()) {
|
||||
biographyText.visibility = View.VISIBLE
|
||||
biographyTitle.visibility = View.VISIBLE
|
||||
biography = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
Html.fromHtml(bioContent, Html.FROM_HTML_MODE_LEGACY)
|
||||
} else {
|
||||
Html.fromHtml(bioContent)
|
||||
}
|
||||
biography = HtmlCompat.fromHtml(bioContent,HtmlCompat.FROM_HTML_MODE_LEGACY)
|
||||
biographyText.text = biography
|
||||
|
||||
if (lastFmArtist.artist.stats.listeners.isNotEmpty()) {
|
||||
listeners.show()
|
||||
listenersLabel.show()
|
||||
|
|
|
@ -57,7 +57,6 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
|||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity;
|
||||
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog;
|
||||
import code.name.monkey.retromusic.dialogs.OptionsSheetDialogFragment;
|
||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.AlbumsFragment;
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.ArtistsFragment;
|
||||
|
@ -763,19 +762,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
|||
.makeSceneTransitionAnimation(this, mToolbarContainer, getString(R.string.transition_toolbar));
|
||||
NavigationUtil.goToSearch(this, options);
|
||||
});
|
||||
|
||||
mToolbar.setNavigationOnClickListener(
|
||||
v -> {
|
||||
Fragment fragment = getCurrentFragment();
|
||||
if (fragment instanceof FoldersFragment) {
|
||||
OptionsSheetDialogFragment.newInstance(OptionsSheetDialogFragment.FOLDER)
|
||||
.show(getSupportFragmentManager(), "Main_Menu");
|
||||
} else {
|
||||
OptionsSheetDialogFragment.newInstance(OptionsSheetDialogFragment.LIBRARY)
|
||||
.show(getSupportFragmentManager(), "Main_Menu");
|
||||
}
|
||||
});
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -150,7 +150,7 @@ class AppWidgetCard : BaseAppWidget() {
|
|||
cardRadius =
|
||||
service.resources.getDimension(code.name.monkey.retromusic.R.dimen.app_widget_card_radius)
|
||||
}
|
||||
val appContext = service.applicationContext
|
||||
|
||||
// Load the album cover async and push the update on completion
|
||||
service.runOnUiThread {
|
||||
if (target != null) {
|
||||
|
|
|
@ -16,7 +16,7 @@ package code.name.monkey.retromusic.dialogs
|
|||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.R.string
|
||||
|
@ -37,14 +37,18 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
if (songs != null) {
|
||||
if (songs.size > 1) {
|
||||
title = R.string.remove_songs_from_playlist_title
|
||||
content = Html.fromHtml(getString(string.remove_x_songs_from_playlist, songs.size))
|
||||
content = HtmlCompat.fromHtml(
|
||||
getString(string.remove_x_songs_from_playlist, songs.size),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
} else {
|
||||
title = R.string.remove_song_from_playlist_title
|
||||
content = Html.fromHtml(
|
||||
content = HtmlCompat.fromHtml(
|
||||
getString(
|
||||
code.name.monkey.retromusic.R.string.remove_song_x_from_playlist,
|
||||
songs[0].title
|
||||
)
|
||||
),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +62,10 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
positiveButton(R.string.remove_action) {
|
||||
if (activity == null)
|
||||
return@positiveButton
|
||||
PlaylistsUtil.removeFromPlaylist(activity!!, songs as MutableList<PlaylistSong>)
|
||||
PlaylistsUtil.removeFromPlaylist(
|
||||
requireContext(),
|
||||
songs as MutableList<PlaylistSong>
|
||||
)
|
||||
}
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class RenamePlaylistDialog : DialogFragment() {
|
|||
negativeButton(android.R.string.cancel)
|
||||
positiveButton(string.action_rename) {
|
||||
if (playlistView.toString().trim { it <= ' ' } != "") {
|
||||
val playlistId = arguments!!.getLong(PLAYLIST_ID)
|
||||
val playlistId = requireArguments().getLong(PLAYLIST_ID)
|
||||
PlaylistsUtil.renamePlaylist(
|
||||
context,
|
||||
playlistId,
|
||||
|
|
|
@ -72,12 +72,12 @@ class SleepTimerDialog : DialogFragment() {
|
|||
val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000
|
||||
PreferenceUtil.getInstance(requireContext())
|
||||
.setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime)
|
||||
val am = activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
val am = requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi)
|
||||
|
||||
Toast.makeText(
|
||||
activity,
|
||||
activity!!.resources.getString(R.string.sleep_timer_set, minutes),
|
||||
requireContext(),
|
||||
requireContext().resources.getString(R.string.sleep_timer_set, minutes),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
@ -87,12 +87,13 @@ class SleepTimerDialog : DialogFragment() {
|
|||
}
|
||||
val previous = makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE)
|
||||
if (previous != null) {
|
||||
val am = activity!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
val am =
|
||||
requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
am.cancel(previous)
|
||||
previous.cancel()
|
||||
Toast.makeText(
|
||||
activity,
|
||||
activity!!.resources.getString(R.string.sleep_timer_canceled),
|
||||
requireContext(),
|
||||
requireContext().resources.getString(R.string.sleep_timer_canceled),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
@ -101,8 +102,8 @@ class SleepTimerDialog : DialogFragment() {
|
|||
if (musicService != null && musicService.pendingQuit) {
|
||||
musicService.pendingQuit = false
|
||||
Toast.makeText(
|
||||
activity,
|
||||
activity!!.resources.getString(R.string.sleep_timer_canceled),
|
||||
requireContext(),
|
||||
requireContext().resources.getString(R.string.sleep_timer_canceled),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
@ -166,11 +167,11 @@ class SleepTimerDialog : DialogFragment() {
|
|||
}
|
||||
|
||||
private fun makeTimerPendingIntent(flag: Int): PendingIntent? {
|
||||
return PendingIntent.getService(activity, 0, makeTimerIntent(), flag)
|
||||
return PendingIntent.getService(requireActivity(), 0, makeTimerIntent(), flag)
|
||||
}
|
||||
|
||||
private fun makeTimerIntent(): Intent {
|
||||
val intent = Intent(activity, MusicService::class.java)
|
||||
val intent = Intent(requireActivity(), MusicService::class.java)
|
||||
return if (shouldFinishLastSong.isChecked) {
|
||||
intent.setAction(ACTION_PENDING_QUIT)
|
||||
} else intent.setAction(ACTION_QUIT)
|
||||
|
@ -192,11 +193,11 @@ class SleepTimerDialog : DialogFragment() {
|
|||
) {
|
||||
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
materialDialog.getActionButton(WhichButton.NEGATIVE).text =
|
||||
String.format(
|
||||
"%s %s", materialDialog.context.getString(R.string.cancel_current_timer),
|
||||
" (" + MusicUtil.getReadableDurationString(millisUntilFinished) + ")"
|
||||
)
|
||||
materialDialog.getActionButton(WhichButton.NEGATIVE).text = String.format(
|
||||
"%s %s",
|
||||
materialDialog.context.getString(R.string.cancel_current_timer),
|
||||
" (" + MusicUtil.getReadableDurationString(millisUntilFinished) + ")"
|
||||
)
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
|
|
|
@ -17,13 +17,13 @@ package code.name.monkey.retromusic.dialogs
|
|||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.text.Spanned
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.R.string
|
||||
|
@ -53,7 +53,7 @@ class SongDetailDialog : DialogFragment() {
|
|||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val context: Context = requireContext()
|
||||
val song = arguments!!.getParcelable<Song>("song")
|
||||
val song = requireArguments().getParcelable<Song>("song")
|
||||
|
||||
val materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT))
|
||||
.show {
|
||||
|
@ -180,7 +180,10 @@ class SongDetailDialog : DialogFragment() {
|
|||
}
|
||||
|
||||
private fun makeTextWithTitle(context: Context, titleResId: Int, text: String?): Spanned {
|
||||
return Html.fromHtml("<b>" + context.resources.getString(titleResId) + ": " + "</b>" + text)
|
||||
return HtmlCompat.fromHtml(
|
||||
"<b>" + context.resources.getString(titleResId) + ": " + "</b>" + text,
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
}
|
||||
|
||||
private fun getFileSizeString(sizeInBytes: Long): String {
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.afollestad.materialdialogs.list.listItems
|
|||
|
||||
class SongShareDialog : DialogFragment() {
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val song: Song? = arguments?.getParcelable("song")
|
||||
val song: Song? = requireArguments().getParcelable("song")
|
||||
val currentlyListening: String =
|
||||
getString(R.string.currently_listening_to_x_by_x, song?.title, song?.artistName)
|
||||
|
||||
|
|
|
@ -45,8 +45,4 @@ abstract class AbsMainActivityFragment : AbsMusicServiceFragment() {
|
|||
setStatusBarColor(view, ColorUtil.darkenColor(colorPrimary))
|
||||
}
|
||||
}
|
||||
|
||||
protected fun showMainMenu(option: Int) {
|
||||
OptionsSheetDialogFragment.newInstance(option).show(childFragmentManager, "Main_Menu")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
|
|||
return true
|
||||
}
|
||||
R.id.action_sleep_timer -> {
|
||||
SleepTimerDialog().show(requireFragmentManager(), TAG)
|
||||
SleepTimerDialog().show(parentFragmentManager, TAG)
|
||||
return true
|
||||
}
|
||||
R.id.action_set_as_ringtone -> {
|
||||
|
|
|
@ -17,10 +17,10 @@ package code.name.monkey.retromusic.preferences
|
|||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.util.AttributeSet
|
||||
import androidx.core.graphics.BlendModeColorFilterCompat
|
||||
import androidx.core.graphics.BlendModeCompat.SRC_IN
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -91,11 +91,12 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
|||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
title(code.name.monkey.retromusic.R.string.remove_from_blacklist)
|
||||
message(
|
||||
text = Html.fromHtml(
|
||||
text = HtmlCompat.fromHtml(
|
||||
getString(
|
||||
code.name.monkey.retromusic.R.string.do_you_want_to_remove_from_the_blacklist,
|
||||
text
|
||||
)
|
||||
),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
)
|
||||
positiveButton(code.name.monkey.retromusic.R.string.remove_action) {
|
||||
|
|
|
@ -43,7 +43,6 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.dialogs.OptionsSheetDialogFragment;
|
||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle;
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen;
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.FoldersFragment;
|
||||
|
@ -587,9 +586,6 @@ public final class PreferenceUtil {
|
|||
return mPreferences.getInt(LAST_CHANGELOG_VERSION, -1);
|
||||
}
|
||||
|
||||
public final int getLastMusicChooser() {
|
||||
return mPreferences.getInt(LAST_MUSIC_CHOOSER, OptionsSheetDialogFragment.LIBRARY);
|
||||
}
|
||||
|
||||
public void setLastMusicChooser(int value) {
|
||||
mPreferences.edit().putInt(LAST_MUSIC_CHOOSER, value).apply();
|
||||
|
|
|
@ -16,7 +16,6 @@ package code.name.monkey.retromusic.util
|
|||
|
||||
import android.content.res.ColorStateList
|
||||
import android.content.res.Resources
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
|
@ -42,7 +41,8 @@ object ViewUtil {
|
|||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
val layerDrawable = progressSlider.progressDrawable as LayerDrawable
|
||||
val progressDrawable = layerDrawable.findDrawableByLayerId(android.R.id.progress)
|
||||
progressDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
progressDrawable.colorFilter =
|
||||
BlendModeColorFilterCompat.createBlendModeColorFilterCompat(newColor, SRC_IN)
|
||||
} else {
|
||||
progressSlider.progressTintList = ColorStateList.valueOf(newColor)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue