Added Snowfall effect

This commit is contained in:
Prathamesh More 2021-12-24 16:47:57 +05:30
parent 8e1dc3a600
commit 5a310ec329
8 changed files with 58 additions and 8 deletions

View file

@ -154,6 +154,7 @@ dependencies {
implementation 'com.github.bosphere.android-fadingedgelayout:fadingedgelayout:1.0.0'
implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:3.0.0-RC3'
implementation 'com.github.jetradarmobile:android-snowfall:1.2.1'
implementation 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5'
implementation 'com.github.Adonai:jaudiotagger:2.3.15'

View file

@ -68,6 +68,8 @@
title="FadingEdgeLayout">FadingEdgeLayout</a></b> by bosphere</p>
<p><b><a href="https://github.com/yshrsmz/KeyboardVisibilityEvent"
title="KeyboardVisibilityEvent">KeyboardVisibilityEvent</a></b> by Yasuhiro SHIMIZU</p>
<p><b><a href="https://github.com/JetradarMobile/android-snowfall"
title="android-snowfall">android-snowfall</a></b> by Jetradar Mobile</p>
<p><b><a href="https://materialdesignicons.com" title="Icons"> Icons</a></b> by Austin Andrews</p>
<p><b><a href="https://www.techjuice.pk" title="City wallpaper"> Material Design City Wallpaper</a></b>
</p>

View file

@ -152,3 +152,4 @@ const val REMEMBER_LAST_TAB = "remember_last_tab"
const val LAST_USED_TAB = "last_used_tab"
const val WHITELIST_MUSIC = "whitelist_music"
const val MATERIAL_YOU = "material_you"
const val SNOWFALL = "snowfall"

View file

@ -16,12 +16,17 @@ package code.name.monkey.retromusic.fragments.player.normal
import android.animation.ArgbEvaluator
import android.animation.ValueAnimator
import android.content.SharedPreferences
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.view.View
import androidx.appcompat.widget.Toolbar
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.preference.PreferenceManager
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.SNOWFALL
import code.name.monkey.retromusic.databinding.FragmentPlayerBinding
import code.name.monkey.retromusic.extensions.colorControlNormal
import code.name.monkey.retromusic.extensions.drawAboveSystemBars
@ -35,7 +40,8 @@ import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import code.name.monkey.retromusic.views.DrawableGradient
class PlayerFragment : AbsPlayerFragment(R.layout.fragment_player) {
class PlayerFragment : AbsPlayerFragment(R.layout.fragment_player),
SharedPreferences.OnSharedPreferenceChangeListener {
private var lastColor: Int = 0
override val paletteColor: Int
@ -120,11 +126,23 @@ class PlayerFragment : AbsPlayerFragment(R.layout.fragment_player) {
_binding = FragmentPlayerBinding.bind(view)
setUpSubFragments()
setUpPlayerToolbar()
if (PreferenceUtil.isSnowFalling) {
binding.snowfallView.isVisible = true
binding.snowfallView.restartFalling()
} else {
binding.snowfallView.isVisible = false
binding.snowfallView.stopFalling()
}
PreferenceManager.getDefaultSharedPreferences(requireContext())
.registerOnSharedPreferenceChangeListener(this)
playerToolbar().drawAboveSystemBars()
}
override fun onDestroyView() {
super.onDestroyView()
PreferenceManager.getDefaultSharedPreferences(requireContext())
.unregisterOnSharedPreferenceChangeListener(this)
_binding = null
}
@ -149,6 +167,16 @@ class PlayerFragment : AbsPlayerFragment(R.layout.fragment_player) {
)
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
if (key == SNOWFALL && PreferenceUtil.isSnowFalling) {
binding.snowfallView.isVisible = true
binding.snowfallView.restartFalling()
} else {
binding.snowfallView.isVisible = false
binding.snowfallView.stopFalling()
}
}
override fun onServiceConnected() {
updateIsFavorite()
}

View file

@ -657,4 +657,7 @@ object PreferenceUtil {
val materialYou
get() = sharedPreferences.getBoolean(MATERIAL_YOU, VersionUtils.hasS())
val isSnowFalling
get() = sharedPreferences.getBoolean(SNOWFALL, false)
}

View file

@ -7,16 +7,18 @@
android:clickable="true"
android:focusable="true">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface" />
<View
android:id="@+id/colorGradientBackground"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.jetradarmobile.snowfall.SnowfallView
android:id="@+id/snowfall_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:snowflakeSpeedMax="6"
app:snowflakeSpeedMin="2"
app:snowflakesNum="75" />
<include layout="@layout/shadow_statusbar_toolbar" />

View file

@ -8,7 +8,6 @@
android:clickable="true"
android:focusable="true">
<View
android:id="@+id/colorGradientBackground"
android:layout_width="match_parent"
@ -18,6 +17,14 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.jetradarmobile.snowfall.SnowfallView
android:id="@+id/snowfall_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:snowflakeSpeedMax="6"
app:snowflakeSpeedMin="2"
app:snowflakesNum="75" />
<include layout="@layout/shadow_statusbar_toolbar" />
<FrameLayout

View file

@ -15,6 +15,12 @@
android:summary="@string/pref_summary_extra_song_info"
android:title="@string/pref_title_extra_song_info" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false"
android:key="snowfall"
android:layout="@layout/list_item_view_switch_no_title"
android:title="Snow Fall Effect (Only on Normal theme)" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
android:layout="@layout/preference_category_title"
android:title="@string/pref_header_album">
@ -77,8 +83,8 @@
android:max="25"
android:summary="@string/pref_blur_amount_summary"
android:title="@string/pref_blur_amount_title"
app:icon="@drawable/ic_blur_on"
app:ateKey_pref_unit="px"
app:icon="@drawable/ic_blur_on"
app:showSeekBarValue="true" />
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>