Code Cleanup
This commit is contained in:
parent
818703c573
commit
ad90694879
61 changed files with 236 additions and 495 deletions
|
@ -22,11 +22,11 @@ import android.os.Bundle
|
||||||
import android.view.animation.LinearInterpolator
|
import android.view.animation.LinearInterpolator
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityDriveModeBinding
|
import code.name.monkey.retromusic.databinding.ActivityDriveModeBinding
|
||||||
import code.name.monkey.retromusic.db.toSongEntity
|
import code.name.monkey.retromusic.db.toSongEntity
|
||||||
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
import code.name.monkey.retromusic.glide.BlurTransformation
|
import code.name.monkey.retromusic.glide.BlurTransformation
|
||||||
|
@ -66,7 +66,7 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
|
||||||
setUpMusicControllers()
|
setUpMusicControllers()
|
||||||
|
|
||||||
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
|
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
|
||||||
lastPlaybackControlsColor = ThemeStore.accentColor(this)
|
lastPlaybackControlsColor = accentColor()
|
||||||
binding.close.setOnClickListener {
|
binding.close.setOnClickListener {
|
||||||
onBackPressed()
|
onBackPressed()
|
||||||
}
|
}
|
||||||
|
@ -91,14 +91,12 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
|
||||||
private fun toggleFavorite(song: Song) {
|
private fun toggleFavorite(song: Song) {
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val playlist = repository.favoritePlaylist()
|
val playlist = repository.favoritePlaylist()
|
||||||
if (playlist != null) {
|
val songEntity = song.toSongEntity(playlist.playListId)
|
||||||
val songEntity = song.toSongEntity(playlist.playListId)
|
val isFavorite = repository.isSongFavorite(song.id)
|
||||||
val isFavorite = repository.isSongFavorite(song.id)
|
if (isFavorite) {
|
||||||
if (isFavorite) {
|
repository.removeSongFromPlaylist(songEntity)
|
||||||
repository.removeSongFromPlaylist(songEntity)
|
} else {
|
||||||
} else {
|
repository.insertSongs(listOf(song.toSongEntity(playlist.playListId)))
|
||||||
repository.insertSongs(listOf(song.toSongEntity(playlist.playListId)))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sendBroadcast(Intent(MusicService.FAVORITE_STATE_CHANGED))
|
sendBroadcast(Intent(MusicService.FAVORITE_STATE_CHANGED))
|
||||||
}
|
}
|
||||||
|
@ -139,7 +137,6 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpPrevNext() {
|
private fun setUpPrevNext() {
|
||||||
|
|
||||||
binding.nextButton.setOnClickListener { MusicPlayerRemote.playNextSong() }
|
binding.nextButton.setOnClickListener { MusicPlayerRemote.playNextSong() }
|
||||||
binding.previousButton.setOnClickListener { MusicPlayerRemote.back() }
|
binding.previousButton.setOnClickListener { MusicPlayerRemote.back() }
|
||||||
}
|
}
|
||||||
|
@ -246,7 +243,8 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
|
||||||
|
|
||||||
GlideApp.with(this)
|
GlideApp.with(this)
|
||||||
.load(RetroGlideExtension.getSongModel(song))
|
.load(RetroGlideExtension.getSongModel(song))
|
||||||
.songCoverOptions(song).transform(BlurTransformation.Builder(this).build())
|
.songCoverOptions(song)
|
||||||
|
.transform(BlurTransformation.Builder(this).build())
|
||||||
.into(binding.image)
|
.into(binding.image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,12 @@ package code.name.monkey.retromusic.activities
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import code.name.monkey.appthemehelper.ThemeStore.Companion.accentColor
|
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil.isWindowBackgroundDark
|
import code.name.monkey.appthemehelper.util.ATHUtil.isWindowBackgroundDark
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil.lightenColor
|
import code.name.monkey.appthemehelper.util.ColorUtil.lightenColor
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
import code.name.monkey.retromusic.activities.base.AbsThemeActivity
|
import code.name.monkey.retromusic.activities.base.AbsThemeActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityLicenseBinding
|
import code.name.monkey.retromusic.databinding.ActivityLicenseBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
|
@ -59,11 +59,11 @@ class LicenseActivity : AbsThemeActivity() {
|
||||||
"body { background-color: %s; color: %s; }", backgroundColor, contentColor
|
"body { background-color: %s; color: %s; }", backgroundColor, contentColor
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.replace("{link-color}", colorToCSS(accentColor(this)))
|
.replace("{link-color}", colorToCSS(accentColor()))
|
||||||
.replace(
|
.replace(
|
||||||
"{link-color-active}",
|
"{link-color-active}",
|
||||||
colorToCSS(
|
colorToCSS(
|
||||||
lightenColor(accentColor(this))
|
lightenColor(accentColor())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
binding.license.loadData(changeLog, "text/html", "UTF-8")
|
binding.license.loadData(changeLog, "text/html", "UTF-8")
|
||||||
|
|
|
@ -25,14 +25,10 @@ import androidx.annotation.RequiresApi
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.core.text.parseAsHtml
|
import androidx.core.text.parseAsHtml
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityPermissionBinding
|
import code.name.monkey.retromusic.databinding.ActivityPermissionBinding
|
||||||
import code.name.monkey.retromusic.extensions.accentBackgroundColor
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.setStatusBarColorAuto
|
|
||||||
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
|
||||||
import code.name.monkey.retromusic.extensions.show
|
|
||||||
import code.name.monkey.retromusic.util.RingtoneManager
|
import code.name.monkey.retromusic.util.RingtoneManager
|
||||||
|
|
||||||
class PermissionActivity : AbsMusicServiceActivity() {
|
class PermissionActivity : AbsMusicServiceActivity() {
|
||||||
|
@ -75,10 +71,11 @@ class PermissionActivity : AbsMusicServiceActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTitle() {
|
private fun setupTitle() {
|
||||||
val color = ThemeStore.accentColor(this)
|
val color = accentColor()
|
||||||
val hexColor = String.format("#%06X", 0xFFFFFF and color)
|
val hexColor = String.format("#%06X", 0xFFFFFF and color)
|
||||||
val appName = "Hello there! <br>Welcome to <b>Retro <span style='color:$hexColor';>Music</span></b>"
|
val appName =
|
||||||
.parseAsHtml()
|
"Hello there! <br>Welcome to <b>Retro <span style='color:$hexColor';>Music</span></b>"
|
||||||
|
.parseAsHtml()
|
||||||
binding.appNameText.text = appName
|
binding.appNameText.text = appName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,14 +84,13 @@ class PermissionActivity : AbsMusicServiceActivity() {
|
||||||
if (hasStoragePermission()) {
|
if (hasStoragePermission()) {
|
||||||
binding.storagePermission.checkImage.isVisible = true
|
binding.storagePermission.checkImage.isVisible = true
|
||||||
binding.storagePermission.checkImage.imageTintList =
|
binding.storagePermission.checkImage.imageTintList =
|
||||||
ColorStateList.valueOf(ThemeStore.accentColor(this))
|
ColorStateList.valueOf(accentColor())
|
||||||
}
|
}
|
||||||
if (hasAudioPermission()) {
|
if (hasAudioPermission()) {
|
||||||
binding.audioPermission.checkImage.isVisible = true
|
binding.audioPermission.checkImage.isVisible = true
|
||||||
binding.audioPermission.checkImage.imageTintList =
|
binding.audioPermission.checkImage.imageTintList =
|
||||||
ColorStateList.valueOf(ThemeStore.accentColor(this))
|
ColorStateList.valueOf(accentColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onResume()
|
super.onResume()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import code.name.monkey.retromusic.Constants.PRO_VERSION_PRODUCT_ID
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityProVersionBinding
|
import code.name.monkey.retromusic.databinding.ActivityProVersionBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
import code.name.monkey.retromusic.extensions.setLightStatusBar
|
import code.name.monkey.retromusic.extensions.setLightStatusBar
|
||||||
import code.name.monkey.retromusic.extensions.setStatusBarColor
|
import code.name.monkey.retromusic.extensions.setStatusBarColor
|
||||||
import com.anjlab.android.iab.v3.BillingProcessor
|
import com.anjlab.android.iab.v3.BillingProcessor
|
||||||
|
@ -61,7 +62,7 @@ class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
|
||||||
billingProcessor.purchase(this@PurchaseActivity, PRO_VERSION_PRODUCT_ID)
|
billingProcessor.purchase(this@PurchaseActivity, PRO_VERSION_PRODUCT_ID)
|
||||||
}
|
}
|
||||||
binding.bannerContainer.backgroundTintList =
|
binding.bannerContainer.backgroundTintList =
|
||||||
ColorStateList.valueOf(ThemeStore.accentColor(this))
|
ColorStateList.valueOf(accentColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun restorePurchase() {
|
private fun restorePurchase() {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityShareInstagramBinding
|
import code.name.monkey.retromusic.databinding.ActivityShareInstagramBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
import code.name.monkey.retromusic.extensions.setLightStatusBar
|
import code.name.monkey.retromusic.extensions.setLightStatusBar
|
||||||
import code.name.monkey.retromusic.extensions.setStatusBarColor
|
import code.name.monkey.retromusic.extensions.setStatusBarColor
|
||||||
import code.name.monkey.retromusic.glide.GlideApp
|
import code.name.monkey.retromusic.glide.GlideApp
|
||||||
|
@ -96,11 +97,11 @@ class ShareInstagramStory : AbsBaseActivity() {
|
||||||
binding.shareButton.setTextColor(
|
binding.shareButton.setTextColor(
|
||||||
MaterialValueHelper.getPrimaryTextColor(
|
MaterialValueHelper.getPrimaryTextColor(
|
||||||
this,
|
this,
|
||||||
ColorUtil.isColorLight(ThemeStore.accentColor(this))
|
ColorUtil.isColorLight(accentColor())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
binding.shareButton.backgroundTintList =
|
binding.shareButton.backgroundTintList =
|
||||||
ColorStateList.valueOf(ThemeStore.accentColor(this))
|
ColorStateList.valueOf(accentColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setColors(colorLight: Boolean, color: Int) {
|
private fun setColors(colorLight: Boolean, color: Int) {
|
||||||
|
|
|
@ -75,8 +75,8 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
|
||||||
setupToolbar()
|
setupToolbar()
|
||||||
|
|
||||||
billingProcessor = BillingProcessor(this, BuildConfig.GOOGLE_PLAY_LICENSING_KEY, this)
|
billingProcessor = BillingProcessor(this, BuildConfig.GOOGLE_PLAY_LICENSING_KEY, this)
|
||||||
TintHelper.setTint(binding.progress, ThemeStore.accentColor(this))
|
TintHelper.setTint(binding.progress, accentColor())
|
||||||
binding.donation.setTextColor(ThemeStore.accentColor(this))
|
binding.donation.setTextColor(accentColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupToolbar() {
|
private fun setupToolbar() {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.pm.PackageManager
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import code.name.monkey.appthemehelper.ThemeStore.Companion.accentColor
|
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil.isWindowBackgroundDark
|
import code.name.monkey.appthemehelper.util.ATHUtil.isWindowBackgroundDark
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil.isColorLight
|
import code.name.monkey.appthemehelper.util.ColorUtil.isColorLight
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil.lightenColor
|
import code.name.monkey.appthemehelper.util.ColorUtil.lightenColor
|
||||||
|
@ -14,12 +13,8 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
import code.name.monkey.retromusic.Constants
|
import code.name.monkey.retromusic.Constants
|
||||||
import code.name.monkey.retromusic.activities.base.AbsThemeActivity
|
import code.name.monkey.retromusic.activities.base.AbsThemeActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityWhatsNewBinding
|
import code.name.monkey.retromusic.databinding.ActivityWhatsNewBinding
|
||||||
import code.name.monkey.retromusic.extensions.accentColor
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
|
||||||
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
|
||||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil.lastVersion
|
import code.name.monkey.retromusic.util.PreferenceUtil.lastVersion
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
@ -45,13 +40,13 @@ class WhatsNewActivity : AbsThemeActivity() {
|
||||||
|
|
||||||
// Inject color values for WebView body background and links
|
// Inject color values for WebView body background and links
|
||||||
val isDark = isWindowBackgroundDark(this)
|
val isDark = isWindowBackgroundDark(this)
|
||||||
val accentColor = accentColor(this)
|
val accentColor = accentColor()
|
||||||
val backgroundColor = colorToCSS(
|
val backgroundColor = colorToCSS(
|
||||||
surfaceColor(Color.parseColor(if (isDark) "#424242" else "#ffffff"))
|
surfaceColor(Color.parseColor(if (isDark) "#424242" else "#ffffff"))
|
||||||
)
|
)
|
||||||
val contentColor = colorToCSS(Color.parseColor(if (isDark) "#ffffff" else "#000000"))
|
val contentColor = colorToCSS(Color.parseColor(if (isDark) "#ffffff" else "#000000"))
|
||||||
val textColor = colorToCSS(Color.parseColor(if (isDark) "#60FFFFFF" else "#80000000"))
|
val textColor = colorToCSS(Color.parseColor(if (isDark) "#60FFFFFF" else "#80000000"))
|
||||||
val accentColorString = colorToCSS(accentColor(this))
|
val accentColorString = colorToCSS(accentColor())
|
||||||
val cardBackgroundColor =
|
val cardBackgroundColor =
|
||||||
colorToCSS(Color.parseColor(if (isDark) "#353535" else "#ffffff"))
|
colorToCSS(Color.parseColor(if (isDark) "#353535" else "#ffffff"))
|
||||||
val accentTextColor = colorToCSS(
|
val accentTextColor = colorToCSS(
|
||||||
|
@ -64,11 +59,11 @@ class WhatsNewActivity : AbsThemeActivity() {
|
||||||
"{style-placeholder}",
|
"{style-placeholder}",
|
||||||
"body { background-color: $backgroundColor; color: $contentColor; } li {color: $textColor;} h3 {color: $accentColorString;} .tag {background-color: $accentColorString; color: $accentTextColor; } div{background-color: $cardBackgroundColor;}"
|
"body { background-color: $backgroundColor; color: $contentColor; } li {color: $textColor;} h3 {color: $accentColorString;} .tag {background-color: $accentColorString; color: $accentTextColor; } div{background-color: $cardBackgroundColor;}"
|
||||||
)
|
)
|
||||||
.replace("{link-color}", colorToCSS(accentColor(this)))
|
.replace("{link-color}", colorToCSS(accentColor()))
|
||||||
.replace(
|
.replace(
|
||||||
"{link-color-active}",
|
"{link-color-active}",
|
||||||
colorToCSS(
|
colorToCSS(
|
||||||
lightenColor(accentColor(this))
|
lightenColor(accentColor())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
binding.webView.loadData(changeLog, "text/html", "UTF-8")
|
binding.webView.loadData(changeLog, "text/html", "UTF-8")
|
||||||
|
@ -79,10 +74,7 @@ class WhatsNewActivity : AbsThemeActivity() {
|
||||||
}
|
}
|
||||||
setChangelogRead(this)
|
setChangelogRead(this)
|
||||||
binding.tgFab.setOnClickListener {
|
binding.tgFab.setOnClickListener {
|
||||||
RetroUtil.openUrl(
|
openUrl(Constants.TELEGRAM_CHANGE_LOG)
|
||||||
this,
|
|
||||||
Constants.TELEGRAM_CHANGE_LOG
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
binding.tgFab.accentColor()
|
binding.tgFab.accentColor()
|
||||||
binding.tgFab.shrink()
|
binding.tgFab.shrink()
|
||||||
|
|
|
@ -29,9 +29,9 @@ import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
|
||||||
abstract class AbsBaseActivity : AbsThemeActivity() {
|
abstract class AbsBaseActivity : AbsThemeActivity() {
|
||||||
|
@ -126,24 +126,25 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
|
||||||
Snackbar.LENGTH_INDEFINITE
|
Snackbar.LENGTH_INDEFINITE
|
||||||
)
|
)
|
||||||
.setAction(R.string.action_grant) { requestPermissions() }
|
.setAction(R.string.action_grant) { requestPermissions() }
|
||||||
.setActionTextColor(ThemeStore.accentColor(this)).show()
|
.setActionTextColor(accentColor()).show()
|
||||||
} else {
|
} else {
|
||||||
// User has deny permission and checked never show permission dialog so you can redirect to Application settings page
|
// User has deny permission and checked never show permission dialog so you can redirect to Application settings page
|
||||||
Snackbar.make(
|
Snackbar.make(
|
||||||
snackBarContainer,
|
snackBarContainer,
|
||||||
permissionDeniedMessage!!,
|
permissionDeniedMessage!!,
|
||||||
Snackbar.LENGTH_INDEFINITE
|
Snackbar.LENGTH_INDEFINITE
|
||||||
).setAction(R.string.action_settings) {
|
)
|
||||||
val intent = Intent()
|
.setAction(R.string.action_settings) {
|
||||||
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
val intent = Intent()
|
||||||
val uri = Uri.fromParts(
|
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
||||||
"package",
|
val uri = Uri.fromParts(
|
||||||
this@AbsBaseActivity.packageName,
|
"package",
|
||||||
null
|
this@AbsBaseActivity.packageName,
|
||||||
)
|
null
|
||||||
intent.data = uri
|
)
|
||||||
startActivity(intent)
|
intent.data = uri
|
||||||
}.setActionTextColor(ThemeStore.accentColor(this)).show()
|
startActivity(intent)
|
||||||
|
}.setActionTextColor(accentColor()).show()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -156,6 +157,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
|
||||||
companion object {
|
companion object {
|
||||||
const val PERMISSION_REQUEST = 100
|
const val PERMISSION_REQUEST = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
// this lets keyboard close when clicked in backgroud
|
// this lets keyboard close when clicked in backgroud
|
||||||
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||||
if (event.action == MotionEvent.ACTION_DOWN) {
|
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||||
|
@ -165,7 +167,10 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
|
||||||
v.getGlobalVisibleRect(outRect)
|
v.getGlobalVisibleRect(outRect)
|
||||||
if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) {
|
if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) {
|
||||||
v.clearFocus()
|
v.clearFocus()
|
||||||
getSystemService<InputMethodManager>()?.hideSoftInputFromWindow(v.windowToken, 0)
|
getSystemService<InputMethodManager>()?.hideSoftInputFromWindow(
|
||||||
|
v.windowToken,
|
||||||
|
0
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import android.os.Bundle
|
||||||
import android.view.ViewStub
|
import android.view.ViewStub
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.cast.CastHelper
|
import code.name.monkey.retromusic.cast.CastHelper
|
||||||
import code.name.monkey.retromusic.cast.RetroSessionManager
|
import code.name.monkey.retromusic.cast.RetroSessionManagerListener
|
||||||
import code.name.monkey.retromusic.cast.RetroWebServer
|
import code.name.monkey.retromusic.cast.RetroWebServer
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import com.google.android.gms.cast.framework.CastContext
|
import com.google.android.gms.cast.framework.CastContext
|
||||||
|
@ -22,7 +22,7 @@ abstract class AbsCastActivity : AbsSlidingMusicPanelActivity() {
|
||||||
private var playServicesAvailable: Boolean = false
|
private var playServicesAvailable: Boolean = false
|
||||||
|
|
||||||
private val sessionManagerListener by lazy {
|
private val sessionManagerListener by lazy {
|
||||||
object : RetroSessionManager {
|
object : RetroSessionManagerListener {
|
||||||
override fun onSessionStarting(castSession: CastSession) {
|
override fun onSessionStarting(castSession: CastSession) {
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
webServer = RetroWebServer.getInstance(this@AbsCastActivity)
|
webServer = RetroWebServer.getInstance(this@AbsCastActivity)
|
||||||
|
@ -88,7 +88,7 @@ abstract class AbsCastActivity : AbsSlidingMusicPanelActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCast() {
|
private fun setupCast() {
|
||||||
sessionManager = CastContext.getSharedInstance(applicationContext).sessionManager
|
sessionManager = CastContext.getSharedInstance(this).sessionManager
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -104,9 +104,15 @@ abstract class AbsCastActivity : AbsSlidingMusicPanelActivity() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onPause() {
|
||||||
super.onStop()
|
super.onPause()
|
||||||
mCastSession = null
|
if (playServicesAvailable) {
|
||||||
|
sessionManager.removeSessionManagerListener(
|
||||||
|
sessionManagerListener,
|
||||||
|
CastSession::class.java
|
||||||
|
)
|
||||||
|
mCastSession = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun songChanged(position: Int) {
|
private fun songChanged(position: Int) {
|
||||||
|
|
|
@ -26,7 +26,6 @@ import androidx.annotation.StringRes
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
@ -38,6 +37,7 @@ import code.name.monkey.retromusic.activities.bugreport.model.github.ExtraInfo
|
||||||
import code.name.monkey.retromusic.activities.bugreport.model.github.GithubLogin
|
import code.name.monkey.retromusic.activities.bugreport.model.github.GithubLogin
|
||||||
import code.name.monkey.retromusic.activities.bugreport.model.github.GithubTarget
|
import code.name.monkey.retromusic.activities.bugreport.model.github.GithubTarget
|
||||||
import code.name.monkey.retromusic.databinding.ActivityBugReportBinding
|
import code.name.monkey.retromusic.databinding.ActivityBugReportBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
@ -87,7 +87,7 @@ open class BugReportActivity : AbsThemeActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
val accentColor = ThemeStore.accentColor(this)
|
val accentColor = accentColor()
|
||||||
setSupportActionBar(binding.toolbar)
|
setSupportActionBar(binding.toolbar)
|
||||||
ToolbarContentTintHelper.colorBackButton(binding.toolbar)
|
ToolbarContentTintHelper.colorBackButton(binding.toolbar)
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
@ -314,6 +314,7 @@ open class BugReportActivity : AbsThemeActivity() {
|
||||||
|
|
||||||
private const val STATUS_BAD_CREDENTIALS = 401
|
private const val STATUS_BAD_CREDENTIALS = 401
|
||||||
private const val STATUS_ISSUES_NOT_ENABLED = 410
|
private const val STATUS_ISSUES_NOT_ENABLED = 410
|
||||||
private const val ISSUE_TRACKER_LINK = "https://github.com/RetroMusicPlayer/RetroMusicPlayer"
|
private const val ISSUE_TRACKER_LINK =
|
||||||
|
"https://github.com/RetroMusicPlayer/RetroMusicPlayer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import code.name.monkey.retromusic.R.drawable
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||||
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
||||||
import code.name.monkey.retromusic.extensions.accentColor
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
|
import code.name.monkey.retromusic.extensions.hideSoftKeyboard
|
||||||
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
||||||
import code.name.monkey.retromusic.model.ArtworkInfo
|
import code.name.monkey.retromusic.model.ArtworkInfo
|
||||||
import code.name.monkey.retromusic.model.AudioTagInfo
|
import code.name.monkey.retromusic.model.AudioTagInfo
|
||||||
|
@ -346,7 +347,7 @@ abstract class AbsTagEditorActivity<VB : ViewBinding> : AbsBaseActivity() {
|
||||||
fieldKeyValueMap: Map<FieldKey, String>,
|
fieldKeyValueMap: Map<FieldKey, String>,
|
||||||
artworkInfo: ArtworkInfo?
|
artworkInfo: ArtworkInfo?
|
||||||
) {
|
) {
|
||||||
RetroUtil.hideSoftKeyboard(this)
|
hideSoftKeyboard()
|
||||||
|
|
||||||
hideFab()
|
hideFab()
|
||||||
println(fieldKeyValueMap)
|
println(fieldKeyValueMap)
|
||||||
|
|
|
@ -14,15 +14,14 @@
|
||||||
*/
|
*/
|
||||||
package code.name.monkey.retromusic.adapter
|
package code.name.monkey.retromusic.adapter
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.extensions.openUrl
|
||||||
import code.name.monkey.retromusic.model.Contributor
|
import code.name.monkey.retromusic.model.Contributor
|
||||||
import code.name.monkey.retromusic.util.RetroUtil.openUrl
|
|
||||||
import code.name.monkey.retromusic.views.RetroShapeableImageView
|
import code.name.monkey.retromusic.views.RetroShapeableImageView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
|
||||||
|
@ -65,7 +64,7 @@ class ContributorAdapter(
|
||||||
val contributor = contributors[position]
|
val contributor = contributors[position]
|
||||||
holder.bindData(contributor)
|
holder.bindData(contributor)
|
||||||
holder.itemView.setOnClickListener {
|
holder.itemView.setOnClickListener {
|
||||||
openUrl(it?.context as Activity, contributors[position].link)
|
it?.context?.openUrl(contributors[position].link)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,9 +91,9 @@ open class AlbumAdapter(
|
||||||
// Check if imageContainer exists so we can have a smooth transition without
|
// Check if imageContainer exists so we can have a smooth transition without
|
||||||
// CardView clipping, if it doesn't exist in current layout set transition name to image instead.
|
// CardView clipping, if it doesn't exist in current layout set transition name to image instead.
|
||||||
if (holder.imageContainer != null) {
|
if (holder.imageContainer != null) {
|
||||||
holder.imageContainer!!.setTransitionName(album.id.toString())
|
holder.imageContainer?.transitionName = album.id.toString()
|
||||||
} else {
|
} else {
|
||||||
holder.image!!.setTransitionName(album.id.toString())
|
holder.image?.transitionName = album.id.toString()
|
||||||
}
|
}
|
||||||
loadAlbumCover(album, holder)
|
loadAlbumCover(album, holder)
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,6 @@ class AlbumCoverPagerAdapter(
|
||||||
|
|
||||||
class AlbumCoverFragment : Fragment() {
|
class AlbumCoverFragment : Fragment() {
|
||||||
|
|
||||||
private lateinit var albumCover: ImageView
|
|
||||||
private var isColorReady: Boolean = false
|
private var isColorReady: Boolean = false
|
||||||
private lateinit var color: MediaNotificationProcessor
|
private lateinit var color: MediaNotificationProcessor
|
||||||
private lateinit var song: Song
|
private lateinit var song: Song
|
||||||
|
@ -106,8 +105,6 @@ class AlbumCoverPagerAdapter(
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
val view = inflater.inflate(getLayoutWithPlayerTheme(), container, false)
|
val view = inflater.inflate(getLayoutWithPlayerTheme(), container, false)
|
||||||
view.setTransitionName("lyrics")
|
|
||||||
albumCover = view.findViewById(R.id.player_image)
|
|
||||||
view.setOnClickListener {
|
view.setOnClickListener {
|
||||||
if (mainActivity.getBottomSheetBehavior().state == STATE_EXPANDED) {
|
if (mainActivity.getBottomSheetBehavior().state == STATE_EXPANDED) {
|
||||||
showLyricsDialog()
|
showLyricsDialog()
|
||||||
|
@ -158,7 +155,7 @@ class AlbumCoverPagerAdapter(
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
loadAlbumCover()
|
loadAlbumCover(albumCover = view.findViewById(R.id.player_image))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
@ -166,7 +163,7 @@ class AlbumCoverPagerAdapter(
|
||||||
colorReceiver = null
|
colorReceiver = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadAlbumCover() {
|
private fun loadAlbumCover(albumCover: ImageView) {
|
||||||
GlideApp.with(this).asBitmapPalette().songCoverOptions(song)
|
GlideApp.with(this).asBitmapPalette().songCoverOptions(song)
|
||||||
//.checkIgnoreMediaStore()
|
//.checkIgnoreMediaStore()
|
||||||
.load(RetroGlideExtension.getSongModel(song))
|
.load(RetroGlideExtension.getSongModel(song))
|
||||||
|
|
|
@ -92,9 +92,9 @@ class ArtistAdapter(
|
||||||
val transitionName =
|
val transitionName =
|
||||||
if (albumArtistsOnly) artist.name else artist.id.toString()
|
if (albumArtistsOnly) artist.name else artist.id.toString()
|
||||||
if (holder.imageContainer != null) {
|
if (holder.imageContainer != null) {
|
||||||
holder.imageContainer!!.setTransitionName(transitionName)
|
holder.imageContainer?.transitionName = transitionName
|
||||||
} else {
|
} else {
|
||||||
holder.image!!.setTransitionName(transitionName)
|
holder.image?.transitionName = transitionName
|
||||||
}
|
}
|
||||||
loadArtistImage(artist, holder)
|
loadArtistImage(artist, holder)
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@ class PlaylistAdapter(
|
||||||
if (isInQuickSelectMode) {
|
if (isInQuickSelectMode) {
|
||||||
toggleChecked(layoutPosition)
|
toggleChecked(layoutPosition)
|
||||||
} else {
|
} else {
|
||||||
itemView.setTransitionName("playlist")
|
itemView.transitionName = "playlist"
|
||||||
listener.onPlaylistClick(dataSet[layoutPosition], itemView)
|
listener.onPlaylistClick(dataSet[layoutPosition], itemView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
package code.name.monkey.retromusic.cast
|
package code.name.monkey.retromusic.cast
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
|
|
@ -3,7 +3,7 @@ package code.name.monkey.retromusic.cast
|
||||||
import com.google.android.gms.cast.framework.CastSession
|
import com.google.android.gms.cast.framework.CastSession
|
||||||
import com.google.android.gms.cast.framework.SessionManagerListener
|
import com.google.android.gms.cast.framework.SessionManagerListener
|
||||||
|
|
||||||
interface RetroSessionManager : SessionManagerListener<CastSession> {
|
interface RetroSessionManagerListener : SessionManagerListener<CastSession> {
|
||||||
override fun onSessionResuming(p0: CastSession, p1: String) {
|
override fun onSessionResuming(p0: CastSession, p1: String) {
|
||||||
|
|
||||||
}
|
}
|
|
@ -26,15 +26,9 @@ class RetroWebServer(val context: Context) : NanoHTTPD(SERVER_PORT) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serve(
|
override fun serve(session: IHTTPSession?): Response {
|
||||||
uri: String?,
|
if (session?.uri?.contains(PART_COVER_ART) == true) {
|
||||||
method: Method?,
|
val albumId = session.parameters?.get(PARAM_ID)?.get(0) ?: return errorResponse()
|
||||||
headers: MutableMap<String, String>?,
|
|
||||||
parms: MutableMap<String, String>?,
|
|
||||||
files: MutableMap<String, String>?
|
|
||||||
): Response {
|
|
||||||
if (uri?.contains(PART_COVER_ART) == true) {
|
|
||||||
val albumId = parms?.get(PARAM_ID) ?: return errorResponse()
|
|
||||||
val albumArtUri = MusicUtil.getMediaStoreAlbumCoverUri(albumId.toLong())
|
val albumArtUri = MusicUtil.getMediaStoreAlbumCoverUri(albumId.toLong())
|
||||||
val fis: InputStream?
|
val fis: InputStream?
|
||||||
try {
|
try {
|
||||||
|
@ -43,12 +37,12 @@ class RetroWebServer(val context: Context) : NanoHTTPD(SERVER_PORT) {
|
||||||
return errorResponse()
|
return errorResponse()
|
||||||
}
|
}
|
||||||
return newChunkedResponse(Status.OK, MIME_TYPE_IMAGE, fis)
|
return newChunkedResponse(Status.OK, MIME_TYPE_IMAGE, fis)
|
||||||
} else if (uri?.contains(PART_SONG) == true) {
|
} else if (session?.uri?.contains(PART_SONG) == true) {
|
||||||
val songId = parms?.get(PARAM_ID) ?: return errorResponse()
|
val songId = session.parameters?.get(PARAM_ID)?.get(0) ?: return errorResponse()
|
||||||
val songUri = MusicUtil.getSongFileUri(songId.toLong())
|
val songUri = MusicUtil.getSongFileUri(songId.toLong())
|
||||||
val songPath = MusicUtil.getSongFilePath(context, songUri)
|
val songPath = MusicUtil.getSongFilePath(context, songUri)
|
||||||
val song = File(songPath)
|
val song = File(songPath)
|
||||||
return serveFile(headers!!, song, MIME_TYPE_AUDIO)
|
return serveFile(session.headers!!, song, MIME_TYPE_AUDIO)
|
||||||
}
|
}
|
||||||
return newFixedLengthResponse(Status.NOT_FOUND, MIME_PLAINTEXT, "Not Found")
|
return newFixedLengthResponse(Status.NOT_FOUND, MIME_PLAINTEXT, "Not Found")
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ package code.name.monkey.retromusic.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.retromusic.EXTRA_PLAYLIST_ID
|
import code.name.monkey.retromusic.EXTRA_PLAYLIST_ID
|
||||||
|
@ -48,7 +47,7 @@ class RenamePlaylistDialog : DialogFragment() {
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val playlistEntity = extraNotNull<PlaylistEntity>(EXTRA_PLAYLIST_ID).value
|
val playlistEntity = extraNotNull<PlaylistEntity>(EXTRA_PLAYLIST_ID).value
|
||||||
val layout = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_playlist, null)
|
val layout = layoutInflater.inflate(R.layout.dialog_playlist, null)
|
||||||
val inputEditText: TextInputEditText = layout.findViewById(R.id.actionNewPlaylist)
|
val inputEditText: TextInputEditText = layout.findViewById(R.id.actionNewPlaylist)
|
||||||
val nameContainer: TextInputLayout = layout.findViewById(R.id.actionNewPlaylistContainer)
|
val nameContainer: TextInputLayout = layout.findViewById(R.id.actionNewPlaylistContainer)
|
||||||
nameContainer.accentColor()
|
nameContainer.accentColor()
|
||||||
|
|
|
@ -19,60 +19,51 @@ import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.annotation.NonNull
|
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.text.parseAsHtml
|
import androidx.core.text.parseAsHtml
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.retromusic.EXTRA_SONG
|
import code.name.monkey.retromusic.EXTRA_SONG
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.databinding.DialogFileDetailsBinding
|
||||||
import code.name.monkey.retromusic.extensions.colorButtons
|
import code.name.monkey.retromusic.extensions.colorButtons
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
import code.name.monkey.retromusic.extensions.materialDialog
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import org.jaudiotagger.audio.AudioFileIO
|
import org.jaudiotagger.audio.AudioFileIO
|
||||||
import org.jaudiotagger.audio.exceptions.CannotReadException
|
import org.jaudiotagger.audio.exceptions.CannotReadException
|
||||||
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
|
|
||||||
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException
|
|
||||||
import org.jaudiotagger.tag.TagException
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
class SongDetailDialog : DialogFragment() {
|
class SongDetailDialog : DialogFragment() {
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val context: Context = requireContext()
|
val context: Context = requireContext()
|
||||||
val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_file_details, null)
|
val binding = DialogFileDetailsBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
val song = requireArguments().getParcelable<Song>(EXTRA_SONG)
|
val song = requireArguments().getParcelable<Song>(EXTRA_SONG)
|
||||||
val fileName: TextView = dialogView.findViewById(R.id.fileName)
|
with(binding) {
|
||||||
val filePath: TextView = dialogView.findViewById(R.id.filePath)
|
fileName.text = makeTextWithTitle(context, R.string.label_file_name, "-")
|
||||||
val fileSize: TextView = dialogView.findViewById(R.id.fileSize)
|
filePath.text = makeTextWithTitle(context, R.string.label_file_path, "-")
|
||||||
val dateModified: TextView = dialogView.findViewById(R.id.dateModified)
|
fileSize.text = makeTextWithTitle(context, R.string.label_file_size, "-")
|
||||||
val fileFormat: TextView = dialogView.findViewById(R.id.fileFormat)
|
fileFormat.text = makeTextWithTitle(context, R.string.label_file_format, "-")
|
||||||
val trackLength: TextView = dialogView.findViewById(R.id.trackLength)
|
trackLength.text = makeTextWithTitle(context, R.string.label_track_length, "-")
|
||||||
val bitRate: TextView = dialogView.findViewById(R.id.bitrate)
|
bitrate.text = makeTextWithTitle(context, R.string.label_bit_rate, "-")
|
||||||
val samplingRate: TextView = dialogView.findViewById(R.id.samplingRate)
|
samplingRate.text = makeTextWithTitle(context, R.string.label_sampling_rate, "-")
|
||||||
|
}
|
||||||
|
|
||||||
fileName.text = makeTextWithTitle(context, R.string.label_file_name, "-")
|
|
||||||
filePath.text = makeTextWithTitle(context, R.string.label_file_path, "-")
|
|
||||||
fileSize.text = makeTextWithTitle(context, R.string.label_file_size, "-")
|
|
||||||
fileFormat.text = makeTextWithTitle(context, R.string.label_file_format, "-")
|
|
||||||
trackLength.text = makeTextWithTitle(context, R.string.label_track_length, "-")
|
|
||||||
bitRate.text = makeTextWithTitle(context, R.string.label_bit_rate, "-")
|
|
||||||
samplingRate.text = makeTextWithTitle(context, R.string.label_sampling_rate, "-")
|
|
||||||
if (song != null) {
|
if (song != null) {
|
||||||
val songFile = File(song.data)
|
val songFile = File(song.data)
|
||||||
if (songFile.exists()) {
|
if (songFile.exists()) {
|
||||||
fileName.text = makeTextWithTitle(context, R.string.label_file_name, songFile.name)
|
binding.fileName.text =
|
||||||
filePath.text =
|
makeTextWithTitle(context, R.string.label_file_name, songFile.name)
|
||||||
|
binding.filePath.text =
|
||||||
makeTextWithTitle(context, R.string.label_file_path, songFile.absolutePath)
|
makeTextWithTitle(context, R.string.label_file_path, songFile.absolutePath)
|
||||||
|
|
||||||
dateModified.text = makeTextWithTitle(context, R.string.label_last_modified,
|
binding.dateModified.text = makeTextWithTitle(
|
||||||
MusicUtil.getDateModifiedString(songFile.lastModified()))
|
context, R.string.label_last_modified,
|
||||||
|
MusicUtil.getDateModifiedString(songFile.lastModified())
|
||||||
|
)
|
||||||
|
|
||||||
fileSize.text =
|
binding.fileSize.text =
|
||||||
makeTextWithTitle(
|
makeTextWithTitle(
|
||||||
context,
|
context,
|
||||||
R.string.label_file_size,
|
R.string.label_file_size,
|
||||||
|
@ -82,56 +73,28 @@ class SongDetailDialog : DialogFragment() {
|
||||||
val audioFile = AudioFileIO.read(songFile)
|
val audioFile = AudioFileIO.read(songFile)
|
||||||
val audioHeader = audioFile.audioHeader
|
val audioHeader = audioFile.audioHeader
|
||||||
|
|
||||||
fileFormat.text =
|
binding.fileFormat.text =
|
||||||
makeTextWithTitle(context, R.string.label_file_format, audioHeader.format)
|
makeTextWithTitle(context, R.string.label_file_format, audioHeader.format)
|
||||||
trackLength.text = makeTextWithTitle(
|
binding.trackLength.text = makeTextWithTitle(
|
||||||
context,
|
context,
|
||||||
R.string.label_track_length,
|
R.string.label_track_length,
|
||||||
MusicUtil.getReadableDurationString((audioHeader.trackLength * 1000).toLong())
|
MusicUtil.getReadableDurationString((audioHeader.trackLength * 1000).toLong())
|
||||||
)
|
)
|
||||||
bitRate.text = makeTextWithTitle(
|
binding.bitrate.text = makeTextWithTitle(
|
||||||
context,
|
context,
|
||||||
R.string.label_bit_rate,
|
R.string.label_bit_rate,
|
||||||
audioHeader.bitRate + " kb/s"
|
audioHeader.bitRate + " kb/s"
|
||||||
)
|
)
|
||||||
samplingRate.text =
|
binding.samplingRate.text =
|
||||||
makeTextWithTitle(
|
makeTextWithTitle(
|
||||||
context,
|
context,
|
||||||
R.string.label_sampling_rate,
|
R.string.label_sampling_rate,
|
||||||
audioHeader.sampleRate + " Hz"
|
audioHeader.sampleRate + " Hz"
|
||||||
)
|
)
|
||||||
} catch (@NonNull e: CannotReadException) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "error while reading the song file", e)
|
Log.e(TAG, "error while reading the song file", e)
|
||||||
// fallback
|
// fallback
|
||||||
trackLength.text = makeTextWithTitle(
|
binding.trackLength.text = makeTextWithTitle(
|
||||||
context,
|
|
||||||
R.string.label_track_length,
|
|
||||||
MusicUtil.getReadableDurationString(song.duration)
|
|
||||||
)
|
|
||||||
} catch (@NonNull e: IOException) {
|
|
||||||
Log.e(TAG, "error while reading the song file", e)
|
|
||||||
trackLength.text = makeTextWithTitle(
|
|
||||||
context,
|
|
||||||
R.string.label_track_length,
|
|
||||||
MusicUtil.getReadableDurationString(song.duration)
|
|
||||||
)
|
|
||||||
} catch (@NonNull e: TagException) {
|
|
||||||
Log.e(TAG, "error while reading the song file", e)
|
|
||||||
trackLength.text = makeTextWithTitle(
|
|
||||||
context,
|
|
||||||
R.string.label_track_length,
|
|
||||||
MusicUtil.getReadableDurationString(song.duration)
|
|
||||||
)
|
|
||||||
} catch (@NonNull e: ReadOnlyFileException) {
|
|
||||||
Log.e(TAG, "error while reading the song file", e)
|
|
||||||
trackLength.text = makeTextWithTitle(
|
|
||||||
context,
|
|
||||||
R.string.label_track_length,
|
|
||||||
MusicUtil.getReadableDurationString(song.duration)
|
|
||||||
)
|
|
||||||
} catch (@NonNull e: InvalidAudioFrameException) {
|
|
||||||
Log.e(TAG, "error while reading the song file", e)
|
|
||||||
trackLength.text = makeTextWithTitle(
|
|
||||||
context,
|
context,
|
||||||
R.string.label_track_length,
|
R.string.label_track_length,
|
||||||
MusicUtil.getReadableDurationString(song.duration)
|
MusicUtil.getReadableDurationString(song.duration)
|
||||||
|
@ -139,8 +102,9 @@ class SongDetailDialog : DialogFragment() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// fallback
|
// fallback
|
||||||
fileName.text = makeTextWithTitle(context, R.string.label_file_name, song.title)
|
binding.fileName.text =
|
||||||
trackLength.text = makeTextWithTitle(
|
makeTextWithTitle(context, R.string.label_file_name, song.title)
|
||||||
|
binding.trackLength.text = makeTextWithTitle(
|
||||||
context,
|
context,
|
||||||
R.string.label_track_length,
|
R.string.label_track_length,
|
||||||
MusicUtil.getReadableDurationString(song.duration)
|
MusicUtil.getReadableDurationString(song.duration)
|
||||||
|
@ -149,7 +113,7 @@ class SongDetailDialog : DialogFragment() {
|
||||||
}
|
}
|
||||||
return materialDialog(R.string.action_details)
|
return materialDialog(R.string.action_details)
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
.setView(dialogView)
|
.setView(binding.root)
|
||||||
.create()
|
.create()
|
||||||
.colorButtons()
|
.colorButtons()
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@ import android.os.Build
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
import androidx.core.view.*
|
import androidx.core.view.*
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
|
@ -222,3 +224,12 @@ fun AppCompatActivity.setStatusBarColorPreMarshmallow(color: Int) {
|
||||||
window.statusBarColor = ColorUtil.darkenColor(color)
|
window.statusBarColor = ColorUtil.darkenColor(color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun AppCompatActivity.hideSoftKeyboard() {
|
||||||
|
val currentFocus: View? = currentFocus
|
||||||
|
if (currentFocus != null) {
|
||||||
|
val inputMethodManager =
|
||||||
|
getSystemService<InputMethodManager>()
|
||||||
|
inputMethodManager?.hideSoftInputFromWindow(currentFocus.windowToken, 0)
|
||||||
|
}
|
||||||
|
}
|
|
@ -131,12 +131,12 @@ fun Slider.accent() {
|
||||||
|
|
||||||
fun Button.accentTextColor() {
|
fun Button.accentTextColor() {
|
||||||
if (materialYou) return
|
if (materialYou) return
|
||||||
setTextColor(ThemeStore.accentColor(App.getContext()))
|
setTextColor(context.accentColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun MaterialButton.accentBackgroundColor() {
|
fun MaterialButton.accentBackgroundColor() {
|
||||||
if (materialYou) return
|
if (materialYou) return
|
||||||
backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(App.getContext()))
|
backgroundTintList = ColorStateList.valueOf(context.accentColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun MaterialButton.accentOutlineColor() {
|
fun MaterialButton.accentOutlineColor() {
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package code.name.monkey.retromusic.extensions
|
package code.name.monkey.retromusic.extensions
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.activity.result.ActivityResult
|
import androidx.activity.result.ActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.core.net.toUri
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
|
|
||||||
|
@ -30,3 +32,15 @@ fun Fragment.createNewFile(
|
||||||
}
|
}
|
||||||
startForResult.launch(intent)
|
startForResult.launch(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.openUrl(url: String) {
|
||||||
|
val i = Intent(Intent.ACTION_VIEW)
|
||||||
|
i.data = url.toUri()
|
||||||
|
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
startActivity(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun Fragment.openUrl(url: String) {
|
||||||
|
requireContext().openUrl(url)
|
||||||
|
}
|
|
@ -14,12 +14,10 @@
|
||||||
*/
|
*/
|
||||||
package code.name.monkey.retromusic.fragments.about
|
package code.name.monkey.retromusic.fragments.about
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.app.ShareCompat
|
import androidx.core.app.ShareCompat
|
||||||
import androidx.core.net.toUri
|
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||||
|
@ -29,6 +27,7 @@ import code.name.monkey.retromusic.Constants
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.ContributorAdapter
|
import code.name.monkey.retromusic.adapter.ContributorAdapter
|
||||||
import code.name.monkey.retromusic.databinding.FragmentAboutBinding
|
import code.name.monkey.retromusic.databinding.FragmentAboutBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.openUrl
|
||||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
|
@ -53,13 +52,6 @@ class AboutFragment : Fragment(R.layout.fragment_about), View.OnClickListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openUrl(url: String) {
|
|
||||||
val i = Intent(Intent.ACTION_VIEW)
|
|
||||||
i.data = url.toUri()
|
|
||||||
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
||||||
startActivity(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setUpView() {
|
private fun setUpView() {
|
||||||
binding.aboutContent.cardRetroInfo.appGithub.setOnClickListener(this)
|
binding.aboutContent.cardRetroInfo.appGithub.setOnClickListener(this)
|
||||||
binding.aboutContent.cardRetroInfo.faqLink.setOnClickListener(this)
|
binding.aboutContent.cardRetroInfo.faqLink.setOnClickListener(this)
|
||||||
|
|
|
@ -117,7 +117,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
mainActivity.setSupportActionBar(binding.toolbar)
|
mainActivity.setSupportActionBar(binding.toolbar)
|
||||||
|
|
||||||
binding.toolbar.title = " "
|
binding.toolbar.title = " "
|
||||||
binding.albumCoverContainer.setTransitionName(arguments.extraAlbumId.toString())
|
binding.albumCoverContainer.transitionName = arguments.extraAlbumId.toString()
|
||||||
postponeEnterTransition()
|
postponeEnterTransition()
|
||||||
detailsViewModel.getAlbum().observe(viewLifecycleOwner) {
|
detailsViewModel.getAlbum().observe(viewLifecycleOwner) {
|
||||||
requireView().doOnPreDraw {
|
requireView().doOnPreDraw {
|
||||||
|
@ -125,10 +125,10 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
}
|
}
|
||||||
albumArtistExists = !it.albumArtist.isNullOrEmpty()
|
albumArtistExists = !it.albumArtist.isNullOrEmpty()
|
||||||
showAlbum(it)
|
showAlbum(it)
|
||||||
if (albumArtistExists) {
|
binding.artistImage.transitionName = if (albumArtistExists) {
|
||||||
binding.artistImage.setTransitionName(album.albumArtist)
|
album.albumArtist
|
||||||
} else {
|
} else {
|
||||||
binding.artistImage.setTransitionName(album.artistId.toString())
|
album.artistId.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
.load(
|
.load(
|
||||||
RetroGlideExtension.getArtistModel(
|
RetroGlideExtension.getArtistModel(
|
||||||
artist,
|
artist,
|
||||||
PreferenceUtil.isAllowedToDownloadMetadata()
|
PreferenceUtil.isAllowedToDownloadMetadata(requireContext())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.artistImageOptions(artist)
|
.artistImageOptions(artist)
|
||||||
|
|
|
@ -88,7 +88,7 @@ abstract class AbsArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragm
|
||||||
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
||||||
mainActivity.setSupportActionBar(binding.toolbar)
|
mainActivity.setSupportActionBar(binding.toolbar)
|
||||||
binding.toolbar.title = null
|
binding.toolbar.title = null
|
||||||
binding.artistCoverContainer.setTransitionName((artistId ?: artistName).toString())
|
binding.artistCoverContainer.transitionName = (artistId ?: artistName).toString()
|
||||||
postponeEnterTransition()
|
postponeEnterTransition()
|
||||||
detailsViewModel.getArtist().observe(viewLifecycleOwner) {
|
detailsViewModel.getArtist().observe(viewLifecycleOwner) {
|
||||||
requireView().doOnPreDraw {
|
requireView().doOnPreDraw {
|
||||||
|
@ -146,7 +146,7 @@ abstract class AbsArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragm
|
||||||
}
|
}
|
||||||
this.artist = artist
|
this.artist = artist
|
||||||
loadArtistImage(artist)
|
loadArtistImage(artist)
|
||||||
if (RetroUtil.isAllowedToDownloadMetadata(requireContext())) {
|
if (PreferenceUtil.isAllowedToDownloadMetadata(requireContext())) {
|
||||||
loadBiography(artist.name)
|
loadBiography(artist.name)
|
||||||
}
|
}
|
||||||
binding.artistTitle.text = artist.name
|
binding.artistTitle.text = artist.name
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package code.name.monkey.retromusic.fragments.backup
|
package code.name.monkey.retromusic.fragments.backup
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
|
|
@ -30,6 +30,7 @@ import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.commit
|
import androidx.fragment.app.commit
|
||||||
import androidx.fragment.app.replace
|
import androidx.fragment.app.replace
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.MusicSeekSkipTouchListener
|
import code.name.monkey.retromusic.fragments.MusicSeekSkipTouchListener
|
||||||
import code.name.monkey.retromusic.fragments.other.VolumeFragment
|
import code.name.monkey.retromusic.fragments.other.VolumeFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
@ -224,8 +225,7 @@ abstract class AbsPlayerControlsFragment(@LayoutRes layout: Int) : AbsMusicServi
|
||||||
}
|
}
|
||||||
childFragmentManager.executePendingTransactions()
|
childFragmentManager.executePendingTransactions()
|
||||||
}
|
}
|
||||||
volumeFragment =
|
volumeFragment = whichFragment(R.id.volumeFragmentContainer)
|
||||||
childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as? VolumeFragment
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
|
|
@ -359,15 +359,6 @@ abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMainActivityFragme
|
||||||
val TAG: String = AbsPlayerFragment::class.java.simpleName
|
val TAG: String = AbsPlayerFragment::class.java.simpleName
|
||||||
const val VISIBILITY_ANIM_DURATION: Long = 300
|
const val VISIBILITY_ANIM_DURATION: Long = 300
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun getUpNextAndQueueTime(): String {
|
|
||||||
val duration = MusicPlayerRemote.getQueueDurationMillis(MusicPlayerRemote.position)
|
|
||||||
|
|
||||||
return MusicUtil.buildInfoString(
|
|
||||||
resources.getString(R.string.up_next),
|
|
||||||
MusicUtil.getReadableDurationString(duration)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun goToArtist(activity: Activity) {
|
fun goToArtist(activity: Activity) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
||||||
mainActivity.setSupportActionBar(binding.toolbar)
|
mainActivity.setSupportActionBar(binding.toolbar)
|
||||||
binding.container.setTransitionName("genre")
|
binding.container.transitionName = "genre"
|
||||||
genre = arguments.extraGenre
|
genre = arguments.extraGenre
|
||||||
binding.toolbar.title = arguments.extraGenre.name
|
binding.toolbar.title = arguments.extraGenre.name
|
||||||
setupRecyclerView()
|
setupRecyclerView()
|
||||||
|
|
|
@ -40,10 +40,7 @@ import code.name.monkey.retromusic.activities.tageditor.TagWriter
|
||||||
import code.name.monkey.retromusic.databinding.FragmentLyricsBinding
|
import code.name.monkey.retromusic.databinding.FragmentLyricsBinding
|
||||||
import code.name.monkey.retromusic.databinding.FragmentNormalLyricsBinding
|
import code.name.monkey.retromusic.databinding.FragmentNormalLyricsBinding
|
||||||
import code.name.monkey.retromusic.databinding.FragmentSyncedLyricsBinding
|
import code.name.monkey.retromusic.databinding.FragmentSyncedLyricsBinding
|
||||||
import code.name.monkey.retromusic.extensions.accentColor
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.materialDialog
|
|
||||||
import code.name.monkey.retromusic.extensions.textColorSecondary
|
|
||||||
import code.name.monkey.retromusic.extensions.uri
|
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||||
|
@ -52,7 +49,6 @@ import code.name.monkey.retromusic.model.AudioTagInfo
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.FileUtils
|
import code.name.monkey.retromusic.util.FileUtils
|
||||||
import code.name.monkey.retromusic.util.LyricUtil
|
import code.name.monkey.retromusic.util.LyricUtil
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
|
||||||
import code.name.monkey.retromusic.util.UriUtil
|
import code.name.monkey.retromusic.util.UriUtil
|
||||||
import com.afollestad.materialdialogs.input.input
|
import com.afollestad.materialdialogs.input.input
|
||||||
import com.google.android.material.color.MaterialColors
|
import com.google.android.material.color.MaterialColors
|
||||||
|
@ -149,7 +145,7 @@ class LyricsFragment : AbsMusicServiceFragment(R.layout.fragment_lyrics) {
|
||||||
exitTransition = Fade()
|
exitTransition = Fade()
|
||||||
lyricsSectionsAdapter = LyricsSectionsAdapter(requireActivity())
|
lyricsSectionsAdapter = LyricsSectionsAdapter(requireActivity())
|
||||||
_binding = FragmentLyricsBinding.bind(view)
|
_binding = FragmentLyricsBinding.bind(view)
|
||||||
binding.container.setTransitionName("lyrics")
|
binding.container.transitionName = "lyrics"
|
||||||
|
|
||||||
setupWakelock()
|
setupWakelock()
|
||||||
setupViews()
|
setupViews()
|
||||||
|
@ -225,8 +221,7 @@ class LyricsFragment : AbsMusicServiceFragment(R.layout.fragment_lyrics) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (item.itemId == R.id.action_search) {
|
if (item.itemId == R.id.action_search) {
|
||||||
RetroUtil.openUrl(
|
openUrl(when (binding.lyricsPager.currentItem) {
|
||||||
requireActivity(), when (binding.lyricsPager.currentItem) {
|
|
||||||
0 -> syairSearchLrcUrl
|
0 -> syairSearchLrcUrl
|
||||||
1 -> googleSearchLrcUrl
|
1 -> googleSearchLrcUrl
|
||||||
else -> googleSearchLrcUrl
|
else -> googleSearchLrcUrl
|
||||||
|
|
|
@ -48,9 +48,9 @@ class AdaptiveFragment : AbsPlayerFragment(R.layout.fragment_adaptive_player) {
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
playbackControlsFragment =
|
playbackControlsFragment =
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as AdaptivePlaybackControlsFragment
|
whichFragment(R.id.playbackControlsFragment) as AdaptivePlaybackControlsFragment
|
||||||
val playerAlbumCoverFragment =
|
val playerAlbumCoverFragment =
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
whichFragment(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||||
playerAlbumCoverFragment.apply {
|
playerAlbumCoverFragment.apply {
|
||||||
removeSlideEffect()
|
removeSlideEffect()
|
||||||
setCallbacks(this@AdaptiveFragment)
|
setCallbacks(this@AdaptiveFragment)
|
||||||
|
|
|
@ -27,6 +27,7 @@ import code.name.monkey.retromusic.NEW_BLUR_AMOUNT
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentBlurBinding
|
import code.name.monkey.retromusic.databinding.FragmentBlurBinding
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.glide.*
|
import code.name.monkey.retromusic.glide.*
|
||||||
|
@ -62,10 +63,9 @@ class BlurPlayerFragment : AbsPlayerFragment(R.layout.fragment_blur),
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
playbackControlsFragment =
|
playbackControlsFragment = whichFragment(R.id.playbackControlsFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as BlurPlaybackControlsFragment
|
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
|
||||||
val playerAlbumCoverFragment =
|
whichFragment(R.id.playerAlbumCoverFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
|
||||||
playerAlbumCoverFragment.setCallbacks(this)
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentCardPlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentCardPlayerBinding
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
||||||
|
@ -87,10 +88,9 @@ class CardFragment : AbsPlayerFragment(R.layout.fragment_card_player) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
playbackControlsFragment =
|
playbackControlsFragment = whichFragment(R.id.playbackControlsFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardPlaybackControlsFragment
|
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
|
||||||
val playerAlbumCoverFragment =
|
whichFragment(R.id.playerAlbumCoverFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
|
||||||
playerAlbumCoverFragment.setCallbacks(this)
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
playerAlbumCoverFragment.removeSlideEffect()
|
playerAlbumCoverFragment.removeSlideEffect()
|
||||||
}
|
}
|
||||||
|
@ -117,14 +117,4 @@ class CardFragment : AbsPlayerFragment(R.layout.fragment_card_player) {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
_binding = null
|
_binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun newInstance(): PlayerFragment {
|
|
||||||
val args = Bundle()
|
|
||||||
val fragment = PlayerFragment()
|
|
||||||
fragment.arguments = args
|
|
||||||
return fragment
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import code.name.monkey.retromusic.NEW_BLUR_AMOUNT
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentCardBlurPlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentCardBlurPlayerBinding
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
||||||
|
@ -98,8 +99,8 @@ class CardBlurFragment : AbsPlayerFragment(R.layout.fragment_card_blur_player),
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
playbackControlsFragment =
|
playbackControlsFragment =
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardBlurPlaybackControlsFragment
|
whichFragment(R.id.playbackControlsFragment) as CardBlurPlaybackControlsFragment
|
||||||
(childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment?)?.setCallbacks(
|
(whichFragment(R.id.playerAlbumCoverFragment) as? PlayerAlbumCoverFragment)?.setCallbacks(
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.RetroBottomSheetBehavior
|
import code.name.monkey.retromusic.RetroBottomSheetBehavior
|
||||||
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
||||||
import code.name.monkey.retromusic.databinding.FragmentClassicPlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentClassicPlayerBinding
|
||||||
import code.name.monkey.retromusic.extensions.getSongInfo
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
|
||||||
import code.name.monkey.retromusic.extensions.show
|
|
||||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
|
||||||
import code.name.monkey.retromusic.fragments.MusicSeekSkipTouchListener
|
import code.name.monkey.retromusic.fragments.MusicSeekSkipTouchListener
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
|
@ -131,8 +128,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(R.layout.fragment_classic_player
|
||||||
hideVolumeIfAvailable()
|
hideVolumeIfAvailable()
|
||||||
setupRecyclerView()
|
setupRecyclerView()
|
||||||
|
|
||||||
val coverFragment =
|
val coverFragment: PlayerAlbumCoverFragment = whichFragment(R.id.playerAlbumCoverFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
|
||||||
coverFragment.setCallbacks(this)
|
coverFragment.setCallbacks(this)
|
||||||
|
|
||||||
getQueuePanel().addBottomSheetCallback(bottomSheetCallbackList)
|
getQueuePanel().addBottomSheetCallback(bottomSheetCallbackList)
|
||||||
|
@ -174,7 +170,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(R.layout.fragment_classic_player
|
||||||
}
|
}
|
||||||
childFragmentManager.executePendingTransactions()
|
childFragmentManager.executePendingTransactions()
|
||||||
volumeFragment =
|
volumeFragment =
|
||||||
childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?
|
whichFragment(R.id.volumeFragmentContainer) as VolumeFragment?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +364,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(R.layout.fragment_classic_player
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupPanel() {
|
private fun setupPanel() {
|
||||||
if (!binding.playerContainer.isLaidOut() || binding.playerContainer.isLayoutRequested) {
|
if (!binding.playerContainer.isLaidOut || binding.playerContainer.isLayoutRequested) {
|
||||||
binding.playerContainer.addOnLayoutChangeListener(this)
|
binding.playerContainer.addOnLayoutChangeListener(this)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -419,7 +415,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(R.layout.fragment_classic_player
|
||||||
linearLayoutManager.scrollToPositionWithOffset(MusicPlayerRemote.position + 1, 0)
|
linearLayoutManager.scrollToPositionWithOffset(MusicPlayerRemote.position + 1, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUpProgressSlider() {
|
private fun setUpProgressSlider() {
|
||||||
binding.playerControlsContainer.progressSlider.setOnSeekBarChangeListener(object :
|
binding.playerControlsContainer.progressSlider.setOnSeekBarChangeListener(object :
|
||||||
SimpleOnSeekbarChangeListener() {
|
SimpleOnSeekbarChangeListener() {
|
||||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentColorPlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentColorPlayerBinding
|
||||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
@ -110,15 +111,14 @@ class ColorFragment : AbsPlayerFragment(R.layout.fragment_color_player) {
|
||||||
_binding = FragmentColorPlayerBinding.bind(view)
|
_binding = FragmentColorPlayerBinding.bind(view)
|
||||||
setUpSubFragments()
|
setUpSubFragments()
|
||||||
setUpPlayerToolbar()
|
setUpPlayerToolbar()
|
||||||
val playerAlbumCoverFragment =
|
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
whichFragment(R.id.playbackControlsFragment)
|
||||||
playerAlbumCoverFragment.setCallbacks(this)
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
playerToolbar().drawAboveSystemBars()
|
playerToolbar().drawAboveSystemBars()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
playbackControlsFragment =
|
playbackControlsFragment = whichFragment(R.id.playbackControlsFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as ColorPlaybackControlsFragment
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpPlayerToolbar() {
|
private fun setUpPlayerToolbar() {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentFitBinding
|
import code.name.monkey.retromusic.databinding.FragmentFitBinding
|
||||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
@ -90,10 +91,9 @@ class FitFragment : AbsPlayerFragment(R.layout.fragment_fit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
playbackControlsFragment =
|
playbackControlsFragment = whichFragment(R.id.playbackControlsFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FitPlaybackControlsFragment
|
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
|
||||||
val playerAlbumCoverFragment =
|
whichFragment(R.id.playerAlbumCoverFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
|
||||||
playerAlbumCoverFragment.setCallbacks(this)
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentFlatPlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentFlatPlayerBinding
|
||||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
@ -52,10 +53,9 @@ class FlatPlayerFragment : AbsPlayerFragment(R.layout.fragment_flat_player) {
|
||||||
|
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
controlsFragment =
|
controlsFragment = whichFragment(R.id.playbackControlsFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as FlatPlaybackControlsFragment
|
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
|
||||||
val playerAlbumCoverFragment =
|
whichFragment(R.id.playerAlbumCoverFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
|
||||||
playerAlbumCoverFragment.setCallbacks(this)
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupPanel() {
|
private fun setupPanel() {
|
||||||
if (!binding.colorBackground.isLaidOut() || binding.colorBackground.isLayoutRequested) {
|
if (!binding.colorBackground.isLaidOut || binding.colorBackground.isLayoutRequested) {
|
||||||
binding.colorBackground.addOnLayoutChangeListener(this)
|
binding.colorBackground.addOnLayoutChangeListener(this)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
}
|
}
|
||||||
childFragmentManager.executePendingTransactions()
|
childFragmentManager.executePendingTransactions()
|
||||||
volumeFragment =
|
volumeFragment =
|
||||||
childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?
|
whichFragment(R.id.volumeFragmentContainer) as VolumeFragment?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import code.name.monkey.retromusic.databinding.FragmentMaterialBinding
|
||||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||||
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
||||||
|
@ -134,10 +135,9 @@ class MaterialFragment : AbsPlayerFragment(R.layout.fragment_material) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
playbackControlsFragment =
|
playbackControlsFragment = whichFragment(R.id.playbackControlsFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as MaterialControlsFragment
|
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
|
||||||
val playerAlbumCoverFragment =
|
whichFragment(R.id.playbackControlsFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
|
||||||
playerAlbumCoverFragment.setCallbacks(this)
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.SNOWFALL
|
import code.name.monkey.retromusic.SNOWFALL
|
||||||
import code.name.monkey.retromusic.databinding.FragmentPlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentPlayerBinding
|
||||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
|
||||||
import code.name.monkey.retromusic.extensions.isColorLight
|
|
||||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
@ -141,10 +138,9 @@ class PlayerFragment : AbsPlayerFragment(R.layout.fragment_player),
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
controlsFragment =
|
controlsFragment = whichFragment(R.id.playbackControlsFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlayerPlaybackControlsFragment
|
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
|
||||||
val playerAlbumCoverFragment =
|
whichFragment(R.id.playerAlbumCoverFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
|
||||||
playerAlbumCoverFragment.setCallbacks(this)
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,10 +58,10 @@ class PeekPlayerFragment : AbsPlayerFragment(R.layout.fragment_peek_player) {
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
controlsFragment =
|
controlsFragment =
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PeekPlayerControlFragment
|
whichFragment(R.id.playbackControlsFragment) as PeekPlayerControlFragment
|
||||||
|
|
||||||
val coverFragment =
|
val coverFragment =
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
whichFragment(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
||||||
coverFragment.setCallbacks(this)
|
coverFragment.setCallbacks(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentPlainPlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentPlainPlayerBinding
|
||||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.goToAlbum
|
import code.name.monkey.retromusic.fragments.base.goToAlbum
|
||||||
import code.name.monkey.retromusic.fragments.base.goToArtist
|
import code.name.monkey.retromusic.fragments.base.goToArtist
|
||||||
|
@ -89,10 +90,9 @@ class PlainPlayerFragment : AbsPlayerFragment(R.layout.fragment_plain_player) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
plainPlaybackControlsFragment =
|
plainPlaybackControlsFragment = whichFragment(R.id.playbackControlsFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlainPlaybackControlsFragment
|
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
|
||||||
val playerAlbumCoverFragment =
|
whichFragment(R.id.playerAlbumCoverFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
|
||||||
playerAlbumCoverFragment.setCallbacks(this)
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentSimplePlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentSimplePlayerBinding
|
||||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
|
import code.name.monkey.retromusic.extensions.whichFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
@ -56,11 +57,10 @@ class SimplePlayerFragment : AbsPlayerFragment(R.layout.fragment_simple_player)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
val playerAlbumCoverFragment =
|
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
whichFragment(R.id.playerAlbumCoverFragment)
|
||||||
playerAlbumCoverFragment.setCallbacks(this)
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
controlsFragment =
|
controlsFragment = whichFragment(R.id.playbackControlsFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as SimplePlaybackControlsFragment
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onShow() {
|
override fun onShow() {
|
||||||
|
|
|
@ -29,10 +29,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentTinyPlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentTinyPlayerBinding
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.getSongInfo
|
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
|
||||||
import code.name.monkey.retromusic.extensions.show
|
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.goToAlbum
|
import code.name.monkey.retromusic.fragments.base.goToAlbum
|
||||||
import code.name.monkey.retromusic.fragments.base.goToArtist
|
import code.name.monkey.retromusic.fragments.base.goToArtist
|
||||||
|
@ -153,10 +150,9 @@ class TinyPlayerFragment : AbsPlayerFragment(R.layout.fragment_tiny_player),
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
controlsFragment =
|
controlsFragment = whichFragment(R.id.playbackControlsFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as TinyPlaybackControlsFragment
|
val playerAlbumCoverFragment: PlayerAlbumCoverFragment =
|
||||||
val playerAlbumCoverFragment =
|
whichFragment(R.id.playerAlbumCoverFragment)
|
||||||
childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
|
|
||||||
playerAlbumCoverFragment.setCallbacks(this)
|
playerAlbumCoverFragment.setCallbacks(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
|
||||||
returnTransition = MaterialSharedAxis(MaterialSharedAxis.Z, false)
|
returnTransition = MaterialSharedAxis(MaterialSharedAxis.Z, false)
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
mainActivity.setSupportActionBar(binding.toolbar)
|
mainActivity.setSupportActionBar(binding.toolbar)
|
||||||
binding.container.setTransitionName("playlist")
|
binding.container.transitionName = "playlist"
|
||||||
playlist = arguments.extraPlaylist
|
playlist = arguments.extraPlaylist
|
||||||
binding.toolbar.title = playlist.playlistEntity.playlistName
|
binding.toolbar.title = playlist.playlistEntity.playlistName
|
||||||
setUpRecyclerView()
|
setUpRecyclerView()
|
||||||
|
|
|
@ -42,7 +42,7 @@ class ArtistImageFetcher(
|
||||||
override fun loadData(priority: Priority, callback: DataFetcher.DataCallback<in InputStream>) {
|
override fun loadData(priority: Priority, callback: DataFetcher.DataCallback<in InputStream>) {
|
||||||
try {
|
try {
|
||||||
if (!MusicUtil.isArtistNameUnknown(model.artist.name) &&
|
if (!MusicUtil.isArtistNameUnknown(model.artist.name) &&
|
||||||
PreferenceUtil.isAllowedToDownloadMetadata()
|
PreferenceUtil.isAllowedToDownloadMetadata(context)
|
||||||
) {
|
) {
|
||||||
val artists = model.artist.name.split(",", "&")
|
val artists = model.artist.name.split(",", "&")
|
||||||
response = deezerService.getArtistImage(artists[0])
|
response = deezerService.getArtistImage(artists[0])
|
||||||
|
|
|
@ -139,8 +139,6 @@ object SearchQueryHelper : KoinComponent {
|
||||||
arrayOf(query.lowercase())
|
arrayOf(query.lowercase())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return if (songs.isNotEmpty()) {
|
return songs.ifEmpty { ArrayList() }
|
||||||
songs
|
|
||||||
} else ArrayList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ import android.view.View;
|
||||||
import android.view.animation.LinearInterpolator;
|
import android.view.animation.LinearInterpolator;
|
||||||
import android.widget.Scroller;
|
import android.widget.Scroller;
|
||||||
|
|
||||||
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
|
@ -1,86 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
|
||||||
*
|
|
||||||
* Licensed under the GNU General Public License v3
|
|
||||||
*
|
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the GNU General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.misc;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class LagTracker {
|
|
||||||
private static Map<String, Long> mMap;
|
|
||||||
private static LagTracker mSingleton;
|
|
||||||
private boolean mEnabled = true;
|
|
||||||
|
|
||||||
private LagTracker() {
|
|
||||||
mMap = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LagTracker get() {
|
|
||||||
if (mSingleton == null) {
|
|
||||||
mSingleton = new LagTracker();
|
|
||||||
}
|
|
||||||
return mSingleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void print(String str, long j) {
|
|
||||||
long toMillis = TimeUnit.NANOSECONDS.toMillis(j);
|
|
||||||
Log.d(
|
|
||||||
"LagTracker",
|
|
||||||
"["
|
|
||||||
+ str
|
|
||||||
+ " completed in]: "
|
|
||||||
+ j
|
|
||||||
+ " ns ("
|
|
||||||
+ toMillis
|
|
||||||
+ "ms, "
|
|
||||||
+ TimeUnit.NANOSECONDS.toSeconds(j)
|
|
||||||
+ "s)");
|
|
||||||
}
|
|
||||||
|
|
||||||
public LagTracker disable() {
|
|
||||||
this.mEnabled = false;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LagTracker enable() {
|
|
||||||
this.mEnabled = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void end(String str) {
|
|
||||||
long nanoTime = System.nanoTime();
|
|
||||||
if (this.mEnabled) {
|
|
||||||
if (mMap.containsKey(str)) {
|
|
||||||
print(str, nanoTime - mMap.get(str));
|
|
||||||
mMap.remove(str);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw new IllegalStateException("No start time found for " + str);
|
|
||||||
} else if (!mMap.isEmpty()) {
|
|
||||||
mMap.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start(String str) {
|
|
||||||
long nanoTime = System.nanoTime();
|
|
||||||
if (this.mEnabled) {
|
|
||||||
mMap.put(str, nanoTime);
|
|
||||||
} else if (!mMap.isEmpty()) {
|
|
||||||
mMap.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,9 +25,9 @@ import java.lang.reflect.Type
|
||||||
class LyricsConverterFactory : Converter.Factory() {
|
class LyricsConverterFactory : Converter.Factory() {
|
||||||
|
|
||||||
override fun responseBodyConverter(
|
override fun responseBodyConverter(
|
||||||
type: Type?,
|
type: Type,
|
||||||
annotations: Array<Annotation>?,
|
annotations: Array<out Annotation>,
|
||||||
retrofit: Retrofit?
|
retrofit: Retrofit
|
||||||
): Converter<ResponseBody, *>? {
|
): Converter<ResponseBody, *>? {
|
||||||
return if (String::class.java == type) {
|
return if (String::class.java == type) {
|
||||||
Converter<ResponseBody, String> { value -> value.string() }
|
Converter<ResponseBody, String> { value -> value.string() }
|
||||||
|
@ -35,10 +35,10 @@ class LyricsConverterFactory : Converter.Factory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun requestBodyConverter(
|
override fun requestBodyConverter(
|
||||||
type: Type?,
|
type: Type,
|
||||||
parameterAnnotations: Array<Annotation>?,
|
parameterAnnotations: Array<Annotation>,
|
||||||
methodAnnotations: Array<Annotation>?,
|
methodAnnotations: Array<Annotation>,
|
||||||
retrofit: Retrofit?
|
retrofit: Retrofit
|
||||||
): Converter<*, RequestBody>? {
|
): Converter<*, RequestBody>? {
|
||||||
|
|
||||||
return if (String::class.java == type) {
|
return if (String::class.java == type) {
|
||||||
|
|
|
@ -392,7 +392,7 @@ class MusicService : MediaBrowserServiceCompat(),
|
||||||
wakeLock?.acquire(milli)
|
wakeLock?.acquire(milli)
|
||||||
}
|
}
|
||||||
|
|
||||||
var pausedByZeroVolume = false
|
private var pausedByZeroVolume = false
|
||||||
override fun onAudioVolumeChanged(currentVolume: Int, maxVolume: Int) {
|
override fun onAudioVolumeChanged(currentVolume: Int, maxVolume: Int) {
|
||||||
if (isPauseOnZeroVolume) {
|
if (isPauseOnZeroVolume) {
|
||||||
if (isPlaying && currentVolume < 1) {
|
if (isPlaying && currentVolume < 1) {
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package code.name.monkey.retromusic.util
|
|
||||||
|
|
||||||
import android.animation.ArgbEvaluator
|
|
||||||
import android.animation.ValueAnimator
|
|
||||||
|
|
||||||
class ColorAnimUtil {
|
|
||||||
companion object {
|
|
||||||
fun createColorAnimator(
|
|
||||||
fromColor: Int,
|
|
||||||
toColor: Int,
|
|
||||||
mDuration: Long = 300
|
|
||||||
): ValueAnimator {
|
|
||||||
return ValueAnimator.ofInt(fromColor, toColor).apply {
|
|
||||||
setEvaluator(ArgbEvaluator())
|
|
||||||
duration = mDuration
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
|
||||||
*
|
|
||||||
* Licensed under the GNU General Public License v3
|
|
||||||
*
|
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the GNU General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.util;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created on : June 18, 2016 Author : zetbaitsu Name : Zetra GitHub : https://github.com/zetbaitsu
|
|
||||||
*/
|
|
||||||
public class Compressor {
|
|
||||||
// max width and height values of the compressed image is taken as 612x816
|
|
||||||
private int maxWidth = 612;
|
|
||||||
private int maxHeight = 816;
|
|
||||||
private Bitmap.CompressFormat compressFormat = Bitmap.CompressFormat.JPEG;
|
|
||||||
private int quality = 80;
|
|
||||||
private String destinationDirectoryPath;
|
|
||||||
|
|
||||||
public Compressor(Context context) {
|
|
||||||
destinationDirectoryPath = context.getCacheDir().getPath() + File.separator + "images";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Compressor setMaxWidth(int maxWidth) {
|
|
||||||
this.maxWidth = maxWidth;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Compressor setMaxHeight(int maxHeight) {
|
|
||||||
this.maxHeight = maxHeight;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Compressor setCompressFormat(Bitmap.CompressFormat compressFormat) {
|
|
||||||
this.compressFormat = compressFormat;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Compressor setQuality(int quality) {
|
|
||||||
this.quality = quality;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Compressor setDestinationDirectoryPath(String destinationDirectoryPath) {
|
|
||||||
this.destinationDirectoryPath = destinationDirectoryPath;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File compressToFile(File imageFile) throws IOException {
|
|
||||||
return compressToFile(imageFile, imageFile.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public File compressToFile(File imageFile, String compressedFileName) throws IOException {
|
|
||||||
return ImageUtil.compressImage(
|
|
||||||
imageFile,
|
|
||||||
maxWidth,
|
|
||||||
maxHeight,
|
|
||||||
compressFormat,
|
|
||||||
quality,
|
|
||||||
destinationDirectoryPath + File.separator + compressedFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bitmap compressToBitmap(File imageFile) throws IOException {
|
|
||||||
return ImageUtil.decodeSampledBitmapFromFile(imageFile, maxWidth, maxHeight);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,13 +24,13 @@ import android.graphics.Paint;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.media.ExifInterface;
|
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
import androidx.exifinterface.media.ExifInterface;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
|
|
@ -268,15 +268,14 @@ object MusicUtil : KoinComponent {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSongFilePath(context: Context, uri: Uri): String? {
|
fun getSongFilePath(context: Context, uri: Uri): String {
|
||||||
val projection = arrayOf(MediaStore.MediaColumns.DATA)
|
val projection = arrayOf(MediaStore.MediaColumns.DATA)
|
||||||
return context.contentResolver.query(uri, projection, null, null, null)?.use {
|
context.contentResolver.query(uri, projection, null, null, null)?.use {
|
||||||
if (it.moveToFirst()) {
|
if (it.moveToFirst()) {
|
||||||
it.getString(0)
|
return it.getString(0)
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTotalDuration(songs: List<Song>): Long {
|
fun getTotalDuration(songs: List<Song>): Long {
|
||||||
|
|
|
@ -71,7 +71,7 @@ class PackageValidator(
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the caller attempting to connect to a [MediaBrowserServiceCompat] is known.
|
* Checks whether the caller attempting to connect to a [MediaBrowserServiceCompat] is known.
|
||||||
* See [MusicService.onGetRoot] for where this is utilized.
|
* See [MediaBrowserServiceCompat.onGetRoot] for where this is utilized.
|
||||||
*
|
*
|
||||||
* @param callingPackage The package name of the caller.
|
* @param callingPackage The package name of the caller.
|
||||||
* @param callingUid The user id of the caller.
|
* @param callingUid The user id of the caller.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package code.name.monkey.retromusic.util
|
package code.name.monkey.retromusic.util
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.NetworkInfo
|
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
@ -328,15 +328,12 @@ object PreferenceUtil {
|
||||||
|
|
||||||
val isLockScreen get() = sharedPreferences.getBoolean(LOCK_SCREEN, false)
|
val isLockScreen get() = sharedPreferences.getBoolean(LOCK_SCREEN, false)
|
||||||
|
|
||||||
fun isAllowedToDownloadMetadata(): Boolean {
|
fun isAllowedToDownloadMetadata(context: Context): Boolean {
|
||||||
return when (autoDownloadImagesPolicy) {
|
return when (autoDownloadImagesPolicy) {
|
||||||
"always" -> true
|
"always" -> true
|
||||||
"only_wifi" -> {
|
"only_wifi" -> {
|
||||||
val connectivityManager = App.getContext().getSystemService<ConnectivityManager>()
|
val connectivityManager = context.getSystemService<ConnectivityManager>()
|
||||||
var netInfo: NetworkInfo? = null
|
val netInfo = connectivityManager?.activeNetworkInfo
|
||||||
if (connectivityManager != null) {
|
|
||||||
netInfo = connectivityManager.activeNetworkInfo
|
|
||||||
}
|
|
||||||
netInfo != null && netInfo.type == ConnectivityManager.TYPE_WIFI && netInfo.isConnectedOrConnecting
|
netInfo != null && netInfo.type == ConnectivityManager.TYPE_WIFI && netInfo.isConnectedOrConnecting
|
||||||
}
|
}
|
||||||
"never" -> false
|
"never" -> false
|
||||||
|
|
|
@ -195,13 +195,6 @@ public class RetroUtil {
|
||||||
>= 600;
|
>= 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openUrl(@NonNull Activity context, @NonNull String str) {
|
|
||||||
Intent intent = new Intent("android.intent.action.VIEW");
|
|
||||||
intent.setData(Uri.parse(str));
|
|
||||||
intent.setFlags(268435456);
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setAllowDrawUnderNavigationBar(Window window) {
|
public static void setAllowDrawUnderNavigationBar(Window window) {
|
||||||
window.setNavigationBarColor(Color.TRANSPARENT);
|
window.setNavigationBarColor(Color.TRANSPARENT);
|
||||||
window
|
window
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue