Merge branch 'dev' of https://github.com/h4h13/RetroMusicPlayer into google-san
This commit is contained in:
commit
e534e6ce75
92 changed files with 887 additions and 1127 deletions
|
@ -137,11 +137,9 @@ dependencies {
|
|||
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
|
||||
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
||||
|
||||
def material_dialog_version = "3.1.1"
|
||||
def material_dialog_version = "0.9.6.0"
|
||||
implementation "com.afollestad.material-dialogs:core:$material_dialog_version"
|
||||
implementation "com.afollestad.material-dialogs:input:$material_dialog_version"
|
||||
implementation "com.afollestad.material-dialogs:color:$material_dialog_version"
|
||||
implementation "com.afollestad.material-dialogs:bottomsheets:$material_dialog_version"
|
||||
implementation "com.afollestad.material-dialogs:commons:$material_dialog_version"
|
||||
implementation 'com.afollestad:material-cab:0.1.12'
|
||||
|
||||
implementation 'com.github.bumptech.glide:glide:3.8.0'
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
<data android:mimeType="vnd.android.cursor.dir/audio" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".activities.AlbumDetailsActivity" />
|
||||
<activity android:name=".activities.albums.AlbumDetailsActivity" />
|
||||
<activity android:name=".activities.ArtistDetailActivity" />
|
||||
<activity android:name=".activities.PlaylistDetailActivity" />
|
||||
<activity android:name=".activities.PlayingQueueActivity" />
|
||||
|
|
|
@ -22,6 +22,7 @@ import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
|||
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
|
||||
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
|
||||
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||
|
@ -95,21 +96,13 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
setLightNavigationBar(true)
|
||||
setBottomBarVisibility(View.GONE)
|
||||
window.sharedElementsUseOverlay = true
|
||||
windowEnterTransition()
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
artistDetailsPresenter.attachView(this)
|
||||
val artistId = extraNotNull<Int>(EXTRA_ARTIST_ID).value
|
||||
artistDetailsPresenter.loadArtist(artistId)
|
||||
|
||||
if (intent.extras!!.containsKey(EXTRA_ARTIST_ID)) {
|
||||
intent.extras?.getInt(EXTRA_ARTIST_ID)?.let {
|
||||
artistDetailsPresenter.loadArtist(it)
|
||||
val name = "${getString(R.string.transition_artist_image)}_$it"
|
||||
artistCoverContainer?.transitionName = name
|
||||
}
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
||||
windowEnterTransition()
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
|
||||
setupRecyclerView()
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.content.res.ColorStateList
|
|||
import android.os.AsyncTask
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.text.TextUtils
|
||||
import android.view.*
|
||||
import androidx.annotation.StringRes
|
||||
|
@ -16,12 +15,14 @@ import androidx.fragment.app.FragmentManager
|
|||
import androidx.fragment.app.FragmentStatePagerAdapter
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||
import code.name.monkey.retromusic.activities.tageditor.WriteTagsAsyncTask
|
||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||
import code.name.monkey.retromusic.extensions.textColorSecondary
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
||||
|
@ -34,18 +35,10 @@ import code.name.monkey.retromusic.model.lyrics.Lyrics
|
|||
import code.name.monkey.retromusic.util.LyricUtil
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.input.getInputLayout
|
||||
import com.afollestad.materialdialogs.input.input
|
||||
import kotlinx.android.synthetic.main.activity_lyrics.*
|
||||
import kotlinx.android.synthetic.main.fragment_lyrics.*
|
||||
import kotlinx.android.synthetic.main.fragment_synced.*
|
||||
import org.jaudiotagger.tag.FieldKey
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.set
|
||||
|
||||
class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
|
||||
ViewPager.OnPageChangeListener {
|
||||
|
@ -170,7 +163,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
|
|||
e.printStackTrace()
|
||||
}
|
||||
|
||||
val materialDialog = MaterialDialog(this)
|
||||
/*val materialDialog = MaterialDialog(this)
|
||||
.show {
|
||||
title(R.string.add_time_framed_lryics)
|
||||
negativeButton(R.string.action_search) {
|
||||
|
@ -188,7 +181,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
|
|||
}
|
||||
}
|
||||
|
||||
MaterialUtil.setTint(materialDialog.getInputLayout(), false)
|
||||
MaterialUtil.setTint(materialDialog.getInputLayout(), false)*/
|
||||
}
|
||||
|
||||
private fun updateSong() {
|
||||
|
@ -206,7 +199,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
|
|||
lyricsString!!
|
||||
}
|
||||
|
||||
val materialDialog = MaterialDialog(
|
||||
/*val materialDialog = MaterialDialog(
|
||||
this
|
||||
).show {
|
||||
|
||||
|
@ -231,7 +224,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
|
|||
updateSong()
|
||||
}
|
||||
}
|
||||
MaterialUtil.setTint(materialDialog.getInputLayout(), false)
|
||||
MaterialUtil.setTint(materialDialog.getInputLayout(), false)*/
|
||||
}
|
||||
|
||||
private fun getSongPaths(song: Song): ArrayList<String> {
|
||||
|
|
|
@ -228,6 +228,12 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
|
|||
menu.add(0, R.id.action_search, 0, getString(R.string.action_search))
|
||||
.setIcon(R.drawable.ic_search_white_24dp)
|
||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS)
|
||||
ToolbarContentTintHelper.handleOnCreateOptionsMenu(
|
||||
this,
|
||||
toolbar,
|
||||
menu,
|
||||
getToolbarBackgroundColor(toolbar)
|
||||
)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,17 @@ import android.os.Bundle
|
|||
import android.view.MenuItem
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.fragment.app.Fragment
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||
import code.name.monkey.retromusic.fragments.settings.MainSettingsFragment
|
||||
import com.afollestad.materialdialogs.color.ColorChooserDialog
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
class SettingsActivity : AbsBaseActivity() {
|
||||
class SettingsActivity : AbsBaseActivity(), ColorChooserDialog.ColorCallback {
|
||||
|
||||
private val fragmentManager = supportFragmentManager
|
||||
|
||||
|
@ -69,4 +73,19 @@ class SettingsActivity : AbsBaseActivity() {
|
|||
companion object {
|
||||
const val TAG: String = "SettingsActivity"
|
||||
}
|
||||
|
||||
override fun onColorSelection(dialog: ColorChooserDialog, selectedColor: Int) {
|
||||
when (dialog.title) {
|
||||
R.string.accent_color -> {
|
||||
ThemeStore.editTheme(this).accentColor(selectedColor).commit()
|
||||
if (VersionUtils.hasNougatMR())
|
||||
DynamicShortcutManager(this).updateDynamicShortcuts()
|
||||
}
|
||||
}
|
||||
recreate()
|
||||
}
|
||||
|
||||
override fun onColorChooserDismissed(dialog: ColorChooserDialog) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package code.name.monkey.retromusic.activities
|
||||
package code.name.monkey.retromusic.activities.albums
|
||||
|
||||
import android.app.ActivityOptions
|
||||
import android.content.Intent
|
||||
|
@ -10,13 +10,13 @@ import android.view.SubMenu
|
|||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
|
||||
|
@ -25,6 +25,7 @@ import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
|
|||
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
|
||||
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
||||
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||
|
@ -36,7 +37,6 @@ import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder
|
|||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsView
|
||||
import code.name.monkey.retromusic.rest.model.LastFmAlbum
|
||||
import code.name.monkey.retromusic.util.*
|
||||
|
@ -46,7 +46,6 @@ import com.bumptech.glide.Glide
|
|||
import kotlinx.android.synthetic.main.activity_album.*
|
||||
import kotlinx.android.synthetic.main.activity_album_content.*
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import android.util.Pair as UtilPair
|
||||
|
||||
class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, CabHolder {
|
||||
|
@ -69,6 +68,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
return cab as MaterialCab
|
||||
}
|
||||
|
||||
private lateinit var viewModel: AlbumDetailsViewModel
|
||||
private lateinit var simpleSongAdapter: SimpleSongAdapter
|
||||
private lateinit var album: Album
|
||||
private lateinit var artistImage: ImageView
|
||||
|
@ -80,9 +80,6 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
return wrapSlidingMusicPanel(R.layout.activity_album)
|
||||
}
|
||||
|
||||
@Inject
|
||||
lateinit var albumDetailsPresenter: AlbumDetailsPresenter
|
||||
|
||||
private fun windowEnterTransition() {
|
||||
val slide = Slide()
|
||||
slide.excludeTarget(R.id.appBarLayout, true)
|
||||
|
@ -101,34 +98,30 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
setLightNavigationBar(true)
|
||||
setBottomBarVisibility(View.GONE)
|
||||
window.sharedElementsUseOverlay = true
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
albumDetailsPresenter.attachView(this)
|
||||
|
||||
if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) {
|
||||
intent.extras?.getInt(EXTRA_ALBUM_ID)?.let {
|
||||
albumDetailsPresenter.loadAlbum(it)
|
||||
albumCoverContainer?.transitionName =
|
||||
"${getString(R.string.transition_album_art)}_$it"
|
||||
}
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
||||
windowEnterTransition()
|
||||
|
||||
val albumId = extraNotNull<Int>(EXTRA_ALBUM_ID).value
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
|
||||
|
||||
artistImage = findViewById(R.id.artistImage)
|
||||
|
||||
val viewModelFactory = AlbumDetailsViewModelFactory(application, albumId)
|
||||
viewModel = ViewModelProvider(this, viewModelFactory).get(AlbumDetailsViewModel::class.java)
|
||||
viewModel.getAlbum().observe(this, androidx.lifecycle.Observer {
|
||||
ActivityCompat.startPostponedEnterTransition(this@AlbumDetailsActivity)
|
||||
album(it)
|
||||
})
|
||||
viewModel.getArtist().observe(this, androidx.lifecycle.Observer {
|
||||
loadArtistImage(it)
|
||||
})
|
||||
viewModel.getAlbumInfo().observe(this, androidx.lifecycle.Observer {
|
||||
aboutAlbum(it)
|
||||
})
|
||||
setupRecyclerView()
|
||||
|
||||
artistImage = findViewById(R.id.artistImage)
|
||||
artistImage.setOnClickListener {
|
||||
val artistPairs = ActivityOptions.makeSceneTransitionAnimation(
|
||||
this,
|
||||
UtilPair.create(
|
||||
artistImage,
|
||||
"${getString(R.string.transition_artist_image)}_${album.artistId}"
|
||||
getString(R.string.transition_artist_image)
|
||||
)
|
||||
)
|
||||
NavigationUtil.goToArtistOptions(this, album.artistId, artistPairs)
|
||||
|
@ -159,11 +152,6 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
albumDetailsPresenter.detachView()
|
||||
}
|
||||
|
||||
override fun complete() {
|
||||
ActivityCompat.startPostponedEnterTransition(this)
|
||||
}
|
||||
|
@ -201,8 +189,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
}
|
||||
loadAlbumCover()
|
||||
simpleSongAdapter.swapDataSet(album.songs)
|
||||
albumDetailsPresenter.loadMore(album.artistId)
|
||||
albumDetailsPresenter.aboutAlbum(album.artistName ?: "-", album.title ?: "-")
|
||||
viewModel.loadArtistAsync(album.artistId)
|
||||
viewModel.loadAlbumInfoAsync(album)
|
||||
}
|
||||
|
||||
override fun moreAlbums(albums: List<Album>) {
|
||||
|
@ -277,7 +265,6 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
|
||||
MaterialUtil.setTint(button = playAction, color = buttonColor)
|
||||
|
||||
|
||||
toolbar.setBackgroundColor(surfaceColor())
|
||||
setSupportActionBar(toolbar)
|
||||
supportActionBar?.title = null
|
||||
|
@ -332,7 +319,10 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
albumCoverContainer,
|
||||
"${getString(R.string.transition_album_art)}_${album.id}"
|
||||
)
|
||||
startActivityForResult(intent, TAG_EDITOR_REQUEST, options.toBundle())
|
||||
startActivityForResult(
|
||||
intent,
|
||||
TAG_EDITOR_REQUEST, options.toBundle()
|
||||
)
|
||||
return true
|
||||
}
|
||||
/*Sort*/
|
||||
|
@ -389,18 +379,6 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
album.songs?.let { simpleSongAdapter.swapDataSet(it) }
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
super.onMediaStoreChanged()
|
||||
reload()
|
||||
}
|
||||
|
||||
private fun reload() {
|
||||
if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) {
|
||||
intent.extras?.getInt(EXTRA_ALBUM_ID)?.let { albumDetailsPresenter.loadAlbum(it) }
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (cab != null && cab!!.isActive) {
|
|
@ -0,0 +1,54 @@
|
|||
package code.name.monkey.retromusic.activities.albums
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.providers.RepositoryImpl
|
||||
import code.name.monkey.retromusic.rest.model.LastFmAlbum
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class AlbumDetailsViewModel(
|
||||
application: Application,
|
||||
private val albumId: Int
|
||||
) : AndroidViewModel(application) {
|
||||
private val _repository = RepositoryImpl(application.applicationContext)
|
||||
private val _album = MutableLiveData<Album>()
|
||||
private val _artist = MutableLiveData<Artist>()
|
||||
private val _lastFmAlbum = MutableLiveData<LastFmAlbum>()
|
||||
|
||||
fun getAlbum(): LiveData<Album> = _album
|
||||
fun getArtist(): LiveData<Artist> = _artist
|
||||
fun getAlbumInfo(): LiveData<LastFmAlbum> = _lastFmAlbum
|
||||
|
||||
init {
|
||||
loadDetails()
|
||||
}
|
||||
|
||||
private fun loadDetails() = viewModelScope.launch {
|
||||
_album.postValue(
|
||||
loadAlbumAsync.await() ?: throw NullPointerException("Album couldn't found")
|
||||
)
|
||||
}
|
||||
|
||||
fun loadAlbumInfoAsync(album: Album) = viewModelScope.launch(Dispatchers.IO) {
|
||||
val lastFmAlbum = _repository.albumInfo(album.artistName ?: "-", album.title ?: "-")
|
||||
_lastFmAlbum.postValue(lastFmAlbum)
|
||||
}
|
||||
|
||||
fun loadArtistAsync(artistId: Int) = viewModelScope.launch(Dispatchers.IO) {
|
||||
val artist = _repository.artistById(artistId)
|
||||
_artist.postValue(artist)
|
||||
}
|
||||
|
||||
private val loadAlbumAsync: Deferred<Album?>
|
||||
get() = viewModelScope.async(Dispatchers.IO) {
|
||||
_repository.albumById(albumId)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package code.name.monkey.retromusic.activities.albums
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
|
||||
class AlbumDetailsViewModelFactory(
|
||||
private val application: Application,
|
||||
private val albumId: Int
|
||||
) :
|
||||
ViewModelProvider.AndroidViewModelFactory(application) {
|
||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
||||
return if (modelClass.isAssignableFrom(AlbumDetailsViewModel::class.java)) {
|
||||
AlbumDetailsViewModel(application, albumId) as T
|
||||
} else {
|
||||
throw IllegalArgumentException("ViewModel Not Found")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ import code.name.monkey.appthemehelper.ThemeStore
|
|||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialDialogsUtil
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import code.name.monkey.retromusic.LanguageContextWrapper
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -33,6 +34,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
|||
setImmersiveFullscreen()
|
||||
registerSystemUiVisibility()
|
||||
toggleScreenOn()
|
||||
MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@ import code.name.monkey.retromusic.activities.bugreport.model.github.ExtraInfo
|
|||
import code.name.monkey.retromusic.activities.bugreport.model.github.GithubLogin
|
||||
import code.name.monkey.retromusic.activities.bugreport.model.github.GithubTarget
|
||||
import code.name.monkey.retromusic.misc.DialogAsyncTask
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.callbacks.onCancel
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import kotlinx.android.synthetic.main.activity_bug_report.*
|
||||
|
@ -278,27 +277,25 @@ open class BugReportActivity : AbsThemeActivity() {
|
|||
|
||||
when (result) {
|
||||
RESULT_SUCCESS -> tryToFinishActivity()
|
||||
RESULT_BAD_CREDENTIALS -> MaterialDialog(context).show {
|
||||
title(R.string.bug_report_failed)
|
||||
message(R.string.bug_report_failed_wrong_credentials)
|
||||
positiveButton(android.R.string.ok)
|
||||
}
|
||||
RESULT_INVALID_TOKEN -> MaterialDialog(context).show {
|
||||
title(R.string.bug_report_failed)
|
||||
message(R.string.bug_report_failed_invalid_token)
|
||||
positiveButton(android.R.string.ok)
|
||||
}
|
||||
RESULT_ISSUES_NOT_ENABLED -> MaterialDialog(context).show {
|
||||
title(R.string.bug_report_failed)
|
||||
message(R.string.bug_report_failed_issues_not_available)
|
||||
positiveButton(android.R.string.ok)
|
||||
}
|
||||
else -> MaterialDialog(context).show {
|
||||
title(R.string.bug_report_failed)
|
||||
message(R.string.bug_report_failed_unknown)
|
||||
positiveButton(android.R.string.ok) { tryToFinishActivity() }
|
||||
onCancel { tryToFinishActivity() }
|
||||
}
|
||||
RESULT_BAD_CREDENTIALS -> MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.bug_report_failed)
|
||||
.setMessage(R.string.bug_report_failed_wrong_credentials)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show()
|
||||
RESULT_INVALID_TOKEN -> MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.bug_report_failed)
|
||||
.setMessage(R.string.bug_report_failed_invalid_token)
|
||||
.setPositiveButton(android.R.string.ok, null).show()
|
||||
RESULT_ISSUES_NOT_ENABLED -> MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.bug_report_failed)
|
||||
.setMessage(R.string.bug_report_failed_issues_not_available)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
|
||||
else -> MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.bug_report_failed)
|
||||
.setMessage(R.string.bug_report_failed_unknown)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ -> tryToFinishActivity() }
|
||||
.setNegativeButton(android.R.string.cancel) { _, _ -> { tryToFinishActivity() } }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,6 +306,7 @@ open class BugReportActivity : AbsThemeActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
|
||||
fun report(
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.util.Log
|
|||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.animation.OvershootInterpolator
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
|
@ -24,9 +25,8 @@ import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
|||
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import code.name.monkey.retromusic.util.SAFUtil
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import kotlinx.android.synthetic.main.activity_album_tag_editor.*
|
||||
import org.jaudiotagger.audio.AudioFile
|
||||
import org.jaudiotagger.audio.AudioFileIO
|
||||
|
@ -48,17 +48,18 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
private var savedTags: Map<FieldKey, String>? = null
|
||||
private var savedArtworkInfo: ArtworkInfo? = null
|
||||
|
||||
protected val show: MaterialDialog
|
||||
get() = MaterialDialog(this).show {
|
||||
title(R.string.update_image)
|
||||
listItems(items = items) { _, position, _ ->
|
||||
when (position) {
|
||||
0 -> startImagePicker()
|
||||
1 -> searchImageOnWeb()
|
||||
2 -> deleteImage()
|
||||
protected val show: AlertDialog
|
||||
get() =
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setTitle(R.string.update_image)
|
||||
.setItems(items.toTypedArray()) { _, position ->
|
||||
when (position) {
|
||||
0 -> startImagePicker()
|
||||
1 -> searchImageOnWeb()
|
||||
2 -> deleteImage()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.show()
|
||||
protected abstract val contentViewLayout: Int
|
||||
|
||||
internal val albumArtist: String?
|
||||
|
|
|
@ -91,7 +91,7 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
|||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
window.sharedElementsUseOverlay = true
|
||||
imageContainer?.transitionName = "${getString(R.string.transition_album_art)}_$id"
|
||||
imageContainer?.transitionName = getString(R.string.transition_album_art)
|
||||
windowEnterTransition()
|
||||
setUpViews()
|
||||
setupToolbar()
|
||||
|
@ -162,7 +162,7 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
|||
|
||||
writeValuesToFiles(
|
||||
fieldKeyValueMap,
|
||||
if (deleteAlbumArt) ArtworkInfo(id, null)
|
||||
if (deleteAlbumArt) AbsTagEditorActivity.ArtworkInfo(id, null)
|
||||
else if (albumArtBitmap == null) null else ArtworkInfo(id, albumArtBitmap!!)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ open class AlbumAdapter(
|
|||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
imageContainerCard ?: image,
|
||||
"${activity.getString(R.string.transition_album_art)}_${dataSet[layoutPosition].id}"
|
||||
activity.getString(R.string.transition_album_art)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(
|
||||
activity,
|
||||
|
|
|
@ -100,7 +100,7 @@ class AlbumFullWidthAdapter(
|
|||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
imageContainerCard ?: image,
|
||||
"${activity.getString(R.string.transition_album_art)}_${dataSet[layoutPosition].id}"
|
||||
activity.getString(R.string.transition_album_art)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, dataSet[layoutPosition].id, activityOptions)
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ class ArtistAdapter(
|
|||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
imageContainerCard ?: image,
|
||||
"${activity.getString(R.string.transition_artist_image)}_${dataSet[layoutPosition].id}"
|
||||
activity.getString(R.string.transition_artist_image)
|
||||
)
|
||||
NavigationUtil.goToArtistOptions(
|
||||
activity, dataSet[layoutPosition].id, activityOptions
|
||||
|
|
|
@ -60,7 +60,7 @@ open class PlaylistSongAdapter(
|
|||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
imageContainerCard ?: image,
|
||||
"${activity.getString(R.string.transition_album_art)}_${song.albumId}"
|
||||
activity.getString(R.string.transition_album_art)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, song.albumId, activityOptions)
|
||||
return true
|
||||
|
|
|
@ -186,7 +186,7 @@ open class SongAdapter(
|
|||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
imageContainerCard ?: image,
|
||||
"${activity.getString(R.string.transition_album_art)}_${song.albumId}"
|
||||
activity.getString(R.string.transition_album_art)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, song.albumId, activityOptions)
|
||||
return true
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
|
||||
package code.name.monkey.retromusic.dagger
|
||||
|
||||
import code.name.monkey.retromusic.activities.*
|
||||
import code.name.monkey.retromusic.activities.ArtistDetailActivity
|
||||
import code.name.monkey.retromusic.activities.GenreDetailsActivity
|
||||
import code.name.monkey.retromusic.activities.PlaylistDetailActivity
|
||||
import code.name.monkey.retromusic.activities.SearchActivity
|
||||
import code.name.monkey.retromusic.dagger.module.AppModule
|
||||
import code.name.monkey.retromusic.dagger.module.PresenterModule
|
||||
import code.name.monkey.retromusic.fragments.albums.AlbumsFragment
|
||||
|
@ -50,8 +53,6 @@ interface MusicComponent {
|
|||
|
||||
fun inject(artistDetailActivity: ArtistDetailActivity)
|
||||
|
||||
fun inject(albumDetailsActivity: AlbumDetailsActivity)
|
||||
|
||||
fun inject(playlistDetailActivity: PlaylistDetailActivity)
|
||||
|
||||
fun inject(genreDetailsActivity: GenreDetailsActivity)
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
package code.name.monkey.retromusic.dialogs;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Dialog;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
||||
public class BlacklistFolderChooserDialog extends DialogFragment implements MaterialDialog.ListCallback {
|
||||
|
||||
String initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
private File parentFolder;
|
||||
private File[] parentContents;
|
||||
private boolean canGoUp = false;
|
||||
private FolderCallback callback;
|
||||
|
||||
public static BlacklistFolderChooserDialog create() {
|
||||
return new BlacklistFolderChooserDialog();
|
||||
}
|
||||
|
||||
private String[] getContentsArray() {
|
||||
if (parentContents == null) {
|
||||
if (canGoUp) {
|
||||
return new String[]{".."};
|
||||
}
|
||||
return new String[]{};
|
||||
}
|
||||
String[] results = new String[parentContents.length + (canGoUp ? 1 : 0)];
|
||||
if (canGoUp) {
|
||||
results[0] = "..";
|
||||
}
|
||||
for (int i = 0; i < parentContents.length; i++) {
|
||||
results[canGoUp ? i + 1 : i] = parentContents[i].getName();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private File[] listFiles() {
|
||||
File[] contents = parentFolder.listFiles();
|
||||
List<File> results = new ArrayList<>();
|
||||
if (contents != null) {
|
||||
for (File fi : contents) {
|
||||
if (fi.isDirectory()) {
|
||||
results.add(fi);
|
||||
}
|
||||
}
|
||||
Collections.sort(results, new FolderSorter());
|
||||
return results.toArray(new File[results.size()]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
&& ActivityCompat.checkSelfPermission(
|
||||
getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
return new MaterialDialog.Builder(getActivity())
|
||||
.title(R.string.md_error_label)
|
||||
.content(R.string.md_storage_perm_error)
|
||||
.positiveText(android.R.string.ok)
|
||||
.build();
|
||||
}
|
||||
if (savedInstanceState == null) {
|
||||
savedInstanceState = new Bundle();
|
||||
}
|
||||
if (!savedInstanceState.containsKey("current_path")) {
|
||||
savedInstanceState.putString("current_path", initialPath);
|
||||
}
|
||||
parentFolder = new File(savedInstanceState.getString("current_path", File.pathSeparator));
|
||||
checkIfCanGoUp();
|
||||
parentContents = listFiles();
|
||||
MaterialDialog.Builder builder =
|
||||
new MaterialDialog.Builder(getActivity())
|
||||
.title(parentFolder.getAbsolutePath())
|
||||
.items((CharSequence[]) getContentsArray())
|
||||
.itemsCallback(this)
|
||||
.autoDismiss(false)
|
||||
.onPositive((dialog, which) -> {
|
||||
dismiss();
|
||||
callback.onFolderSelection(BlacklistFolderChooserDialog.this, parentFolder);
|
||||
})
|
||||
.onNegative((materialDialog, dialogAction) -> dismiss())
|
||||
.positiveText(R.string.add_action)
|
||||
.negativeText(android.R.string.cancel);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence s) {
|
||||
if (canGoUp && i == 0) {
|
||||
parentFolder = parentFolder.getParentFile();
|
||||
if (parentFolder.getAbsolutePath().equals("/storage/emulated")) {
|
||||
parentFolder = parentFolder.getParentFile();
|
||||
}
|
||||
checkIfCanGoUp();
|
||||
} else {
|
||||
parentFolder = parentContents[canGoUp ? i - 1 : i];
|
||||
canGoUp = true;
|
||||
if (parentFolder.getAbsolutePath().equals("/storage/emulated")) {
|
||||
parentFolder = Environment.getExternalStorageDirectory();
|
||||
}
|
||||
}
|
||||
reload();
|
||||
}
|
||||
|
||||
private void checkIfCanGoUp() {
|
||||
canGoUp = parentFolder.getParent() != null;
|
||||
}
|
||||
|
||||
private void reload() {
|
||||
parentContents = listFiles();
|
||||
MaterialDialog dialog = (MaterialDialog) getDialog();
|
||||
dialog.setTitle(parentFolder.getAbsolutePath());
|
||||
dialog.setItems((CharSequence[]) getContentsArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putString("current_path", parentFolder.getAbsolutePath());
|
||||
}
|
||||
|
||||
public void setCallback(FolderCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public interface FolderCallback {
|
||||
void onFolderSelection(@NonNull BlacklistFolderChooserDialog dialog, @NonNull File folder);
|
||||
}
|
||||
|
||||
private static class FolderSorter implements Comparator<File> {
|
||||
|
||||
@Override
|
||||
public int compare(File lhs, File rhs) {
|
||||
return lhs.getName().compareTo(rhs.getName());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,180 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.dialogs
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Dialog
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class BlacklistFolderChooserDialog : DialogFragment() {
|
||||
|
||||
private val initialPath = Environment.getExternalStorageDirectory().absolutePath
|
||||
private var parentFolder: File? = null
|
||||
private var parentContents: Array<File>? = null
|
||||
private var canGoUp = false
|
||||
private var callback: FolderCallback? = null
|
||||
|
||||
|
||||
private fun contentsArray(): List<String> {
|
||||
if (parentContents == null) {
|
||||
return if (canGoUp) {
|
||||
return listOf("..")
|
||||
} else listOf()
|
||||
}
|
||||
|
||||
val results = arrayOfNulls<String>(parentContents!!.size + if (canGoUp) 1 else 0)
|
||||
if (canGoUp) {
|
||||
results[0] = ".."
|
||||
}
|
||||
for (i in parentContents!!.indices) {
|
||||
results[if (canGoUp) i + 1 else i] = parentContents!![i].name
|
||||
}
|
||||
|
||||
val data = ArrayList<String>()
|
||||
for (i in results) {
|
||||
data.add(i!!)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
private fun listFiles(): Array<File>? {
|
||||
val contents = parentFolder!!.listFiles()
|
||||
val results = ArrayList<File>()
|
||||
if (contents != null) {
|
||||
for (fi in contents) {
|
||||
if (fi.isDirectory) {
|
||||
results.add(fi)
|
||||
}
|
||||
}
|
||||
Collections.sort(results, FolderSorter())
|
||||
return results.toTypedArray()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
var savedInstanceStateFinal = savedInstanceState
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
||||
ActivityCompat.checkSelfPermission(
|
||||
requireActivity(),
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
) != PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
return MaterialDialog(requireActivity()).show {
|
||||
title(R.string.md_error_label)
|
||||
|
||||
message(R.string.md_storage_perm_error)
|
||||
positiveButton(android.R.string.ok)
|
||||
}
|
||||
}
|
||||
if (savedInstanceStateFinal == null) {
|
||||
savedInstanceStateFinal = Bundle()
|
||||
}
|
||||
if (!savedInstanceStateFinal.containsKey("current_path")) {
|
||||
savedInstanceStateFinal.putString("current_path", initialPath)
|
||||
}
|
||||
parentFolder = File(savedInstanceStateFinal.getString("current_path", File.pathSeparator))
|
||||
checkIfCanGoUp()
|
||||
parentContents = listFiles()
|
||||
|
||||
return MaterialDialog(requireContext()).show {
|
||||
title(text = parentFolder!!.absolutePath)
|
||||
|
||||
listItems(items = contentsArray(), waitForPositiveButton = false) { _, index, _ ->
|
||||
onSelection(index)
|
||||
}
|
||||
noAutoDismiss()
|
||||
positiveButton(R.string.add_action) {
|
||||
dismiss()
|
||||
callback!!.onFolderSelection(this@BlacklistFolderChooserDialog, parentFolder!!)
|
||||
}
|
||||
negativeButton(android.R.string.cancel) {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onSelection(i: Int) {
|
||||
if (canGoUp && i == 0) {
|
||||
parentFolder = parentFolder!!.parentFile
|
||||
if (parentFolder!!.absolutePath == "/storage/emulated") {
|
||||
parentFolder = parentFolder!!.parentFile
|
||||
}
|
||||
checkIfCanGoUp()
|
||||
} else {
|
||||
parentFolder = parentContents!![if (canGoUp) i - 1 else i]
|
||||
canGoUp = true
|
||||
if (parentFolder!!.absolutePath == "/storage/emulated") {
|
||||
parentFolder = Environment.getExternalStorageDirectory()
|
||||
}
|
||||
}
|
||||
reload()
|
||||
}
|
||||
|
||||
private fun checkIfCanGoUp() {
|
||||
canGoUp = parentFolder!!.parent != null
|
||||
}
|
||||
|
||||
private fun reload() {
|
||||
parentContents = listFiles()
|
||||
val dialog = dialog as MaterialDialog?
|
||||
|
||||
dialog?.apply {
|
||||
|
||||
setTitle(parentFolder!!.absolutePath)
|
||||
listItems(items = contentsArray()) { _, index, _ ->
|
||||
onSelection(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putString("current_path", parentFolder!!.absolutePath)
|
||||
}
|
||||
|
||||
fun setCallback(callback: FolderCallback) {
|
||||
this.callback = callback
|
||||
}
|
||||
|
||||
interface FolderCallback {
|
||||
fun onFolderSelection(dialog: BlacklistFolderChooserDialog, folder: File)
|
||||
}
|
||||
|
||||
private class FolderSorter : Comparator<File> {
|
||||
|
||||
override fun compare(lhs: File, rhs: File): Int {
|
||||
return lhs.name.compareTo(rhs.name)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun create(): BlacklistFolderChooserDialog {
|
||||
return BlacklistFolderChooserDialog()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,9 +36,8 @@ import code.name.monkey.retromusic.service.MusicService
|
|||
import code.name.monkey.retromusic.service.MusicService.ACTION_PENDING_QUIT
|
||||
import code.name.monkey.retromusic.service.MusicService.ACTION_QUIT
|
||||
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||
import com.afollestad.materialdialogs.DialogAction
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.WhichButton
|
||||
import com.afollestad.materialdialogs.actions.getActionButton
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class SleepTimerDialog : DialogFragment() {
|
||||
|
@ -153,10 +152,10 @@ class SleepTimerDialog : DialogFragment() {
|
|||
private fun updateCancelButton() {
|
||||
val musicService = MusicPlayerRemote.musicService
|
||||
if (musicService != null && musicService.pendingQuit) {
|
||||
materialDialog.getActionButton(WhichButton.NEGATIVE).text =
|
||||
materialDialog.getActionButton(DialogAction.NEUTRAL).text =
|
||||
materialDialog.context.getString(R.string.cancel_current_timer)
|
||||
} else {
|
||||
materialDialog.getActionButton(WhichButton.NEGATIVE).text = null
|
||||
materialDialog.getActionButton(DialogAction.NEUTRAL).text = null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ import androidx.lifecycle.AndroidViewModel
|
|||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import code.name.monkey.retromusic.Result.Error
|
||||
import code.name.monkey.retromusic.Result.Success
|
||||
import code.name.monkey.retromusic.fragments.ReloadType.*
|
||||
import code.name.monkey.retromusic.interfaces.MusicServiceEventListener
|
||||
import code.name.monkey.retromusic.model.*
|
||||
|
@ -60,8 +58,8 @@ class LibraryViewModel(application: Application) :
|
|||
_repository.favoritePlaylist()
|
||||
)
|
||||
for (r in result) {
|
||||
if (r is Success) {
|
||||
list.add(r.data)
|
||||
if (r != null) {
|
||||
list.add(r)
|
||||
}
|
||||
}
|
||||
_homeSections.value = list
|
||||
|
@ -69,41 +67,27 @@ class LibraryViewModel(application: Application) :
|
|||
|
||||
private val loadSongs: Deferred<List<Song>>
|
||||
get() = viewModelScope.async(IO) {
|
||||
when (val result = _repository.allSongs()) {
|
||||
is Success -> result.data
|
||||
is Error -> arrayListOf()
|
||||
}
|
||||
_repository.allSongs()
|
||||
}
|
||||
|
||||
private val loadAlbums: Deferred<List<Album>>
|
||||
get() = viewModelScope.async(IO) {
|
||||
when (val result = _repository.allAlbums()) {
|
||||
is Success -> result.data
|
||||
is Error -> arrayListOf()
|
||||
}
|
||||
_repository.allAlbums()
|
||||
}
|
||||
|
||||
private val loadArtists: Deferred<List<Artist>>
|
||||
get() = viewModelScope.async(IO) {
|
||||
when (val result = _repository.allArtists()) {
|
||||
is Success -> result.data
|
||||
is Error -> arrayListOf()
|
||||
}
|
||||
_repository.allArtists()
|
||||
}
|
||||
|
||||
private val loadPlaylists: Deferred<List<Playlist>>
|
||||
get() = viewModelScope.async(IO) {
|
||||
when (val result = _repository.allPlaylists()) {
|
||||
is Success -> result.data
|
||||
is Error -> arrayListOf()
|
||||
}
|
||||
_repository.allPlaylists()
|
||||
}
|
||||
|
||||
private val loadGenres: Deferred<List<Genre>>
|
||||
get() = viewModelScope.async(IO) {
|
||||
when (val result = _repository.allGenres()) {
|
||||
is Success -> result.data
|
||||
is Error -> arrayListOf()
|
||||
}
|
||||
_repository.allGenres()
|
||||
}
|
||||
|
||||
fun forceReload(reloadType: ReloadType) = viewModelScope.launch {
|
||||
|
|
|
@ -307,10 +307,10 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
String.format(getString(R.string.not_listed_in_media_store), file1.getName())),
|
||||
Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.action_scan,
|
||||
v -> new ListPathsAsyncTask(getActivity(), this::scanPaths)
|
||||
v -> new ListPathsAsyncTask(requireActivity(), this::scanPaths)
|
||||
.execute(
|
||||
new ListPathsAsyncTask.LoadingInfo(finalFile, AUDIO_FILE_FILTER)))
|
||||
.setActionTextColor(ThemeStore.Companion.accentColor(getActivity()))
|
||||
.setActionTextColor(ThemeStore.Companion.accentColor(requireActivity()))
|
||||
.show();
|
||||
}
|
||||
}).execute(new ListSongsAsyncTask.LoadingInfo(toList(file.getParentFile()), fileFilter,
|
||||
|
|
|
@ -21,8 +21,8 @@ import android.view.View
|
|||
import android.widget.Toast
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceFragmentCompat
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.preferences.*
|
||||
|
@ -32,7 +32,7 @@ import code.name.monkey.retromusic.util.NavigationUtil
|
|||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
|
||||
abstract class AbsSettingsFragment : PreferenceFragmentCompat() {
|
||||
abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() {
|
||||
|
||||
internal fun showProToastAndNavigate(message: String) {
|
||||
Toast.makeText(requireContext(), "$message is Pro version feature.", Toast.LENGTH_SHORT)
|
||||
|
|
|
@ -31,7 +31,6 @@ class ImageSettingFragment : AbsSettingsFragment() {
|
|||
setSummary(autoDownloadImagesPolicy, o)
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
|
|
|
@ -48,20 +48,23 @@ class NowPlayingSettingsFragment : AbsSettingsFragment(),
|
|||
}
|
||||
|
||||
private fun updateAlbumCoverStyleSummary() {
|
||||
val preference: Preference = findPreference(ALBUM_COVER_STYLE)!!
|
||||
preference.setSummary(PreferenceUtilKT.albumCoverStyle.titleRes)
|
||||
val preference: Preference? = findPreference(ALBUM_COVER_STYLE)
|
||||
preference?.setSummary(PreferenceUtilKT.albumCoverStyle.titleRes)
|
||||
}
|
||||
|
||||
private fun updateNowPlayingScreenSummary() {
|
||||
val preference: Preference = findPreference(NOW_PLAYING_SCREEN_ID)!!
|
||||
preference.setSummary(PreferenceUtilKT.nowPlayingScreen.titleRes)
|
||||
val preference: Preference? = findPreference(NOW_PLAYING_SCREEN_ID)
|
||||
preference?.setSummary(PreferenceUtilKT.nowPlayingScreen.titleRes)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this)
|
||||
val preference: Preference = findPreference("album_cover_transform")!!
|
||||
setSummary(preference)
|
||||
val preference: Preference? = findPreference("album_cover_transform")
|
||||
preference?.setOnPreferenceChangeListener { albumPrefs, newValue ->
|
||||
setSummary(albumPrefs, newValue)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
|
|
@ -17,9 +17,8 @@ package code.name.monkey.retromusic.fragments.settings
|
|||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.preference.Preference
|
||||
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
|
@ -27,8 +26,8 @@ import code.name.monkey.retromusic.preferences.MaterialListPreference
|
|||
|
||||
class OtherSettingsFragment : AbsSettingsFragment() {
|
||||
override fun invalidateSettings() {
|
||||
val languagePreference: MaterialListPreference = findPreference("language_name")!!
|
||||
languagePreference.setOnPreferenceChangeListener { _, _ ->
|
||||
val languagePreference: ATEListPreference? = findPreference("language_name")
|
||||
languagePreference?.setOnPreferenceChangeListener { _, _ ->
|
||||
requireActivity().recreate()
|
||||
return@setOnPreferenceChangeListener true
|
||||
}
|
||||
|
@ -40,9 +39,15 @@ class OtherSettingsFragment : AbsSettingsFragment() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val preference: Preference = findPreference("last_added_interval")!!
|
||||
setSummary(preference)
|
||||
val languagePreference: Preference = findPreference("language_name")!!
|
||||
setSummary(languagePreference)
|
||||
val preference: Preference? = findPreference("last_added_interval")
|
||||
preference?.setOnPreferenceChangeListener { lastAdded, newValue ->
|
||||
setSummary(lastAdded, newValue)
|
||||
true
|
||||
}
|
||||
val languagePreference: Preference? = findPreference("language_name")
|
||||
languagePreference?.setOnPreferenceChangeListener { prefs, newValue ->
|
||||
setSummary(prefs, newValue)
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,21 +14,15 @@
|
|||
|
||||
package code.name.monkey.retromusic.fragments.settings
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.TwoStatePreference
|
||||
import code.name.monkey.retromusic.CAROUSEL_EFFECT
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
import code.name.monkey.retromusic.R
|
||||
|
||||
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||
|
||||
class PersonalizeSettingsFragment : AbsSettingsFragment(),
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
class PersonalizeSettingsFragment : AbsSettingsFragment() {
|
||||
|
||||
override fun invalidateSettings() {
|
||||
|
||||
val toggleFullScreen: TwoStatePreference = findPreference("toggle_full_screen")!!
|
||||
toggleFullScreen.setOnPreferenceChangeListener { _, _ ->
|
||||
requireActivity().recreate()
|
||||
|
@ -42,22 +36,15 @@ class PersonalizeSettingsFragment : AbsSettingsFragment(),
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this)
|
||||
|
||||
var preference: Preference? = findPreference("home_artist_grid_style")
|
||||
setSummary(preference!!)
|
||||
preference = findPreference("tab_text_mode")
|
||||
setSummary(preference!!)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
PreferenceUtilKT.unregisterOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
when (key) {
|
||||
CAROUSEL_EFFECT -> invalidateSettings()
|
||||
val homeArtistStyle: ATEListPreference? = findPreference("home_artist_grid_style")
|
||||
homeArtistStyle?.setOnPreferenceChangeListener { preference, newValue ->
|
||||
setSummary(preference, newValue)
|
||||
true
|
||||
}
|
||||
val tabTextMode: ATEListPreference? = findPreference("tab_text_mode")
|
||||
tabTextMode?.setOnPreferenceChangeListener { prefs, newValue ->
|
||||
setSummary(prefs, newValue)
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@ import android.os.Build
|
|||
import android.os.Bundle
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.TwoStatePreference
|
||||
import code.name.monkey.appthemehelper.ACCENT_COLORS
|
||||
import code.name.monkey.appthemehelper.ACCENT_COLORS_SUB
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
|
@ -30,9 +28,7 @@ import code.name.monkey.retromusic.DESATURATED_COLOR
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
||||
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.color.colorChooser
|
||||
|
||||
import com.afollestad.materialdialogs.color.ColorChooserDialog
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
|
@ -62,21 +58,12 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
accentColorPref.setColor(accentColor, ColorUtil.darkenColor(accentColor))
|
||||
|
||||
accentColorPref.setOnPreferenceClickListener {
|
||||
MaterialDialog(requireActivity()).show {
|
||||
title(R.string.accent_color)
|
||||
positiveButton(R.string.set)
|
||||
colorChooser(
|
||||
colors = ACCENT_COLORS,
|
||||
allowCustomArgb = true,
|
||||
subColors = ACCENT_COLORS_SUB
|
||||
) { _, color ->
|
||||
ThemeStore.editTheme(requireContext()).accentColor(color).commit()
|
||||
if (VersionUtils.hasNougatMR())
|
||||
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
||||
|
||||
requireActivity().recreate()
|
||||
}
|
||||
}
|
||||
ColorChooserDialog.Builder(requireContext(), R.string.accent_color)
|
||||
.accentMode(true)
|
||||
.allowUserColorInput(true)
|
||||
.allowUserColorInputAlpha(false)
|
||||
.preselect(accentColor)
|
||||
.show(requireActivity())
|
||||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
val blackTheme: ATESwitchPreference? = findPreference("black_theme")
|
||||
|
|
|
@ -14,14 +14,16 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.Result.Success
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import code.name.monkey.retromusic.rest.model.LastFmAlbum
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
|
@ -57,19 +59,15 @@ interface AlbumDetailsPresenter : Presenter<AlbumDetailsView> {
|
|||
|
||||
override fun loadMore(artistId: Int) {
|
||||
launch {
|
||||
when (val result = repository.artistById(artistId)) {
|
||||
is Success -> withContext(Dispatchers.Main) { showArtistImage(result.data) }
|
||||
is Error -> withContext(Dispatchers.Main) {}
|
||||
}
|
||||
val result = repository.artistById(artistId)
|
||||
showArtistImage(result)
|
||||
}
|
||||
}
|
||||
|
||||
override fun aboutAlbum(artist: String, album: String) {
|
||||
launch {
|
||||
when (val result = repository.albumInfo(artist, album)) {
|
||||
is Success -> withContext(Dispatchers.Main) { view.aboutAlbum(result.data) }
|
||||
is Error -> withContext(Dispatchers.Main) {}
|
||||
}
|
||||
val result = repository.albumInfo(artist, album)
|
||||
view.aboutAlbum(result)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,13 +81,10 @@ interface AlbumDetailsPresenter : Presenter<AlbumDetailsView> {
|
|||
|
||||
override fun loadAlbum(albumId: Int) {
|
||||
launch {
|
||||
when (val result = repository.albumById(albumId)) {
|
||||
is Success -> withContext(Dispatchers.Main) {
|
||||
album = result.data
|
||||
view?.album(result.data)
|
||||
}
|
||||
is Error -> withContext(Dispatchers.Main) { view?.complete() }
|
||||
}
|
||||
val result = repository.albumById(albumId)
|
||||
album = result
|
||||
view?.album(result)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,14 +14,15 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.Result.Error
|
||||
import code.name.monkey.retromusic.Result.Success
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
|
@ -53,10 +54,8 @@ interface AlbumsPresenter : Presenter<AlbumsView> {
|
|||
|
||||
override fun loadAlbums() {
|
||||
launch {
|
||||
when (val result = repository.allAlbums()) {
|
||||
is Success -> withContext(Dispatchers.Main) { view?.albums(result.data) }
|
||||
is Error -> withContext(Dispatchers.Main) { view?.showEmptyView() }
|
||||
}
|
||||
val result = repository.allAlbums()
|
||||
view?.albums(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,15 +14,16 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.Result.Error
|
||||
import code.name.monkey.retromusic.Result.Success
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import code.name.monkey.retromusic.rest.model.LastFmArtist
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
@ -60,19 +61,15 @@ interface ArtistDetailsPresenter : Presenter<ArtistDetailsView> {
|
|||
|
||||
override fun loadBiography(name: String, lang: String?, cache: String?) {
|
||||
launch {
|
||||
when (val result = repository.artistInfo(name, lang, cache)) {
|
||||
is Success -> withContext(Dispatchers.Main) { view?.artistInfo(result.data) }
|
||||
is Error -> withContext(Dispatchers.Main) {}
|
||||
}
|
||||
val result = repository.artistInfo(name, lang, cache)
|
||||
view?.artistInfo(result)
|
||||
}
|
||||
}
|
||||
|
||||
override fun loadArtist(artistId: Int) {
|
||||
launch {
|
||||
when (val result = repository.artistById(artistId)) {
|
||||
is Success -> withContext(Dispatchers.Main) { view?.artist(result.data) }
|
||||
is Error -> withContext(Dispatchers.Main) { view?.showEmptyView() }
|
||||
}
|
||||
val result = repository.artistById(artistId)
|
||||
view?.artist(result)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,14 +14,15 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.Result.Error
|
||||
import code.name.monkey.retromusic.Result.Success
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
|
@ -49,10 +50,8 @@ interface ArtistsPresenter : Presenter<ArtistsView> {
|
|||
|
||||
override fun loadArtists() {
|
||||
launch {
|
||||
when (val result = repository.allArtists()) {
|
||||
is Success -> withContext(Dispatchers.Main) { view?.artists(result.data) }
|
||||
is Error -> withContext(Dispatchers.Main) { view?.showEmptyView() }
|
||||
}
|
||||
val result = repository.allArtists()
|
||||
view?.artists(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,14 +14,15 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.Result.Error
|
||||
import code.name.monkey.retromusic.Result.Success
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
|
@ -53,10 +54,8 @@ interface GenreDetailsPresenter : Presenter<GenreDetailsView> {
|
|||
|
||||
override fun loadGenreSongs(genreId: Int) {
|
||||
launch {
|
||||
when (val result = repository.getGenre(genreId)) {
|
||||
is Success -> withContext(Dispatchers.Main) { view?.songs(result.data) }
|
||||
is Error -> withContext(Dispatchers.Main) { view?.showEmptyView() }
|
||||
}
|
||||
val result = repository.getGenre(genreId)
|
||||
view?.songs(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,14 +14,15 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.Result.Error
|
||||
import code.name.monkey.retromusic.Result.Success
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
|
@ -52,10 +53,8 @@ interface GenresPresenter : Presenter<GenresView> {
|
|||
|
||||
override fun loadGenres() {
|
||||
launch {
|
||||
when (val result = repository.allGenres()) {
|
||||
is Success -> withContext(Dispatchers.Main) { view?.genres(result.data) }
|
||||
is Error -> withContext(Dispatchers.Main) { view?.showEmptyView() }
|
||||
}
|
||||
val result = repository.allGenres()
|
||||
view?.genres(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.Result
|
||||
import code.name.monkey.retromusic.model.Home
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
|
@ -56,9 +55,7 @@ interface HomePresenter : Presenter<HomeView> {
|
|||
repository.favoritePlaylist()
|
||||
)
|
||||
for (r in recentArtistResult) {
|
||||
when (r) {
|
||||
is Result.Success -> list.add(r.data)
|
||||
}
|
||||
r?.let { list.add(it) }
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
if (list.isNotEmpty()) view?.sections(list) else view?.showEmptyView()
|
||||
|
|
|
@ -14,13 +14,15 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.Result
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
|
@ -53,10 +55,8 @@ interface PlaylistsPresenter : Presenter<PlaylistView> {
|
|||
|
||||
override fun playlists() {
|
||||
launch {
|
||||
when (val result = repository.allPlaylists()) {
|
||||
is Result.Success -> withContext(Dispatchers.Main) { view?.playlists(result.data) }
|
||||
is Result.Error -> withContext(Dispatchers.Main) { view?.showEmptyView() }
|
||||
}
|
||||
val result = repository.allPlaylists()
|
||||
view?.playlists(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,15 +14,16 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.Result.Error
|
||||
import code.name.monkey.retromusic.Result.Success
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
|
@ -48,10 +49,8 @@ interface PlaylistSongsPresenter : Presenter<PlaylistSongsView> {
|
|||
|
||||
override fun loadPlaylistSongs(playlist: Playlist) {
|
||||
launch {
|
||||
when (val songs = repository.getPlaylistSongs(playlist)) {
|
||||
is Success -> withContext(Dispatchers.Main) { view?.songs(songs.data) }
|
||||
is Error -> withContext(Dispatchers.Main) { view?.showEmptyView() }
|
||||
}
|
||||
val songs = repository.getPlaylistSongs(playlist)
|
||||
view?.songs(songs)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,13 +14,14 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.Result.Error
|
||||
import code.name.monkey.retromusic.Result.Success
|
||||
import code.name.monkey.retromusic.mvp.BaseView
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
|
@ -53,10 +54,8 @@ interface SearchPresenter : Presenter<SearchView> {
|
|||
|
||||
override fun search(query: String?) {
|
||||
launch {
|
||||
when (val result = repository.search(query)) {
|
||||
is Success -> withContext(Dispatchers.Main) { view?.showData(result.data) }
|
||||
is Error -> withContext(Dispatchers.Main) { view?.showEmptyView() }
|
||||
}
|
||||
val result = repository.search(query)
|
||||
view?.showData(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,12 +14,14 @@
|
|||
|
||||
package code.name.monkey.retromusic.mvp.presenter
|
||||
|
||||
import code.name.monkey.retromusic.Result
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.Presenter
|
||||
import code.name.monkey.retromusic.mvp.PresenterImpl
|
||||
import code.name.monkey.retromusic.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
|
@ -48,10 +50,8 @@ interface SongPresenter : Presenter<SongView> {
|
|||
|
||||
override fun loadSongs() {
|
||||
launch {
|
||||
when (val songs = repository.allSongs()) {
|
||||
is Result.Success -> withContext(Dispatchers.Main) { view?.songs(songs.data) }
|
||||
is Result.Error -> withContext(Dispatchers.Main) { view?.showEmptyView() }
|
||||
}
|
||||
val songs = repository.allSongs()
|
||||
view?.songs(songs)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ package code.name.monkey.retromusic.preferences
|
|||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import androidx.core.graphics.BlendModeColorFilterCompat
|
||||
|
|
|
@ -23,13 +23,10 @@ import androidx.core.graphics.BlendModeColorFilterCompat
|
|||
import androidx.core.graphics.BlendModeCompat.SRC_IN
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceDialogFragmentCompat
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.WhichButton
|
||||
import com.afollestad.materialdialogs.actions.getActionButton
|
||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class MaterialListPreference @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
@ -72,30 +69,31 @@ class MaterialListPreferenceDialog : PreferenceDialogFragmentCompat() {
|
|||
val entries = arguments?.getStringArrayList(EXTRA_ENTRIES)
|
||||
val entriesValues = arguments?.getStringArrayList(EXTRA_ENTRIES_VALUES)
|
||||
val position: Int = arguments?.getInt(EXTRA_POSITION) ?: 0
|
||||
materialDialog = MaterialDialog(requireContext())
|
||||
.title(text = materialListPreference.title.toString())
|
||||
.positiveButton(R.string.set)
|
||||
.listItemsSingleChoice(
|
||||
items = entries,
|
||||
initialSelection = position,
|
||||
waitForPositiveButton = true
|
||||
) { _, index, _ ->
|
||||
entriesValues?.let {
|
||||
materialListPreference.callChangeListener(it[index])
|
||||
materialListPreference.setCustomValue(it[index])
|
||||
}
|
||||
entries?.let {
|
||||
materialListPreference.summary = it[index]
|
||||
val value = materialListPreference.entryValues[index].toString()
|
||||
if (materialListPreference.callChangeListener(value)) {
|
||||
materialListPreference.value = value
|
||||
}
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
materialDialog.getActionButton(WhichButton.POSITIVE)
|
||||
.updateTextColor(ThemeStore.accentColor(requireContext()))
|
||||
return materialDialog
|
||||
/* materialDialog = MaterialDialog(requireContext())
|
||||
.title(text = materialListPreference.title.toString())
|
||||
.positiveButton(R.string.set)
|
||||
.listItemsSingleChoice(
|
||||
items = entries,
|
||||
initialSelection = position,
|
||||
waitForPositiveButton = true
|
||||
) { _, index, _ ->
|
||||
entriesValues?.let {
|
||||
materialListPreference.callChangeListener(it[index])
|
||||
materialListPreference.setCustomValue(it[index])
|
||||
}
|
||||
entries?.let {
|
||||
materialListPreference.summary = it[index]
|
||||
val value = materialListPreference.entryValues[index].toString()
|
||||
if (materialListPreference.callChangeListener(value)) {
|
||||
materialListPreference.value = value
|
||||
}
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
materialDialog.getActionButton(WhichButton.POSITIVE)
|
||||
.updateTextColor(ThemeStore.accentColor(requireContext()))
|
||||
return materialDialog*/
|
||||
return MaterialAlertDialogBuilder(requireContext()).create()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
|
|
@ -16,9 +16,6 @@ package code.name.monkey.retromusic.providers
|
|||
|
||||
import android.content.Context
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.Result
|
||||
import code.name.monkey.retromusic.Result.Error
|
||||
import code.name.monkey.retromusic.Result.Success
|
||||
import code.name.monkey.retromusic.adapter.HomeAdapter
|
||||
import code.name.monkey.retromusic.loaders.*
|
||||
import code.name.monkey.retromusic.model.*
|
||||
|
@ -26,268 +23,114 @@ import code.name.monkey.retromusic.providers.interfaces.Repository
|
|||
import code.name.monkey.retromusic.rest.LastFmClient
|
||||
import code.name.monkey.retromusic.rest.model.LastFmAlbum
|
||||
import code.name.monkey.retromusic.rest.model.LastFmArtist
|
||||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
|
||||
class RepositoryImpl @Inject constructor(private val context: Context) : Repository {
|
||||
|
||||
override suspend fun allAlbums(): Result<ArrayList<Album>> {
|
||||
return try {
|
||||
val albums = AlbumLoader.getAllAlbums(context)
|
||||
if (albums.isNotEmpty()) {
|
||||
Success(albums)
|
||||
} else {
|
||||
Error(Throwable("No items found"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
override suspend fun allAlbums(): List<Album> = AlbumLoader.getAllAlbums(context)
|
||||
|
||||
override suspend fun allArtists(): List<Artist> = ArtistLoader.getAllArtists(context)
|
||||
|
||||
override suspend fun allPlaylists(): List<Playlist> = PlaylistLoader.getAllPlaylists(context)
|
||||
|
||||
override suspend fun allGenres(): List<Genre> = GenreLoader.getAllGenres(context)
|
||||
|
||||
override suspend fun allSongs(): List<Song> = SongLoader.getAllSongs(context)
|
||||
|
||||
override suspend fun albumById(albumId: Int): Album = AlbumLoader.getAlbum(context, albumId)
|
||||
|
||||
override suspend fun artistById(artistId: Int): Artist =
|
||||
ArtistLoader.getArtist(context, artistId)
|
||||
|
||||
override suspend fun search(query: String?): MutableList<Any> =
|
||||
SearchLoader.searchAll(context, query)
|
||||
|
||||
override suspend fun getPlaylistSongs(playlist: Playlist): ArrayList<Song> {
|
||||
return if (playlist is AbsCustomPlaylist) {
|
||||
playlist.getSongs(context)
|
||||
} else {
|
||||
PlaylistSongsLoader.getPlaylistSongList(context, playlist.id)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun albumById(albumId: Int): Result<Album> {
|
||||
return try {
|
||||
val album = AlbumLoader.getAlbum(context, albumId)
|
||||
if (album != null) {
|
||||
Success(album)
|
||||
} else {
|
||||
Error(Throwable("No album"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
override suspend fun getGenre(genreId: Int): ArrayList<Song> =
|
||||
GenreLoader.getSongs(context, genreId)
|
||||
|
||||
override suspend fun recentArtists(): Home? {
|
||||
val artists = LastAddedSongsLoader.getLastAddedArtists(context)
|
||||
return if (artists.isNotEmpty()) Home(
|
||||
0,
|
||||
R.string.recent_artists,
|
||||
artists,
|
||||
HomeAdapter.RECENT_ARTISTS,
|
||||
R.drawable.ic_artist_white_24dp
|
||||
) else null
|
||||
}
|
||||
|
||||
override suspend fun allArtists(): Result<ArrayList<Artist>> {
|
||||
return try {
|
||||
val artists = ArtistLoader.getAllArtists(context)
|
||||
if (artists.isNotEmpty()) {
|
||||
Success(artists)
|
||||
} else {
|
||||
Error(Throwable("No items found"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
override suspend fun recentAlbums(): Home? {
|
||||
val albums = LastAddedSongsLoader.getLastAddedAlbums(context)
|
||||
return if (albums.isNotEmpty()) {
|
||||
Home(
|
||||
1,
|
||||
R.string.recent_albums,
|
||||
albums,
|
||||
HomeAdapter.RECENT_ALBUMS,
|
||||
R.drawable.ic_album_white_24dp
|
||||
)
|
||||
} else null
|
||||
}
|
||||
|
||||
override suspend fun allPlaylists(): Result<ArrayList<Playlist>> {
|
||||
return try {
|
||||
val playlists = PlaylistLoader.getAllPlaylists(context)
|
||||
if (playlists.isNotEmpty()) {
|
||||
Success(playlists)
|
||||
} else {
|
||||
Error(Throwable("No items found"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
override suspend fun topAlbums(): Home? {
|
||||
val albums = TopAndRecentlyPlayedTracksLoader.getTopAlbums(context)
|
||||
return if (albums.isNotEmpty()) {
|
||||
Home(
|
||||
3,
|
||||
R.string.top_albums,
|
||||
albums,
|
||||
HomeAdapter.TOP_ALBUMS,
|
||||
R.drawable.ic_album_white_24dp
|
||||
)
|
||||
} else null
|
||||
}
|
||||
|
||||
override suspend fun allGenres(): Result<ArrayList<Genre>> {
|
||||
return try {
|
||||
val genres = GenreLoader.getAllGenres(context)
|
||||
if (genres.isNotEmpty()) {
|
||||
Success(genres)
|
||||
} else {
|
||||
Error(Throwable("No items found"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
override suspend fun topArtists(): Home? {
|
||||
|
||||
val artists = TopAndRecentlyPlayedTracksLoader.getTopArtists(context)
|
||||
return if (artists.isNotEmpty()) {
|
||||
Home(
|
||||
2,
|
||||
R.string.top_artists,
|
||||
artists,
|
||||
HomeAdapter.TOP_ARTISTS,
|
||||
R.drawable.ic_artist_white_24dp
|
||||
)
|
||||
} else null
|
||||
|
||||
}
|
||||
|
||||
override suspend fun search(query: String?): Result<MutableList<Any>> {
|
||||
return try {
|
||||
val result = SearchLoader.searchAll(context, query)
|
||||
if (result.isNotEmpty()) {
|
||||
Success(result)
|
||||
} else {
|
||||
Error(Throwable("No items found"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun allSongs(): Result<ArrayList<Song>> {
|
||||
return try {
|
||||
val songs = SongLoader.getAllSongs(context)
|
||||
if (songs.isEmpty()) {
|
||||
Error(Throwable("No items found"))
|
||||
} else {
|
||||
Success(songs)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getPlaylistSongs(playlist: Playlist): Result<ArrayList<Song>> {
|
||||
return try {
|
||||
val songs: ArrayList<Song> = if (playlist is AbsCustomPlaylist) {
|
||||
playlist.getSongs(context)
|
||||
} else {
|
||||
PlaylistSongsLoader.getPlaylistSongList(context, playlist.id)
|
||||
}
|
||||
Success(songs)
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getGenre(genreId: Int): Result<ArrayList<Song>> {
|
||||
return try {
|
||||
val songs = GenreLoader.getSongs(context, genreId)
|
||||
if (songs.isEmpty()) {
|
||||
Error(Throwable("No items found"))
|
||||
} else {
|
||||
Success(songs)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun recentArtists(): Result<Home> {
|
||||
return try {
|
||||
val artists = LastAddedSongsLoader.getLastAddedArtists(context)
|
||||
if (artists.isEmpty()) {
|
||||
Error(Throwable("No items found"))
|
||||
} else {
|
||||
Success(
|
||||
Home(
|
||||
0,
|
||||
R.string.recent_artists,
|
||||
artists,
|
||||
HomeAdapter.RECENT_ARTISTS,
|
||||
R.drawable.ic_artist_white_24dp
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun recentAlbums(): Result<Home> {
|
||||
return try {
|
||||
val albums = LastAddedSongsLoader.getLastAddedAlbums(context)
|
||||
if (albums.isEmpty()) {
|
||||
Error(Throwable("No items found"))
|
||||
} else {
|
||||
Success(
|
||||
Home(
|
||||
1,
|
||||
R.string.recent_albums,
|
||||
albums,
|
||||
HomeAdapter.RECENT_ALBUMS,
|
||||
R.drawable.ic_album_white_24dp
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun topAlbums(): Result<Home> {
|
||||
return try {
|
||||
val albums = TopAndRecentlyPlayedTracksLoader.getTopAlbums(context)
|
||||
if (albums.isEmpty()) {
|
||||
Error(Throwable("No items found"))
|
||||
} else {
|
||||
Success(
|
||||
Home(
|
||||
3,
|
||||
R.string.top_albums,
|
||||
albums,
|
||||
HomeAdapter.TOP_ALBUMS,
|
||||
R.drawable.ic_album_white_24dp
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun topArtists(): Result<Home> {
|
||||
return try {
|
||||
val artists = TopAndRecentlyPlayedTracksLoader.getTopArtists(context)
|
||||
if (artists.isEmpty()) {
|
||||
Error(Throwable("No items found"))
|
||||
} else {
|
||||
Success(
|
||||
Home(
|
||||
2,
|
||||
R.string.top_artists,
|
||||
artists,
|
||||
HomeAdapter.TOP_ARTISTS,
|
||||
R.drawable.ic_artist_white_24dp
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun favoritePlaylist(): Result<Home> {
|
||||
return try {
|
||||
val playlists = PlaylistLoader.getFavoritePlaylist(context)
|
||||
if (playlists.isEmpty()) {
|
||||
Error(Throwable("No items found"))
|
||||
} else {
|
||||
Success(
|
||||
Home(
|
||||
4,
|
||||
R.string.favorites,
|
||||
playlists,
|
||||
HomeAdapter.PLAYLISTS,
|
||||
R.drawable.ic_favorite_white_24dp
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Error(e)
|
||||
}
|
||||
override suspend fun favoritePlaylist(): Home? {
|
||||
val playlists = PlaylistLoader.getFavoritePlaylist(context)
|
||||
return if (playlists.isNotEmpty()) {
|
||||
Home(
|
||||
4,
|
||||
R.string.favorites,
|
||||
playlists,
|
||||
HomeAdapter.PLAYLISTS,
|
||||
R.drawable.ic_favorite_white_24dp
|
||||
)
|
||||
} else null
|
||||
}
|
||||
|
||||
override suspend fun artistInfo(
|
||||
name: String,
|
||||
lang: String?,
|
||||
cache: String?
|
||||
): Result<LastFmArtist> = safeApiCall(
|
||||
call = {
|
||||
Success(LastFmClient.getApiService().artistInfo(name, lang, cache))
|
||||
},
|
||||
errorMessage = "Error"
|
||||
): LastFmArtist = LastFmClient.getApiService().artistInfo(name, lang, cache)
|
||||
|
||||
)
|
||||
|
||||
override suspend fun albumInfo(
|
||||
artist: String,
|
||||
album: String
|
||||
): Result<LastFmAlbum> = safeApiCall(
|
||||
call = {
|
||||
Success(LastFmClient.getApiService().albumInfo(artist, album))
|
||||
},
|
||||
errorMessage = "Error"
|
||||
)
|
||||
): LastFmAlbum = LastFmClient.getApiService().albumInfo(artist, album)
|
||||
|
||||
override suspend fun artistById(artistId: Int): Result<Artist> {
|
||||
return try {
|
||||
val artist = ArtistLoader.getArtist(context, artistId)
|
||||
return Success(artist)
|
||||
} catch (e: Exception) {
|
||||
Error(Throwable("Error loading artist"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun <T : Any> safeApiCall(call: suspend () -> Result<T>, errorMessage: String): Result<T> =
|
||||
try {
|
||||
call.invoke()
|
||||
} catch (e: Exception) {
|
||||
Error(IOException(errorMessage, e))
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
package code.name.monkey.retromusic.providers.interfaces
|
||||
|
||||
import code.name.monkey.retromusic.Result
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.rest.model.LastFmAlbum
|
||||
import code.name.monkey.retromusic.rest.model.LastFmArtist
|
||||
|
@ -25,37 +24,37 @@ import code.name.monkey.retromusic.rest.model.LastFmArtist
|
|||
|
||||
interface Repository {
|
||||
|
||||
suspend fun allAlbums(): Result<ArrayList<Album>>
|
||||
suspend fun allAlbums(): List<Album>
|
||||
|
||||
suspend fun albumById(albumId: Int): Result<Album>
|
||||
suspend fun albumById(albumId: Int): Album
|
||||
|
||||
suspend fun allSongs(): Result<ArrayList<Song>>
|
||||
suspend fun allSongs(): List<Song>
|
||||
|
||||
suspend fun allArtists(): Result<ArrayList<Artist>>
|
||||
suspend fun allArtists(): List<Artist>
|
||||
|
||||
suspend fun allPlaylists(): Result<ArrayList<Playlist>>
|
||||
suspend fun allPlaylists(): List<Playlist>
|
||||
|
||||
suspend fun allGenres(): Result<ArrayList<Genre>>
|
||||
suspend fun allGenres(): List<Genre>
|
||||
|
||||
suspend fun search(query: String?): Result<MutableList<Any>>
|
||||
suspend fun search(query: String?): MutableList<Any>
|
||||
|
||||
suspend fun getPlaylistSongs(playlist: Playlist): Result<ArrayList<Song>>
|
||||
suspend fun getPlaylistSongs(playlist: Playlist): ArrayList<Song>
|
||||
|
||||
suspend fun getGenre(genreId: Int): Result<ArrayList<Song>>
|
||||
suspend fun getGenre(genreId: Int): ArrayList<Song>
|
||||
|
||||
suspend fun recentArtists(): Result<Home>
|
||||
suspend fun recentArtists(): Home?
|
||||
|
||||
suspend fun topArtists(): Result<Home>
|
||||
suspend fun topArtists(): Home?
|
||||
|
||||
suspend fun topAlbums(): Result<Home>
|
||||
suspend fun topAlbums(): Home?
|
||||
|
||||
suspend fun recentAlbums(): Result<Home>
|
||||
suspend fun recentAlbums(): Home?
|
||||
|
||||
suspend fun favoritePlaylist(): Result<Home>
|
||||
suspend fun favoritePlaylist(): Home?
|
||||
|
||||
suspend fun artistInfo(name: String, lang: String?, cache: String?): Result<LastFmArtist>
|
||||
suspend fun artistInfo(name: String, lang: String?, cache: String?): LastFmArtist
|
||||
|
||||
suspend fun albumInfo(artist: String, album: String): Result<LastFmAlbum>
|
||||
suspend fun albumInfo(artist: String, album: String): LastFmAlbum
|
||||
|
||||
suspend fun artistById(artistId: Int): Result<Artist>
|
||||
suspend fun artistById(artistId: Int): Artist
|
||||
}
|
|
@ -17,12 +17,9 @@ package code.name.monkey.retromusic.util
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import code.name.monkey.retromusic.R
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.WhichButton
|
||||
import com.afollestad.materialdialogs.actions.getActionButton
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
object AppRater {
|
||||
private const val DO_NOT_SHOW_AGAIN = "do_not_show_again"// Package Name
|
||||
|
@ -64,30 +61,24 @@ object AppRater {
|
|||
}
|
||||
|
||||
private fun showRateDialog(context: Context, editor: SharedPreferences.Editor) {
|
||||
MaterialDialog(context)
|
||||
.show {
|
||||
title(text = "Rate this App")
|
||||
message(text = "If you enjoy using Retro Music, please take a moment to rate it. Thanks for your support!")
|
||||
positiveButton(R.string.app_name) {
|
||||
context.startActivity(
|
||||
Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse("market://details?id=${context.packageName}")
|
||||
)
|
||||
MaterialAlertDialogBuilder(context)
|
||||
.setTitle("Rate this App")
|
||||
.setMessage("If you enjoy using Retro Music, please take a moment to rate it. Thanks for your support!")
|
||||
.setPositiveButton(R.string.app_name) { _, _ ->
|
||||
context.startActivity(
|
||||
Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse("market://details?id=${context.packageName}")
|
||||
)
|
||||
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
|
||||
editor.commit()
|
||||
dismiss()
|
||||
}
|
||||
negativeButton(text = "Later") {
|
||||
dismiss()
|
||||
}
|
||||
neutralButton(text = " No thanks") {
|
||||
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
|
||||
editor.commit()
|
||||
dismiss()
|
||||
}
|
||||
getActionButton(WhichButton.POSITIVE).updateTextColor(Color.RED)
|
||||
)
|
||||
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
|
||||
editor.commit()
|
||||
}
|
||||
.setNeutralButton("Not now", null)
|
||||
.setNegativeButton("No thanks") { _, _ ->
|
||||
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
|
||||
editor.commit()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.activities.AboutActivity;
|
||||
import code.name.monkey.retromusic.activities.AlbumDetailsActivity;
|
||||
import code.name.monkey.retromusic.activities.albums.AlbumDetailsActivity;
|
||||
import code.name.monkey.retromusic.activities.ArtistDetailActivity;
|
||||
import code.name.monkey.retromusic.activities.DriveModeActivity;
|
||||
import code.name.monkey.retromusic.activities.GenreDetailsActivity;
|
||||
|
|
|
@ -23,10 +23,11 @@ import android.provider.BaseColumns
|
|||
import android.provider.MediaStore
|
||||
import android.provider.Settings
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil.getSongFileUri
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class RingtoneManager(val context: Context) {
|
||||
fun setRingtone(song: Song) {
|
||||
|
@ -72,17 +73,17 @@ class RingtoneManager(val context: Context) {
|
|||
return false
|
||||
}
|
||||
|
||||
fun getDialog(context: Context): MaterialDialog {
|
||||
return MaterialDialog(context).show {
|
||||
title(R.string.dialog_title_set_ringtone)
|
||||
message(R.string.dialog_message_set_ringtone)
|
||||
positiveButton(android.R.string.ok) {
|
||||
fun getDialog(context: Context): AlertDialog {
|
||||
return MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.dialog_title_set_ringtone)
|
||||
.setMessage(R.string.dialog_message_set_ringtone)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
val intent = Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS)
|
||||
intent.data = Uri.parse("package:" + context.applicationContext.packageName)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
negativeButton(android.R.string.cancel)
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="511.999"
|
||||
android:viewportHeight="511.999">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M276.503 421.573c5.687-26.889 21.401-49.915 44.245-64.834 19.137-12.495 30.74-29.04 33.555-47.846 3.149-21.04-4.592-44.418-23.022-69.629l64.952-64.949-58.682-58.682-65.311 65.315c-24.124-16.967-46.712-24.068-67.286-21.117-18.947 2.72-35.843 14.104-48.864 32.926-15.481 22.39-38.441 37.471-64.657 42.467-25.764 4.921-43.684 12.515-54.784 23.212-23.097 22.258-36.062 54.037-36.506 89.484-0.53 42.25 16.932 85.486 46.71 115.656 29.794 30.185 72.705 48.286 114.787 48.421 0.162 0.001 0.318 0 0.48 0 35.187-0.001 67.001-12.443 89.616-35.062 11.137-11.137 19.239-29.245 24.767-55.362zm-127.857 1.924c-3.839 0-7.678-1.464-10.607-4.393l-45.276-45.276c-5.858-5.858-5.858-15.355 0-21.213 5.857-5.858 15.355-5.858 21.213 0l45.276 45.276c5.858 5.858 5.858 15.355 0 21.213-2.929 2.929-6.768 4.393-10.606 4.393zm64.261-74.466c-12.827 0-25.653-4.88-35.422-14.641-19.529-19.544-19.527-51.322-0.004-70.847 8.539-8.539 19.875-13.705 31.921-14.547 14.474-1.02 28.658 4.281 38.923 14.547 10.266 10.265 15.567 24.455 14.546 38.932-0.834 12.032-5.999 23.364-14.547 31.911-9.762 9.763-22.59 14.645-35.417 14.645z" />
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M359.067 40.306c-5.858 5.858-5.858 15.355 0 21.213l15.16 15.16-15.485 17.719 58.728 58.728 17.719-15.485 15.159 15.159c2.929 2.929 6.768 4.394 10.607 4.393 3.839 0 7.678-1.464 10.606-4.393 5.858-5.858 5.858-15.355 0-21.213l-13.732-13.732 11.057-9.663 13.036 13.036c2.929 2.929 6.768 4.394 10.607 4.393 3.839 0 7.678-1.464 10.606-4.393 5.858-5.858 5.858-15.355 0-21.213l-11.609-11.609 15.213-13.295c3.127-2.733 4.981-6.64 5.121-10.79 0.139 -4.151-1.448-8.174-4.385-11.11l-48.818-48.818c-2.936-2.937-6.943-4.52-11.11-4.385-4.15 0.14 -8.057 1.994-10.79 5.121l-13.295 15.213-11.609-11.609c-5.858-5.858-15.356-5.858-21.213 0-5.858 5.858-5.858 15.355 0 21.213l13.036 13.036-9.663 11.057-13.733-13.733c-5.858-5.859-15.356-5.859-21.213 0z" />
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M232.945 300.364c0.332-4.714-1.009-9.354-3.732-13.136-0.628-0.873-1.33-1.7-2.102-2.472-3.781-3.782-8.89-5.884-14.193-5.884-0.47 0-0.941 0.017 -1.414 0.05 -4.84 0.338 -9.386 2.41-12.81 5.833-7.831 7.832-7.829 20.582 0.004 28.421 7.832 7.826 20.581 7.828 28.413-0.004 3.431-3.43 5.502-7.969 5.832-12.782 0.001 -0.008 0.002 -0.017 0.002 -0.026z" />
|
||||
</vector>
|
|
@ -15,13 +15,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="512"
|
||||
android:viewportHeight="512">
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M511.861 64.321c0.139-4.151-1.448-8.174-4.385-11.11l-48.817-48.818c-2.936-2.937-6.943-4.521-11.11-4.385-4.15 0.14 -8.058 1.994-10.791 5.121l-13.295 15.213-11.608-11.609c-5.857-5.858-15.355-5.858-21.213 0s-5.858 15.355 0 21.213l13.036 13.036-9.663 11.057-13.733-13.733c-5.857-5.858-15.355-5.858-21.213 0s-5.858 15.355 0 21.213l15.16 15.16-102.024 104.305c-22.898-16.082-44.302-23.315-63.925-21.541-20.337 1.838-38.384 13.358-52.188 33.316-15.486 22.389-38.447 37.472-64.653 42.47-25.751 4.912-43.671 12.503-54.782 23.208-23.1 22.254-36.067 54.03-36.514 89.476-0.533 42.25 16.928 85.488 46.708 115.66 29.792 30.185 72.7 48.289 114.779 48.426 0.165 0 0.327 0.001 0.49 0.001 35.188 0 66.999-12.441 89.618-35.06 11.143-11.143 19.245-29.252 24.77-55.363 5.69-26.892 21.404-49.917 44.248-64.835 20.106-13.129 31.83-30.629 33.904-50.607 2.139-20.603-5.537-42.685-23.346-66.899l103.876-101.595 15.16 15.159c2.929 2.929 6.768 4.394 10.606 4.394s7.678-1.464 10.606-4.394c5.858-5.858 5.858-15.355 0-21.213l-13.732-13.732 11.057-9.663 13.036 13.036c2.929 2.929 6.768 4.394 10.606 4.394s7.678-1.464 10.606-4.394c5.858-5.858 5.858-15.355 0-21.213l-11.609-11.609 15.213-13.295c3.128-2.733 4.982-6.64 5.122-10.79zm-187.042 238.716c-1.125 10.834-8.011 20.452-20.468 28.587-29.538 19.289-49.85 49.029-57.195 83.743-5.54 26.185-12.798 36.526-16.632 40.359-17.032 17.032-41.486 26.318-68.797 26.273-34.262-0.113-69.225-14.879-93.526-39.5-24.267-24.587-38.495-59.805-38.062-94.209 0.345 -27.364 10.051-51.602 27.331-68.249 3.767-3.629 13.918-10.448 39.588-15.344 33.986-6.481 63.713-25.969 83.705-54.872 8.701-12.58 18.868-19.479 30.216-20.504 1.046-0.094 2.111-0.142 3.193-0.142 10.609 0 22.904 4.54 36.463 13.373l-47.245 47.245c-9.497 1.824-18.565 6.404-25.904 13.742-19.531 19.531-19.531 51.311 0 70.841 9.766 9.766 22.593 14.648 35.421 14.648s25.655-4.883 35.421-14.648c7.338-7.339 11.918-16.406 13.742-25.904l47.701-47.701c11.128 16.162 16.272 30.472 15.048 42.262zm-97.704-18.283c7.834 7.834 7.834 20.582 0 28.416-7.835 7.834-20.581 7.834-28.416 0-7.834-7.834-7.834-20.581 0-28.416 3.918-3.917 9.062-5.875 14.208-5.875 5.145-0.001 10.291 1.958 14.208 5.875zm28.388-12.135c-1.996-3.227-4.378-6.282-7.175-9.078-2.797-2.797-5.851-5.179-9.079-7.175l130.124-130.124 16.254 16.254zm152.027-150.647-17.633-17.633 58.893-67.389 26.129 26.129z" />
|
||||
<path
|
||||
android:fillColor="@color/md_white_1000"
|
||||
android:pathData="M113.978 352.615c-5.857-5.858-15.355-5.858-21.213 0s-5.858 15.355 0 21.213l45.276 45.276c2.929 2.929 6.768 4.394 10.606 4.394s7.678-1.464 10.606-4.394c5.858-5.858 5.858-15.355 0-21.213z" />
|
||||
android:pathData="M19.59,3H22V5H20.41L16.17,9.24C15.8,8.68 15.32,8.2 14.76,7.83L19.59,3M12,8A4,4 0 0,1 16,12C16,13.82 14.77,15.42 13,15.87V16A5,5 0 0,1 8,21A5,5 0 0,1 3,16A5,5 0 0,1 8,11H8.13C8.58,9.24 10.17,8 12,8M12,10.5A1.5,1.5 0 0,0 10.5,12A1.5,1.5 0 0,0 12,13.5A1.5,1.5 0 0,0 13.5,12A1.5,1.5 0 0,0 12,10.5M6.94,14.24L6.23,14.94L9.06,17.77L9.77,17.06L6.94,14.24Z" />
|
||||
</vector>
|
|
@ -48,7 +48,7 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:transitionName="@string/transition_album_art"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardElevation="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/container"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:transitionName="@string/transition_artist_image"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardElevation="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/container"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="156dp"
|
||||
android:layout_margin="8dp"
|
||||
app:cardCornerRadius="16dp">
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/image"
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="256dp"
|
||||
android:layout_margin="8dp"
|
||||
app:cardCornerRadius="16dp">
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/image"
|
||||
|
|
|
@ -22,11 +22,13 @@
|
|||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorSurface"
|
||||
app:liftOnScroll="true">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Toolbar"
|
||||
android:background="?attr/colorSurface"
|
||||
app:layout_collapseMode="pin"
|
||||
app:navigationIcon="@drawable/ic_keyboard_backspace_black_24dp"
|
||||
app:title="@string/action_about"
|
||||
|
@ -36,9 +38,9 @@
|
|||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/container"
|
||||
android:overScrollMode="never"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="never"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<include layout="@layout/activity_about_content" />
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:transitionName="@string/transition_album_art"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardElevation="0dp"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:transitionName="@string/transition_artist_image"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardElevation="0dp"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
@ -74,7 +74,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic[16]" />
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
@ -94,7 +94,7 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/artistCoverContainer"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:text="Title" />
|
||||
tools:text="@tools:sample/full_names" />
|
||||
|
||||
<code.name.monkey.retromusic.views.BaselineGridTextView
|
||||
android:id="@+id/text"
|
||||
|
@ -109,7 +109,7 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/artistTitle"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:text="Title" />
|
||||
tools:text="@tools:sample/full_names" />
|
||||
|
||||
<include
|
||||
layout="@layout/activity_artist_content"
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="@dimen/about_card_radius"
|
||||
app:cardUseCompatPadding="true">
|
||||
android:layout_margin="4dp"
|
||||
app:cardCornerRadius="@dimen/about_card_radius">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<code.name.monkey.appthemehelper.common.views.ATEAccentTextView
|
||||
android:id="@+id/sb1"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -36,7 +36,9 @@
|
|||
android:overScrollMode="never"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/sb1" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/sb1"
|
||||
tools:itemCount="3"
|
||||
tools:listitem="@layout/item_contributor" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
|
@ -3,8 +3,8 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="@dimen/about_card_radius"
|
||||
app:cardUseCompatPadding="true">
|
||||
android:layout_margin="4dp"
|
||||
app:cardCornerRadius="@dimen/about_card_radius">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="@dimen/about_card_radius"
|
||||
app:cardUseCompatPadding="true">
|
||||
android:layout_margin="4dp"
|
||||
app:cardCornerRadius="@dimen/about_card_radius">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/nameContainer"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:startIconDrawable="@drawable/ic_account_white_24dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/nameText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/my_name"
|
||||
android:inputType="text|textCapWords"
|
||||
android:maxLines="1" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/amountContainer"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/nameContainer"
|
||||
app:startIconDrawable="@drawable/ic_currency_inr_white_24dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/amountText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/amount"
|
||||
android:inputType="numberDecimal"
|
||||
android:maxLines="1" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/noteContainer"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
app:hintEnabled="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/amountContainer"
|
||||
app:startIconDrawable="@drawable/ic_edit_white_24dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/noteText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/note"
|
||||
android:inputType="text|textCapWords"
|
||||
android:maxLines="1" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/submit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/start_payment"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/noteContainer" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -12,8 +12,8 @@
|
|||
android:layout_width="112dp"
|
||||
android:layout_height="156dp"
|
||||
android:layout_margin="8dp"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="4dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="0dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
@ -41,5 +41,5 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageContainer"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
tools:text="@tools:sample/full_names" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -17,7 +17,8 @@
|
|||
android:layout_width="128dp"
|
||||
android:layout_height="128dp"
|
||||
android:layout_margin="4dp"
|
||||
app:cardCornerRadius="16dp">
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/paletteColorContainer"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
android:layout_margin="8dp"
|
||||
android:background="?attr/rectSelector"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="4dp">
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -32,16 +32,15 @@
|
|||
android:scaleType="centerCrop"
|
||||
app:civ_border="false"
|
||||
app:civ_shadow="false"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:retroCornerSize="21dp"
|
||||
app:srcCompat="@drawable/ic_account_white_24dp"
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic[20]" />
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:textAppearance="@style/TextViewSubtitle1"
|
||||
|
@ -54,9 +53,11 @@
|
|||
|
||||
<code.name.monkey.retromusic.views.BaselineGridTextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/icon"
|
||||
|
@ -64,6 +65,6 @@
|
|||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toEndOf="@id/icon"
|
||||
app:lineHeightHint="24sp"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -10,6 +10,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="0dp"
|
||||
app:contentPadding="12dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
android:layout_height="0dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="0dp"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
android:layout_margin="8dp"
|
||||
android:orientation="vertical"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
android:layout_margin="4dp"
|
||||
android:orientation="vertical"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
app:cardCornerRadius="6dp">
|
||||
app:cardCornerRadius="6dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/image"
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
android:layout_height="0dp"
|
||||
android:layout_margin="8dp"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp"
|
||||
app:layout_constraintDimensionRatio="16:9"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
@ -50,8 +51,8 @@
|
|||
android:paddingTop="6dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="4dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/imageContainer"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
|
@ -63,11 +64,11 @@
|
|||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="16dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:paddingEnd="8dp"
|
||||
android:textAppearance="@style/TextViewSubtitle1"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/text"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
|
|
|
@ -25,5 +25,5 @@
|
|||
android:paddingTop="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textAppearance="@style/TextViewOverline"
|
||||
tools:text="@string/about_settings_summary" />
|
||||
tools:text="@tools:sample/full_names" />
|
||||
</LinearLayout>
|
|
@ -32,7 +32,6 @@
|
|||
</style>
|
||||
|
||||
<style name="Theme.RetroMusic.Base" parent="Theme.MaterialComponents.NoActionBar">
|
||||
<item name="md_color_button_text">@color/md_white_1000</item>
|
||||
<item name="md_background_color">@color/darkColorPrimary</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
|
@ -53,7 +52,6 @@
|
|||
</style>
|
||||
|
||||
<style name="Theme.RetroMusic.Base.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
|
||||
<item name="md_color_button_text">@color/md_black_1000</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
<item name="roundSelector">@drawable/round_selector</item>
|
||||
|
|
|
@ -44,4 +44,11 @@
|
|||
<color name="progress_gray">#FFD8D8D8</color>
|
||||
<color name="progress_gray_dark">#FF383838</color>
|
||||
<color name="default_blue_light">#ff33b5e5</color>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -133,7 +133,9 @@
|
|||
<item name="fontFamily">@font/google_san</item>
|
||||
</style>
|
||||
|
||||
<style name="TextViewNormal" parent="TextAppearance.AppCompat.Body2" />
|
||||
<style name="TextViewNormal" parent="">
|
||||
<item name="android:textSize">14sp</item>
|
||||
</style>
|
||||
|
||||
<style name="TextViewHeadline4" parent="TextAppearance.MaterialComponents.Headline4">
|
||||
<item name="android:fontFamily">@font/google_san</item>
|
||||
|
@ -176,13 +178,11 @@
|
|||
</style>
|
||||
|
||||
<style name="TextViewBody1" parent="TextAppearance.MaterialComponents.Body1">
|
||||
<item name="lineHeightHint">24sp</item>
|
||||
<item name="android:fontFamily">@font/google_san</item>
|
||||
<item name="fontFamily">@font/google_san</item>
|
||||
</style>
|
||||
|
||||
<style name="TextViewBody2" parent="TextAppearance.MaterialComponents.Body2">
|
||||
<item name="lineHeightHint">24sp</item>
|
||||
<item name="android:fontFamily">@font/google_san</item>
|
||||
<item name="fontFamily">@font/google_san</item>
|
||||
</style>
|
||||
|
@ -192,6 +192,7 @@
|
|||
<item name="fontFamily">@font/google_san</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="TopCornerCardView">
|
||||
<item name="cornerFamilyTopLeft">rounded</item>
|
||||
<item name="cornerFamilyTopRight">rounded</item>
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
</style>
|
||||
|
||||
<style name="Theme.RetroMusic.Base" parent="Theme.MaterialComponents.NoActionBar">
|
||||
<item name="md_color_button_text">@color/md_white_1000</item>
|
||||
<item name="md_background_color">@color/darkColorSurface</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="android:windowActivityTransitions">true</item>
|
||||
|
@ -54,7 +53,6 @@
|
|||
</style>
|
||||
|
||||
<style name="Theme.RetroMusic.Base.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
|
||||
<item name="md_color_button_text">@color/md_black_1000</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
<item name="roundSelector">@drawable/round_selector</item>
|
||||
|
@ -67,6 +65,7 @@
|
|||
<item name="windowActionBar">false</item>
|
||||
<item name="materialAlertDialogTheme">@style/MaterialAlertDialogTheme</item>
|
||||
<item name="materialButtonStyle">@style/MaterialButtonTheme</item>
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
app:showSeekBarValue="true" />
|
||||
|
||||
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
android:defaultValue="auto"
|
||||
android:entries="@array/pref_language_names"
|
||||
android:entryValues="@array/pref_language_codes"
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
android:layout="@layout/preference_category_title"
|
||||
android:title="@string/pref_header_general">
|
||||
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
android:defaultValue="auto"
|
||||
android:entries="@array/pref_general_theme_list_titles"
|
||||
android:entryValues="@array/pref_general_theme_list_values"
|
||||
android:key="general_theme"
|
||||
android:layout="@layout/list_item_view"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="@string/pref_title_general_theme"
|
||||
app:icon="@drawable/ic_color_lens_white_24dp" />
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
android:title="@string/pref_title_ignore_media_store_artwork"
|
||||
app:icon="@drawable/ic_image_white_24dp" />
|
||||
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
android:defaultValue="only_wifi"
|
||||
android:entries="@array/pref_auto_download_images_titles"
|
||||
android:entryValues="@array/pref_auto_download_images_values"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
android:title="@string/pref_title_album_cover_style"
|
||||
app:icon="@drawable/ic_image_white_24dp" />
|
||||
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_album_cover_transform_entities"
|
||||
android:entryValues="@array/pref_album_cover_transform_values"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
android:layout="@layout/preference_category_title"
|
||||
app:title="@string/home">
|
||||
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_home_grid_style_list_titles"
|
||||
android:entryValues="@array/pref_home_grid_style_list_values"
|
||||
|
@ -36,7 +36,7 @@
|
|||
android:title="@string/library_categories"
|
||||
app:icon="@drawable/ic_library_music_white_24dp" />
|
||||
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_tab_text_mode_titles"
|
||||
android:entryValues="@array/pref_tab_text_mode_values"
|
||||
|
|
|
@ -31,9 +31,8 @@ dependencies {
|
|||
implementation 'androidx.preference:preference:1.1.0'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
// Used for the list preference classes
|
||||
implementation 'com.afollestad.material-dialogs:core:3.1.1'
|
||||
implementation 'com.afollestad.material-dialogs:input:3.1.1'
|
||||
implementation 'com.afollestad.material-dialogs:color:3.1.1'
|
||||
implementation 'com.afollestad.material-dialogs:bottomsheets:3.1.1'
|
||||
def material_dialog_version = "0.9.6.0"
|
||||
implementation "com.afollestad.material-dialogs:core:$material_dialog_version"
|
||||
implementation "com.afollestad.material-dialogs:commons:$material_dialog_version"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
}
|
||||
|
|
|
@ -4,16 +4,14 @@ import android.annotation.SuppressLint
|
|||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.Color
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.CheckResult
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.annotation.*
|
||||
import androidx.annotation.IntRange
|
||||
import androidx.annotation.StyleRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
|
||||
|
||||
/**
|
||||
* @author Aidan Follestad (afollestad), Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
|
@ -183,7 +181,10 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
|
|||
|
||||
@CheckResult
|
||||
fun prefs(context: Context): SharedPreferences {
|
||||
return context.getSharedPreferences(ThemeStorePrefKeys.CONFIG_PREFS_KEY_DEFAULT, Context.MODE_PRIVATE)
|
||||
return context.getSharedPreferences(
|
||||
ThemeStorePrefKeys.CONFIG_PREFS_KEY_DEFAULT,
|
||||
Context.MODE_PRIVATE
|
||||
)
|
||||
}
|
||||
|
||||
fun markChanged(context: Context) {
|
||||
|
@ -224,12 +225,18 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
|
|||
fun navigationBarColor(context: Context): Int {
|
||||
return if (!coloredNavigationBar(context)) {
|
||||
Color.BLACK
|
||||
} else prefs(context).getInt(ThemeStorePrefKeys.KEY_NAVIGATION_BAR_COLOR, primaryColor(context))
|
||||
} else prefs(context).getInt(
|
||||
ThemeStorePrefKeys.KEY_NAVIGATION_BAR_COLOR,
|
||||
primaryColor(context)
|
||||
)
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
fun coloredStatusBar(context: Context): Boolean {
|
||||
return prefs(context).getBoolean(ThemeStorePrefKeys.KEY_APPLY_PRIMARYDARK_STATUSBAR, true)
|
||||
return prefs(context).getBoolean(
|
||||
ThemeStorePrefKeys.KEY_APPLY_PRIMARYDARK_STATUSBAR,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
|
@ -247,6 +254,42 @@ private constructor(private val mContext: Context) : ThemeStorePrefKeys, ThemeSt
|
|||
return prefs(context).getBoolean(ThemeStorePrefKeys.IS_CONFIGURED_KEY, false)
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
@ColorInt
|
||||
fun textColorPrimary(context: Context): Int {
|
||||
return prefs(context).getInt(
|
||||
ThemeStorePrefKeys.KEY_TEXT_COLOR_PRIMARY,
|
||||
resolveColor(context, android.R.attr.textColorPrimary)
|
||||
)
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
@ColorInt
|
||||
fun textColorPrimaryInverse(context: Context): Int {
|
||||
return prefs(context).getInt(
|
||||
ThemeStorePrefKeys.KEY_TEXT_COLOR_PRIMARY_INVERSE,
|
||||
resolveColor(context, android.R.attr.textColorPrimaryInverse)
|
||||
)
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
@ColorInt
|
||||
fun textColorSecondary(context: Context): Int {
|
||||
return prefs(context).getInt(
|
||||
ThemeStorePrefKeys.KEY_TEXT_COLOR_SECONDARY,
|
||||
resolveColor(context, android.R.attr.textColorSecondary)
|
||||
)
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
@ColorInt
|
||||
fun textColorSecondaryInverse(context: Context): Int {
|
||||
return prefs(context).getInt(
|
||||
ThemeStorePrefKeys.KEY_TEXT_COLOR_SECONDARY_INVERSE,
|
||||
resolveColor(context, android.R.attr.textColorSecondaryInverse)
|
||||
)
|
||||
}
|
||||
|
||||
@SuppressLint("CommitPrefEdits")
|
||||
fun isConfigured(
|
||||
context: Context, @IntRange(
|
||||
|
|
|
@ -36,7 +36,6 @@ class ATEColorPreference @JvmOverloads constructor(
|
|||
private var border: Int = 0
|
||||
|
||||
init {
|
||||
layoutResource = R.layout.ate_preference_custom_support
|
||||
widgetLayoutResource = R.layout.ate_preference_color
|
||||
isPersistent = false
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.appthemehelper.common.prefs.supportv7
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.preference.EditTextPreference
|
||||
import code.name.monkey.appthemehelper.R
|
||||
|
||||
class ATEEditTextPreference @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0,
|
||||
defStyleRes: Int = 0
|
||||
) : EditTextPreference(context, attrs, defStyleAttr, defStyleRes) {
|
||||
|
||||
init {
|
||||
layoutResource = R.layout.ate_preference_custom_support
|
||||
}
|
||||
}
|
|
@ -16,7 +16,6 @@ package code.name.monkey.appthemehelper.common.prefs.supportv7
|
|||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.preference.ListPreference
|
||||
import code.name.monkey.appthemehelper.R.layout
|
||||
|
||||
class ATEListPreference @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
@ -26,7 +25,6 @@ class ATEListPreference @JvmOverloads constructor(
|
|||
) : ListPreference(context, attrs, defStyleAttr, defStyleRes) {
|
||||
|
||||
init {
|
||||
layoutResource = layout.ate_preference_custom_support
|
||||
if (summary == null || summary.toString().trim { it <= ' ' }.isEmpty()) {
|
||||
summary = "%s"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package code.name.monkey.appthemehelper.common.prefs.supportv7;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs.ATEListPreferenceDialogFragmentCompat;
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs.ATEPreferenceDialogFragment;
|
||||
|
||||
import static androidx.preference.PreferenceFragmentCompat.*;
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public abstract class ATEPreferenceFragmentCompat extends PreferenceFragmentCompat {
|
||||
@Override
|
||||
public void onDisplayPreferenceDialog(Preference preference) {
|
||||
if (getCallbackFragment() instanceof OnPreferenceDisplayDialogCallback) {
|
||||
((OnPreferenceDisplayDialogCallback) getCallbackFragment()).onPreferenceDisplayDialog(this, preference);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.getActivity() instanceof OnPreferenceDisplayDialogCallback) {
|
||||
((OnPreferenceDisplayDialogCallback) this.getActivity()).onPreferenceDisplayDialog(this, preference);
|
||||
return;
|
||||
}
|
||||
|
||||
if (getFragmentManager().findFragmentByTag("androidx.preference.PreferenceFragment.DIALOG") == null) {
|
||||
DialogFragment dialogFragment = onCreatePreferenceDialog(preference);
|
||||
|
||||
if (dialogFragment != null) {
|
||||
dialogFragment.setTargetFragment(this, 0);
|
||||
dialogFragment.show(this.getFragmentManager(), "androidx.preference.PreferenceFragment.DIALOG");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
super.onDisplayPreferenceDialog(preference);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public DialogFragment onCreatePreferenceDialog(Preference preference) {
|
||||
if (preference instanceof ATEListPreference) {
|
||||
return ATEListPreferenceDialogFragmentCompat.newInstance(preference.getKey());
|
||||
} else if (preference instanceof ATEDialogPreference) {
|
||||
return ATEPreferenceDialogFragment.newInstance(preference.getKey());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.appthemehelper.common.prefs.supportv7
|
||||
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs.ATEListPreferenceDialogFragmentCompat
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs.ATEPreferenceDialogFragment
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
abstract class ATEPreferenceFragmentCompat : PreferenceFragmentCompat() {
|
||||
|
||||
override fun onDisplayPreferenceDialog(preference: Preference) {
|
||||
if (callbackFragment is OnPreferenceDisplayDialogCallback) {
|
||||
(callbackFragment as OnPreferenceDisplayDialogCallback).onPreferenceDisplayDialog(this, preference)
|
||||
return
|
||||
}
|
||||
|
||||
if (activity is OnPreferenceDisplayDialogCallback) {
|
||||
(activity as OnPreferenceDisplayDialogCallback).onPreferenceDisplayDialog(this, preference)
|
||||
return
|
||||
}
|
||||
|
||||
if (fragmentManager?.findFragmentByTag("android.support.v7.preference.PreferenceFragment.DIALOG") == null) {
|
||||
val dialogFragment = onCreatePreferenceDialog(preference)
|
||||
|
||||
if (dialogFragment != null) {
|
||||
dialogFragment.setTargetFragment(this, 0)
|
||||
dialogFragment.show(fragmentManager!!, "android.support.v7.preference.PreferenceFragment.DIALOG")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
super.onDisplayPreferenceDialog(preference)
|
||||
}
|
||||
|
||||
open fun onCreatePreferenceDialog(preference: Preference): DialogFragment? {
|
||||
if (preference is ATEListPreference) {
|
||||
return ATEListPreferenceDialogFragmentCompat.newInstance(preference.getKey())
|
||||
} else if (preference is ATEDialogPreference) {
|
||||
return ATEPreferenceDialogFragment.newInstance(preference.getKey())
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
package code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs;
|
||||
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.ListPreference;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
@ -25,13 +25,13 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEListPreference;
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-09-03.
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class ATEListPreferenceDialogFragmentCompat extends ATEPreferenceDialogFragment {
|
||||
private static final String TAG = "ATEPreferenceDialog";
|
||||
private int mClickedDialogEntryIndex;
|
||||
|
||||
@NonNull
|
||||
public static ATEListPreferenceDialogFragmentCompat newInstance(@NonNull String key) {
|
||||
public static ATEListPreferenceDialogFragmentCompat newInstance(String key) {
|
||||
final ATEListPreferenceDialogFragmentCompat fragment = new ATEListPreferenceDialogFragmentCompat();
|
||||
final Bundle b = new Bundle(1);
|
||||
b.putString(ARG_KEY, key);
|
||||
|
@ -44,7 +44,7 @@ public class ATEListPreferenceDialogFragmentCompat extends ATEPreferenceDialogFr
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialogBuilder(@NonNull MaterialAlertDialogBuilder builder) {
|
||||
protected void onPrepareDialogBuilder(MaterialAlertDialogBuilder builder) {
|
||||
super.onPrepareDialogBuilder(builder);
|
||||
|
||||
final ListPreference preference = getListPreference();
|
||||
|
@ -55,24 +55,41 @@ public class ATEListPreferenceDialogFragmentCompat extends ATEPreferenceDialogFr
|
|||
}
|
||||
|
||||
mClickedDialogEntryIndex = preference.findIndexOfValue(preference.getValue());
|
||||
builder.setSingleChoiceItems(preference.getEntries(), mClickedDialogEntryIndex, (dialogInterface, i) -> {
|
||||
mClickedDialogEntryIndex = i;
|
||||
builder.setSingleChoiceItems(preference.getEntries(), mClickedDialogEntryIndex, (dialog, which) -> {
|
||||
mClickedDialogEntryIndex = which;
|
||||
onClick(dialog, which);
|
||||
dismiss();
|
||||
});
|
||||
|
||||
builder.setPositiveButton("Ok", null);
|
||||
builder.setNegativeButton("", null);
|
||||
builder.setNeutralButton("", null);
|
||||
/*
|
||||
* The typical interaction for list-based dialogs is to have
|
||||
* click-on-an-item dismiss the dialog instead of the user having to
|
||||
* press 'Ok'.
|
||||
*/
|
||||
builder.setPositiveButton(null, null);
|
||||
builder.setNegativeButton(null, null);
|
||||
builder.setNeutralButton(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialogClosed(boolean positiveResult) {
|
||||
final ListPreference preference = getListPreference();
|
||||
Log.i(TAG, "onDialogClosed: " + positiveResult);
|
||||
if (positiveResult && mClickedDialogEntryIndex >= 0 &&
|
||||
preference.getEntryValues() != null) {
|
||||
String value = preference.getEntryValues()[mClickedDialogEntryIndex].toString();
|
||||
Log.i(TAG, "onDialogClosed: value " + value);
|
||||
if (preference.callChangeListener(value)) {
|
||||
preference.setValue(value);
|
||||
Log.i(TAG, "onDialogClosed: set value ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Log.i(TAG, "onClick: " + which);
|
||||
mClickedDialogEntryIndex = which;
|
||||
super.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
|
||||
}
|
||||
}
|
|
@ -14,16 +14,17 @@
|
|||
|
||||
package code.name.monkey.appthemehelper.common.prefs.supportv7.dialogs;
|
||||
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Window;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.DialogPreference;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
@ -33,10 +34,10 @@ import code.name.monkey.appthemehelper.R;
|
|||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
public class ATEPreferenceDialogFragment extends DialogFragment {
|
||||
|
||||
static final String ARG_KEY = "key";
|
||||
|
||||
public class ATEPreferenceDialogFragment extends DialogFragment implements DialogInterface.OnClickListener {
|
||||
protected static final String ARG_KEY = "key";
|
||||
private static final String TAG = "ATEPreferenceDialog";
|
||||
private int mWhichButtonClicked;
|
||||
private DialogPreference mPreference;
|
||||
|
||||
public static ATEPreferenceDialogFragment newInstance(String key) {
|
||||
|
@ -59,34 +60,27 @@ public class ATEPreferenceDialogFragment extends DialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public DialogPreference getPreference() {
|
||||
return this.mPreference;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
MaterialAlertDialogBuilder materialDialog = new MaterialAlertDialogBuilder(requireActivity(),
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
FragmentActivity context = this.getActivity();
|
||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context,
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert)
|
||||
.setTitle(mPreference.getTitle())
|
||||
.setIcon(mPreference.getIcon())
|
||||
.setMessage(mPreference.getDialogMessage())
|
||||
.setPositiveButton(mPreference.getPositiveButtonText(), (dialogInterface, i) -> {
|
||||
onDialogClosed(true);
|
||||
})
|
||||
.setNegativeButton(mPreference.getNegativeButtonText(), (dialogInterface, i) -> {
|
||||
onDialogClosed(false);
|
||||
});
|
||||
.setTitle(this.mPreference.getDialogTitle())
|
||||
.setIcon(this.mPreference.getDialogIcon())
|
||||
.setMessage(this.mPreference.getDialogMessage())
|
||||
.setPositiveButton(this.mPreference.getPositiveButtonText(), this)
|
||||
.setNegativeButton(this.mPreference.getNegativeButtonText(), this);
|
||||
|
||||
//this.onPrepareDialogBuilder(materialDialog);
|
||||
AlertDialog dialog = materialDialog.create();
|
||||
this.onPrepareDialogBuilder(builder);
|
||||
AlertDialog dialog = builder.create();
|
||||
if (this.needInputMethod()) {
|
||||
this.requestInputMethod(dialog);
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public void onDialogClosed(boolean positiveResult) {
|
||||
|
||||
public DialogPreference getPreference() {
|
||||
return this.mPreference;
|
||||
}
|
||||
|
||||
protected void onPrepareDialogBuilder(MaterialAlertDialogBuilder builder) {
|
||||
|
@ -100,4 +94,22 @@ public class ATEPreferenceDialogFragment extends DialogFragment {
|
|||
Window window = dialog.getWindow();
|
||||
window.setSoftInputMode(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
Log.i(TAG, "onDismiss: " + mWhichButtonClicked);
|
||||
onDialogClosed(mWhichButtonClicked == DialogInterface.BUTTON_POSITIVE);
|
||||
}
|
||||
|
||||
public void onDialogClosed(boolean positiveResult) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Log.i(TAG, "onClick: " + which);
|
||||
mWhichButtonClicked = which;
|
||||
onDialogClosed(which == DialogInterface.BUTTON_POSITIVE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package code.name.monkey.appthemehelper.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil.isWindowBackgroundDark
|
||||
import com.afollestad.materialdialogs.internal.ThemeSingleton
|
||||
|
||||
/**
|
||||
* @author Karim Abou Zeid (kabouzeid)
|
||||
*/
|
||||
object MaterialDialogsUtil {
|
||||
fun updateMaterialDialogsThemeSingleton(context: Context) {
|
||||
val md = ThemeSingleton.get()
|
||||
md.titleColor = ThemeStore.textColorPrimary(context)
|
||||
md.contentColor = ThemeStore.textColorSecondary(context)
|
||||
md.itemColor = md.titleColor
|
||||
md.widgetColor = ThemeStore.accentColor(context)
|
||||
md.linkColor = ColorStateList.valueOf(md.widgetColor)
|
||||
md.positiveColor = ColorStateList.valueOf(md.widgetColor)
|
||||
md.neutralColor = ColorStateList.valueOf(md.widgetColor)
|
||||
md.negativeColor = ColorStateList.valueOf(md.widgetColor)
|
||||
md.darkTheme = isWindowBackgroundDark(context)
|
||||
}
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
package code.name.monkey.appthemehelper.util
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import androidx.appcompat.widget.AppCompatButton
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import com.afollestad.materialdialogs.internal.button.DialogActionButton
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
|
||||
|
@ -54,30 +52,4 @@ object MaterialUtil {
|
|||
textInputLayout.isHintAnimationEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
fun setTint(
|
||||
button: DialogActionButton,
|
||||
color: Int = ThemeStore.accentColor(button.context),
|
||||
background: Boolean = true
|
||||
) {
|
||||
val temp = button as AppCompatButton
|
||||
val context = temp.context
|
||||
val colorState = ColorStateList.valueOf(color)
|
||||
val textColor =
|
||||
ColorStateList.valueOf(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
context,
|
||||
ColorUtil.isColorLight(color)
|
||||
)
|
||||
)
|
||||
|
||||
if (background) {
|
||||
temp.backgroundTintList = colorState
|
||||
temp.setTextColor(textColor)
|
||||
} else {
|
||||
temp.setTextColor(colorState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue