Tiny player update
This commit is contained in:
parent
1270912d29
commit
147b8b5292
16 changed files with 84 additions and 77 deletions
|
@ -14,7 +14,10 @@ import androidx.recyclerview.widget.DefaultItemAnimator
|
|||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.*
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
|
||||
|
@ -38,9 +41,7 @@ import code.name.monkey.retromusic.util.NavigationUtil
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.android.synthetic.main.activity_album.*
|
||||
import kotlinx.android.synthetic.main.activity_album_content.*
|
||||
import java.util.*
|
||||
|
@ -71,12 +72,12 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
|
|||
setupWindowTransition()
|
||||
super.onCreate(savedInstanceState)
|
||||
toggleBottomNavigationView(true)
|
||||
contentContainer?.setCardBackgroundColor( ColorStateList.valueOf(ThemeStore.primaryColor(this)))
|
||||
setLightNavigationBar(true)
|
||||
setNavigationbarColorAuto()
|
||||
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
contentContainer?.setCardBackgroundColor(ColorStateList.valueOf(ThemeStore.primaryColor(this)))
|
||||
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
|
||||
artistImage = findViewById(R.id.artistImage)
|
||||
|
||||
|
@ -116,19 +117,19 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
|
|||
val primaryColor = ThemeStore.primaryColor(this)
|
||||
//TintHelper.setTintAuto(contentContainer!!, primaryColor, true)
|
||||
|
||||
if (collapsingToolbarLayout != null) {
|
||||
collapsingToolbarLayout!!.apply {
|
||||
setContentScrimColor(primaryColor)
|
||||
setStatusBarScrimColor(ColorUtil.darkenColor(primaryColor))
|
||||
}
|
||||
|
||||
collapsingToolbarLayout?.let {
|
||||
it.setContentScrimColor(primaryColor)
|
||||
it.setStatusBarScrimColor(ColorUtil.darkenColor(primaryColor))
|
||||
}
|
||||
|
||||
|
||||
toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp)
|
||||
|
||||
if (toolbar != null && !PreferenceUtil.getInstance().fullScreenMode) {
|
||||
val params = toolbar!!.layoutParams as ViewGroup.MarginLayoutParams
|
||||
val params = toolbar.layoutParams as ViewGroup.MarginLayoutParams
|
||||
params.topMargin = RetroUtil.getStatusBarHeight()
|
||||
toolbar!!.layoutParams = params
|
||||
toolbar.layoutParams = params
|
||||
}
|
||||
|
||||
appBarLayout?.apply {
|
||||
|
@ -253,6 +254,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsContrac
|
|||
|
||||
MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
|
||||
MaterialUtil.setTint(button = playAction, color = buttonColor)
|
||||
|
||||
ToolbarContentTintHelper.setToolbarContentColorBasedOnToolbarColor(this@AlbumDetailsActivity, toolbar, color)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
|
|||
playerAlbumCoverFragment?.setCallbacks(this)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
statusBarShadow.hide()
|
||||
statusBarShadow?.hide()
|
||||
}
|
||||
|
||||
interface Callbacks {
|
||||
|
|
|
@ -25,7 +25,6 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
|||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.*
|
||||
|
||||
class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||
|
@ -113,17 +112,11 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
updateShuffleState()
|
||||
updatePrevNextColor()
|
||||
|
||||
text.setTextColor(lastDisabledPlaybackControlsColor)
|
||||
|
||||
val colorFinal = if (PreferenceUtil.getInstance().adaptiveColor) {
|
||||
color
|
||||
} else {
|
||||
ThemeStore.textColorSecondary(requireContext())
|
||||
}
|
||||
|
||||
text.setTextColor(colorFinal)
|
||||
TintHelper.setTintAuto(progressSlider, colorFinal.ripAlpha(), false)
|
||||
volumeFragment?.setTintableColor(Color.WHITE)
|
||||
setFabColor(colorFinal.ripAlpha())
|
||||
TintHelper.setTintAuto(progressSlider, lastPlaybackControlsColor , false)
|
||||
volumeFragment?.setTintableColor(lastPlaybackControlsColor)
|
||||
setFabColor(lastPlaybackControlsColor)
|
||||
}
|
||||
|
||||
private fun setFabColor(i: Int) {
|
||||
|
|
|
@ -5,12 +5,11 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
|
||||
import kotlinx.android.synthetic.main.fragment_tiny_controls_fragment.*
|
||||
|
||||
class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||
|
@ -28,13 +27,9 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
|
||||
override fun setDark(color: Int) {
|
||||
if (ColorUtil.isColorLight(color)) {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(getActivity(), true);
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(getActivity(), true);
|
||||
} else {
|
||||
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(getActivity(), false);
|
||||
lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(getActivity(), false);
|
||||
}
|
||||
|
||||
lastPlaybackControlsColor = ThemeStore.textColorPrimary(requireContext())
|
||||
lastDisabledPlaybackControlsColor = ThemeStore.textColorSecondary(requireContext())
|
||||
|
||||
updateRepeatState();
|
||||
updateShuffleState();
|
||||
|
@ -94,4 +89,16 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
updateRepeatState()
|
||||
updateShuffleState()
|
||||
}
|
||||
|
||||
override fun onRepeatModeChanged() {
|
||||
updateRepeatState()
|
||||
}
|
||||
|
||||
override fun onShuffleModeChanged() {
|
||||
updateShuffleState()
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
}
|
||||
|
||||
override fun toolbarIconColor(): Int {
|
||||
return MaterialValueHelper.getSecondaryTextColor(context, ColorUtil.isColorLight(lastColor))
|
||||
return ThemeStore.textColorSecondary(requireContext())
|
||||
}
|
||||
|
||||
private var lastColor: Int = 0
|
||||
|
@ -67,18 +67,20 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
get() = lastColor
|
||||
|
||||
override fun onColorChanged(color: Int) {
|
||||
|
||||
val lastColor = if (PreferenceUtil.getInstance().adaptiveColor) {
|
||||
color
|
||||
} else {
|
||||
ThemeStore.accentColor(context!!)
|
||||
ThemeStore.accentColor(requireContext())
|
||||
}
|
||||
callbacks?.onPaletteColorChanged()
|
||||
|
||||
tinyPlaybackControlsFragment.setDark(lastColor)
|
||||
|
||||
TintHelper.setTintAuto(progressBar, lastColor, false)
|
||||
|
||||
val iconColor = MaterialValueHelper.getSecondaryTextColor(context, ColorUtil.isColorLight(lastColor))
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, activity)
|
||||
val iconColor = ThemeStore.textColorSecondary(requireContext())
|
||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, requireActivity())
|
||||
}
|
||||
|
||||
override fun onFavoriteToggled() {
|
||||
|
|
|
@ -35,8 +35,8 @@ import code.name.monkey.retromusic.util.NavigationUtil
|
|||
abstract class AbsSettingsFragment : PreferenceFragmentCompat() {
|
||||
|
||||
internal fun showProToastAndNavigate(message: String) {
|
||||
Toast.makeText(context, "$message is Pro version feature.", Toast.LENGTH_SHORT).show()
|
||||
NavigationUtil.goToProVersion(activity!!)
|
||||
Toast.makeText(requireContext(), "$message is Pro version feature.", Toast.LENGTH_SHORT).show()
|
||||
NavigationUtil.goToProVersion(requireActivity())
|
||||
}
|
||||
|
||||
internal fun setSummary(preference: Preference, value: Any) {
|
||||
|
@ -60,7 +60,7 @@ abstract class AbsSettingsFragment : PreferenceFragmentCompat() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setDivider(ColorDrawable(Color.TRANSPARENT))
|
||||
listView.setBackgroundColor(ThemeStore.primaryColor(context!!))
|
||||
listView.setBackgroundColor(ThemeStore.primaryColor(requireContext()))
|
||||
listView.overScrollMode = View.OVER_SCROLL_NEVER
|
||||
listView.setPadding(0, 0, 0, 0)
|
||||
listView.setPaddingRelative(0, 0, 0, 0)
|
||||
|
|
|
@ -36,7 +36,7 @@ class AudioSettings : AbsSettingsFragment() {
|
|||
findPreference.isEnabled = true
|
||||
}
|
||||
findPreference.setOnPreferenceClickListener {
|
||||
NavigationUtil.openEqualizer(activity!!)
|
||||
NavigationUtil.openEqualizer(requireActivity())
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class AudioSettings : AbsSettingsFragment() {
|
|||
private fun hasEqualizer(): Boolean {
|
||||
val effects = Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL)
|
||||
|
||||
val pm = activity!!.packageManager
|
||||
val pm = requireActivity().packageManager
|
||||
val ri = pm.resolveActivity(effects, 0)
|
||||
return ri != null
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class ImageSettingFragment : AbsSettingsFragment() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val preference: Preference = findPreference("auto_download_images_policy")!!
|
||||
setSummary(preference)
|
||||
val preference: Preference? = findPreference("auto_download_images_policy")
|
||||
preference?.let { setSummary(it) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,8 +48,6 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
|
|||
}
|
||||
}
|
||||
|
||||
private val settingsIcons = arrayOf(R.id.general_settings_icon, R.id.audio_settings_icon, R.id.now_playing_settings_icon, R.id.personalize_settings_icon, R.id.image_settings_icon, R.id.notification_settings_icon, R.id.other_settings_icon)
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_main_settings, container, false)
|
||||
|
@ -74,20 +72,16 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
|
|||
}
|
||||
}
|
||||
buyPremium.setOnClickListener {
|
||||
NavigationUtil.goToProVersion(context!!)
|
||||
NavigationUtil.goToProVersion(requireContext())
|
||||
}
|
||||
MaterialUtil.setTint(buyPremium)
|
||||
val primaryColor = MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(ThemeStore.primaryColor(context!!)))
|
||||
val primaryColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), ColorUtil.isColorLight(ThemeStore.primaryColor(requireContext())))
|
||||
text.setTextColor(ColorUtil.withAlpha(primaryColor, 0.75f))
|
||||
//title.setTextColor(primaryColor)
|
||||
text2.setTextColor(primaryColor)
|
||||
text3.imageTintList = ColorStateList.valueOf(primaryColor)
|
||||
|
||||
}
|
||||
|
||||
private fun inflateFragment(fragment: Fragment, @StringRes title: Int) {
|
||||
if (activity != null) {
|
||||
(activity as SettingsActivity).setupFragment(fragment, title)
|
||||
}
|
||||
(requireActivity() as SettingsActivity).setupFragment(fragment, title)
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import android.os.Build.VERSION
|
|||
import android.os.Build.VERSION_CODES
|
||||
import android.os.Bundle
|
||||
import androidx.preference.TwoStatePreference
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
|
||||
|
||||
|
@ -58,6 +59,6 @@ class NotificationSettingsFragment : AbsSettingsFragment() {
|
|||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(code.name.monkey.retromusic.R.xml.pref_notification)
|
||||
addPreferencesFromResource(R.xml.pref_notification)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
else
|
||||
PreferenceUtil.getThemeResFromPrefValue("dark")
|
||||
|
||||
ThemeStore.editTheme(context).activityTheme(theme).primaryColor(color).commit()
|
||||
ThemeStore.editTheme(requireContext()).activityTheme(theme).primaryColor(color).commit()
|
||||
|
||||
if (VersionUtils.hasNougatMR())
|
||||
DynamicShortcutManager(context).updateDynamicShortcuts()
|
||||
|
@ -107,10 +107,10 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
.commit()
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
activity?.setTheme(PreferenceUtil.getThemeResFromPrefValue(theme))
|
||||
requireActivity().setTheme(PreferenceUtil.getThemeResFromPrefValue(theme))
|
||||
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
||||
}
|
||||
activity?.recreate()
|
||||
requireActivity().recreate()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -128,9 +128,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
if (!ColorUtil.isColorSaturated(color)) {
|
||||
colorFinal = color
|
||||
}*/
|
||||
ThemeStore.editTheme(context).accentColor(color).commit()
|
||||
ThemeStore.editTheme(requireContext()).accentColor(color).commit()
|
||||
if (VersionUtils.hasNougatMR())
|
||||
DynamicShortcutManager(context).updateDynamicShortcuts()
|
||||
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
||||
requireActivity().recreate()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.provider.DocumentsContract
|
|||
import android.provider.MediaStore
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat
|
||||
import code.name.monkey.retromusic.loaders.SongLoader
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
|
@ -108,9 +109,12 @@ object MusicPlayerRemote {
|
|||
}
|
||||
|
||||
val contextWrapper = ContextWrapper(realActivity)
|
||||
|
||||
contextWrapper.startService(Intent(contextWrapper, MusicService::class.java))
|
||||
|
||||
val intent = Intent(contextWrapper, MusicService::class.java)
|
||||
try {
|
||||
contextWrapper.startService(intent)
|
||||
} catch (ignored: IllegalStateException) {
|
||||
ContextCompat.startForegroundService(context, intent)
|
||||
}
|
||||
val binder = ServiceBinder(callback)
|
||||
|
||||
if (contextWrapper.bindService(Intent().setClass(contextWrapper, MusicService::class.java), binder, Context.BIND_AUTO_CREATE)) {
|
||||
|
@ -140,8 +144,8 @@ object MusicPlayerRemote {
|
|||
try {
|
||||
cursor = context.contentResolver.query(uri, projection, null, null, null)
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
val column_index = cursor.getColumnIndexOrThrow(column)
|
||||
return cursor.getString(column_index)
|
||||
val columnIndex = cursor.getColumnIndexOrThrow(column)
|
||||
return cursor.getString(columnIndex)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, e.message)
|
||||
|
|
|
@ -10,10 +10,8 @@
|
|||
android:clipOrientation="vertical"
|
||||
android:gravity="bottom">
|
||||
<shape>
|
||||
<gradient
|
||||
android:angle="135"
|
||||
android:endColor="@color/md_blue_A200"
|
||||
android:startColor="@color/md_green_A700" />
|
||||
<solid
|
||||
android:color="@color/md_deep_purple_A400" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
|
|
|
@ -33,13 +33,13 @@
|
|||
android:id="@+id/toolbarContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="0dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
app:strokeColor="?dividerColor"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:strokeColor="?dividerColor"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<FrameLayout
|
||||
|
@ -49,8 +49,9 @@
|
|||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Toolbar"
|
||||
app:title="@string/search_hint"
|
||||
app:titleMarginStart="0dp"
|
||||
app:title="@string/library"
|
||||
app:titleTextAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
|
||||
<ViewStub
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
tools:layout="@layout/fragment_player_album_cover" />
|
||||
|
||||
<View
|
||||
android:id="@+id/masked"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#90000000" />
|
||||
android:background="?colorPrimary" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
|
|
|
@ -226,9 +226,12 @@ public final class ToolbarContentTintHelper {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void setToolbarContentColor(@NonNull Context context, Toolbar toolbar,
|
||||
@Nullable Menu menu, final @ColorInt int toolbarContentColor,
|
||||
final @ColorInt int titleTextColor, final @ColorInt int subtitleTextColor,
|
||||
public static void setToolbarContentColor(@NonNull Context context,
|
||||
Toolbar toolbar,
|
||||
@Nullable Menu menu,
|
||||
final @ColorInt int toolbarContentColor,
|
||||
final @ColorInt int titleTextColor,
|
||||
final @ColorInt int subtitleTextColor,
|
||||
final @ColorInt int menuWidgetColor) {
|
||||
if (toolbar == null) {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue