Dialog content has changed follow font

main
Hemanth S 2020-08-14 14:04:03 +05:30
parent 038e872e7a
commit c6c89e9b9e
36 changed files with 161 additions and 87 deletions

View File

@ -109,17 +109,17 @@ dependencies {
implementation "androidx.gridlayout:gridlayout:1.0.0"
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.viewpager2:viewpager2:1.1.0-alpha01"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.fragment:fragment-ktx:1.2.5'
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta8'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-rc1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.3.0-alpha01'
implementation 'com.google.android.material:material:1.3.0-alpha02'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
def retrofit_version = '2.9.0'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View File

@ -43,19 +43,19 @@ class AppShortcutLauncherActivity : Activity() {
when (shortcutType) {
SHORTCUT_TYPE_SHUFFLE_ALL -> {
startServiceWithPlaylist(
SHUFFLE_MODE_SHUFFLE, ShuffleAllPlaylist(applicationContext)
SHUFFLE_MODE_SHUFFLE, ShuffleAllPlaylist()
)
DynamicShortcutManager.reportShortcutUsed(this, ShuffleAllShortcutType.id)
}
SHORTCUT_TYPE_TOP_TRACKS -> {
startServiceWithPlaylist(
SHUFFLE_MODE_NONE, TopTracksPlaylist(applicationContext)
SHUFFLE_MODE_NONE, TopTracksPlaylist()
)
DynamicShortcutManager.reportShortcutUsed(this, TopTracksShortcutType.id)
}
SHORTCUT_TYPE_LAST_ADDED -> {
startServiceWithPlaylist(
SHUFFLE_MODE_NONE, LastAddedPlaylist(applicationContext)
SHUFFLE_MODE_NONE, LastAddedPlaylist()
)
DynamicShortcutManager.reportShortcutUsed(this, LastAddedShortcutType.id)
}

View File

@ -17,7 +17,6 @@ package code.name.monkey.retromusic.dialogs
import android.app.Dialog
import android.os.Bundle
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import code.name.monkey.retromusic.EXTRA_SONG
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.colorButtons
@ -26,9 +25,6 @@ import code.name.monkey.retromusic.extensions.materialDialog
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.repository.PlaylistRepository
import code.name.monkey.retromusic.util.PlaylistsUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.koin.android.ext.android.inject
@ -37,35 +33,28 @@ class AddToPlaylistDialog : DialogFragment() {
override fun onCreateDialog(
savedInstanceState: Bundle?
): Dialog {
val materialDialog = materialDialog(R.string.add_playlist_title)
lifecycleScope.launch {
val playlists = playlistRepository.playlists()
val playlistNames = mutableListOf<String>()
playlistNames.add(requireContext().resources.getString(R.string.action_new_playlist))
for (p in playlists) {
playlistNames.add(p.name)
}
withContext(Dispatchers.Main) {
materialDialog.setItems(playlistNames.toTypedArray()) { _, which ->
val songs = extraNotNull<ArrayList<Song>>(EXTRA_SONG).value
if (which == 0) {
CreatePlaylistDialog.create(songs)
.show(requireActivity().supportFragmentManager, "ADD_TO_PLAYLIST")
} else {
PlaylistsUtil.addToPlaylist(
requireContext(),
songs,
playlists[which - 1].id,
true
)
}
dismiss()
}
}
val playlists = playlistRepository.playlists()
val playlistNames = mutableListOf<String>()
playlistNames.add(requireContext().resources.getString(R.string.action_new_playlist))
for (p in playlists) {
playlistNames.add(p.name)
}
return materialDialog(R.string.add_playlist_title)
.setItems(playlistNames.toTypedArray()) { _, which ->
val songs = extraNotNull<ArrayList<Song>>(EXTRA_SONG).value
if (which == 0) {
CreatePlaylistDialog.create(songs)
.show(requireActivity().supportFragmentManager, "ADD_TO_PLAYLIST")
} else {
PlaylistsUtil.addToPlaylist(
requireContext(),
songs,
playlists[which - 1].id,
true
)
}
dismiss()
}
.create().colorButtons()
}

View File

@ -127,6 +127,7 @@ fun TextInputLayout.accentColor() {
defaultHintTextColor = colorState
isHintAnimationEnabled = true
}
fun TextInputEditText.accentColor(){
fun TextInputEditText.accentColor() {
}

View File

@ -61,7 +61,7 @@ class LibraryViewModel(
private val loadArtists: Deferred<List<Artist>>
get() = viewModelScope.async(IO) {
realRepository.allArtists()
realRepository.albumArtists()
}
private val loadPlaylists: Deferred<List<Playlist>>

View File

@ -75,14 +75,14 @@ class HomeFragment :
lastAdded.setOnClickListener {
findActivityNavController(R.id.fragment_container).navigate(
R.id.playlistDetailsFragment,
bundleOf(EXTRA_PLAYLIST to LastAddedPlaylist(requireActivity()))
bundleOf(EXTRA_PLAYLIST to LastAddedPlaylist())
)
}
topPlayed.setOnClickListener {
findActivityNavController(R.id.fragment_container).navigate(
R.id.playlistDetailsFragment,
bundleOf(EXTRA_PLAYLIST to TopTracksPlaylist(requireActivity()))
bundleOf(EXTRA_PLAYLIST to TopTracksPlaylist())
)
}
@ -98,7 +98,7 @@ class HomeFragment :
history.setOnClickListener {
requireActivity().findNavController(R.id.fragment_container).navigate(
R.id.playlistDetailsFragment,
bundleOf(EXTRA_PLAYLIST to HistoryPlaylist(requireActivity()))
bundleOf(EXTRA_PLAYLIST to HistoryPlaylist())
)
}

View File

@ -41,6 +41,9 @@ class Album {
val songCount: Int
get() = songs!!.size
val albumArtist: String?
get() = safeGetFirstSong().albumArtist
constructor(songs: ArrayList<Song>) {
this.songs = songs
}

View File

@ -25,10 +25,10 @@ class Artist {
val name: String
get() {
val name = safeGetFirstAlbum().artistName
val name = safeGetFirstAlbum().safeGetFirstSong().albumArtist
return if (MusicUtil.isArtistNameUnknown(name)) {
UNKNOWN_ARTIST_DISPLAY_NAME
} else name!!
} else safeGetFirstAlbum().safeGetFirstSong().artistName
}
val songCount: Int

View File

@ -1,14 +1,18 @@
package code.name.monkey.retromusic.model.smartplaylist
import android.content.Context
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.model.Song
import kotlinx.android.parcel.Parcelize
import org.koin.core.KoinComponent
class HistoryPlaylist(
context: Context
) : AbsSmartPlaylist(context.getString(R.string.history), R.drawable.ic_history), KoinComponent {
@Parcelize
class HistoryPlaylist :
AbsSmartPlaylist(
App.getContext().getString(R.string.history),
R.drawable.ic_history
),
KoinComponent {
override fun songs(): List<Song> {
return topPlayedRepository.recentlyPlayedTracks()
}

View File

@ -1,11 +1,13 @@
package code.name.monkey.retromusic.model.smartplaylist
import android.content.Context
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.model.Song
import kotlinx.android.parcel.Parcelize
class LastAddedPlaylist(context: Context) :
AbsSmartPlaylist(context.getString(R.string.last_added), R.drawable.ic_library_add) {
@Parcelize
class LastAddedPlaylist :
AbsSmartPlaylist(App.getContext().getString(R.string.last_added), R.drawable.ic_library_add) {
override fun songs(): List<Song> {
return lastAddedRepository.recentSongs()
}

View File

@ -1,12 +1,15 @@
package code.name.monkey.retromusic.model.smartplaylist
import android.content.Context
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.model.Song
import kotlinx.android.parcel.Parcelize
class NotPlayedPlaylist(
context: Context
) : AbsSmartPlaylist(context.getString(R.string.not_recently_played), R.drawable.ic_watch_later) {
@Parcelize
class NotPlayedPlaylist : AbsSmartPlaylist(
App.getContext().getString(R.string.not_recently_played),
R.drawable.ic_watch_later
) {
override fun songs(): List<Song> {
return topPlayedRepository.notRecentlyPlayedTracks()
}

View File

@ -1,12 +1,15 @@
package code.name.monkey.retromusic.model.smartplaylist
import android.content.Context
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.model.Song
import kotlinx.android.parcel.Parcelize
class ShuffleAllPlaylist(
context: Context
) : AbsSmartPlaylist(context.getString(R.string.action_shuffle_all), R.drawable.ic_shuffle) {
@Parcelize
class ShuffleAllPlaylist : AbsSmartPlaylist(
App.getContext().getString(R.string.action_shuffle_all),
R.drawable.ic_shuffle
) {
override fun songs(): List<Song> {
return songRepository.songs()
}

View File

@ -1,13 +1,13 @@
package code.name.monkey.retromusic.model.smartplaylist
import android.content.Context
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.model.Song
import kotlinx.android.parcel.Parcelize
class TopTracksPlaylist(
context: Context
) : AbsSmartPlaylist(
context.getString(R.string.my_top_tracks),
@Parcelize
class TopTracksPlaylist : AbsSmartPlaylist(
App.getContext().getString(R.string.my_top_tracks),
R.drawable.ic_trending_up
) {
override fun songs(): List<Song> {

View File

@ -63,7 +63,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
chooserDialog?.setCallback(this)
refreshBlacklistData()
return materialDialog(R.string.blacklist)
.setPositiveButton(android.R.string.ok) { _, _ ->
.setPositiveButton(R.string.done) { _, _ ->
dismiss()
}
.setNeutralButton(R.string.clear_action) { _, _ ->

View File

@ -22,6 +22,8 @@ import code.name.monkey.retromusic.util.PreferenceUtil
interface ArtistRepository {
fun artists(): List<Artist>
fun albumArtists(): List<Artist>
fun artists(query: String): List<Artist>
fun artist(artistId: Int): Artist
@ -59,6 +61,31 @@ class RealArtistRepository(
return splitIntoArtists(albumRepository.splitIntoAlbums(songs))
}
override fun albumArtists(): List<Artist> {
val songs = songRepository.songs(
songRepository.makeSongCursor(
null,
null,
getSongLoaderSortOrder()
)
)
return splitIntoAlbumArtists(albumRepository.splitIntoAlbums(songs))
}
private fun splitIntoAlbumArtists(albums: List<Album>): List<Artist> {
// First group the songs in albums by filtering each artist name
val amap = hashMapOf<String, Artist>()
albums.forEach {
val key = it.albumArtist
if (key != null) {
val artist: Artist = if (amap[key] != null) amap[key]!! else Artist()
artist.albums?.add(it)
amap[key] = artist
}
}
return ArrayList(amap.values)
}
override fun artist(artistId: Int): Artist {
val songs = songRepository.songs(
songRepository.makeSongCursor(

View File

@ -36,6 +36,8 @@ interface Repository {
suspend fun allArtists(): List<Artist>
suspend fun albumArtists(): List<Artist>
suspend fun allPlaylists(): List<Playlist>
suspend fun allGenres(): List<Genre>
@ -112,6 +114,8 @@ class RealRepository(
override suspend fun allArtists(): List<Artist> = artistRepository.artists()
override suspend fun albumArtists(): List<Artist> = artistRepository.albumArtists()
override suspend fun artistById(artistId: Int): Artist = artistRepository.artist(artistId)
override suspend fun recentArtists(): List<Artist> = lastAddedRepository.recentArtists()
@ -212,7 +216,7 @@ class RealRepository(
override suspend fun suggestionsHome(): Home {
val songs =
NotPlayedPlaylist(context).songs().shuffled().takeIf {
NotPlayedPlaylist().songs().shuffled().takeIf {
it.size > 9
} ?: emptyList()
println(songs.size)

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?attr/colorSurface" />
<corners android:radius="12dp" />
</shape>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -882,4 +882,5 @@
</plurals>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="done">Done</string>
</resources>

View File

@ -191,4 +191,50 @@
<item name="android:textColor">@color/md_red_400</item>
</style>
<style name="MaterialPopupMenuStyle" parent="Widget.MaterialComponents.PopupMenu">
<item name="android:popupBackground">@drawable/popup_background</item>
</style>
<style name="MaterialAlertDialogTheme" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="android:dialogCornerRadius" tools:targetApi="p">12dp</item>
<item name="materialAlertDialogBodyTextStyle">
@style/AppTextAppearance.MaterialAlertDialog.Body
</item>
<item name="materialAlertDialogTitleTextStyle">
@style/AppTextAppearance.MaterialAlertDialog.Title
</item>
<item name="buttonBarPositiveButtonStyle">
@style/AppTextAppearance.MaterialAlertDialog.Button
</item>
<item name="buttonBarNegativeButtonStyle">
@style/AppTextAppearance.MaterialAlertDialog.Button
</item>
<item name="buttonBarNeutralButtonStyle">
@style/AppTextAppearance.MaterialAlertDialog.Button
</item>
</style>
<style name="AppTextAppearance.MaterialAlertDialog.Button" parent="Widget.MaterialComponents.Button.TextButton">
<item name="android:textSize">16sp</item>
</style>
<style name="AppTextAppearance.MaterialAlertDialog.Body" parent="MaterialAlertDialog.MaterialComponents.Body.Text">
<item name="android:textSize">14sp</item>
</style>
<style name="AppTextAppearance.MaterialAlertDialog.Title" parent="MaterialAlertDialog.MaterialComponents.Title.Text">
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="MaterialButtonTheme" parent="Widget.MaterialComponents.Button">
<item name="cornerRadius">6dp</item>
<item name="iconGravity">textStart</item>
<item name="iconTint">?attr/colorControlNormal</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:textAppearance">@style/TextViewNormal</item>
<item name="android:textAllCaps">false</item>
<item name="android:paddingTop">@dimen/button_padding_vertical</item>
<item name="android:paddingBottom">@dimen/button_padding_vertical</item>
</style>
</resources>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>
<style name="Theme.RetroMusic.Base.Adaptive" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:windowActionBarOverlay">true</item>
@ -13,6 +13,8 @@
<item name="android:actionOverflowButtonStyle">@style/Widget.ActionButton.Overflow</item>
<item name="materialAlertDialogTheme">@style/MaterialAlertDialogTheme</item>
<item name="materialButtonStyle">@style/MaterialButtonTheme</item>
<item name="popupMenuStyle">@style/MaterialPopupMenuStyle</item>
<item name="popupWindowStyle">@style/MaterialPopupMenuStyle</item>
</style>
<style name="Theme.RetroMusic.Base" parent="Theme.MaterialComponents.NoActionBar">
@ -29,11 +31,9 @@
<item name="windowActionBar">false</item>
<item name="materialAlertDialogTheme">@style/MaterialAlertDialogTheme</item>
<item name="materialButtonStyle">@style/MaterialButtonTheme</item>
<!--Manual setting colors-->
<item name="colorSurface">@color/darkColorSurface</item>
<item name="android:windowBackground">@color/window_color_dark</item>
<item name="popupMenuStyle">@style/MaterialPopupMenuStyle</item>
</style>
<style name="Theme.RetroMusic.Base.Black" parent="Theme.MaterialComponents.NoActionBar">
@ -50,6 +50,7 @@
<item name="colorOnBackground">@color/blackColorSurface</item>
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
<item name="mcab_popup_theme">@style/ThemeOverlay.AppCompat.Dark</item>
<item name="popupMenuStyle">@style/MaterialPopupMenuStyle</item>
</style>
<style name="Theme.RetroMusic.Base.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
@ -65,7 +66,7 @@
<item name="windowActionBar">false</item>
<item name="materialAlertDialogTheme">@style/MaterialAlertDialogTheme</item>
<item name="materialButtonStyle">@style/MaterialButtonTheme</item>
<item name="popupMenuStyle">@style/MaterialPopupMenuStyle</item>
</style>
@ -87,19 +88,4 @@
<item name="android:layout_height">wrap_content</item>
</style>
<style name="MaterialAlertDialogTheme" parent="@style/ThemeOverlay.MaterialComponents.Dialog">
<item name="android:dialogCornerRadius" tools:targetApi="p">12dp</item>
</style>
<style name="MaterialButtonTheme" parent="Widget.MaterialComponents.Button">
<item name="cornerRadius">6dp</item>
<item name="iconGravity">textStart</item>
<item name="iconTint">?attr/colorControlNormal</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:textAppearance">@style/TextViewNormal</item>
<item name="android:textAllCaps">false</item>
<item name="android:paddingTop">@dimen/button_padding_vertical</item>
<item name="android:paddingBottom">@dimen/button_padding_vertical</item>
</style>
</resources>