From e5743ee98b32c51b7680b1f0206bc7c45e59d6f1 Mon Sep 17 00:00:00 2001 From: Prathamesh More Date: Thu, 2 Dec 2021 00:37:43 +0530 Subject: [PATCH] [Cleanup] Converted functions of super class(AbsThemeActivity) to extension functions --- app/src/main/AndroidManifest.xml | 2 +- .../activities/DriveModeActivity.kt | 1 + .../activities/LockScreenActivity.kt | 4 +- .../retromusic/activities/MainActivity.kt | 4 +- .../activities/PermissionActivity.kt | 4 +- .../retromusic/activities/PurchaseActivity.kt | 7 +- .../retromusic/activities/SettingsActivity.kt | 7 +- .../activities/ShareInstagramStory.kt | 8 +- .../activities/SupportDevelopmentActivity.kt | 4 +- .../retromusic/activities/WhatsNewActivity.kt | 4 +- .../base/AbsSlidingMusicPanelActivity.kt | 36 ++--- .../activities/base/AbsThemeActivity.kt | 135 +---------------- .../activities/bugreport/BugReportActivity.kt | 1 + .../tageditor/AbsTagEditorActivity.kt | 1 + .../tageditor/AlbumTagEditorActivity.kt | 1 + .../extensions/ActivityThemeExtensions.kt | 139 ++++++++++++++++++ .../extensions/FragmentMusicExtensions.kt | 39 +++++ .../fragments/base/AbsMainActivityFragment.kt | 4 +- .../fragments/base/AbsMusicServiceFragment.kt | 36 ----- .../AdaptivePlaybackControlsFragment.kt | 5 +- .../blur/BlurPlaybackControlsFragment.kt | 1 + .../card/CardPlaybackControlsFragment.kt | 1 + .../CardBlurPlaybackControlsFragment.kt | 1 + .../player/classic/ClassicPlayerFragment.kt | 1 + .../color/ColorPlaybackControlsFragment.kt | 1 + .../player/fit/FitPlaybackControlsFragment.kt | 1 + .../flat/FlatPlaybackControlsFragment.kt | 5 +- .../full/FullPlaybackControlsFragment.kt | 1 + .../normal/PlayerPlaybackControlsFragment.kt | 5 +- .../player/peak/PeakPlayerFragment.kt | 1 + .../plain/PlainPlaybackControlsFragment.kt | 1 + .../simple/SimplePlaybackControlsFragment.kt | 1 + .../player/tiny/TinyPlayerFragment.kt | 1 + .../code/name/monkey/appthemehelper/ATH.kt | 12 +- 34 files changed, 249 insertions(+), 226 deletions(-) create mode 100644 app/src/main/java/code/name/monkey/retromusic/extensions/ActivityThemeExtensions.kt create mode 100644 app/src/main/java/code/name/monkey/retromusic/extensions/FragmentMusicExtensions.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a4ea84e9..fda8258e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -296,6 +296,6 @@ + android:value="code.name.monkey.retromusic.cast.CastOptionsProvider" /> diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/DriveModeActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/DriveModeActivity.kt index d2bbcbe2..df912bcd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/DriveModeActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/DriveModeActivity.kt @@ -24,6 +24,7 @@ import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity 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.glide.BlurTransformation import code.name.monkey.retromusic.glide.GlideApp diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt index ba026cdb..46c1e438 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt @@ -24,7 +24,7 @@ import androidx.core.view.ViewCompat import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity 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.glide.GlideApp import code.name.monkey.retromusic.glide.RetroGlideExtension @@ -47,7 +47,7 @@ class LockScreenActivity : AbsMusicServiceActivity() { binding = ActivityLockScreenBinding.inflate(layoutInflater) setContentView(binding.root) hideStatusBar() - setStatusbarColorAuto() + setStatusBarColorAuto() setTaskDescriptionColorAuto() val config = SlidrConfig.Builder().listener(object : SlidrListener { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt index 59b59bf1..632cf71f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt @@ -26,9 +26,7 @@ import androidx.navigation.ui.setupWithNavController import code.name.monkey.retromusic.* import code.name.monkey.retromusic.activities.base.AbsCastActivity import code.name.monkey.retromusic.databinding.SlidingMusicPanelLayoutBinding -import code.name.monkey.retromusic.extensions.currentFragment -import code.name.monkey.retromusic.extensions.extra -import code.name.monkey.retromusic.extensions.findNavController +import code.name.monkey.retromusic.extensions.* import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewFragment import code.name.monkey.retromusic.fragments.home.HomeFragment import code.name.monkey.retromusic.helper.MusicPlayerRemote diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PermissionActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PermissionActivity.kt index 34d4a50c..8a5d7543 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/PermissionActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/PermissionActivity.kt @@ -30,6 +30,8 @@ import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity import code.name.monkey.retromusic.databinding.ActivityPermissionBinding 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.util.RingtoneManager @@ -40,7 +42,7 @@ class PermissionActivity : AbsMusicServiceActivity() { super.onCreate(savedInstanceState) binding = ActivityPermissionBinding.inflate(layoutInflater) setContentView(binding.root) - setStatusbarColorAuto() + setStatusBarColorAuto() setTaskDescriptionColorAuto() setupTitle() diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt index 1550ee3c..1054c1ef 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt @@ -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.activities.base.AbsBaseActivity 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.PurchaseInfo @@ -41,8 +44,8 @@ class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler { super.onCreate(savedInstanceState) binding = ActivityProVersionBinding.inflate(layoutInflater) setContentView(binding.root) - setStatusbarColor(Color.TRANSPARENT) - setLightStatusbar(false) + setStatusBarColor(Color.TRANSPARENT) + setLightStatusBar(false) binding.toolbar.navigationIcon?.setTint(Color.WHITE) binding.toolbar.setNavigationOnClickListener { onBackPressed() } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt index b9a233bb..39702cf9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt @@ -25,10 +25,7 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsThemeActivity import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager import code.name.monkey.retromusic.databinding.ActivitySettingsBinding -import code.name.monkey.retromusic.extensions.applyToolbar -import code.name.monkey.retromusic.extensions.extra -import code.name.monkey.retromusic.extensions.findNavController -import code.name.monkey.retromusic.extensions.surfaceColor +import code.name.monkey.retromusic.extensions.* import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.color.ColorCallback @@ -38,7 +35,7 @@ class SettingsActivity : AbsThemeActivity(), ColorCallback, OnThemeChangedListen setDrawUnderStatusBar() val mSavedInstanceState = extra(TAG).value ?: savedInstanceState super.onCreate(mSavedInstanceState) - setLightStatusbarAuto(surfaceColor()) + setLightStatusBarAuto(surfaceColor()) binding = ActivitySettingsBinding.inflate(layoutInflater) setContentView(binding.root) setupToolbar() diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/ShareInstagramStory.kt b/app/src/main/java/code/name/monkey/retromusic/activities/ShareInstagramStory.kt index a0a71973..6fd9a2b8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/ShareInstagramStory.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/ShareInstagramStory.kt @@ -28,6 +28,10 @@ import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.retromusic.activities.base.AbsBaseActivity 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.RetroGlideExtension import code.name.monkey.retromusic.glide.RetroMusicColoredTarget @@ -60,7 +64,7 @@ class ShareInstagramStory : AbsBaseActivity() { super.onCreate(savedInstanceState) binding = ActivityShareInstagramBinding.inflate(layoutInflater) setContentView(binding.root) - setStatusbarColor(Color.TRANSPARENT) + setStatusBarColor(Color.TRANSPARENT) binding.toolbar.setBackgroundColor(Color.TRANSPARENT) setSupportActionBar(binding.toolbar) @@ -104,7 +108,7 @@ class ShareInstagramStory : AbsBaseActivity() { } private fun setColors(colorLight: Boolean, color: Int) { - setLightStatusbar(colorLight) + setLightStatusBar(colorLight) binding.toolbar.setTitleTextColor( MaterialValueHelper.getPrimaryTextColor( this@ShareInstagramStory, diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt index 128746fb..b055c45e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt @@ -37,6 +37,8 @@ import code.name.monkey.retromusic.BuildConfig import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsBaseActivity import code.name.monkey.retromusic.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.textColorSecondary import com.anjlab.android.iab.v3.BillingProcessor @@ -73,7 +75,7 @@ class SupportDevelopmentActivity : AbsBaseActivity(), BillingProcessor.IBillingH binding = ActivityDonationBinding.inflate(layoutInflater) setContentView(binding.root) - setStatusbarColorAuto() + setStatusBarColorAuto() setTaskDescriptionColorAuto() setupToolbar() diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.kt index a8b05999..40200eba 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.kt @@ -17,6 +17,8 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsThemeActivity import code.name.monkey.retromusic.databinding.ActivityWhatsNewBinding 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.RetroUtil import java.io.BufferedReader @@ -29,7 +31,7 @@ class WhatsNewActivity : AbsThemeActivity() { super.onCreate(savedInstanceState) val binding = ActivityWhatsNewBinding.inflate(layoutInflater) setContentView(binding.root) - setLightStatusbarAuto(resolveColor(this, R.attr.colorSurface)) + setLightStatusBarAuto(resolveColor(this, R.attr.colorSurface)) setTaskDescriptionColorAuto() binding.toolbar.setNavigationOnClickListener { onBackPressed() } ToolbarContentTintHelper.colorBackButton(binding.toolbar) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt index fea75a46..5c800900 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt @@ -184,9 +184,9 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() { open fun onPanelCollapsed() { setMiniPlayerAlphaProgress(0F) // restore values - super.setLightStatusbarAuto(surfaceColor()) - super.setLightNavigationAuto() - super.setTaskDescriptionColor(taskColor) + setLightStatusBarAuto(surfaceColor()) + setLightNavigationAuto() + setTaskDescriptionColor(taskColor) } open fun onPanelExpanded() { @@ -257,26 +257,26 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() { private fun onPaletteColorChanged() { if (panelState == STATE_EXPANDED) { - super.setTaskDescriptionColor(paletteColor) + setTaskDescColor(paletteColor) val isColorLight = ColorUtil.isColorLight(paletteColor) if (PreferenceUtil.isAdaptiveColor && (nowPlayingScreen == Normal || nowPlayingScreen == Flat)) { - super.setLightNavigationBar(true) - super.setLightStatusbar(isColorLight) + setLightNavigationBar(true) + setLightStatusBar(isColorLight) } else if (nowPlayingScreen == Card || nowPlayingScreen == Blur || nowPlayingScreen == BlurCard) { - super.setLightStatusbar(false) - super.setLightNavigationBar(true) + setLightStatusBar(false) + setLightNavigationBar(true) } else if (nowPlayingScreen == Color || nowPlayingScreen == Tiny || nowPlayingScreen == Gradient) { - super.setLightNavigationBar(isColorLight) - super.setLightStatusbar(isColorLight) + setLightNavigationBar(isColorLight) + setLightStatusBar(isColorLight) } else if (nowPlayingScreen == Full) { - super.setLightNavigationBar(isColorLight) - super.setLightStatusbar(false) + setLightNavigationBar(isColorLight) + setLightStatusBar(false) } else if (nowPlayingScreen == Classic) { - super.setLightStatusbar(false) + setLightStatusBar(false) } else if (nowPlayingScreen == Fit) { - super.setLightStatusbar(false) + setLightStatusBar(false) } else { - super.setLightStatusbar( + setLightStatusBar( ColorUtil.isColorLight( ATHUtil.resolveColor( 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 if (panelState == STATE_COLLAPSED) { - super.setTaskDescriptionColor(color) + setTaskDescriptionColor(color) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt index 598cdc34..87ff2f32 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt @@ -16,29 +16,16 @@ package code.name.monkey.retromusic.activities.base import android.content.Context import android.content.res.Resources -import android.graphics.Color -import android.os.Build import android.os.Bundle import android.os.Handler import android.view.KeyEvent import android.view.View -import android.view.WindowManager -import androidx.annotation.ColorInt import androidx.appcompat.app.AppCompatDelegate.setDefaultNightMode 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.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.R -import code.name.monkey.retromusic.extensions.surfaceColor +import code.name.monkey.retromusic.extensions.* import code.name.monkey.retromusic.util.PreferenceUtil -import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.theme.ThemeManager import com.google.android.material.color.DynamicColors import java.util.* @@ -54,9 +41,8 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable { setImmersiveFullscreen() registerSystemUiVisibility() toggleScreenOn() - setDrawUnderNavigationBar() setLightNavigationAuto() - setLightStatusbarAuto(surfaceColor()) + setLightStatusBarAuto(surfaceColor()) } 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) { super.onWindowFocusChanged(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(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(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() { val decorView = window.decorView decorView.setOnSystemUiVisibilityChangeListener { visibility -> @@ -194,26 +83,6 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable { 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() { setImmersiveFullscreen() } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt index cc0ca55c..c446fdcf 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt @@ -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.GithubTarget import code.name.monkey.retromusic.databinding.ActivityBugReportBinding +import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto import code.name.monkey.retromusic.misc.DialogAsyncTask import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.floatingactionbutton.FloatingActionButton diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt index 3c6d0c7e..cee65c01 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt @@ -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.saf.SAFGuideActivity 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.AudioTagInfo import code.name.monkey.retromusic.repository.Repository diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt index bd6bf459..4b9958c6 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt @@ -32,6 +32,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.ActivityAlbumTagEditorBinding 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.glide.GlideApp import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper diff --git a/app/src/main/java/code/name/monkey/retromusic/extensions/ActivityThemeExtensions.kt b/app/src/main/java/code/name/monkey/retromusic/extensions/ActivityThemeExtensions.kt new file mode 100644 index 00000000..4806c1ba --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/extensions/ActivityThemeExtensions.kt @@ -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(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(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)) +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/extensions/FragmentMusicExtensions.kt b/app/src/main/java/code/name/monkey/retromusic/extensions/FragmentMusicExtensions.kt new file mode 100644 index 00000000..c1998b6b --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/extensions/FragmentMusicExtensions.kt @@ -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 +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt index 0ced7780..7ee590fd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt @@ -22,6 +22,8 @@ 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.activities.MainActivity +import code.name.monkey.retromusic.extensions.setLightStatusBarAuto +import code.name.monkey.retromusic.extensions.setTaskDescriptionColorAuto import code.name.monkey.retromusic.fragments.LibraryViewModel import org.koin.androidx.viewmodel.ext.android.sharedViewModel @@ -42,7 +44,7 @@ abstract class AbsMainActivityFragment(@LayoutRes layout: Int) : AbsMusicService if (statusBar != null) { if (VersionUtils.hasMarshmallow()) { statusBar.setBackgroundColor(color) - mainActivity.setLightStatusbarAuto(color) + mainActivity.setLightStatusBarAuto(color) } else { statusBar.setBackgroundColor(color) } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt index 6be8f2d5..536c46e1 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt @@ -15,21 +15,14 @@ package code.name.monkey.retromusic.fragments.base import android.content.Context -import android.net.Uri import android.os.Bundle import android.view.View -import android.webkit.MimeTypeMap import androidx.annotation.LayoutRes import androidx.fragment.app.Fragment import androidx.navigation.navOptions import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity 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. @@ -103,33 +96,4 @@ open class AbsMusicServiceFragment(@LayoutRes layout: Int) : Fragment(layout), 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 - } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt index a1196a03..55891b96 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt @@ -29,10 +29,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentAdaptivePlayerPlaybackControlsBinding -import code.name.monkey.retromusic.extensions.applyColor -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.extensions.* import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt index 55f8e322..83dcd1fc 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt @@ -29,6 +29,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentBlurPlayerPlaybackControlsBinding +import code.name.monkey.retromusic.extensions.getSongInfo import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt index a142ebaf..f9647e6b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt @@ -27,6 +27,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentCardPlayerPlaybackControlsBinding +import code.name.monkey.retromusic.extensions.getSongInfo import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.show diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt index a78ed750..753a060e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt @@ -27,6 +27,7 @@ import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentCardBlurPlayerPlaybackControlsBinding 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.show import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt index f0d5c696..6a34c809 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt @@ -36,6 +36,7 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.RetroBottomSheetBehavior import code.name.monkey.retromusic.adapter.song.PlayingQueueAdapter 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.show import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorPlaybackControlsFragment.kt index 7b3170af..22ffee1e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorPlaybackControlsFragment.kt @@ -32,6 +32,7 @@ import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentColorPlayerPlaybackControlsBinding 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.show import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitPlaybackControlsFragment.kt index e7bab207..a480f4e7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitPlaybackControlsFragment.kt @@ -29,6 +29,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentFitPlaybackControlsBinding +import code.name.monkey.retromusic.extensions.getSongInfo import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.ripAlpha import code.name.monkey.retromusic.extensions.show diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlaybackControlsFragment.kt index 4d277fa2..c258edd4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlaybackControlsFragment.kt @@ -28,10 +28,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentFlatPlayerPlaybackControlsBinding -import code.name.monkey.retromusic.extensions.applyColor -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.extensions.* import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.goToAlbum import code.name.monkey.retromusic.fragments.base.goToArtist diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlaybackControlsFragment.kt index 968794db..24a3616a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlaybackControlsFragment.kt @@ -36,6 +36,7 @@ import code.name.monkey.retromusic.db.PlaylistEntity import code.name.monkey.retromusic.db.SongEntity import code.name.monkey.retromusic.db.toSongEntity 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.show import code.name.monkey.retromusic.fragments.LibraryViewModel diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt index 79631258..c0306e71 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt @@ -28,10 +28,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentPlayerPlaybackControlsBinding -import code.name.monkey.retromusic.extensions.applyColor -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.extensions.* import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment import code.name.monkey.retromusic.fragments.base.goToAlbum import code.name.monkey.retromusic.fragments.base.goToArtist diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt index 9b2b0b11..c2ed05b6 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt @@ -22,6 +22,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentPeakPlayerBinding 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.show import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlaybackControlsFragment.kt index 2f3d45c3..f8438b0f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlaybackControlsFragment.kt @@ -30,6 +30,7 @@ import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentPlainControlsFragmentBinding 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.show import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt index 16aaaf71..5619b42f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt @@ -25,6 +25,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentSimpleControlsFragmentBinding +import code.name.monkey.retromusic.extensions.getSongInfo import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt index 80ba1c56..e73992e0 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt @@ -28,6 +28,7 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.databinding.FragmentTinyPlayerBinding 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.show import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATH.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATH.kt index 6653930a..1c4a65fe 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATH.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/ATH.kt @@ -24,7 +24,7 @@ object ATH { ) > since } - fun setLightStatusbar(activity: Activity, enabled: Boolean) { + fun setLightStatusBar(activity: Activity, enabled: Boolean) { activity.window.apply { WindowInsetsControllerCompat( this, @@ -42,21 +42,17 @@ object ATH { } } - fun setLightNavigationbarAuto(activity: Activity, bgColor: Int) { + fun setLightNavigationBarAuto(activity: Activity, bgColor: Int) { setLightNavigationbar(activity, ColorUtil.isColorLight(bgColor)) } - fun setNavigationbarColorAuto(activity: Activity) { - setNavigationbarColor(activity, ThemeStore.navigationBarColor(activity)) - } - - fun setNavigationbarColor(activity: Activity, color: Int) { + fun setNavigationBarColor(activity: Activity, color: Int) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { activity.window.navigationBarColor = color } else { activity.window.navigationBarColor = ColorUtil.darkenColor(color) } - setLightNavigationbarAuto(activity, color) + setLightNavigationBarAuto(activity, color) } fun setActivityToolbarColorAuto(activity: Activity, toolbar: Toolbar?) {