[Cleanup] Fixing Warnings
This commit is contained in:
parent
1fdd537253
commit
fa976b1cba
68 changed files with 242 additions and 498 deletions
|
@ -126,7 +126,7 @@ dependencies {
|
||||||
def retrofit_version = '2.9.0'
|
def retrofit_version = '2.9.0'
|
||||||
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
|
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
|
||||||
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
||||||
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'
|
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.3'
|
||||||
|
|
||||||
def material_dialog_version = "3.3.0"
|
def material_dialog_version = "3.3.0"
|
||||||
implementation "com.afollestad.material-dialogs:core:$material_dialog_version"
|
implementation "com.afollestad.material-dialogs:core:$material_dialog_version"
|
||||||
|
|
|
@ -132,7 +132,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
|
||||||
permissionDeniedMessage!!,
|
permissionDeniedMessage!!,
|
||||||
Snackbar.LENGTH_INDEFINITE
|
Snackbar.LENGTH_INDEFINITE
|
||||||
)
|
)
|
||||||
.setAction(code.name.monkey.retromusic.R.string.action_grant) { requestPermissions() }
|
.setAction(R.string.action_grant) { requestPermissions() }
|
||||||
.setActionTextColor(ThemeStore.accentColor(this)).show()
|
.setActionTextColor(ThemeStore.accentColor(this)).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
|
||||||
|
@ -140,7 +140,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
|
||||||
snackBarContainer,
|
snackBarContainer,
|
||||||
permissionDeniedMessage!!,
|
permissionDeniedMessage!!,
|
||||||
Snackbar.LENGTH_INDEFINITE
|
Snackbar.LENGTH_INDEFINITE
|
||||||
).setAction(code.name.monkey.retromusic.R.string.action_settings) {
|
).setAction(R.string.action_settings) {
|
||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
|
||||||
val uri = Uri.fromParts(
|
val uri = Uri.fromParts(
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
*/
|
*/
|
||||||
package code.name.monkey.retromusic.adapter
|
package code.name.monkey.retromusic.adapter
|
||||||
|
|
||||||
import android.os.Handler
|
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -25,8 +24,6 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.AppCompatTextView
|
import androidx.appcompat.widget.AppCompatTextView
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.findFragment
|
import androidx.fragment.app.findFragment
|
||||||
import androidx.lifecycle.findViewTreeLifecycleOwner
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.navigation.fragment.FragmentNavigatorExtras
|
import androidx.navigation.fragment.FragmentNavigatorExtras
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
@ -49,7 +46,6 @@ import code.name.monkey.retromusic.interfaces.IGenreClickListener
|
||||||
import code.name.monkey.retromusic.model.*
|
import code.name.monkey.retromusic.model.*
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
|
|
||||||
class HomeAdapter(
|
class HomeAdapter(
|
||||||
private val activity: AppCompatActivity
|
private val activity: AppCompatActivity
|
||||||
|
@ -204,7 +200,7 @@ class HomeAdapter(
|
||||||
if (SystemClock.elapsedRealtime() - mLastClickTime < 1000){
|
if (SystemClock.elapsedRealtime() - mLastClickTime < 1000){
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
mLastClickTime = SystemClock.elapsedRealtime();
|
mLastClickTime = SystemClock.elapsedRealtime()
|
||||||
MusicPlayerRemote.playNext((home.arrayList as List<Song>).subList(0, 8))
|
MusicPlayerRemote.playNext((home.arrayList as List<Song>).subList(0, 8))
|
||||||
if (!MusicPlayerRemote.isPlaying) {
|
if (!MusicPlayerRemote.isPlaying) {
|
||||||
MusicPlayerRemote.playNextSong()
|
MusicPlayerRemote.playNextSong()
|
||||||
|
|
|
@ -27,13 +27,13 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.MainActivity
|
import code.name.monkey.retromusic.activities.MainActivity
|
||||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
|
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
|
||||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
||||||
|
import code.name.monkey.retromusic.fragments.base.goToLyrics
|
||||||
import code.name.monkey.retromusic.glide.GlideApp
|
import code.name.monkey.retromusic.glide.GlideApp
|
||||||
import code.name.monkey.retromusic.glide.RetroGlideExtension
|
import code.name.monkey.retromusic.glide.RetroGlideExtension
|
||||||
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||||
import code.name.monkey.retromusic.misc.CustomFragmentStatePagerAdapter
|
import code.name.monkey.retromusic.misc.CustomFragmentStatePagerAdapter
|
||||||
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 code.name.monkey.retromusic.util.NavigationUtil
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED
|
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
@ -127,7 +127,8 @@ class AlbumCoverPagerAdapter(
|
||||||
setTitle(song.title)
|
setTitle(song.title)
|
||||||
setMessage(if (data.isNullOrEmpty()) "No lyrics found" else data)
|
setMessage(if (data.isNullOrEmpty()) "No lyrics found" else data)
|
||||||
setNegativeButton(R.string.synced_lyrics) { _, _ ->
|
setNegativeButton(R.string.synced_lyrics) { _, _ ->
|
||||||
NavigationUtil.goToLyrics(requireActivity())
|
|
||||||
|
goToLyrics(requireActivity())
|
||||||
}
|
}
|
||||||
show()
|
show()
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ class PlayingQueueAdapter(
|
||||||
private const val UP_NEXT = 2
|
private const val UP_NEXT = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSwipeItem(holder: ViewHolder, position: Int, result: Int): SwipeResultAction? {
|
override fun onSwipeItem(holder: ViewHolder, position: Int, result: Int): SwipeResultAction {
|
||||||
return if (result == SwipeableItemConstants.RESULT_CANCELED) {
|
return if (result == SwipeableItemConstants.RESULT_CANCELED) {
|
||||||
SwipeResultActionDefault()
|
SwipeResultActionDefault()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -42,6 +42,6 @@ class LastAddedShortcutType(context: Context) : BaseShortcutType(context) {
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
val id: String
|
val id: String
|
||||||
get() = BaseShortcutType.ID_PREFIX + "last_added"
|
get() = ID_PREFIX + "last_added"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,6 @@ class TopTracksShortcutType(context: Context) : BaseShortcutType(context) {
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
val id: String
|
val id: String
|
||||||
get() = BaseShortcutType.ID_PREFIX + "top_tracks"
|
get() = ID_PREFIX + "top_tracks"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ class AppWidgetBig : BaseAppWidget() {
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_skip_next,
|
R.drawable.ic_skip_next,
|
||||||
MaterialValueHelper.getPrimaryTextColor(context, false)
|
MaterialValueHelper.getPrimaryTextColor(context, false)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -71,16 +71,16 @@ class AppWidgetBig : BaseAppWidget() {
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_skip_previous,
|
R.drawable.ic_skip_previous,
|
||||||
MaterialValueHelper.getPrimaryTextColor(context, false)
|
MaterialValueHelper.getPrimaryTextColor(context, false)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
R.id.button_toggle_play_pause, BaseAppWidget.createBitmap(
|
R.id.button_toggle_play_pause, createBitmap(
|
||||||
RetroUtil.getTintedVectorDrawable(
|
RetroUtil.getTintedVectorDrawable(
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_play_arrow_white_32dp,
|
R.drawable.ic_play_arrow_white_32dp,
|
||||||
MaterialValueHelper.getPrimaryTextColor(context, false)
|
MaterialValueHelper.getPrimaryTextColor(context, false)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ class AppWidgetBig : BaseAppWidget() {
|
||||||
service,
|
service,
|
||||||
playPauseRes,
|
playPauseRes,
|
||||||
primaryColor
|
primaryColor
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ class AppWidgetBig : BaseAppWidget() {
|
||||||
service,
|
service,
|
||||||
R.drawable.ic_skip_next,
|
R.drawable.ic_skip_next,
|
||||||
primaryColor
|
primaryColor
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -147,7 +147,7 @@ class AppWidgetBig : BaseAppWidget() {
|
||||||
service,
|
service,
|
||||||
R.drawable.ic_skip_previous,
|
R.drawable.ic_skip_previous,
|
||||||
primaryColor
|
primaryColor
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ class AppWidgetBig : BaseAppWidget() {
|
||||||
|
|
||||||
// Load the album cover async and push the update on completion
|
// Load the album cover async and push the update on completion
|
||||||
val p = RetroUtil.getScreenSize(service)
|
val p = RetroUtil.getScreenSize(service)
|
||||||
val widgetImageSize = Math.min(p.x, p.y)
|
val widgetImageSize = p.x.coerceAtMost(p.y)
|
||||||
val appContext = service.applicationContext
|
val appContext = service.applicationContext
|
||||||
service.runOnUiThread {
|
service.runOnUiThread {
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ class AppWidgetCard : BaseAppWidget() {
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_skip_next,
|
R.drawable.ic_skip_next,
|
||||||
secondaryColor
|
secondaryColor
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -69,7 +69,7 @@ class AppWidgetCard : BaseAppWidget() {
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_skip_previous,
|
R.drawable.ic_skip_previous,
|
||||||
secondaryColor
|
secondaryColor
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -78,7 +78,7 @@ class AppWidgetCard : BaseAppWidget() {
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_play_arrow_white_32dp,
|
R.drawable.ic_play_arrow_white_32dp,
|
||||||
secondaryColor
|
secondaryColor
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ class AppWidgetCard : BaseAppWidget() {
|
||||||
service,
|
service,
|
||||||
playPauseRes,
|
playPauseRes,
|
||||||
MaterialValueHelper.getSecondaryTextColor(service, true)
|
MaterialValueHelper.getSecondaryTextColor(service, true)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class AppWidgetCard : BaseAppWidget() {
|
||||||
service,
|
service,
|
||||||
R.drawable.ic_skip_next,
|
R.drawable.ic_skip_next,
|
||||||
MaterialValueHelper.getSecondaryTextColor(service, true)
|
MaterialValueHelper.getSecondaryTextColor(service, true)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -133,7 +133,7 @@ class AppWidgetCard : BaseAppWidget() {
|
||||||
service,
|
service,
|
||||||
R.drawable.ic_skip_previous,
|
R.drawable.ic_skip_previous,
|
||||||
MaterialValueHelper.getSecondaryTextColor(service, true)
|
MaterialValueHelper.getSecondaryTextColor(service, true)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class AppWidgetClassic : BaseAppWidget() {
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_skip_next,
|
R.drawable.ic_skip_next,
|
||||||
MaterialValueHelper.getSecondaryTextColor(context, true)
|
MaterialValueHelper.getSecondaryTextColor(context, true)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -71,7 +71,7 @@ class AppWidgetClassic : BaseAppWidget() {
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_skip_previous,
|
R.drawable.ic_skip_previous,
|
||||||
MaterialValueHelper.getSecondaryTextColor(context, true)
|
MaterialValueHelper.getSecondaryTextColor(context, true)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -81,7 +81,7 @@ class AppWidgetClassic : BaseAppWidget() {
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_play_arrow_white_32dp,
|
R.drawable.ic_play_arrow_white_32dp,
|
||||||
MaterialValueHelper.getSecondaryTextColor(context, true)
|
MaterialValueHelper.getSecondaryTextColor(context, true)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ class AppWidgetSmall : BaseAppWidget() {
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_skip_next,
|
R.drawable.ic_skip_next,
|
||||||
MaterialValueHelper.getSecondaryTextColor(context, true)
|
MaterialValueHelper.getSecondaryTextColor(context, true)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -69,7 +69,7 @@ class AppWidgetSmall : BaseAppWidget() {
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_skip_previous,
|
R.drawable.ic_skip_previous,
|
||||||
MaterialValueHelper.getSecondaryTextColor(context, true)
|
MaterialValueHelper.getSecondaryTextColor(context, true)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -79,7 +79,7 @@ class AppWidgetSmall : BaseAppWidget() {
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_play_arrow_white_32dp,
|
R.drawable.ic_play_arrow_white_32dp,
|
||||||
MaterialValueHelper.getSecondaryTextColor(context, true)
|
MaterialValueHelper.getSecondaryTextColor(context, true)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ class AppWidgetSmall : BaseAppWidget() {
|
||||||
R.id.button_toggle_play_pause, createBitmap(
|
R.id.button_toggle_play_pause, createBitmap(
|
||||||
RetroUtil.getTintedVectorDrawable(
|
RetroUtil.getTintedVectorDrawable(
|
||||||
service, playPauseRes, color
|
service, playPauseRes, color
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -170,14 +170,14 @@ class AppWidgetSmall : BaseAppWidget() {
|
||||||
R.id.button_next, createBitmap(
|
R.id.button_next, createBitmap(
|
||||||
RetroUtil.getTintedVectorDrawable(
|
RetroUtil.getTintedVectorDrawable(
|
||||||
service, R.drawable.ic_skip_next, color
|
service, R.drawable.ic_skip_next, color
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
R.id.button_prev, createBitmap(
|
R.id.button_prev, createBitmap(
|
||||||
RetroUtil.getTintedVectorDrawable(
|
RetroUtil.getTintedVectorDrawable(
|
||||||
service, R.drawable.ic_skip_previous, color
|
service, R.drawable.ic_skip_previous, color
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import android.app.PendingIntent
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.provider.MediaStore
|
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
|
@ -43,7 +42,7 @@ class AppWidgetText : BaseAppWidget() {
|
||||||
context, R.drawable.ic_skip_next, ContextCompat.getColor(
|
context, R.drawable.ic_skip_next, ContextCompat.getColor(
|
||||||
context, R.color.md_white_1000
|
context, R.color.md_white_1000
|
||||||
)
|
)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -52,7 +51,7 @@ class AppWidgetText : BaseAppWidget() {
|
||||||
context, R.drawable.ic_skip_previous, ContextCompat.getColor(
|
context, R.drawable.ic_skip_previous, ContextCompat.getColor(
|
||||||
context, R.color.md_white_1000
|
context, R.color.md_white_1000
|
||||||
)
|
)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -61,7 +60,7 @@ class AppWidgetText : BaseAppWidget() {
|
||||||
context, R.drawable.ic_play_arrow_white_32dp, ContextCompat.getColor(
|
context, R.drawable.ic_play_arrow_white_32dp, ContextCompat.getColor(
|
||||||
context, R.color.md_white_1000
|
context, R.color.md_white_1000
|
||||||
)
|
)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -137,7 +136,7 @@ class AppWidgetText : BaseAppWidget() {
|
||||||
App.getContext(), playPauseRes, ContextCompat.getColor(
|
App.getContext(), playPauseRes, ContextCompat.getColor(
|
||||||
App.getContext(), R.color.md_white_1000
|
App.getContext(), R.color.md_white_1000
|
||||||
)
|
)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -148,7 +147,7 @@ class AppWidgetText : BaseAppWidget() {
|
||||||
ContextCompat.getColor(
|
ContextCompat.getColor(
|
||||||
App.getContext(), R.color.md_white_1000
|
App.getContext(), R.color.md_white_1000
|
||||||
)
|
)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
appWidgetView.setImageViewBitmap(
|
appWidgetView.setImageViewBitmap(
|
||||||
|
@ -159,7 +158,7 @@ class AppWidgetText : BaseAppWidget() {
|
||||||
ContextCompat.getColor(
|
ContextCompat.getColor(
|
||||||
App.getContext(), R.color.md_white_1000
|
App.getContext(), R.color.md_white_1000
|
||||||
)
|
)
|
||||||
)!!, 1f
|
), 1f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.google.android.gms.cast.MediaInfo.STREAM_TYPE_BUFFERED
|
||||||
import com.google.android.gms.cast.MediaMetadata.*
|
import com.google.android.gms.cast.MediaMetadata.*
|
||||||
import com.google.android.gms.cast.framework.CastSession
|
import com.google.android.gms.cast.framework.CastSession
|
||||||
import com.google.android.gms.common.images.WebImage
|
import com.google.android.gms.common.images.WebImage
|
||||||
|
import org.json.JSONObject
|
||||||
import java.net.MalformedURLException
|
import java.net.MalformedURLException
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ object CastHelper {
|
||||||
position,
|
position,
|
||||||
MediaStatus.REPEAT_MODE_REPEAT_OFF,
|
MediaStatus.REPEAT_MODE_REPEAT_OFF,
|
||||||
progress,
|
progress,
|
||||||
null
|
JSONObject()
|
||||||
)
|
)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ExpandedControlsActivity : ExpandedControllerActivity() {
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
super.onCreateOptionsMenu(menu)
|
super.onCreateOptionsMenu(menu)
|
||||||
menuInflater.inflate(R.menu.menu_cast, menu)
|
menuInflater.inflate(R.menu.menu_cast, menu)
|
||||||
CastButtonFactory.setUpMediaRouteButton(this, menu, R.id.action_cast)
|
CastButtonFactory.setUpMediaRouteButton(this, menu!!, R.id.action_cast)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@ class RetroWebServer(val context: Context) : NanoHTTPD(SERVER_PORT) {
|
||||||
const val PART_COVER_ART = "coverart"
|
const val PART_COVER_ART = "coverart"
|
||||||
const val PART_SONG = "song"
|
const val PART_SONG = "song"
|
||||||
const val PARAM_ID = "id"
|
const val PARAM_ID = "id"
|
||||||
var mRetroWebServer: RetroWebServer? = null
|
private var mRetroWebServer: RetroWebServer? = null
|
||||||
fun getInstance(context: Context): RetroWebServer {
|
fun getInstance(context: Context): RetroWebServer {
|
||||||
if (mRetroWebServer == null) {
|
if (mRetroWebServer == null) {
|
||||||
mRetroWebServer = RetroWebServer(context)
|
mRetroWebServer = RetroWebServer(context)
|
||||||
|
|
|
@ -139,7 +139,7 @@ class DeleteSongsDialog : DialogFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reloadTabs() {
|
private fun reloadTabs() {
|
||||||
libraryViewModel.forceReload(ReloadType.Songs)
|
libraryViewModel.forceReload(ReloadType.Songs)
|
||||||
libraryViewModel.forceReload(ReloadType.HomeSections)
|
libraryViewModel.forceReload(ReloadType.HomeSections)
|
||||||
libraryViewModel.forceReload(ReloadType.Artists)
|
libraryViewModel.forceReload(ReloadType.Artists)
|
||||||
|
|
|
@ -78,7 +78,7 @@ fun isBlack(fArr: FloatArray): Boolean {
|
||||||
|
|
||||||
fun isNearRedLine(fArr: FloatArray): Boolean {
|
fun isNearRedLine(fArr: FloatArray): Boolean {
|
||||||
val f = fArr[0]
|
val f = fArr[0]
|
||||||
return f >= 10.0f && f <= 37.0f && fArr[1] <= 0.82f
|
return f in 10.0f..37.0f && fArr[1] <= 0.82f
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isDark(@ColorInt i: Int): Boolean {
|
fun isDark(@ColorInt i: Int): Boolean {
|
||||||
|
|
|
@ -43,7 +43,7 @@ class LibraryViewModel(
|
||||||
private val legacyPlaylists = MutableLiveData<List<Playlist>>()
|
private val legacyPlaylists = MutableLiveData<List<Playlist>>()
|
||||||
private val genres = MutableLiveData<List<Genre>>()
|
private val genres = MutableLiveData<List<Genre>>()
|
||||||
private val searchResults = MutableLiveData<List<Any>>()
|
private val searchResults = MutableLiveData<List<Any>>()
|
||||||
private val fabMargin = MutableLiveData<Int>(0)
|
private val fabMargin = MutableLiveData(0)
|
||||||
val paletteColor: LiveData<Int> = _paletteColor
|
val paletteColor: LiveData<Int> = _paletteColor
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -227,7 +227,7 @@ class LibraryViewModel(
|
||||||
repository.deleteRoomPlaylist(playlists)
|
repository.deleteRoomPlaylist(playlists)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun albumById(id: Long) = repository.albumById(id)
|
fun albumById(id: Long) = repository.albumById(id)
|
||||||
suspend fun artistById(id: Long) = repository.artistById(id)
|
suspend fun artistById(id: Long) = repository.artistById(id)
|
||||||
suspend fun favoritePlaylist() = repository.favoritePlaylist()
|
suspend fun favoritePlaylist() = repository.favoritePlaylist()
|
||||||
suspend fun isFavoriteSong(song: SongEntity) = repository.isFavoriteSong(song)
|
suspend fun isFavoriteSong(song: SongEntity) = repository.isFavoriteSong(song)
|
||||||
|
|
|
@ -405,9 +405,8 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
binding.albumCoverContainer,
|
binding.albumCoverContainer,
|
||||||
"${getString(R.string.transition_album_art)}_${album.id}"
|
"${getString(R.string.transition_album_art)}_${album.id}"
|
||||||
)
|
)
|
||||||
startActivityForResult(
|
startActivity(
|
||||||
intent,
|
intent, options.toBundle()
|
||||||
TAG_EDITOR_REQUEST, options.toBundle()
|
|
||||||
)
|
)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -499,8 +498,4 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
_binding = null
|
_binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val TAG_EDITOR_REQUEST = 9002
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ class BackupFragment : Fragment(R.layout.fragment_backup), BackupAdapter.BackupC
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkIsEmpty() {
|
private fun checkIsEmpty() {
|
||||||
val isEmpty = backupAdapter!!.itemCount == 0
|
val isEmpty = backupAdapter?.itemCount == 0
|
||||||
binding.backupTitle.isVisible = !isEmpty
|
binding.backupTitle.isVisible = !isEmpty
|
||||||
binding.backupRecyclerview.isVisible = !isEmpty
|
binding.backupRecyclerview.isVisible = !isEmpty
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ import code.name.monkey.retromusic.adapter.StorageAdapter
|
||||||
import code.name.monkey.retromusic.adapter.StorageClickListener
|
import code.name.monkey.retromusic.adapter.StorageClickListener
|
||||||
import code.name.monkey.retromusic.databinding.FragmentFolderBinding
|
import code.name.monkey.retromusic.databinding.FragmentFolderBinding
|
||||||
import code.name.monkey.retromusic.extensions.drawNextToNavbar
|
import code.name.monkey.retromusic.extensions.drawNextToNavbar
|
||||||
import code.name.monkey.retromusic.extensions.navigate
|
|
||||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||||
import code.name.monkey.retromusic.fragments.folder.FoldersFragment.ListPathsAsyncTask.OnPathsListedCallback
|
import code.name.monkey.retromusic.fragments.folder.FoldersFragment.ListPathsAsyncTask.OnPathsListedCallback
|
||||||
|
@ -725,9 +724,10 @@ class FoldersFragment : AbsMainActivityFragment(R.layout.fragment_folder),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ListingFilesDialogAsyncTask<Params, Progress, Result> :
|
abstract class ListingFilesDialogAsyncTask<Params, Progress, Result> internal constructor(
|
||||||
DialogAsyncTask<Params, Progress, Result> {
|
context: Context?
|
||||||
internal constructor(context: Context?) : super(context)
|
) :
|
||||||
|
DialogAsyncTask<Params, Progress, Result>(context) {
|
||||||
|
|
||||||
override fun createDialog(context: Context): Dialog {
|
override fun createDialog(context: Context): Dialog {
|
||||||
return MaterialAlertDialogBuilder(context)
|
return MaterialAlertDialogBuilder(context)
|
||||||
|
|
|
@ -162,30 +162,26 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(R.layout.fragment_mini_p
|
||||||
|
|
||||||
class FlingPlayBackController(context: Context) : View.OnTouchListener {
|
class FlingPlayBackController(context: Context) : View.OnTouchListener {
|
||||||
|
|
||||||
private var flingPlayBackController: GestureDetector
|
private var flingPlayBackController = GestureDetector(context,
|
||||||
|
object : GestureDetector.SimpleOnGestureListener() {
|
||||||
init {
|
override fun onFling(
|
||||||
flingPlayBackController = GestureDetector(context,
|
e1: MotionEvent,
|
||||||
object : GestureDetector.SimpleOnGestureListener() {
|
e2: MotionEvent,
|
||||||
override fun onFling(
|
velocityX: Float,
|
||||||
e1: MotionEvent,
|
velocityY: Float
|
||||||
e2: MotionEvent,
|
): Boolean {
|
||||||
velocityX: Float,
|
if (abs(velocityX) > abs(velocityY)) {
|
||||||
velocityY: Float
|
if (velocityX < 0) {
|
||||||
): Boolean {
|
MusicPlayerRemote.playNextSong()
|
||||||
if (abs(velocityX) > abs(velocityY)) {
|
return true
|
||||||
if (velocityX < 0) {
|
} else if (velocityX > 0) {
|
||||||
MusicPlayerRemote.playNextSong()
|
MusicPlayerRemote.playPreviousSong()
|
||||||
return true
|
return true
|
||||||
} else if (velocityX > 0) {
|
|
||||||
MusicPlayerRemote.playPreviousSong()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
})
|
return false
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
||||||
|
|
|
@ -32,6 +32,7 @@ import code.name.monkey.retromusic.databinding.FragmentPlayerAlbumCoverBinding
|
||||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.base.goToLyrics
|
||||||
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
|
||||||
import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics
|
import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics
|
||||||
|
@ -39,7 +40,6 @@ import code.name.monkey.retromusic.model.lyrics.Lyrics
|
||||||
import code.name.monkey.retromusic.transform.CarousalPagerTransformer
|
import code.name.monkey.retromusic.transform.CarousalPagerTransformer
|
||||||
import code.name.monkey.retromusic.transform.ParallaxPagerTransformer
|
import code.name.monkey.retromusic.transform.ParallaxPagerTransformer
|
||||||
import code.name.monkey.retromusic.util.LyricUtil
|
import code.name.monkey.retromusic.util.LyricUtil
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -214,7 +214,7 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(R.layout.fragment_playe
|
||||||
}
|
}
|
||||||
// Go to lyrics activity when clicked lyrics
|
// Go to lyrics activity when clicked lyrics
|
||||||
binding.playerLyricsLine2.setOnClickListener {
|
binding.playerLyricsLine2.setOnClickListener {
|
||||||
NavigationUtil.goToLyrics(requireActivity())
|
goToLyrics(requireActivity())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ class CirclePlayerFragment : AbsPlayerFragment(R.layout.fragment_circle_player),
|
||||||
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
|
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
|
||||||
private var audioVolumeObserver: AudioVolumeObserver? = null
|
private var audioVolumeObserver: AudioVolumeObserver? = null
|
||||||
|
|
||||||
private val audioManager: AudioManager?
|
private val audioManager: AudioManager
|
||||||
get() = requireContext().getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
get() = requireContext().getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||||
|
|
||||||
private var _binding: FragmentCirclePlayerBinding? = null
|
private var _binding: FragmentCirclePlayerBinding? = null
|
||||||
|
@ -239,7 +239,7 @@ class CirclePlayerFragment : AbsPlayerFragment(R.layout.fragment_circle_player),
|
||||||
|
|
||||||
override fun onProgressChanged(seekArc: SeekArc?, progress: Int, fromUser: Boolean) {
|
override fun onProgressChanged(seekArc: SeekArc?, progress: Int, fromUser: Boolean) {
|
||||||
val audioManager = audioManager
|
val audioManager = audioManager
|
||||||
audioManager?.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0)
|
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartTrackingTouch(seekArc: SeekArc?) {
|
override fun onStartTrackingTouch(seekArc: SeekArc?) {
|
||||||
|
|
|
@ -247,7 +247,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(R.layout.fragment_classic_player
|
||||||
updateQueue()
|
updateQueue()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun playerToolbar(): Toolbar? {
|
override fun playerToolbar(): Toolbar {
|
||||||
return binding.playerToolbar
|
return binding.playerToolbar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -316,7 +316,7 @@ class FullPlaybackControlsFragment :
|
||||||
|
|
||||||
fun updateIsFavorite(animate: Boolean = false) {
|
fun updateIsFavorite(animate: Boolean = false) {
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val playlist: PlaylistEntity? = libraryViewModel.favoritePlaylist()
|
val playlist: PlaylistEntity = libraryViewModel.favoritePlaylist()
|
||||||
if (playlist != null) {
|
if (playlist != null) {
|
||||||
val song: SongEntity =
|
val song: SongEntity =
|
||||||
MusicPlayerRemote.currentSong.toSongEntity(playlist.playListId)
|
MusicPlayerRemote.currentSong.toSongEntity(playlist.playListId)
|
||||||
|
@ -327,7 +327,7 @@ class FullPlaybackControlsFragment :
|
||||||
} else {
|
} else {
|
||||||
if (isFavorite) R.drawable.ic_favorite else R.drawable.ic_favorite_border
|
if (isFavorite) R.drawable.ic_favorite else R.drawable.ic_favorite_border
|
||||||
}
|
}
|
||||||
val drawable: Drawable? = RetroUtil.getTintedVectorDrawable(
|
val drawable: Drawable = RetroUtil.getTintedVectorDrawable(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
icon,
|
icon,
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
|
@ -347,7 +347,7 @@ class FullPlaybackControlsFragment :
|
||||||
|
|
||||||
private fun toggleFavorite(song: Song) {
|
private fun toggleFavorite(song: Song) {
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val playlist: PlaylistEntity? = libraryViewModel.favoritePlaylist()
|
val playlist: PlaylistEntity = libraryViewModel.favoritePlaylist()
|
||||||
if (playlist != null) {
|
if (playlist != null) {
|
||||||
val songEntity = song.toSongEntity(playlist.playListId)
|
val songEntity = song.toSongEntity(playlist.playListId)
|
||||||
val isFavorite = libraryViewModel.isFavoriteSong(songEntity).isNotEmpty()
|
val isFavorite = libraryViewModel.isFavoriteSong(songEntity).isNotEmpty()
|
||||||
|
|
|
@ -281,7 +281,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
|
|
||||||
private fun updateIsFavoriteIcon(animate: Boolean = false) {
|
private fun updateIsFavoriteIcon(animate: Boolean = false) {
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
val playlist: PlaylistEntity? = libraryViewModel.favoritePlaylist()
|
val playlist: PlaylistEntity = libraryViewModel.favoritePlaylist()
|
||||||
if (playlist != null) {
|
if (playlist != null) {
|
||||||
val song: SongEntity =
|
val song: SongEntity =
|
||||||
MusicPlayerRemote.currentSong.toSongEntity(playlist.playListId)
|
MusicPlayerRemote.currentSong.toSongEntity(playlist.playListId)
|
||||||
|
|
|
@ -26,7 +26,7 @@ object M3UWriter : M3UConstants {
|
||||||
fun write(
|
fun write(
|
||||||
dir: File,
|
dir: File,
|
||||||
playlist: Playlist
|
playlist: Playlist
|
||||||
): File? {
|
): File {
|
||||||
if (!dir.exists()) dir.mkdirs()
|
if (!dir.exists()) dir.mkdirs()
|
||||||
val file = File(dir, playlist.name + "." + M3UConstants.EXTENSION)
|
val file = File(dir, playlist.name + "." + M3UConstants.EXTENSION)
|
||||||
val songs = playlist.getSongs()
|
val songs = playlist.getSongs()
|
||||||
|
|
|
@ -16,6 +16,7 @@ package code.name.monkey.retromusic.helper
|
||||||
|
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Message
|
import android.os.Message
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
class MusicProgressViewUpdateHelper : Handler {
|
class MusicProgressViewUpdateHelper : Handler {
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ class MusicProgressViewUpdateHelper : Handler {
|
||||||
|
|
||||||
val remainingMillis = intervalPlaying - progressMillis % intervalPlaying
|
val remainingMillis = intervalPlaying - progressMillis % intervalPlaying
|
||||||
|
|
||||||
return Math.max(MIN_INTERVAL, remainingMillis)
|
return max(MIN_INTERVAL, remainingMillis)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun queueNextRefresh(delay: Long) {
|
private fun queueNextRefresh(delay: Long) {
|
||||||
|
|
|
@ -134,7 +134,7 @@ class SortOrder {
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
/* Artist song sort order A-Z */
|
/* Artist song sort order A-Z */
|
||||||
const val SONG_A_Z = MediaStore.Audio.Media.DEFAULT_SORT_ORDER
|
private const val SONG_A_Z = MediaStore.Audio.Media.DEFAULT_SORT_ORDER
|
||||||
|
|
||||||
/* Artist song sort order Z-A */
|
/* Artist song sort order Z-A */
|
||||||
const val SONG_Z_A = "$SONG_A_Z DESC"
|
const val SONG_Z_A = "$SONG_A_Z DESC"
|
||||||
|
|
|
@ -76,8 +76,8 @@ public class StackBlur {
|
||||||
original.getPixels(currentPixels, 0, w, 0, 0, w, h);
|
original.getPixels(currentPixels, 0, w, 0, 0, w, h);
|
||||||
int cores = EXECUTOR_THREADS;
|
int cores = EXECUTOR_THREADS;
|
||||||
|
|
||||||
ArrayList<BlurTask> horizontal = new ArrayList<BlurTask>(cores);
|
ArrayList<BlurTask> horizontal = new ArrayList<>(cores);
|
||||||
ArrayList<BlurTask> vertical = new ArrayList<BlurTask>(cores);
|
ArrayList<BlurTask> vertical = new ArrayList<>(cores);
|
||||||
for (int i = 0; i < cores; i++) {
|
for (int i = 0; i < cores; i++) {
|
||||||
horizontal.add(new BlurTask(currentPixels, w, h, (int) radius, cores, i, 1));
|
horizontal.add(new BlurTask(currentPixels, w, h, (int) radius, cores, i, 1));
|
||||||
vertical.add(new BlurTask(currentPixels, w, h, (int) radius, cores, i, 2));
|
vertical.add(new BlurTask(currentPixels, w, h, (int) radius, cores, i, 2));
|
||||||
|
@ -158,7 +158,7 @@ public class StackBlur {
|
||||||
for (x = 0; x < w; x++) {
|
for (x = 0; x < w; x++) {
|
||||||
src[dst_i] =
|
src[dst_i] =
|
||||||
(int)
|
(int)
|
||||||
((src[dst_i] & 0xFFFFFFFF)
|
((src[dst_i])
|
||||||
| ((((sum_r * mul_sum) >>> shr_sum) & 0xff) << 16)
|
| ((((sum_r * mul_sum) >>> shr_sum) & 0xff) << 16)
|
||||||
| ((((sum_g * mul_sum) >>> shr_sum) & 0xff) << 8)
|
| ((((sum_g * mul_sum) >>> shr_sum) & 0xff) << 8)
|
||||||
| ((((sum_b * mul_sum) >>> shr_sum) & 0xff)));
|
| ((((sum_b * mul_sum) >>> shr_sum) & 0xff)));
|
||||||
|
@ -245,7 +245,7 @@ public class StackBlur {
|
||||||
for (y = 0; y < h; y++) {
|
for (y = 0; y < h; y++) {
|
||||||
src[dst_i] =
|
src[dst_i] =
|
||||||
(int)
|
(int)
|
||||||
((src[dst_i] & 0xFFFFFFFF)
|
((src[dst_i])
|
||||||
| ((((sum_r * mul_sum) >>> shr_sum) & 0xff) << 16)
|
| ((((sum_r * mul_sum) >>> shr_sum) & 0xff) << 16)
|
||||||
| ((((sum_g * mul_sum) >>> shr_sum) & 0xff) << 8)
|
| ((((sum_g * mul_sum) >>> shr_sum) & 0xff) << 8)
|
||||||
| ((((sum_b * mul_sum) >>> shr_sum) & 0xff)));
|
| ((((sum_b * mul_sum) >>> shr_sum) & 0xff)));
|
||||||
|
|
|
@ -1,138 +0,0 @@
|
||||||
package code.name.monkey.retromusic.lyrics;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Desc : 歌词解析 Author : Lauzy Date : 2017/10/13 Blog : http://www.jianshu.com/u/e76853f863a9 Email :
|
|
||||||
* freedompaladin@gmail.com
|
|
||||||
*/
|
|
||||||
public class LrcHelper {
|
|
||||||
|
|
||||||
private static final String CHARSET = "utf-8";
|
|
||||||
// [03:56.00][03:18.00][02:06.00][01:07.00]原谅我这一生不羁放纵爱自由
|
|
||||||
private static final String LINE_REGEX = "((\\[\\d{2}:\\d{2}\\.\\d{2}])+)(.*)";
|
|
||||||
private static final String TIME_REGEX = "\\[(\\d{2}):(\\d{2})\\.(\\d{2})]";
|
|
||||||
|
|
||||||
public static List<Lrc> parseLrcFromAssets(Context context, String fileName) {
|
|
||||||
try {
|
|
||||||
return parseInputStream(context.getResources().getAssets().open(fileName));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Lrc> parseLrcFromFile(File file) {
|
|
||||||
try {
|
|
||||||
return parseInputStream(new FileInputStream(file));
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<Lrc> parseInputStream(InputStream inputStream) {
|
|
||||||
List<Lrc> lrcs = new ArrayList<>();
|
|
||||||
InputStreamReader isr = null;
|
|
||||||
BufferedReader br = null;
|
|
||||||
try {
|
|
||||||
isr = new InputStreamReader(inputStream, CHARSET);
|
|
||||||
br = new BufferedReader(isr);
|
|
||||||
String line;
|
|
||||||
while ((line = br.readLine()) != null) {
|
|
||||||
List<Lrc> lrcList = parseLrc(line);
|
|
||||||
if (lrcList != null && lrcList.size() != 0) {
|
|
||||||
lrcs.addAll(lrcList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sortLrcs(lrcs);
|
|
||||||
return lrcs;
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (isr != null) {
|
|
||||||
isr.close();
|
|
||||||
}
|
|
||||||
if (br != null) {
|
|
||||||
br.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lrcs;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void sortLrcs(List<Lrc> lrcs) {
|
|
||||||
Collections.sort(
|
|
||||||
lrcs,
|
|
||||||
new Comparator<Lrc>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Lrc o1, Lrc o2) {
|
|
||||||
return (int) (o1.getTime() - o2.getTime());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<Lrc> parseLrc(String lrcLine) {
|
|
||||||
if (lrcLine.trim().isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
List<Lrc> lrcs = new ArrayList<>();
|
|
||||||
Matcher matcher = Pattern.compile(LINE_REGEX).matcher(lrcLine);
|
|
||||||
if (!matcher.matches()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String time = matcher.group(1);
|
|
||||||
String content = matcher.group(3);
|
|
||||||
Matcher timeMatcher = Pattern.compile(TIME_REGEX).matcher(time);
|
|
||||||
|
|
||||||
while (timeMatcher.find()) {
|
|
||||||
String min = timeMatcher.group(1);
|
|
||||||
String sec = timeMatcher.group(2);
|
|
||||||
String mil = timeMatcher.group(3);
|
|
||||||
Lrc lrc = new Lrc();
|
|
||||||
if (content != null && content.length() != 0) {
|
|
||||||
lrc.setTime(
|
|
||||||
Long.parseLong(min) * 60 * 1000
|
|
||||||
+ Long.parseLong(sec) * 1000
|
|
||||||
+ Long.parseLong(mil) * 10);
|
|
||||||
lrc.setText(content);
|
|
||||||
lrcs.add(lrc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lrcs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String formatTime(long time) {
|
|
||||||
int min = (int) (time / 60000);
|
|
||||||
int sec = (int) (time / 1000 % 60);
|
|
||||||
return adjustFormat(min) + ":" + adjustFormat(sec);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String adjustFormat(int time) {
|
|
||||||
if (time < 10) {
|
|
||||||
return "0" + time;
|
|
||||||
}
|
|
||||||
return time + "";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -78,8 +78,8 @@ public abstract class CustomFragmentStatePagerAdapter extends PagerAdapter {
|
||||||
private final FragmentManager mFragmentManager;
|
private final FragmentManager mFragmentManager;
|
||||||
private FragmentTransaction mCurTransaction = null;
|
private FragmentTransaction mCurTransaction = null;
|
||||||
|
|
||||||
private final ArrayList<Fragment.SavedState> mSavedState = new ArrayList<Fragment.SavedState>();
|
private final ArrayList<Fragment.SavedState> mSavedState = new ArrayList<>();
|
||||||
private final ArrayList<Fragment> mFragments = new ArrayList<Fragment>();
|
private final ArrayList<Fragment> mFragments = new ArrayList<>();
|
||||||
private Fragment mCurrentPrimaryItem = null;
|
private Fragment mCurrentPrimaryItem = null;
|
||||||
|
|
||||||
public CustomFragmentStatePagerAdapter(FragmentManager fm) {
|
public CustomFragmentStatePagerAdapter(FragmentManager fm) {
|
||||||
|
@ -212,8 +212,8 @@ public abstract class CustomFragmentStatePagerAdapter extends PagerAdapter {
|
||||||
mSavedState.clear();
|
mSavedState.clear();
|
||||||
mFragments.clear();
|
mFragments.clear();
|
||||||
if (fss != null) {
|
if (fss != null) {
|
||||||
for (int i = 0; i < fss.length; i++) {
|
for (Parcelable parcelable : fss) {
|
||||||
mSavedState.add((Fragment.SavedState) fss[i]);
|
mSavedState.add((Fragment.SavedState) parcelable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Iterable<String> keys = bundle.keySet();
|
Iterable<String> keys = bundle.keySet();
|
||||||
|
|
|
@ -148,7 +148,7 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(),
|
||||||
return view === instace
|
return view === instace
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getPageTitle(position: Int): CharSequence? {
|
override fun getPageTitle(position: Int): CharSequence {
|
||||||
return context.getString(values()[position].titleRes)
|
return context.getString(values()[position].titleRes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ private class NowPlayingScreenAdapter(private val context: Context) : PagerAdapt
|
||||||
return view === instance
|
return view === instance
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getPageTitle(position: Int): CharSequence? {
|
override fun getPageTitle(position: Int): CharSequence {
|
||||||
return context.getString(values()[position].titleRes)
|
return context.getString(values()[position].titleRes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,30 +84,23 @@ public class HistoryStore extends SQLiteOpenHelper {
|
||||||
database.insert(RecentStoreColumns.NAME, null, values);
|
database.insert(RecentStoreColumns.NAME, null, values);
|
||||||
|
|
||||||
// if our db is too large, delete the extra items
|
// if our db is too large, delete the extra items
|
||||||
Cursor oldest = null;
|
try (Cursor oldest = database.query(
|
||||||
try {
|
RecentStoreColumns.NAME,
|
||||||
oldest =
|
new String[]{RecentStoreColumns.TIME_PLAYED},
|
||||||
database.query(
|
null,
|
||||||
RecentStoreColumns.NAME,
|
null,
|
||||||
new String[] {RecentStoreColumns.TIME_PLAYED},
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
RecentStoreColumns.TIME_PLAYED + " ASC")) {
|
||||||
null,
|
|
||||||
null,
|
|
||||||
RecentStoreColumns.TIME_PLAYED + " ASC");
|
|
||||||
|
|
||||||
if (oldest != null && oldest.getCount() > MAX_ITEMS_IN_DB) {
|
if (oldest != null && oldest.getCount() > MAX_ITEMS_IN_DB) {
|
||||||
oldest.moveToPosition(oldest.getCount() - MAX_ITEMS_IN_DB);
|
oldest.moveToPosition(oldest.getCount() - MAX_ITEMS_IN_DB);
|
||||||
long timeOfRecordToKeep = oldest.getLong(0);
|
long timeOfRecordToKeep = oldest.getLong(0);
|
||||||
|
|
||||||
database.delete(
|
database.delete(
|
||||||
RecentStoreColumns.NAME,
|
RecentStoreColumns.NAME,
|
||||||
RecentStoreColumns.TIME_PLAYED + " < ?",
|
RecentStoreColumns.TIME_PLAYED + " < ?",
|
||||||
new String[] {String.valueOf(timeOfRecordToKeep)});
|
new String[]{String.valueOf(timeOfRecordToKeep)});
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (oldest != null) {
|
|
||||||
oldest.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -40,14 +40,11 @@ public class SongPlayCountStore extends SQLiteOpenHelper {
|
||||||
@NonNull
|
@NonNull
|
||||||
private static final Interpolator sInterpolator = new AccelerateInterpolator(1.5f);
|
private static final Interpolator sInterpolator = new AccelerateInterpolator(1.5f);
|
||||||
// how high to multiply the interpolation curve
|
// how high to multiply the interpolation curve
|
||||||
@SuppressWarnings("FieldCanBeLocal")
|
|
||||||
private static final int INTERPOLATOR_HEIGHT = 50;
|
private static final int INTERPOLATOR_HEIGHT = 50;
|
||||||
|
|
||||||
// how high the base value is. The ratio of the Height to Base is what really matters
|
// how high the base value is. The ratio of the Height to Base is what really matters
|
||||||
@SuppressWarnings("FieldCanBeLocal")
|
|
||||||
private static final int INTERPOLATOR_BASE = 25;
|
private static final int INTERPOLATOR_BASE = 25;
|
||||||
|
|
||||||
@SuppressWarnings("FieldCanBeLocal")
|
|
||||||
private static final int ONE_WEEK_IN_MS = 1000 * 60 * 60 * 24 * 7;
|
private static final int ONE_WEEK_IN_MS = 1000 * 60 * 60 * 24 * 7;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -257,7 +254,7 @@ public class SongPlayCountStore extends SQLiteOpenHelper {
|
||||||
for (int i = 0; i < NUM_WEEKS - weekDiff; i++) {
|
for (int i = 0; i < NUM_WEEKS - weekDiff; i++) {
|
||||||
playCounts[i + weekDiff] = cursor.getInt(getColumnIndexForWeek(i));
|
playCounts[i + weekDiff] = cursor.getInt(getColumnIndexForWeek(i));
|
||||||
}
|
}
|
||||||
} else if (weekDiff < 0) {
|
} else {
|
||||||
// time is shifted backwards (by user) - nor typical behavior but we
|
// time is shifted backwards (by user) - nor typical behavior but we
|
||||||
// will still handle it
|
// will still handle it
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ class RealTopPlayedRepository(
|
||||||
val notRecentlyPlayedSongs = songRepository.songs(
|
val notRecentlyPlayedSongs = songRepository.songs(
|
||||||
makeNotRecentTracksCursorAndClearUpDatabase()
|
makeNotRecentTracksCursorAndClearUpDatabase()
|
||||||
)
|
)
|
||||||
allSongs.removeAll(playedSongs)
|
allSongs.removeAll(playedSongs.toSet())
|
||||||
allSongs.addAll(notRecentlyPlayedSongs)
|
allSongs.addAll(notRecentlyPlayedSongs)
|
||||||
return allSongs
|
return allSongs
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,6 @@ public class MusicService extends MediaBrowserServiceCompat
|
||||||
private List<Song> originalPlayingQueue = new ArrayList<>();
|
private List<Song> originalPlayingQueue = new ArrayList<>();
|
||||||
private List<Song> playingQueue = new ArrayList<>();
|
private List<Song> playingQueue = new ArrayList<>();
|
||||||
private boolean pausedByTransientLossOfFocus;
|
private boolean pausedByTransientLossOfFocus;
|
||||||
private AudioVolumeObserver audioVolumeObserver = null;
|
|
||||||
|
|
||||||
private final BroadcastReceiver becomingNoisyReceiver =
|
private final BroadcastReceiver becomingNoisyReceiver =
|
||||||
new BroadcastReceiver() {
|
new BroadcastReceiver() {
|
||||||
|
@ -453,7 +452,7 @@ public class MusicService extends MediaBrowserServiceCompat
|
||||||
.registerContentObserver(
|
.registerContentObserver(
|
||||||
MediaStore.Audio.Playlists.INTERNAL_CONTENT_URI, true, mediaStoreObserver);
|
MediaStore.Audio.Playlists.INTERNAL_CONTENT_URI, true, mediaStoreObserver);
|
||||||
|
|
||||||
audioVolumeObserver = new AudioVolumeObserver(this);
|
AudioVolumeObserver audioVolumeObserver = new AudioVolumeObserver(this);
|
||||||
audioVolumeObserver.register(AudioManager.STREAM_MUSIC, this);
|
audioVolumeObserver.register(AudioManager.STREAM_MUSIC, this);
|
||||||
|
|
||||||
PreferenceUtil.INSTANCE.registerOnSharedPreferenceChangedListener(this);
|
PreferenceUtil.INSTANCE.registerOnSharedPreferenceChangedListener(this);
|
||||||
|
|
|
@ -38,6 +38,6 @@ class ThrottledSeekHandler(
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// milliseconds to throttle before calling run() to aggregate events
|
// milliseconds to throttle before calling run() to aggregate events
|
||||||
private val THROTTLE: Long = 500
|
private const val THROTTLE: Long = 500
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -54,7 +54,7 @@ class PlayingNotificationImpl : PlayingNotification(), KoinComponent {
|
||||||
stopped = false
|
stopped = false
|
||||||
GlobalScope.launch {
|
GlobalScope.launch {
|
||||||
val song = service.currentSong
|
val song = service.currentSong
|
||||||
val playlist: PlaylistEntity? = MusicUtil.repository.favoritePlaylist()
|
val playlist: PlaylistEntity = MusicUtil.repository.favoritePlaylist()
|
||||||
val isPlaying = service.isPlaying
|
val isPlaying = service.isPlaying
|
||||||
val isFavorite = if (playlist != null) {
|
val isFavorite = if (playlist != null) {
|
||||||
val songEntity = song.toSongEntity(playlist.playListId)
|
val songEntity = song.toSongEntity(playlist.playListId)
|
||||||
|
|
|
@ -183,21 +183,21 @@ class PlayingNotificationOreo : PlayingNotification() {
|
||||||
service,
|
service,
|
||||||
R.drawable.ic_close,
|
R.drawable.ic_close,
|
||||||
primary
|
primary
|
||||||
)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
|
), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
|
||||||
)
|
)
|
||||||
val prev = createBitmap(
|
val prev = createBitmap(
|
||||||
RetroUtil.getTintedVectorDrawable(
|
RetroUtil.getTintedVectorDrawable(
|
||||||
service,
|
service,
|
||||||
R.drawable.ic_skip_previous_round_white_32dp,
|
R.drawable.ic_skip_previous_round_white_32dp,
|
||||||
primary
|
primary
|
||||||
)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
|
), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
|
||||||
)
|
)
|
||||||
val next = createBitmap(
|
val next = createBitmap(
|
||||||
RetroUtil.getTintedVectorDrawable(
|
RetroUtil.getTintedVectorDrawable(
|
||||||
service,
|
service,
|
||||||
R.drawable.ic_skip_next_round_white_32dp,
|
R.drawable.ic_skip_next_round_white_32dp,
|
||||||
primary
|
primary
|
||||||
)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
|
), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
|
||||||
)
|
)
|
||||||
val playPause = createBitmap(
|
val playPause = createBitmap(
|
||||||
RetroUtil.getTintedVectorDrawable(
|
RetroUtil.getTintedVectorDrawable(
|
||||||
|
@ -206,7 +206,7 @@ class PlayingNotificationOreo : PlayingNotification() {
|
||||||
R.drawable.ic_pause_white_48dp
|
R.drawable.ic_pause_white_48dp
|
||||||
else
|
else
|
||||||
R.drawable.ic_play_arrow_white_48dp, primary
|
R.drawable.ic_play_arrow_white_48dp, primary
|
||||||
)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
|
), NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
|
||||||
)
|
)
|
||||||
|
|
||||||
notificationLayout.setTextColor(R.id.title, primary)
|
notificationLayout.setTextColor(R.id.title, primary)
|
||||||
|
@ -233,7 +233,7 @@ class PlayingNotificationOreo : PlayingNotification() {
|
||||||
service,
|
service,
|
||||||
R.drawable.ic_notification,
|
R.drawable.ic_notification,
|
||||||
secondary
|
secondary
|
||||||
)!!, 0.6f
|
), 0.6f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
notificationLayoutBig.setImageViewBitmap(
|
notificationLayoutBig.setImageViewBitmap(
|
||||||
|
@ -243,7 +243,7 @@ class PlayingNotificationOreo : PlayingNotification() {
|
||||||
service,
|
service,
|
||||||
R.drawable.ic_notification,
|
R.drawable.ic_notification,
|
||||||
secondary
|
secondary
|
||||||
)!!, 0.6f
|
), 0.6f
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -16,26 +16,32 @@ package code.name.monkey.retromusic.transform
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
class DepthTransformation : ViewPager.PageTransformer {
|
class DepthTransformation : ViewPager.PageTransformer {
|
||||||
override fun transformPage(page: View, position: Float) {
|
override fun transformPage(page: View, position: Float) {
|
||||||
if (position < -1) { // [-Infinity,-1)
|
when {
|
||||||
// This page is way off-screen to the left.
|
position < -1 -> { // [-Infinity,-1)
|
||||||
page.alpha = 0f
|
// This page is way off-screen to the left.
|
||||||
} else if (position <= 0) { // [-1,0]
|
page.alpha = 0f
|
||||||
page.alpha = 1f
|
}
|
||||||
page.translationX = 0f
|
position <= 0 -> { // [-1,0]
|
||||||
page.scaleX = 1f
|
page.alpha = 1f
|
||||||
page.scaleY = 1f
|
page.translationX = 0f
|
||||||
} else if (position <= 1) { // (0,1]
|
page.scaleX = 1f
|
||||||
page.translationX = -position * page.width
|
page.scaleY = 1f
|
||||||
page.alpha = 1 - Math.abs(position)
|
}
|
||||||
page.scaleX = 1 - Math.abs(position)
|
position <= 1 -> { // (0,1]
|
||||||
page.scaleY = 1 - Math.abs(position)
|
page.translationX = -position * page.width
|
||||||
} else { // (1,+Infinity]
|
page.alpha = 1 - abs(position)
|
||||||
// This page is way off-screen to the right.
|
page.scaleX = 1 - abs(position)
|
||||||
page.alpha = 0f
|
page.scaleY = 1 - abs(position)
|
||||||
|
}
|
||||||
|
else -> { // (1,+Infinity]
|
||||||
|
// This page is way off-screen to the right.
|
||||||
|
page.alpha = 0f
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,6 +16,7 @@ package code.name.monkey.retromusic.transform
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
class HorizontalFlipTransformation : ViewPager.PageTransformer {
|
class HorizontalFlipTransformation : ViewPager.PageTransformer {
|
||||||
override fun transformPage(page: View, position: Float) {
|
override fun transformPage(page: View, position: Float) {
|
||||||
|
@ -36,11 +37,11 @@ class HorizontalFlipTransformation : ViewPager.PageTransformer {
|
||||||
|
|
||||||
} else if (position <= 0) { // [-1,0]
|
} else if (position <= 0) { // [-1,0]
|
||||||
page.alpha = 1f
|
page.alpha = 1f
|
||||||
page.rotationX = 180 * (1 - Math.abs(position) + 1)
|
page.rotationX = 180 * (1 - abs(position) + 1)
|
||||||
|
|
||||||
} else if (position <= 1) { // (0,1]
|
} else if (position <= 1) { // (0,1]
|
||||||
page.alpha = 1f
|
page.alpha = 1f
|
||||||
page.rotationX = -180 * (1 - Math.abs(position) + 1)
|
page.rotationX = -180 * (1 - abs(position) + 1)
|
||||||
|
|
||||||
} else { // (1,+Infinity]
|
} else { // (1,+Infinity]
|
||||||
// This page is way off-screen to the right.
|
// This page is way off-screen to the right.
|
||||||
|
|
|
@ -16,6 +16,8 @@ package code.name.monkey.retromusic.transform
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
import kotlin.math.abs
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hemanth S (h4h13).
|
* @author Hemanth S (h4h13).
|
||||||
|
@ -33,7 +35,7 @@ class NormalPageTransformer : ViewPager.PageTransformer {
|
||||||
view.scaleY = 0.7f
|
view.scaleY = 0.7f
|
||||||
} else if (position <= 1) { // [-1,1]
|
} else if (position <= 1) { // [-1,1]
|
||||||
// Modify the default slide transition to shrink the page as well
|
// Modify the default slide transition to shrink the page as well
|
||||||
val scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position))
|
val scaleFactor = max(MIN_SCALE, 1 - abs(position))
|
||||||
val vertMargin = pageHeight * (1 - scaleFactor) / 2
|
val vertMargin = pageHeight * (1 - scaleFactor) / 2
|
||||||
val horzMargin = pageWidth * (1 - scaleFactor) / 2
|
val horzMargin = pageWidth * (1 - scaleFactor) / 2
|
||||||
if (position < 0) {
|
if (position < 0) {
|
||||||
|
@ -57,7 +59,7 @@ class NormalPageTransformer : ViewPager.PageTransformer {
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val MIN_SCALE = 0.85f
|
private const val MIN_SCALE = 0.85f
|
||||||
private val MIN_ALPHA = 0.5f
|
private const val MIN_ALPHA = 0.5f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ package code.name.monkey.retromusic.transform
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
class VerticalFlipTransformation : ViewPager.PageTransformer {
|
class VerticalFlipTransformation : ViewPager.PageTransformer {
|
||||||
override fun transformPage(page: View, position: Float) {
|
override fun transformPage(page: View, position: Float) {
|
||||||
|
@ -36,11 +37,11 @@ class VerticalFlipTransformation : ViewPager.PageTransformer {
|
||||||
|
|
||||||
} else if (position <= 0) { // [-1,0]
|
} else if (position <= 0) { // [-1,0]
|
||||||
page.alpha = 1f
|
page.alpha = 1f
|
||||||
page.rotationY = 180 * (1 - Math.abs(position) + 1)
|
page.rotationY = 180 * (1 - abs(position) + 1)
|
||||||
|
|
||||||
} else if (position <= 1) { // (0,1]
|
} else if (position <= 1) { // (0,1]
|
||||||
page.alpha = 1f
|
page.alpha = 1f
|
||||||
page.rotationY = -180 * (1 - Math.abs(position) + 1)
|
page.rotationY = -180 * (1 - abs(position) + 1)
|
||||||
|
|
||||||
} else { // (1,+Infinity]
|
} else { // (1,+Infinity]
|
||||||
// This page is way off-screen to the right.
|
// This page is way off-screen to the right.
|
||||||
|
|
|
@ -348,7 +348,7 @@ object MusicUtil : KoinComponent {
|
||||||
val repository = get<Repository>()
|
val repository = get<Repository>()
|
||||||
fun toggleFavorite(context: Context, song: Song) {
|
fun toggleFavorite(context: Context, song: Song) {
|
||||||
GlobalScope.launch {
|
GlobalScope.launch {
|
||||||
val playlist: PlaylistEntity? = repository.favoritePlaylist()
|
val playlist: PlaylistEntity = repository.favoritePlaylist()
|
||||||
if (playlist != null) {
|
if (playlist != null) {
|
||||||
val songEntity = song.toSongEntity(playlist.playListId)
|
val songEntity = song.toSongEntity(playlist.playListId)
|
||||||
val isFavorite = repository.isFavoriteSong(songEntity).isNotEmpty()
|
val isFavorite = repository.isFavoriteSong(songEntity).isNotEmpty()
|
||||||
|
@ -529,7 +529,7 @@ object MusicUtil : KoinComponent {
|
||||||
val pendingIntent = MediaStore.createDeleteRequest(activity.contentResolver, songs.map {
|
val pendingIntent = MediaStore.createDeleteRequest(activity.contentResolver, songs.map {
|
||||||
getSongFileUri(it.id)
|
getSongFileUri(it.id)
|
||||||
})
|
})
|
||||||
activity.startIntentSenderForResult(pendingIntent.intentSender, 45, null, 0, 0, 0, null);
|
activity.startIntentSenderForResult(pendingIntent.intentSender, 45, null, 0, 0, 0, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun songByGenre(genreId: Long): Song {
|
fun songByGenre(genreId: Long): Song {
|
||||||
|
|
|
@ -20,12 +20,10 @@ import android.content.Intent
|
||||||
import android.media.audiofx.AudioEffect
|
import android.media.audiofx.AudioEffect
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.navigation.findNavController
|
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.*
|
import code.name.monkey.retromusic.activities.*
|
||||||
import code.name.monkey.retromusic.activities.bugreport.BugReportActivity
|
import code.name.monkey.retromusic.activities.bugreport.BugReportActivity
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote.audioSessionId
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote.audioSessionId
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
|
||||||
|
|
||||||
object NavigationUtil {
|
object NavigationUtil {
|
||||||
fun bugReport(activity: Activity) {
|
fun bugReport(activity: Activity) {
|
||||||
|
@ -40,21 +38,6 @@ object NavigationUtil {
|
||||||
ActivityCompat.startActivity(activity, Intent(activity, LicenseActivity::class.java), null)
|
ActivityCompat.startActivity(activity, Intent(activity, LicenseActivity::class.java), null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun goToLyrics(activity: Activity) {
|
|
||||||
if (activity !is MainActivity) return
|
|
||||||
activity.apply {
|
|
||||||
//Hide Bottom Bar First, else Bottom Sheet doesn't collapse fully
|
|
||||||
setBottomNavVisibility(false)
|
|
||||||
if (getBottomSheetBehavior().state == BottomSheetBehavior.STATE_EXPANDED) {
|
|
||||||
collapsePanel()
|
|
||||||
}
|
|
||||||
|
|
||||||
findNavController(R.id.fragment_container).navigate(
|
|
||||||
R.id.lyrics_fragment
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun goToProVersion(context: Context) {
|
fun goToProVersion(context: Context) {
|
||||||
ActivityCompat.startActivity(context, Intent(context, PurchaseActivity::class.java), null)
|
ActivityCompat.startActivity(context, Intent(context, PurchaseActivity::class.java), null)
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,11 +208,11 @@ class PackageValidator(
|
||||||
private fun getSignature(packageInfo: PackageInfo): String? {
|
private fun getSignature(packageInfo: PackageInfo): String? {
|
||||||
// Security best practices dictate that an app should be signed with exactly one (1)
|
// Security best practices dictate that an app should be signed with exactly one (1)
|
||||||
// signature. Because of this, if there are multiple signatures, reject it.
|
// signature. Because of this, if there are multiple signatures, reject it.
|
||||||
if (packageInfo.signatures == null || packageInfo.signatures.size != 1) {
|
return if (packageInfo.signatures == null || packageInfo.signatures.size != 1) {
|
||||||
return null
|
null
|
||||||
} else {
|
} else {
|
||||||
val certificate = packageInfo.signatures[0].toByteArray()
|
val certificate = packageInfo.signatures[0].toByteArray()
|
||||||
return getSignatureSha256(certificate)
|
getSignatureSha256(certificate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ import java.util.List;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.db.PlaylistWithSongs;
|
import code.name.monkey.retromusic.db.PlaylistWithSongs;
|
||||||
import code.name.monkey.retromusic.helper.M3UConstants;
|
|
||||||
import code.name.monkey.retromusic.helper.M3UWriter;
|
import code.name.monkey.retromusic.helper.M3UWriter;
|
||||||
import code.name.monkey.retromusic.model.Playlist;
|
import code.name.monkey.retromusic.model.Playlist;
|
||||||
import code.name.monkey.retromusic.model.PlaylistSong;
|
import code.name.monkey.retromusic.model.PlaylistSong;
|
||||||
|
|
|
@ -188,7 +188,7 @@ public class RetroColorUtil {
|
||||||
|
|
||||||
public static int getDominantColor(Bitmap bitmap, int defaultFooterColor) {
|
public static int getDominantColor(Bitmap bitmap, int defaultFooterColor) {
|
||||||
List<Palette.Swatch> swatchesTemp = Palette.from(bitmap).generate().getSwatches();
|
List<Palette.Swatch> swatchesTemp = Palette.from(bitmap).generate().getSwatches();
|
||||||
List<Palette.Swatch> swatches = new ArrayList<Palette.Swatch>(swatchesTemp);
|
List<Palette.Swatch> swatches = new ArrayList<>(swatchesTemp);
|
||||||
Collections.sort(
|
Collections.sort(
|
||||||
swatches, (swatch1, swatch2) -> swatch2.getPopulation() - swatch1.getPopulation());
|
swatches, (swatch1, swatch2) -> swatch2.getPopulation() - swatch1.getPopulation());
|
||||||
return swatches.size() > 0 ? swatches.get(0).getRgb() : defaultFooterColor;
|
return swatches.size() > 0 ? swatches.get(0).getRgb() : defaultFooterColor;
|
||||||
|
|
|
@ -40,7 +40,7 @@ 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.vectordrawable.graphics.drawable.VectorDrawableCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
|
@ -127,14 +127,14 @@ public class RetroUtil {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@NonNull
|
||||||
public static Drawable getTintedVectorDrawable(
|
public static Drawable getTintedVectorDrawable(
|
||||||
@NonNull Context context, @DrawableRes int id, @ColorInt int color) {
|
@NonNull Context context, @DrawableRes int id, @ColorInt int color) {
|
||||||
return TintHelper.createTintedDrawable(
|
return TintHelper.createTintedDrawable(
|
||||||
getVectorDrawable(context.getResources(), id, context.getTheme()), color);
|
getVectorDrawable(context.getResources(), id, context.getTheme()), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@NonNull
|
||||||
public static Drawable getTintedVectorDrawable(
|
public static Drawable getTintedVectorDrawable(
|
||||||
@NonNull Resources res,
|
@NonNull Resources res,
|
||||||
@DrawableRes int resId,
|
@DrawableRes int resId,
|
||||||
|
@ -146,10 +146,7 @@ public class RetroUtil {
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Drawable getVectorDrawable(
|
public static Drawable getVectorDrawable(
|
||||||
@NonNull Resources res, @DrawableRes int resId, @Nullable Resources.Theme theme) {
|
@NonNull Resources res, @DrawableRes int resId, @Nullable Resources.Theme theme) {
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
return ResourcesCompat.getDrawable(res, resId, theme);
|
||||||
return res.getDrawable(resId, theme);
|
|
||||||
}
|
|
||||||
return VectorDrawableCompat.create(res, resId, theme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void hideSoftKeyboard(@Nullable Activity activity) {
|
public static void hideSoftKeyboard(@Nullable Activity activity) {
|
||||||
|
|
|
@ -75,11 +75,9 @@ public class MediaNotificationProcessor {
|
||||||
*/
|
*/
|
||||||
private static final int LIGHTNESS_TEXT_DIFFERENCE_DARK = -10;
|
private static final int LIGHTNESS_TEXT_DIFFERENCE_DARK = -10;
|
||||||
|
|
||||||
private static final String TAG = "ColorPicking";
|
|
||||||
private float[] mFilteredBackgroundHsl = null;
|
private float[] mFilteredBackgroundHsl = null;
|
||||||
private final Palette.Filter mBlackWhiteFilter =
|
private final Palette.Filter mBlackWhiteFilter =
|
||||||
(rgb, hsl) -> !isWhiteOrBlack(hsl);
|
(rgb, hsl) -> !isWhiteOrBlack(hsl);
|
||||||
private boolean mIsLowPriority;
|
|
||||||
private int backgroundColor;
|
private int backgroundColor;
|
||||||
private int secondaryTextColor;
|
private int secondaryTextColor;
|
||||||
private int primaryTextColor;
|
private int primaryTextColor;
|
||||||
|
@ -376,10 +374,6 @@ public class MediaNotificationProcessor {
|
||||||
return hslColor[2] >= WHITE_MIN_LIGHTNESS;
|
return hslColor[2] >= WHITE_MIN_LIGHTNESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsLowPriority(boolean isLowPriority) {
|
|
||||||
mIsLowPriority = isLowPriority;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensureColors(int backgroundColor, int mForegroundColor) {
|
private void ensureColors(int backgroundColor, int mForegroundColor) {
|
||||||
{
|
{
|
||||||
double backLum = NotificationColorUtil.calculateLuminance(backgroundColor);
|
double backLum = NotificationColorUtil.calculateLuminance(backgroundColor);
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class NotificationColorUtil {
|
||||||
|
|
||||||
private final ImageUtils mImageUtils = new ImageUtils();
|
private final ImageUtils mImageUtils = new ImageUtils();
|
||||||
private final WeakHashMap<Bitmap, Pair<Boolean, Integer>> mGrayscaleBitmapCache =
|
private final WeakHashMap<Bitmap, Pair<Boolean, Integer>> mGrayscaleBitmapCache =
|
||||||
new WeakHashMap<Bitmap, Pair<Boolean, Integer>>();
|
new WeakHashMap<>();
|
||||||
|
|
||||||
private final int mGrayscaleIconMaxSize; // @dimen/notification_large_icon_width (64dp)
|
private final int mGrayscaleIconMaxSize; // @dimen/notification_large_icon_width (64dp)
|
||||||
|
|
||||||
|
@ -831,11 +831,11 @@ public class NotificationColorUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int constrain(int amount, int low, int high) {
|
private static int constrain(int amount, int low, int high) {
|
||||||
return amount < low ? low : (amount > high ? high : amount);
|
return amount < low ? low : (Math.min(amount, high));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float constrain(float amount, float low, float high) {
|
private static float constrain(float amount, float low, float high) {
|
||||||
return amount < low ? low : (amount > high ? high : amount);
|
return amount < low ? low : (Math.min(amount, high));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double pivotXyzComponent(double component) {
|
private static double pivotXyzComponent(double component) {
|
||||||
|
|
|
@ -39,9 +39,7 @@ public class SeekArc extends View {
|
||||||
|
|
||||||
private static final String TAG = SeekArc.class.getSimpleName();
|
private static final String TAG = SeekArc.class.getSimpleName();
|
||||||
private static final int INVALID_PROGRESS_VALUE = -1;
|
private static final int INVALID_PROGRESS_VALUE = -1;
|
||||||
// The initial rotational offset -90 means we start at 12 o'clock
|
private Paint mArcPaint;
|
||||||
private final int mAngleOffset = -90;
|
|
||||||
private Paint mArcPaint;
|
|
||||||
// Internal variables
|
// Internal variables
|
||||||
private int mArcRadius = 0;
|
private int mArcRadius = 0;
|
||||||
private final RectF mArcRect = new RectF();
|
private final RectF mArcRect = new RectF();
|
||||||
|
@ -77,8 +75,7 @@ public class SeekArc extends View {
|
||||||
|
|
||||||
private int mThumbXPos;
|
private int mThumbXPos;
|
||||||
private int mThumbYPos;
|
private int mThumbYPos;
|
||||||
private double mTouchAngle;
|
private float mTouchIgnoreRadius;
|
||||||
private float mTouchIgnoreRadius;
|
|
||||||
/** Enable touch inside the SeekArc */
|
/** Enable touch inside the SeekArc */
|
||||||
private boolean mTouchInside = true;
|
private boolean mTouchInside = true;
|
||||||
|
|
||||||
|
@ -243,8 +240,8 @@ public class SeekArc extends View {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTouchInSide(boolean isEnabled) {
|
public void setTouchInSide(boolean isEnabled) {
|
||||||
int thumbHalfheight = (int) mThumb.getIntrinsicHeight() / 2;
|
int thumbHalfheight = mThumb.getIntrinsicHeight() / 2;
|
||||||
int thumbHalfWidth = (int) mThumb.getIntrinsicWidth() / 2;
|
int thumbHalfWidth = mThumb.getIntrinsicWidth() / 2;
|
||||||
mTouchInside = isEnabled;
|
mTouchInside = isEnabled;
|
||||||
if (mTouchInside) {
|
if (mTouchInside) {
|
||||||
mTouchIgnoreRadius = (float) mArcRadius / 4;
|
mTouchIgnoreRadius = (float) mArcRadius / 4;
|
||||||
|
@ -271,7 +268,9 @@ public class SeekArc extends View {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the arcs
|
// Draw the arcs
|
||||||
final int arcStart = mStartAngle + mAngleOffset + mRotation;
|
// The initial rotational offset -90 means we start at 12 o'clock
|
||||||
|
int mAngleOffset = -90;
|
||||||
|
final int arcStart = mStartAngle + mAngleOffset + mRotation;
|
||||||
final int arcSweep = mSweepAngle;
|
final int arcSweep = mSweepAngle;
|
||||||
canvas.drawArc(mArcRect, arcStart, arcSweep, false, mArcPaint);
|
canvas.drawArc(mArcRect, arcStart, arcSweep, false, mArcPaint);
|
||||||
canvas.drawArc(mArcRect, arcStart, mProgressSweep, false, mProgressPaint);
|
canvas.drawArc(mArcRect, arcStart, mProgressSweep, false, mProgressPaint);
|
||||||
|
@ -368,8 +367,8 @@ public class SeekArc extends View {
|
||||||
mThumb = thumb;
|
mThumb = thumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
thumbHalfheight = (int) mThumb.getIntrinsicHeight() / 2;
|
thumbHalfheight = mThumb.getIntrinsicHeight() / 2;
|
||||||
thumbHalfWidth = (int) mThumb.getIntrinsicWidth() / 2;
|
thumbHalfWidth = mThumb.getIntrinsicWidth() / 2;
|
||||||
mThumb.setBounds(-thumbHalfWidth, -thumbHalfheight, thumbHalfWidth, thumbHalfheight);
|
mThumb.setBounds(-thumbHalfWidth, -thumbHalfheight, thumbHalfWidth, thumbHalfheight);
|
||||||
|
|
||||||
mMax = a.getInteger(R.styleable.SeekArc_max, mMax);
|
mMax = a.getInteger(R.styleable.SeekArc_max, mMax);
|
||||||
|
@ -390,16 +389,16 @@ public class SeekArc extends View {
|
||||||
a.recycle();
|
a.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
mProgress = (mProgress > mMax) ? mMax : mProgress;
|
mProgress = Math.min(mProgress, mMax);
|
||||||
mProgress = (mProgress < 0) ? 0 : mProgress;
|
mProgress = Math.max(mProgress, 0);
|
||||||
|
|
||||||
mSweepAngle = (mSweepAngle > 360) ? 360 : mSweepAngle;
|
mSweepAngle = Math.min(mSweepAngle, 360);
|
||||||
mSweepAngle = (mSweepAngle < 0) ? 0 : mSweepAngle;
|
mSweepAngle = Math.max(mSweepAngle, 0);
|
||||||
|
|
||||||
mProgressSweep = (float) mProgress / mMax * mSweepAngle;
|
mProgressSweep = (float) mProgress / mMax * mSweepAngle;
|
||||||
|
|
||||||
mStartAngle = (mStartAngle > 360) ? 0 : mStartAngle;
|
mStartAngle = (mStartAngle > 360) ? 0 : mStartAngle;
|
||||||
mStartAngle = (mStartAngle < 0) ? 0 : mStartAngle;
|
mStartAngle = Math.max(mStartAngle, 0);
|
||||||
|
|
||||||
mArcPaint = new Paint();
|
mArcPaint = new Paint();
|
||||||
mArcPaint.setColor(arcColor);
|
mArcPaint.setColor(arcColor);
|
||||||
|
@ -442,7 +441,7 @@ public class SeekArc extends View {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setPressed(true);
|
setPressed(true);
|
||||||
mTouchAngle = getTouchDegrees(event.getX(), event.getY());
|
double mTouchAngle = getTouchDegrees(event.getX(), event.getY());
|
||||||
int progress = getProgressForAngle(mTouchAngle);
|
int progress = getProgressForAngle(mTouchAngle);
|
||||||
onProgressRefresh(progress, true);
|
onProgressRefresh(progress, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,9 @@ package code.name.monkey.retromusic.views.insets
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.WindowInsets
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBarsWithPadding
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBarsWithPadding
|
||||||
import code.name.monkey.retromusic.extensions.recordInitialPaddingForView
|
|
||||||
import code.name.monkey.retromusic.extensions.requestApplyInsetsWhenAttached
|
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import com.afollestad.materialdialogs.utils.MDUtil.updatePadding
|
|
||||||
|
|
||||||
class InsetsConstraintLayout @JvmOverloads constructor(
|
class InsetsConstraintLayout @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true">
|
android:fitsSystemWindows="true"
|
||||||
|
android:transitionGroup="true">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/appBarLayout"
|
android:id="@+id/appBarLayout"
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/scrollView"
|
android:id="@+id/scrollView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:transitionGroup="true">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/container"
|
android:id="@+id/container"
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources></resources>
|
|
|
@ -74,7 +74,7 @@ object ATH {
|
||||||
setActivityToolbarColor(activity, toolbar, ThemeStore.primaryColor(activity))
|
setActivityToolbarColor(activity, toolbar, ThemeStore.primaryColor(activity))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setActivityToolbarColor(
|
private fun setActivityToolbarColor(
|
||||||
activity: Activity, toolbar: Toolbar?,
|
activity: Activity, toolbar: Toolbar?,
|
||||||
color: Int
|
color: Int
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ open class ATHActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onThemeChanged() {
|
private fun onThemeChanged() {
|
||||||
postRecreate()
|
postRecreate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class ATEPreferenceDialogFragment extends DialogFragment implements Dialo
|
||||||
} else {
|
} else {
|
||||||
DialogPreference.TargetFragment fragment = (DialogPreference.TargetFragment) rawFragment;
|
DialogPreference.TargetFragment fragment = (DialogPreference.TargetFragment) rawFragment;
|
||||||
String key = this.getArguments().getString(ARG_KEY);
|
String key = this.getArguments().getString(ARG_KEY);
|
||||||
this.mPreference = (DialogPreference) fragment.findPreference(key);
|
this.mPreference = fragment.findPreference(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class ATEPreferenceDialogFragment extends DialogFragment implements Dialo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
Log.i(TAG, "onDismiss: " + mWhichButtonClicked);
|
Log.i(TAG, "onDismiss: " + mWhichButtonClicked);
|
||||||
onDialogClosed(mWhichButtonClicked == DialogInterface.BUTTON_POSITIVE);
|
onDialogClosed(mWhichButtonClicked == DialogInterface.BUTTON_POSITIVE);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package code.name.monkey.appthemehelper.util
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.FloatRange
|
import androidx.annotation.FloatRange
|
||||||
|
import kotlin.math.*
|
||||||
|
|
||||||
object ColorUtil {
|
object ColorUtil {
|
||||||
fun desaturateColor(color: Int, ratio: Float): Int {
|
fun desaturateColor(color: Int, ratio: Float): Int {
|
||||||
|
@ -59,7 +60,7 @@ object ColorUtil {
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun adjustAlpha(@ColorInt color: Int, @FloatRange(from = 0.0, to = 1.0) factor: Float): Int {
|
fun adjustAlpha(@ColorInt color: Int, @FloatRange(from = 0.0, to = 1.0) factor: Float): Int {
|
||||||
val alpha = Math.round(Color.alpha(color) * factor)
|
val alpha = (Color.alpha(color) * factor).roundToInt()
|
||||||
val red = Color.red(color)
|
val red = Color.red(color)
|
||||||
val green = Color.green(color)
|
val green = Color.green(color)
|
||||||
val blue = Color.blue(color)
|
val blue = Color.blue(color)
|
||||||
|
@ -68,7 +69,7 @@ object ColorUtil {
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun withAlpha(@ColorInt baseColor: Int, @FloatRange(from = 0.0, to = 1.0) alpha: Float): Int {
|
fun withAlpha(@ColorInt baseColor: Int, @FloatRange(from = 0.0, to = 1.0) alpha: Float): Int {
|
||||||
val a = Math.min(255, Math.max(0, (alpha * 255).toInt())) shl 24
|
val a = min(255, max(0, (alpha * 255).toInt())) shl 24
|
||||||
val rgb = 0x00ffffff and baseColor
|
val rgb = 0x00ffffff and baseColor
|
||||||
return a + rgb
|
return a + rgb
|
||||||
}
|
}
|
||||||
|
@ -100,15 +101,15 @@ object ColorUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isColorSaturated(@ColorInt color: Int): Boolean {
|
fun isColorSaturated(@ColorInt color: Int): Boolean {
|
||||||
val max = Math.max(
|
val max = max(
|
||||||
0.299 * Color.red(color),
|
0.299 * Color.red(color),
|
||||||
Math.max(0.587 * Color.green(color), 0.114 * Color.blue(color))
|
max(0.587 * Color.green(color), 0.114 * Color.blue(color))
|
||||||
)
|
)
|
||||||
val min = Math.min(
|
val min = min(
|
||||||
0.299 * Color.red(color),
|
0.299 * Color.red(color),
|
||||||
Math.min(0.587 * Color.green(color), 0.114 * Color.blue(color))
|
min(0.587 * Color.green(color), 0.114 * Color.blue(color))
|
||||||
)
|
)
|
||||||
val diff = Math.abs(max - min)
|
val diff = abs(max - min)
|
||||||
return diff > 20
|
return diff > 20
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,10 +122,10 @@ object ColorUtil {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getDifference(@ColorInt color1: Int, @ColorInt color2: Int): Double {
|
private fun getDifference(@ColorInt color1: Int, @ColorInt color2: Int): Double {
|
||||||
var diff = Math.abs(0.299 * (Color.red(color1) - Color.red(color2)))
|
var diff = abs(0.299 * (Color.red(color1) - Color.red(color2)))
|
||||||
diff += Math.abs(0.587 * (Color.green(color1) - Color.green(color2)))
|
diff += abs(0.587 * (Color.green(color1) - Color.green(color2)))
|
||||||
diff += Math.abs(0.114 * (Color.blue(color1) - Color.blue(color2)))
|
diff += abs(0.114 * (Color.blue(color1) - Color.blue(color2)))
|
||||||
return diff
|
return diff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.content.res.ColorStateList;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.RippleDrawable;
|
import android.graphics.drawable.RippleDrawable;
|
||||||
import android.os.Build;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
@ -149,40 +148,14 @@ public final class TintHelper {
|
||||||
useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
|
useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
|
||||||
color
|
color
|
||||||
});
|
});
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
radioButton.setButtonTintList(sl);
|
||||||
radioButton.setButtonTintList(sl);
|
|
||||||
} else {
|
|
||||||
Drawable d = createTintedDrawable(
|
|
||||||
ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material), sl);
|
|
||||||
radioButton.setButtonDrawable(d);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color, boolean useDarker) {
|
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color, boolean useDarker) {
|
||||||
final ColorStateList s1 = getDisabledColorStateList(color, ContextCompat.getColor(seekBar.getContext(),
|
final ColorStateList s1 = getDisabledColorStateList(color, ContextCompat.getColor(seekBar.getContext(),
|
||||||
useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light));
|
useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light));
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
seekBar.setThumbTintList(s1);
|
||||||
seekBar.setThumbTintList(s1);
|
seekBar.setProgressTintList(s1);
|
||||||
seekBar.setProgressTintList(s1);
|
|
||||||
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
|
|
||||||
Drawable progressDrawable = createTintedDrawable(seekBar.getProgressDrawable(), s1);
|
|
||||||
seekBar.setProgressDrawable(progressDrawable);
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
Drawable thumbDrawable = createTintedDrawable(seekBar.getThumb(), s1);
|
|
||||||
seekBar.setThumb(thumbDrawable);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
|
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
|
|
||||||
mode = PorterDuff.Mode.MULTIPLY;
|
|
||||||
}
|
|
||||||
if (seekBar.getIndeterminateDrawable() != null) {
|
|
||||||
seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
|
|
||||||
}
|
|
||||||
if (seekBar.getProgressDrawable() != null) {
|
|
||||||
seekBar.getProgressDrawable().setColorFilter(color, mode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTint(@NonNull ProgressBar progressBar, @ColorInt int color) {
|
public static void setTint(@NonNull ProgressBar progressBar, @ColorInt int color) {
|
||||||
|
@ -191,23 +164,10 @@ public final class TintHelper {
|
||||||
|
|
||||||
public static void setTint(@NonNull ProgressBar progressBar, @ColorInt int color, boolean skipIndeterminate) {
|
public static void setTint(@NonNull ProgressBar progressBar, @ColorInt int color, boolean skipIndeterminate) {
|
||||||
ColorStateList sl = ColorStateList.valueOf(color);
|
ColorStateList sl = ColorStateList.valueOf(color);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
progressBar.setProgressTintList(sl);
|
||||||
progressBar.setProgressTintList(sl);
|
progressBar.setSecondaryProgressTintList(sl);
|
||||||
progressBar.setSecondaryProgressTintList(sl);
|
if (!skipIndeterminate) {
|
||||||
if (!skipIndeterminate) {
|
progressBar.setIndeterminateTintList(sl);
|
||||||
progressBar.setIndeterminateTintList(sl);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
|
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
|
|
||||||
mode = PorterDuff.Mode.MULTIPLY;
|
|
||||||
}
|
|
||||||
if (!skipIndeterminate && progressBar.getIndeterminateDrawable() != null) {
|
|
||||||
progressBar.getIndeterminateDrawable().setColorFilter(color, mode);
|
|
||||||
}
|
|
||||||
if (progressBar.getProgressDrawable() != null) {
|
|
||||||
progressBar.getProgressDrawable().setColorFilter(color, mode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +185,7 @@ public final class TintHelper {
|
||||||
});
|
});
|
||||||
if (editText instanceof AppCompatEditText) {
|
if (editText instanceof AppCompatEditText) {
|
||||||
((AppCompatEditText) editText).setSupportBackgroundTintList(editTextColorStateList);
|
((AppCompatEditText) editText).setSupportBackgroundTintList(editTextColorStateList);
|
||||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
} else {
|
||||||
editText.setBackgroundTintList(editTextColorStateList);
|
editText.setBackgroundTintList(editTextColorStateList);
|
||||||
}
|
}
|
||||||
setCursorTint(editText, color);
|
setCursorTint(editText, color);
|
||||||
|
@ -243,13 +203,7 @@ public final class TintHelper {
|
||||||
useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
|
useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
|
||||||
color
|
color
|
||||||
});
|
});
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
box.setButtonTintList(sl);
|
||||||
box.setButtonTintList(sl);
|
|
||||||
} else {
|
|
||||||
Drawable drawable = createTintedDrawable(
|
|
||||||
ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material), sl);
|
|
||||||
box.setButtonDrawable(drawable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTint(@NonNull ImageView image, @ColorInt int color) {
|
public static void setTint(@NonNull ImageView image, @ColorInt int color) {
|
||||||
|
@ -257,9 +211,6 @@ public final class TintHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTint(@NonNull Switch switchView, @ColorInt int color, boolean useDarker) {
|
public static void setTint(@NonNull Switch switchView, @ColorInt int color, boolean useDarker) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (switchView.getTrackDrawable() != null) {
|
if (switchView.getTrackDrawable() != null) {
|
||||||
switchView.setTrackDrawable(modifySwitchDrawable(switchView.getContext(),
|
switchView.setTrackDrawable(modifySwitchDrawable(switchView.getContext(),
|
||||||
switchView.getTrackDrawable(), color, false, false, useDarker));
|
switchView.getTrackDrawable(), color, false, false, useDarker));
|
||||||
|
@ -286,7 +237,6 @@ public final class TintHelper {
|
||||||
setTintAuto(view, color, background, ATHUtil.INSTANCE.isWindowBackgroundDark(view.getContext()));
|
setTintAuto(view, color, background, ATHUtil.INSTANCE.isWindowBackgroundDark(view.getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static void setTintAuto(final @NonNull View view, final @ColorInt int color,
|
public static void setTintAuto(final @NonNull View view, final @ColorInt int color,
|
||||||
boolean background, final boolean isDark) {
|
boolean background, final boolean isDark) {
|
||||||
if (!background) {
|
if (!background) {
|
||||||
|
@ -312,8 +262,7 @@ public final class TintHelper {
|
||||||
background = true;
|
background = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
|
if (!background && view.getBackground() instanceof RippleDrawable) {
|
||||||
!background && view.getBackground() instanceof RippleDrawable) {
|
|
||||||
// Ripples for the above views (e.g. when you tap and hold a switch or checkbox)
|
// Ripples for the above views (e.g. when you tap and hold a switch or checkbox)
|
||||||
RippleDrawable rd = (RippleDrawable) view.getBackground();
|
RippleDrawable rd = (RippleDrawable) view.getBackground();
|
||||||
@SuppressLint("PrivateResource") final int unchecked = ContextCompat.getColor(view.getContext(),
|
@SuppressLint("PrivateResource") final int unchecked = ContextCompat.getColor(view.getContext(),
|
||||||
|
@ -348,7 +297,6 @@ public final class TintHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static void setTintSelector(@NonNull View view, @ColorInt final int color, final boolean darker,
|
public static void setTintSelector(@NonNull View view, @ColorInt final int color, final boolean darker,
|
||||||
final boolean useDarkTheme) {
|
final boolean useDarkTheme) {
|
||||||
final boolean isColorLight = ColorUtil.INSTANCE.isColorLight(color);
|
final boolean isColorLight = ColorUtil.INSTANCE.isColorLight(color);
|
||||||
|
@ -363,8 +311,7 @@ public final class TintHelper {
|
||||||
final ColorStateList sl;
|
final ColorStateList sl;
|
||||||
if (view instanceof Button) {
|
if (view instanceof Button) {
|
||||||
sl = getDisabledColorStateList(color, disabled);
|
sl = getDisabledColorStateList(color, disabled);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
|
if (view.getBackground() instanceof RippleDrawable) {
|
||||||
view.getBackground() instanceof RippleDrawable) {
|
|
||||||
RippleDrawable rd = (RippleDrawable) view.getBackground();
|
RippleDrawable rd = (RippleDrawable) view.getBackground();
|
||||||
rd.setColor(ColorStateList.valueOf(rippleColor));
|
rd.setColor(ColorStateList.valueOf(rippleColor));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Context;
|
||||||
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.os.Build;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -17,6 +16,7 @@ import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
|
||||||
import androidx.annotation.CheckResult;
|
import androidx.annotation.CheckResult;
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -35,11 +35,13 @@ import androidx.appcompat.widget.AppCompatImageView;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.appcompat.widget.ToolbarWidgetWrapper;
|
import androidx.appcompat.widget.ToolbarWidgetWrapper;
|
||||||
import androidx.core.graphics.drawable.DrawableCompat;
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
import code.name.monkey.appthemehelper.R;
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import code.name.monkey.appthemehelper.R;
|
||||||
|
import code.name.monkey.appthemehelper.ThemeStore;
|
||||||
|
|
||||||
public final class ToolbarContentTintHelper {
|
public final class ToolbarContentTintHelper {
|
||||||
|
|
||||||
public static class InternalToolbarContentTintUtil {
|
public static class InternalToolbarContentTintUtil {
|
||||||
|
@ -92,30 +94,27 @@ public final class ToolbarContentTintHelper {
|
||||||
if (toolbar == null) {
|
if (toolbar == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
toolbar.post(new Runnable() {
|
toolbar.post(() -> {
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
Field f1 = Toolbar.class.getDeclaredField("mMenuView");
|
||||||
try {
|
f1.setAccessible(true);
|
||||||
Field f1 = Toolbar.class.getDeclaredField("mMenuView");
|
ActionMenuView actionMenuView = (ActionMenuView) f1.get(toolbar);
|
||||||
f1.setAccessible(true);
|
Field f2 = ActionMenuView.class.getDeclaredField("mPresenter");
|
||||||
ActionMenuView actionMenuView = (ActionMenuView) f1.get(toolbar);
|
f2.setAccessible(true);
|
||||||
Field f2 = ActionMenuView.class.getDeclaredField("mPresenter");
|
|
||||||
f2.setAccessible(true);
|
|
||||||
|
|
||||||
// Actually ActionMenuPresenter
|
// Actually ActionMenuPresenter
|
||||||
BaseMenuPresenter presenter = (BaseMenuPresenter) f2.get(actionMenuView);
|
BaseMenuPresenter presenter = (BaseMenuPresenter) f2.get(actionMenuView);
|
||||||
Field f3 = presenter.getClass().getDeclaredField("mOverflowPopup");
|
Field f3 = presenter.getClass().getDeclaredField("mOverflowPopup");
|
||||||
f3.setAccessible(true);
|
f3.setAccessible(true);
|
||||||
MenuPopupHelper overflowMenuPopupHelper = (MenuPopupHelper) f3.get(presenter);
|
MenuPopupHelper overflowMenuPopupHelper = (MenuPopupHelper) f3.get(presenter);
|
||||||
setTintForMenuPopupHelper(context, overflowMenuPopupHelper, color);
|
setTintForMenuPopupHelper(context, overflowMenuPopupHelper, color);
|
||||||
|
|
||||||
Field f4 = presenter.getClass().getDeclaredField("mActionButtonPopup");
|
Field f4 = presenter.getClass().getDeclaredField("mActionButtonPopup");
|
||||||
f4.setAccessible(true);
|
f4.setAccessible(true);
|
||||||
MenuPopupHelper subMenuPopupHelper = (MenuPopupHelper) f4.get(presenter);
|
MenuPopupHelper subMenuPopupHelper = (MenuPopupHelper) f4.get(presenter);
|
||||||
setTintForMenuPopupHelper(context, subMenuPopupHelper, color);
|
setTintForMenuPopupHelper(context, subMenuPopupHelper, color);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -172,28 +171,19 @@ public final class ToolbarContentTintHelper {
|
||||||
CheckBox check = (CheckBox) checkboxField.get(iv);
|
CheckBox check = (CheckBox) checkboxField.get(iv);
|
||||||
if (check != null) {
|
if (check != null) {
|
||||||
TintHelper.setTint(check, color, isDark);
|
TintHelper.setTint(check, color, isDark);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
check.setBackground(null);
|
||||||
check.setBackground(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioButton radioButton = (RadioButton) radioButtonField.get(iv);
|
RadioButton radioButton = (RadioButton) radioButtonField.get(iv);
|
||||||
if (radioButton != null) {
|
if (radioButton != null) {
|
||||||
TintHelper.setTint(radioButton, color, isDark);
|
TintHelper.setTint(radioButton, color, isDark);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
radioButton.setBackground(null);
|
||||||
radioButton.setBackground(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
listView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
listView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
} else {
|
|
||||||
//noinspection deprecation
|
|
||||||
listView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -202,7 +192,6 @@ public final class ToolbarContentTintHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static void tintMenu(@NonNull Toolbar toolbar, @Nullable Menu menu,
|
public static void tintMenu(@NonNull Toolbar toolbar, @Nullable Menu menu,
|
||||||
final @ColorInt int color) {
|
final @ColorInt int color) {
|
||||||
try {
|
try {
|
||||||
|
@ -338,13 +327,8 @@ public final class ToolbarContentTintHelper {
|
||||||
|
|
||||||
//Important to set the color filter in seperate thread, by adding it to the message queue
|
//Important to set the color filter in seperate thread, by adding it to the message queue
|
||||||
//Won't work otherwise.
|
//Won't work otherwise.
|
||||||
innerView.post(new Runnable() {
|
innerView.post(() -> ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK]
|
||||||
@Override
|
.setColorFilter(colorFilter));
|
||||||
public void run() {
|
|
||||||
((ActionMenuItemView) innerView).getCompoundDrawables()[finalK]
|
|
||||||
.setColorFilter(colorFilter);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,7 +347,7 @@ public final class ToolbarContentTintHelper {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) {
|
public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) {
|
||||||
if (ab == null || !(ab instanceof WindowDecorActionBar)) {
|
if (!(ab instanceof WindowDecorActionBar)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -411,7 +395,6 @@ public final class ToolbarContentTintHelper {
|
||||||
secondaryTextColor, menuWidgetColor);
|
secondaryTextColor, menuWidgetColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static void setToolbarContentColor(@NonNull Context context,
|
public static void setToolbarContentColor(@NonNull Context context,
|
||||||
Toolbar toolbar,
|
Toolbar toolbar,
|
||||||
@Nullable Menu menu,
|
@Nullable Menu menu,
|
||||||
|
@ -577,7 +560,7 @@ public final class ToolbarContentTintHelper {
|
||||||
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGlobalLayout() {
|
public void onGlobalLayout() {
|
||||||
final ArrayList<View> outViews = new ArrayList<View>();
|
final ArrayList<View> outViews = new ArrayList<>();
|
||||||
decorView.findViewsWithText(outViews, overflowDescription,
|
decorView.findViewsWithText(outViews, overflowDescription,
|
||||||
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
|
View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
|
||||||
if (outViews.isEmpty()) {
|
if (outViews.isEmpty()) {
|
||||||
|
@ -605,7 +588,7 @@ public final class ToolbarContentTintHelper {
|
||||||
final View actionView = item.getActionView();
|
final View actionView = item.getActionView();
|
||||||
final View expandActivitiesButton = actionView.findViewById(R.id.expand_activities_button);
|
final View expandActivitiesButton = actionView.findViewById(R.id.expand_activities_button);
|
||||||
if (expandActivitiesButton != null) {
|
if (expandActivitiesButton != null) {
|
||||||
final ImageView image = (ImageView) expandActivitiesButton.findViewById(R.id.image);
|
final ImageView image = expandActivitiesButton.findViewById(R.id.image);
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
final Drawable drawable = image.getDrawable();
|
final Drawable drawable = image.getDrawable();
|
||||||
final Drawable wrapped = DrawableCompat.wrap(drawable);
|
final Drawable wrapped = DrawableCompat.wrap(drawable);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ATESwitch xmlns:android="http://schemas.android.com/apk/res/android"
|
<code.name.monkey.appthemehelper.common.views.ATESwitch xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@android:id/checkbox"
|
android:id="@android:id/checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="m3_accent_color">@android:color/system_accent1_200</color>
|
<color name="m3_accent_color">@android:color/system_accent1_200</color>
|
||||||
<color name="m3_selection_color">@android:color/system_accent1_800</color>
|
<color name="m3_selection_color">@android:color/system_accent1_500</color>
|
||||||
</resources>
|
</resources>
|
|
@ -1,2 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources></resources>
|
|
Loading…
Reference in a new issue