commit
66c9f19ab9
193 changed files with 4451 additions and 4297 deletions
|
@ -13,8 +13,8 @@ android {
|
|||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
applicationId "code.name.monkey.retromusic"
|
||||
versionCode 391
|
||||
versionName '3.4.700'
|
||||
versionCode 392
|
||||
versionName '3.4.800'
|
||||
|
||||
multiDexEnabled true
|
||||
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.RetroMusic.Light"
|
||||
android:theme="@style/Theme.RetroMusic.FollowSystem"
|
||||
android:usesCleartextTraffic="false"
|
||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning"
|
||||
tools:targetApi="m">
|
||||
<activity
|
||||
android:name=".activities.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/SplashTheme">
|
||||
android:theme="@style/SplashTheme"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<action android:name="android.intent.action.MUSIC_PLAYER" />
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,10 +4,12 @@ import android.content.Intent
|
|||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.core.app.ShareCompat
|
||||
import androidx.recyclerview.widget.*
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.Constants.APP_INSTAGRAM_LINK
|
||||
import code.name.monkey.retromusic.Constants.APP_TELEGRAM_LINK
|
||||
import code.name.monkey.retromusic.Constants.APP_TWITTER_LINK
|
||||
|
@ -20,9 +22,12 @@ import code.name.monkey.retromusic.Constants.TRANSLATE
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||
import code.name.monkey.retromusic.adapter.ContributorAdapter
|
||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||
import code.name.monkey.retromusic.model.Contributor
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import com.afollestad.materialdialogs.*
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import com.google.gson.Gson
|
||||
|
@ -37,132 +42,133 @@ import java.nio.charset.StandardCharsets
|
|||
|
||||
class AboutActivity : AbsBaseActivity(), View.OnClickListener {
|
||||
|
||||
private val assetJsonData: String?
|
||||
get() {
|
||||
val json: String
|
||||
try {
|
||||
val inputStream = assets.open("contributors.json")
|
||||
val size = inputStream.available()
|
||||
val buffer = ByteArray(size)
|
||||
inputStream.read(buffer)
|
||||
inputStream.close()
|
||||
json = String(buffer, StandardCharsets.UTF_8)
|
||||
} catch (ex: IOException) {
|
||||
ex.printStackTrace()
|
||||
return null
|
||||
}
|
||||
private val assetJsonData: String?
|
||||
get() {
|
||||
val json: String
|
||||
try {
|
||||
val inputStream = assets.open("contributors.json")
|
||||
val size = inputStream.available()
|
||||
val buffer = ByteArray(size)
|
||||
inputStream.read(buffer)
|
||||
inputStream.close()
|
||||
json = String(buffer, StandardCharsets.UTF_8)
|
||||
} catch (ex: IOException) {
|
||||
ex.printStackTrace()
|
||||
return null
|
||||
}
|
||||
|
||||
return json
|
||||
}
|
||||
return json
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_about)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setLightNavigationBar(true)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_about)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
loadContributors()
|
||||
setSupportActionBar(toolbar)
|
||||
toolbar.apply {
|
||||
setTitleTextColor(ATHUtil.resolveColor(this@AboutActivity, R.attr.colorOnPrimary))
|
||||
setBackgroundColor(ATHUtil.resolveColor(this@AboutActivity, R.attr.colorPrimary))
|
||||
setNavigationOnClickListener { onBackPressed() }
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar)
|
||||
}
|
||||
version.setSummary(getAppVersion())
|
||||
setUpView()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
loadContributors()
|
||||
setSupportActionBar(toolbar)
|
||||
toolbar.apply {
|
||||
setBackgroundColor(surfaceColor(context))
|
||||
setNavigationOnClickListener { onBackPressed() }
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar)
|
||||
}
|
||||
version.setSummary(getAppVersion())
|
||||
setUpView()
|
||||
}
|
||||
|
||||
private fun openUrl(url: String) {
|
||||
val i = Intent(Intent.ACTION_VIEW)
|
||||
i.data = Uri.parse(url)
|
||||
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
startActivity(i)
|
||||
}
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun setUpView() {
|
||||
appGithub.setOnClickListener(this)
|
||||
faqLink.setOnClickListener(this)
|
||||
telegramLink.setOnClickListener(this)
|
||||
appRate.setOnClickListener(this)
|
||||
appTranslation.setOnClickListener(this)
|
||||
appShare.setOnClickListener(this)
|
||||
donateLink.setOnClickListener(this)
|
||||
instagramLink.setOnClickListener(this)
|
||||
twitterLink.setOnClickListener(this)
|
||||
changelog.setOnClickListener(this)
|
||||
openSource.setOnClickListener(this)
|
||||
pinterestLink.setOnClickListener(this)
|
||||
bugReportLink.setOnClickListener(this)
|
||||
private fun openUrl(url: String) {
|
||||
val i = Intent(Intent.ACTION_VIEW)
|
||||
i.data = Uri.parse(url)
|
||||
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
startActivity(i)
|
||||
}
|
||||
|
||||
}
|
||||
private fun setUpView() {
|
||||
appGithub.setOnClickListener(this)
|
||||
faqLink.setOnClickListener(this)
|
||||
telegramLink.setOnClickListener(this)
|
||||
appRate.setOnClickListener(this)
|
||||
appTranslation.setOnClickListener(this)
|
||||
appShare.setOnClickListener(this)
|
||||
donateLink.setOnClickListener(this)
|
||||
instagramLink.setOnClickListener(this)
|
||||
twitterLink.setOnClickListener(this)
|
||||
changelog.setOnClickListener(this)
|
||||
openSource.setOnClickListener(this)
|
||||
pinterestLink.setOnClickListener(this)
|
||||
bugReportLink.setOnClickListener(this)
|
||||
|
||||
override fun onClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.pinterestLink -> openUrl(PINTEREST)
|
||||
R.id.faqLink -> openUrl(FAQ_LINK)
|
||||
R.id.telegramLink -> openUrl(APP_TELEGRAM_LINK)
|
||||
R.id.appGithub -> openUrl(GITHUB_PROJECT)
|
||||
R.id.appTranslation -> openUrl(TRANSLATE)
|
||||
R.id.appRate -> openUrl(RATE_ON_GOOGLE_PLAY)
|
||||
R.id.appShare -> shareApp()
|
||||
R.id.donateLink -> NavigationUtil.goToSupportDevelopment(this)
|
||||
R.id.instagramLink -> openUrl(APP_INSTAGRAM_LINK)
|
||||
R.id.twitterLink -> openUrl(APP_TWITTER_LINK)
|
||||
R.id.changelog -> showChangeLogOptions()
|
||||
R.id.openSource -> NavigationUtil.goToOpenSource(this)
|
||||
R.id.bugReportLink -> NavigationUtil.bugReport(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showChangeLogOptions() {
|
||||
MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
cornerRadius(PreferenceUtil.getInstance(this@AboutActivity).dialogCorner)
|
||||
listItems(items = listOf("Telegram Channel", "App")) { _, position, _ ->
|
||||
if (position == 0) {
|
||||
openUrl(TELEGRAM_CHANGE_LOG)
|
||||
} else {
|
||||
NavigationUtil.gotoWhatNews(this@AboutActivity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun onClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.pinterestLink -> openUrl(PINTEREST)
|
||||
R.id.faqLink -> openUrl(FAQ_LINK)
|
||||
R.id.telegramLink -> openUrl(APP_TELEGRAM_LINK)
|
||||
R.id.appGithub -> openUrl(GITHUB_PROJECT)
|
||||
R.id.appTranslation -> openUrl(TRANSLATE)
|
||||
R.id.appRate -> openUrl(RATE_ON_GOOGLE_PLAY)
|
||||
R.id.appShare -> shareApp()
|
||||
R.id.donateLink -> NavigationUtil.goToSupportDevelopment(this)
|
||||
R.id.instagramLink -> openUrl(APP_INSTAGRAM_LINK)
|
||||
R.id.twitterLink -> openUrl(APP_TWITTER_LINK)
|
||||
R.id.changelog -> showChangeLogOptions()
|
||||
R.id.openSource -> NavigationUtil.goToOpenSource(this)
|
||||
R.id.bugReportLink -> NavigationUtil.bugReport(this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAppVersion(): String {
|
||||
return try {
|
||||
val packageInfo = packageManager.getPackageInfo(packageName, 0)
|
||||
packageInfo.versionName
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
e.printStackTrace()
|
||||
"0.0.0"
|
||||
}
|
||||
}
|
||||
private fun showChangeLogOptions() {
|
||||
MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
cornerRadius(PreferenceUtil.getInstance(this@AboutActivity).dialogCorner)
|
||||
listItems(items = listOf("Telegram Channel", "App")) { _, position, _ ->
|
||||
if (position == 0) {
|
||||
openUrl(TELEGRAM_CHANGE_LOG)
|
||||
} else {
|
||||
NavigationUtil.gotoWhatNews(this@AboutActivity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun shareApp() {
|
||||
ShareCompat.IntentBuilder.from(this).setType("text/plain")
|
||||
.setChooserTitle(R.string.share_app)
|
||||
.setText(String.format(getString(R.string.app_share), packageName)).startChooser()
|
||||
}
|
||||
private fun getAppVersion(): String {
|
||||
return try {
|
||||
val packageInfo = packageManager.getPackageInfo(packageName, 0)
|
||||
packageInfo.versionName
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
e.printStackTrace()
|
||||
"0.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadContributors() {
|
||||
val data = assetJsonData
|
||||
val type = object : TypeToken<List<Contributor>>() {
|
||||
private fun shareApp() {
|
||||
ShareCompat.IntentBuilder.from(this).setType("text/plain")
|
||||
.setChooserTitle(R.string.share_app)
|
||||
.setText(String.format(getString(R.string.app_share), packageName)).startChooser()
|
||||
}
|
||||
|
||||
}.type
|
||||
val contributors = Gson().fromJson<List<Contributor>>(data, type)
|
||||
private fun loadContributors() {
|
||||
val data = assetJsonData
|
||||
val type = object : TypeToken<List<Contributor>>() {
|
||||
|
||||
val contributorAdapter = ContributorAdapter(contributors)
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
recyclerView.itemAnimator = DefaultItemAnimator()
|
||||
recyclerView.adapter = contributorAdapter
|
||||
}
|
||||
}.type
|
||||
val contributors = Gson().fromJson<List<Contributor>>(data, type)
|
||||
|
||||
val contributorAdapter = ContributorAdapter(contributors)
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
recyclerView.itemAnimator = DefaultItemAnimator()
|
||||
recyclerView.adapter = contributorAdapter
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package code.name.monkey.retromusic.activities
|
|||
|
||||
import android.app.ActivityOptions
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
|
@ -15,7 +14,6 @@ import androidx.recyclerview.widget.GridLayoutManager
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -26,6 +24,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.ripAlpha
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.glide.ArtistGlideRequest
|
||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||
|
@ -45,6 +44,7 @@ import com.afollestad.materialcab.MaterialCab
|
|||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.activity_album.*
|
||||
import kotlinx.android.synthetic.main.activity_album_content.*
|
||||
import kotlinx.android.synthetic.main.status_bar.*
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import android.util.Pair as UtilPair
|
||||
|
@ -58,7 +58,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
cab = MaterialCab(this, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorSurface)))
|
||||
.start(callback)
|
||||
return cab as MaterialCab
|
||||
}
|
||||
|
@ -81,11 +81,10 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
toggleBottomNavigationView(true)
|
||||
setStatusbarColor(Color.TRANSPARENT)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
setLightStatusbar(ColorUtil.isColorLight(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
|
||||
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
|
||||
|
@ -189,19 +188,23 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
}
|
||||
|
||||
private fun setColors(color: Int) {
|
||||
val themeColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color
|
||||
val themeColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color.ripAlpha()
|
||||
else ThemeStore.accentColor(this)
|
||||
|
||||
songTitle.setTextColor(themeColor)
|
||||
moreTitle.setTextColor(themeColor)
|
||||
|
||||
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color
|
||||
else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor)
|
||||
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
|
||||
color.ripAlpha()
|
||||
else
|
||||
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||
|
||||
MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
|
||||
MaterialUtil.setTint(button = playAction, color = buttonColor)
|
||||
|
||||
toolbar.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
val toolbarColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||
status_bar.setBackgroundColor(toolbarColor)
|
||||
toolbar.setBackgroundColor(toolbarColor)
|
||||
setSupportActionBar(toolbar)
|
||||
supportActionBar?.title = null
|
||||
}
|
||||
|
@ -244,7 +247,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
R.id.action_tag_editor -> {
|
||||
val intent = Intent(this, AlbumTagEditorActivity::class.java)
|
||||
intent.putExtra(AbsTagEditorActivity.EXTRA_ID, album.id)
|
||||
startActivityForResult(intent, TAG_EDITOR_REQUEST)
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(this, image, getString(R.string.transition_album_art))
|
||||
startActivityForResult(intent, TAG_EDITOR_REQUEST, options.toBundle())
|
||||
return true
|
||||
}
|
||||
/*Sort*/
|
||||
|
|
|
@ -2,7 +2,6 @@ package code.name.monkey.retromusic.activities
|
|||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
|
@ -17,7 +16,6 @@ import androidx.recyclerview.widget.GridLayoutManager
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -26,6 +24,7 @@ import code.name.monkey.retromusic.adapter.album.AlbumAdapter
|
|||
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.ripAlpha
|
||||
import code.name.monkey.retromusic.glide.ArtistGlideRequest
|
||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
|
@ -39,6 +38,7 @@ import com.afollestad.materialcab.MaterialCab
|
|||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.activity_artist_content.*
|
||||
import kotlinx.android.synthetic.main.activity_artist_details.*
|
||||
import kotlinx.android.synthetic.main.status_bar.*
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import kotlin.collections.ArrayList
|
||||
|
@ -51,7 +51,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
cab = MaterialCab(this, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorSurface)))
|
||||
.start(callback)
|
||||
return cab as MaterialCab
|
||||
}
|
||||
|
@ -74,11 +74,10 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
toggleBottomNavigationView(true)
|
||||
setStatusbarColor(Color.TRANSPARENT)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
setLightStatusbar(ColorUtil.isColorLight(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
|
||||
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
|
||||
|
@ -226,21 +225,26 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
}
|
||||
|
||||
private fun setColors(color: Int) {
|
||||
|
||||
val textColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color
|
||||
else ThemeStore.accentColor(this)
|
||||
val textColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
|
||||
color.ripAlpha()
|
||||
else
|
||||
ThemeStore.accentColor(this)
|
||||
|
||||
albumTitle.setTextColor(textColor)
|
||||
songTitle.setTextColor(textColor)
|
||||
biographyTitle.setTextColor(textColor)
|
||||
|
||||
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color
|
||||
else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor)
|
||||
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
|
||||
color.ripAlpha()
|
||||
else
|
||||
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||
|
||||
MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
|
||||
MaterialUtil.setTint(button = playAction, color = buttonColor)
|
||||
|
||||
toolbar.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
val toolbarColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||
status_bar.setBackgroundColor(toolbarColor)
|
||||
toolbar.setBackgroundColor(toolbarColor)
|
||||
setSupportActionBar(toolbar)
|
||||
supportActionBar?.title = null
|
||||
}
|
||||
|
@ -271,21 +275,12 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
R.id.action_set_artist_image -> {
|
||||
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
||||
intent.type = "image/*"
|
||||
startActivityForResult(
|
||||
Intent.createChooser(
|
||||
intent, getString(R.string.pick_from_local_storage)
|
||||
), REQUEST_CODE_SELECT_IMAGE
|
||||
)
|
||||
startActivityForResult(Intent.createChooser(intent, getString(R.string.pick_from_local_storage)), REQUEST_CODE_SELECT_IMAGE)
|
||||
return true
|
||||
}
|
||||
R.id.action_reset_artist_image -> {
|
||||
Toast.makeText(
|
||||
this@ArtistDetailActivity,
|
||||
resources.getString(R.string.updating),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
CustomArtistImageUtil.getInstance(this@ArtistDetailActivity)
|
||||
.resetCustomArtistImage(artist)
|
||||
Toast.makeText(this@ArtistDetailActivity, resources.getString(R.string.updating), Toast.LENGTH_SHORT).show()
|
||||
CustomArtistImageUtil.getInstance(this@ArtistDetailActivity).resetCustomArtistImage(artist)
|
||||
forceDownload = true
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -1,19 +1,25 @@
|
|||
package code.name.monkey.retromusic.activities
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import androidx.recyclerview.widget.*
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.retromusic.*
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
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.adapter.song.ShuffleButtonSongAdapter
|
||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||
import code.name.monkey.retromusic.helper.menu.GenreMenuHelper
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.mvp.presenter.*
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenreDetailsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenreDetailsView
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import kotlinx.android.synthetic.main.activity_playlist_detail.*
|
||||
|
@ -26,127 +32,128 @@ import javax.inject.Inject
|
|||
|
||||
class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDetailsView {
|
||||
|
||||
@Inject
|
||||
lateinit var genreDetailsPresenter: GenreDetailsPresenter
|
||||
@Inject
|
||||
lateinit var genreDetailsPresenter: GenreDetailsPresenter
|
||||
|
||||
private lateinit var genre: Genre
|
||||
private lateinit var songAdapter: ShuffleButtonSongAdapter
|
||||
private var cab: MaterialCab? = null
|
||||
private lateinit var genre: Genre
|
||||
private lateinit var songAdapter: ShuffleButtonSongAdapter
|
||||
private var cab: MaterialCab? = null
|
||||
|
||||
private fun checkIsEmpty() {
|
||||
empty?.visibility = if (songAdapter.itemCount == 0) View.VISIBLE else View.GONE
|
||||
}
|
||||
private fun getEmojiByUnicode(unicode: Int): String {
|
||||
return String(Character.toChars(unicode))
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
private fun checkIsEmpty() {
|
||||
emptyEmoji.text = getEmojiByUnicode(0x1F631)
|
||||
empty?.visibility = if (songAdapter.itemCount == 0) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
setStatusbarColor(Color.TRANSPARENT)
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
setLightStatusbar(ColorUtil.isColorLight(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
|
||||
toggleBottomNavigationView(true)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
toggleBottomNavigationView(true)
|
||||
|
||||
if (intent.extras != null) {
|
||||
genre = intent?.extras?.getParcelable(EXTRA_GENRE_ID)!!
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
if (intent.extras != null) {
|
||||
genre = intent?.extras?.getParcelable(EXTRA_GENRE_ID)!!
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
||||
setUpToolBar()
|
||||
setupRecyclerView()
|
||||
setUpToolBar()
|
||||
setupRecyclerView()
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
genreDetailsPresenter.attachView(this)
|
||||
App.musicComponent.inject(this)
|
||||
genreDetailsPresenter.attachView(this)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUpToolBar() {
|
||||
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
|
||||
appBarLayout.setBackgroundColor(primaryColor)
|
||||
applyToolbar(toolbar)
|
||||
title = genre.name
|
||||
}
|
||||
private fun setUpToolBar() {
|
||||
applyToolbar(toolbar)
|
||||
title = genre.name
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
genreDetailsPresenter.loadGenreSongs(genre.id)
|
||||
}
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
genreDetailsPresenter.loadGenreSongs(genre.id)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
genreDetailsPresenter.detachView()
|
||||
}
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
genreDetailsPresenter.detachView()
|
||||
}
|
||||
|
||||
override fun createContentView(): View {
|
||||
return wrapSlidingMusicPanel(R.layout.activity_playlist_detail)
|
||||
}
|
||||
override fun createContentView(): View {
|
||||
return wrapSlidingMusicPanel(R.layout.activity_playlist_detail)
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
override fun showEmptyView() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_genre_detail, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_genre_detail, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
}
|
||||
return GenreMenuHelper.handleMenuClick(this, genre, item)
|
||||
}
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
}
|
||||
return GenreMenuHelper.handleMenuClick(this, genre, item)
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
ViewUtil.setUpFastScrollRecyclerViewColor(this, recyclerView)
|
||||
songAdapter = ShuffleButtonSongAdapter(this, ArrayList(), R.layout.item_list, false, this)
|
||||
recyclerView.apply {
|
||||
itemAnimator = DefaultItemAnimator()
|
||||
layoutManager = LinearLayoutManager(this@GenreDetailsActivity)
|
||||
adapter = songAdapter
|
||||
}
|
||||
songAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onChanged() {
|
||||
super.onChanged()
|
||||
checkIsEmpty()
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun setupRecyclerView() {
|
||||
ViewUtil.setUpFastScrollRecyclerViewColor(this, recyclerView)
|
||||
songAdapter = ShuffleButtonSongAdapter(this, ArrayList(), R.layout.item_list, false, this)
|
||||
recyclerView.apply {
|
||||
itemAnimator = DefaultItemAnimator()
|
||||
layoutManager = LinearLayoutManager(this@GenreDetailsActivity)
|
||||
adapter = songAdapter
|
||||
}
|
||||
songAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onChanged() {
|
||||
super.onChanged()
|
||||
checkIsEmpty()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun songs(songs: ArrayList<Song>) {
|
||||
songAdapter.swapDataSet(songs)
|
||||
}
|
||||
override fun songs(songs: ArrayList<Song>) {
|
||||
songAdapter.swapDataSet(songs)
|
||||
}
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
if (cab != null && cab!!.isActive) cab!!.finish()
|
||||
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp).setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
ATHUtil.resolveColor(
|
||||
this,
|
||||
R.attr.colorPrimary
|
||||
)
|
||||
)
|
||||
).start(callback)
|
||||
return cab!!
|
||||
}
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
if (cab != null && cab!!.isActive) cab!!.finish()
|
||||
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp).setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
ATHUtil.resolveColor(
|
||||
this,
|
||||
R.attr.colorPrimary
|
||||
)
|
||||
)
|
||||
).start(callback)
|
||||
return cab!!
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (cab != null && cab!!.isActive) cab!!.finish()
|
||||
else {
|
||||
recyclerView!!.stopScroll()
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
override fun onBackPressed() {
|
||||
if (cab != null && cab!!.isActive) cab!!.finish()
|
||||
else {
|
||||
recyclerView!!.stopScroll()
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
super.onMediaStoreChanged()
|
||||
genreDetailsPresenter.loadGenreSongs(genre.id)
|
||||
}
|
||||
override fun onMediaStoreChanged() {
|
||||
super.onMediaStoreChanged()
|
||||
genreDetailsPresenter.loadGenreSongs(genre.id)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val EXTRA_GENRE_ID = "extra_genre_id"
|
||||
}
|
||||
companion object {
|
||||
const val EXTRA_GENRE_ID = "extra_genre_id"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,15 +57,16 @@ public class LicenseActivity extends AbsBaseActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
setDrawUnderStatusBar();
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_license);
|
||||
setStatusbarColorAuto();
|
||||
setNavigationBarColorPrimary();
|
||||
setNavigationbarColorAuto();
|
||||
setLightNavigationBar(true);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar);
|
||||
toolbar.setBackgroundColor(INSTANCE.resolveColor(this, R.attr.colorPrimary));
|
||||
toolbar.setBackgroundColor(INSTANCE.resolveColor(this, R.attr.colorSurface));
|
||||
WebView webView = findViewById(R.id.license);
|
||||
try {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
@ -78,7 +79,7 @@ public class LicenseActivity extends AbsBaseActivity {
|
|||
|
||||
// Inject color values for WebView body background and links
|
||||
final boolean isDark = INSTANCE.isWindowBackgroundDark(this);
|
||||
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.colorPrimary, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, android.R.attr.windowBackground, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
||||
final String changeLog = buf.toString()
|
||||
.replace("{style-placeholder}",
|
||||
|
|
|
@ -34,7 +34,7 @@ class LockScreenActivity : AbsMusicServiceActivity() {
|
|||
|
||||
hideStatusBar()
|
||||
setStatusbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
|
|
|
@ -2,28 +2,44 @@ package code.name.monkey.retromusic.activities
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.*
|
||||
import android.text.*
|
||||
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
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.*
|
||||
import androidx.fragment.app.Fragment
|
||||
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.retromusic.*
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
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.applyToolbar
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
||||
import code.name.monkey.retromusic.helper.*
|
||||
import code.name.monkey.retromusic.lyrics.*
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||
import code.name.monkey.retromusic.lyrics.LrcHelper
|
||||
import code.name.monkey.retromusic.lyrics.LrcView
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.model.lyrics.Lyrics
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import com.afollestad.materialdialogs.*
|
||||
import code.name.monkey.retromusic.util.LyricUtil
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.input.*
|
||||
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.*
|
||||
|
@ -33,393 +49,373 @@ import java.util.*
|
|||
import kotlin.collections.ArrayList
|
||||
|
||||
class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPager.OnPageChangeListener {
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
when (state) {
|
||||
ViewPager.SCROLL_STATE_IDLE -> fab.show()
|
||||
ViewPager.SCROLL_STATE_DRAGGING, ViewPager.SCROLL_STATE_SETTLING -> fab.hide()
|
||||
}
|
||||
}
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
when (state) {
|
||||
ViewPager.SCROLL_STATE_IDLE -> fab.show()
|
||||
ViewPager.SCROLL_STATE_DRAGGING, ViewPager.SCROLL_STATE_SETTLING -> fab.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
}
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
PreferenceUtil.getInstance(this).lyricsOptions = position
|
||||
if (position == 0) fab.text = getString(R.string.synced_lyrics)
|
||||
else if (position == 1) fab.text = getString(R.string.lyrics)
|
||||
}
|
||||
override fun onPageSelected(position: Int) {
|
||||
PreferenceUtil.getInstance(this).lyricsOptions = position
|
||||
if (position == 0) fab.text = getString(R.string.synced_lyrics)
|
||||
else if (position == 1) fab.text = getString(R.string.lyrics)
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
when (viewPager.currentItem) {
|
||||
0 -> showSyncedLyrics()
|
||||
1 -> showLyricsSaveDialog()
|
||||
}
|
||||
}
|
||||
override fun onClick(v: View?) {
|
||||
when (viewPager.currentItem) {
|
||||
0 -> showSyncedLyrics()
|
||||
1 -> showLyricsSaveDialog()
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var song: Song
|
||||
private var lyricsString: String? = null
|
||||
private lateinit var song: Song
|
||||
private var lyricsString: String? = null
|
||||
|
||||
private val googleSearchLrcUrl: String
|
||||
get() {
|
||||
var baseUrl = "http://www.google.com/search?"
|
||||
var query = song.title + "+" + song.artistName
|
||||
query = "q=" + query.replace(" ", "+") + " .lrc"
|
||||
baseUrl += query
|
||||
return baseUrl
|
||||
}
|
||||
private val googleSearchLrcUrl: String
|
||||
get() {
|
||||
var baseUrl = "http://www.google.com/search?"
|
||||
var query = song.title + "+" + song.artistName
|
||||
query = "q=" + query.replace(" ", "+") + " .lrc"
|
||||
baseUrl += query
|
||||
return baseUrl
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_lyrics)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_lyrics)
|
||||
setStatusbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
applyToolbar(toolbar)
|
||||
fab.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
|
||||
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.accentColor(this))))
|
||||
.apply {
|
||||
fab.setTextColor(this)
|
||||
fab.iconTint = this
|
||||
}
|
||||
setupWakelock()
|
||||
|
||||
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
|
||||
appBarLayout.setBackgroundColor(primaryColor)
|
||||
toolbar.apply {
|
||||
setBackgroundColor(primaryColor)
|
||||
navigationIcon = TintHelper.createTintedDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
this@LyricsActivity, R.drawable.ic_keyboard_backspace_black_24dp
|
||||
), ThemeStore.textColorSecondary(this@LyricsActivity)
|
||||
)
|
||||
setSupportActionBar(toolbar)
|
||||
}
|
||||
viewPager.apply {
|
||||
adapter = PagerAdapter(supportFragmentManager)
|
||||
currentItem = PreferenceUtil.getInstance(this@LyricsActivity).lyricsOptions
|
||||
addOnPageChangeListener(this@LyricsActivity)
|
||||
}
|
||||
|
||||
tabs.apply {
|
||||
setupWithViewPager(viewPager)
|
||||
setSelectedTabIndicator(
|
||||
TintHelper.createTintedDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
this@LyricsActivity, R.drawable.tab_indicator
|
||||
), ThemeStore.accentColor(this@LyricsActivity)
|
||||
)
|
||||
)
|
||||
setTabTextColors(
|
||||
ThemeStore.textColorSecondary(this@LyricsActivity),
|
||||
ThemeStore.accentColor(this@LyricsActivity)
|
||||
)
|
||||
setSelectedTabIndicatorColor(ThemeStore.accentColor(context))
|
||||
}
|
||||
fab.setOnClickListener(this)
|
||||
}
|
||||
|
||||
fab.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
|
||||
ColorStateList.valueOf(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
this, ColorUtil.isColorLight(
|
||||
ThemeStore.accentColor(
|
||||
this
|
||||
)
|
||||
)
|
||||
)
|
||||
).apply {
|
||||
fab.setTextColor(this)
|
||||
fab.iconTint = this
|
||||
}
|
||||
setupWakelock()
|
||||
override fun onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged()
|
||||
song = MusicPlayerRemote.currentSong
|
||||
toolbar.title = song.title
|
||||
toolbar.subtitle = song.artistName
|
||||
}
|
||||
|
||||
viewPager.apply {
|
||||
adapter = PagerAdapter(supportFragmentManager)
|
||||
currentItem = PreferenceUtil.getInstance(this@LyricsActivity).lyricsOptions
|
||||
addOnPageChangeListener(this@LyricsActivity)
|
||||
}
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
song = MusicPlayerRemote.currentSong
|
||||
toolbar.title = song.title
|
||||
toolbar.subtitle = song.artistName
|
||||
}
|
||||
|
||||
tabs.apply {
|
||||
setupWithViewPager(viewPager)
|
||||
setSelectedTabIndicator(
|
||||
TintHelper.createTintedDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
this@LyricsActivity, R.drawable.tab_indicator
|
||||
), ThemeStore.accentColor(this@LyricsActivity)
|
||||
)
|
||||
)
|
||||
setTabTextColors(
|
||||
ThemeStore.textColorSecondary(this@LyricsActivity),
|
||||
ThemeStore.accentColor(this@LyricsActivity)
|
||||
)
|
||||
setSelectedTabIndicatorColor(ThemeStore.accentColor(context))
|
||||
}
|
||||
fab.setOnClickListener(this)
|
||||
}
|
||||
private fun setupWakelock() {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged()
|
||||
song = MusicPlayerRemote.currentSong
|
||||
toolbar.title = song.title
|
||||
toolbar.subtitle = song.artistName
|
||||
}
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
song = MusicPlayerRemote.currentSong
|
||||
toolbar.title = song.title
|
||||
toolbar.subtitle = song.artistName
|
||||
}
|
||||
private fun showSyncedLyrics() {
|
||||
var content = ""
|
||||
try {
|
||||
content = LyricUtil.getStringFromFile(song.data, song.artistName)
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
content = LyricUtil.getStringFromFile(song.title, song.artistName)
|
||||
} catch (e2: Exception) {
|
||||
|
||||
private fun setupWakelock() {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
}
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
val materialDialog = MaterialDialog(
|
||||
this, BottomSheet(LayoutMode.WRAP_CONTENT)
|
||||
).show {
|
||||
title(R.string.add_time_framed_lryics)
|
||||
negativeButton(R.string.action_search) {
|
||||
RetroUtil.openUrl(
|
||||
this@LyricsActivity, googleSearchLrcUrl
|
||||
)
|
||||
}
|
||||
input(
|
||||
hint = getString(R.string.paste_lyrics_here),
|
||||
prefill = content,
|
||||
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
||||
) { _, input ->
|
||||
LyricUtil.writeLrcToLoc(song.data, song.artistName, input.toString())
|
||||
}
|
||||
positiveButton(android.R.string.ok) {
|
||||
updateSong()
|
||||
}
|
||||
}
|
||||
MaterialUtil.setTint(materialDialog.getInputLayout(), false)
|
||||
}
|
||||
|
||||
private fun showSyncedLyrics() {
|
||||
var content = ""
|
||||
try {
|
||||
content = LyricUtil.getStringFromFile(song.data, song.artistName)
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
content = LyricUtil.getStringFromFile(song.title, song.artistName)
|
||||
} catch (e2: Exception) {
|
||||
private fun updateSong() {
|
||||
val page = supportFragmentManager.findFragmentByTag("android:switcher:" + R.id.viewPager + ":" + viewPager.currentItem)
|
||||
if (viewPager.currentItem == 0 && page != null) {
|
||||
(page as BaseLyricsFragment).upDateSong()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
e.printStackTrace()
|
||||
}
|
||||
private fun showLyricsSaveDialog() {
|
||||
val content: String = if (lyricsString == null) {
|
||||
""
|
||||
} else {
|
||||
lyricsString!!
|
||||
}
|
||||
|
||||
val materialDialog = MaterialDialog(
|
||||
this, BottomSheet(LayoutMode.WRAP_CONTENT)
|
||||
).show {
|
||||
title(R.string.add_time_framed_lryics)
|
||||
negativeButton(R.string.action_search) {
|
||||
RetroUtil.openUrl(
|
||||
this@LyricsActivity, googleSearchLrcUrl
|
||||
)
|
||||
}
|
||||
input(
|
||||
hint = getString(R.string.paste_lyrics_here),
|
||||
prefill = content,
|
||||
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
||||
) { _, input ->
|
||||
LyricUtil.writeLrcToLoc(song.data, song.artistName, input.toString())
|
||||
}
|
||||
positiveButton(android.R.string.ok) {
|
||||
updateSong()
|
||||
}
|
||||
}
|
||||
MaterialUtil.setTint(materialDialog.getInputLayout(), false)
|
||||
}
|
||||
val materialDialog = MaterialDialog(
|
||||
this, BottomSheet(LayoutMode.WRAP_CONTENT)
|
||||
).show {
|
||||
title(R.string.add_lyrics)
|
||||
negativeButton(R.string.action_search) {
|
||||
RetroUtil.openUrl(
|
||||
this@LyricsActivity, getGoogleSearchUrl()
|
||||
)
|
||||
}
|
||||
input(
|
||||
hint = getString(R.string.paste_lyrics_here),
|
||||
prefill = content,
|
||||
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
||||
) { _, input ->
|
||||
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
|
||||
fieldKeyValueMap[FieldKey.LYRICS] = input.toString()
|
||||
WriteTagsAsyncTask(this@LyricsActivity).execute(
|
||||
WriteTagsAsyncTask.LoadingInfo(
|
||||
getSongPaths(song), fieldKeyValueMap, null
|
||||
)
|
||||
)
|
||||
}
|
||||
positiveButton(android.R.string.ok) {
|
||||
updateSong()
|
||||
}
|
||||
}
|
||||
MaterialUtil.setTint(materialDialog.getInputLayout(), false)
|
||||
}
|
||||
|
||||
private fun updateSong() {
|
||||
val page = supportFragmentManager.findFragmentByTag("android:switcher:" + R.id.viewPager + ":" + viewPager.currentItem)
|
||||
if (viewPager.currentItem == 0 && page != null) {
|
||||
(page as BaseLyricsFragment).upDateSong()
|
||||
}
|
||||
}
|
||||
private fun getSongPaths(song: Song): ArrayList<String> {
|
||||
val paths = ArrayList<String>(1)
|
||||
paths.add(song.data)
|
||||
return paths
|
||||
}
|
||||
|
||||
private fun showLyricsSaveDialog() {
|
||||
val content: String = if (lyricsString == null) {
|
||||
""
|
||||
} else {
|
||||
lyricsString!!
|
||||
}
|
||||
private fun getGoogleSearchUrl(): String {
|
||||
var baseUrl = "http://www.google.com/search?"
|
||||
var query = song.title + "+" + song.artistName
|
||||
query = "q=" + query.replace(" ", "+") + " lyrics"
|
||||
baseUrl += query
|
||||
return baseUrl
|
||||
}
|
||||
|
||||
val materialDialog = MaterialDialog(
|
||||
this, BottomSheet(LayoutMode.WRAP_CONTENT)
|
||||
).show {
|
||||
title(R.string.add_lyrics)
|
||||
negativeButton(R.string.action_search) {
|
||||
RetroUtil.openUrl(
|
||||
this@LyricsActivity, getGoogleSearchUrl()
|
||||
)
|
||||
}
|
||||
input(
|
||||
hint = getString(R.string.paste_lyrics_here),
|
||||
prefill = content,
|
||||
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
||||
) { _, input ->
|
||||
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
|
||||
fieldKeyValueMap[FieldKey.LYRICS] = input.toString()
|
||||
WriteTagsAsyncTask(this@LyricsActivity).execute(
|
||||
WriteTagsAsyncTask.LoadingInfo(
|
||||
getSongPaths(song), fieldKeyValueMap, null
|
||||
)
|
||||
)
|
||||
}
|
||||
positiveButton(android.R.string.ok) {
|
||||
updateSong()
|
||||
}
|
||||
}
|
||||
MaterialUtil.setTint(materialDialog.getInputLayout(), false)
|
||||
}
|
||||
class PagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(
|
||||
fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
|
||||
) {
|
||||
class Tabs(
|
||||
@StringRes val title: Int, val fragment: Fragment
|
||||
)
|
||||
|
||||
private fun getSongPaths(song: Song): ArrayList<String> {
|
||||
val paths = ArrayList<String>(1)
|
||||
paths.add(song.data)
|
||||
return paths
|
||||
}
|
||||
private var tabs = ArrayList<Tabs>()
|
||||
|
||||
private fun getGoogleSearchUrl(): String {
|
||||
var baseUrl = "http://www.google.com/search?"
|
||||
var query = song.title + "+" + song.artistName
|
||||
query = "q=" + query.replace(" ", "+") + " lyrics"
|
||||
baseUrl += query
|
||||
return baseUrl
|
||||
}
|
||||
init {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
tabs.add(Tabs(R.string.synced_lyrics, SyncedLyricsFragment()))
|
||||
}
|
||||
tabs.add(Tabs(R.string.normal_lyrics, OfflineLyricsFragment()))
|
||||
}
|
||||
|
||||
class PagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(
|
||||
fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
|
||||
) {
|
||||
class Tabs(
|
||||
@StringRes val title: Int, val fragment: Fragment
|
||||
)
|
||||
override fun getItem(position: Int): Fragment {
|
||||
return tabs[position].fragment
|
||||
}
|
||||
|
||||
private var tabs = ArrayList<Tabs>()
|
||||
override fun getPageTitle(position: Int): CharSequence? {
|
||||
return App.getContext().getString(tabs[position].title)
|
||||
}
|
||||
|
||||
init {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
tabs.add(Tabs(R.string.synced_lyrics, SyncedLyricsFragment()))
|
||||
}
|
||||
tabs.add(Tabs(R.string.normal_lyrics, OfflineLyricsFragment()))
|
||||
}
|
||||
override fun getCount(): Int {
|
||||
return tabs.size
|
||||
}
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
return tabs[position].fragment
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPageTitle(position: Int): CharSequence? {
|
||||
return App.getContext().getString(tabs[position].title)
|
||||
}
|
||||
abstract class BaseLyricsFragment : AbsMusicServiceFragment() {
|
||||
abstract fun upDateSong()
|
||||
|
||||
override fun getCount(): Int {
|
||||
return tabs.size
|
||||
}
|
||||
override fun onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged()
|
||||
upDateSong()
|
||||
}
|
||||
|
||||
}
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
upDateSong()
|
||||
}
|
||||
|
||||
abstract class BaseLyricsFragment : AbsMusicServiceFragment() {
|
||||
abstract fun upDateSong()
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged()
|
||||
upDateSong()
|
||||
}
|
||||
class OfflineLyricsFragment : BaseLyricsFragment() {
|
||||
override fun upDateSong() {
|
||||
loadSongLyrics()
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
upDateSong()
|
||||
}
|
||||
private var updateLyricsAsyncTask: AsyncTask<*, *, *>? = null
|
||||
private var lyrics: Lyrics? = null
|
||||
|
||||
}
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private fun loadSongLyrics() {
|
||||
if (updateLyricsAsyncTask != null) {
|
||||
updateLyricsAsyncTask!!.cancel(false)
|
||||
}
|
||||
val song = MusicPlayerRemote.currentSong
|
||||
updateLyricsAsyncTask = object : AsyncTask<Void?, Void?, Lyrics?>() {
|
||||
override fun doInBackground(vararg params: Void?): Lyrics? {
|
||||
val data = MusicUtil.getLyrics(song)
|
||||
return if (TextUtils.isEmpty(data)) {
|
||||
null
|
||||
} else Lyrics.parse(song, data!!)
|
||||
}
|
||||
|
||||
class OfflineLyricsFragment : BaseLyricsFragment() {
|
||||
override fun upDateSong() {
|
||||
loadSongLyrics()
|
||||
}
|
||||
override fun onPreExecute() {
|
||||
super.onPreExecute()
|
||||
lyrics = null
|
||||
}
|
||||
|
||||
private var updateLyricsAsyncTask: AsyncTask<*, *, *>? = null
|
||||
private var lyrics: Lyrics? = null
|
||||
override fun onPostExecute(l: Lyrics?) {
|
||||
lyrics = l
|
||||
offlineLyrics?.visibility = View.VISIBLE
|
||||
if (l == null) {
|
||||
offlineLyrics?.setText(R.string.no_lyrics_found)
|
||||
return
|
||||
}
|
||||
(activity as LyricsActivity).lyricsString = l.text
|
||||
offlineLyrics?.text = l.text
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private fun loadSongLyrics() {
|
||||
if (updateLyricsAsyncTask != null) {
|
||||
updateLyricsAsyncTask!!.cancel(false)
|
||||
}
|
||||
val song = MusicPlayerRemote.currentSong
|
||||
updateLyricsAsyncTask = object : AsyncTask<Void?, Void?, Lyrics?>() {
|
||||
override fun doInBackground(vararg params: Void?): Lyrics? {
|
||||
val data = MusicUtil.getLyrics(song)
|
||||
return if (TextUtils.isEmpty(data)) {
|
||||
null
|
||||
} else Lyrics.parse(song, data!!)
|
||||
}
|
||||
override fun onCancelled(s: Lyrics?) {
|
||||
onPostExecute(null)
|
||||
}
|
||||
}.execute()
|
||||
}
|
||||
|
||||
override fun onPreExecute() {
|
||||
super.onPreExecute()
|
||||
lyrics = null
|
||||
}
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
loadSongLyrics()
|
||||
}
|
||||
|
||||
override fun onPostExecute(l: Lyrics?) {
|
||||
lyrics = l
|
||||
offlineLyrics?.visibility = View.VISIBLE
|
||||
if (l == null) {
|
||||
offlineLyrics?.setText(R.string.no_lyrics_found)
|
||||
return
|
||||
}
|
||||
(activity as LyricsActivity).lyricsString = l.text
|
||||
offlineLyrics?.text = l.text
|
||||
}
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
if (updateLyricsAsyncTask != null && !updateLyricsAsyncTask!!.isCancelled) {
|
||||
updateLyricsAsyncTask?.cancel(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCancelled(s: Lyrics?) {
|
||||
onPostExecute(null)
|
||||
}
|
||||
}.execute()
|
||||
}
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_lyrics, container, false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
loadSongLyrics()
|
||||
}
|
||||
class SyncedLyricsFragment : BaseLyricsFragment(), MusicProgressViewUpdateHelper.Callback {
|
||||
override fun upDateSong() {
|
||||
loadLRCLyrics()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
if (updateLyricsAsyncTask != null && !updateLyricsAsyncTask!!.isCancelled) {
|
||||
updateLyricsAsyncTask?.cancel(true)
|
||||
}
|
||||
}
|
||||
private lateinit var updateHelper: MusicProgressViewUpdateHelper
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_synced, container, false)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_lyrics, container, false)
|
||||
}
|
||||
}
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
updateHelper = MusicProgressViewUpdateHelper(this, 500, 1000)
|
||||
}
|
||||
|
||||
class SyncedLyricsFragment : BaseLyricsFragment(), MusicProgressViewUpdateHelper.Callback {
|
||||
override fun upDateSong() {
|
||||
loadLRCLyrics()
|
||||
}
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setupLyricsView()
|
||||
}
|
||||
|
||||
private lateinit var updateHelper: MusicProgressViewUpdateHelper
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_synced, container, false)
|
||||
}
|
||||
private fun setupLyricsView() {
|
||||
lyricsView.apply {
|
||||
val context = activity!!
|
||||
setCurrentPlayLineColor(ThemeStore.accentColor(context))
|
||||
setIndicatorTextColor(ThemeStore.accentColor(context))
|
||||
setCurrentIndicateLineTextColor(ThemeStore.textColorPrimary(context))
|
||||
setNoLrcTextColor(ThemeStore.textColorPrimary(context))
|
||||
setOnPlayIndicatorLineListener(object : LrcView.OnPlayIndicatorLineListener {
|
||||
override fun onPlay(time: Long, content: String) {
|
||||
MusicPlayerRemote.seekTo(time.toInt())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
updateHelper = MusicProgressViewUpdateHelper(this, 500, 1000)
|
||||
}
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateHelper.start()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setupLyricsView()
|
||||
}
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
updateHelper.stop()
|
||||
}
|
||||
|
||||
private fun setupLyricsView() {
|
||||
lyricsView.apply {
|
||||
val context = activity!!
|
||||
setCurrentPlayLineColor(ThemeStore.accentColor(context))
|
||||
setIndicatorTextColor(ThemeStore.accentColor(context))
|
||||
setCurrentIndicateLineTextColor(ThemeStore.textColorPrimary(context))
|
||||
setNoLrcTextColor(ThemeStore.textColorPrimary(context))
|
||||
setOnPlayIndicatorLineListener(object : LrcView.OnPlayIndicatorLineListener {
|
||||
override fun onPlay(time: Long, content: String) {
|
||||
MusicPlayerRemote.seekTo(time.toInt())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
lyricsView.updateTime(progress.toLong())
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateHelper.start()
|
||||
}
|
||||
private fun loadLRCLyrics() {
|
||||
val song = MusicPlayerRemote.currentSong
|
||||
if (LyricUtil.isLrcFile2Exist(song.data, song.artistName)) {
|
||||
showLyricsLocal(LyricUtil.getLocalLyricFile(song.data, song.artistName))
|
||||
} else {
|
||||
if (LyricUtil.isLrcFileExist(song.title, song.artistName)) {
|
||||
showLyricsLocal(LyricUtil.getLocalLyricFile(song.title, song.artistName))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
updateHelper.stop()
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
lyricsView.updateTime(progress.toLong())
|
||||
}
|
||||
|
||||
private fun loadLRCLyrics() {
|
||||
val song = MusicPlayerRemote.currentSong
|
||||
if (LyricUtil.isLrcFile2Exist(song.data, song.artistName)) {
|
||||
showLyricsLocal(LyricUtil.getLocalLyricFile(song.data, song.artistName))
|
||||
} else {
|
||||
if (LyricUtil.isLrcFileExist(song.title, song.artistName)) {
|
||||
showLyricsLocal(LyricUtil.getLocalLyricFile(song.title, song.artistName))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showLyricsLocal(file: File?) {
|
||||
if (file != null) {
|
||||
lyricsView.setLrcData(LrcHelper.parseLrcFromFile(file))
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun showLyricsLocal(file: File?) {
|
||||
if (file != null) {
|
||||
lyricsView.setLrcData(LrcHelper.parseLrcFromFile(file))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,263 +12,263 @@ import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
|||
import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.folders.FoldersFragment
|
||||
import code.name.monkey.retromusic.fragments.mainactivity.home.BannerHomeFragment
|
||||
import code.name.monkey.retromusic.helper.*
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.SearchQueryHelper
|
||||
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||
import code.name.monkey.retromusic.loaders.*
|
||||
import code.name.monkey.retromusic.loaders.AlbumLoader
|
||||
import code.name.monkey.retromusic.loaders.ArtistLoader
|
||||
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.util.AppRater
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import java.util.*
|
||||
|
||||
class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
private lateinit var currentFragment: MainActivityFragmentCallbacks
|
||||
private lateinit var currentFragment: MainActivityFragmentCallbacks
|
||||
|
||||
private var blockRequestPermissions: Boolean = false
|
||||
private val disposable = CompositeDisposable()
|
||||
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val action = intent.action
|
||||
if (action != null && action == Intent.ACTION_SCREEN_OFF) {
|
||||
if (PreferenceUtil.getInstance(this@MainActivity).lockScreen && MusicPlayerRemote.isPlaying) {
|
||||
val activity = Intent(context, LockScreenActivity::class.java)
|
||||
activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||
ActivityCompat.startActivity(context, activity, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private var blockRequestPermissions: Boolean = false
|
||||
private val disposable = CompositeDisposable()
|
||||
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val action = intent.action
|
||||
if (action != null && action == Intent.ACTION_SCREEN_OFF) {
|
||||
if (PreferenceUtil.getInstance(this@MainActivity).lockScreen && MusicPlayerRemote.isPlaying) {
|
||||
val activity = Intent(context, LockScreenActivity::class.java)
|
||||
activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||
ActivityCompat.startActivity(context, activity, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun createContentView(): View {
|
||||
return wrapSlidingMusicPanel(R.layout.activity_main_content)
|
||||
}
|
||||
override fun createContentView(): View {
|
||||
return wrapSlidingMusicPanel(R.layout.activity_main_content)
|
||||
}
|
||||
|
||||
override fun onCreate(
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
override fun onCreate(
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
getBottomNavigationView().selectedItemId = PreferenceUtil.getInstance(this).lastPage
|
||||
getBottomNavigationView().setOnNavigationItemSelectedListener {
|
||||
PreferenceUtil.getInstance(this).lastPage = it.itemId
|
||||
selectedFragment(it.itemId)
|
||||
true
|
||||
}
|
||||
|
||||
getBottomNavigationView().selectedItemId = PreferenceUtil.getInstance(this).lastPage
|
||||
if (savedInstanceState == null) {
|
||||
setMusicChooser(PreferenceUtil.getInstance(this).lastMusicChooser)
|
||||
} else {
|
||||
restoreCurrentFragment()
|
||||
}
|
||||
|
||||
getBottomNavigationView().setOnNavigationItemSelectedListener {
|
||||
PreferenceUtil.getInstance(this).lastPage = it.itemId
|
||||
selectedFragment(it.itemId)
|
||||
true
|
||||
}
|
||||
checkShowChangelog()
|
||||
AppRater.appLaunched(this)
|
||||
}
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
setMusicChooser(PreferenceUtil.getInstance(this).lastMusicChooser)
|
||||
} else {
|
||||
restoreCurrentFragment()
|
||||
}
|
||||
private fun checkShowChangelog() {
|
||||
try {
|
||||
val pInfo = packageManager.getPackageInfo(packageName, 0)
|
||||
val currentVersion = pInfo.versionCode
|
||||
if (currentVersion != PreferenceUtil.getInstance(this).lastChangelogVersion) {
|
||||
startActivityForResult(
|
||||
Intent(this, WhatsNewActivity::class.java),
|
||||
APP_INTRO_REQUEST
|
||||
)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
checkShowChangelog()
|
||||
AppRater.appLaunched(this);
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkShowChangelog() {
|
||||
try {
|
||||
val pInfo = packageManager.getPackageInfo(packageName, 0)
|
||||
val currentVersion = pInfo.versionCode
|
||||
if (currentVersion != PreferenceUtil.getInstance(this).lastChangelogVersion) {
|
||||
startActivityForResult(
|
||||
Intent(this, WhatsNewActivity::class.java),
|
||||
APP_INTRO_REQUEST
|
||||
)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val screenOnOff = IntentFilter()
|
||||
screenOnOff.addAction(Intent.ACTION_SCREEN_OFF)
|
||||
registerReceiver(broadcastReceiver, screenOnOff)
|
||||
|
||||
}
|
||||
PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this)
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val screenOnOff = IntentFilter()
|
||||
screenOnOff.addAction(Intent.ACTION_SCREEN_OFF)
|
||||
registerReceiver(broadcastReceiver, screenOnOff)
|
||||
if (intent.hasExtra("expand")) {
|
||||
if (intent.getBooleanExtra("expand", false)) {
|
||||
expandPanel()
|
||||
intent.putExtra("expand", false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this)
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
disposable.clear()
|
||||
unregisterReceiver(broadcastReceiver)
|
||||
PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
|
||||
if (intent.hasExtra("expand")) {
|
||||
if (intent.getBooleanExtra("expand", false)) {
|
||||
expandPanel()
|
||||
intent.putExtra("expand", false)
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun setCurrentFragment(fragment: Fragment, tag: String) {
|
||||
if (tag != supportFragmentManager.findFragmentById(R.id.fragment_container)?.tag) {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment, tag).commit()
|
||||
currentFragment = fragment as MainActivityFragmentCallbacks
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
disposable.clear()
|
||||
unregisterReceiver(broadcastReceiver)
|
||||
PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
private fun restoreCurrentFragment() {
|
||||
currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) as MainActivityFragmentCallbacks
|
||||
}
|
||||
|
||||
private fun setCurrentFragment(fragment: Fragment, tag: String) {
|
||||
println("setCurrentFragment -> $tag -> ${supportFragmentManager.findFragmentById(R.id.fragment_container)?.tag}")
|
||||
if (tag != supportFragmentManager.findFragmentById(R.id.fragment_container)?.tag) {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment, tag).commit()
|
||||
currentFragment = fragment as MainActivityFragmentCallbacks
|
||||
}
|
||||
}
|
||||
private fun handlePlaybackIntent(intent: Intent?) {
|
||||
if (intent == null) {
|
||||
return
|
||||
}
|
||||
val uri = intent.data
|
||||
val mimeType = intent.type
|
||||
var handled = false
|
||||
if (intent.action != null && intent.action == MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH) {
|
||||
val songs = SearchQueryHelper.getSongs(this, intent.extras!!)
|
||||
if (MusicPlayerRemote.shuffleMode == MusicService.SHUFFLE_MODE_SHUFFLE) {
|
||||
MusicPlayerRemote.openAndShuffleQueue(songs, true)
|
||||
} else {
|
||||
MusicPlayerRemote.openQueue(songs, 0, true)
|
||||
}
|
||||
handled = true
|
||||
}
|
||||
|
||||
private fun restoreCurrentFragment() {
|
||||
currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) as MainActivityFragmentCallbacks
|
||||
}
|
||||
if (uri != null && uri.toString().isNotEmpty()) {
|
||||
MusicPlayerRemote.playFromUri(uri)
|
||||
handled = true
|
||||
} else if (MediaStore.Audio.Playlists.CONTENT_TYPE == mimeType) {
|
||||
val id = parseIdFromIntent(intent, "playlistId", "playlist").toInt()
|
||||
if (id >= 0) {
|
||||
val position = intent.getIntExtra("position", 0)
|
||||
val songs = ArrayList(PlaylistSongsLoader.getPlaylistSongList(this, id))
|
||||
MusicPlayerRemote.openQueue(songs, position, true)
|
||||
handled = true
|
||||
}
|
||||
} else if (MediaStore.Audio.Albums.CONTENT_TYPE == mimeType) {
|
||||
val id = parseIdFromIntent(intent, "albumId", "album").toInt()
|
||||
if (id >= 0) {
|
||||
val position = intent.getIntExtra("position", 0)
|
||||
MusicPlayerRemote.openQueue(AlbumLoader.getAlbum(this, id).songs!!, position, true)
|
||||
handled = true
|
||||
}
|
||||
} else if (MediaStore.Audio.Artists.CONTENT_TYPE == mimeType) {
|
||||
val id = parseIdFromIntent(intent, "artistId", "artist").toInt()
|
||||
if (id >= 0) {
|
||||
val position = intent.getIntExtra("position", 0)
|
||||
MusicPlayerRemote.openQueue(ArtistLoader.getArtist(this, id).songs, position, true)
|
||||
handled = true
|
||||
}
|
||||
}
|
||||
if (handled) {
|
||||
setIntent(Intent())
|
||||
}
|
||||
}
|
||||
|
||||
private fun handlePlaybackIntent(intent: Intent?) {
|
||||
if (intent == null) {
|
||||
return
|
||||
}
|
||||
private fun parseIdFromIntent(intent: Intent, longKey: String, stringKey: String): Long {
|
||||
var id = intent.getLongExtra(longKey, -1)
|
||||
if (id < 0) {
|
||||
val idString = intent.getStringExtra(stringKey)
|
||||
if (idString != null) {
|
||||
try {
|
||||
id = java.lang.Long.parseLong(idString)
|
||||
} catch (e: NumberFormatException) {
|
||||
Log.e(TAG, e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
val uri = intent.data
|
||||
val mimeType = intent.type
|
||||
var handled = false
|
||||
if (intent.action != null && intent.action == MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH) {
|
||||
val songs = SearchQueryHelper.getSongs(this, intent.extras!!)
|
||||
if (MusicPlayerRemote.shuffleMode == MusicService.SHUFFLE_MODE_SHUFFLE) {
|
||||
MusicPlayerRemote.openAndShuffleQueue(songs, true)
|
||||
} else {
|
||||
MusicPlayerRemote.openQueue(songs, 0, true)
|
||||
}
|
||||
handled = true
|
||||
}
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
when (requestCode) {
|
||||
APP_INTRO_REQUEST -> {
|
||||
blockRequestPermissions = false
|
||||
if (!hasPermissions()) {
|
||||
requestPermissions()
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_THEME, APP_USER_INFO_REQUEST -> postRecreate()
|
||||
PURCHASE_REQUEST -> {
|
||||
if (resultCode == RESULT_OK) {
|
||||
//checkSetUpPro();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uri != null && uri.toString().isNotEmpty()) {
|
||||
MusicPlayerRemote.playFromUri(uri)
|
||||
handled = true
|
||||
} else if (MediaStore.Audio.Playlists.CONTENT_TYPE == mimeType) {
|
||||
val id = parseIdFromIntent(intent, "playlistId", "playlist").toInt()
|
||||
if (id >= 0) {
|
||||
val position = intent.getIntExtra("position", 0)
|
||||
val songs = ArrayList(PlaylistSongsLoader.getPlaylistSongList(this, id))
|
||||
MusicPlayerRemote.openQueue(songs, position, true)
|
||||
handled = true
|
||||
}
|
||||
} else if (MediaStore.Audio.Albums.CONTENT_TYPE == mimeType) {
|
||||
val id = parseIdFromIntent(intent, "albumId", "album").toInt()
|
||||
if (id >= 0) {
|
||||
val position = intent.getIntExtra("position", 0)
|
||||
MusicPlayerRemote.openQueue(AlbumLoader.getAlbum(this, id).songs!!, position, true)
|
||||
handled = true
|
||||
}
|
||||
} else if (MediaStore.Audio.Artists.CONTENT_TYPE == mimeType) {
|
||||
val id = parseIdFromIntent(intent, "artistId", "artist").toInt()
|
||||
if (id >= 0) {
|
||||
val position = intent.getIntExtra("position", 0)
|
||||
MusicPlayerRemote.openQueue(ArtistLoader.getArtist(this, id).songs, position, true)
|
||||
handled = true
|
||||
}
|
||||
}
|
||||
if (handled) {
|
||||
setIntent(Intent())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseIdFromIntent(intent: Intent, longKey: String, stringKey: String): Long {
|
||||
var id = intent.getLongExtra(longKey, -1)
|
||||
if (id < 0) {
|
||||
val idString = intent.getStringExtra(stringKey)
|
||||
if (idString != null) {
|
||||
try {
|
||||
id = java.lang.Long.parseLong(idString)
|
||||
} catch (e: NumberFormatException) {
|
||||
Log.e(TAG, e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
return id
|
||||
}
|
||||
override fun handleBackPress(): Boolean {
|
||||
return super.handleBackPress() || currentFragment.handleBackPress()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
when (requestCode) {
|
||||
APP_INTRO_REQUEST -> {
|
||||
blockRequestPermissions = false
|
||||
if (!hasPermissions()) {
|
||||
requestPermissions()
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_THEME, APP_USER_INFO_REQUEST -> postRecreate()
|
||||
PURCHASE_REQUEST -> {
|
||||
if (resultCode == RESULT_OK) {
|
||||
//checkSetUpPro();
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
handlePlaybackIntent(intent)
|
||||
}
|
||||
|
||||
}
|
||||
override fun requestPermissions() {
|
||||
if (!blockRequestPermissions) {
|
||||
super.requestPermissions()
|
||||
}
|
||||
}
|
||||
|
||||
override fun handleBackPress(): Boolean {
|
||||
return super.handleBackPress() || currentFragment.handleBackPress()
|
||||
}
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
if (key == PreferenceUtil.GENERAL_THEME || key == PreferenceUtil.BLACK_THEME || key == PreferenceUtil.ADAPTIVE_COLOR_APP || key == PreferenceUtil.DOMINANT_COLOR || key == PreferenceUtil.USER_NAME || key == PreferenceUtil.TOGGLE_FULL_SCREEN || key == PreferenceUtil.TOGGLE_VOLUME || key == PreferenceUtil.ROUND_CORNERS || key == PreferenceUtil.CAROUSEL_EFFECT || key == PreferenceUtil.NOW_PLAYING_SCREEN_ID || key == PreferenceUtil.TOGGLE_GENRE || key == PreferenceUtil.BANNER_IMAGE_PATH || key == PreferenceUtil.PROFILE_IMAGE_PATH || key == PreferenceUtil.CIRCULAR_ALBUM_ART || key == PreferenceUtil.KEEP_SCREEN_ON || key == PreferenceUtil.TOGGLE_SEPARATE_LINE || key == PreferenceUtil.ALBUM_GRID_STYLE || key == PreferenceUtil.ARTIST_GRID_STYLE || key == PreferenceUtil.TOGGLE_HOME_BANNER || key == PreferenceUtil.TOGGLE_ADD_CONTROLS || key == PreferenceUtil.ALBUM_COVER_STYLE || key == PreferenceUtil.HOME_ARTIST_GRID_STYLE || key == PreferenceUtil.ALBUM_COVER_TRANSFORM || key == PreferenceUtil.DESATURATED_COLOR || key == PreferenceUtil.TAB_TEXT_MODE || key == PreferenceUtil.LIBRARY_CATEGORIES) postRecreate()
|
||||
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
handlePlaybackIntent(intent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun requestPermissions() {
|
||||
if (!blockRequestPermissions) {
|
||||
super.requestPermissions()
|
||||
}
|
||||
}
|
||||
private fun showPromotionalOffer() {
|
||||
/*MaterialDialog(this).show {
|
||||
positiveButton(text = "Buy") { startActivity(Intent(this@MainActivity, PurchaseActivity::class.java)) }
|
||||
negativeButton(android.R.string.cancel)
|
||||
customView(R.layout.dialog_promotional_offer)
|
||||
onDismiss {
|
||||
PreferenceManager.getDefaultSharedPreferences(this@MainActivity)
|
||||
.edit()
|
||||
.putBoolean("shown", true)
|
||||
.apply()
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
if (key == PreferenceUtil.GENERAL_THEME || key == PreferenceUtil.BLACK_THEME || key == PreferenceUtil.ADAPTIVE_COLOR_APP || key == PreferenceUtil.DOMINANT_COLOR || key == PreferenceUtil.USER_NAME || key == PreferenceUtil.TOGGLE_FULL_SCREEN || key == PreferenceUtil.TOGGLE_VOLUME || key == PreferenceUtil.ROUND_CORNERS || key == PreferenceUtil.CAROUSEL_EFFECT || key == PreferenceUtil.NOW_PLAYING_SCREEN_ID || key == PreferenceUtil.TOGGLE_GENRE || key == PreferenceUtil.BANNER_IMAGE_PATH || key == PreferenceUtil.PROFILE_IMAGE_PATH || key == PreferenceUtil.CIRCULAR_ALBUM_ART || key == PreferenceUtil.KEEP_SCREEN_ON || key == PreferenceUtil.TOGGLE_SEPARATE_LINE || key == PreferenceUtil.ALBUM_GRID_STYLE || key == PreferenceUtil.ARTIST_GRID_STYLE || key == PreferenceUtil.TOGGLE_HOME_BANNER || key == PreferenceUtil.TOGGLE_ADD_CONTROLS || key == PreferenceUtil.ALBUM_COVER_STYLE || key == PreferenceUtil.HOME_ARTIST_GRID_STYLE || key == PreferenceUtil.ALBUM_COVER_TRANSFORM || key == PreferenceUtil.DESATURATED_COLOR || key == PreferenceUtil.TAB_TEXT_MODE || key == PreferenceUtil.LIBRARY_CATEGORIES) postRecreate()
|
||||
private fun selectedFragment(itemId: Int) {
|
||||
when (itemId) {
|
||||
R.id.action_album, R.id.action_artist, R.id.action_playlist, R.id.action_genre, R.id.action_song -> setCurrentFragment(
|
||||
LibraryFragment.newInstance(itemId),
|
||||
itemId.toString()
|
||||
)
|
||||
R.id.action_home -> setCurrentFragment(
|
||||
BannerHomeFragment.newInstance(),
|
||||
BannerHomeFragment.TAG
|
||||
)
|
||||
else -> {
|
||||
setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
fun setMusicChooser(key: Int) {
|
||||
PreferenceUtil.getInstance(this).lastMusicChooser = key
|
||||
when (key) {
|
||||
FOLDER -> setCurrentFragment(FoldersFragment.newInstance(this), FoldersFragment.TAG)
|
||||
else -> selectedFragment(PreferenceUtil.getInstance(this).lastPage)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showPromotionalOffer() {
|
||||
/*MaterialDialog(this).show {
|
||||
positiveButton(text = "Buy") { startActivity(Intent(this@MainActivity, PurchaseActivity::class.java)) }
|
||||
negativeButton(android.R.string.cancel)
|
||||
customView(R.layout.dialog_promotional_offer)
|
||||
onDismiss {
|
||||
PreferenceManager.getDefaultSharedPreferences(this@MainActivity)
|
||||
.edit()
|
||||
.putBoolean("shown", true)
|
||||
.apply()
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private fun selectedFragment(itemId: Int) {
|
||||
when (itemId) {
|
||||
R.id.action_album, R.id.action_artist, R.id.action_playlist, R.id.action_genre, R.id.action_song -> setCurrentFragment(
|
||||
LibraryFragment.newInstance(itemId),
|
||||
itemId.toString()
|
||||
)
|
||||
R.id.action_home -> setCurrentFragment(
|
||||
BannerHomeFragment.newInstance(),
|
||||
BannerHomeFragment.TAG
|
||||
)
|
||||
else -> {
|
||||
setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setMusicChooser(key: Int) {
|
||||
PreferenceUtil.getInstance(this).lastMusicChooser = key
|
||||
when (key) {
|
||||
FOLDER -> setCurrentFragment(FoldersFragment.newInstance(this), FoldersFragment.TAG)
|
||||
else -> selectedFragment(PreferenceUtil.getInstance(this).lastPage)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val APP_INTRO_REQUEST = 2323
|
||||
const val HOME = 0
|
||||
const val FOLDER = 1
|
||||
const val LIBRARY = 2
|
||||
private const val TAG = "MainActivity"
|
||||
private const val APP_USER_INFO_REQUEST = 9003
|
||||
private const val REQUEST_CODE_THEME = 9002
|
||||
private const val PURCHASE_REQUEST = 101
|
||||
}
|
||||
companion object {
|
||||
const val APP_INTRO_REQUEST = 2323
|
||||
const val HOME = 0
|
||||
const val FOLDER = 1
|
||||
const val LIBRARY = 2
|
||||
private const val TAG = "MainActivity"
|
||||
private const val APP_USER_INFO_REQUEST = 9003
|
||||
private const val REQUEST_CODE_THEME = 9002
|
||||
private const val PURCHASE_REQUEST = 101
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,17 @@ package code.name.monkey.retromusic.activities
|
|||
import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.recyclerview.widget.*
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
|
||||
|
@ -20,169 +22,162 @@ import kotlinx.android.synthetic.main.activity_playing_queue.*
|
|||
|
||||
open class PlayingQueueActivity : AbsMusicServiceActivity() {
|
||||
|
||||
private var wrappedAdapter: RecyclerView.Adapter<*>? = null
|
||||
private var recyclerViewDragDropManager: RecyclerViewDragDropManager? = null
|
||||
private var playingQueueAdapter: PlayingQueueAdapter? = null
|
||||
private lateinit var linearLayoutManager: LinearLayoutManager
|
||||
private var wrappedAdapter: RecyclerView.Adapter<*>? = null
|
||||
private var recyclerViewDragDropManager: RecyclerViewDragDropManager? = null
|
||||
private var playingQueueAdapter: PlayingQueueAdapter? = null
|
||||
private lateinit var linearLayoutManager: LinearLayoutManager
|
||||
|
||||
private fun getUpNextAndQueueTime(): String {
|
||||
val duration = MusicPlayerRemote.getQueueDurationMillis(MusicPlayerRemote.position)
|
||||
private fun getUpNextAndQueueTime(): String {
|
||||
val duration = MusicPlayerRemote.getQueueDurationMillis(MusicPlayerRemote.position)
|
||||
return MusicUtil.buildInfoString(resources.getString(R.string.up_next), MusicUtil.getReadableDurationString(duration))
|
||||
}
|
||||
|
||||
return MusicUtil.buildInfoString(
|
||||
resources.getString(R.string.up_next), MusicUtil.getReadableDurationString(duration)
|
||||
)
|
||||
}
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_playing_queue)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
override fun onCreate(
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_playing_queue)
|
||||
setupToolbar()
|
||||
setUpRecyclerView()
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
clearQueue.setOnClickListener {
|
||||
MusicPlayerRemote.clearQueue()
|
||||
}
|
||||
checkForPadding()
|
||||
}
|
||||
|
||||
setupToolbar()
|
||||
setUpRecyclerView()
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
clearQueue.setOnClickListener {
|
||||
MusicPlayerRemote.clearQueue()
|
||||
}
|
||||
checkForPadding()
|
||||
}
|
||||
private fun setUpRecyclerView() {
|
||||
recyclerViewDragDropManager = RecyclerViewDragDropManager()
|
||||
val animator = RefactoredDefaultItemAnimator()
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
playingQueueAdapter = PlayingQueueAdapter(
|
||||
this,
|
||||
MusicPlayerRemote.playingQueue,
|
||||
MusicPlayerRemote.position,
|
||||
R.layout.item_queue
|
||||
)
|
||||
wrappedAdapter = recyclerViewDragDropManager?.createWrappedAdapter(playingQueueAdapter!!)
|
||||
|
||||
private fun setUpRecyclerView() {
|
||||
recyclerViewDragDropManager = RecyclerViewDragDropManager()
|
||||
val animator = RefactoredDefaultItemAnimator()
|
||||
linearLayoutManager = LinearLayoutManager(this)
|
||||
|
||||
playingQueueAdapter = PlayingQueueAdapter(
|
||||
this,
|
||||
MusicPlayerRemote.playingQueue,
|
||||
MusicPlayerRemote.position,
|
||||
R.layout.item_queue
|
||||
)
|
||||
wrappedAdapter = recyclerViewDragDropManager?.createWrappedAdapter(playingQueueAdapter!!)
|
||||
recyclerView.apply {
|
||||
layoutManager = linearLayoutManager
|
||||
adapter = wrappedAdapter
|
||||
itemAnimator = animator
|
||||
recyclerViewDragDropManager?.attachRecyclerView(this)
|
||||
}
|
||||
|
||||
linearLayoutManager = LinearLayoutManager(this)
|
||||
linearLayoutManager.scrollToPositionWithOffset(MusicPlayerRemote.position + 1, 0)
|
||||
|
||||
recyclerView.apply {
|
||||
layoutManager = linearLayoutManager
|
||||
adapter = wrappedAdapter
|
||||
itemAnimator = animator
|
||||
recyclerViewDragDropManager?.attachRecyclerView(this)
|
||||
}
|
||||
recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
if (dy > 0) {
|
||||
clearQueue.shrink()
|
||||
} else if (dy < 0) {
|
||||
clearQueue.extend()
|
||||
}
|
||||
}
|
||||
})
|
||||
ViewUtil.setUpFastScrollRecyclerViewColor(this, recyclerView)
|
||||
}
|
||||
|
||||
linearLayoutManager.scrollToPositionWithOffset(MusicPlayerRemote.position + 1, 0)
|
||||
private fun checkForPadding() {
|
||||
|
||||
recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
if (dy > 0) {
|
||||
clearQueue.shrink()
|
||||
} else if (dy < 0) {
|
||||
clearQueue.extend()
|
||||
}
|
||||
}
|
||||
})
|
||||
ViewUtil.setUpFastScrollRecyclerViewColor(this, recyclerView)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkForPadding() {
|
||||
override fun onQueueChanged() {
|
||||
if (MusicPlayerRemote.playingQueue.isEmpty()) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
checkForPadding()
|
||||
updateQueue()
|
||||
updateCurrentSong()
|
||||
}
|
||||
|
||||
}
|
||||
override fun onMediaStoreChanged() {
|
||||
updateQueue()
|
||||
updateCurrentSong()
|
||||
}
|
||||
|
||||
override fun onQueueChanged() {
|
||||
if (MusicPlayerRemote.playingQueue.isEmpty()) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
checkForPadding()
|
||||
updateQueue()
|
||||
updateCurrentSong()
|
||||
}
|
||||
private fun updateCurrentSong() {
|
||||
playerQueueSubHeader.text = getUpNextAndQueueTime()
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
updateQueue()
|
||||
updateCurrentSong()
|
||||
}
|
||||
override fun onPlayingMetaChanged() {
|
||||
updateQueuePosition()
|
||||
}
|
||||
|
||||
private fun updateCurrentSong() {
|
||||
playerQueueSubHeader.text = getUpNextAndQueueTime()
|
||||
}
|
||||
private fun updateQueuePosition() {
|
||||
playingQueueAdapter?.setCurrent(MusicPlayerRemote.position)
|
||||
resetToCurrentPosition()
|
||||
playerQueueSubHeader.text = getUpNextAndQueueTime()
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
updateQueuePosition()
|
||||
}
|
||||
private fun updateQueue() {
|
||||
playingQueueAdapter?.swapDataSet(MusicPlayerRemote.playingQueue, MusicPlayerRemote.position)
|
||||
resetToCurrentPosition()
|
||||
}
|
||||
|
||||
private fun updateQueuePosition() {
|
||||
playingQueueAdapter?.setCurrent(MusicPlayerRemote.position)
|
||||
resetToCurrentPosition()
|
||||
playerQueueSubHeader.text = getUpNextAndQueueTime()
|
||||
}
|
||||
private fun resetToCurrentPosition() {
|
||||
recyclerView.stopScroll()
|
||||
linearLayoutManager.scrollToPositionWithOffset(MusicPlayerRemote.position + 1, 0)
|
||||
}
|
||||
|
||||
private fun updateQueue() {
|
||||
playingQueueAdapter?.swapDataSet(MusicPlayerRemote.playingQueue, MusicPlayerRemote.position)
|
||||
resetToCurrentPosition()
|
||||
}
|
||||
override fun onPause() {
|
||||
if (recyclerViewDragDropManager != null) {
|
||||
recyclerViewDragDropManager!!.cancelDrag()
|
||||
}
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
private fun resetToCurrentPosition() {
|
||||
recyclerView.stopScroll()
|
||||
linearLayoutManager.scrollToPositionWithOffset(MusicPlayerRemote.position + 1, 0)
|
||||
}
|
||||
override fun onDestroy() {
|
||||
if (recyclerViewDragDropManager != null) {
|
||||
recyclerViewDragDropManager!!.release()
|
||||
recyclerViewDragDropManager = null
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
if (recyclerViewDragDropManager != null) {
|
||||
recyclerViewDragDropManager!!.cancelDrag()
|
||||
}
|
||||
super.onPause()
|
||||
}
|
||||
if (wrappedAdapter != null) {
|
||||
WrapperAdapterUtils.releaseAll(wrappedAdapter)
|
||||
wrappedAdapter = null
|
||||
}
|
||||
playingQueueAdapter = null
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
if (recyclerViewDragDropManager != null) {
|
||||
recyclerViewDragDropManager!!.release()
|
||||
recyclerViewDragDropManager = null
|
||||
}
|
||||
private fun setupToolbar() {
|
||||
playerQueueSubHeader.text = getUpNextAndQueueTime()
|
||||
playerQueueSubHeader.setTextColor(ThemeStore.accentColor(this))
|
||||
|
||||
if (wrappedAdapter != null) {
|
||||
WrapperAdapterUtils.releaseAll(wrappedAdapter)
|
||||
wrappedAdapter = null
|
||||
}
|
||||
playingQueueAdapter = null
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
private fun setupToolbar() {
|
||||
playerQueueSubHeader.text = getUpNextAndQueueTime()
|
||||
playerQueueSubHeader.setTextColor(ThemeStore.accentColor(this))
|
||||
|
||||
applyToolbar(toolbar)
|
||||
appBarLayout.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
|
||||
clearQueue.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
|
||||
ColorStateList.valueOf(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
this,
|
||||
ColorUtil.isColorLight(
|
||||
ThemeStore.accentColor(
|
||||
this
|
||||
)
|
||||
)
|
||||
)
|
||||
).apply {
|
||||
clearQueue.setTextColor(this)
|
||||
clearQueue.iconTint = this
|
||||
}
|
||||
}
|
||||
applyToolbar(toolbar)
|
||||
clearQueue.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
|
||||
ColorStateList.valueOf(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
this,
|
||||
ColorUtil.isColorLight(
|
||||
ThemeStore.accentColor(
|
||||
this
|
||||
)
|
||||
)
|
||||
)
|
||||
).apply {
|
||||
clearQueue.setTextColor(this)
|
||||
clearQueue.iconTint = this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,29 @@
|
|||
package code.name.monkey.retromusic.activities
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import androidx.recyclerview.widget.*
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.retromusic.*
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
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.adapter.song.*
|
||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||
import code.name.monkey.retromusic.adapter.song.OrderablePlaylistSongAdapter
|
||||
import code.name.monkey.retromusic.adapter.song.PlaylistSongAdapter
|
||||
import code.name.monkey.retromusic.adapter.song.SongAdapter
|
||||
import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.loaders.PlaylistLoader
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.mvp.presenter.*
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.model.AbsCustomPlaylist
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsView
|
||||
import code.name.monkey.retromusic.util.DensityUtil
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator
|
||||
|
@ -25,217 +34,207 @@ import javax.inject.Inject
|
|||
|
||||
class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, PlaylistSongsView {
|
||||
|
||||
@Inject
|
||||
lateinit var playlistSongsPresenter: PlaylistSongsPresenter
|
||||
@Inject
|
||||
lateinit var playlistSongsPresenter: PlaylistSongsPresenter
|
||||
|
||||
private lateinit var playlist: Playlist
|
||||
private var cab: MaterialCab? = null
|
||||
private lateinit var adapter: SongAdapter
|
||||
private var wrappedAdapter: RecyclerView.Adapter<*>? = null
|
||||
private var recyclerViewDragDropManager: RecyclerViewDragDropManager? = null
|
||||
private lateinit var playlist: Playlist
|
||||
private var cab: MaterialCab? = null
|
||||
private lateinit var adapter: SongAdapter
|
||||
private var wrappedAdapter: RecyclerView.Adapter<*>? = null
|
||||
private var recyclerViewDragDropManager: RecyclerViewDragDropManager? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
App.musicComponent.inject(this)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
toggleBottomNavigationView(true)
|
||||
|
||||
playlistSongsPresenter.attachView(this)
|
||||
App.musicComponent.inject(this)
|
||||
playlistSongsPresenter.attachView(this)
|
||||
|
||||
setStatusbarColor(Color.TRANSPARENT)
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
setLightStatusbar(ColorUtil.isColorLight(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
|
||||
if (intent.extras != null) {
|
||||
playlist = intent.extras!!.getParcelable(EXTRA_PLAYLIST)!!
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
||||
toggleBottomNavigationView(true)
|
||||
setUpToolBar()
|
||||
setUpRecyclerView()
|
||||
}
|
||||
|
||||
if (intent.extras != null) {
|
||||
playlist = intent.extras!!.getParcelable(EXTRA_PLAYLIST)!!
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
override fun createContentView(): View {
|
||||
return wrapSlidingMusicPanel(R.layout.activity_playlist_detail)
|
||||
}
|
||||
|
||||
setUpToolBar()
|
||||
setUpRecyclerView()
|
||||
}
|
||||
private fun setUpRecyclerView() {
|
||||
ViewUtil.setUpFastScrollRecyclerViewColor(this, recyclerView)
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
if (playlist is AbsCustomPlaylist) {
|
||||
adapter = PlaylistSongAdapter(this, ArrayList(), R.layout.item_list, false, this)
|
||||
recyclerView.adapter = adapter
|
||||
} else {
|
||||
recyclerViewDragDropManager = RecyclerViewDragDropManager()
|
||||
val animator = RefactoredDefaultItemAnimator()
|
||||
adapter = OrderablePlaylistSongAdapter(this,
|
||||
ArrayList(),
|
||||
R.layout.item_list,
|
||||
false,
|
||||
this,
|
||||
object : OrderablePlaylistSongAdapter.OnMoveItemListener {
|
||||
override fun onMoveItem(fromPosition: Int, toPosition: Int) {
|
||||
if (PlaylistsUtil.moveItem(this@PlaylistDetailActivity, playlist.id, fromPosition, toPosition)) {
|
||||
val song = adapter.dataSet.removeAt(fromPosition)
|
||||
adapter.dataSet.add(toPosition, song)
|
||||
adapter.notifyItemMoved(fromPosition, toPosition)
|
||||
}
|
||||
}
|
||||
})
|
||||
wrappedAdapter = recyclerViewDragDropManager!!.createWrappedAdapter(adapter)
|
||||
|
||||
override fun createContentView(): View {
|
||||
return wrapSlidingMusicPanel(R.layout.activity_playlist_detail)
|
||||
}
|
||||
recyclerView.adapter = wrappedAdapter
|
||||
recyclerView.itemAnimator = animator
|
||||
|
||||
private fun setUpRecyclerView() {
|
||||
ViewUtil.setUpFastScrollRecyclerViewColor(this, recyclerView)
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
if (playlist is AbsCustomPlaylist) {
|
||||
adapter = PlaylistSongAdapter(this, ArrayList(), R.layout.item_list, false, this)
|
||||
recyclerView.adapter = adapter
|
||||
} else {
|
||||
recyclerViewDragDropManager = RecyclerViewDragDropManager()
|
||||
val animator = RefactoredDefaultItemAnimator()
|
||||
adapter = OrderablePlaylistSongAdapter(this,
|
||||
ArrayList(),
|
||||
R.layout.item_list,
|
||||
false,
|
||||
this,
|
||||
object : OrderablePlaylistSongAdapter.OnMoveItemListener {
|
||||
override fun onMoveItem(
|
||||
fromPosition: Int,
|
||||
toPosition: Int
|
||||
) {
|
||||
if (PlaylistsUtil.moveItem(
|
||||
this@PlaylistDetailActivity,
|
||||
playlist.id,
|
||||
fromPosition,
|
||||
toPosition
|
||||
)) {
|
||||
val song = adapter.dataSet.removeAt(
|
||||
fromPosition
|
||||
)
|
||||
adapter.dataSet.add(toPosition, song)
|
||||
adapter.notifyItemMoved(
|
||||
fromPosition,
|
||||
toPosition
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
wrappedAdapter = recyclerViewDragDropManager!!.createWrappedAdapter(adapter)
|
||||
recyclerViewDragDropManager?.attachRecyclerView(recyclerView)
|
||||
}
|
||||
adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onChanged() {
|
||||
super.onChanged()
|
||||
checkIsEmpty()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
recyclerView.adapter = wrappedAdapter
|
||||
recyclerView.itemAnimator = animator
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
playlistSongsPresenter.loadPlaylistSongs(playlist)
|
||||
}
|
||||
|
||||
recyclerViewDragDropManager?.attachRecyclerView(recyclerView)
|
||||
}
|
||||
adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onChanged() {
|
||||
super.onChanged()
|
||||
checkIsEmpty()
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun setUpToolBar() {
|
||||
toolbar.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
||||
setSupportActionBar(toolbar)
|
||||
title = playlist.name
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
playlistSongsPresenter.loadPlaylistSongs(playlist)
|
||||
}
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(
|
||||
if (playlist is AbsCustomPlaylist) R.menu.menu_smart_playlist_detail
|
||||
else R.menu.menu_playlist_detail, menu
|
||||
)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
private fun setUpToolBar() {
|
||||
applyToolbar(toolbar)
|
||||
title = playlist.name
|
||||
}
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return PlaylistMenuHelper.handleMenuClick(this, playlist, item)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(
|
||||
if (playlist is AbsCustomPlaylist) R.menu.menu_smart_playlist_detail
|
||||
else R.menu.menu_playlist_detail, menu
|
||||
)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
if (cab != null && cab!!.isActive) {
|
||||
cab!!.finish()
|
||||
}
|
||||
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp).setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
ATHUtil.resolveColor(
|
||||
this,
|
||||
R.attr.colorPrimary
|
||||
)
|
||||
)
|
||||
).start(callback)
|
||||
return cab!!
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return PlaylistMenuHelper.handleMenuClick(this, playlist, item)
|
||||
}
|
||||
override fun onBackPressed() {
|
||||
if (cab != null && cab!!.isActive) {
|
||||
cab!!.finish()
|
||||
} else {
|
||||
recyclerView!!.stopScroll()
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
if (cab != null && cab!!.isActive) {
|
||||
cab!!.finish()
|
||||
}
|
||||
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp).setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
ATHUtil.resolveColor(
|
||||
this,
|
||||
R.attr.colorPrimary
|
||||
)
|
||||
)
|
||||
).start(callback)
|
||||
return cab!!
|
||||
}
|
||||
override fun onMediaStoreChanged() {
|
||||
super.onMediaStoreChanged()
|
||||
if (playlist !is AbsCustomPlaylist) {
|
||||
// Playlist deleted
|
||||
if (!PlaylistsUtil.doesPlaylistExist(this, playlist.id)) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
// Playlist renamed
|
||||
val playlistName = PlaylistsUtil.getNameForPlaylist(this, playlist.id.toLong())
|
||||
if (playlistName != playlist.name) {
|
||||
playlist = PlaylistLoader.getPlaylist(this, playlist.id)
|
||||
setToolbarTitle(playlist.name)
|
||||
}
|
||||
}
|
||||
playlistSongsPresenter.loadPlaylistSongs(playlist)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (cab != null && cab!!.isActive) {
|
||||
cab!!.finish()
|
||||
} else {
|
||||
recyclerView!!.stopScroll()
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
private fun setToolbarTitle(title: String) {
|
||||
supportActionBar!!.title = title
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
super.onMediaStoreChanged()
|
||||
if (playlist !is AbsCustomPlaylist) {
|
||||
// Playlist deleted
|
||||
if (!PlaylistsUtil.doesPlaylistExist(this, playlist.id)) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
// Playlist renamed
|
||||
val playlistName = PlaylistsUtil.getNameForPlaylist(this, playlist.id.toLong())
|
||||
if (playlistName != playlist.name) {
|
||||
playlist = PlaylistLoader.getPlaylist(this, playlist.id)
|
||||
setToolbarTitle(playlist.name)
|
||||
}
|
||||
}
|
||||
playlistSongsPresenter.loadPlaylistSongs(playlist)
|
||||
}
|
||||
private fun checkForPadding() {
|
||||
val height = DensityUtil.dip2px(this, 52f)
|
||||
recyclerView.setPadding(0, 0, 0, (height))
|
||||
}
|
||||
|
||||
private fun setToolbarTitle(title: String) {
|
||||
supportActionBar!!.title = title
|
||||
}
|
||||
private fun checkIsEmpty() {
|
||||
checkForPadding()
|
||||
emptyEmoji.text = getEmojiByUnicode(0x1F631)
|
||||
empty.visibility = if (adapter.itemCount == 0) View.VISIBLE else View.GONE
|
||||
emptyText.visibility = if (adapter.itemCount == 0) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
private fun checkForPadding() {
|
||||
val height = DensityUtil.dip2px(this, 52f)
|
||||
recyclerView.setPadding(0, 0, 0, (height))
|
||||
}
|
||||
private fun getEmojiByUnicode(unicode: Int): String {
|
||||
return String(Character.toChars(unicode))
|
||||
}
|
||||
|
||||
private fun checkIsEmpty() {
|
||||
checkForPadding()
|
||||
empty.visibility = if (adapter.itemCount == 0) View.VISIBLE else View.GONE
|
||||
emptyText.visibility = if (adapter.itemCount == 0) View.VISIBLE else View.GONE
|
||||
}
|
||||
public override fun onPause() {
|
||||
if (recyclerViewDragDropManager != null) {
|
||||
recyclerViewDragDropManager!!.cancelDrag()
|
||||
}
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
public override fun onPause() {
|
||||
if (recyclerViewDragDropManager != null) {
|
||||
recyclerViewDragDropManager!!.cancelDrag()
|
||||
}
|
||||
super.onPause()
|
||||
}
|
||||
override fun onDestroy() {
|
||||
if (recyclerViewDragDropManager != null) {
|
||||
recyclerViewDragDropManager!!.release()
|
||||
recyclerViewDragDropManager = null
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
if (recyclerViewDragDropManager != null) {
|
||||
recyclerViewDragDropManager!!.release()
|
||||
recyclerViewDragDropManager = null
|
||||
}
|
||||
if (recyclerView != null) {
|
||||
recyclerView!!.itemAnimator = null
|
||||
recyclerView!!.adapter = null
|
||||
}
|
||||
|
||||
if (recyclerView != null) {
|
||||
recyclerView!!.itemAnimator = null
|
||||
recyclerView!!.adapter = null
|
||||
}
|
||||
if (wrappedAdapter != null) {
|
||||
WrapperAdapterUtils.releaseAll(wrappedAdapter)
|
||||
wrappedAdapter = null
|
||||
}
|
||||
super.onDestroy()
|
||||
playlistSongsPresenter.detachView()
|
||||
}
|
||||
|
||||
if (wrappedAdapter != null) {
|
||||
WrapperAdapterUtils.releaseAll(wrappedAdapter)
|
||||
wrappedAdapter = null
|
||||
}
|
||||
super.onDestroy()
|
||||
playlistSongsPresenter.detachView()
|
||||
}
|
||||
override fun showEmptyView() {
|
||||
empty.visibility = View.VISIBLE
|
||||
emptyText.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
empty.visibility = View.VISIBLE
|
||||
emptyText.visibility = View.VISIBLE
|
||||
}
|
||||
override fun songs(songs: ArrayList<Song>) {
|
||||
adapter.swapDataSet(songs)
|
||||
}
|
||||
|
||||
override fun songs(songs: ArrayList<Song>) {
|
||||
adapter.swapDataSet(songs)
|
||||
}
|
||||
|
||||
companion object {
|
||||
var EXTRA_PLAYLIST = "extra_playlist"
|
||||
}
|
||||
companion object {
|
||||
var EXTRA_PLAYLIST = "extra_playlist"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
package code.name.monkey.retromusic.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.*
|
||||
import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.retromusic.*
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.BuildConfig
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||
import com.anjlab.android.iab.v3.*
|
||||
import com.anjlab.android.iab.v3.BillingProcessor
|
||||
import com.anjlab.android.iab.v3.TransactionDetails
|
||||
import kotlinx.android.synthetic.main.activity_pro_version.*
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
|
@ -23,16 +26,11 @@ class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_pro_version)
|
||||
setDrawUnderStatusBar()
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
|
||||
toolbar.setBackgroundColor(primaryColor)
|
||||
appBarLayout.setBackgroundColor(primaryColor)
|
||||
|
||||
applyToolbar(toolbar)
|
||||
|
||||
restoreButton.isEnabled = false
|
||||
|
|
|
@ -27,7 +27,6 @@ import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
|||
import code.name.monkey.retromusic.adapter.SearchAdapter
|
||||
import code.name.monkey.retromusic.mvp.presenter.SearchPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.SearchView
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import kotlinx.android.synthetic.main.activity_search.*
|
||||
|
@ -46,14 +45,14 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_search)
|
||||
App.musicComponent.inject(this)
|
||||
searchPresenter.attachView(this)
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
searchPresenter.attachView(this)
|
||||
|
||||
setupRecyclerView()
|
||||
setUpToolBar()
|
||||
setupSearchView()
|
||||
|
@ -65,7 +64,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
back.setOnClickListener { onBackPressed() }
|
||||
voiceSearch.setOnClickListener { startMicSearch() }
|
||||
clearText.setOnClickListener { searchView.clearText() }
|
||||
searchContainer.setCardBackgroundColor(RetroColorUtil.toolbarColor(this))
|
||||
searchContainer.backgroundTintList = ColorStateList.valueOf(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
||||
|
||||
keyboardPopup.setOnClickListener {
|
||||
val inputManager = getSystemService(Service.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
|
@ -80,7 +79,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
keyboardPopup.iconTint = this
|
||||
}
|
||||
if (savedInstanceState != null) {
|
||||
query = savedInstanceState.getString(QUERY);
|
||||
query = savedInstanceState.getString(QUERY)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -125,7 +124,6 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
|
||||
private fun setUpToolBar() {
|
||||
title = null
|
||||
appBarLayout.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
}
|
||||
|
||||
private fun search(query: String) {
|
||||
|
|
|
@ -5,7 +5,8 @@ import android.view.MenuItem
|
|||
import androidx.annotation.StringRes
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.transition.TransitionManager
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||
import code.name.monkey.retromusic.fragments.settings.MainSettingsFragment
|
||||
|
@ -16,31 +17,28 @@ class SettingsActivity : AbsBaseActivity() {
|
|||
private val fragmentManager = supportFragmentManager
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setNavigationbarColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
setupToolbar()
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
fragmentManager.beginTransaction().replace(R.id.contentFrame, MainSettingsFragment())
|
||||
.commit()
|
||||
fragmentManager.beginTransaction().replace(R.id.contentFrame, MainSettingsFragment()).commit()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupToolbar() {
|
||||
setSupportActionBar(toolbar)
|
||||
setTitle(R.string.action_settings)
|
||||
toolbar.apply {
|
||||
setTitleTextColor(ATHUtil.resolveColor(this@SettingsActivity, R.attr.colorOnPrimary))
|
||||
setBackgroundColor(ATHUtil.resolveColor(this@SettingsActivity, R.attr.colorPrimary))
|
||||
setBackgroundColor(ATHUtil.resolveColor(this@SettingsActivity, R.attr.colorSurface))
|
||||
setNavigationOnClickListener { onBackPressed() }
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar)
|
||||
}
|
||||
appBarLayout.setBackgroundColor(ATHUtil.resolveColor(this@SettingsActivity, R.attr.colorPrimary))
|
||||
|
||||
setSupportActionBar(toolbar)
|
||||
}
|
||||
|
||||
fun setupFragment(fragment: Fragment, @StringRes titleName: Int) {
|
||||
|
|
|
@ -2,20 +2,30 @@ package code.name.monkey.retromusic.activities
|
|||
|
||||
import android.content.Intent
|
||||
import android.graphics.Paint
|
||||
import android.os.*
|
||||
import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.*
|
||||
import android.widget.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.recyclerview.widget.*
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.retromusic.*
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.retromusic.BuildConfig
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||
import com.anjlab.android.iab.v3.*
|
||||
import com.anjlab.android.iab.v3.BillingProcessor
|
||||
import com.anjlab.android.iab.v3.SkuDetails
|
||||
import com.anjlab.android.iab.v3.TransactionDetails
|
||||
import kotlinx.android.synthetic.main.activity_donation.*
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.*
|
||||
|
@ -49,7 +59,7 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
|
|||
setContentView(R.layout.activity_donation)
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
|
@ -61,8 +71,6 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
|
|||
}
|
||||
|
||||
private fun setupToolbar() {
|
||||
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
|
||||
appBarLayout.setBackgroundColor(primaryColor)
|
||||
applyToolbar(toolbar)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package code.name.monkey.retromusic.activities
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.*
|
||||
import android.content.ContentUris
|
||||
import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
|
@ -13,298 +16,266 @@ import android.text.TextUtils
|
|||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.retromusic.*
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.Constants.USER_BANNER
|
||||
import code.name.monkey.retromusic.Constants.USER_PROFILE
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.util.Compressor
|
||||
import code.name.monkey.retromusic.util.ImageUtil.getResizedBitmap
|
||||
import com.afollestad.materialdialogs.*
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.afollestad.materialdialogs.list.listItems
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.android.synthetic.main.activity_user_info.*
|
||||
import java.io.*
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
|
||||
class UserInfoActivity : AbsBaseActivity() {
|
||||
|
||||
private var disposable = CompositeDisposable()
|
||||
private var disposable = CompositeDisposable()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_user_info)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationBarColorPrimary()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_user_info)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
setupToolbar()
|
||||
applyToolbar(toolbar)
|
||||
|
||||
MaterialUtil.setTint(nameContainer, false)
|
||||
name.setText(PreferenceUtil.getInstance(this).userName)
|
||||
MaterialUtil.setTint(nameContainer, false)
|
||||
name.setText(PreferenceUtil.getInstance(this).userName)
|
||||
|
||||
if (PreferenceUtil.getInstance(this).profileImage.isNotEmpty()) {
|
||||
loadImageFromStorage(PreferenceUtil.getInstance(this).profileImage)
|
||||
}
|
||||
if (PreferenceUtil.getInstance(this).bannerImage.isNotEmpty()) {
|
||||
loadBannerFromStorage(PreferenceUtil.getInstance(this).bannerImage)
|
||||
}
|
||||
userImage.setOnClickListener {
|
||||
MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
title(text = getString(R.string.set_photo))
|
||||
listItems(
|
||||
items = listOf(
|
||||
getString(R.string.new_profile_photo),
|
||||
getString(R.string.remove_profile_photo)
|
||||
)
|
||||
) { _, position, _ ->
|
||||
when (position) {
|
||||
0 -> pickNewPhoto()
|
||||
1 -> PreferenceUtil.getInstance(this@UserInfoActivity).saveProfileImage("")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bannerSelect.setOnClickListener {
|
||||
showBannerOptions()
|
||||
}
|
||||
next.setOnClickListener {
|
||||
val nameString = name.text.toString().trim { it <= ' ' }
|
||||
if (TextUtils.isEmpty(nameString)) {
|
||||
Toast.makeText(this, "Umm name is empty", Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
/*val bioString = bio.text.toString().trim() { it <= ' ' }
|
||||
if (TextUtils.isEmpty(bioString)) {
|
||||
Toast.makeText(this, "Umm bio is empty", Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickListener
|
||||
if (PreferenceUtil.getInstance(this).profileImage.isNotEmpty()) {
|
||||
loadImageFromStorage(PreferenceUtil.getInstance(this).profileImage)
|
||||
}
|
||||
if (PreferenceUtil.getInstance(this).bannerImage.isNotEmpty()) {
|
||||
loadBannerFromStorage(PreferenceUtil.getInstance(this).bannerImage)
|
||||
}
|
||||
userImage.setOnClickListener {
|
||||
MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
cornerRadius(PreferenceUtil.getInstance(this@UserInfoActivity).dialogCorner)
|
||||
title(text = getString(R.string.set_photo))
|
||||
listItems(items = listOf(getString(R.string.new_profile_photo), getString(R.string.remove_profile_photo))) { _, position, _ ->
|
||||
when (position) {
|
||||
0 -> pickNewPhoto()
|
||||
1 -> PreferenceUtil.getInstance(this@UserInfoActivity).saveProfileImage("")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bannerSelect.setOnClickListener {
|
||||
MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
cornerRadius(PreferenceUtil.getInstance(this@UserInfoActivity).dialogCorner)
|
||||
title(R.string.select_banner_photo)
|
||||
listItems(items = listOf(getString(R.string.new_banner_photo), getString(R.string.remove_banner_photo)))
|
||||
{ _, position, _ ->
|
||||
when (position) {
|
||||
0 -> selectBannerImage()
|
||||
1 -> PreferenceUtil.getInstance(this@UserInfoActivity).setBannerImagePath("")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
next.setOnClickListener {
|
||||
val nameString = name.text.toString().trim { it <= ' ' }
|
||||
if (TextUtils.isEmpty(nameString)) {
|
||||
Toast.makeText(this, "Umm name is empty", Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
PreferenceUtil.getInstance(this).userName = nameString
|
||||
setResult(Activity.RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
next.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
|
||||
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.accentColor(this))))
|
||||
.apply {
|
||||
next.setTextColor(this)
|
||||
next.iconTint = this
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
PreferenceUtil.getInstance(this).userName = nameString
|
||||
//PreferenceUtil.getInstance().userBio = bioString
|
||||
setResult(Activity.RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
next.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
|
||||
ColorStateList.valueOf(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
this,
|
||||
ColorUtil.isColorLight(
|
||||
ThemeStore.accentColor(
|
||||
this
|
||||
)
|
||||
)
|
||||
)
|
||||
).apply {
|
||||
next.setTextColor(this)
|
||||
next.iconTint = this
|
||||
}
|
||||
}
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
private fun selectBannerImage() {
|
||||
val pickImageIntent = Intent(Intent.ACTION_PICK, Media.EXTERNAL_CONTENT_URI)
|
||||
pickImageIntent.type = "image/*"
|
||||
//pickImageIntent.putExtra("crop", "true")
|
||||
pickImageIntent.putExtra("outputX", 1290)
|
||||
pickImageIntent.putExtra("outputY", 720)
|
||||
pickImageIntent.putExtra("aspectX", 16)
|
||||
pickImageIntent.putExtra("aspectY", 9)
|
||||
pickImageIntent.putExtra("scale", true)
|
||||
//intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(
|
||||
Intent.createChooser(pickImageIntent, "Select Picture"),
|
||||
PICK_BANNER_REQUEST
|
||||
)
|
||||
}
|
||||
|
||||
private fun setupToolbar() {
|
||||
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
|
||||
applyToolbar(toolbar)
|
||||
appBarLayout.setBackgroundColor(primaryColor)
|
||||
}
|
||||
private fun pickNewPhoto() {
|
||||
val pickImageIntent = Intent(Intent.ACTION_PICK, Media.EXTERNAL_CONTENT_URI)
|
||||
pickImageIntent.type = "image/*"
|
||||
pickImageIntent.putExtra("crop", "true")
|
||||
pickImageIntent.putExtra("outputX", 512)
|
||||
pickImageIntent.putExtra("outputY", 512)
|
||||
pickImageIntent.putExtra("aspectX", 1)
|
||||
pickImageIntent.putExtra("aspectY", 1)
|
||||
pickImageIntent.putExtra("scale", true)
|
||||
startActivityForResult(
|
||||
Intent.createChooser(pickImageIntent, "Select Picture"),
|
||||
PICK_IMAGE_REQUEST
|
||||
)
|
||||
}
|
||||
|
||||
private fun showBannerOptions() {
|
||||
MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
||||
title(R.string.select_banner_photo)
|
||||
listItems(
|
||||
items = listOf(
|
||||
getString(R.string.new_banner_photo),
|
||||
getString(R.string.remove_banner_photo)
|
||||
)
|
||||
) { _, position, _ ->
|
||||
when (position) {
|
||||
0 -> selectBannerImage()
|
||||
1 -> PreferenceUtil.getInstance(this@UserInfoActivity).setBannerImagePath("")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
PICK_IMAGE_REQUEST -> {
|
||||
try {
|
||||
data.data?.let {
|
||||
val bitmap = getResizedBitmap(
|
||||
getBitmap(contentResolver, it),
|
||||
PROFILE_ICON_SIZE
|
||||
)
|
||||
val profileImagePath = saveToInternalStorage(bitmap, USER_PROFILE)
|
||||
PreferenceUtil.getInstance(this).saveProfileImage(profileImagePath)
|
||||
loadImageFromStorage(profileImagePath)
|
||||
}
|
||||
|
||||
private fun selectBannerImage() {
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
PICK_BANNER_REQUEST -> {
|
||||
try {
|
||||
data.data?.let {
|
||||
val bitmap = getBitmap(contentResolver, it)
|
||||
val profileImagePath = saveToInternalStorage(bitmap, USER_BANNER)
|
||||
PreferenceUtil.getInstance(this).setBannerImagePath(profileImagePath)
|
||||
loadBannerFromStorage(profileImagePath)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(PreferenceUtil.getInstance(this).bannerImage)) {
|
||||
val pickImageIntent = Intent(Intent.ACTION_PICK, Media.EXTERNAL_CONTENT_URI)
|
||||
pickImageIntent.type = "image/*"
|
||||
//pickImageIntent.putExtra("crop", "true")
|
||||
pickImageIntent.putExtra("outputX", 1290)
|
||||
pickImageIntent.putExtra("outputY", 720)
|
||||
pickImageIntent.putExtra("aspectX", 16)
|
||||
pickImageIntent.putExtra("aspectY", 9)
|
||||
pickImageIntent.putExtra("scale", true)
|
||||
//intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(
|
||||
Intent.createChooser(pickImageIntent, "Select Picture"),
|
||||
PICK_BANNER_REQUEST
|
||||
)
|
||||
} else {
|
||||
PreferenceUtil.getInstance(this).setBannerImagePath("")
|
||||
bannerImage.setImageResource(android.R.color.transparent)
|
||||
}
|
||||
}
|
||||
private fun getImagePathFromUri(aUri: Uri?): String? {
|
||||
var imagePath: String? = null
|
||||
if (aUri == null) {
|
||||
return imagePath
|
||||
}
|
||||
if (DocumentsContract.isDocumentUri(App.getContext(), aUri)) {
|
||||
val documentId = DocumentsContract.getDocumentId(aUri)
|
||||
if ("com.android.providers.media.documents" == aUri.authority) {
|
||||
val id = documentId.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[1]
|
||||
val selection = Media._ID + "=" + id
|
||||
imagePath = getImagePath(Media.EXTERNAL_CONTENT_URI, selection)
|
||||
} else if ("com.android.providers.downloads.documents" == aUri.authority) {
|
||||
val contentUri = ContentUris.withAppendedId(
|
||||
Uri.parse("content://downloads/public_downloads"),
|
||||
java.lang.Long.valueOf(documentId)
|
||||
)
|
||||
imagePath = getImagePath(contentUri, null)
|
||||
}
|
||||
} else if ("content".equals(aUri.scheme!!, ignoreCase = true)) {
|
||||
imagePath = getImagePath(aUri, null)
|
||||
} else if ("file".equals(aUri.scheme!!, ignoreCase = true)) {
|
||||
imagePath = aUri.path
|
||||
}
|
||||
return imagePath
|
||||
}
|
||||
|
||||
private fun pickNewPhoto() {
|
||||
val pickImageIntent = Intent(Intent.ACTION_PICK, Media.EXTERNAL_CONTENT_URI)
|
||||
pickImageIntent.type = "image/*"
|
||||
pickImageIntent.putExtra("crop", "true")
|
||||
pickImageIntent.putExtra("outputX", 512)
|
||||
pickImageIntent.putExtra("outputY", 512)
|
||||
pickImageIntent.putExtra("aspectX", 1)
|
||||
pickImageIntent.putExtra("aspectY", 1)
|
||||
pickImageIntent.putExtra("scale", true)
|
||||
startActivityForResult(
|
||||
Intent.createChooser(pickImageIntent, "Select Picture"),
|
||||
PICK_IMAGE_REQUEST
|
||||
)
|
||||
}
|
||||
private fun getImagePath(aUri: Uri, aSelection: String?): String? {
|
||||
var path: String? = null
|
||||
val cursor = App.getContext().contentResolver.query(aUri, null, aSelection, null, null)
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToFirst()) {
|
||||
path = cursor.getString(cursor.getColumnIndex(Media.DATA))
|
||||
}
|
||||
cursor.close()
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
PICK_IMAGE_REQUEST -> {
|
||||
try {
|
||||
data.data?.let {
|
||||
val bitmap = getResizedBitmap(
|
||||
getBitmap(contentResolver, it),
|
||||
PROFILE_ICON_SIZE
|
||||
)
|
||||
val profileImagePath = saveToInternalStorage(bitmap, USER_PROFILE)
|
||||
PreferenceUtil.getInstance(this).saveProfileImage(profileImagePath)
|
||||
loadImageFromStorage(profileImagePath)
|
||||
}
|
||||
private fun loadBannerFromStorage(profileImagePath: String) {
|
||||
disposable.add(
|
||||
Compressor(this).setQuality(100).setCompressFormat(Bitmap.CompressFormat.WEBP).compressToBitmapAsFlowable(
|
||||
File(profileImagePath, USER_BANNER)
|
||||
).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(
|
||||
{ bitmap -> bannerImage.setImageBitmap(bitmap) },
|
||||
{ t -> println() })
|
||||
)
|
||||
}
|
||||
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
PICK_BANNER_REQUEST -> {
|
||||
try {
|
||||
data.data?.let {
|
||||
val bitmap = getBitmap(contentResolver, it)
|
||||
val profileImagePath = saveToInternalStorage(bitmap, USER_BANNER)
|
||||
PreferenceUtil.getInstance(this).setBannerImagePath(profileImagePath)
|
||||
loadBannerFromStorage(profileImagePath)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun loadImageFromStorage(path: String) {
|
||||
disposable.add(
|
||||
Compressor(this).setMaxHeight(300).setMaxWidth(300).setQuality(75).setCompressFormat(
|
||||
Bitmap.CompressFormat.WEBP
|
||||
).compressToBitmapAsFlowable(
|
||||
File(
|
||||
path,
|
||||
USER_PROFILE
|
||||
)
|
||||
).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(
|
||||
{ bitmap -> userImage!!.setImageBitmap(bitmap) },
|
||||
{ t -> println() })
|
||||
)
|
||||
}
|
||||
|
||||
private fun getImagePathFromUri(aUri: Uri?): String? {
|
||||
var imagePath: String? = null
|
||||
if (aUri == null) {
|
||||
return imagePath
|
||||
}
|
||||
if (DocumentsContract.isDocumentUri(App.getContext(), aUri)) {
|
||||
val documentId = DocumentsContract.getDocumentId(aUri)
|
||||
if ("com.android.providers.media.documents" == aUri.authority) {
|
||||
val id = documentId.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[1]
|
||||
val selection = Media._ID + "=" + id
|
||||
imagePath = getImagePath(Media.EXTERNAL_CONTENT_URI, selection)
|
||||
} else if ("com.android.providers.downloads.documents" == aUri.authority) {
|
||||
val contentUri = ContentUris.withAppendedId(
|
||||
Uri.parse("content://downloads/public_downloads"),
|
||||
java.lang.Long.valueOf(documentId)
|
||||
)
|
||||
imagePath = getImagePath(contentUri, null)
|
||||
}
|
||||
} else if ("content".equals(aUri.scheme!!, ignoreCase = true)) {
|
||||
imagePath = getImagePath(aUri, null)
|
||||
} else if ("file".equals(aUri.scheme!!, ignoreCase = true)) {
|
||||
imagePath = aUri.path
|
||||
}
|
||||
return imagePath
|
||||
}
|
||||
private fun saveToInternalStorage(bitmapImage: Bitmap, userBanner: String): String {
|
||||
val cw = ContextWrapper(this)
|
||||
val directory = cw.getDir("imageDir", Context.MODE_PRIVATE)
|
||||
val myPath = File(directory, userBanner)
|
||||
var fos: FileOutputStream? = null
|
||||
try {
|
||||
fos = FileOutputStream(myPath)
|
||||
// Use the compress method on the BitMap object to write image to the OutputStream
|
||||
bitmapImage.compress(Bitmap.CompressFormat.WEBP, 100, fos)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
try {
|
||||
fos?.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return directory.absolutePath
|
||||
}
|
||||
|
||||
private fun getImagePath(aUri: Uri, aSelection: String?): String? {
|
||||
var path: String? = null
|
||||
val cursor = App.getContext().contentResolver.query(aUri, null, aSelection, null, null)
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToFirst()) {
|
||||
path = cursor.getString(cursor.getColumnIndex(Media.DATA))
|
||||
}
|
||||
cursor.close()
|
||||
}
|
||||
return path
|
||||
}
|
||||
companion object {
|
||||
|
||||
private fun loadBannerFromStorage(profileImagePath: String) {
|
||||
disposable.add(
|
||||
Compressor(this).setQuality(100).setCompressFormat(Bitmap.CompressFormat.WEBP).compressToBitmapAsFlowable(
|
||||
File(profileImagePath, USER_BANNER)
|
||||
).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(
|
||||
{ bitmap -> bannerImage.setImageBitmap(bitmap) },
|
||||
{ t -> println() })
|
||||
)
|
||||
}
|
||||
|
||||
private fun loadImageFromStorage(path: String) {
|
||||
disposable.add(
|
||||
Compressor(this).setMaxHeight(300).setMaxWidth(300).setQuality(75).setCompressFormat(
|
||||
Bitmap.CompressFormat.WEBP
|
||||
).compressToBitmapAsFlowable(
|
||||
File(
|
||||
path,
|
||||
USER_PROFILE
|
||||
)
|
||||
).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(
|
||||
{ bitmap -> userImage!!.setImageBitmap(bitmap) },
|
||||
{ t -> println() })
|
||||
)
|
||||
}
|
||||
|
||||
private fun saveToInternalStorage(bitmapImage: Bitmap, userBanner: String): String {
|
||||
val cw = ContextWrapper(this)
|
||||
val directory = cw.getDir("imageDir", Context.MODE_PRIVATE)
|
||||
val myPath = File(directory, userBanner)
|
||||
var fos: FileOutputStream? = null
|
||||
try {
|
||||
fos = FileOutputStream(myPath)
|
||||
// Use the compress method on the BitMap object to write image to the OutputStream
|
||||
bitmapImage.compress(Bitmap.CompressFormat.WEBP, 100, fos)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
try {
|
||||
fos?.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
return directory.absolutePath
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private const val PICK_IMAGE_REQUEST = 9002
|
||||
private const val PICK_BANNER_REQUEST = 9004
|
||||
private const val PROFILE_ICON_SIZE = 400
|
||||
}
|
||||
private const val PICK_IMAGE_REQUEST = 9002
|
||||
private const val PICK_BANNER_REQUEST = 9004
|
||||
private const val PROFILE_ICON_SIZE = 400
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.pickImage(requestCode: Int) {
|
||||
Intent(Intent.ACTION_GET_CONTENT).apply {
|
||||
addCategory(Intent.CATEGORY_OPENABLE)
|
||||
type = "image/*"
|
||||
startActivityForResult(this, requestCode)
|
||||
}
|
||||
Intent(Intent.ACTION_GET_CONTENT).apply {
|
||||
addCategory(Intent.CATEGORY_OPENABLE)
|
||||
type = "image/*"
|
||||
startActivityForResult(this, requestCode)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,20 +49,18 @@ public class WhatsNewActivity extends AbsBaseActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
setDrawUnderStatusBar();
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_whats_new);
|
||||
|
||||
setStatusbarColorAuto();
|
||||
setNavigationBarColorPrimary();
|
||||
setNavigationbarColorAuto();
|
||||
setTaskDescriptionColorAuto();
|
||||
|
||||
webView = findViewById(R.id.webView);
|
||||
toolbar = findViewById(R.id.toolbar);
|
||||
appBarLayout = findViewById(R.id.appBarLayout);
|
||||
|
||||
int primaryColor = INSTANCE.resolveColor(this, R.attr.colorPrimary);
|
||||
toolbar.setBackgroundColor(primaryColor);
|
||||
appBarLayout.setBackgroundColor(primaryColor);
|
||||
toolbar.setBackgroundColor(INSTANCE.resolveColor(this, R.attr.colorSurface));
|
||||
//setSupportActionBar(toolbar);
|
||||
|
||||
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
||||
|
@ -79,11 +77,10 @@ public class WhatsNewActivity extends AbsBaseActivity {
|
|||
|
||||
// Inject color values for WebView body background and links
|
||||
final boolean isDark = INSTANCE.isWindowBackgroundDark(this);
|
||||
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.colorPrimary, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
||||
final String changeLog = buf.toString()
|
||||
.replace("{style-placeholder}",
|
||||
String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor))
|
||||
.replace("{style-placeholder}", String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor))
|
||||
.replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this)))
|
||||
.replace("{link-color-active}", colorToCSS(ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this))));
|
||||
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
package code.name.monkey.retromusic.activities.base
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.*
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewTreeObserver
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.fragment.app.Fragment
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.*
|
||||
import code.name.monkey.retromusic.fragments.*
|
||||
import code.name.monkey.retromusic.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.fragments.MiniPlayerFragment
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||
import code.name.monkey.retromusic.fragments.player.adaptive.AdaptiveFragment
|
||||
|
@ -28,330 +32,326 @@ import code.name.monkey.retromusic.fragments.player.plain.PlainPlayerFragment
|
|||
import code.name.monkey.retromusic.fragments.player.simple.SimplePlayerFragment
|
||||
import code.name.monkey.retromusic.fragments.player.tiny.TinyPlayerFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.model.CategoryInfo
|
||||
import code.name.monkey.retromusic.util.DensityUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import kotlinx.android.synthetic.main.sliding_music_panel_layout.*
|
||||
|
||||
abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlayerFragment.Callbacks {
|
||||
companion object {
|
||||
val TAG: String = AbsSlidingMusicPanelActivity::class.java.simpleName
|
||||
}
|
||||
companion object {
|
||||
val TAG: String = AbsSlidingMusicPanelActivity::class.java.simpleName
|
||||
}
|
||||
|
||||
private lateinit var bottomSheetBehavior: BottomSheetBehavior<MaterialCardView>
|
||||
private var miniPlayerFragment: MiniPlayerFragment? = null
|
||||
private var playerFragment: AbsPlayerFragment? = null
|
||||
private var currentNowPlayingScreen: NowPlayingScreen? = null
|
||||
private var navigationBarColor: Int = 0
|
||||
private var taskColor: Int = 0
|
||||
private var lightStatusBar: Boolean = false
|
||||
private var lightNavigationBar: Boolean = false
|
||||
private var navigationBarColorAnimator: ValueAnimator? = null
|
||||
protected abstract fun createContentView(): View
|
||||
private val panelState: Int
|
||||
get() = bottomSheetBehavior.state
|
||||
private lateinit var bottomSheetBehavior: BottomSheetBehavior<MaterialCardView>
|
||||
private var miniPlayerFragment: MiniPlayerFragment? = null
|
||||
private var playerFragment: AbsPlayerFragment? = null
|
||||
private var currentNowPlayingScreen: NowPlayingScreen? = null
|
||||
private var navigationBarColor: Int = 0
|
||||
private var taskColor: Int = 0
|
||||
private var lightStatusBar: Boolean = false
|
||||
private var lightNavigationBar: Boolean = false
|
||||
private var navigationBarColorAnimator: ValueAnimator? = null
|
||||
protected abstract fun createContentView(): View
|
||||
private val panelState: Int
|
||||
get() = bottomSheetBehavior.state
|
||||
|
||||
private val bottomSheetCallbackList = object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
private val bottomSheetCallbackList = object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||
setMiniPlayerAlphaProgress(slideOffset)
|
||||
dimBackground.show()
|
||||
dimBackground.alpha = slideOffset
|
||||
}
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||
setMiniPlayerAlphaProgress(slideOffset)
|
||||
dimBackground.show()
|
||||
dimBackground.alpha = slideOffset
|
||||
}
|
||||
|
||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||
when (newState) {
|
||||
BottomSheetBehavior.STATE_EXPANDED -> {
|
||||
onPanelExpanded()
|
||||
}
|
||||
BottomSheetBehavior.STATE_COLLAPSED -> {
|
||||
onPanelCollapsed()
|
||||
dimBackground.hide()
|
||||
}
|
||||
else -> {
|
||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||
when (newState) {
|
||||
BottomSheetBehavior.STATE_EXPANDED -> {
|
||||
onPanelExpanded()
|
||||
}
|
||||
BottomSheetBehavior.STATE_COLLAPSED -> {
|
||||
onPanelCollapsed()
|
||||
dimBackground.hide()
|
||||
}
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(createContentView())
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(createContentView())
|
||||
|
||||
chooseFragmentForTheme()
|
||||
setupSlidingUpPanel()
|
||||
chooseFragmentForTheme()
|
||||
setupSlidingUpPanel()
|
||||
|
||||
updateTabs()
|
||||
updateTabs()
|
||||
|
||||
bottomSheetBehavior = BottomSheetBehavior.from(slidingPanel)
|
||||
bottomSheetBehavior = BottomSheetBehavior.from(slidingPanel)
|
||||
|
||||
val themeColor = ATHUtil.resolveColor(this, R.attr.colorPrimary, Color.GRAY)
|
||||
dimBackground.setBackgroundColor(ColorUtil.withAlpha(themeColor, 0.5f))
|
||||
}
|
||||
val themeColor = ATHUtil.resolveColor(this, android.R.attr.windowBackground, Color.GRAY)
|
||||
dimBackground.setBackgroundColor(ColorUtil.withAlpha(themeColor, 0.5f))
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (currentNowPlayingScreen != PreferenceUtil.getInstance(this).nowPlayingScreen) {
|
||||
postRecreate()
|
||||
}
|
||||
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallbackList)
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (currentNowPlayingScreen != PreferenceUtil.getInstance(this).nowPlayingScreen) {
|
||||
postRecreate()
|
||||
}
|
||||
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallbackList)
|
||||
|
||||
if (bottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
setMiniPlayerAlphaProgress(1f)
|
||||
}
|
||||
}
|
||||
if (bottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
setMiniPlayerAlphaProgress(1f)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallbackList)
|
||||
if (navigationBarColorAnimator != null) navigationBarColorAnimator!!.cancel() // just in case
|
||||
}
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallbackList)
|
||||
if (navigationBarColorAnimator != null) navigationBarColorAnimator?.cancel() // just in case
|
||||
}
|
||||
|
||||
protected fun wrapSlidingMusicPanel(@LayoutRes resId: Int): View {
|
||||
@SuppressLint("InflateParams") val slidingMusicPanelLayout = layoutInflater.inflate(
|
||||
R.layout.sliding_music_panel_layout, null
|
||||
)
|
||||
val contentContainer = slidingMusicPanelLayout.findViewById<ViewGroup>(R.id.mainContentFrame)
|
||||
layoutInflater.inflate(resId, contentContainer)
|
||||
return slidingMusicPanelLayout
|
||||
}
|
||||
protected fun wrapSlidingMusicPanel(@LayoutRes resId: Int): View {
|
||||
val slidingMusicPanelLayout = layoutInflater.inflate(R.layout.sliding_music_panel_layout, null)
|
||||
val contentContainer = slidingMusicPanelLayout.findViewById<ViewGroup>(R.id.mainContentFrame)
|
||||
layoutInflater.inflate(resId, contentContainer)
|
||||
return slidingMusicPanelLayout
|
||||
}
|
||||
|
||||
private fun collapsePanel() {
|
||||
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||
}
|
||||
private fun collapsePanel() {
|
||||
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||
}
|
||||
|
||||
fun expandPanel() {
|
||||
bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
setMiniPlayerAlphaProgress(1f)
|
||||
}
|
||||
fun expandPanel() {
|
||||
bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
setMiniPlayerAlphaProgress(1f)
|
||||
}
|
||||
|
||||
private fun setMiniPlayerAlphaProgress(progress: Float) {
|
||||
if (miniPlayerFragment?.view == null) return
|
||||
val alpha = 1 - progress
|
||||
miniPlayerFragment?.view?.alpha = alpha
|
||||
// necessary to make the views below clickable
|
||||
miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE
|
||||
private fun setMiniPlayerAlphaProgress(progress: Float) {
|
||||
if (miniPlayerFragment?.view == null) return
|
||||
val alpha = 1 - progress
|
||||
miniPlayerFragment?.view?.alpha = alpha
|
||||
// necessary to make the views below clickable
|
||||
miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE
|
||||
|
||||
bottomNavigationView.translationY = progress * 500
|
||||
bottomNavigationView.alpha = alpha
|
||||
}
|
||||
bottomNavigationView.translationY = progress * 500
|
||||
//bottomNavigationView.alpha = alpha
|
||||
}
|
||||
|
||||
open fun onPanelCollapsed() {
|
||||
// restore values
|
||||
super.setLightStatusbar(lightStatusBar)
|
||||
super.setTaskDescriptionColor(taskColor)
|
||||
super.setNavigationbarColor(navigationBarColor)
|
||||
super.setLightNavigationBar(lightNavigationBar)
|
||||
open fun onPanelCollapsed() {
|
||||
// restore values
|
||||
super.setLightStatusbar(lightStatusBar)
|
||||
super.setTaskDescriptionColor(taskColor)
|
||||
super.setNavigationbarColor(navigationBarColor)
|
||||
super.setLightNavigationBar(lightNavigationBar)
|
||||
|
||||
|
||||
playerFragment?.setMenuVisibility(false)
|
||||
playerFragment?.userVisibleHint = false
|
||||
playerFragment?.onHide()
|
||||
}
|
||||
playerFragment?.setMenuVisibility(false)
|
||||
playerFragment?.userVisibleHint = false
|
||||
playerFragment?.onHide()
|
||||
}
|
||||
|
||||
open fun onPanelExpanded() {
|
||||
val playerFragmentColor = playerFragment!!.paletteColor
|
||||
super.setTaskDescriptionColor(playerFragmentColor)
|
||||
open fun onPanelExpanded() {
|
||||
val playerFragmentColor = playerFragment!!.paletteColor
|
||||
super.setTaskDescriptionColor(playerFragmentColor)
|
||||
|
||||
playerFragment?.setMenuVisibility(true)
|
||||
playerFragment?.userVisibleHint = true
|
||||
playerFragment?.onShow()
|
||||
onPaletteColorChanged()
|
||||
}
|
||||
playerFragment?.setMenuVisibility(true)
|
||||
playerFragment?.userVisibleHint = true
|
||||
playerFragment?.onShow()
|
||||
onPaletteColorChanged()
|
||||
}
|
||||
|
||||
private fun setupSlidingUpPanel() {
|
||||
slidingPanel.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
if (currentNowPlayingScreen != PEAK) {
|
||||
val params = slidingPanel.layoutParams as ViewGroup.LayoutParams
|
||||
params.height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
slidingPanel.layoutParams = params
|
||||
}
|
||||
when (panelState) {
|
||||
BottomSheetBehavior.STATE_EXPANDED -> onPanelExpanded()
|
||||
BottomSheetBehavior.STATE_COLLAPSED -> onPanelCollapsed()
|
||||
else -> playerFragment!!.onHide()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun setupSlidingUpPanel() {
|
||||
slidingPanel.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
if (currentNowPlayingScreen != PEAK) {
|
||||
val params = slidingPanel.layoutParams as ViewGroup.LayoutParams
|
||||
params.height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
slidingPanel.layoutParams = params
|
||||
}
|
||||
when (panelState) {
|
||||
BottomSheetBehavior.STATE_EXPANDED -> onPanelExpanded()
|
||||
BottomSheetBehavior.STATE_COLLAPSED -> onPanelCollapsed()
|
||||
else -> playerFragment!!.onHide()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun toggleBottomNavigationView(toggle: Boolean) {
|
||||
bottomNavigationView.visibility = if (toggle) View.GONE else View.VISIBLE
|
||||
}
|
||||
fun toggleBottomNavigationView(toggle: Boolean) {
|
||||
bottomNavigationView.visibility = if (toggle) View.GONE else View.VISIBLE
|
||||
}
|
||||
|
||||
fun getBottomNavigationView(): BottomNavigationBarTinted {
|
||||
return bottomNavigationView
|
||||
}
|
||||
fun getBottomNavigationView(): BottomNavigationBarTinted {
|
||||
return bottomNavigationView
|
||||
}
|
||||
|
||||
private fun hideBottomBar(hide: Boolean) {
|
||||
val heightOfBar = resources.getDimensionPixelSize(R.dimen.mini_player_height)
|
||||
val heightOfBarWithTabs = resources.getDimensionPixelSize(R.dimen.mini_player_height_expanded)
|
||||
private fun hideBottomBar(hide: Boolean) {
|
||||
val heightOfBar = resources.getDimensionPixelSize(R.dimen.mini_player_height)
|
||||
val heightOfBarWithTabs = resources.getDimensionPixelSize(R.dimen.mini_player_height_expanded)
|
||||
|
||||
if (hide) {
|
||||
bottomSheetBehavior.isHideable = true
|
||||
bottomSheetBehavior.peekHeight = 0
|
||||
collapsePanel()
|
||||
bottomNavigationView.elevation = DensityUtil.dip2px(this, 10f).toFloat()
|
||||
} else {
|
||||
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
slidingPanel.cardElevation = DensityUtil.dip2px(this, 10f).toFloat()
|
||||
bottomNavigationView.elevation = DensityUtil.dip2px(this, 10f).toFloat()
|
||||
bottomSheetBehavior.isHideable = false
|
||||
bottomSheetBehavior.peekHeight = if (bottomNavigationView.visibility == View.VISIBLE) heightOfBarWithTabs else heightOfBar
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hide) {
|
||||
bottomSheetBehavior.isHideable = true
|
||||
bottomSheetBehavior.peekHeight = 0
|
||||
collapsePanel()
|
||||
bottomNavigationView.elevation = DensityUtil.dip2px(this, 10f).toFloat()
|
||||
} else {
|
||||
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
slidingPanel.cardElevation = DensityUtil.dip2px(this, 10f).toFloat()
|
||||
bottomNavigationView.elevation = DensityUtil.dip2px(this, 10f).toFloat()
|
||||
bottomSheetBehavior.isHideable = false
|
||||
bottomSheetBehavior.peekHeight = if (bottomNavigationView.visibility == View.VISIBLE) heightOfBarWithTabs else heightOfBar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setBottomBarVisibility(gone: Int) {
|
||||
bottomNavigationView.visibility = gone
|
||||
hideBottomBar(false)
|
||||
}
|
||||
fun setBottomBarVisibility(gone: Int) {
|
||||
bottomNavigationView.visibility = gone
|
||||
hideBottomBar(false)
|
||||
}
|
||||
|
||||
private fun chooseFragmentForTheme() {
|
||||
currentNowPlayingScreen = PreferenceUtil.getInstance(this).nowPlayingScreen
|
||||
private fun chooseFragmentForTheme() {
|
||||
currentNowPlayingScreen = PreferenceUtil.getInstance(this).nowPlayingScreen
|
||||
|
||||
val fragment: Fragment = when (currentNowPlayingScreen) {
|
||||
BLUR -> BlurPlayerFragment()
|
||||
ADAPTIVE -> AdaptiveFragment()
|
||||
NORMAL -> PlayerFragment()
|
||||
CARD -> CardFragment()
|
||||
BLUR_CARD -> CardBlurFragment()
|
||||
FIT -> FitFragment()
|
||||
FLAT -> FlatPlayerFragment()
|
||||
FULL -> FullPlayerFragment()
|
||||
PLAIN -> PlainPlayerFragment()
|
||||
SIMPLE -> SimplePlayerFragment()
|
||||
MATERIAL -> MaterialFragment()
|
||||
COLOR -> ColorFragment()
|
||||
TINY -> TinyPlayerFragment()
|
||||
PEAK -> PeakPlayerFragment()
|
||||
else -> PlayerFragment()
|
||||
} // must implement AbsPlayerFragment
|
||||
supportFragmentManager.beginTransaction().replace(R.id.playerFragmentContainer, fragment)
|
||||
.commit()
|
||||
supportFragmentManager.executePendingTransactions()
|
||||
val fragment: Fragment = when (currentNowPlayingScreen) {
|
||||
BLUR -> BlurPlayerFragment()
|
||||
ADAPTIVE -> AdaptiveFragment()
|
||||
NORMAL -> PlayerFragment()
|
||||
CARD -> CardFragment()
|
||||
BLUR_CARD -> CardBlurFragment()
|
||||
FIT -> FitFragment()
|
||||
FLAT -> FlatPlayerFragment()
|
||||
FULL -> FullPlayerFragment()
|
||||
PLAIN -> PlainPlayerFragment()
|
||||
SIMPLE -> SimplePlayerFragment()
|
||||
MATERIAL -> MaterialFragment()
|
||||
COLOR -> ColorFragment()
|
||||
TINY -> TinyPlayerFragment()
|
||||
PEAK -> PeakPlayerFragment()
|
||||
else -> PlayerFragment()
|
||||
} // must implement AbsPlayerFragment
|
||||
supportFragmentManager.beginTransaction().replace(R.id.playerFragmentContainer, fragment)
|
||||
.commit()
|
||||
supportFragmentManager.executePendingTransactions()
|
||||
|
||||
playerFragment = supportFragmentManager.findFragmentById(R.id.playerFragmentContainer) as AbsPlayerFragment
|
||||
miniPlayerFragment = supportFragmentManager.findFragmentById(R.id.miniPlayerFragment) as MiniPlayerFragment
|
||||
miniPlayerFragment?.view?.setOnClickListener { expandPanel() }
|
||||
}
|
||||
playerFragment = supportFragmentManager.findFragmentById(R.id.playerFragmentContainer) as AbsPlayerFragment
|
||||
miniPlayerFragment = supportFragmentManager.findFragmentById(R.id.miniPlayerFragment) as MiniPlayerFragment
|
||||
miniPlayerFragment?.view?.setOnClickListener { expandPanel() }
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
slidingPanel.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
hideBottomBar(false)
|
||||
}
|
||||
})
|
||||
} // don't call hideBottomBar(true) here as it causes a bug with the SlidingUpPanelLayout
|
||||
}
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
slidingPanel.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
hideBottomBar(false)
|
||||
}
|
||||
})
|
||||
} // don't call hideBottomBar(true) here as it causes a bug with the SlidingUpPanelLayout
|
||||
}
|
||||
|
||||
override fun onQueueChanged() {
|
||||
super.onQueueChanged()
|
||||
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
||||
}
|
||||
override fun onQueueChanged() {
|
||||
super.onQueueChanged()
|
||||
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (!handleBackPress()) super.onBackPressed()
|
||||
}
|
||||
override fun onBackPressed() {
|
||||
if (!handleBackPress()) super.onBackPressed()
|
||||
}
|
||||
|
||||
open fun handleBackPress(): Boolean {
|
||||
if (bottomSheetBehavior.peekHeight != 0 && playerFragment!!.onBackPressed()) return true
|
||||
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
collapsePanel()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
open fun handleBackPress(): Boolean {
|
||||
if (bottomSheetBehavior.peekHeight != 0 && playerFragment!!.onBackPressed()) return true
|
||||
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
collapsePanel()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onPaletteColorChanged() {
|
||||
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
val paletteColor = playerFragment!!.paletteColor
|
||||
super.setTaskDescriptionColor(paletteColor)
|
||||
override fun onPaletteColorChanged() {
|
||||
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
val paletteColor = playerFragment!!.paletteColor
|
||||
super.setTaskDescriptionColor(paletteColor)
|
||||
|
||||
val isColorLight = ColorUtil.isColorLight(paletteColor)
|
||||
val isColorLight = ColorUtil.isColorLight(paletteColor)
|
||||
|
||||
if (PreferenceUtil.getInstance(this).adaptiveColor && (currentNowPlayingScreen == NORMAL || currentNowPlayingScreen == FLAT)) {
|
||||
super.setLightNavigationBar(true)
|
||||
super.setLightStatusbar(isColorLight)
|
||||
} else if (currentNowPlayingScreen == FULL || currentNowPlayingScreen == CARD || currentNowPlayingScreen == FIT || currentNowPlayingScreen == BLUR || currentNowPlayingScreen == BLUR_CARD) {
|
||||
super.setLightStatusbar(false)
|
||||
super.setLightNavigationBar(true)
|
||||
} else if (currentNowPlayingScreen == COLOR || currentNowPlayingScreen == TINY) {
|
||||
super.setNavigationbarColor(paletteColor)
|
||||
super.setLightNavigationBar(isColorLight)
|
||||
super.setLightStatusbar(isColorLight)
|
||||
} else {
|
||||
super.setLightStatusbar(
|
||||
ColorUtil.isColorLight(
|
||||
ATHUtil.resolveColor(
|
||||
this, R.attr.colorPrimary
|
||||
)
|
||||
)
|
||||
)
|
||||
super.setLightNavigationBar(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PreferenceUtil.getInstance(this).adaptiveColor && (currentNowPlayingScreen == NORMAL || currentNowPlayingScreen == FLAT)) {
|
||||
super.setLightNavigationBar(true)
|
||||
super.setLightStatusbar(isColorLight)
|
||||
} else if (currentNowPlayingScreen == FULL || currentNowPlayingScreen == CARD || currentNowPlayingScreen == FIT || currentNowPlayingScreen == BLUR || currentNowPlayingScreen == BLUR_CARD) {
|
||||
super.setLightStatusbar(false)
|
||||
super.setLightNavigationBar(true)
|
||||
} else if (currentNowPlayingScreen == COLOR || currentNowPlayingScreen == TINY) {
|
||||
super.setNavigationbarColor(paletteColor)
|
||||
super.setLightNavigationBar(isColorLight)
|
||||
super.setLightStatusbar(isColorLight)
|
||||
} else {
|
||||
super.setLightStatusbar(ColorUtil.isColorLight(ATHUtil.resolveColor(this, android.R.attr.windowBackground)))
|
||||
super.setLightNavigationBar(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLightStatusbar(enabled: Boolean) {
|
||||
lightStatusBar = enabled
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
super.setLightStatusbar(enabled)
|
||||
}
|
||||
}
|
||||
override fun setLightStatusbar(enabled: Boolean) {
|
||||
lightStatusBar = enabled
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
super.setLightStatusbar(enabled)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLightNavigationBar(enabled: Boolean) {
|
||||
lightNavigationBar = enabled
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
super.setLightNavigationBar(enabled)
|
||||
}
|
||||
}
|
||||
override fun setLightNavigationBar(enabled: Boolean) {
|
||||
lightNavigationBar = enabled
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
super.setLightNavigationBar(enabled)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setNavigationbarColor(color: Int) {
|
||||
navigationBarColor = color
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
if (navigationBarColorAnimator != null) navigationBarColorAnimator!!.cancel()
|
||||
super.setNavigationbarColor(color)
|
||||
}
|
||||
}
|
||||
override fun setNavigationbarColor(color: Int) {
|
||||
navigationBarColor = color
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
if (navigationBarColorAnimator != null) navigationBarColorAnimator!!.cancel()
|
||||
super.setNavigationbarColor(color)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setTaskDescriptionColor(color: Int) {
|
||||
taskColor = color
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
super.setTaskDescriptionColor(color)
|
||||
}
|
||||
}
|
||||
override fun setTaskDescriptionColor(color: Int) {
|
||||
taskColor = color
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
super.setTaskDescriptionColor(color)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTabs() {
|
||||
bottomNavigationView.menu.clear()
|
||||
val currentTabs = PreferenceUtil.getInstance(this).libraryCategoryInfos
|
||||
for (tab in currentTabs) {
|
||||
if (tab.visible) {
|
||||
val menu = tab.category
|
||||
bottomNavigationView.menu.add(
|
||||
0, menu.id, 0, menu.stringRes
|
||||
).setIcon(menu.icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun updateTabs() {
|
||||
bottomNavigationView.menu.clear()
|
||||
val currentTabs: List<CategoryInfo> = PreferenceUtil.getInstance(this).libraryCategoryInfos
|
||||
for (tab in currentTabs) {
|
||||
if (tab.visible) {
|
||||
val menu = tab.category
|
||||
bottomNavigationView.menu.add(0, menu.id, 0, menu.stringRes).setIcon(menu.icon)
|
||||
}
|
||||
}
|
||||
print("Tabs -> ${currentTabs.size}")
|
||||
if (currentTabs.size <= 1) {
|
||||
toggleBottomNavigationView(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
|
||||
if (ev?.action == MotionEvent.ACTION_DOWN) {
|
||||
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
val outRect = Rect()
|
||||
slidingPanel.getGlobalVisibleRect(outRect)
|
||||
if (!outRect.contains(ev.rawX.toInt(), ev.rawY.toInt())) {
|
||||
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.dispatchTouchEvent(ev)
|
||||
}
|
||||
/*override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
|
||||
if (ev?.action == MotionEvent.ACTION_DOWN) {
|
||||
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
val outRect = Rect()
|
||||
slidingPanel.getGlobalVisibleRect(outRect)
|
||||
if (!outRect.contains(ev.rawX.toInt(), ev.rawY.toInt())) {
|
||||
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.dispatchTouchEvent(ev)
|
||||
}*/
|
||||
}
|
|
@ -2,199 +2,194 @@ package code.name.monkey.retromusic.activities.base
|
|||
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.*
|
||||
import android.view.*
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.content.ContextCompat
|
||||
import code.name.monkey.appthemehelper.*
|
||||
import code.name.monkey.appthemehelper.ATH
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import code.name.monkey.retromusic.util.ThemeManager
|
||||
|
||||
abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||
|
||||
private val handler = Handler()
|
||||
private val handler = Handler()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setTheme(ThemeManager.getThemeResValue(this))
|
||||
hideStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setTheme(ThemeManager.getThemeResValue(this))
|
||||
hideStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
setImmersiveFullscreen()
|
||||
registerSystemUiVisibility()
|
||||
toggleScreenOn()
|
||||
}
|
||||
|
||||
changeBackgroundShape()
|
||||
setImmersiveFullscreen()
|
||||
registerSystemUiVisibility()
|
||||
toggleScreenOn()
|
||||
}
|
||||
private fun toggleScreenOn() {
|
||||
if (PreferenceUtil.getInstance(this).isScreenOnEnabled) {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
} else {
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleScreenOn() {
|
||||
if (PreferenceUtil.getInstance(this).isScreenOnEnabled) {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
} else {
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
}
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
super.onWindowFocusChanged(hasFocus)
|
||||
if (hasFocus) {
|
||||
hideStatusBar()
|
||||
handler.removeCallbacks(this)
|
||||
handler.postDelayed(this, 300)
|
||||
} else {
|
||||
handler.removeCallbacks(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
super.onWindowFocusChanged(hasFocus)
|
||||
if (hasFocus) {
|
||||
hideStatusBar()
|
||||
handler.removeCallbacks(this)
|
||||
handler.postDelayed(this, 300)
|
||||
} else {
|
||||
handler.removeCallbacks(this)
|
||||
}
|
||||
}
|
||||
fun hideStatusBar() {
|
||||
hideStatusBar(PreferenceUtil.getInstance(this).fullScreenMode)
|
||||
}
|
||||
|
||||
fun hideStatusBar() {
|
||||
hideStatusBar(PreferenceUtil.getInstance(this).fullScreenMode)
|
||||
}
|
||||
private fun hideStatusBar(fullscreen: Boolean) {
|
||||
val statusBar = window.decorView.rootView.findViewById<View>(R.id.status_bar)
|
||||
if (statusBar != null) {
|
||||
statusBar.visibility = if (fullscreen) View.GONE else View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideStatusBar(fullscreen: Boolean) {
|
||||
val statusBar = window.decorView.rootView.findViewById<View>(R.id.status_bar)
|
||||
if (statusBar != null) {
|
||||
statusBar.visibility = if (fullscreen) View.GONE else View.VISIBLE
|
||||
}
|
||||
}
|
||||
private fun changeBackgroundShape() {
|
||||
var background: Drawable? = if (PreferenceUtil.getInstance(this).isRoundCorners)
|
||||
ContextCompat.getDrawable(this, R.drawable.round_window)
|
||||
else ContextCompat.getDrawable(this, R.drawable.square_window)
|
||||
background = TintHelper.createTintedDrawable(background, ATHUtil.resolveColor(this, android.R.attr.windowBackground))
|
||||
window.setBackgroundDrawable(background)
|
||||
}
|
||||
|
||||
private fun changeBackgroundShape() {
|
||||
var background: Drawable? = if (PreferenceUtil.getInstance(this).isRoundCorners) ContextCompat.getDrawable(
|
||||
this,
|
||||
R.drawable.round_window
|
||||
)
|
||||
else ContextCompat.getDrawable(this, R.drawable.square_window)
|
||||
background = TintHelper.createTintedDrawable(
|
||||
background,
|
||||
ATHUtil.resolveColor(this, R.attr.colorPrimary)
|
||||
)
|
||||
window.setBackgroundDrawable(background)
|
||||
}
|
||||
fun setDrawUnderStatusBar() {
|
||||
RetroUtil.setAllowDrawUnderStatusBar(window)
|
||||
}
|
||||
|
||||
fun setDrawUnderStatusBar() {
|
||||
RetroUtil.setAllowDrawUnderStatusBar(window)
|
||||
}
|
||||
fun setDrawUnderNavigationBar() {
|
||||
RetroUtil.setAllowDrawUnderNavigationBar(window)
|
||||
}
|
||||
|
||||
fun setDrawUnderNavigationBar() {
|
||||
RetroUtil.setAllowDrawUnderNavigationBar(window)
|
||||
}
|
||||
/**
|
||||
* This will set the color of the view with the id "status_bar" on KitKat and Lollipop. On
|
||||
* Lollipop if no such view is found it will set the statusbar color using the native method.
|
||||
*
|
||||
* @param color the new statusbar color (will be shifted down on Lollipop and above)
|
||||
*/
|
||||
fun setStatusbarColor(color: Int) {
|
||||
val statusBar = window.decorView.rootView.findViewById<View>(R.id.status_bar)
|
||||
if (statusBar != null) {
|
||||
when {
|
||||
VersionUtils.hasMarshmallow() -> window.statusBarColor = color
|
||||
VersionUtils.hasLollipop() -> statusBar.setBackgroundColor(ColorUtil.darkenColor(color))
|
||||
else -> statusBar.setBackgroundColor(color)
|
||||
}
|
||||
} else {
|
||||
when {
|
||||
VersionUtils.hasMarshmallow() -> window.statusBarColor = color
|
||||
else -> window.statusBarColor = ColorUtil.darkenColor(color)
|
||||
}
|
||||
}
|
||||
setLightStatusbarAuto(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
||||
}
|
||||
|
||||
/**
|
||||
* This will set the color of the view with the id "status_bar" on KitKat and Lollipop. On
|
||||
* Lollipop if no such view is found it will set the statusbar color using the native method.
|
||||
*
|
||||
* @param color the new statusbar color (will be shifted down on Lollipop and above)
|
||||
*/
|
||||
fun setStatusbarColor(color: Int) {
|
||||
val statusBar = window.decorView.rootView.findViewById<View>(R.id.status_bar)
|
||||
if (statusBar != null) {
|
||||
when {
|
||||
VersionUtils.hasMarshmallow() -> window.statusBarColor = color
|
||||
VersionUtils.hasLollipop() -> statusBar.setBackgroundColor(
|
||||
ColorUtil.darkenColor(
|
||||
color
|
||||
)
|
||||
)
|
||||
else -> statusBar.setBackgroundColor(color)
|
||||
}
|
||||
} else {
|
||||
when {
|
||||
VersionUtils.hasMarshmallow() -> window.statusBarColor = color
|
||||
else -> window.statusBarColor = ColorUtil.darkenColor(color)
|
||||
}
|
||||
}
|
||||
setLightStatusbarAuto(color)
|
||||
}
|
||||
fun setStatusbarColorAuto() {
|
||||
// we don't want to use statusbar color because we are doing the color darkening on our own to support KitKat
|
||||
//setStatusbarColor(ATHUtil.resolveColor(this, android.R.attr.windowBackground))
|
||||
setLightStatusbarAuto(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
||||
}
|
||||
|
||||
fun setStatusbarColorAuto() {
|
||||
// we don't want to use statusbar color because we are doing the color darkening on our own to support KitKat
|
||||
setStatusbarColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
}
|
||||
open fun setTaskDescriptionColor(@ColorInt color: Int) {
|
||||
ATH.setTaskDescriptionColor(this, color)
|
||||
}
|
||||
|
||||
open fun setTaskDescriptionColor(@ColorInt color: Int) {
|
||||
ATH.setTaskDescriptionColor(this, color)
|
||||
}
|
||||
fun setTaskDescriptionColorAuto() {
|
||||
setTaskDescriptionColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
||||
}
|
||||
|
||||
fun setTaskDescriptionColorAuto() {
|
||||
setTaskDescriptionColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
}
|
||||
open fun setNavigationbarColor(color: Int) {
|
||||
if (ThemeStore.coloredNavigationBar(this)) {
|
||||
ATH.setNavigationbarColor(this, color)
|
||||
} else {
|
||||
ATH.setNavigationbarColor(this, Color.BLACK)
|
||||
}
|
||||
}
|
||||
|
||||
open fun setNavigationbarColor(color: Int) {
|
||||
if (ThemeStore.coloredNavigationBar(this)) {
|
||||
ATH.setNavigationbarColor(this, color)
|
||||
} else {
|
||||
ATH.setNavigationbarColor(this, Color.BLACK)
|
||||
}
|
||||
}
|
||||
fun setNavigationbarColorAuto() {
|
||||
setNavigationbarColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
||||
}
|
||||
|
||||
open fun setNavigationBarColorPrimary() {
|
||||
ATH.setNavigationbarColor(this, ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
}
|
||||
open fun setLightStatusbar(enabled: Boolean) {
|
||||
ATH.setLightStatusbar(this, enabled)
|
||||
}
|
||||
|
||||
fun setNavigationbarColorAuto() {
|
||||
setNavigationbarColor(ATHUtil.resolveColor(this, R.attr.colorSecondary))
|
||||
}
|
||||
fun setLightStatusbarAuto(bgColor: Int) {
|
||||
setLightStatusbar(ColorUtil.isColorLight(bgColor))
|
||||
}
|
||||
|
||||
open fun setLightStatusbar(enabled: Boolean) {
|
||||
ATH.setLightStatusbar(this, enabled)
|
||||
}
|
||||
open fun setLightNavigationBar(enabled: Boolean) {
|
||||
if (!ATHUtil.isWindowBackgroundDark(this) and ThemeStore.coloredNavigationBar(this)) {
|
||||
ATH.setLightNavigationbar(this, enabled)
|
||||
}
|
||||
}
|
||||
|
||||
fun setLightStatusbarAuto(bgColor: Int) {
|
||||
setLightStatusbar(ColorUtil.isColorLight(bgColor))
|
||||
}
|
||||
private fun registerSystemUiVisibility() {
|
||||
val decorView = window.decorView
|
||||
decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
||||
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
|
||||
setImmersiveFullscreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open fun setLightNavigationBar(enabled: Boolean) {
|
||||
if (!ATHUtil.isWindowBackgroundDark(this) and ThemeStore.coloredNavigationBar(this)) {
|
||||
ATH.setLightNavigationbar(this, enabled)
|
||||
}
|
||||
}
|
||||
private fun unregisterSystemUiVisibility() {
|
||||
val decorView = window.decorView
|
||||
decorView.setOnSystemUiVisibilityChangeListener(null)
|
||||
}
|
||||
|
||||
private fun registerSystemUiVisibility() {
|
||||
val decorView = window.decorView
|
||||
decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
||||
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
|
||||
setImmersiveFullscreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun setImmersiveFullscreen() {
|
||||
val flags = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
|
||||
|
||||
private fun unregisterSystemUiVisibility() {
|
||||
val decorView = window.decorView
|
||||
decorView.setOnSystemUiVisibilityChangeListener(null)
|
||||
}
|
||||
if (PreferenceUtil.getInstance(this).fullScreenMode) {
|
||||
window.decorView.systemUiVisibility = flags
|
||||
}
|
||||
}
|
||||
|
||||
private fun setImmersiveFullscreen() {
|
||||
val flags = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
|
||||
private fun exitFullscreen() {
|
||||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
|
||||
}
|
||||
|
||||
if (PreferenceUtil.getInstance(this).fullScreenMode) {
|
||||
window.decorView.systemUiVisibility = flags
|
||||
}
|
||||
}
|
||||
override fun run() {
|
||||
setImmersiveFullscreen()
|
||||
}
|
||||
|
||||
private fun exitFullscreen() {
|
||||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
|
||||
}
|
||||
override fun onStop() {
|
||||
handler.removeCallbacks(this)
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun run() {
|
||||
setImmersiveFullscreen()
|
||||
}
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
unregisterSystemUiVisibility()
|
||||
exitFullscreen()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
handler.removeCallbacks(this)
|
||||
super.onStop()
|
||||
}
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
|
||||
handler.removeCallbacks(this)
|
||||
handler.postDelayed(this, 500)
|
||||
}
|
||||
return super.onKeyDown(keyCode, event)
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
unregisterSystemUiVisibility()
|
||||
exitFullscreen()
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
|
||||
handler.removeCallbacks(this)
|
||||
handler.postDelayed(this, 500)
|
||||
}
|
||||
return super.onKeyDown(keyCode, event)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +1,32 @@
|
|||
package code.name.monkey.retromusic.activities.bugreport
|
||||
|
||||
import android.app.*
|
||||
import android.content.*
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.MenuItem
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.*
|
||||
import androidx.annotation.StringDef
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsThemeActivity
|
||||
import code.name.monkey.retromusic.activities.bugreport.model.*
|
||||
import code.name.monkey.retromusic.activities.bugreport.model.github.*
|
||||
import code.name.monkey.retromusic.activities.bugreport.model.DeviceInfo
|
||||
import code.name.monkey.retromusic.activities.bugreport.model.Report
|
||||
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
|
||||
|
@ -25,7 +36,8 @@ import kotlinx.android.synthetic.main.activity_bug_report.*
|
|||
import kotlinx.android.synthetic.main.bug_report_card_device_info.*
|
||||
import kotlinx.android.synthetic.main.bug_report_card_report.*
|
||||
import org.eclipse.egit.github.core.Issue
|
||||
import org.eclipse.egit.github.core.client.*
|
||||
import org.eclipse.egit.github.core.client.GitHubClient
|
||||
import org.eclipse.egit.github.core.client.RequestException
|
||||
import org.eclipse.egit.github.core.service.IssueService
|
||||
import java.io.IOException
|
||||
|
||||
|
@ -50,9 +62,9 @@ open class BugReportActivity : AbsThemeActivity() {
|
|||
private var deviceInfo: DeviceInfo? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_bug_report)
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
|
@ -67,7 +79,7 @@ open class BugReportActivity : AbsThemeActivity() {
|
|||
|
||||
private fun initViews() {
|
||||
val accentColor = ThemeStore.accentColor(this)
|
||||
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorPrimary)
|
||||
val primaryColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||
toolbar.setBackgroundColor(primaryColor)
|
||||
setSupportActionBar(toolbar)
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar)
|
||||
|
|
|
@ -2,20 +2,28 @@ package code.name.monkey.retromusic.activities.tageditor
|
|||
|
||||
import android.app.Activity
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.*
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.*
|
||||
import android.text.Editable
|
||||
import android.text.TextUtils
|
||||
import android.text.TextWatcher
|
||||
import android.widget.Toast
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.appHandleColor
|
||||
import code.name.monkey.retromusic.glide.palette.*
|
||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||
import code.name.monkey.retromusic.glide.palette.BitmapPaletteTranscoder
|
||||
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||
import code.name.monkey.retromusic.loaders.AlbumLoader
|
||||
import code.name.monkey.retromusic.rest.LastFMRestClient
|
||||
import code.name.monkey.retromusic.rest.model.LastFmAlbum
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.util.ImageUtil
|
||||
import code.name.monkey.retromusic.util.LastFMUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil.generatePalette
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil.getColor
|
||||
import com.bumptech.glide.Glide
|
||||
|
@ -43,16 +51,7 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
|||
) {
|
||||
getColor(resource?.palette, Color.TRANSPARENT)
|
||||
albumArtBitmap = resource?.bitmap?.let { ImageUtil.resizeBitmap(it, 2048) }
|
||||
setImageBitmap(
|
||||
albumArtBitmap,
|
||||
getColor(
|
||||
resource?.palette,
|
||||
ATHUtil.resolveColor(
|
||||
this@AlbumTagEditorActivity,
|
||||
R.attr.defaultFooterColor
|
||||
)
|
||||
)
|
||||
)
|
||||
setImageBitmap(albumArtBitmap, getColor(resource?.palette, ATHUtil.resolveColor(this@AlbumTagEditorActivity, R.attr.defaultFooterColor)))
|
||||
deleteAlbumArt = false
|
||||
dataChanged()
|
||||
setResult(Activity.RESULT_OK)
|
||||
|
@ -72,8 +71,7 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
|||
private val disposable = CompositeDisposable()
|
||||
|
||||
private fun setupToolbar() {
|
||||
toolbar.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
setSupportActionBar(toolbar)
|
||||
applyToolbar(toolbar)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@ package code.name.monkey.retromusic.activities.tageditor
|
|||
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.*
|
||||
import androidx.core.content.ContextCompat
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.appHandleColor
|
||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||
import code.name.monkey.retromusic.loaders.SongLoader
|
||||
import kotlinx.android.synthetic.main.activity_song_tag_editor.*
|
||||
import org.jaudiotagger.tag.FieldKey
|
||||
|
@ -15,125 +15,105 @@ import java.util.*
|
|||
|
||||
class SongTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
||||
|
||||
override val contentViewLayout: Int
|
||||
get() = R.layout.activity_song_tag_editor
|
||||
override val contentViewLayout: Int
|
||||
get() = R.layout.activity_song_tag_editor
|
||||
|
||||
private fun setupToolbar() {
|
||||
appBarLayout.setBackgroundColor(ATHUtil.resolveColor(this, R.attr.colorPrimary))
|
||||
toolbar.apply {
|
||||
setBackgroundColor(
|
||||
ATHUtil.resolveColor(
|
||||
this@SongTagEditorActivity,
|
||||
R.attr.colorPrimary
|
||||
)
|
||||
)
|
||||
navigationIcon = TintHelper.createTintedDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
context,
|
||||
R.drawable.ic_keyboard_backspace_black_24dp
|
||||
), ThemeStore.textColorPrimary(context)
|
||||
)
|
||||
setNavigationOnClickListener { onBackPressed() }
|
||||
setSupportActionBar(toolbar)
|
||||
}
|
||||
title = null
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setNoImageMode()
|
||||
setUpViews()
|
||||
setupToolbar()
|
||||
setStatusbarColorAuto()
|
||||
}
|
||||
setNoImageMode()
|
||||
setUpViews()
|
||||
applyToolbar(toolbar)
|
||||
setStatusbarColorAuto()
|
||||
}
|
||||
|
||||
private fun setUpViews() {
|
||||
fillViewsWithFileTags()
|
||||
MaterialUtil.setTint(songTextContainer, false)
|
||||
MaterialUtil.setTint(composerContainer, false)
|
||||
MaterialUtil.setTint(albumTextContainer, false)
|
||||
MaterialUtil.setTint(artistContainer, false)
|
||||
MaterialUtil.setTint(albumArtistContainer, false)
|
||||
MaterialUtil.setTint(yearContainer, false)
|
||||
MaterialUtil.setTint(genreContainer, false)
|
||||
MaterialUtil.setTint(trackNumberContainer, false)
|
||||
MaterialUtil.setTint(lyricsContainer, false)
|
||||
private fun setUpViews() {
|
||||
fillViewsWithFileTags()
|
||||
MaterialUtil.setTint(songTextContainer, false)
|
||||
MaterialUtil.setTint(composerContainer, false)
|
||||
MaterialUtil.setTint(albumTextContainer, false)
|
||||
MaterialUtil.setTint(artistContainer, false)
|
||||
MaterialUtil.setTint(albumArtistContainer, false)
|
||||
MaterialUtil.setTint(yearContainer, false)
|
||||
MaterialUtil.setTint(genreContainer, false)
|
||||
MaterialUtil.setTint(trackNumberContainer, false)
|
||||
MaterialUtil.setTint(lyricsContainer, false)
|
||||
|
||||
songText.appHandleColor().addTextChangedListener(this)
|
||||
albumText.appHandleColor().addTextChangedListener(this)
|
||||
albumArtistText.appHandleColor().addTextChangedListener(this)
|
||||
artistText.appHandleColor().addTextChangedListener(this)
|
||||
genreText.appHandleColor().addTextChangedListener(this)
|
||||
yearText.appHandleColor().addTextChangedListener(this)
|
||||
trackNumberText.appHandleColor().addTextChangedListener(this)
|
||||
lyricsText.appHandleColor().addTextChangedListener(this)
|
||||
songComposerText.appHandleColor().addTextChangedListener(this)
|
||||
}
|
||||
songText.appHandleColor().addTextChangedListener(this)
|
||||
albumText.appHandleColor().addTextChangedListener(this)
|
||||
albumArtistText.appHandleColor().addTextChangedListener(this)
|
||||
artistText.appHandleColor().addTextChangedListener(this)
|
||||
genreText.appHandleColor().addTextChangedListener(this)
|
||||
yearText.appHandleColor().addTextChangedListener(this)
|
||||
trackNumberText.appHandleColor().addTextChangedListener(this)
|
||||
lyricsText.appHandleColor().addTextChangedListener(this)
|
||||
songComposerText.appHandleColor().addTextChangedListener(this)
|
||||
}
|
||||
|
||||
private fun fillViewsWithFileTags() {
|
||||
songText.setText(songTitle)
|
||||
albumArtistText.setText(albumArtist)
|
||||
albumText.setText(albumTitle)
|
||||
artistText.setText(artistName)
|
||||
genreText.setText(genreName)
|
||||
yearText.setText(songYear)
|
||||
trackNumberText.setText(trackNumber)
|
||||
lyricsText.setText(lyrics)
|
||||
songComposerText.setText(composer)
|
||||
}
|
||||
private fun fillViewsWithFileTags() {
|
||||
songText.setText(songTitle)
|
||||
albumArtistText.setText(albumArtist)
|
||||
albumText.setText(albumTitle)
|
||||
artistText.setText(artistName)
|
||||
genreText.setText(genreName)
|
||||
yearText.setText(songYear)
|
||||
trackNumberText.setText(trackNumber)
|
||||
lyricsText.setText(lyrics)
|
||||
songComposerText.setText(composer)
|
||||
}
|
||||
|
||||
override fun loadCurrentImage() {
|
||||
override fun loadCurrentImage() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun searchImageOnWeb() {
|
||||
override fun searchImageOnWeb() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteImage() {
|
||||
override fun deleteImage() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun save() {
|
||||
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
|
||||
fieldKeyValueMap[FieldKey.TITLE] = songText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.ALBUM] = albumText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.ARTIST] = artistText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.GENRE] = genreText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.YEAR] = yearText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.TRACK] = trackNumberText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.LYRICS] = lyricsText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.ALBUM_ARTIST] = albumArtistText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.COMPOSER] = songComposerText.text.toString()
|
||||
writeValuesToFiles(fieldKeyValueMap, null)
|
||||
}
|
||||
override fun save() {
|
||||
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
|
||||
fieldKeyValueMap[FieldKey.TITLE] = songText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.ALBUM] = albumText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.ARTIST] = artistText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.GENRE] = genreText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.YEAR] = yearText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.TRACK] = trackNumberText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.LYRICS] = lyricsText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.ALBUM_ARTIST] = albumArtistText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.COMPOSER] = songComposerText.text.toString()
|
||||
writeValuesToFiles(fieldKeyValueMap, null)
|
||||
}
|
||||
|
||||
override fun getSongPaths(): List<String> {
|
||||
val paths = ArrayList<String>(1)
|
||||
paths.add(SongLoader.getSong(this, id).data)
|
||||
return paths
|
||||
}
|
||||
override fun getSongPaths(): List<String> {
|
||||
val paths = ArrayList<String>(1)
|
||||
paths.add(SongLoader.getSong(this, id).data)
|
||||
return paths
|
||||
}
|
||||
|
||||
override fun loadImageFromFile(selectedFile: Uri?) {
|
||||
override fun loadImageFromFile(selectedFile: Uri?) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable) {
|
||||
dataChanged()
|
||||
}
|
||||
override fun afterTextChanged(s: Editable) {
|
||||
dataChanged()
|
||||
}
|
||||
|
||||
companion object {
|
||||
val TAG: String = SongTagEditorActivity::class.java.simpleName
|
||||
}
|
||||
companion object {
|
||||
val TAG: String = SongTagEditorActivity::class.java.simpleName
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package code.name.monkey.retromusic.adapter
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
|
@ -14,49 +16,39 @@ import java.util.*
|
|||
*/
|
||||
|
||||
class GenreAdapter(
|
||||
private val activity: Activity, dataSet: ArrayList<Genre>, private val mItemLayoutRes: Int
|
||||
private val activity: Activity, dataSet: ArrayList<Genre>, private val mItemLayoutRes: Int
|
||||
) : RecyclerView.Adapter<GenreAdapter.ViewHolder>() {
|
||||
var dataSet = ArrayList<Genre>()
|
||||
private set
|
||||
var dataSet = ArrayList<Genre>()
|
||||
private set
|
||||
|
||||
init {
|
||||
this.dataSet = dataSet
|
||||
}
|
||||
init {
|
||||
this.dataSet = dataSet
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return ViewHolder(LayoutInflater.from(activity).inflate(mItemLayoutRes, parent, false))
|
||||
}
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return ViewHolder(LayoutInflater.from(activity).inflate(mItemLayoutRes, parent, false))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val genre = dataSet[position]
|
||||
if (holder.title != null) {
|
||||
holder.title!!.text = genre.name
|
||||
}
|
||||
if (holder.text != null) {
|
||||
holder.text!!.text = String.format(
|
||||
Locale.getDefault(),
|
||||
"%d %s",
|
||||
genre.songCount,
|
||||
if (genre.songCount > 1) activity.getString(R.string.songs)
|
||||
else activity.getString(R.string.song)
|
||||
)
|
||||
}
|
||||
}
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val genre = dataSet[position]
|
||||
holder.title?.text = genre.name
|
||||
holder.text?.text = String.format(Locale.getDefault(), "%d %s", genre.songCount, if (genre.songCount > 1) activity.getString(R.string.songs) else activity.getString(R.string.song))
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
|
||||
fun swapDataSet(list: ArrayList<Genre>) {
|
||||
dataSet = list
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
fun swapDataSet(list: ArrayList<Genre>) {
|
||||
dataSet = list
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
override fun onClick(v: View?) {
|
||||
super.onClick(v)
|
||||
val genre = dataSet[adapterPosition]
|
||||
NavigationUtil.goToGenre(activity, genre)
|
||||
}
|
||||
}
|
||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
override fun onClick(v: View?) {
|
||||
super.onClick(v)
|
||||
val genre = dataSet[adapterPosition]
|
||||
NavigationUtil.goToGenre(activity, genre)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,210 +1,180 @@
|
|||
package code.name.monkey.retromusic.adapter
|
||||
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.IntDef
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.recyclerview.widget.*
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.album.AlbumFullWidthAdapter
|
||||
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
|
||||
import code.name.monkey.retromusic.adapter.song.SongAdapter
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.model.Home
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
|
||||
class HomeAdapter(
|
||||
private val activity: AppCompatActivity, private val displayMetrics: DisplayMetrics
|
||||
private val activity: AppCompatActivity, private val displayMetrics: DisplayMetrics
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
private var list = ArrayList<Home>()
|
||||
private var list = ArrayList<Home>()
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return list[position].homeSection
|
||||
}
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return list[position].homeSection
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val layout = LayoutInflater.from(activity)
|
||||
.inflate(R.layout.section_recycler_view, parent, false)
|
||||
return when (viewType) {
|
||||
RECENT_ARTISTS, TOP_ARTISTS -> ArtistViewHolder(layout)
|
||||
PLAYLISTS -> PlaylistViewHolder(layout)
|
||||
else -> {
|
||||
AlbumViewHolder(
|
||||
LayoutInflater.from(activity).inflate(
|
||||
R.layout.metal_section_recycler_view, parent, false
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val layout = LayoutInflater.from(activity)
|
||||
.inflate(R.layout.section_recycler_view, parent, false)
|
||||
return when (viewType) {
|
||||
RECENT_ARTISTS, TOP_ARTISTS -> ArtistViewHolder(layout)
|
||||
PLAYLISTS -> PlaylistViewHolder(layout)
|
||||
else -> {
|
||||
AlbumViewHolder(LayoutInflater.from(activity).inflate(R.layout.metal_section_recycler_view, parent, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
println("ViewType ${getItemViewType(position)}")
|
||||
when (getItemViewType(position)) {
|
||||
RECENT_ALBUMS -> {
|
||||
val viewHolder = holder as AlbumViewHolder
|
||||
viewHolder.bindView(
|
||||
list[position].arrayList.toAlbums(),
|
||||
R.string.recent_albums,
|
||||
R.string.recent_added_albums
|
||||
)
|
||||
}
|
||||
TOP_ALBUMS -> {
|
||||
val viewHolder = holder as AlbumViewHolder
|
||||
viewHolder.bindView(
|
||||
list[position].arrayList.toAlbums(),
|
||||
R.string.top_albums,
|
||||
R.string.most_played_albums
|
||||
)
|
||||
}
|
||||
RECENT_ARTISTS -> {
|
||||
val viewHolder = holder as ArtistViewHolder
|
||||
viewHolder.bindView(
|
||||
list[position].arrayList.toArtists(),
|
||||
R.string.recent_artists,
|
||||
R.string.recent_added_artists
|
||||
)
|
||||
}
|
||||
TOP_ARTISTS -> {
|
||||
val viewHolder = holder as ArtistViewHolder
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
println("ViewType ${getItemViewType(position)}")
|
||||
when (getItemViewType(position)) {
|
||||
RECENT_ALBUMS -> {
|
||||
val viewHolder = holder as AlbumViewHolder
|
||||
viewHolder.bindView(list[position].arrayList.toAlbums(), R.string.recent_albums)
|
||||
}
|
||||
TOP_ALBUMS -> {
|
||||
val viewHolder = holder as AlbumViewHolder
|
||||
viewHolder.bindView(list[position].arrayList.toAlbums(), R.string.top_albums)
|
||||
}
|
||||
RECENT_ARTISTS -> {
|
||||
val viewHolder = holder as ArtistViewHolder
|
||||
viewHolder.bindView(list[position].arrayList.toArtists(), R.string.recent_artists)
|
||||
}
|
||||
TOP_ARTISTS -> {
|
||||
val viewHolder = holder as ArtistViewHolder
|
||||
viewHolder.bindView(list[position].arrayList.toArtists(), R.string.top_artists)
|
||||
}
|
||||
PLAYLISTS -> {
|
||||
val viewHolder = holder as PlaylistViewHolder
|
||||
viewHolder.bindView(list[position].arrayList.toPlaylist(), R.string.favorites)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewHolder.bindView(
|
||||
list[position].arrayList.toArtists(),
|
||||
R.string.top_artists,
|
||||
R.string.most_played_artists
|
||||
)
|
||||
}
|
||||
PLAYLISTS -> {
|
||||
val viewHolder = holder as PlaylistViewHolder
|
||||
viewHolder.bindView(
|
||||
list[position].arrayList.toPlaylist(),
|
||||
R.string.favorites,
|
||||
R.string.favorites_songs
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun getItemCount(): Int {
|
||||
return list.size
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return list.size
|
||||
}
|
||||
fun swapData(sections: ArrayList<Home>) {
|
||||
list = sections
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun swapData(sections: ArrayList<Home>) {
|
||||
list = sections
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
companion object {
|
||||
|
||||
companion object {
|
||||
@IntDef(RECENT_ALBUMS, TOP_ALBUMS, RECENT_ARTISTS, TOP_ARTISTS, PLAYLISTS)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class HomeSection
|
||||
|
||||
@IntDef(RECENT_ALBUMS, TOP_ALBUMS, RECENT_ARTISTS, TOP_ARTISTS, PLAYLISTS)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class HomeSection
|
||||
const val RECENT_ALBUMS = 3
|
||||
const val TOP_ALBUMS = 1
|
||||
const val RECENT_ARTISTS = 2
|
||||
const val TOP_ARTISTS = 0
|
||||
const val PLAYLISTS = 4
|
||||
|
||||
const val RECENT_ALBUMS = 3
|
||||
const val TOP_ALBUMS = 1
|
||||
const val RECENT_ARTISTS = 2
|
||||
const val TOP_ARTISTS = 0
|
||||
const val PLAYLISTS = 4
|
||||
}
|
||||
|
||||
}
|
||||
private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||
fun bindView(list: ArrayList<Album>, titleRes: Int) {
|
||||
if (list.isNotEmpty()) {
|
||||
recyclerView.apply {
|
||||
show()
|
||||
adapter = AlbumFullWidthAdapter(activity, list, displayMetrics)
|
||||
}
|
||||
title.text = activity.getString(titleRes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||
fun bindView(list: ArrayList<Album>, titleRes: Int, subtitleRes: Int) {
|
||||
if (list.isNotEmpty()) {
|
||||
recyclerView.apply {
|
||||
show()
|
||||
adapter = AlbumFullWidthAdapter(activity, list, displayMetrics)
|
||||
}
|
||||
titleContainer.show()
|
||||
title.text = activity.getString(titleRes)
|
||||
text.text = activity.getString(subtitleRes)
|
||||
}
|
||||
}
|
||||
inner class ArtistViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||
fun bindView(list: ArrayList<Artist>, titleRes: Int) {
|
||||
if (list.isNotEmpty()) {
|
||||
recyclerView.apply {
|
||||
show()
|
||||
layoutManager = GridLayoutManager(
|
||||
activity, 1, GridLayoutManager.HORIZONTAL, false
|
||||
)
|
||||
val artistAdapter = ArtistAdapter(
|
||||
activity,
|
||||
list,
|
||||
PreferenceUtil.getInstance(activity).getHomeGridStyle(activity),
|
||||
false,
|
||||
null
|
||||
)
|
||||
adapter = artistAdapter
|
||||
}
|
||||
title.text = activity.getString(titleRes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inner class PlaylistViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||
fun bindView(arrayList: ArrayList<Playlist>, titleRes: Int) {
|
||||
if (arrayList.isNotEmpty()) {
|
||||
val songs = PlaylistSongsLoader.getPlaylistSongList(activity, arrayList[0])
|
||||
if (songs.isNotEmpty()) {
|
||||
recyclerView.apply {
|
||||
show()
|
||||
val songAdapter = SongAdapter(
|
||||
activity, songs, R.layout.item_album_card, false, null
|
||||
)
|
||||
layoutManager = GridLayoutManager(
|
||||
activity, 1, GridLayoutManager.HORIZONTAL, false
|
||||
)
|
||||
adapter = songAdapter
|
||||
|
||||
}
|
||||
}
|
||||
title.text = activity.getString(titleRes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inner class ArtistViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||
fun bindView(list: ArrayList<Artist>, titleRes: Int, subtitleRes: Int) {
|
||||
if (list.isNotEmpty()) {
|
||||
recyclerView.apply {
|
||||
show()
|
||||
layoutManager = GridLayoutManager(
|
||||
activity, 1, GridLayoutManager.HORIZONTAL, false
|
||||
)
|
||||
val artistAdapter = ArtistAdapter(
|
||||
activity,
|
||||
list,
|
||||
PreferenceUtil.getInstance(activity).getHomeGridStyle(activity),
|
||||
false,
|
||||
null
|
||||
)
|
||||
adapter = artistAdapter
|
||||
}
|
||||
titleContainer.show()
|
||||
title.text = activity.getString(titleRes)
|
||||
text.text = activity.getString(subtitleRes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inner class PlaylistViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||
fun bindView(arrayList: ArrayList<Playlist>, titleRes: Int, subtitleRes: Int) {
|
||||
if (arrayList.isNotEmpty()) {
|
||||
val songs = PlaylistSongsLoader.getPlaylistSongList(activity, arrayList[0])
|
||||
if (songs.isNotEmpty()) {
|
||||
recyclerView.apply {
|
||||
show()
|
||||
val songAdapter = SongAdapter(
|
||||
activity, songs, R.layout.item_album_card, false, null
|
||||
)
|
||||
layoutManager = GridLayoutManager(
|
||||
activity, 1, GridLayoutManager.HORIZONTAL, false
|
||||
)
|
||||
adapter = songAdapter
|
||||
|
||||
}
|
||||
titleContainer.show()
|
||||
title.text = activity.getString(titleRes)
|
||||
text.text = activity.getString(subtitleRes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView)
|
||||
val titleContainer: View = itemView.findViewById(R.id.titleContainer)
|
||||
val title: AppCompatTextView = itemView.findViewById(R.id.title)
|
||||
val text: MaterialTextView = itemView.findViewById(R.id.text)
|
||||
}
|
||||
open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView)
|
||||
val title: AppCompatTextView = itemView.findViewById(R.id.title)
|
||||
}
|
||||
}
|
||||
|
||||
private fun <E> ArrayList<E>.toAlbums(): ArrayList<Album> {
|
||||
val arrayList = ArrayList<Album>()
|
||||
for (x in this) {
|
||||
arrayList.add(x as Album)
|
||||
}
|
||||
return arrayList;
|
||||
val arrayList = ArrayList<Album>()
|
||||
for (x in this) {
|
||||
arrayList.add(x as Album)
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private fun <E> ArrayList<E>.toArtists(): ArrayList<Artist> {
|
||||
val arrayList = ArrayList<Artist>()
|
||||
for (x in this) {
|
||||
arrayList.add(x as Artist)
|
||||
}
|
||||
return arrayList;
|
||||
val arrayList = ArrayList<Artist>()
|
||||
for (x in this) {
|
||||
arrayList.add(x as Artist)
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private fun <E> ArrayList<E>.toPlaylist(): ArrayList<Playlist> {
|
||||
val arrayList = ArrayList<Playlist>()
|
||||
for (x in this) {
|
||||
arrayList.add(x as Playlist)
|
||||
}
|
||||
return arrayList;
|
||||
val arrayList = ArrayList<Playlist>()
|
||||
for (x in this) {
|
||||
arrayList.add(x as Playlist)
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,140 +1,140 @@
|
|||
package code.name.monkey.retromusic.adapter
|
||||
|
||||
import android.app.ActivityOptions
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.glide.*
|
||||
import code.name.monkey.retromusic.glide.ArtistGlideRequest
|
||||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.menu.SongMenuHelper
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import android.util.Pair as UtilPair
|
||||
|
||||
class SearchAdapter(
|
||||
private val activity: AppCompatActivity, private var dataSet: List<Any>?
|
||||
private val activity: AppCompatActivity, private var dataSet: List<Any>?
|
||||
) : RecyclerView.Adapter<SearchAdapter.ViewHolder>() {
|
||||
|
||||
fun swapDataSet(dataSet: MutableList<Any>) {
|
||||
this.dataSet = dataSet
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
fun swapDataSet(dataSet: MutableList<Any>) {
|
||||
this.dataSet = dataSet
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
if (dataSet!![position] is Album) return ALBUM
|
||||
if (dataSet!![position] is Artist) return ARTIST
|
||||
return if (dataSet!![position] is Song) SONG else HEADER
|
||||
}
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
if (dataSet!![position] is Album) return ALBUM
|
||||
if (dataSet!![position] is Artist) return ARTIST
|
||||
if (dataSet!![position] is Genre) return GENRE
|
||||
return if (dataSet!![position] is Song) SONG else HEADER
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return if (viewType == HEADER) ViewHolder(
|
||||
LayoutInflater.from(activity).inflate(
|
||||
R.layout.sub_header,
|
||||
parent,
|
||||
false
|
||||
), viewType
|
||||
) else ViewHolder(
|
||||
LayoutInflater.from(activity).inflate(R.layout.item_list, parent, false),
|
||||
viewType
|
||||
)
|
||||
}
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return if (viewType == HEADER) ViewHolder(LayoutInflater.from(activity).inflate(R.layout.sub_header, parent, false), viewType)
|
||||
else
|
||||
ViewHolder(LayoutInflater.from(activity).inflate(R.layout.item_list, parent, false), viewType)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
when (getItemViewType(position)) {
|
||||
ALBUM -> {
|
||||
val album = dataSet?.get(position) as Album
|
||||
holder.title?.text = album.title
|
||||
holder.text?.text = album.artistName
|
||||
SongGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
||||
.checkIgnoreMediaStore(activity).build().into(holder.image)
|
||||
}
|
||||
ARTIST -> {
|
||||
val artist = dataSet?.get(position) as Artist
|
||||
holder.title?.text = artist.name
|
||||
holder.text?.text = MusicUtil.getArtistInfoString(activity, artist)
|
||||
ArtistGlideRequest.Builder.from(Glide.with(activity), artist).build()
|
||||
.into(holder.image)
|
||||
}
|
||||
SONG -> {
|
||||
val song = dataSet?.get(position) as Song
|
||||
holder.title?.text = song.title
|
||||
holder.text?.text = song.albumName
|
||||
}
|
||||
else -> {
|
||||
holder.title?.text = dataSet?.get(position).toString()
|
||||
holder.title?.setTextColor(ThemeStore.accentColor(activity))
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
when (getItemViewType(position)) {
|
||||
ALBUM -> {
|
||||
val album = dataSet?.get(position) as Album
|
||||
holder.title?.text = album.title
|
||||
holder.text?.text = album.artistName
|
||||
SongGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
||||
.checkIgnoreMediaStore(activity).build().into(holder.image)
|
||||
}
|
||||
ARTIST -> {
|
||||
val artist = dataSet?.get(position) as Artist
|
||||
holder.title?.text = artist.name
|
||||
holder.text?.text = MusicUtil.getArtistInfoString(activity, artist)
|
||||
ArtistGlideRequest.Builder.from(Glide.with(activity), artist).build()
|
||||
.into(holder.image)
|
||||
}
|
||||
SONG -> {
|
||||
val song = dataSet?.get(position) as Song
|
||||
holder.title?.text = song.title
|
||||
holder.text?.text = song.albumName
|
||||
}
|
||||
GENRE -> {
|
||||
val genre = dataSet?.get(position) as Genre
|
||||
holder.title?.text = genre.name
|
||||
holder.text?.text = String.format(Locale.getDefault(), "%d %s", genre.songCount, if (genre.songCount > 1) activity.getString(R.string.songs) else activity.getString(R.string.song))
|
||||
}
|
||||
else -> {
|
||||
holder.title?.text = dataSet?.get(position).toString()
|
||||
holder.title?.setTextColor(ThemeStore.accentColor(activity))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet!!.size
|
||||
}
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet!!.size
|
||||
}
|
||||
|
||||
inner class ViewHolder(itemView: View, itemViewType: Int) : MediaEntryViewHolder(itemView) {
|
||||
init {
|
||||
itemView.setOnLongClickListener(null)
|
||||
inner class ViewHolder(itemView: View, itemViewType: Int) : MediaEntryViewHolder(itemView) {
|
||||
init {
|
||||
itemView.setOnLongClickListener(null)
|
||||
|
||||
if (itemViewType == SONG) {
|
||||
menu?.visibility = View.VISIBLE
|
||||
menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) {
|
||||
override val song: Song
|
||||
get() = dataSet!![adapterPosition] as Song
|
||||
})
|
||||
} else {
|
||||
menu?.visibility = View.GONE
|
||||
}
|
||||
if (itemViewType == SONG) {
|
||||
menu?.visibility = View.VISIBLE
|
||||
menu?.setOnClickListener(object : SongMenuHelper.OnClickSongMenu(activity) {
|
||||
override val song: Song
|
||||
get() = dataSet!![adapterPosition] as Song
|
||||
})
|
||||
} else {
|
||||
menu?.visibility = View.GONE
|
||||
}
|
||||
|
||||
when (itemViewType) {
|
||||
ALBUM -> setImageTransitionName(activity.getString(R.string.transition_album_art))
|
||||
ARTIST -> setImageTransitionName(activity.getString(R.string.transition_artist_image))
|
||||
else -> {
|
||||
val container = itemView.findViewById<View>(R.id.imageContainer)
|
||||
container?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
when (itemViewType) {
|
||||
ALBUM -> setImageTransitionName(activity.getString(R.string.transition_album_art))
|
||||
ARTIST -> setImageTransitionName(activity.getString(R.string.transition_artist_image))
|
||||
else -> {
|
||||
val container = itemView.findViewById<View>(R.id.imageContainer)
|
||||
container?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
val item = dataSet!![adapterPosition]
|
||||
when (itemViewType) {
|
||||
ALBUM -> {
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
UtilPair.create(
|
||||
image,
|
||||
activity.getString(R.string.transition_album_art)
|
||||
)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, (item as Album).id, options)
|
||||
}
|
||||
ARTIST -> {
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
UtilPair.create(
|
||||
image,
|
||||
activity.getString(R.string.transition_artist_image)
|
||||
)
|
||||
)
|
||||
NavigationUtil.goToArtistOptions(activity, (item as Artist).id, options)
|
||||
}
|
||||
SONG -> {
|
||||
val playList = ArrayList<Song>()
|
||||
playList.add(item as Song)
|
||||
MusicPlayerRemote.openQueue(playList, 0, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun onClick(v: View?) {
|
||||
val item = dataSet!![adapterPosition]
|
||||
when (itemViewType) {
|
||||
ALBUM -> {
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(activity, UtilPair.create(image, activity.getString(R.string.transition_album_art)))
|
||||
NavigationUtil.goToAlbumOptions(activity, (item as Album).id, options)
|
||||
}
|
||||
ARTIST -> {
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(activity, UtilPair.create(image, activity.getString(R.string.transition_artist_image)))
|
||||
NavigationUtil.goToArtistOptions(activity, (item as Artist).id, options)
|
||||
}
|
||||
GENRE -> {
|
||||
NavigationUtil.goToGenre(activity, item as Genre)
|
||||
}
|
||||
SONG -> {
|
||||
val playList = ArrayList<Song>()
|
||||
playList.add(item as Song)
|
||||
MusicPlayerRemote.openQueue(playList, 0, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val HEADER = 0
|
||||
private const val ALBUM = 1
|
||||
private const val ARTIST = 2
|
||||
private const val SONG = 3
|
||||
}
|
||||
companion object {
|
||||
private const val HEADER = 0
|
||||
private const val ALBUM = 1
|
||||
private const val ARTIST = 2
|
||||
private const val SONG = 3
|
||||
private const val GENRE = 4
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package code.name.monkey.retromusic.adapter
|
||||
|
||||
import android.graphics.PorterDuff
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.base.*
|
||||
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
|
||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.glide.audiocover.AudioFileCover
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
|
@ -16,164 +20,161 @@ import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
|||
import java.io.File
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
import kotlin.math.*
|
||||
import kotlin.math.log10
|
||||
import kotlin.math.pow
|
||||
|
||||
class SongFileAdapter(
|
||||
private val activity: AppCompatActivity,
|
||||
private var dataSet: List<File>?,
|
||||
private val itemLayoutRes: Int,
|
||||
private val callbacks: Callbacks?,
|
||||
cabHolder: CabHolder?
|
||||
private val activity: AppCompatActivity,
|
||||
private var dataSet: List<File>?,
|
||||
private val itemLayoutRes: Int,
|
||||
private val callbacks: Callbacks?,
|
||||
cabHolder: CabHolder?
|
||||
) : AbsMultiSelectAdapter<SongFileAdapter.ViewHolder, File>(
|
||||
activity, cabHolder, R.menu.menu_media_selection
|
||||
activity, cabHolder, R.menu.menu_media_selection
|
||||
), FastScrollRecyclerView.SectionedAdapter {
|
||||
|
||||
init {
|
||||
this.setHasStableIds(true)
|
||||
}
|
||||
init {
|
||||
this.setHasStableIds(true)
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (dataSet!![position].isDirectory) FOLDER else FILE
|
||||
}
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (dataSet!![position].isDirectory) FOLDER else FILE
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return dataSet!![position].hashCode().toLong()
|
||||
}
|
||||
override fun getItemId(position: Int): Long {
|
||||
return dataSet!![position].hashCode().toLong()
|
||||
}
|
||||
|
||||
fun swapDataSet(songFiles: List<File>) {
|
||||
this.dataSet = songFiles
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
fun swapDataSet(songFiles: List<File>) {
|
||||
this.dataSet = songFiles
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return ViewHolder(LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false))
|
||||
}
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return ViewHolder(LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, index: Int) {
|
||||
val file = dataSet!![index]
|
||||
holder.itemView.isActivated = isChecked(file)
|
||||
holder.title?.text = getFileTitle(file)
|
||||
if (holder.text != null) {
|
||||
if (holder.itemViewType == FILE) {
|
||||
holder.text?.text = getFileText(file)
|
||||
} else {
|
||||
holder.text?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
override fun onBindViewHolder(holder: ViewHolder, index: Int) {
|
||||
val file = dataSet!![index]
|
||||
holder.itemView.isActivated = isChecked(file)
|
||||
holder.title?.text = getFileTitle(file)
|
||||
if (holder.text != null) {
|
||||
if (holder.itemViewType == FILE) {
|
||||
holder.text?.text = getFileText(file)
|
||||
} else {
|
||||
holder.text?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
if (holder.image != null) {
|
||||
loadFileImage(file, holder)
|
||||
}
|
||||
}
|
||||
if (holder.image != null) {
|
||||
loadFileImage(file, holder)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFileTitle(file: File): String {
|
||||
return file.name
|
||||
}
|
||||
private fun getFileTitle(file: File): String {
|
||||
return file.name
|
||||
}
|
||||
|
||||
private fun getFileText(file: File): String? {
|
||||
return if (file.isDirectory) null else readableFileSize(file.length())
|
||||
}
|
||||
private fun getFileText(file: File): String? {
|
||||
return if (file.isDirectory) null else readableFileSize(file.length())
|
||||
}
|
||||
|
||||
private fun loadFileImage(file: File, holder: ViewHolder) {
|
||||
val iconColor = ATHUtil.resolveColor(activity, R.attr.iconColor)
|
||||
if (file.isDirectory) {
|
||||
holder.image?.let {
|
||||
it.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN)
|
||||
it.setImageResource(R.drawable.ic_folder_white_24dp)
|
||||
}
|
||||
holder.imageTextContainer?.setCardBackgroundColor(
|
||||
ATHUtil.resolveColor(
|
||||
activity, R.attr.colorPrimary
|
||||
)
|
||||
)
|
||||
private fun loadFileImage(file: File, holder: ViewHolder) {
|
||||
val iconColor = ATHUtil.resolveColor(activity, R.attr.colorControlNormal)
|
||||
if (file.isDirectory) {
|
||||
holder.image?.let {
|
||||
it.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN)
|
||||
it.setImageResource(R.drawable.ic_folder_white_24dp)
|
||||
}
|
||||
holder.imageTextContainer?.setCardBackgroundColor(ATHUtil.resolveColor(activity, R.attr.colorSurface))
|
||||
|
||||
} else {
|
||||
val error = RetroUtil.getTintedVectorDrawable(
|
||||
activity, R.drawable.ic_file_music_white_24dp, iconColor
|
||||
)
|
||||
Glide.with(activity).load(AudioFileCover(file.path))
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE).error(error).placeholder(error)
|
||||
.animate(android.R.anim.fade_in)
|
||||
.signature(MediaStoreSignature("", file.lastModified(), 0)).into(holder.image)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val error = RetroUtil.getTintedVectorDrawable(
|
||||
activity, R.drawable.ic_file_music_white_24dp, iconColor
|
||||
)
|
||||
Glide.with(activity).load(AudioFileCover(file.path))
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE).error(error).placeholder(error)
|
||||
.animate(android.R.anim.fade_in)
|
||||
.signature(MediaStoreSignature("", file.lastModified(), 0)).into(holder.image)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet!!.size
|
||||
}
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet!!.size
|
||||
}
|
||||
|
||||
override fun getIdentifier(position: Int): File? {
|
||||
return dataSet!![position]
|
||||
}
|
||||
override fun getIdentifier(position: Int): File? {
|
||||
return dataSet!![position]
|
||||
}
|
||||
|
||||
override fun getName(`object`: File): String {
|
||||
return getFileTitle(`object`)
|
||||
}
|
||||
override fun getName(`object`: File): String {
|
||||
return getFileTitle(`object`)
|
||||
}
|
||||
|
||||
override fun onMultipleItemAction(menuItem: MenuItem, selection: ArrayList<File>) {
|
||||
if (callbacks == null) return
|
||||
callbacks.onMultipleItemAction(menuItem, selection)
|
||||
}
|
||||
override fun onMultipleItemAction(menuItem: MenuItem, selection: ArrayList<File>) {
|
||||
if (callbacks == null) return
|
||||
callbacks.onMultipleItemAction(menuItem, selection)
|
||||
}
|
||||
|
||||
override fun getSectionName(position: Int): String {
|
||||
return dataSet!![position].name[0].toString().toUpperCase()
|
||||
}
|
||||
override fun getSectionName(position: Int): String {
|
||||
return dataSet!![position].name[0].toString().toUpperCase()
|
||||
}
|
||||
|
||||
interface Callbacks {
|
||||
fun onFileSelected(file: File)
|
||||
interface Callbacks {
|
||||
fun onFileSelected(file: File)
|
||||
|
||||
fun onFileMenuClicked(file: File, view: View)
|
||||
fun onFileMenuClicked(file: File, view: View)
|
||||
|
||||
fun onMultipleItemAction(item: MenuItem, files: ArrayList<File>)
|
||||
}
|
||||
fun onMultipleItemAction(item: MenuItem, files: ArrayList<File>)
|
||||
}
|
||||
|
||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
|
||||
init {
|
||||
if (menu != null && callbacks != null) {
|
||||
menu!!.setOnClickListener { v ->
|
||||
val position = adapterPosition
|
||||
if (isPositionInRange(position)) {
|
||||
callbacks.onFileMenuClicked(dataSet!![position], v)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (imageTextContainer != null) {
|
||||
imageTextContainer?.cardElevation = 0f
|
||||
}
|
||||
}
|
||||
init {
|
||||
if (menu != null && callbacks != null) {
|
||||
menu?.setOnClickListener { v ->
|
||||
val position = adapterPosition
|
||||
if (isPositionInRange(position)) {
|
||||
callbacks.onFileMenuClicked(dataSet!![position], v)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (imageTextContainer != null) {
|
||||
imageTextContainer?.cardElevation = 0f
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
val position = adapterPosition
|
||||
if (isPositionInRange(position)) {
|
||||
if (isInQuickSelectMode) {
|
||||
toggleChecked(position)
|
||||
} else {
|
||||
callbacks?.onFileSelected(dataSet!![position])
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun onClick(v: View?) {
|
||||
val position = adapterPosition
|
||||
if (isPositionInRange(position)) {
|
||||
if (isInQuickSelectMode) {
|
||||
toggleChecked(position)
|
||||
} else {
|
||||
callbacks?.onFileSelected(dataSet!![position])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLongClick(v: View?): Boolean {
|
||||
val position = adapterPosition
|
||||
return isPositionInRange(position) && toggleChecked(position)
|
||||
}
|
||||
override fun onLongClick(v: View?): Boolean {
|
||||
val position = adapterPosition
|
||||
return isPositionInRange(position) && toggleChecked(position)
|
||||
}
|
||||
|
||||
private fun isPositionInRange(position: Int): Boolean {
|
||||
return position >= 0 && position < dataSet!!.size
|
||||
}
|
||||
}
|
||||
private fun isPositionInRange(position: Int): Boolean {
|
||||
return position >= 0 && position < dataSet!!.size
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
companion object {
|
||||
|
||||
private const val FILE = 0
|
||||
private const val FOLDER = 1
|
||||
private const val FILE = 0
|
||||
private const val FOLDER = 1
|
||||
|
||||
fun readableFileSize(size: Long): String {
|
||||
if (size <= 0) return "$size B"
|
||||
val units = arrayOf("B", "KB", "MB", "GB", "TB")
|
||||
val digitGroups = (log10(size.toDouble()) / log10(1024.0)).toInt()
|
||||
return DecimalFormat("#,##0.##").format(size / 1024.0.pow(digitGroups.toDouble())) + " " + units[digitGroups]
|
||||
}
|
||||
}
|
||||
fun readableFileSize(size: Long): String {
|
||||
if (size <= 0) return "$size B"
|
||||
val units = arrayOf("B", "KB", "MB", "GB", "TB")
|
||||
val digitGroups = (log10(size.toDouble()) / log10(1024.0)).toInt()
|
||||
return DecimalFormat("#,##0.##").format(size / 1024.0.pow(digitGroups.toDouble())) + " " + units[digitGroups]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -93,7 +93,7 @@ public class MediaEntryViewHolder extends RecyclerView.ViewHolder implements Vie
|
|||
playSongs = itemView.findViewById(R.id.playSongs);
|
||||
|
||||
if (imageContainerCard != null) {
|
||||
imageContainerCard.setCardBackgroundColor(ATHUtil.INSTANCE.resolveColor(itemView.getContext(), R.attr.colorPrimary));
|
||||
imageContainerCard.setCardBackgroundColor(ATHUtil.INSTANCE.resolveColor(itemView.getContext(), R.attr.colorSurface));
|
||||
}
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
|
|
|
@ -1,222 +1,216 @@
|
|||
package code.name.monkey.retromusic.adapter.playlist
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.base.*
|
||||
import code.name.monkey.retromusic.dialogs.*
|
||||
import code.name.monkey.retromusic.helper.menu.*
|
||||
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
|
||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.dialogs.ClearSmartPlaylistDialog
|
||||
import code.name.monkey.retromusic.dialogs.DeletePlaylistDialog
|
||||
import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
|
||||
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.model.smartplaylist.*
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.model.AbsCustomPlaylist
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import java.util.*
|
||||
|
||||
class PlaylistAdapter(
|
||||
private val activity: AppCompatActivity,
|
||||
var dataSet: ArrayList<Playlist>,
|
||||
private var itemLayoutRes: Int,
|
||||
cabHolder: CabHolder?
|
||||
private val activity: AppCompatActivity,
|
||||
var dataSet: ArrayList<Playlist>,
|
||||
private var itemLayoutRes: Int,
|
||||
cabHolder: CabHolder?
|
||||
) : AbsMultiSelectAdapter<PlaylistAdapter.ViewHolder, Playlist>(
|
||||
activity,
|
||||
cabHolder,
|
||||
R.menu.menu_playlists_selection
|
||||
activity,
|
||||
cabHolder,
|
||||
R.menu.menu_playlists_selection
|
||||
) {
|
||||
|
||||
var songs = ArrayList<Song>()
|
||||
var songs = ArrayList<Song>()
|
||||
|
||||
init {
|
||||
setHasStableIds(true)
|
||||
}
|
||||
init {
|
||||
setHasStableIds(true)
|
||||
}
|
||||
|
||||
fun swapDataSet(dataSet: ArrayList<Playlist>) {
|
||||
this.dataSet = dataSet
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
fun swapDataSet(dataSet: ArrayList<Playlist>) {
|
||||
this.dataSet = dataSet
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return dataSet[position].id.toLong()
|
||||
}
|
||||
override fun getItemId(position: Int): Long {
|
||||
return dataSet[position].id.toLong()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false)
|
||||
return createViewHolder(view)
|
||||
}
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false)
|
||||
return createViewHolder(view)
|
||||
}
|
||||
|
||||
protected fun createViewHolder(view: View): ViewHolder {
|
||||
return ViewHolder(view)
|
||||
}
|
||||
protected fun createViewHolder(view: View): ViewHolder {
|
||||
return ViewHolder(view)
|
||||
}
|
||||
|
||||
protected fun getPlaylistTitle(playlist: Playlist): String {
|
||||
return playlist.name
|
||||
}
|
||||
protected fun getPlaylistTitle(playlist: Playlist): String {
|
||||
return playlist.name
|
||||
}
|
||||
|
||||
protected fun getPlaylistText(playlist: Playlist): String {
|
||||
return MusicUtil.getPlaylistInfoString(activity, getSongs(playlist))
|
||||
}
|
||||
protected fun getPlaylistText(playlist: Playlist): String {
|
||||
return MusicUtil.getPlaylistInfoString(activity, getSongs(playlist))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val playlist = dataSet[position]
|
||||
holder.itemView.isActivated = isChecked(playlist)
|
||||
holder.title?.text = getPlaylistTitle(playlist)
|
||||
holder.text?.text = getPlaylistText(playlist)
|
||||
holder.image?.setImageDrawable(getIconRes(playlist))
|
||||
}
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val playlist = dataSet[position]
|
||||
holder.itemView.isActivated = isChecked(playlist)
|
||||
holder.title?.text = getPlaylistTitle(playlist)
|
||||
holder.text?.text = getPlaylistText(playlist)
|
||||
holder.image?.setImageDrawable(getIconRes(playlist))
|
||||
}
|
||||
|
||||
private fun getIconRes(playlist: Playlist): Drawable {
|
||||
if (playlist is AbsSmartPlaylist) {
|
||||
return TintHelper.createTintedDrawable(
|
||||
activity,
|
||||
playlist.iconRes,
|
||||
ATHUtil.resolveColor(activity, R.attr.iconColor)
|
||||
)!!
|
||||
}
|
||||
return if (MusicUtil.isFavoritePlaylist(
|
||||
activity,
|
||||
playlist
|
||||
)) TintHelper.createTintedDrawable(
|
||||
activity,
|
||||
R.drawable.ic_favorite_white_24dp,
|
||||
ThemeStore.accentColor(activity)
|
||||
)!!
|
||||
else TintHelper.createTintedDrawable(
|
||||
activity,
|
||||
R.drawable.ic_playlist_play_white_24dp,
|
||||
ATHUtil.resolveColor(activity, R.attr.iconColor)
|
||||
)!!
|
||||
}
|
||||
private fun getIconRes(playlist: Playlist): Drawable {
|
||||
return if (MusicUtil.isFavoritePlaylist(activity, playlist))
|
||||
TintHelper.createTintedDrawable(activity, R.drawable.ic_favorite_white_24dp, ThemeStore.accentColor(activity))!!
|
||||
else TintHelper.createTintedDrawable(activity, R.drawable.ic_playlist_play_white_24dp, ATHUtil.resolveColor(activity, R.attr.colorControlNormal))!!
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (dataSet[position] is AbsSmartPlaylist) SMART_PLAYLIST else DEFAULT_PLAYLIST
|
||||
}
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (dataSet[position] is AbsSmartPlaylist) SMART_PLAYLIST else DEFAULT_PLAYLIST
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
|
||||
override fun getIdentifier(position: Int): Playlist? {
|
||||
return dataSet[position]
|
||||
}
|
||||
override fun getIdentifier(position: Int): Playlist? {
|
||||
return dataSet[position]
|
||||
}
|
||||
|
||||
override fun getName(playlist: Playlist): String {
|
||||
return playlist.name
|
||||
}
|
||||
override fun getName(playlist: Playlist): String {
|
||||
return playlist.name
|
||||
}
|
||||
|
||||
override fun onMultipleItemAction(menuItem: MenuItem, selection: ArrayList<Playlist>) {
|
||||
when (menuItem.itemId) {
|
||||
R.id.action_delete_playlist -> {
|
||||
var i = 0
|
||||
while (i < selection.size) {
|
||||
val playlist = selection[i]
|
||||
if (playlist is AbsSmartPlaylist) {
|
||||
ClearSmartPlaylistDialog.create(playlist).show(
|
||||
activity.supportFragmentManager, "CLEAR_PLAYLIST_" + playlist.name
|
||||
)
|
||||
selection.remove(playlist)
|
||||
i--
|
||||
}
|
||||
i++
|
||||
}
|
||||
if (selection.size > 0) {
|
||||
DeletePlaylistDialog.create(selection)
|
||||
.show(activity.supportFragmentManager, "DELETE_PLAYLIST")
|
||||
}
|
||||
}
|
||||
else -> SongsMenuHelper.handleMenuClick(
|
||||
activity,
|
||||
getSongList(selection),
|
||||
menuItem.itemId
|
||||
)
|
||||
}
|
||||
}
|
||||
override fun onMultipleItemAction(menuItem: MenuItem, selection: ArrayList<Playlist>) {
|
||||
when (menuItem.itemId) {
|
||||
R.id.action_delete_playlist -> {
|
||||
var i = 0
|
||||
while (i < selection.size) {
|
||||
val playlist = selection[i]
|
||||
if (playlist is AbsSmartPlaylist) {
|
||||
ClearSmartPlaylistDialog.create(playlist).show(
|
||||
activity.supportFragmentManager, "CLEAR_PLAYLIST_" + playlist.name
|
||||
)
|
||||
selection.remove(playlist)
|
||||
i--
|
||||
}
|
||||
i++
|
||||
}
|
||||
if (selection.size > 0) {
|
||||
DeletePlaylistDialog.create(selection)
|
||||
.show(activity.supportFragmentManager, "DELETE_PLAYLIST")
|
||||
}
|
||||
}
|
||||
else -> SongsMenuHelper.handleMenuClick(
|
||||
activity,
|
||||
getSongList(selection),
|
||||
menuItem.itemId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSongList(playlists: List<Playlist>): ArrayList<Song> {
|
||||
val songs = ArrayList<Song>()
|
||||
for (playlist in playlists) {
|
||||
if (playlist is AbsCustomPlaylist) {
|
||||
songs.addAll(playlist.getSongs(activity))
|
||||
} else {
|
||||
songs.addAll(PlaylistSongsLoader.getPlaylistSongList(activity, playlist.id))
|
||||
}
|
||||
}
|
||||
return songs
|
||||
}
|
||||
private fun getSongList(playlists: List<Playlist>): ArrayList<Song> {
|
||||
val songs = ArrayList<Song>()
|
||||
for (playlist in playlists) {
|
||||
if (playlist is AbsCustomPlaylist) {
|
||||
songs.addAll(playlist.getSongs(activity))
|
||||
} else {
|
||||
songs.addAll(PlaylistSongsLoader.getPlaylistSongList(activity, playlist.id))
|
||||
}
|
||||
}
|
||||
return songs
|
||||
}
|
||||
|
||||
private fun getSongs(playlist: Playlist): ArrayList<Song> {
|
||||
val songs = ArrayList<Song>()
|
||||
if (playlist is AbsSmartPlaylist) {
|
||||
songs.addAll(playlist.getSongs(activity))
|
||||
} else {
|
||||
songs.addAll(PlaylistSongsLoader.getPlaylistSongList(activity, playlist.id))
|
||||
}
|
||||
return songs
|
||||
}
|
||||
private fun getSongs(playlist: Playlist): ArrayList<Song> {
|
||||
val songs = ArrayList<Song>()
|
||||
if (playlist is AbsSmartPlaylist) {
|
||||
songs.addAll(playlist.getSongs(activity))
|
||||
} else {
|
||||
songs.addAll(PlaylistSongsLoader.getPlaylistSongList(activity, playlist.id))
|
||||
}
|
||||
return songs
|
||||
}
|
||||
|
||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
init {
|
||||
inner class ViewHolder(itemView: View) : MediaEntryViewHolder(itemView) {
|
||||
init {
|
||||
|
||||
image?.apply {
|
||||
val iconPadding = activity.resources.getDimensionPixelSize(R.dimen.list_item_image_icon_padding)
|
||||
setPadding(iconPadding, iconPadding, iconPadding, iconPadding)
|
||||
//setColorFilter(ATHUtil.resolveColor(activity, R.attr.iconColor), PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
image?.apply {
|
||||
val iconPadding = activity.resources.getDimensionPixelSize(R.dimen.list_item_image_icon_padding)
|
||||
setPadding(iconPadding, iconPadding, iconPadding, iconPadding)
|
||||
//setColorFilter(ATHUtil.resolveColor(activity, R.attr.iconColor), PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
||||
menu?.setOnClickListener { view ->
|
||||
val playlist = dataSet[adapterPosition]
|
||||
val popupMenu = PopupMenu(activity, view)
|
||||
popupMenu.inflate(
|
||||
if (itemViewType == SMART_PLAYLIST) R.menu.menu_item_smart_playlist
|
||||
else R.menu.menu_item_playlist
|
||||
)
|
||||
if (playlist is LastAddedPlaylist) {
|
||||
popupMenu.menu.findItem(R.id.action_clear_playlist).isVisible = false
|
||||
}
|
||||
popupMenu.setOnMenuItemClickListener { item ->
|
||||
if (item.itemId == R.id.action_clear_playlist) {
|
||||
if (playlist is AbsSmartPlaylist) {
|
||||
ClearSmartPlaylistDialog.create(playlist).show(
|
||||
activity.supportFragmentManager,
|
||||
"CLEAR_SMART_PLAYLIST_" + playlist.name
|
||||
)
|
||||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
}
|
||||
PlaylistMenuHelper.handleMenuClick(
|
||||
activity, dataSet[adapterPosition], item
|
||||
)
|
||||
}
|
||||
popupMenu.show()
|
||||
}
|
||||
menu?.setOnClickListener { view ->
|
||||
val playlist = dataSet[adapterPosition]
|
||||
val popupMenu = PopupMenu(activity, view)
|
||||
popupMenu.inflate(
|
||||
if (itemViewType == SMART_PLAYLIST) R.menu.menu_item_smart_playlist
|
||||
else R.menu.menu_item_playlist
|
||||
)
|
||||
if (playlist is LastAddedPlaylist) {
|
||||
popupMenu.menu.findItem(R.id.action_clear_playlist).isVisible = false
|
||||
}
|
||||
popupMenu.setOnMenuItemClickListener { item ->
|
||||
if (item.itemId == R.id.action_clear_playlist) {
|
||||
if (playlist is AbsSmartPlaylist) {
|
||||
ClearSmartPlaylistDialog.create(playlist).show(
|
||||
activity.supportFragmentManager,
|
||||
"CLEAR_SMART_PLAYLIST_" + playlist.name
|
||||
)
|
||||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
}
|
||||
PlaylistMenuHelper.handleMenuClick(
|
||||
activity, dataSet[adapterPosition], item
|
||||
)
|
||||
}
|
||||
popupMenu.show()
|
||||
}
|
||||
|
||||
imageTextContainer?.apply {
|
||||
cardElevation = 0f
|
||||
setCardBackgroundColor(ATHUtil.resolveColor(activity, R.attr.colorPrimary))
|
||||
}
|
||||
}
|
||||
imageTextContainer?.apply {
|
||||
cardElevation = 0f
|
||||
setCardBackgroundColor(ATHUtil.resolveColor(activity, R.attr.colorSurface))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
if (isInQuickSelectMode) {
|
||||
toggleChecked(adapterPosition)
|
||||
} else {
|
||||
val playlist = dataSet[adapterPosition]
|
||||
NavigationUtil.goToPlaylistNew(activity, playlist)
|
||||
}
|
||||
}
|
||||
override fun onClick(v: View?) {
|
||||
if (isInQuickSelectMode) {
|
||||
toggleChecked(adapterPosition)
|
||||
} else {
|
||||
val playlist = dataSet[adapterPosition]
|
||||
NavigationUtil.goToPlaylistNew(activity, playlist)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLongClick(v: View?): Boolean {
|
||||
toggleChecked(adapterPosition)
|
||||
return true
|
||||
}
|
||||
}
|
||||
override fun onLongClick(v: View?): Boolean {
|
||||
toggleChecked(adapterPosition)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val TAG: String = PlaylistAdapter::class.java.simpleName
|
||||
private const val SMART_PLAYLIST = 0
|
||||
private const val DEFAULT_PLAYLIST = 1
|
||||
}
|
||||
companion object {
|
||||
val TAG: String = PlaylistAdapter::class.java.simpleName
|
||||
private const val SMART_PLAYLIST = 0
|
||||
private const val DEFAULT_PLAYLIST = 1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,96 +1,79 @@
|
|||
package code.name.monkey.retromusic.adapter.song
|
||||
|
||||
import android.app.ActivityOptions
|
||||
import android.content.res.ColorStateList
|
||||
import android.view.*
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import java.util.*
|
||||
|
||||
open class PlaylistSongAdapter(
|
||||
activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?
|
||||
activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?
|
||||
) : AbsOffsetSongAdapter(activity, dataSet, itemLayoutRes, usePalette, cabHolder, false) {
|
||||
|
||||
init {
|
||||
this.setMultiSelectMenuRes(R.menu.menu_cannot_delete_single_songs_playlist_songs_selection)
|
||||
}
|
||||
init {
|
||||
this.setMultiSelectMenuRes(R.menu.menu_cannot_delete_single_songs_playlist_songs_selection)
|
||||
}
|
||||
|
||||
override fun createViewHolder(view: View): SongAdapter.ViewHolder {
|
||||
return ViewHolder(view)
|
||||
}
|
||||
override fun createViewHolder(view: View): SongAdapter.ViewHolder {
|
||||
return ViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
|
||||
override fun onBindViewHolder(holder: SongAdapter.ViewHolder, position: Int) {
|
||||
if (holder.itemViewType == OFFSET_ITEM) {
|
||||
val viewHolder = holder as ViewHolder
|
||||
viewHolder.playAction?.let {
|
||||
it.setOnClickListener {
|
||||
MusicPlayerRemote.openQueue(dataSet, 0, true)
|
||||
}
|
||||
}
|
||||
viewHolder.shuffleAction?.let {
|
||||
it.setOnClickListener {
|
||||
MusicPlayerRemote.openAndShuffleQueue(dataSet, true)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.onBindViewHolder(holder, position - 1)
|
||||
}
|
||||
}
|
||||
|
||||
if (holder.itemViewType == OFFSET_ITEM) {
|
||||
open inner class ViewHolder(itemView: View) : AbsOffsetSongAdapter.ViewHolder(itemView) {
|
||||
|
||||
val buttonColor = RetroColorUtil.toolbarColor(activity)
|
||||
val textColor = MaterialValueHelper.getPrimaryTextColor(
|
||||
activity, ColorUtil.isColorLight(
|
||||
buttonColor
|
||||
)
|
||||
)
|
||||
val viewHolder = holder as ViewHolder
|
||||
val playAction: MaterialButton? = itemView.findViewById(R.id.playAction)
|
||||
val shuffleAction: MaterialButton? = itemView.findViewById(R.id.shuffleAction)
|
||||
|
||||
viewHolder.playAction?.let {
|
||||
it.backgroundTintList = ColorStateList.valueOf(buttonColor)
|
||||
it.setTextColor(textColor)
|
||||
it.iconTint = ColorStateList.valueOf(textColor)
|
||||
it.setOnClickListener {
|
||||
MusicPlayerRemote.openQueue(dataSet, 0, true)
|
||||
}
|
||||
}
|
||||
viewHolder.shuffleAction?.let {
|
||||
it.backgroundTintList = ColorStateList.valueOf(buttonColor)
|
||||
it.setTextColor(textColor)
|
||||
it.iconTint = ColorStateList.valueOf(textColor)
|
||||
it.setOnClickListener {
|
||||
MusicPlayerRemote.openAndShuffleQueue(dataSet, true)
|
||||
}
|
||||
}
|
||||
override var songMenuRes: Int
|
||||
get() = R.menu.menu_item_cannot_delete_single_songs_playlist_song
|
||||
set(value) {
|
||||
super.songMenuRes = value
|
||||
}
|
||||
|
||||
} else {
|
||||
super.onBindViewHolder(holder, position - 1)
|
||||
}
|
||||
}
|
||||
override fun onSongMenuItemClick(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.action_go_to_album) {
|
||||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity, image, activity.getString(
|
||||
R.string.transition_album_art
|
||||
)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(
|
||||
activity, dataSet[adapterPosition - 1].albumId, activityOptions
|
||||
)
|
||||
return true
|
||||
}
|
||||
return super.onSongMenuItemClick(item)
|
||||
}
|
||||
}
|
||||
|
||||
open inner class ViewHolder(itemView: View) : AbsOffsetSongAdapter.ViewHolder(itemView) {
|
||||
|
||||
val playAction: MaterialButton? = itemView.findViewById(R.id.playAction)
|
||||
val shuffleAction: MaterialButton? = itemView.findViewById(R.id.shuffleAction)
|
||||
|
||||
override var songMenuRes: Int
|
||||
get() = R.menu.menu_item_cannot_delete_single_songs_playlist_song
|
||||
set(value) {
|
||||
super.songMenuRes = value
|
||||
}
|
||||
|
||||
override fun onSongMenuItemClick(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.action_go_to_album) {
|
||||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity, image, activity.getString(
|
||||
R.string.transition_album_art
|
||||
)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(
|
||||
activity, dataSet[adapterPosition - 1].albumId, activityOptions
|
||||
)
|
||||
return true
|
||||
}
|
||||
return super.onSongMenuItemClick(item)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val TAG: String = PlaylistSongAdapter::class.java.simpleName
|
||||
}
|
||||
companion object {
|
||||
val TAG: String = PlaylistSongAdapter::class.java.simpleName
|
||||
}
|
||||
}
|
|
@ -2,17 +2,25 @@ package code.name.monkey.retromusic.adapter.song
|
|||
|
||||
import android.app.ActivityOptions
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.base.*
|
||||
import code.name.monkey.retromusic.glide.*
|
||||
import code.name.monkey.retromusic.helper.*
|
||||
import code.name.monkey.retromusic.helper.menu.*
|
||||
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
|
||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.SortOrder
|
||||
import code.name.monkey.retromusic.helper.menu.SongMenuHelper
|
||||
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.bumptech.glide.Glide
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
|
@ -79,20 +87,8 @@ open class SongAdapter(
|
|||
private fun setColors(color: Int, holder: ViewHolder) {
|
||||
if (holder.paletteColorContainer != null) {
|
||||
holder.paletteColorContainer?.setBackgroundColor(color)
|
||||
holder.title?.setTextColor(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
activity, ColorUtil.isColorLight(
|
||||
color
|
||||
)
|
||||
)
|
||||
)
|
||||
holder.text?.setTextColor(
|
||||
MaterialValueHelper.getSecondaryTextColor(
|
||||
activity, ColorUtil.isColorLight(
|
||||
color
|
||||
)
|
||||
)
|
||||
)
|
||||
//holder.title?.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
//holder.text?.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
dialog?.window?.let {
|
||||
(requireActivity() as MainActivity).setNavigationBarColorPrimary()
|
||||
(requireActivity() as MainActivity).setNavigationbarColorAuto()
|
||||
(requireActivity() as MainActivity).setLightNavigationBar(true)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package code.name.monkey.retromusic.extensions
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
|
@ -25,8 +26,7 @@ fun AppCompatActivity.applyToolbar(toolbar: Toolbar) {
|
|||
setNavigationOnClickListener { onBackPressed() }
|
||||
setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp)
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar)
|
||||
setBackgroundColor(ATHUtil.resolveColor(this@applyToolbar, R.attr.colorPrimary))
|
||||
|
||||
backgroundTintList = ColorStateList.valueOf(ATHUtil.resolveColor(this@applyToolbar, R.attr.colorSurface))
|
||||
}
|
||||
setSupportActionBar(toolbar)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,16 @@
|
|||
|
||||
package code.name.monkey.retromusic.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
|
||||
fun Int.ripAlpha(): Int {
|
||||
return ColorUtil.stripAlpha(this)
|
||||
}
|
||||
|
||||
fun Any.surfaceColor(context: Context): Int {
|
||||
return ATHUtil.resolveColor(context, R.attr.colorSurface, Color.WHITE)
|
||||
}
|
|
@ -49,18 +49,16 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
|||
setUpMiniPlayer()
|
||||
|
||||
if (RetroUtil.isTablet()) {
|
||||
actionNext.visibility = View.VISIBLE
|
||||
actionPrevious.visibility = View.VISIBLE
|
||||
actionNext?.visibility = View.VISIBLE
|
||||
actionPrevious?.visibility = View.VISIBLE
|
||||
actionPlayingQueue.visibility = View.VISIBLE
|
||||
} else {
|
||||
actionNext.visibility = if (PreferenceUtil.getInstance(requireContext()).isExtraControls) View.VISIBLE else View.GONE
|
||||
actionPlayingQueue.visibility = if (PreferenceUtil.getInstance(requireContext()).isExtraControls) View.GONE else View.VISIBLE
|
||||
actionPrevious.visibility = if (PreferenceUtil.getInstance(requireContext()).isExtraControls) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
actionPlayingQueue.setOnClickListener(this)
|
||||
actionNext.setOnClickListener(this)
|
||||
actionPrevious.setOnClickListener(this)
|
||||
actionNext?.setOnClickListener(this)
|
||||
actionPrevious?.setOnClickListener(this)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
package code.name.monkey.retromusic.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.*
|
||||
import android.graphics.Color
|
||||
import android.graphics.PorterDuff
|
||||
import android.media.AudioManager
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.SeekBar
|
||||
import androidx.fragment.app.Fragment
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.volume.*
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import code.name.monkey.retromusic.volume.AudioVolumeObserver
|
||||
import code.name.monkey.retromusic.volume.OnAudioVolumeChangedListener
|
||||
import kotlinx.android.synthetic.main.fragment_volume.*
|
||||
|
||||
class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolumeChangedListener, View.OnClickListener {
|
||||
|
@ -33,10 +37,6 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
|
|||
setTintable(ThemeStore.accentColor(requireContext()))
|
||||
volumeDown.setOnClickListener(this)
|
||||
volumeUp.setOnClickListener(this)
|
||||
|
||||
val iconColor = ATHUtil.resolveColor(requireContext(), R.attr.iconColor)
|
||||
volumeDown.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN)
|
||||
volumeUp.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
@ -1,129 +1,127 @@
|
|||
package code.name.monkey.retromusic.fragments.base
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import androidx.annotation.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.*
|
||||
import code.name.monkey.retromusic.util.DensityUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.*
|
||||
|
||||
abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : RecyclerView.LayoutManager> : AbsLibraryPagerFragment(), AppBarLayout.OnOffsetChangedListener {
|
||||
|
||||
protected var adapter: A? = null
|
||||
protected var layoutManager: LM? = null
|
||||
protected var adapter: A? = null
|
||||
protected var layoutManager: LM? = null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val view = inflater.inflate(
|
||||
R.layout.fragment_main_activity_recycler_view, container, false
|
||||
);
|
||||
return view
|
||||
}
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_main_activity_recycler_view, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
libraryFragment.addOnAppBarOffsetChangedListener(this)
|
||||
initLayoutManager()
|
||||
initAdapter()
|
||||
setUpRecyclerView()
|
||||
}
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
libraryFragment.addOnAppBarOffsetChangedListener(this)
|
||||
initLayoutManager()
|
||||
initAdapter()
|
||||
setUpRecyclerView()
|
||||
}
|
||||
|
||||
private fun setUpRecyclerView() {
|
||||
if (recyclerView is FastScrollRecyclerView) {
|
||||
ViewUtil.setUpFastScrollRecyclerViewColor(
|
||||
requireActivity(), recyclerView as FastScrollRecyclerView
|
||||
)
|
||||
}
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
private fun setUpRecyclerView() {
|
||||
if (recyclerView is FastScrollRecyclerView) {
|
||||
ViewUtil.setUpFastScrollRecyclerViewColor(requireActivity(), recyclerView as FastScrollRecyclerView)
|
||||
}
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
private fun initAdapter() {
|
||||
adapter = createAdapter()
|
||||
adapter?.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onChanged() {
|
||||
super.onChanged()
|
||||
checkIsEmpty()
|
||||
checkForPadding()
|
||||
}
|
||||
})
|
||||
}
|
||||
private fun initAdapter() {
|
||||
adapter = createAdapter()
|
||||
adapter?.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onChanged() {
|
||||
super.onChanged()
|
||||
checkIsEmpty()
|
||||
checkForPadding()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
protected open val emptyMessage: Int
|
||||
@StringRes get() = R.string.empty
|
||||
protected open val emptyMessage: Int
|
||||
@StringRes get() = R.string.empty
|
||||
|
||||
private fun getEmojiByUnicode(unicode: Int): String {
|
||||
return String(Character.toChars(unicode))
|
||||
}
|
||||
private fun getEmojiByUnicode(unicode: Int): String {
|
||||
return String(Character.toChars(unicode))
|
||||
}
|
||||
|
||||
private fun checkIsEmpty() {
|
||||
emptyEmoji.text = getEmojiByUnicode(0x1F631)
|
||||
emptyText.setText(emptyMessage)
|
||||
empty.visibility = if (adapter!!.itemCount == 0) View.VISIBLE else View.GONE
|
||||
}
|
||||
private fun checkIsEmpty() {
|
||||
emptyEmoji.text = getEmojiByUnicode(0x1F631)
|
||||
emptyText.setText(emptyMessage)
|
||||
empty.visibility = if (adapter!!.itemCount == 0) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
private fun checkForPadding() {
|
||||
val itemCount: Int = adapter?.itemCount ?: 0
|
||||
val params = container.layoutParams as ViewGroup.MarginLayoutParams
|
||||
if (itemCount > 0 && MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
val height = DensityUtil.dip2px(requireContext(), 104f)
|
||||
params.bottomMargin = height
|
||||
} else {
|
||||
val height = DensityUtil.dip2px(requireContext(), 52f)
|
||||
params.bottomMargin = height
|
||||
}
|
||||
}
|
||||
private fun checkForPadding() {
|
||||
val itemCount: Int = adapter?.itemCount ?: 0
|
||||
val params = container.layoutParams as ViewGroup.MarginLayoutParams
|
||||
if (itemCount > 0 && MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
val height = DensityUtil.dip2px(requireContext(), 104f)
|
||||
params.bottomMargin = height
|
||||
} else {
|
||||
val height = DensityUtil.dip2px(requireContext(), 52f)
|
||||
params.bottomMargin = height
|
||||
}
|
||||
}
|
||||
|
||||
private fun initLayoutManager() {
|
||||
layoutManager = createLayoutManager()
|
||||
}
|
||||
private fun initLayoutManager() {
|
||||
layoutManager = createLayoutManager()
|
||||
}
|
||||
|
||||
protected abstract fun createLayoutManager(): LM
|
||||
protected abstract fun createLayoutManager(): LM
|
||||
|
||||
@NonNull
|
||||
protected abstract fun createAdapter(): A
|
||||
@NonNull
|
||||
protected abstract fun createAdapter(): A
|
||||
|
||||
override fun onOffsetChanged(p0: AppBarLayout?, i: Int) {
|
||||
container.setPadding(
|
||||
container.paddingLeft,
|
||||
container.paddingTop,
|
||||
container.paddingRight,
|
||||
libraryFragment.totalAppBarScrollingRange + i
|
||||
)
|
||||
}
|
||||
override fun onOffsetChanged(p0: AppBarLayout?, i: Int) {
|
||||
container.setPadding(
|
||||
container.paddingLeft,
|
||||
container.paddingTop,
|
||||
container.paddingRight,
|
||||
libraryFragment.totalAppBarScrollingRange + i)
|
||||
}
|
||||
|
||||
override fun onQueueChanged() {
|
||||
super.onQueueChanged()
|
||||
checkForPadding()
|
||||
}
|
||||
override fun onQueueChanged() {
|
||||
super.onQueueChanged()
|
||||
checkForPadding()
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
checkForPadding()
|
||||
}
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
checkForPadding()
|
||||
}
|
||||
|
||||
protected fun invalidateLayoutManager() {
|
||||
initLayoutManager()
|
||||
recyclerView.layoutManager = layoutManager
|
||||
}
|
||||
protected fun invalidateLayoutManager() {
|
||||
initLayoutManager()
|
||||
recyclerView.layoutManager = layoutManager
|
||||
}
|
||||
|
||||
protected fun invalidateAdapter() {
|
||||
initAdapter()
|
||||
checkIsEmpty()
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
protected fun invalidateAdapter() {
|
||||
initAdapter()
|
||||
checkIsEmpty()
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
libraryFragment.removeOnAppBarOffsetChangedListener(this)
|
||||
}
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
libraryFragment.removeOnAppBarOffsetChangedListener(this)
|
||||
}
|
||||
|
||||
fun recyclerView(): RecyclerView {
|
||||
return recyclerView
|
||||
}
|
||||
fun recyclerView(): RecyclerView {
|
||||
return recyclerView
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package code.name.monkey.retromusic.fragments.base
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
|
@ -26,10 +25,10 @@ abstract class AbsMainActivityFragment : AbsMusicServiceFragment() {
|
|||
mainActivity.setBottomBarVisibility(View.VISIBLE)
|
||||
}
|
||||
|
||||
private fun setStatusbarColor(view: View, color: Int) {
|
||||
private fun setStatusBarColor(view: View, color: Int) {
|
||||
val statusBar = view.findViewById<View>(R.id.status_bar)
|
||||
if (statusBar != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (VersionUtils.hasMarshmallow()) {
|
||||
statusBar.setBackgroundColor(color)
|
||||
mainActivity.setLightStatusbarAuto(color)
|
||||
} else {
|
||||
|
@ -38,13 +37,13 @@ abstract class AbsMainActivityFragment : AbsMusicServiceFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
fun setStatusbarColorAuto(view: View) {
|
||||
val colorPrimary = ATHUtil.resolveColor(requireContext(), R.attr.colorPrimary)
|
||||
fun setStatusBarColorAuto(view: View) {
|
||||
val colorPrimary = ATHUtil.resolveColor(requireContext(), R.attr.colorSurface)
|
||||
// we don't want to use statusbar color because we are doing the color darkening on our own to support KitKat
|
||||
if (VersionUtils.hasMarshmallow()) {
|
||||
setStatusbarColor(view, colorPrimary)
|
||||
setStatusBarColor(view, colorPrimary)
|
||||
} else {
|
||||
setStatusbarColor(view, ColorUtil.darkenColor(colorPrimary))
|
||||
setStatusBarColor(view, ColorUtil.darkenColor(colorPrimary))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package code.name.monkey.retromusic.fragments.mainactivity;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityOptions;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
@ -108,7 +109,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setStatusbarColorAuto(view);
|
||||
setStatusBarColorAuto(view);
|
||||
setupToolbar();
|
||||
inflateFragment();
|
||||
}
|
||||
|
@ -140,7 +141,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void setupToolbar() {
|
||||
toolbar.setBackgroundColor(RetroColorUtil.toolbarColor(getMainActivity()));
|
||||
toolbar.setBackgroundTintList(ColorStateList.valueOf(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface)));
|
||||
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
|
||||
toolbar.setOnClickListener(v -> {
|
||||
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getMainActivity(), toolbarContainer, getString(R.string.transition_toolbar));
|
||||
|
@ -149,7 +150,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
getMainActivity().setSupportActionBar(toolbar);
|
||||
toolbar.setNavigationOnClickListener(v -> showMainMenu(OptionsSheetDialogFragment.LIBRARY));
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar);
|
||||
toolbar.setTitleTextColor(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorOnSecondary));
|
||||
//toolbar.setTitleTextColor(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorOnSecondary));
|
||||
}
|
||||
|
||||
private Fragment getCurrentFragment() {
|
||||
|
@ -187,7 +188,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorPrimary)))
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface)))
|
||||
.start(callback);
|
||||
return cab;
|
||||
}
|
||||
|
|
|
@ -131,4 +131,4 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
|||
return fragment
|
||||
}
|
||||
}
|
||||
}// Required empty public constructor
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
setStatusbarColorAuto(view);
|
||||
setStatusBarColorAuto(view);
|
||||
setUpAppbarColor();
|
||||
setUpBreadCrumbs();
|
||||
setUpRecyclerView();
|
||||
|
@ -229,9 +229,8 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
}
|
||||
|
||||
private void setUpAppbarColor() {
|
||||
int primaryColor = ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorPrimary);
|
||||
int primaryColor = ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface);
|
||||
getMainActivity().setSupportActionBar(toolbar);
|
||||
appBarLayout.setBackgroundColor(primaryColor);
|
||||
toolbar.setBackgroundColor(RetroColorUtil.toolbarColor(getMainActivity()));
|
||||
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
|
||||
toolbar.setNavigationOnClickListener(v -> {
|
||||
|
@ -307,7 +306,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
cab = new MaterialCab(getMainActivity(), R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorPrimary)))
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface)))
|
||||
.start(callback);
|
||||
return cab;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package code.name.monkey.retromusic.fragments.mainactivity.home
|
||||
|
||||
import android.app.ActivityOptions
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.*
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
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.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.App
|
||||
|
@ -72,15 +74,13 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
setStatusBarColorAuto(view)
|
||||
toolbar = view.findViewById(R.id.toolbar)
|
||||
|
||||
bannerImage?.setOnClickListener {
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(mainActivity, userImage, getString(R.string.transition_user_image))
|
||||
NavigationUtil.goToUserInfo(requireActivity(), options)
|
||||
}
|
||||
if (!PreferenceUtil.getInstance(requireContext()).isHomeBanner)
|
||||
setStatusbarColorAuto(view)
|
||||
|
||||
lastAdded.setOnClickListener {
|
||||
NavigationUtil.goToPlaylistNew(requireActivity(), LastAddedPlaylist(requireActivity()))
|
||||
|
@ -100,11 +100,11 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
|
||||
setupToolbar()
|
||||
|
||||
userImage.setOnClickListener {
|
||||
userImage?.setOnClickListener {
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(mainActivity, userImage, getString(R.string.transition_user_image))
|
||||
NavigationUtil.goToUserInfo(requireActivity(), options)
|
||||
}
|
||||
titleWelcome.text = String.format("%s", PreferenceUtil.getInstance(requireContext()).userName)
|
||||
titleWelcome?.text = String.format("%s", PreferenceUtil.getInstance(requireContext()).userName)
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
homeAdapter = HomeAdapter(mainActivity, displayMetrics)
|
||||
|
@ -127,7 +127,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
|
||||
private fun setupToolbar() {
|
||||
toolbar.apply {
|
||||
setBackgroundColor(toolbarColor())
|
||||
backgroundTintList = ColorStateList.valueOf(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface))
|
||||
setNavigationIcon(R.drawable.ic_menu_white_24dp)
|
||||
setOnClickListener {
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(mainActivity, toolbarContainer, getString(R.string.transition_toolbar))
|
||||
|
|
|
@ -143,9 +143,9 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
|
|||
playerToolbar.apply {
|
||||
inflateMenu(R.menu.menu_player)
|
||||
setNavigationOnClickListener { requireActivity().onBackPressed() }
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, primaryColor, activity)
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, primaryColor, requireActivity())
|
||||
setTitleTextColor(primaryColor)
|
||||
setSubtitleTextColor(ThemeStore.textColorSecondary(context!!))
|
||||
setSubtitleTextColor(ThemeStore.textColorSecondary(requireContext()))
|
||||
setOnMenuItemClickListener(this@AdaptiveFragment)
|
||||
}
|
||||
}
|
||||
|
@ -183,8 +183,8 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
|
|||
override fun onColorChanged(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
callbacks!!.onPaletteColorChanged()
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.iconColor), activity)
|
||||
callbacks?.onPaletteColorChanged()
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity())
|
||||
}
|
||||
|
||||
override fun onShow() {
|
||||
|
@ -201,7 +201,7 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
|
|||
}
|
||||
|
||||
override fun toolbarIconColor(): Int {
|
||||
return ATHUtil.resolveColor(context, R.attr.iconColor)
|
||||
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override val paletteColor: Int
|
||||
|
|
|
@ -14,17 +14,17 @@ 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.retromusic.R
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.*
|
||||
import kotlinx.android.synthetic.main.media_button.*
|
||||
import kotlinx.android.synthetic.main.player_time.*
|
||||
|
||||
|
||||
class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||
|
||||
|
@ -33,7 +33,6 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
|
||||
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
|
||||
|
|
|
@ -8,14 +8,14 @@ import androidx.appcompat.widget.Toolbar
|
|||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import kotlinx.android.synthetic.main.fragment_fit.*
|
||||
|
||||
|
||||
class FitFragment : AbsPlayerFragment() {
|
||||
class FitFragment : AbsPlayerFragment() {
|
||||
override fun playerToolbar(): Toolbar {
|
||||
return playerToolbar
|
||||
}
|
||||
|
@ -40,15 +40,15 @@ class FitFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
override fun toolbarIconColor(): Int {
|
||||
return ATHUtil.resolveColor(context, R.attr.iconColor)
|
||||
return ATHUtil.resolveColor(context, R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
callbacks!!.onPaletteColorChanged()
|
||||
callbacks?.onPaletteColorChanged()
|
||||
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.iconColor), activity)
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity())
|
||||
|
||||
}
|
||||
|
||||
|
@ -84,11 +84,11 @@ class FitFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
private fun setUpPlayerToolbar() {
|
||||
playerToolbar!!.apply {
|
||||
playerToolbar.apply {
|
||||
inflateMenu(R.menu.menu_player)
|
||||
setNavigationOnClickListener { activity!!.onBackPressed() }
|
||||
setNavigationOnClickListener { requireActivity().onBackPressed() }
|
||||
setOnMenuItemClickListener(this@FitFragment)
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.iconColor), activity)
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.iconColor), requireActivity())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,9 @@ class FlatPlayerFragment : AbsPlayerFragment() {
|
|||
|
||||
private fun setUpPlayerToolbar() {
|
||||
playerToolbar.inflateMenu(R.menu.menu_player)
|
||||
playerToolbar.setNavigationOnClickListener { _ -> activity!!.onBackPressed() }
|
||||
playerToolbar.setNavigationOnClickListener { _ -> requireActivity().onBackPressed() }
|
||||
playerToolbar.setOnMenuItemClickListener(this)
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context,
|
||||
R.attr.iconColor), activity)
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.iconColor), requireActivity())
|
||||
}
|
||||
|
||||
private fun colorize(i: Int) {
|
||||
|
@ -90,24 +89,21 @@ class FlatPlayerFragment : AbsPlayerFragment() {
|
|||
override fun toolbarIconColor(): Int {
|
||||
val isLight = ColorUtil.isColorLight(paletteColor)
|
||||
return if (PreferenceUtil.getInstance(requireContext()).adaptiveColor)
|
||||
MaterialValueHelper.getPrimaryTextColor(context, isLight)
|
||||
MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight)
|
||||
else
|
||||
ATHUtil.resolveColor(context, R.attr.iconColor)
|
||||
ATHUtil.resolveColor(context, R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
lastColor = color
|
||||
flatPlaybackControlsFragment.setDark(color)
|
||||
callbacks!!.onPaletteColorChanged()
|
||||
|
||||
callbacks?.onPaletteColorChanged()
|
||||
val isLight = ColorUtil.isColorLight(color)
|
||||
|
||||
//TransitionManager.beginDelayedTransition(mToolbar);
|
||||
val iconColor = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor)
|
||||
MaterialValueHelper.getPrimaryTextColor(context!!, isLight)
|
||||
MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight)
|
||||
else
|
||||
ATHUtil.resolveColor(context!!, R.attr.iconColor)
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, activity)
|
||||
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, requireActivity())
|
||||
if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
||||
colorize(color)
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class MaterialFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
override fun toolbarIconColor(): Int {
|
||||
return ATHUtil.resolveColor(requireContext(), R.attr.iconColor)
|
||||
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
|
@ -52,7 +52,7 @@ class MaterialFragment : AbsPlayerFragment() {
|
|||
lastColor = color
|
||||
callbacks?.onPaletteColorChanged()
|
||||
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.iconColor), requireActivity())
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity())
|
||||
}
|
||||
|
||||
override fun toggleFavorite(song: Song) {
|
||||
|
@ -89,7 +89,7 @@ class MaterialFragment : AbsPlayerFragment() {
|
|||
inflateMenu(R.menu.menu_player)
|
||||
setNavigationOnClickListener { requireActivity().onBackPressed() }
|
||||
setOnMenuItemClickListener(this@MaterialFragment)
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.iconColor), requireActivity())
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package code.name.monkey.retromusic.fragments.player.normal
|
|||
import android.animation.ArgbEvaluator
|
||||
import android.animation.ValueAnimator
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
@ -22,7 +21,7 @@ import code.name.monkey.retromusic.views.DrawableGradient
|
|||
import kotlinx.android.synthetic.main.fragment_player.*
|
||||
|
||||
|
||||
class PlayerFragment : AbsPlayerFragment() {
|
||||
class PlayerFragment : AbsPlayerFragment() {
|
||||
|
||||
private var lastColor: Int = 0
|
||||
override val paletteColor: Int
|
||||
|
@ -34,15 +33,19 @@ class PlayerFragment : AbsPlayerFragment() {
|
|||
|
||||
private fun colorize(i: Int) {
|
||||
if (valueAnimator != null) {
|
||||
valueAnimator!!.cancel()
|
||||
valueAnimator?.cancel()
|
||||
}
|
||||
|
||||
valueAnimator = ValueAnimator.ofObject(ArgbEvaluator(), android.R.color.transparent, i)
|
||||
valueAnimator!!.addUpdateListener { animation ->
|
||||
val drawable = DrawableGradient(GradientDrawable.Orientation.TOP_BOTTOM, intArrayOf(animation.animatedValue as Int, android.R.color.transparent), 0)
|
||||
colorGradientBackground?.background = drawable
|
||||
valueAnimator = ValueAnimator.ofObject(ArgbEvaluator(), ATHUtil.resolveColor(requireContext(), R.attr.colorSurface), i)
|
||||
valueAnimator?.addUpdateListener { animation ->
|
||||
if (isAdded) {
|
||||
val drawable = DrawableGradient(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
intArrayOf(animation.animatedValue as Int,
|
||||
ATHUtil.resolveColor(requireContext(), R.attr.colorSurface)), 0)
|
||||
colorGradientBackground?.background = drawable
|
||||
}
|
||||
}
|
||||
valueAnimator!!.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong()).start()
|
||||
valueAnimator?.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong())?.start()
|
||||
}
|
||||
|
||||
override fun onShow() {
|
||||
|
@ -59,25 +62,21 @@ class PlayerFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
override fun toolbarIconColor(): Int {
|
||||
return ATHUtil.resolveColor(context, R.attr.iconColor)
|
||||
return ATHUtil.resolveColor(context, R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
playbackControlsFragment.setDark(color)
|
||||
lastColor = color
|
||||
callbacks!!.onPaletteColorChanged()
|
||||
callbacks?.onPaletteColorChanged()
|
||||
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.iconColor), activity)
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.colorControlNormal), activity)
|
||||
|
||||
if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
||||
colorize(color)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCutOff(): Int {
|
||||
return if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) 20 else 0
|
||||
}
|
||||
|
||||
override fun toggleFavorite(song: Song) {
|
||||
super.toggleFavorite(song)
|
||||
if (song.id == MusicPlayerRemote.currentSong.id) {
|
||||
|
|
|
@ -60,9 +60,9 @@ class PeakPlayerFragment : AbsPlayerFragment() {
|
|||
private fun setUpPlayerToolbar() {
|
||||
playerToolbar.apply {
|
||||
inflateMenu(R.menu.menu_player)
|
||||
setNavigationOnClickListener { activity!!.onBackPressed() }
|
||||
setNavigationOnClickListener { requireActivity().onBackPressed() }
|
||||
setOnMenuItemClickListener(this@PeakPlayerFragment)
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.iconColor), activity)
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class PeakPlayerFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
override fun toolbarIconColor(): Int {
|
||||
return ATHUtil.resolveColor(requireContext(), R.attr.iconColor)
|
||||
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override val paletteColor: Int
|
||||
|
|
|
@ -60,14 +60,14 @@ class SimplePlayerFragment : AbsPlayerFragment() {
|
|||
}
|
||||
|
||||
override fun toolbarIconColor(): Int {
|
||||
return ATHUtil.resolveColor(requireContext(), R.attr.iconColor)
|
||||
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||
}
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
lastColor = color
|
||||
callbacks?.onPaletteColorChanged()
|
||||
simplePlaybackControlsFragment.setDark(color)
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.iconColor), requireActivity())
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity())
|
||||
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ class SimplePlayerFragment : AbsPlayerFragment() {
|
|||
inflateMenu(R.menu.menu_player)
|
||||
setNavigationOnClickListener { requireActivity().onBackPressed() }
|
||||
setOnMenuItemClickListener(this@SimplePlayerFragment)
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.iconColor), requireActivity())
|
||||
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() {
|
|||
NavigationUtil.goToProVersion(requireActivity())
|
||||
}
|
||||
|
||||
internal fun setSummary(preference: Preference, value: Any) {
|
||||
internal fun setSummary(preference: Preference, value: Any?) {
|
||||
val stringValue = value.toString()
|
||||
if (preference is ListPreference) {
|
||||
val index = preference.findIndexOfValue(stringValue)
|
||||
|
@ -52,16 +52,18 @@ abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() {
|
|||
|
||||
abstract fun invalidateSettings()
|
||||
|
||||
protected fun setSummary(preference: Preference) {
|
||||
setSummary(preference, PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.context)
|
||||
.getString(preference.key, "")!!)
|
||||
protected fun setSummary(preference: Preference?) {
|
||||
preference?.let {
|
||||
setSummary(it, PreferenceManager
|
||||
.getDefaultSharedPreferences(it.context)
|
||||
.getString(it.key, ""))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setDivider(ColorDrawable(Color.TRANSPARENT))
|
||||
listView.setBackgroundColor(ATHUtil.resolveColor(requireContext(), R.attr.colorPrimary))
|
||||
listView.setBackgroundColor(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface))
|
||||
listView.overScrollMode = View.OVER_SCROLL_NEVER
|
||||
listView.setPadding(0, 0, 0, 0)
|
||||
listView.setPaddingRelative(0, 0, 0, 0)
|
||||
|
|
|
@ -37,7 +37,7 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
|
|||
R.id.generalSettings -> inflateFragment(ThemeSettingsFragment(), R.string.general_settings_title)
|
||||
R.id.audioSettings -> inflateFragment(AudioSettings(), R.string.pref_header_audio)
|
||||
R.id.nowPlayingSettings -> inflateFragment(NowPlayingSettingsFragment(), R.string.now_playing)
|
||||
R.id.personalizeSettings -> inflateFragment(PersonaizeSettingsFragment(), R.string.personalize)
|
||||
R.id.personalizeSettings -> inflateFragment(PersonalizeSettingsFragment(), R.string.personalize)
|
||||
R.id.imageSettings -> inflateFragment(ImageSettingFragment(), R.string.pref_header_images)
|
||||
R.id.notificationSettings -> inflateFragment(NotificationSettingsFragment(), R.string.notification)
|
||||
R.id.otherSettings -> inflateFragment(OtherSettingsFragment(), R.string.others)
|
||||
|
|
|
@ -30,8 +30,6 @@ class OtherSettingsFragment : AbsSettingsFragment() {
|
|||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_blacklist)
|
||||
addPreferencesFromResource(R.xml.pref_playlists)
|
||||
addPreferencesFromResource(R.xml.pref_advanced)
|
||||
}
|
||||
|
||||
|
|
|
@ -19,23 +19,14 @@ import android.os.Bundle
|
|||
import android.view.View
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.TwoStatePreference
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
|
||||
|
||||
class PersonaizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
class PersonalizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
override fun invalidateSettings() {
|
||||
val cornerWindow: TwoStatePreference = findPreference("corner_window")!!
|
||||
cornerWindow.setOnPreferenceChangeListener { _, newValue ->
|
||||
if (newValue as Boolean && !App.isProVersion()) {
|
||||
showProToastAndNavigate(activity!!.getString(R.string.pref_title_round_corners))
|
||||
return@setOnPreferenceChangeListener false
|
||||
}
|
||||
requireActivity().recreate()
|
||||
return@setOnPreferenceChangeListener true
|
||||
}
|
||||
|
||||
val toggleFullScreen: TwoStatePreference = findPreference("toggle_full_screen")!!
|
||||
toggleFullScreen.setOnPreferenceChangeListener { _, _ ->
|
||||
requireActivity().recreate()
|
||||
|
@ -45,8 +36,6 @@ class PersonaizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSh
|
|||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_ui)
|
||||
addPreferencesFromResource(R.xml.pref_window)
|
||||
addPreferencesFromResource(R.xml.pref_lockscreen)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
@ -19,34 +19,21 @@ import android.database.Cursor
|
|||
import android.net.Uri
|
||||
import android.provider.BaseColumns
|
||||
import android.provider.MediaStore.Audio.Genres
|
||||
import code.name.monkey.retromusic.Constants.baseProjection
|
||||
import code.name.monkey.retromusic.Constants.BASE_SELECTION
|
||||
import code.name.monkey.retromusic.Constants.baseProjection
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import io.reactivex.Observable
|
||||
import java.util.*
|
||||
|
||||
|
||||
object GenreLoader {
|
||||
|
||||
fun getAllGenresFlowable(context: Context): Observable<ArrayList<Genre>> {
|
||||
return getGenresFromCursorFlowable(context, makeGenreCursor(context))
|
||||
}
|
||||
|
||||
fun getAllGenres(context: Context): ArrayList<Genre> {
|
||||
return getGenresFromCursor(context, makeGenreCursor(context))
|
||||
}
|
||||
|
||||
fun getSongsFlowable(context: Context, genreId: Int): Observable<ArrayList<Song>> {
|
||||
// The genres table only stores songs that have a genre specified,
|
||||
// so we need to get songs without a genre a different way.
|
||||
return if (genreId == -1) {
|
||||
getSongsWithNoGenreFlowable(context)
|
||||
} else SongLoader.getSongsFlowable(makeGenreSongCursor(context, genreId))
|
||||
|
||||
}
|
||||
|
||||
fun getSongs(context: Context, genreId: Int): ArrayList<Song> {
|
||||
// The genres table only stores songs that have a genre specified,
|
||||
// so we need to get songs without a genre a different way.
|
||||
|
@ -64,12 +51,6 @@ object GenreLoader {
|
|||
|
||||
}
|
||||
|
||||
private fun getSongsWithNoGenreFlowable(context: Context): Observable<ArrayList<Song>> {
|
||||
val selection = BaseColumns._ID + " NOT IN " +
|
||||
"(SELECT " + Genres.Members.AUDIO_ID + " FROM audio_genres_map)"
|
||||
return SongLoader.getSongsFlowable(SongLoader.makeSongCursor(context, selection, null))
|
||||
}
|
||||
|
||||
private fun getSongsWithNoGenre(context: Context): ArrayList<Song> {
|
||||
val selection = BaseColumns._ID + " NOT IN " +
|
||||
"(SELECT " + Genres.Members.AUDIO_ID + " FROM audio_genres_map)"
|
||||
|
@ -112,34 +93,6 @@ object GenreLoader {
|
|||
|
||||
}
|
||||
|
||||
private fun getGenresFromCursorFlowable(context: Context, cursor: Cursor?): Observable<ArrayList<Genre>> {
|
||||
return Observable.create { e ->
|
||||
val genres = ArrayList<Genre>()
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
val genre = getGenreFromCursor(context, cursor)
|
||||
if (genre.songCount > 0) {
|
||||
genres.add(genre)
|
||||
} else {
|
||||
// try to remove the empty genre from the media store
|
||||
try {
|
||||
context.contentResolver.delete(Genres.EXTERNAL_CONTENT_URI, Genres._ID + " == " + genre.id, null)
|
||||
} catch (ex: Exception) {
|
||||
ex.printStackTrace()
|
||||
// nothing we can do then
|
||||
}
|
||||
|
||||
}
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
cursor.close()
|
||||
}
|
||||
e.onNext(genres)
|
||||
e.onComplete()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGenresFromCursor(context: Context, cursor: Cursor?): ArrayList<Genre> {
|
||||
val genres = arrayListOf<Genre>()
|
||||
if (cursor != null) {
|
||||
|
|
|
@ -16,31 +16,40 @@ package code.name.monkey.retromusic.loaders
|
|||
|
||||
import android.content.Context
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import java.util.*
|
||||
|
||||
|
||||
object SearchLoader {
|
||||
fun searchAll(context: Context, query: String?): MutableList<Any> {
|
||||
val results = mutableListOf<Any>()
|
||||
query?.let {
|
||||
val songs = SongLoader.getSongs(context, it)
|
||||
query?.let { searchString ->
|
||||
val songs = SongLoader.getSongs(context, searchString)
|
||||
if (songs.isNotEmpty()) {
|
||||
results.add(context.resources.getString(R.string.songs))
|
||||
results.addAll(songs)
|
||||
}
|
||||
|
||||
val artists = ArtistLoader.getArtists(context, it)
|
||||
val artists = ArtistLoader.getArtists(context, searchString)
|
||||
if (artists.isNotEmpty()) {
|
||||
results.add(context.resources.getString(R.string.artists))
|
||||
results.addAll(artists)
|
||||
}
|
||||
|
||||
val albums = AlbumLoader.getAlbums(context, it)
|
||||
val albums = AlbumLoader.getAlbums(context, searchString)
|
||||
if (albums.isNotEmpty()) {
|
||||
results.add(context.resources.getString(R.string.albums))
|
||||
results.addAll(albums)
|
||||
}
|
||||
val genres: List<Genre> = GenreLoader.getAllGenres(context).filter { genre -> genre.name.toLowerCase(Locale.getDefault()).contains(searchString.toLowerCase(Locale.getDefault())) }
|
||||
genres.forEach {
|
||||
println(it.name)
|
||||
}
|
||||
if (genres.isNotEmpty()) {
|
||||
results.add(context.resources.getString(R.string.genres))
|
||||
results.addAll(genres)
|
||||
}
|
||||
}
|
||||
return results
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import code.name.monkey.retromusic.adapter.HomeAdapter.Companion.HomeSection
|
|||
|
||||
class Home(val priority: Int,
|
||||
@StringRes val title: Int,
|
||||
@StringRes val subTitle: Int,
|
||||
val arrayList: ArrayList<*>,
|
||||
@HomeSection
|
||||
val homeSection: Int,
|
||||
|
|
|
@ -53,9 +53,7 @@ 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 Success -> withContext(Dispatchers.Main) { view?.showData(result.data) }
|
||||
is Error -> withContext(Dispatchers.Main) { view?.showEmptyView() }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,7 +144,6 @@ class RepositoryImpl(private val context: Context) : Repository {
|
|||
} else {
|
||||
Success(Home(0,
|
||||
R.string.recent_artists,
|
||||
R.string.recent_added_artists,
|
||||
artists,
|
||||
HomeAdapter.RECENT_ARTISTS,
|
||||
R.drawable.ic_artist_white_24dp))
|
||||
|
@ -162,7 +161,6 @@ class RepositoryImpl(private val context: Context) : Repository {
|
|||
} else {
|
||||
Success(Home(1,
|
||||
R.string.recent_albums,
|
||||
R.string.recent_added_albums,
|
||||
albums,
|
||||
HomeAdapter.RECENT_ALBUMS,
|
||||
R.drawable.ic_album_white_24dp
|
||||
|
@ -181,7 +179,6 @@ class RepositoryImpl(private val context: Context) : Repository {
|
|||
} else {
|
||||
Success(Home(3,
|
||||
R.string.top_albums,
|
||||
R.string.most_played_albums,
|
||||
albums,
|
||||
HomeAdapter.TOP_ALBUMS,
|
||||
R.drawable.ic_album_white_24dp
|
||||
|
@ -201,7 +198,6 @@ class RepositoryImpl(private val context: Context) : Repository {
|
|||
} else {
|
||||
Success(Home(2,
|
||||
R.string.top_artists,
|
||||
R.string.most_played_artists,
|
||||
artists,
|
||||
HomeAdapter.TOP_ARTISTS,
|
||||
R.drawable.ic_artist_white_24dp
|
||||
|
@ -220,7 +216,6 @@ class RepositoryImpl(private val context: Context) : Repository {
|
|||
} else {
|
||||
Success(Home(4,
|
||||
R.string.favorites,
|
||||
R.string.favorites_songs,
|
||||
playlists,
|
||||
HomeAdapter.PLAYLISTS,
|
||||
R.drawable.ic_favorite_white_24dp
|
||||
|
@ -252,12 +247,6 @@ class RepositoryImpl(private val context: Context) : Repository {
|
|||
}
|
||||
}
|
||||
|
||||
override fun getSongFlowable(id: Int): Observable<Song> {
|
||||
return SongLoader.getSongFlowable(context, id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
override fun getAlbumFlowable(albumId: Int): Observable<Album> {
|
||||
return AlbumLoader.getAlbumFlowable(context, albumId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -276,70 +265,12 @@ class RepositoryImpl(private val context: Context) : Repository {
|
|||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
override fun getGenreFlowable(genreId: Int): Observable<ArrayList<Song>> {
|
||||
return GenreLoader.getSongsFlowable(context, genreId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
|
||||
override val favoritePlaylistFlowable: Observable<ArrayList<Playlist>>
|
||||
get() = PlaylistLoader.getFavoritePlaylistFlowable(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
|
||||
override val allSongsFlowable: Observable<ArrayList<Song>>
|
||||
get() = SongLoader.getAllSongsFlowable(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val suggestionSongsFlowable: Observable<ArrayList<Song>>
|
||||
get() = SongLoader.suggestSongs(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val allAlbumsFlowable: Observable<ArrayList<Album>>
|
||||
get() = AlbumLoader.getAllAlbumsFlowable(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val recentAlbumsFlowable: Observable<ArrayList<Album>>
|
||||
get() = LastAddedSongsLoader.getLastAddedAlbumsFlowable(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val topAlbumsFlowable: Observable<ArrayList<Album>>
|
||||
get() = TopAndRecentlyPlayedTracksLoader.getTopAlbumsFlowable(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val allArtistsFlowable: Observable<ArrayList<Artist>>
|
||||
get() = ArtistLoader.getAllArtistsFlowable(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val recentArtistsFlowable: Observable<ArrayList<Artist>>
|
||||
get() = LastAddedSongsLoader.getLastAddedArtistsFlowable(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val topArtistsFlowable: Observable<ArrayList<Artist>>
|
||||
get() = TopAndRecentlyPlayedTracksLoader.getTopArtistsFlowable(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override val allPlaylistsFlowable: Observable<ArrayList<Playlist>>
|
||||
get() = PlaylistLoader.getAllPlaylistsFlowoable(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
|
||||
override val allGenresFlowable: Observable<ArrayList<Genre>>
|
||||
get() = GenreLoader.getAllGenresFlowable(context)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
override fun getSong(id: Int): Song {
|
||||
return SongLoader.getSong(context, id)
|
||||
}
|
||||
|
@ -352,11 +283,10 @@ class RepositoryImpl(private val context: Context) : Repository {
|
|||
return ArtistLoader.getArtist(context, artistId.toInt())
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
suspend fun <T : Any> safeApiCall(call: suspend () -> Result<T>, errorMessage: String): Result<T> = try {
|
||||
call.invoke()
|
||||
} catch (e: Exception) {
|
||||
Result.Error(IOException(errorMessage, e))
|
||||
Error(IOException(errorMessage, e))
|
||||
}
|
||||
|
|
|
@ -55,28 +55,6 @@ interface Repository {
|
|||
|
||||
suspend fun artistById(artistId: Int): Result<Artist>
|
||||
|
||||
val allSongsFlowable: Observable<ArrayList<Song>>
|
||||
|
||||
val suggestionSongsFlowable: Observable<ArrayList<Song>>
|
||||
|
||||
val allAlbumsFlowable: Observable<ArrayList<Album>>
|
||||
|
||||
val recentAlbumsFlowable: Observable<ArrayList<Album>>
|
||||
|
||||
val topAlbumsFlowable: Observable<ArrayList<Album>>
|
||||
|
||||
val allArtistsFlowable: Observable<ArrayList<Artist>>
|
||||
|
||||
val recentArtistsFlowable: Observable<ArrayList<Artist>>
|
||||
|
||||
val topArtistsFlowable: Observable<ArrayList<Artist>>
|
||||
|
||||
val allPlaylistsFlowable: Observable<ArrayList<Playlist>>
|
||||
|
||||
val allGenresFlowable: Observable<ArrayList<Genre>>
|
||||
|
||||
fun getSongFlowable(id: Int): Observable<Song>
|
||||
|
||||
fun getSong(id: Int): Song
|
||||
|
||||
fun getAlbumFlowable(albumId: Int): Observable<Album>
|
||||
|
@ -89,10 +67,6 @@ interface Repository {
|
|||
|
||||
fun getPlaylistSongsFlowable(playlist: Playlist): Observable<ArrayList<Song>>
|
||||
|
||||
fun getGenreFlowable(genreId: Int): Observable<ArrayList<Song>>
|
||||
|
||||
|
||||
val favoritePlaylistFlowable: Observable<ArrayList<Playlist>>
|
||||
|
||||
|
||||
}
|
|
@ -38,12 +38,13 @@ public class RetroColorUtil {
|
|||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color, hsv);
|
||||
|
||||
hsv[1] = ( hsv[1] / 1 * ratio ) + ( 0.2f * (1.0f - ratio) );
|
||||
hsv[1] = (hsv[1] / 1 * ratio) + (0.2f * (1.0f - ratio));
|
||||
|
||||
return Color.HSVToColor(hsv);
|
||||
}
|
||||
|
||||
public static int toolbarColor(@NonNull Context context) {
|
||||
return ATHUtil.INSTANCE.resolveColor(context, R.attr.colorSurface);
|
||||
return ATHUtil.INSTANCE.resolveColor(context, R.attr.colorButtonNormal);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -15,13 +15,10 @@ object ThemeManager {
|
|||
@StyleRes
|
||||
fun getThemeResValue(context: Context): Int = when (PreferenceUtil.getInstance(context).generalThemeValue) {
|
||||
"light" -> R.style.Theme_RetroMusic_Light
|
||||
"auto" -> if (isSystemDarkModeEnabled(context)) R.style.Theme_RetroMusic else R.style.Theme_RetroMusic_Light
|
||||
"dark" -> R.style.Theme_RetroMusic_Base
|
||||
"auto" -> R.style.Theme_RetroMusic_FollowSystem
|
||||
"black" -> R.style.Theme_RetroMusic_Black
|
||||
else -> R.style.Theme_RetroMusic
|
||||
/**
|
||||
* To add a toggle for amoled theme just add an if statement such as
|
||||
* if(PreferenceUtil.getInstance(context).useAmoled) blablabla
|
||||
*/
|
||||
else -> R.style.Theme_RetroMusic_FollowSystem
|
||||
}
|
||||
|
||||
private fun isSystemDarkModeEnabled(context: Context): Boolean {
|
||||
|
|
|
@ -14,119 +14,107 @@
|
|||
|
||||
package code.name.monkey.retromusic.util
|
||||
|
||||
import android.animation.*
|
||||
import android.animation.Animator
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.animation.ObjectAnimator
|
||||
import android.content.Context
|
||||
import android.content.res.*
|
||||
import android.graphics.*
|
||||
import android.content.res.ColorStateList
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Color
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.animation.PathInterpolator
|
||||
import android.widget.*
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.SeekBar
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.view.ViewCompat
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
|
||||
object ViewUtil {
|
||||
|
||||
const val RETRO_MUSIC_ANIM_TIME = 1000
|
||||
const val RETRO_MUSIC_ANIM_TIME = 1000
|
||||
|
||||
fun setProgressDrawable(progressSlider: SeekBar, newColor: Int, thumbTint: Boolean = false) {
|
||||
fun setProgressDrawable(progressSlider: SeekBar, newColor: Int, thumbTint: Boolean = false) {
|
||||
|
||||
if (thumbTint) {
|
||||
progressSlider.thumbTintList = ColorStateList.valueOf(newColor)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
val layerDrawable = progressSlider.progressDrawable as LayerDrawable
|
||||
val progressDrawable = layerDrawable.findDrawableByLayerId(android.R.id.progress)
|
||||
progressDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
} else {
|
||||
progressSlider.progressTintList = ColorStateList.valueOf(newColor)
|
||||
}
|
||||
}
|
||||
if (thumbTint) {
|
||||
progressSlider.thumbTintList = ColorStateList.valueOf(newColor)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
val layerDrawable = progressSlider.progressDrawable as LayerDrawable
|
||||
val progressDrawable = layerDrawable.findDrawableByLayerId(android.R.id.progress)
|
||||
progressDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
} else {
|
||||
progressSlider.progressTintList = ColorStateList.valueOf(newColor)
|
||||
}
|
||||
}
|
||||
|
||||
fun setProgressDrawable(progressSlider: ProgressBar, newColor: Int) {
|
||||
fun setProgressDrawable(progressSlider: ProgressBar, newColor: Int) {
|
||||
|
||||
val ld = progressSlider.progressDrawable as LayerDrawable
|
||||
val ld = progressSlider.progressDrawable as LayerDrawable
|
||||
|
||||
val progress = ld.findDrawableByLayerId(android.R.id.progress)
|
||||
progress.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
val progress = ld.findDrawableByLayerId(android.R.id.progress)
|
||||
progress.setColorFilter(newColor, PorterDuff.Mode.SRC_IN)
|
||||
|
||||
val background = ld.findDrawableByLayerId(android.R.id.background)
|
||||
val primaryColor = ATHUtil.resolveColor(progressSlider.context, R.attr.colorPrimary)
|
||||
background.setColorFilter(
|
||||
MaterialValueHelper.getPrimaryDisabledTextColor(
|
||||
progressSlider.context, ColorUtil.isColorLight(
|
||||
primaryColor
|
||||
)
|
||||
), PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
val background = ld.findDrawableByLayerId(android.R.id.background)
|
||||
val primaryColor = ATHUtil.resolveColor(progressSlider.context, android.R.attr.windowBackground)
|
||||
background.setColorFilter(MaterialValueHelper.getPrimaryDisabledTextColor(progressSlider.context, ColorUtil.isColorLight(primaryColor)), PorterDuff.Mode.SRC_IN)
|
||||
|
||||
val secondaryProgress = ld.findDrawableByLayerId(android.R.id.secondaryProgress)
|
||||
secondaryProgress?.setColorFilter(
|
||||
ColorUtil.withAlpha(newColor, 0.65f), PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
val secondaryProgress = ld.findDrawableByLayerId(android.R.id.secondaryProgress)
|
||||
secondaryProgress?.setColorFilter(
|
||||
ColorUtil.withAlpha(newColor, 0.65f), PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
|
||||
private fun createColorAnimator(
|
||||
target: Any, propertyName: String, @ColorInt startColor: Int, @ColorInt endColor: Int
|
||||
): Animator {
|
||||
val animator: ObjectAnimator
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor)
|
||||
} else {
|
||||
animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor)
|
||||
animator.setEvaluator(ArgbEvaluator())
|
||||
}
|
||||
private fun createColorAnimator(
|
||||
target: Any, propertyName: String, @ColorInt startColor: Int, @ColorInt endColor: Int
|
||||
): Animator {
|
||||
val animator: ObjectAnimator
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor)
|
||||
} else {
|
||||
animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor)
|
||||
animator.setEvaluator(ArgbEvaluator())
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
animator.interpolator = PathInterpolator(0.4f, 0f, 1f, 1f)
|
||||
}
|
||||
animator.duration = RETRO_MUSIC_ANIM_TIME.toLong()
|
||||
return animator
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
animator.interpolator = PathInterpolator(0.4f, 0f, 1f, 1f)
|
||||
}
|
||||
animator.duration = RETRO_MUSIC_ANIM_TIME.toLong()
|
||||
return animator
|
||||
}
|
||||
|
||||
fun hitTest(v: View, x: Int, y: Int): Boolean {
|
||||
val tx = (ViewCompat.getTranslationX(v) + 0.5f).toInt()
|
||||
val ty = (ViewCompat.getTranslationY(v) + 0.5f).toInt()
|
||||
val left = v.left + tx
|
||||
val right = v.right + tx
|
||||
val top = v.top + ty
|
||||
val bottom = v.bottom + ty
|
||||
fun hitTest(v: View, x: Int, y: Int): Boolean {
|
||||
val tx = (ViewCompat.getTranslationX(v) + 0.5f).toInt()
|
||||
val ty = (ViewCompat.getTranslationY(v) + 0.5f).toInt()
|
||||
val left = v.left + tx
|
||||
val right = v.right + tx
|
||||
val top = v.top + ty
|
||||
val bottom = v.bottom + ty
|
||||
|
||||
return x in left..right && y >= top && y <= bottom
|
||||
}
|
||||
return x in left..right && y >= top && y <= bottom
|
||||
}
|
||||
|
||||
fun setUpFastScrollRecyclerViewColor(
|
||||
context: Context,
|
||||
recyclerView: FastScrollRecyclerView,
|
||||
accentColor: Int = ThemeStore.accentColor(context)
|
||||
) {
|
||||
recyclerView.setPopupBgColor(accentColor)
|
||||
recyclerView.setPopupTextColor(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
context, ColorUtil.isColorLight(
|
||||
accentColor
|
||||
)
|
||||
)
|
||||
)
|
||||
recyclerView.setThumbColor(accentColor)
|
||||
recyclerView.setTrackColor(Color.TRANSPARENT)
|
||||
recyclerView.setTrackColor(
|
||||
ColorUtil.withAlpha(
|
||||
ATHUtil.resolveColor(
|
||||
context, R.attr.colorControlNormal
|
||||
), 0.12f
|
||||
)
|
||||
)
|
||||
fun setUpFastScrollRecyclerViewColor(
|
||||
context: Context,
|
||||
recyclerView: FastScrollRecyclerView,
|
||||
accentColor: Int = ThemeStore.accentColor(context)
|
||||
) {
|
||||
recyclerView.setPopupBgColor(accentColor)
|
||||
recyclerView.setPopupTextColor(MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(accentColor)))
|
||||
recyclerView.setThumbColor(accentColor)
|
||||
recyclerView.setTrackColor(Color.TRANSPARENT)
|
||||
recyclerView.setTrackColor(ColorUtil.withAlpha(ATHUtil.resolveColor(context, R.attr.colorControlNormal), 0.12f))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun convertDpToPixel(dp: Float, resources: Resources): Float {
|
||||
val metrics = resources.displayMetrics
|
||||
return dp * metrics.density
|
||||
}
|
||||
fun convertDpToPixel(dp: Float, resources: Resources): Float {
|
||||
val metrics = resources.displayMetrics
|
||||
return dp * metrics.density
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ package code.name.monkey.retromusic.views
|
|||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.RippleDrawable
|
||||
import android.util.AttributeSet
|
||||
import androidx.core.content.ContextCompat
|
||||
|
@ -38,12 +39,14 @@ class BottomNavigationBarTinted @JvmOverloads constructor(
|
|||
labelVisibilityMode = PreferenceUtil.getInstance(context).tabTitleMode
|
||||
selectedItemId = PreferenceUtil.getInstance(context).lastPage
|
||||
|
||||
val iconColor = ATHUtil.resolveColor(context, R.attr.iconColor)
|
||||
val iconColor = ATHUtil.resolveColor(context, android.R.attr.colorControlNormal)
|
||||
val accentColor = ThemeStore.accentColor(context)
|
||||
NavigationViewUtil.setItemIconColors(this, ColorUtil.withAlpha(iconColor, 0.5f), accentColor)
|
||||
NavigationViewUtil.setItemTextColors(this, ColorUtil.withAlpha(iconColor, 0.5f), accentColor)
|
||||
itemBackground = RippleDrawable(RippleUtils.convertToRippleDrawableColor(ColorStateList.valueOf(ThemeStore.accentColor(context).addAlpha())), ContextCompat.getDrawable(context, R.drawable.bottom_navigation_item_background), null)
|
||||
itemBackground = RippleDrawable(RippleUtils.convertToRippleDrawableColor(ColorStateList.valueOf(ThemeStore.accentColor(context).addAlpha())), ContextCompat.getDrawable(context, R.drawable.bottom_navigation_item_background), ContextCompat.getDrawable(context, R.drawable.bottom_navigation_item_background_mask))
|
||||
setOnApplyWindowInsetsListener(null)
|
||||
//itemRippleColor = ColorStateList.valueOf(accentColor)
|
||||
background = ColorDrawable(ATHUtil.resolveColor(context, R.attr.colorSurface))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class ColorIconsImageView : AppCompatImageView {
|
|||
if (ATHUtil.isWindowBackgroundDark(context) && PreferenceUtil.getInstance(context).desaturatedColor()) {
|
||||
val desaturatedColor = RetroColorUtil.desaturateColor(color, 0.4f)
|
||||
backgroundTintList = ColorStateList.valueOf(desaturatedColor)
|
||||
imageTintList = ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.colorPrimary))
|
||||
imageTintList = ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.colorSurface))
|
||||
} else {
|
||||
backgroundTintList = ColorStateList.valueOf(ColorUtil.adjustAlpha(color, 0.22f))
|
||||
imageTintList = ColorStateList.valueOf(ColorUtil.withAlpha(color, 0.75f))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/ripple_material_light">
|
||||
android:color="?attr/colorOnSecondary">
|
||||
|
||||
<item
|
||||
android:id="@android:id/mask"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/ate_control_normal_light">
|
||||
android:color="?attr/colorOnSecondary">
|
||||
|
||||
<item
|
||||
android:id="@android:id/mask"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/ripple_material_light">
|
||||
android:color="?attr/colorOnSecondary">
|
||||
|
||||
<item
|
||||
android:id="@android:id/mask"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/ripple_material_dark">
|
||||
android:color="?attr/colorOnSecondary">
|
||||
|
||||
<item
|
||||
android:id="@android:id/mask"
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/md_black_1000" />
|
||||
<corners
|
||||
android:topLeftRadius="12dp"
|
||||
android:topRightRadius="12dp" />
|
||||
</shape>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners
|
||||
android:topLeftRadius="12dp"
|
||||
android:topRightRadius="12dp" />
|
||||
<solid android:color="?attr/cardBackgroundColor" />
|
||||
|
||||
</shape>
|
|
@ -1,6 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="8dp" />
|
||||
<solid android:color="?colorPrimary" />
|
||||
</shape>
|
||||
<solid android:color="?colorSurface" />
|
||||
</shape>
|
||||
|
||||
|
||||
<!--<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/colorBottomTabSelected">
|
||||
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/colorBottomTabSelected"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/colorBottomTabUnselected"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</ripple>-->
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="?attr/colorSurface" />
|
||||
<corners android:radius="8dp" />
|
||||
</shape>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?android:attr/colorControlHighlight">
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#000000" />
|
||||
<corners android:radius="15dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:drawable="@drawable/bottom_navigation_item_background" />
|
||||
</ripple>
|
|
@ -19,7 +19,7 @@
|
|||
android:thickness="3dp"
|
||||
android:type="sweep"
|
||||
android:useLevel="false">
|
||||
<solid android:color="?colorOnSecondary" />
|
||||
<solid android:color="?android:attr/textColorSecondary" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@android:id/progress">
|
||||
|
@ -28,7 +28,7 @@
|
|||
android:thickness="3dp"
|
||||
android:type="sweep"
|
||||
android:useLevel="true">
|
||||
<solid android:color="?colorAccent" />
|
||||
<solid android:color="?attr/colorAccent" />
|
||||
|
||||
</shape>
|
||||
</item>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="8dp" />
|
||||
<solid android:color="?colorPrimary" />
|
||||
<solid android:color="?attr/colorControlHighlight" />
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/ripple_material_light"/>
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/ripple_material_light" />
|
||||
</shape>
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/gradient_background"
|
||||
android:background="?attr/colorSurface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
|
|
|
@ -17,33 +17,40 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
<include layout="@layout/status_bar" />
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
|
||||
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
|
||||
app:behavior_overlapTop="72dp"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:elevation="0dp"
|
||||
app:elevation="0dp">
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/imageContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
app:contentScrim="@android:color/transparent"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||
app:statusBarScrim="@color/md_black_1000"
|
||||
app:titleEnabled="false">
|
||||
android:layout_height="228dp"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/imageContainer"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="182dp"
|
||||
app:layout_collapseMode="pin">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/bannerImage"
|
||||
|
@ -51,53 +58,31 @@
|
|||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_collapseMode="parallax"
|
||||
tools:background="@color/md_red_400"
|
||||
tools:ignore="ContentDescription"
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic[9]" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/shadow_up_full_theme"
|
||||
android:backgroundTint="?colorPrimary" />
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_collapseMode="pin"
|
||||
app:layout_scrollFlags="scroll|enterAlways">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/status_bar" />
|
||||
</FrameLayout>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/toolbarContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
|
||||
android:layout_marginTop="@dimen/toolbar_margin_vertical"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
|
||||
android:layout_marginBottom="@dimen/toolbar_margin_vertical"
|
||||
app:cardBackgroundColor="@android:color/transparent"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="6dp"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:layout_collapseMode="pin"
|
||||
app:layout_scrollFlags="scroll|enterAlways">
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:shapeAppearance="@style/ToolbarCornerCardView">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:background="?colorSurface"
|
||||
android:background="?attr/colorSurface"
|
||||
app:contentInsetStart="0dp"
|
||||
app:contentInsetStartWithNavigation="0dp"
|
||||
app:popupTheme="?toolbarPopupTheme"
|
||||
|
@ -106,29 +91,54 @@
|
|||
app:titleTextAppearance="@style/ToolbarTextAppearanceSearch"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</LinearLayout>
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="52dp"
|
||||
android:background="@drawable/shadow_up"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
|
||||
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
|
||||
android:elevation="@dimen/card_elevation"
|
||||
app:behavior_overlapTop="72dp"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
<code.name.monkey.retromusic.views.CircularImageView
|
||||
android:id="@+id/userImage"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:civ_border="false"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:cardBackgroundColor="?colorPrimary"
|
||||
app:cardElevation="8dp"
|
||||
app:shapeAppearanceOverlay="@style/TopCornerCardView">
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:ellipsize="end"
|
||||
android:text="@string/welcome"
|
||||
android:textColor="@color/md_white_1000"
|
||||
app:layout_constraintStart_toEndOf="@+id/userImage"
|
||||
app:layout_constraintTop_toTopOf="@+id/userImage" />
|
||||
|
||||
<include layout="@layout/home_content" />
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/titleWelcome"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:padding="0dp"
|
||||
android:textAppearance="@style/TextViewHeadline5"
|
||||
android:textColor="@color/md_white_1000"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/userImage"
|
||||
app:layout_constraintStart_toEndOf="@+id/userImage"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text"
|
||||
tools:text="@string/app_name" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<include layout="@layout/home_content" />
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</LinearLayout>
|
|
@ -8,6 +8,11 @@
|
|||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/playerAlbumCoverFragment"
|
||||
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
android:focusable="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface" />
|
||||
|
||||
<View
|
||||
android:id="@+id/colorGradientBackground"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
|
@ -36,8 +37,9 @@
|
|||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?colorPrimary"
|
||||
app:liftOnScroll="true">
|
||||
android:background="@android:color/transparent"
|
||||
android:elevation="0dp"
|
||||
app:elevation="0dp">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/toolbarContainer"
|
||||
|
@ -75,7 +77,56 @@
|
|||
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<include layout="@layout/home_content" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<code.name.monkey.retromusic.views.CircularImageView
|
||||
android:id="@+id/userImage"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:civ_border="false"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:ellipsize="end"
|
||||
android:text="@string/welcome"
|
||||
app:layout_constraintStart_toEndOf="@+id/userImage"
|
||||
app:layout_constraintTop_toTopOf="@+id/userImage"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/titleWelcome"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:padding="0dp"
|
||||
android:textAppearance="@style/TextViewHeadline5"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/userImage"
|
||||
app:layout_constraintStart_toEndOf="@+id/userImage"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<include
|
||||
layout="@layout/home_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/titleWelcome" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</LinearLayout>
|
|
@ -7,6 +7,11 @@
|
|||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface" />
|
||||
|
||||
<include layout="@layout/shadow_statusbar_toolbar" />
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface" />
|
||||
|
||||
<include layout="@layout/shadow_statusbar_toolbar" />
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface" />
|
||||
|
||||
<View
|
||||
android:id="@+id/colorGradientBackground"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -8,6 +8,13 @@
|
|||
android:focusable="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/gradient_background"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
android:id="@+id/imageContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="156dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
android:layout_gravity="fill_vertical"
|
||||
android:layout_marginStart="128dp"
|
||||
android:layout_marginEnd="128dp"
|
||||
android:background="@drawable/bg_bottom_sheet_dialog_fragment"
|
||||
android:background="?attr/colorSurface"
|
||||
android:fillViewport="true"
|
||||
android:overScrollMode="never"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
app:layout_collapseMode="parallax" />
|
||||
|
||||
<FrameLayout
|
||||
app:layout_collapseMode="pin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_collapseMode="pin">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
@ -67,6 +67,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="?attr/colorSurface"
|
||||
app:cardElevation="8dp"
|
||||
app:shapeAppearanceOverlay="@style/TopCornerCardView">
|
||||
|
||||
|
@ -75,7 +76,6 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
android:id="@+id/main_fragment_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
|
@ -27,6 +28,9 @@
|
|||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:elevation="0dp"
|
||||
app:elevation="0dp"
|
||||
app:liftOnScroll="true">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main_fragment_content"
|
||||
android:layout_width="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
@ -37,8 +38,9 @@
|
|||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?colorPrimary"
|
||||
app:liftOnScroll="true">
|
||||
android:background="@android:color/transparent"
|
||||
android:elevation="0dp"
|
||||
app:elevation="0dp">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/toolbarContainer"
|
||||
|
@ -75,8 +77,56 @@
|
|||
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<include layout="@layout/home_content" />
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<code.name.monkey.retromusic.views.CircularImageView
|
||||
android:id="@+id/userImage"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:civ_border="false"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:ellipsize="end"
|
||||
android:text="@string/welcome"
|
||||
app:layout_constraintStart_toEndOf="@+id/userImage"
|
||||
app:layout_constraintTop_toTopOf="@+id/userImage"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/titleWelcome"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:padding="0dp"
|
||||
android:textAppearance="@style/TextViewHeadline5"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/userImage"
|
||||
app:layout_constraintStart_toEndOf="@+id/userImage"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<include
|
||||
layout="@layout/home_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/titleWelcome" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</LinearLayout>
|
|
@ -7,6 +7,11 @@
|
|||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface" />
|
||||
|
||||
<View
|
||||
android:id="@+id/colorGradientBackground"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -135,7 +135,7 @@
|
|||
android:paddingRight="8dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
|
||||
|
@ -149,7 +149,7 @@
|
|||
android:paddingLeft="8dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
android:textColor="?colorOnSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="00:22" />
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
android:id="@+id/imageContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="256dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:transitionName="@string/transition_album_art">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
|
@ -60,6 +60,7 @@
|
|||
android:layout_gravity="fill_vertical"
|
||||
android:layout_marginStart="96dp"
|
||||
android:layout_marginEnd="96dp"
|
||||
android:background="?attr/colorSurface"
|
||||
android:fillViewport="true"
|
||||
android:overScrollMode="never"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="?attr/colorSurface"
|
||||
app:cardElevation="8dp"
|
||||
app:shapeAppearanceOverlay="@style/TopCornerCardView">
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:elevation="0dp"
|
||||
app:elevation="0dp">
|
||||
|
||||
|
@ -64,8 +65,8 @@
|
|||
android:layout_gravity="center"
|
||||
android:background="?roundSelector"
|
||||
android:padding="16dp"
|
||||
app:tint="@color/md_white_1000"
|
||||
app:srcCompat="@drawable/ic_add_photo_white_24dp" />
|
||||
app:srcCompat="@drawable/ic_add_photo_white_24dp"
|
||||
app:tint="@color/md_white_1000" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue