[Cleanup] Converted functions of super class(AbsThemeActivity) to extension functions
This commit is contained in:
parent
42a00dee95
commit
e5743ee98b
34 changed files with 249 additions and 226 deletions
|
@ -296,6 +296,6 @@
|
||||||
<!-- ChromeCast -->
|
<!-- ChromeCast -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
|
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
|
||||||
android:value=".cast.CastOptionsProvider" />
|
android:value="code.name.monkey.retromusic.cast.CastOptionsProvider" />
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -24,6 +24,7 @@ import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityDriveModeBinding
|
import code.name.monkey.retromusic.databinding.ActivityDriveModeBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.setDrawUnderStatusBar
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
import code.name.monkey.retromusic.glide.BlurTransformation
|
import code.name.monkey.retromusic.glide.BlurTransformation
|
||||||
import code.name.monkey.retromusic.glide.GlideApp
|
import code.name.monkey.retromusic.glide.GlideApp
|
||||||
|
|
|
@ -24,7 +24,7 @@ import androidx.core.view.ViewCompat
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityLockScreenBinding
|
import code.name.monkey.retromusic.databinding.ActivityLockScreenBinding
|
||||||
import code.name.monkey.retromusic.extensions.whichFragment
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.fragments.player.lockscreen.LockScreenControlsFragment
|
import code.name.monkey.retromusic.fragments.player.lockscreen.LockScreenControlsFragment
|
||||||
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
|
||||||
|
@ -47,7 +47,7 @@ class LockScreenActivity : AbsMusicServiceActivity() {
|
||||||
binding = ActivityLockScreenBinding.inflate(layoutInflater)
|
binding = ActivityLockScreenBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
hideStatusBar()
|
hideStatusBar()
|
||||||
setStatusbarColorAuto()
|
setStatusBarColorAuto()
|
||||||
setTaskDescriptionColorAuto()
|
setTaskDescriptionColorAuto()
|
||||||
|
|
||||||
val config = SlidrConfig.Builder().listener(object : SlidrListener {
|
val config = SlidrConfig.Builder().listener(object : SlidrListener {
|
||||||
|
|
|
@ -26,9 +26,7 @@ import androidx.navigation.ui.setupWithNavController
|
||||||
import code.name.monkey.retromusic.*
|
import code.name.monkey.retromusic.*
|
||||||
import code.name.monkey.retromusic.activities.base.AbsCastActivity
|
import code.name.monkey.retromusic.activities.base.AbsCastActivity
|
||||||
import code.name.monkey.retromusic.databinding.SlidingMusicPanelLayoutBinding
|
import code.name.monkey.retromusic.databinding.SlidingMusicPanelLayoutBinding
|
||||||
import code.name.monkey.retromusic.extensions.currentFragment
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.extra
|
|
||||||
import code.name.monkey.retromusic.extensions.findNavController
|
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewFragment
|
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewFragment
|
||||||
import code.name.monkey.retromusic.fragments.home.HomeFragment
|
import code.name.monkey.retromusic.fragments.home.HomeFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
|
|
|
@ -30,6 +30,8 @@ import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityPermissionBinding
|
import code.name.monkey.retromusic.databinding.ActivityPermissionBinding
|
||||||
import code.name.monkey.retromusic.extensions.accentBackgroundColor
|
import code.name.monkey.retromusic.extensions.accentBackgroundColor
|
||||||
|
import code.name.monkey.retromusic.extensions.setStatusBarColorAuto
|
||||||
|
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.util.RingtoneManager
|
import code.name.monkey.retromusic.util.RingtoneManager
|
||||||
|
|
||||||
|
@ -40,7 +42,7 @@ class PermissionActivity : AbsMusicServiceActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityPermissionBinding.inflate(layoutInflater)
|
binding = ActivityPermissionBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setStatusbarColorAuto()
|
setStatusBarColorAuto()
|
||||||
setTaskDescriptionColorAuto()
|
setTaskDescriptionColorAuto()
|
||||||
setupTitle()
|
setupTitle()
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,9 @@ import code.name.monkey.retromusic.Constants.PRO_VERSION_PRODUCT_ID
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityProVersionBinding
|
import code.name.monkey.retromusic.databinding.ActivityProVersionBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.setDrawUnderStatusBar
|
||||||
|
import code.name.monkey.retromusic.extensions.setLightStatusBar
|
||||||
|
import code.name.monkey.retromusic.extensions.setStatusBarColor
|
||||||
import com.anjlab.android.iab.v3.BillingProcessor
|
import com.anjlab.android.iab.v3.BillingProcessor
|
||||||
import com.anjlab.android.iab.v3.PurchaseInfo
|
import com.anjlab.android.iab.v3.PurchaseInfo
|
||||||
|
|
||||||
|
@ -41,8 +44,8 @@ class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityProVersionBinding.inflate(layoutInflater)
|
binding = ActivityProVersionBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setStatusbarColor(Color.TRANSPARENT)
|
setStatusBarColor(Color.TRANSPARENT)
|
||||||
setLightStatusbar(false)
|
setLightStatusBar(false)
|
||||||
binding.toolbar.navigationIcon?.setTint(Color.WHITE)
|
binding.toolbar.navigationIcon?.setTint(Color.WHITE)
|
||||||
binding.toolbar.setNavigationOnClickListener { onBackPressed() }
|
binding.toolbar.setNavigationOnClickListener { onBackPressed() }
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.base.AbsThemeActivity
|
import code.name.monkey.retromusic.activities.base.AbsThemeActivity
|
||||||
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
||||||
import code.name.monkey.retromusic.databinding.ActivitySettingsBinding
|
import code.name.monkey.retromusic.databinding.ActivitySettingsBinding
|
||||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.extra
|
|
||||||
import code.name.monkey.retromusic.extensions.findNavController
|
|
||||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.color.ColorCallback
|
import com.afollestad.materialdialogs.color.ColorCallback
|
||||||
|
|
||||||
|
@ -38,7 +35,7 @@ class SettingsActivity : AbsThemeActivity(), ColorCallback, OnThemeChangedListen
|
||||||
setDrawUnderStatusBar()
|
setDrawUnderStatusBar()
|
||||||
val mSavedInstanceState = extra<Bundle>(TAG).value ?: savedInstanceState
|
val mSavedInstanceState = extra<Bundle>(TAG).value ?: savedInstanceState
|
||||||
super.onCreate(mSavedInstanceState)
|
super.onCreate(mSavedInstanceState)
|
||||||
setLightStatusbarAuto(surfaceColor())
|
setLightStatusBarAuto(surfaceColor())
|
||||||
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setupToolbar()
|
setupToolbar()
|
||||||
|
|
|
@ -28,6 +28,10 @@ import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityShareInstagramBinding
|
import code.name.monkey.retromusic.databinding.ActivityShareInstagramBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||||
|
import code.name.monkey.retromusic.extensions.setDrawUnderStatusBar
|
||||||
|
import code.name.monkey.retromusic.extensions.setLightStatusBar
|
||||||
|
import code.name.monkey.retromusic.extensions.setStatusBarColor
|
||||||
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
|
||||||
|
@ -60,7 +64,7 @@ class ShareInstagramStory : AbsBaseActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityShareInstagramBinding.inflate(layoutInflater)
|
binding = ActivityShareInstagramBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setStatusbarColor(Color.TRANSPARENT)
|
setStatusBarColor(Color.TRANSPARENT)
|
||||||
|
|
||||||
binding.toolbar.setBackgroundColor(Color.TRANSPARENT)
|
binding.toolbar.setBackgroundColor(Color.TRANSPARENT)
|
||||||
setSupportActionBar(binding.toolbar)
|
setSupportActionBar(binding.toolbar)
|
||||||
|
@ -104,7 +108,7 @@ class ShareInstagramStory : AbsBaseActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setColors(colorLight: Boolean, color: Int) {
|
private fun setColors(colorLight: Boolean, color: Int) {
|
||||||
setLightStatusbar(colorLight)
|
setLightStatusBar(colorLight)
|
||||||
binding.toolbar.setTitleTextColor(
|
binding.toolbar.setTitleTextColor(
|
||||||
MaterialValueHelper.getPrimaryTextColor(
|
MaterialValueHelper.getPrimaryTextColor(
|
||||||
this@ShareInstagramStory,
|
this@ShareInstagramStory,
|
||||||
|
|
|
@ -37,6 +37,8 @@ import code.name.monkey.retromusic.BuildConfig
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityDonationBinding
|
import code.name.monkey.retromusic.databinding.ActivityDonationBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.setStatusBarColorAuto
|
||||||
|
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
||||||
import code.name.monkey.retromusic.extensions.textColorPrimary
|
import code.name.monkey.retromusic.extensions.textColorPrimary
|
||||||
import code.name.monkey.retromusic.extensions.textColorSecondary
|
import code.name.monkey.retromusic.extensions.textColorSecondary
|
||||||
import com.anjlab.android.iab.v3.BillingProcessor
|
import com.anjlab.android.iab.v3.BillingProcessor
|
||||||
|
@ -73,7 +75,7 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH
|
||||||
binding = ActivityDonationBinding.inflate(layoutInflater)
|
binding = ActivityDonationBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
setStatusbarColorAuto()
|
setStatusBarColorAuto()
|
||||||
setTaskDescriptionColorAuto()
|
setTaskDescriptionColorAuto()
|
||||||
|
|
||||||
setupToolbar()
|
setupToolbar()
|
||||||
|
|
|
@ -17,6 +17,8 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.base.AbsThemeActivity
|
import code.name.monkey.retromusic.activities.base.AbsThemeActivity
|
||||||
import code.name.monkey.retromusic.databinding.ActivityWhatsNewBinding
|
import code.name.monkey.retromusic.databinding.ActivityWhatsNewBinding
|
||||||
import code.name.monkey.retromusic.extensions.accentColor
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
|
import code.name.monkey.retromusic.extensions.setLightStatusBarAuto
|
||||||
|
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil.lastVersion
|
import code.name.monkey.retromusic.util.PreferenceUtil.lastVersion
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
|
@ -29,7 +31,7 @@ class WhatsNewActivity : AbsThemeActivity() {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
val binding = ActivityWhatsNewBinding.inflate(layoutInflater)
|
val binding = ActivityWhatsNewBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setLightStatusbarAuto(resolveColor(this, R.attr.colorSurface))
|
setLightStatusBarAuto(resolveColor(this, R.attr.colorSurface))
|
||||||
setTaskDescriptionColorAuto()
|
setTaskDescriptionColorAuto()
|
||||||
binding.toolbar.setNavigationOnClickListener { onBackPressed() }
|
binding.toolbar.setNavigationOnClickListener { onBackPressed() }
|
||||||
ToolbarContentTintHelper.colorBackButton(binding.toolbar)
|
ToolbarContentTintHelper.colorBackButton(binding.toolbar)
|
||||||
|
|
|
@ -184,9 +184,9 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
open fun onPanelCollapsed() {
|
open fun onPanelCollapsed() {
|
||||||
setMiniPlayerAlphaProgress(0F)
|
setMiniPlayerAlphaProgress(0F)
|
||||||
// restore values
|
// restore values
|
||||||
super.setLightStatusbarAuto(surfaceColor())
|
setLightStatusBarAuto(surfaceColor())
|
||||||
super.setLightNavigationAuto()
|
setLightNavigationAuto()
|
||||||
super.setTaskDescriptionColor(taskColor)
|
setTaskDescriptionColor(taskColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun onPanelExpanded() {
|
open fun onPanelExpanded() {
|
||||||
|
@ -257,26 +257,26 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
|
|
||||||
private fun onPaletteColorChanged() {
|
private fun onPaletteColorChanged() {
|
||||||
if (panelState == STATE_EXPANDED) {
|
if (panelState == STATE_EXPANDED) {
|
||||||
super.setTaskDescriptionColor(paletteColor)
|
setTaskDescColor(paletteColor)
|
||||||
val isColorLight = ColorUtil.isColorLight(paletteColor)
|
val isColorLight = ColorUtil.isColorLight(paletteColor)
|
||||||
if (PreferenceUtil.isAdaptiveColor && (nowPlayingScreen == Normal || nowPlayingScreen == Flat)) {
|
if (PreferenceUtil.isAdaptiveColor && (nowPlayingScreen == Normal || nowPlayingScreen == Flat)) {
|
||||||
super.setLightNavigationBar(true)
|
setLightNavigationBar(true)
|
||||||
super.setLightStatusbar(isColorLight)
|
setLightStatusBar(isColorLight)
|
||||||
} else if (nowPlayingScreen == Card || nowPlayingScreen == Blur || nowPlayingScreen == BlurCard) {
|
} else if (nowPlayingScreen == Card || nowPlayingScreen == Blur || nowPlayingScreen == BlurCard) {
|
||||||
super.setLightStatusbar(false)
|
setLightStatusBar(false)
|
||||||
super.setLightNavigationBar(true)
|
setLightNavigationBar(true)
|
||||||
} else if (nowPlayingScreen == Color || nowPlayingScreen == Tiny || nowPlayingScreen == Gradient) {
|
} else if (nowPlayingScreen == Color || nowPlayingScreen == Tiny || nowPlayingScreen == Gradient) {
|
||||||
super.setLightNavigationBar(isColorLight)
|
setLightNavigationBar(isColorLight)
|
||||||
super.setLightStatusbar(isColorLight)
|
setLightStatusBar(isColorLight)
|
||||||
} else if (nowPlayingScreen == Full) {
|
} else if (nowPlayingScreen == Full) {
|
||||||
super.setLightNavigationBar(isColorLight)
|
setLightNavigationBar(isColorLight)
|
||||||
super.setLightStatusbar(false)
|
setLightStatusBar(false)
|
||||||
} else if (nowPlayingScreen == Classic) {
|
} else if (nowPlayingScreen == Classic) {
|
||||||
super.setLightStatusbar(false)
|
setLightStatusBar(false)
|
||||||
} else if (nowPlayingScreen == Fit) {
|
} else if (nowPlayingScreen == Fit) {
|
||||||
super.setLightStatusbar(false)
|
setLightStatusBar(false)
|
||||||
} else {
|
} else {
|
||||||
super.setLightStatusbar(
|
setLightStatusBar(
|
||||||
ColorUtil.isColorLight(
|
ColorUtil.isColorLight(
|
||||||
ATHUtil.resolveColor(
|
ATHUtil.resolveColor(
|
||||||
this,
|
this,
|
||||||
|
@ -284,15 +284,15 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
super.setLightNavigationBar(true)
|
setLightNavigationBar(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setTaskDescriptionColor(color: Int) {
|
private fun setTaskDescColor(color: Int) {
|
||||||
taskColor = color
|
taskColor = color
|
||||||
if (panelState == STATE_COLLAPSED) {
|
if (panelState == STATE_COLLAPSED) {
|
||||||
super.setTaskDescriptionColor(color)
|
setTaskDescriptionColor(color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,29 +16,16 @@ package code.name.monkey.retromusic.activities.base
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.Color
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
|
||||||
import androidx.annotation.ColorInt
|
|
||||||
import androidx.appcompat.app.AppCompatDelegate.setDefaultNightMode
|
import androidx.appcompat.app.AppCompatDelegate.setDefaultNightMode
|
||||||
import androidx.core.os.ConfigurationCompat
|
import androidx.core.os.ConfigurationCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
import androidx.core.view.WindowInsetsControllerCompat
|
|
||||||
import code.name.monkey.appthemehelper.ATH
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
|
||||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
|
||||||
import code.name.monkey.retromusic.LanguageContextWrapper
|
import code.name.monkey.retromusic.LanguageContextWrapper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
|
||||||
import code.name.monkey.retromusic.util.theme.ThemeManager
|
import code.name.monkey.retromusic.util.theme.ThemeManager
|
||||||
import com.google.android.material.color.DynamicColors
|
import com.google.android.material.color.DynamicColors
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -54,9 +41,8 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
setImmersiveFullscreen()
|
setImmersiveFullscreen()
|
||||||
registerSystemUiVisibility()
|
registerSystemUiVisibility()
|
||||||
toggleScreenOn()
|
toggleScreenOn()
|
||||||
setDrawUnderNavigationBar()
|
|
||||||
setLightNavigationAuto()
|
setLightNavigationAuto()
|
||||||
setLightStatusbarAuto(surfaceColor())
|
setLightStatusBarAuto(surfaceColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTheme() {
|
private fun updateTheme() {
|
||||||
|
@ -72,14 +58,6 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleScreenOn() {
|
|
||||||
if (PreferenceUtil.isScreenOnEnabled) {
|
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
||||||
} else {
|
|
||||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||||
super.onWindowFocusChanged(hasFocus)
|
super.onWindowFocusChanged(hasFocus)
|
||||||
if (hasFocus) {
|
if (hasFocus) {
|
||||||
|
@ -91,95 +69,6 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hideStatusBar() {
|
|
||||||
hideStatusBar(PreferenceUtil.isFullScreenMode)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun hideStatusBar(fullscreen: Boolean) {
|
|
||||||
val statusBar = window.decorView.rootView.findViewById<View>(R.id.status_bar)
|
|
||||||
if (statusBar != null) {
|
|
||||||
statusBar.visibility = if (fullscreen) View.GONE else View.VISIBLE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setDrawUnderStatusBar() {
|
|
||||||
RetroUtil.setAllowDrawUnderStatusBar(window)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setDrawUnderNavigationBar() {
|
|
||||||
RetroUtil.setAllowDrawUnderNavigationBar(window)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This will set the color of the view with the id "status_bar" on KitKat and Lollipop. On
|
|
||||||
* Lollipop if no such view is found it will set the statusbar color using the native method.
|
|
||||||
*
|
|
||||||
* @param color the new statusbar color (will be shifted down on Lollipop and above)
|
|
||||||
*/
|
|
||||||
fun setStatusbarColor(color: Int) {
|
|
||||||
val statusBar = window.decorView.rootView.findViewById<View>(R.id.status_bar)
|
|
||||||
if (statusBar != null) {
|
|
||||||
when {
|
|
||||||
VersionUtils.hasMarshmallow() -> statusBar.setBackgroundColor(color)
|
|
||||||
else -> statusBar.setBackgroundColor(
|
|
||||||
ColorUtil.darkenColor(
|
|
||||||
color
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
when {
|
|
||||||
VersionUtils.hasMarshmallow() -> window.statusBarColor = color
|
|
||||||
else -> window.statusBarColor = ColorUtil.darkenColor(color)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setLightStatusbarAuto(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setStatusbarColorAuto() {
|
|
||||||
// we don't want to use statusbar color because we are doing the color darkening on our own to support KitKat
|
|
||||||
setStatusbarColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
|
||||||
setLightStatusbarAuto(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun setTaskDescriptionColor(@ColorInt color: Int) {
|
|
||||||
ATH.setTaskDescriptionColor(this, color)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setTaskDescriptionColorAuto() {
|
|
||||||
setTaskDescriptionColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun setNavigationbarColor(color: Int) {
|
|
||||||
if (ThemeStore.coloredNavigationBar(this)) {
|
|
||||||
ATH.setNavigationbarColor(this, color)
|
|
||||||
} else {
|
|
||||||
ATH.setNavigationbarColor(this, Color.BLACK)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setNavigationbarColorAuto() {
|
|
||||||
setNavigationbarColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setLightNavigationAuto() {
|
|
||||||
ATH.setLightNavigationbarAuto(this, surfaceColor())
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun setLightStatusbar(enabled: Boolean) {
|
|
||||||
ATH.setLightStatusbar(this, enabled)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setLightStatusbarAuto(bgColor: Int) {
|
|
||||||
setLightStatusbar(ColorUtil.isColorLight(bgColor))
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun setLightNavigationBar(enabled: Boolean) {
|
|
||||||
if (!ATHUtil.isWindowBackgroundDark(this) and ThemeStore.coloredNavigationBar(this)) {
|
|
||||||
ATH.setLightNavigationbar(this, enabled)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun registerSystemUiVisibility() {
|
private fun registerSystemUiVisibility() {
|
||||||
val decorView = window.decorView
|
val decorView = window.decorView
|
||||||
decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
||||||
|
@ -194,26 +83,6 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
decorView.setOnSystemUiVisibilityChangeListener(null)
|
decorView.setOnSystemUiVisibilityChangeListener(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setImmersiveFullscreen() {
|
|
||||||
if (PreferenceUtil.isFullScreenMode) {
|
|
||||||
WindowInsetsControllerCompat(window, window.decorView).apply {
|
|
||||||
systemBarsBehavior =
|
|
||||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
|
||||||
hide(WindowInsetsCompat.Type.systemBars())
|
|
||||||
}
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
||||||
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun exitFullscreen() {
|
|
||||||
WindowInsetsControllerCompat(window, window.decorView).apply {
|
|
||||||
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
|
||||||
show(WindowInsetsCompat.Type.systemBars())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
setImmersiveFullscreen()
|
setImmersiveFullscreen()
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import code.name.monkey.retromusic.activities.bugreport.model.github.ExtraInfo
|
||||||
import code.name.monkey.retromusic.activities.bugreport.model.github.GithubLogin
|
import code.name.monkey.retromusic.activities.bugreport.model.github.GithubLogin
|
||||||
import code.name.monkey.retromusic.activities.bugreport.model.github.GithubTarget
|
import code.name.monkey.retromusic.activities.bugreport.model.github.GithubTarget
|
||||||
import code.name.monkey.retromusic.databinding.ActivityBugReportBinding
|
import code.name.monkey.retromusic.databinding.ActivityBugReportBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
||||||
import code.name.monkey.retromusic.misc.DialogAsyncTask
|
import code.name.monkey.retromusic.misc.DialogAsyncTask
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
|
|
@ -42,6 +42,7 @@ import code.name.monkey.retromusic.R.drawable
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||||
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
||||||
import code.name.monkey.retromusic.extensions.accentColor
|
import code.name.monkey.retromusic.extensions.accentColor
|
||||||
|
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
||||||
import code.name.monkey.retromusic.model.ArtworkInfo
|
import code.name.monkey.retromusic.model.ArtworkInfo
|
||||||
import code.name.monkey.retromusic.model.AudioTagInfo
|
import code.name.monkey.retromusic.model.AudioTagInfo
|
||||||
import code.name.monkey.retromusic.repository.Repository
|
import code.name.monkey.retromusic.repository.Repository
|
||||||
|
|
|
@ -32,6 +32,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.ActivityAlbumTagEditorBinding
|
import code.name.monkey.retromusic.databinding.ActivityAlbumTagEditorBinding
|
||||||
import code.name.monkey.retromusic.extensions.appHandleColor
|
import code.name.monkey.retromusic.extensions.appHandleColor
|
||||||
|
import code.name.monkey.retromusic.extensions.setDrawUnderStatusBar
|
||||||
import code.name.monkey.retromusic.extensions.setTint
|
import code.name.monkey.retromusic.extensions.setTint
|
||||||
import code.name.monkey.retromusic.glide.GlideApp
|
import code.name.monkey.retromusic.glide.GlideApp
|
||||||
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||||
|
|
|
@ -0,0 +1,139 @@
|
||||||
|
package code.name.monkey.retromusic.extensions
|
||||||
|
|
||||||
|
import android.app.ActivityManager
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.os.Build
|
||||||
|
import android.view.View
|
||||||
|
import android.view.WindowManager
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.WindowCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import code.name.monkey.appthemehelper.ATH
|
||||||
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
|
|
||||||
|
fun AppCompatActivity.toggleScreenOn() {
|
||||||
|
if (PreferenceUtil.isScreenOnEnabled) {
|
||||||
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
} else {
|
||||||
|
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AppCompatActivity.setImmersiveFullscreen() {
|
||||||
|
if (PreferenceUtil.isFullScreenMode) {
|
||||||
|
WindowInsetsControllerCompat(window, window.decorView).apply {
|
||||||
|
systemBarsBehavior =
|
||||||
|
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
|
hide(WindowInsetsCompat.Type.systemBars())
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
window.attributes.layoutInDisplayCutoutMode =
|
||||||
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AppCompatActivity.exitFullscreen() {
|
||||||
|
WindowInsetsControllerCompat(window, window.decorView).apply {
|
||||||
|
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
|
show(WindowInsetsCompat.Type.systemBars())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun AppCompatActivity.hideStatusBar() {
|
||||||
|
hideStatusBar(PreferenceUtil.isFullScreenMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun AppCompatActivity.hideStatusBar(fullscreen: Boolean) {
|
||||||
|
val statusBar = window.decorView.rootView.findViewById<View>(R.id.status_bar)
|
||||||
|
if (statusBar != null) {
|
||||||
|
statusBar.visibility = if (fullscreen) View.GONE else View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AppCompatActivity.setDrawUnderStatusBar() {
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
|
window.statusBarColor = Color.TRANSPARENT
|
||||||
|
}
|
||||||
|
|
||||||
|
fun FragmentActivity.setTaskDescriptionColor(color: Int) {
|
||||||
|
var colorFinal = color
|
||||||
|
// Task description requires fully opaque color
|
||||||
|
colorFinal = ColorUtil.stripAlpha(colorFinal)
|
||||||
|
// Sets color of entry in the system recents page
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
setTaskDescription(
|
||||||
|
ActivityManager.TaskDescription(
|
||||||
|
title as String?,
|
||||||
|
-1,
|
||||||
|
colorFinal
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
setTaskDescription(ActivityManager.TaskDescription(title as String?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AppCompatActivity.setTaskDescriptionColorAuto() {
|
||||||
|
setTaskDescriptionColor(surfaceColor())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AppCompatActivity.setLightNavigationAuto() {
|
||||||
|
ATH.setLightNavigationBarAuto(this, surfaceColor())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AppCompatActivity.setLightStatusBar(enabled: Boolean) {
|
||||||
|
ATH.setLightStatusBar(this, enabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AppCompatActivity.setLightStatusBarAuto(bgColor: Int) {
|
||||||
|
setLightStatusBar(ColorUtil.isColorLight(bgColor))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AppCompatActivity.setLightNavigationBar(enabled: Boolean) {
|
||||||
|
if (!ATHUtil.isWindowBackgroundDark(this) and ThemeStore.coloredNavigationBar(this)) {
|
||||||
|
ATH.setLightNavigationbar(this, enabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will set the color of the view with the id "status_bar" on KitKat and Lollipop. On
|
||||||
|
* Lollipop if no such view is found it will set the statusbar color using the native method.
|
||||||
|
*
|
||||||
|
* @param color the new statusbar color (will be shifted down on Lollipop and above)
|
||||||
|
*/
|
||||||
|
fun AppCompatActivity.setStatusBarColor(color: Int) {
|
||||||
|
val statusBar = window.decorView.rootView.findViewById<View>(R.id.status_bar)
|
||||||
|
if (statusBar != null) {
|
||||||
|
when {
|
||||||
|
VersionUtils.hasMarshmallow() -> statusBar.setBackgroundColor(color)
|
||||||
|
else -> statusBar.setBackgroundColor(
|
||||||
|
ColorUtil.darkenColor(
|
||||||
|
color
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
when {
|
||||||
|
VersionUtils.hasMarshmallow() -> window.statusBarColor = color
|
||||||
|
else -> window.statusBarColor = ColorUtil.darkenColor(color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setLightStatusBarAuto(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AppCompatActivity.setStatusBarColorAuto() {
|
||||||
|
// we don't want to use statusbar color because we are doing the color darkening on our own to support KitKat
|
||||||
|
setStatusBarColor(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
||||||
|
setLightStatusBarAuto(ATHUtil.resolveColor(this, R.attr.colorSurface))
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package code.name.monkey.retromusic.extensions
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import android.webkit.MimeTypeMap
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
|
import org.jaudiotagger.audio.AudioFileIO
|
||||||
|
import java.io.File
|
||||||
|
import java.net.URLEncoder
|
||||||
|
|
||||||
|
fun getSongInfo(song: Song): String {
|
||||||
|
val file = File(song.data)
|
||||||
|
if (file.exists()) {
|
||||||
|
return try {
|
||||||
|
val audioHeader = AudioFileIO.read(File(song.data)).audioHeader
|
||||||
|
val string: StringBuilder = StringBuilder()
|
||||||
|
val uriFile = Uri.fromFile(file)
|
||||||
|
string.append(getMimeType(uriFile.toString())).append(" • ")
|
||||||
|
string.append(audioHeader.bitRate).append(" kb/s").append(" • ")
|
||||||
|
string.append(RetroUtil.frequencyCount(audioHeader.sampleRate.toInt()))
|
||||||
|
.append(" kHz")
|
||||||
|
string.toString()
|
||||||
|
} catch (er: Exception) {
|
||||||
|
" - "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "-"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getMimeType(url: String): String {
|
||||||
|
var type: String? = MimeTypeMap.getFileExtensionFromUrl(
|
||||||
|
URLEncoder.encode(url, "utf-8")
|
||||||
|
).uppercase()
|
||||||
|
if (type == null) {
|
||||||
|
type = url.substring(url.lastIndexOf(".") + 1)
|
||||||
|
}
|
||||||
|
return type
|
||||||
|
}
|
|
@ -22,6 +22,8 @@ import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.MainActivity
|
import code.name.monkey.retromusic.activities.MainActivity
|
||||||
|
import code.name.monkey.retromusic.extensions.setLightStatusBarAuto
|
||||||
|
import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto
|
||||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
|
||||||
|
@ -42,7 +44,7 @@ abstract class AbsMainActivityFragment(@LayoutRes layout: Int) : AbsMusicService
|
||||||
if (statusBar != null) {
|
if (statusBar != null) {
|
||||||
if (VersionUtils.hasMarshmallow()) {
|
if (VersionUtils.hasMarshmallow()) {
|
||||||
statusBar.setBackgroundColor(color)
|
statusBar.setBackgroundColor(color)
|
||||||
mainActivity.setLightStatusbarAuto(color)
|
mainActivity.setLightStatusBarAuto(color)
|
||||||
} else {
|
} else {
|
||||||
statusBar.setBackgroundColor(color)
|
statusBar.setBackgroundColor(color)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,21 +15,14 @@
|
||||||
package code.name.monkey.retromusic.fragments.base
|
package code.name.monkey.retromusic.fragments.base
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.webkit.MimeTypeMap
|
|
||||||
import androidx.annotation.LayoutRes
|
import androidx.annotation.LayoutRes
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.navOptions
|
import androidx.navigation.navOptions
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||||
import code.name.monkey.retromusic.interfaces.IMusicServiceEventListener
|
import code.name.monkey.retromusic.interfaces.IMusicServiceEventListener
|
||||||
import code.name.monkey.retromusic.model.Song
|
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
|
||||||
import org.jaudiotagger.audio.AudioFileIO
|
|
||||||
import java.io.File
|
|
||||||
import java.net.URLEncoder
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by hemanths on 18/08/17.
|
* Created by hemanths on 18/08/17.
|
||||||
|
@ -103,33 +96,4 @@ open class AbsMusicServiceFragment(@LayoutRes layout: Int) : Fragment(layout),
|
||||||
|
|
||||||
override fun onMediaStoreChanged() {
|
override fun onMediaStoreChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSongInfo(song: Song): String {
|
|
||||||
val file = File(song.data)
|
|
||||||
if (file.exists()) {
|
|
||||||
return try {
|
|
||||||
val audioHeader = AudioFileIO.read(File(song.data)).audioHeader
|
|
||||||
val string: StringBuilder = StringBuilder()
|
|
||||||
val uriFile = Uri.fromFile(file)
|
|
||||||
string.append(getMimeType(uriFile.toString())).append(" • ")
|
|
||||||
string.append(audioHeader.bitRate).append(" kb/s").append(" • ")
|
|
||||||
string.append(RetroUtil.frequencyCount(audioHeader.sampleRate.toInt()))
|
|
||||||
.append(" kHz")
|
|
||||||
string.toString()
|
|
||||||
} catch (er: Exception) {
|
|
||||||
" - "
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "-"
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getMimeType(url: String): String {
|
|
||||||
var type: String? = MimeTypeMap.getFileExtensionFromUrl(
|
|
||||||
URLEncoder.encode(url, "utf-8")
|
|
||||||
).uppercase()
|
|
||||||
if (type == null) {
|
|
||||||
type = url.substring(url.lastIndexOf(".") + 1)
|
|
||||||
}
|
|
||||||
return type
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentAdaptivePlayerPlaybackControlsBinding
|
import code.name.monkey.retromusic.databinding.FragmentAdaptivePlayerPlaybackControlsBinding
|
||||||
import code.name.monkey.retromusic.extensions.applyColor
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
|
||||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
|
||||||
import code.name.monkey.retromusic.extensions.show
|
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
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
|
||||||
|
|
|
@ -29,6 +29,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentBlurPlayerPlaybackControlsBinding
|
import code.name.monkey.retromusic.databinding.FragmentBlurPlayerPlaybackControlsBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.getSongInfo
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
|
|
|
@ -27,6 +27,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentCardPlayerPlaybackControlsBinding
|
import code.name.monkey.retromusic.databinding.FragmentCardPlayerPlaybackControlsBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.getSongInfo
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
import code.name.monkey.retromusic.extensions.ripAlpha
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
|
|
|
@ -27,6 +27,7 @@ import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentCardBlurPlayerPlaybackControlsBinding
|
import code.name.monkey.retromusic.databinding.FragmentCardBlurPlayerPlaybackControlsBinding
|
||||||
import code.name.monkey.retromusic.extensions.applyColor
|
import code.name.monkey.retromusic.extensions.applyColor
|
||||||
|
import code.name.monkey.retromusic.extensions.getSongInfo
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
|
|
|
@ -36,6 +36,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.RetroBottomSheetBehavior
|
import code.name.monkey.retromusic.RetroBottomSheetBehavior
|
||||||
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter
|
||||||
import code.name.monkey.retromusic.databinding.FragmentClassicPlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentClassicPlayerBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.getSongInfo
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
|
|
|
@ -32,6 +32,7 @@ import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentColorPlayerPlaybackControlsBinding
|
import code.name.monkey.retromusic.databinding.FragmentColorPlayerPlaybackControlsBinding
|
||||||
import code.name.monkey.retromusic.extensions.applyColor
|
import code.name.monkey.retromusic.extensions.applyColor
|
||||||
|
import code.name.monkey.retromusic.extensions.getSongInfo
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
|
|
|
@ -29,6 +29,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentFitPlaybackControlsBinding
|
import code.name.monkey.retromusic.databinding.FragmentFitPlaybackControlsBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.getSongInfo
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
import code.name.monkey.retromusic.extensions.ripAlpha
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
|
|
|
@ -28,10 +28,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentFlatPlayerPlaybackControlsBinding
|
import code.name.monkey.retromusic.databinding.FragmentFlatPlayerPlaybackControlsBinding
|
||||||
import code.name.monkey.retromusic.extensions.applyColor
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
|
||||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
|
||||||
import code.name.monkey.retromusic.extensions.show
|
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.goToAlbum
|
import code.name.monkey.retromusic.fragments.base.goToAlbum
|
||||||
import code.name.monkey.retromusic.fragments.base.goToArtist
|
import code.name.monkey.retromusic.fragments.base.goToArtist
|
||||||
|
|
|
@ -36,6 +36,7 @@ import code.name.monkey.retromusic.db.PlaylistEntity
|
||||||
import code.name.monkey.retromusic.db.SongEntity
|
import code.name.monkey.retromusic.db.SongEntity
|
||||||
import code.name.monkey.retromusic.db.toSongEntity
|
import code.name.monkey.retromusic.db.toSongEntity
|
||||||
import code.name.monkey.retromusic.extensions.applyColor
|
import code.name.monkey.retromusic.extensions.applyColor
|
||||||
|
import code.name.monkey.retromusic.extensions.getSongInfo
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||||
|
|
|
@ -28,10 +28,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentPlayerPlaybackControlsBinding
|
import code.name.monkey.retromusic.databinding.FragmentPlayerPlaybackControlsBinding
|
||||||
import code.name.monkey.retromusic.extensions.applyColor
|
import code.name.monkey.retromusic.extensions.*
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
|
||||||
import code.name.monkey.retromusic.extensions.ripAlpha
|
|
||||||
import code.name.monkey.retromusic.extensions.show
|
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
import code.name.monkey.retromusic.fragments.base.goToAlbum
|
import code.name.monkey.retromusic.fragments.base.goToAlbum
|
||||||
import code.name.monkey.retromusic.fragments.base.goToArtist
|
import code.name.monkey.retromusic.fragments.base.goToArtist
|
||||||
|
|
|
@ -22,6 +22,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentPeakPlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentPeakPlayerBinding
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
|
import code.name.monkey.retromusic.extensions.getSongInfo
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
|
|
|
@ -30,6 +30,7 @@ import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentPlainControlsFragmentBinding
|
import code.name.monkey.retromusic.databinding.FragmentPlainControlsFragmentBinding
|
||||||
import code.name.monkey.retromusic.extensions.applyColor
|
import code.name.monkey.retromusic.extensions.applyColor
|
||||||
|
import code.name.monkey.retromusic.extensions.getSongInfo
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
|
|
|
@ -25,6 +25,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentSimpleControlsFragmentBinding
|
import code.name.monkey.retromusic.databinding.FragmentSimpleControlsFragmentBinding
|
||||||
|
import code.name.monkey.retromusic.extensions.getSongInfo
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||||
|
|
|
@ -28,6 +28,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.databinding.FragmentTinyPlayerBinding
|
import code.name.monkey.retromusic.databinding.FragmentTinyPlayerBinding
|
||||||
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
|
||||||
|
import code.name.monkey.retromusic.extensions.getSongInfo
|
||||||
import code.name.monkey.retromusic.extensions.hide
|
import code.name.monkey.retromusic.extensions.hide
|
||||||
import code.name.monkey.retromusic.extensions.show
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
|
|
|
@ -24,7 +24,7 @@ object ATH {
|
||||||
) > since
|
) > since
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setLightStatusbar(activity: Activity, enabled: Boolean) {
|
fun setLightStatusBar(activity: Activity, enabled: Boolean) {
|
||||||
activity.window.apply {
|
activity.window.apply {
|
||||||
WindowInsetsControllerCompat(
|
WindowInsetsControllerCompat(
|
||||||
this,
|
this,
|
||||||
|
@ -42,21 +42,17 @@ object ATH {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setLightNavigationbarAuto(activity: Activity, bgColor: Int) {
|
fun setLightNavigationBarAuto(activity: Activity, bgColor: Int) {
|
||||||
setLightNavigationbar(activity, ColorUtil.isColorLight(bgColor))
|
setLightNavigationbar(activity, ColorUtil.isColorLight(bgColor))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setNavigationbarColorAuto(activity: Activity) {
|
fun setNavigationBarColor(activity: Activity, color: Int) {
|
||||||
setNavigationbarColor(activity, ThemeStore.navigationBarColor(activity))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setNavigationbarColor(activity: Activity, color: Int) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
activity.window.navigationBarColor = color
|
activity.window.navigationBarColor = color
|
||||||
} else {
|
} else {
|
||||||
activity.window.navigationBarColor = ColorUtil.darkenColor(color)
|
activity.window.navigationBarColor = ColorUtil.darkenColor(color)
|
||||||
}
|
}
|
||||||
setLightNavigationbarAuto(activity, color)
|
setLightNavigationBarAuto(activity, color)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setActivityToolbarColorAuto(activity: Activity, toolbar: Toolbar?) {
|
fun setActivityToolbarColorAuto(activity: Activity, toolbar: Toolbar?) {
|
||||||
|
|
Loading…
Reference in a new issue