Shorten INTENT Constants names

This commit is contained in:
tzugen 2021-11-30 21:21:50 +01:00
parent f1e789ea9b
commit 2ac1ea3f89
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
22 changed files with 161 additions and 173 deletions

View File

@ -76,8 +76,8 @@ public class LyricsFragment extends Fragment {
{
Bundle arguments = getArguments();
if (arguments == null) return null;
String artist = arguments.getString(Constants.INTENT_EXTRA_NAME_ARTIST);
String title = arguments.getString(Constants.INTENT_EXTRA_NAME_TITLE);
String artist = arguments.getString(Constants.INTENT_ARTIST);
String title = arguments.getString(Constants.INTENT_TITLE);
MusicService musicService = MusicServiceFactory.getMusicService();
return musicService.getLyrics(artist, title);
}

View File

@ -102,9 +102,9 @@ public class PlaylistsFragment extends Fragment {
}
Bundle bundle = new Bundle();
bundle.putString(Constants.INTENT_EXTRA_NAME_ID, playlist.getId());
bundle.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
bundle.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
bundle.putString(Constants.INTENT_ID, playlist.getId());
bundle.putString(Constants.INTENT_PLAYLIST_ID, playlist.getId());
bundle.putString(Constants.INTENT_PLAYLIST_NAME, playlist.getName());
Navigation.findNavController(getView()).navigate(R.id.trackCollectionFragment, bundle);
}
});
@ -187,16 +187,16 @@ public class PlaylistsFragment extends Fragment {
downloadHandler.getValue().downloadPlaylist(this, playlist.getId(), playlist.getName(), false, false, false, false, true, false, false);
} else if (itemId == R.id.playlist_menu_play_now) {
bundle = new Bundle();
bundle.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
bundle.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
bundle.putString(Constants.INTENT_PLAYLIST_ID, playlist.getId());
bundle.putString(Constants.INTENT_PLAYLIST_NAME, playlist.getName());
bundle.putBoolean(Constants.INTENT_AUTOPLAY, true);
Navigation.findNavController(getView()).navigate(R.id.trackCollectionFragment, bundle);
} else if (itemId == R.id.playlist_menu_play_shuffled) {
bundle = new Bundle();
bundle.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
bundle.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, true);
bundle.putString(Constants.INTENT_PLAYLIST_ID, playlist.getId());
bundle.putString(Constants.INTENT_PLAYLIST_NAME, playlist.getName());
bundle.putBoolean(Constants.INTENT_AUTOPLAY, true);
bundle.putBoolean(Constants.INTENT_SHUFFLE, true);
Navigation.findNavController(getView()).navigate(R.id.trackCollectionFragment, bundle);
} else if (itemId == R.id.playlist_menu_delete) {
deletePlaylist(playlist);

View File

@ -75,7 +75,7 @@ public class PodcastFragment extends Fragment {
}
Bundle bundle = new Bundle();
bundle.putString(Constants.INTENT_EXTRA_NAME_PODCAST_CHANNEL_ID, pc.getId());
bundle.putString(Constants.INTENT_PODCAST_CHANNEL_ID, pc.getId());
Navigation.findNavController(view).navigate(R.id.trackCollectionFragment, bundle);
}
});

View File

@ -75,9 +75,9 @@ public class SelectGenreFragment extends Fragment {
if (genre != null)
{
Bundle bundle = new Bundle();
bundle.putString(Constants.INTENT_EXTRA_NAME_GENRE_NAME, genre.getName());
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, Settings.getMaxSongs());
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0);
bundle.putString(Constants.INTENT_GENRE_NAME, genre.getName());
bundle.putInt(Constants.INTENT_ALBUM_LIST_SIZE, Settings.getMaxSongs());
bundle.putInt(Constants.INTENT_ALBUM_LIST_OFFSET, 0);
Navigation.findNavController(view).navigate(R.id.trackCollectionFragment, bundle);
}
}

View File

@ -104,8 +104,8 @@ public class SharesFragment extends Fragment {
}
Bundle bundle = new Bundle();
bundle.putString(Constants.INTENT_EXTRA_NAME_SHARE_ID, share.getId());
bundle.putString(Constants.INTENT_EXTRA_NAME_SHARE_NAME, share.getName());
bundle.putString(Constants.INTENT_SHARE_ID, share.getId());
bundle.putString(Constants.INTENT_SHARE_NAME, share.getName());
Navigation.findNavController(view).navigate(R.id.trackCollectionFragment, bundle);
}
});

View File

@ -191,7 +191,7 @@ public class UltrasonicAppWidgetProvider extends AppWidgetProvider
{
Intent intent = new Intent(context, NavigationActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
if (playerActive)
intent.putExtra(Constants.INTENT_EXTRA_NAME_SHOW_PLAYER, true);
intent.putExtra(Constants.INTENT_SHOW_PLAYER, true);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");

View File

@ -319,7 +319,7 @@ class NavigationActivity : AppCompatActivity() {
super.onNewIntent(intent)
if (intent == null) return
if (intent.getBooleanExtra(Constants.INTENT_EXTRA_NAME_SHOW_PLAYER, false)) {
if (intent.getBooleanExtra(Constants.INTENT_SHOW_PLAYER, false)) {
findNavController(R.id.nav_host_fragment).navigate(R.id.playerFragment)
return
}
@ -335,8 +335,8 @@ class NavigationActivity : AppCompatActivity() {
suggestions.saveRecentQuery(query, null)
val bundle = Bundle()
bundle.putString(Constants.INTENT_EXTRA_NAME_QUERY, query)
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, autoPlay)
bundle.putString(Constants.INTENT_QUERY, query)
bundle.putBoolean(Constants.INTENT_AUTOPLAY, autoPlay)
findNavController(R.id.nav_host_fragment).navigate(R.id.searchFragment, bundle)
}
}

View File

@ -43,8 +43,8 @@ class AlbumListFragment : EntryListFragment<MusicDirectory.Album>() {
): LiveData<List<MusicDirectory.Album>> {
if (args == null) throw IllegalArgumentException("Required arguments are missing")
val refresh = args.getBoolean(Constants.INTENT_EXTRA_NAME_REFRESH) || refresh
val append = args.getBoolean(Constants.INTENT_EXTRA_NAME_APPEND)
val refresh = args.getBoolean(Constants.INTENT_REFRESH) || refresh
val append = args.getBoolean(Constants.INTENT_APPEND)
return listModel.getAlbumList(refresh or append, refreshListView!!, args)
}
@ -59,7 +59,7 @@ class AlbumListFragment : EntryListFragment<MusicDirectory.Album>() {
// Triggered only when new data needs to be appended to the list
// Add whatever code is needed to append new items to the bottom of the list
val appendArgs = getArgumentsClone()
appendArgs.putBoolean(Constants.INTENT_EXTRA_NAME_APPEND, true)
appendArgs.putBoolean(Constants.INTENT_APPEND, true)
getLiveData(appendArgs)
}
}
@ -80,10 +80,10 @@ class AlbumListFragment : EntryListFragment<MusicDirectory.Album>() {
override fun onItemClick(item: MusicDirectory.Album) {
val bundle = Bundle()
bundle.putString(Constants.INTENT_EXTRA_NAME_ID, item.id)
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_IS_ALBUM, item.isDirectory)
bundle.putString(Constants.INTENT_EXTRA_NAME_NAME, item.title)
bundle.putString(Constants.INTENT_EXTRA_NAME_PARENT_ID, item.parent)
bundle.putString(Constants.INTENT_ID, item.id)
bundle.putBoolean(Constants.INTENT_IS_ALBUM, item.isDirectory)
bundle.putString(Constants.INTENT_NAME, item.title)
bundle.putString(Constants.INTENT_PARENT_ID, item.parent)
findNavController().navigate(R.id.trackCollectionFragment, bundle)
}
}

View File

@ -33,7 +33,7 @@ class ArtistListFragment : EntryListFragment<ArtistOrIndex>() {
* The central function to pass a query to the model and return a LiveData object
*/
override fun getLiveData(args: Bundle?, refresh: Boolean): LiveData<List<ArtistOrIndex>> {
val refresh = args?.getBoolean(Constants.INTENT_EXTRA_NAME_REFRESH) ?: false || refresh
val refresh = args?.getBoolean(Constants.INTENT_REFRESH) ?: false || refresh
return listModel.getItems(refresh, refreshListView!!)
}
@ -63,22 +63,19 @@ class ArtistListFragment : EntryListFragment<ArtistOrIndex>() {
val bundle = Bundle()
// Common arguments
bundle.putString(Constants.INTENT_EXTRA_NAME_ID, item.id)
bundle.putString(Constants.INTENT_EXTRA_NAME_NAME, item.name)
bundle.putString(Constants.INTENT_EXTRA_NAME_PARENT_ID, item.id)
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, (item is Artist))
bundle.putString(Constants.INTENT_ID, item.id)
bundle.putString(Constants.INTENT_NAME, item.name)
bundle.putString(Constants.INTENT_PARENT_ID, item.id)
bundle.putBoolean(Constants.INTENT_ARTIST, (item is Artist))
// Check type
if (item is Index) {
navController.navigate(R.id.artistsListToTrackCollection, bundle)
} else {
bundle.putString(
Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE,
Constants.ALBUMS_OF_ARTIST
)
bundle.putString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TITLE, item.name)
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 1000)
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0)
bundle.putString(Constants.INTENT_ALBUM_LIST_TYPE, Constants.ALBUMS_OF_ARTIST)
bundle.putString(Constants.INTENT_ALBUM_LIST_TITLE, item.name)
bundle.putInt(Constants.INTENT_ALBUM_LIST_SIZE, 1000)
bundle.putInt(Constants.INTENT_ALBUM_LIST_OFFSET, 0)
navController.navigate(R.id.artistsListToAlbumsList, bundle)
}
}

View File

@ -39,10 +39,10 @@ abstract class EntryListFragment<T : GenericEntry> : MultiListFragment<T>() {
override fun onItemClick(item: T) {
val bundle = Bundle()
bundle.putString(Constants.INTENT_EXTRA_NAME_ID, item.id)
bundle.putString(Constants.INTENT_EXTRA_NAME_NAME, item.name)
bundle.putString(Constants.INTENT_EXTRA_NAME_PARENT_ID, item.id)
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, (item is Artist))
bundle.putString(Constants.INTENT_ID, item.id)
bundle.putString(Constants.INTENT_NAME, item.name)
bundle.putString(Constants.INTENT_PARENT_ID, item.id)
bundle.putBoolean(Constants.INTENT_ARTIST, (item is Artist))
findNavController().navigate(R.id.trackCollectionFragment, bundle)
}

View File

@ -201,21 +201,21 @@ class MainFragment : Fragment(), KoinComponent {
private fun showStarredSongs() {
val bundle = Bundle()
bundle.putInt(Constants.INTENT_EXTRA_NAME_STARRED, 1)
bundle.putInt(Constants.INTENT_STARRED, 1)
Navigation.findNavController(requireView()).navigate(R.id.mainToTrackCollection, bundle)
}
private fun showRandomSongs() {
val bundle = Bundle()
bundle.putInt(Constants.INTENT_EXTRA_NAME_RANDOM, 1)
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, Settings.maxSongs)
bundle.putInt(Constants.INTENT_RANDOM, 1)
bundle.putInt(Constants.INTENT_ALBUM_LIST_SIZE, Settings.maxSongs)
Navigation.findNavController(requireView()).navigate(R.id.mainToTrackCollection, bundle)
}
private fun showArtists() {
val bundle = Bundle()
bundle.putString(
Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TITLE,
Constants.INTENT_ALBUM_LIST_TITLE,
requireContext().resources.getString(R.string.main_artists_title)
)
Navigation.findNavController(requireView()).navigate(R.id.mainToArtistList, bundle)
@ -224,10 +224,10 @@ class MainFragment : Fragment(), KoinComponent {
private fun showAlbumList(type: String, titleIndex: Int) {
val bundle = Bundle()
val title = requireContext().resources.getString(titleIndex, "")
bundle.putString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE, type)
bundle.putString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TITLE, title)
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, Settings.maxAlbums)
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0)
bundle.putString(Constants.INTENT_ALBUM_LIST_TYPE, type)
bundle.putString(Constants.INTENT_ALBUM_LIST_TITLE, title)
bundle.putInt(Constants.INTENT_ALBUM_LIST_SIZE, Settings.maxAlbums)
bundle.putInt(Constants.INTENT_ALBUM_LIST_OFFSET, 0)
Navigation.findNavController(requireView()).navigate(R.id.mainToAlbumList, bundle)
}
@ -237,7 +237,7 @@ class MainFragment : Fragment(), KoinComponent {
private fun showVideos() {
val bundle = Bundle()
bundle.putInt(Constants.INTENT_EXTRA_NAME_VIDEOS, 1)
bundle.putInt(Constants.INTENT_VIDEOS, 1)
Navigation.findNavController(requireView()).navigate(R.id.mainToTrackCollection, bundle)
}

View File

@ -114,7 +114,7 @@ abstract class MultiListFragment<T : Identifiable> : Fragment() {
super.onViewCreated(view, savedInstanceState)
// Set the title if available
setTitle(arguments?.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TITLE))
setTitle(arguments?.getString(Constants.INTENT_ALBUM_LIST_TITLE))
// Setup refresh handler
refreshListView = view.findViewById(refreshListId)

View File

@ -123,15 +123,15 @@ class NowPlayingFragment : Fragment() {
val bundle = Bundle()
if (Settings.shouldUseId3Tags) {
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_IS_ALBUM, true)
bundle.putString(Constants.INTENT_EXTRA_NAME_ID, song.albumId)
bundle.putBoolean(Constants.INTENT_IS_ALBUM, true)
bundle.putString(Constants.INTENT_ID, song.albumId)
} else {
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_IS_ALBUM, false)
bundle.putString(Constants.INTENT_EXTRA_NAME_ID, song.parent)
bundle.putBoolean(Constants.INTENT_IS_ALBUM, false)
bundle.putString(Constants.INTENT_ID, song.parent)
}
bundle.putString(Constants.INTENT_EXTRA_NAME_NAME, song.album)
bundle.putString(Constants.INTENT_EXTRA_NAME_NAME, song.album)
bundle.putString(Constants.INTENT_NAME, song.album)
bundle.putString(Constants.INTENT_NAME, song.album)
Navigation.findNavController(requireActivity(), R.id.nav_host_fragment)
.navigate(R.id.trackCollectionFragment, bundle)

View File

@ -339,7 +339,7 @@ class PlayerFragment :
registerForContextMenu(playlistView)
if (arguments != null && requireArguments().getBoolean(
Constants.INTENT_EXTRA_NAME_SHUFFLE,
Constants.INTENT_SHUFFLE,
false
)
) {
@ -579,10 +579,10 @@ class PlayerFragment :
if (Settings.shouldUseId3Tags) {
bundle = Bundle()
bundle.putString(Constants.INTENT_EXTRA_NAME_ID, entry.artistId)
bundle.putString(Constants.INTENT_EXTRA_NAME_NAME, entry.artist)
bundle.putString(Constants.INTENT_EXTRA_NAME_PARENT_ID, entry.artistId)
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true)
bundle.putString(Constants.INTENT_ID, entry.artistId)
bundle.putString(Constants.INTENT_NAME, entry.artist)
bundle.putString(Constants.INTENT_PARENT_ID, entry.artistId)
bundle.putBoolean(Constants.INTENT_ARTIST, true)
Navigation.findNavController(requireView())
.navigate(R.id.playerToSelectAlbum, bundle)
}
@ -593,10 +593,10 @@ class PlayerFragment :
val albumId = if (Settings.shouldUseId3Tags) entry.albumId else entry.parent
bundle = Bundle()
bundle.putString(Constants.INTENT_EXTRA_NAME_ID, albumId)
bundle.putString(Constants.INTENT_EXTRA_NAME_NAME, entry.album)
bundle.putString(Constants.INTENT_EXTRA_NAME_PARENT_ID, entry.parent)
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_IS_ALBUM, true)
bundle.putString(Constants.INTENT_ID, albumId)
bundle.putString(Constants.INTENT_NAME, entry.album)
bundle.putString(Constants.INTENT_PARENT_ID, entry.parent)
bundle.putBoolean(Constants.INTENT_IS_ALBUM, true)
Navigation.findNavController(requireView())
.navigate(R.id.playerToSelectAlbum, bundle)
return true
@ -605,8 +605,8 @@ class PlayerFragment :
if (entry == null) return false
bundle = Bundle()
bundle.putString(Constants.INTENT_EXTRA_NAME_ARTIST, entry.artist)
bundle.putString(Constants.INTENT_EXTRA_NAME_TITLE, entry.title)
bundle.putString(Constants.INTENT_ARTIST, entry.artist)
bundle.putString(Constants.INTENT_TITLE, entry.title)
Navigation.findNavController(requireView()).navigate(R.id.playerToLyrics, bundle)
return true
}

View File

@ -127,8 +127,8 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
// Fragment was started with a query (e.g. from voice search), try to execute search right away
val arguments = arguments
if (arguments != null) {
val query = arguments.getString(Constants.INTENT_EXTRA_NAME_QUERY)
val autoPlay = arguments.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false)
val query = arguments.getString(Constants.INTENT_QUERY)
val autoPlay = arguments.getBoolean(Constants.INTENT_AUTOPLAY, false)
if (query != null) {
return search(query, autoPlay)
}
@ -149,8 +149,8 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
val arguments = arguments
val autoPlay = arguments != null &&
arguments.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false)
val query = arguments?.getString(Constants.INTENT_EXTRA_NAME_QUERY)
arguments.getBoolean(Constants.INTENT_AUTOPLAY, false)
val query = arguments?.getString(Constants.INTENT_QUERY)
// If started with a query, enter it to the searchView
if (query != null) {
@ -268,32 +268,29 @@ class SearchFragment : MultiListFragment<Identifiable>(), KoinComponent {
val bundle = Bundle()
// Common arguments
bundle.putString(Constants.INTENT_EXTRA_NAME_ID, item.id)
bundle.putString(Constants.INTENT_EXTRA_NAME_NAME, item.name)
bundle.putString(Constants.INTENT_EXTRA_NAME_PARENT_ID, item.id)
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, (item is Artist))
bundle.putString(Constants.INTENT_ID, item.id)
bundle.putString(Constants.INTENT_NAME, item.name)
bundle.putString(Constants.INTENT_PARENT_ID, item.id)
bundle.putBoolean(Constants.INTENT_ARTIST, (item is Artist))
// Check type
if (item is Index) {
findNavController().navigate(R.id.searchToTrackCollection, bundle)
} else {
bundle.putString(
Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE,
Constants.ALBUMS_OF_ARTIST
)
bundle.putString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TITLE, item.name)
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 1000)
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0)
bundle.putString(Constants.INTENT_ALBUM_LIST_TYPE, Constants.ALBUMS_OF_ARTIST)
bundle.putString(Constants.INTENT_ALBUM_LIST_TITLE, item.name)
bundle.putInt(Constants.INTENT_ALBUM_LIST_SIZE, 1000)
bundle.putInt(Constants.INTENT_ALBUM_LIST_OFFSET, 0)
findNavController().navigate(R.id.searchToAlbumsList, bundle)
}
}
private fun onAlbumSelected(album: MusicDirectory.Album, autoplay: Boolean) {
val bundle = Bundle()
bundle.putString(Constants.INTENT_EXTRA_NAME_ID, album.id)
bundle.putString(Constants.INTENT_EXTRA_NAME_NAME, album.title)
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_IS_ALBUM, album.isDirectory)
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, autoplay)
bundle.putString(Constants.INTENT_ID, album.id)
bundle.putString(Constants.INTENT_NAME, album.title)
bundle.putBoolean(Constants.INTENT_IS_ALBUM, album.isDirectory)
bundle.putBoolean(Constants.INTENT_AUTOPLAY, autoplay)
Navigation.findNavController(requireView()).navigate(R.id.searchToTrackCollection, bundle)
}

View File

@ -284,8 +284,8 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
}
}
val isArtist = arguments?.getBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, false) ?: false
val id = arguments?.getString(Constants.INTENT_EXTRA_NAME_ID)
val isArtist = arguments?.getBoolean(Constants.INTENT_ARTIST, false) ?: false
val id = arguments?.getString(Constants.INTENT_ID)
if (hasSubFolders && id != null) {
downloadHandler.downloadRecursively(
@ -428,7 +428,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
// Hide more button when results are less than album list size
if (musicDirectory.size < requireArguments().getInt(
Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0
Constants.INTENT_ALBUM_LIST_SIZE, 0
)
) {
moreButton!!.visibility = View.GONE
@ -437,15 +437,15 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
}
moreButton!!.setOnClickListener {
val theGenre = requireArguments().getString(Constants.INTENT_EXTRA_NAME_GENRE_NAME)
val size = requireArguments().getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0)
val theGenre = requireArguments().getString(Constants.INTENT_GENRE_NAME)
val size = requireArguments().getInt(Constants.INTENT_ALBUM_LIST_SIZE, 0)
val theOffset = requireArguments().getInt(
Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0
Constants.INTENT_ALBUM_LIST_OFFSET, 0
) + size
val bundle = Bundle()
bundle.putString(Constants.INTENT_EXTRA_NAME_GENRE_NAME, theGenre)
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, size)
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, theOffset)
bundle.putString(Constants.INTENT_GENRE_NAME, theGenre)
bundle.putInt(Constants.INTENT_ALBUM_LIST_SIZE, size)
bundle.putInt(Constants.INTENT_ALBUM_LIST_OFFSET, theOffset)
Navigation.findNavController(requireView())
.navigate(R.id.trackCollectionFragment, bundle)
@ -472,7 +472,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
}
}
val listSize = arguments?.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0) ?: 0
val listSize = arguments?.getInt(Constants.INTENT_ALBUM_LIST_SIZE, 0) ?: 0
// Hide select button for video lists and singular selection lists
selectButton!!.isVisible = !allVideos && viewAdapter.hasMultipleSelection() && songCount > 0
@ -482,15 +482,15 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
moreButton!!.visibility = View.GONE
} else {
moreButton!!.visibility = View.VISIBLE
if (arguments?.getInt(Constants.INTENT_EXTRA_NAME_RANDOM, 0) ?: 0 > 0) {
if (arguments?.getInt(Constants.INTENT_RANDOM, 0) ?: 0 > 0) {
moreButton!!.setOnClickListener {
val offset = requireArguments().getInt(
Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0
Constants.INTENT_ALBUM_LIST_OFFSET, 0
) + listSize
val bundle = Bundle()
bundle.putInt(Constants.INTENT_EXTRA_NAME_RANDOM, 1)
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, listSize)
bundle.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, offset)
bundle.putInt(Constants.INTENT_RANDOM, 1)
bundle.putInt(Constants.INTENT_ALBUM_LIST_SIZE, listSize)
bundle.putInt(Constants.INTENT_ALBUM_LIST_OFFSET, offset)
Navigation.findNavController(requireView()).navigate(
R.id.trackCollectionFragment, bundle
)
@ -505,7 +505,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
enableButtons()
val isAlbumList = arguments?.containsKey(
Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE
Constants.INTENT_ALBUM_LIST_TYPE
) ?: false
playAllButtonVisible = !(isAlbumList || entryList.isEmpty()) && !allVideos
@ -515,7 +515,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
shareButton?.isVisible = shareButtonVisible
if (songCount > 0 && listModel.showHeader) {
val intentAlbumName = arguments?.getString(Constants.INTENT_EXTRA_NAME_NAME, "")
val intentAlbumName = arguments?.getString(Constants.INTENT_NAME, "")
val albumHeader = AlbumHeader(it, intentAlbumName)
val mixedList: MutableList<Identifiable> = mutableListOf(albumHeader)
mixedList.addAll(entryList)
@ -524,11 +524,11 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
viewAdapter.submitList(entryList)
}
val playAll = arguments?.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false) ?: false
val playAll = arguments?.getBoolean(Constants.INTENT_AUTOPLAY, false) ?: false
if (playAll && songCount > 0) {
playAll(
arguments?.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, false) ?: false,
arguments?.getBoolean(Constants.INTENT_SHUFFLE, false) ?: false,
false
)
}
@ -560,28 +560,22 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
refresh: Boolean
): LiveData<List<MusicDirectory.Child>> {
if (args == null) return listModel.currentList
val id = args.getString(Constants.INTENT_EXTRA_NAME_ID)
val isAlbum = args.getBoolean(Constants.INTENT_EXTRA_NAME_IS_ALBUM, false)
val name = args.getString(Constants.INTENT_EXTRA_NAME_NAME)
val playlistId = args.getString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID)
val podcastChannelId = args.getString(
Constants.INTENT_EXTRA_NAME_PODCAST_CHANNEL_ID
)
val playlistName = args.getString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME)
val shareId = args.getString(Constants.INTENT_EXTRA_NAME_SHARE_ID)
val shareName = args.getString(Constants.INTENT_EXTRA_NAME_SHARE_NAME)
val genreName = args.getString(Constants.INTENT_EXTRA_NAME_GENRE_NAME)
val id = args.getString(Constants.INTENT_ID)
val isAlbum = args.getBoolean(Constants.INTENT_IS_ALBUM, false)
val name = args.getString(Constants.INTENT_NAME)
val playlistId = args.getString(Constants.INTENT_PLAYLIST_ID)
val podcastChannelId = args.getString(Constants.INTENT_PODCAST_CHANNEL_ID)
val playlistName = args.getString(Constants.INTENT_PLAYLIST_NAME)
val shareId = args.getString(Constants.INTENT_SHARE_ID)
val shareName = args.getString(Constants.INTENT_SHARE_NAME)
val genreName = args.getString(Constants.INTENT_GENRE_NAME)
val getStarredTracks = args.getInt(Constants.INTENT_EXTRA_NAME_STARRED, 0)
val getVideos = args.getInt(Constants.INTENT_EXTRA_NAME_VIDEOS, 0)
val getRandomTracks = args.getInt(Constants.INTENT_EXTRA_NAME_RANDOM, 0)
val albumListSize = args.getInt(
Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0
)
val albumListOffset = args.getInt(
Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0
)
val refresh2 = args.getBoolean(Constants.INTENT_EXTRA_NAME_REFRESH, true) || refresh
val getStarredTracks = args.getInt(Constants.INTENT_STARRED, 0)
val getVideos = args.getInt(Constants.INTENT_VIDEOS, 0)
val getRandomTracks = args.getInt(Constants.INTENT_RANDOM, 0)
val albumListSize = args.getInt(Constants.INTENT_ALBUM_LIST_SIZE, 0)
val albumListOffset = args.getInt(Constants.INTENT_ALBUM_LIST_OFFSET, 0)
val refresh2 = args.getBoolean(Constants.INTENT_REFRESH, true) || refresh
listModel.viewModelScope.launch(handler) {
refreshListView?.isRefreshing = true
@ -698,10 +692,10 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
when {
item.isDirectory -> {
val bundle = Bundle()
bundle.putString(Constants.INTENT_EXTRA_NAME_ID, item.id)
bundle.putBoolean(Constants.INTENT_EXTRA_NAME_IS_ALBUM, item.isDirectory)
bundle.putString(Constants.INTENT_EXTRA_NAME_NAME, item.title)
bundle.putString(Constants.INTENT_EXTRA_NAME_PARENT_ID, item.parent)
bundle.putString(Constants.INTENT_ID, item.id)
bundle.putBoolean(Constants.INTENT_IS_ALBUM, item.isDirectory)
bundle.putString(Constants.INTENT_NAME, item.title)
bundle.putString(Constants.INTENT_PARENT_ID, item.parent)
Navigation.findNavController(requireView()).navigate(
R.id.trackCollectionFragment,
bundle

View File

@ -24,7 +24,7 @@ class AlbumListModel(application: Application) : GenericListModel(application) {
): LiveData<List<MusicDirectory.Album>> {
// Don't reload the data if navigating back to the view that was active before.
// This way, we keep the scroll position
val albumListType = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE)!!
val albumListType = args.getString(Constants.INTENT_ALBUM_LIST_TYPE)!!
if (refresh || list.value?.isEmpty() != false || albumListType != lastType) {
lastType = albumListType
@ -51,10 +51,10 @@ class AlbumListModel(application: Application) : GenericListModel(application) {
) {
super.load(isOffline, useId3Tags, musicService, refresh, args)
val albumListType = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE)!!
val size = args.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0)
var offset = args.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0)
val append = args.getBoolean(Constants.INTENT_EXTRA_NAME_APPEND, false)
val albumListType = args.getString(Constants.INTENT_ALBUM_LIST_TYPE)!!
val size = args.getInt(Constants.INTENT_ALBUM_LIST_SIZE, 0)
var offset = args.getInt(Constants.INTENT_ALBUM_LIST_OFFSET, 0)
val append = args.getBoolean(Constants.INTENT_APPEND, false)
val musicDirectory: List<MusicDirectory.Album>
val musicFolderId = if (showSelectFolderHeader(args)) {
@ -71,8 +71,8 @@ class AlbumListModel(application: Application) : GenericListModel(application) {
return getAlbumsOfArtist(
musicService,
refresh,
args.getString(Constants.INTENT_EXTRA_NAME_ID, ""),
args.getString(Constants.INTENT_EXTRA_NAME_NAME, "")
args.getString(Constants.INTENT_ID, ""),
args.getString(Constants.INTENT_NAME, "")
)
}
@ -106,7 +106,7 @@ class AlbumListModel(application: Application) : GenericListModel(application) {
override fun showSelectFolderHeader(args: Bundle?): Boolean {
if (args == null) return false
val albumListType = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE)!!
val albumListType = args.getString(Constants.INTENT_ALBUM_LIST_TYPE)!!
val isAlphabetical = (albumListType == AlbumListType.SORTED_BY_NAME.toString()) ||
(albumListType == AlbumListType.SORTED_BY_ARTIST.toString())

View File

@ -416,7 +416,7 @@ class CachedMusicService(private val musicService: MusicService) : MusicService,
override fun getVideos(refresh: Boolean): MusicDirectory? {
checkSettingsChanged()
var cache =
if (refresh) null else cachedMusicDirectories[Constants.INTENT_EXTRA_NAME_VIDEOS]
if (refresh) null else cachedMusicDirectories[Constants.INTENT_VIDEOS]
var dir = cache?.get()
if (dir == null) {
dir = musicService.getVideos(refresh)
@ -424,7 +424,7 @@ class CachedMusicService(private val musicService: MusicService) : MusicService,
Settings.directoryCacheTime.toLong(), TimeUnit.SECONDS
)
cache.set(dir)
cachedMusicDirectories.put(Constants.INTENT_EXTRA_NAME_VIDEOS, cache)
cachedMusicDirectories.put(Constants.INTENT_VIDEOS, cache)
}
return dir
}

View File

@ -702,7 +702,7 @@ class MediaPlayerService : Service() {
val intent = Intent(this, NavigationActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
val flags = PendingIntent.FLAG_UPDATE_CURRENT
intent.putExtra(Constants.INTENT_EXTRA_NAME_SHOW_PLAYER, true)
intent.putExtra(Constants.INTENT_SHOW_PLAYER, true)
return PendingIntent.getActivity(this, 0, intent, flags)
}

View File

@ -49,7 +49,7 @@ class DownloadHandler(
false
)
val playlistName: String? = fragment.arguments?.getString(
Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME
Constants.INTENT_PLAYLIST_NAME
)
if (playlistName != null) {
mediaPlayerController.suggestedPlaylistName = playlistName

View File

@ -80,7 +80,7 @@ class ShareHandler(val context: Context) {
if (!shareDetails.ShareOnServer && shareDetails.Entries.size == 1) return null
if (shareDetails.Entries.isEmpty()) {
fragment.arguments?.getString(Constants.INTENT_EXTRA_NAME_ID).ifNotNull {
fragment.arguments?.getString(Constants.INTENT_ID).ifNotNull {
ids.add(it)
}
} else {

View File

@ -16,31 +16,31 @@ object Constants {
const val REST_CLIENT_ID = "Ultrasonic"
// Names for intent extras.
const val INTENT_EXTRA_NAME_ID = "subsonic.id"
const val INTENT_EXTRA_NAME_NAME = "subsonic.name"
const val INTENT_EXTRA_NAME_ARTIST = "subsonic.artist"
const val INTENT_EXTRA_NAME_TITLE = "subsonic.title"
const val INTENT_EXTRA_NAME_AUTOPLAY = "subsonic.playall"
const val INTENT_EXTRA_NAME_QUERY = "subsonic.query"
const val INTENT_EXTRA_NAME_PLAYLIST_ID = "subsonic.playlist.id"
const val INTENT_EXTRA_NAME_PODCAST_CHANNEL_ID = "subsonic.podcastChannel.id"
const val INTENT_EXTRA_NAME_PARENT_ID = "subsonic.parent.id"
const val INTENT_EXTRA_NAME_PLAYLIST_NAME = "subsonic.playlist.name"
const val INTENT_EXTRA_NAME_SHARE_ID = "subsonic.share.id"
const val INTENT_EXTRA_NAME_SHARE_NAME = "subsonic.share.name"
const val INTENT_EXTRA_NAME_ALBUM_LIST_TYPE = "subsonic.albumlisttype"
const val INTENT_EXTRA_NAME_ALBUM_LIST_TITLE = "subsonic.albumlisttitle"
const val INTENT_EXTRA_NAME_ALBUM_LIST_SIZE = "subsonic.albumlistsize"
const val INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET = "subsonic.albumlistoffset"
const val INTENT_EXTRA_NAME_SHUFFLE = "subsonic.shuffle"
const val INTENT_EXTRA_NAME_REFRESH = "subsonic.refresh"
const val INTENT_EXTRA_NAME_STARRED = "subsonic.starred"
const val INTENT_EXTRA_NAME_RANDOM = "subsonic.random"
const val INTENT_EXTRA_NAME_GENRE_NAME = "subsonic.genre"
const val INTENT_EXTRA_NAME_IS_ALBUM = "subsonic.isalbum"
const val INTENT_EXTRA_NAME_VIDEOS = "subsonic.videos"
const val INTENT_EXTRA_NAME_SHOW_PLAYER = "subsonic.showplayer"
const val INTENT_EXTRA_NAME_APPEND = "subsonic.append"
const val INTENT_ID = "subsonic.id"
const val INTENT_NAME = "subsonic.name"
const val INTENT_ARTIST = "subsonic.artist"
const val INTENT_TITLE = "subsonic.title"
const val INTENT_AUTOPLAY = "subsonic.playall"
const val INTENT_QUERY = "subsonic.query"
const val INTENT_PLAYLIST_ID = "subsonic.playlist.id"
const val INTENT_PODCAST_CHANNEL_ID = "subsonic.podcastChannel.id"
const val INTENT_PARENT_ID = "subsonic.parent.id"
const val INTENT_PLAYLIST_NAME = "subsonic.playlist.name"
const val INTENT_SHARE_ID = "subsonic.share.id"
const val INTENT_SHARE_NAME = "subsonic.share.name"
const val INTENT_ALBUM_LIST_TYPE = "subsonic.albumlisttype"
const val INTENT_ALBUM_LIST_TITLE = "subsonic.albumlisttitle"
const val INTENT_ALBUM_LIST_SIZE = "subsonic.albumlistsize"
const val INTENT_ALBUM_LIST_OFFSET = "subsonic.albumlistoffset"
const val INTENT_SHUFFLE = "subsonic.shuffle"
const val INTENT_REFRESH = "subsonic.refresh"
const val INTENT_STARRED = "subsonic.starred"
const val INTENT_RANDOM = "subsonic.random"
const val INTENT_GENRE_NAME = "subsonic.genre"
const val INTENT_IS_ALBUM = "subsonic.isalbum"
const val INTENT_VIDEOS = "subsonic.videos"
const val INTENT_SHOW_PLAYER = "subsonic.showplayer"
const val INTENT_APPEND = "subsonic.append"
// Names for Intent Actions
const val CMD_PROCESS_KEYCODE = "org.moire.ultrasonic.CMD_PROCESS_KEYCODE"