Fix theming issues w/PlaybackFragment

Fix some theme issues with PlaybackFragment
This commit is contained in:
OxygenCobalt 2020-10-11 16:46:53 -06:00
parent f884adc39d
commit d8042ef159
6 changed files with 12 additions and 7 deletions

View file

@ -8,7 +8,6 @@ import org.oxycblt.auxio.theme.accent
// FIXME: Fix bug where fast navigation will break the fade animation and // FIXME: Fix bug where fast navigation will break the fade animation and
// lead to nothing being displayed [Possibly Un-fixable] // lead to nothing being displayed [Possibly Un-fixable]
class MainActivity : AppCompatActivity(R.layout.activity_main) { class MainActivity : AppCompatActivity(R.layout.activity_main) {
override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? { override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? {

View file

@ -30,6 +30,7 @@ class CompactPlaybackFragment : Fragment() {
val iconPauseToPlay = ContextCompat.getDrawable( val iconPauseToPlay = ContextCompat.getDrawable(
requireContext(), R.drawable.ic_pause_to_play requireContext(), R.drawable.ic_pause_to_play
) as AnimatedVectorDrawable ) as AnimatedVectorDrawable
val iconPlayToPause = ContextCompat.getDrawable( val iconPlayToPause = ContextCompat.getDrawable(
requireContext(), R.drawable.ic_play_to_pause requireContext(), R.drawable.ic_play_to_pause
) as AnimatedVectorDrawable ) as AnimatedVectorDrawable
@ -65,9 +66,9 @@ class CompactPlaybackFragment : Fragment() {
} }
} }
// TODO: Animate this icon
playbackModel.isPlaying.observe(viewLifecycleOwner) { playbackModel.isPlaying.observe(viewLifecycleOwner) {
if (it) { if (it) {
// Animate the icon transition when the playing status switches
binding.playbackControls.setImageDrawable(iconPauseToPlay) binding.playbackControls.setImageDrawable(iconPauseToPlay)
iconPauseToPlay.start() iconPauseToPlay.start()
} else { } else {

View file

@ -28,11 +28,12 @@ class PlaybackFragment : BottomSheetDialogFragment() {
val binding = FragmentPlaybackBinding.inflate(inflater) val binding = FragmentPlaybackBinding.inflate(inflater)
val accentColor = ColorStateList.valueOf(accent.first.toColor(requireContext())) val accentColor = ColorStateList.valueOf(accent.first.toColor(requireContext()))
val white = ColorStateList.valueOf(android.R.color.white.toColor(requireContext())) val inactiveColor = ColorStateList.valueOf(R.color.control_color.toColor(requireContext()))
val iconPauseToPlay = ContextCompat.getDrawable( val iconPauseToPlay = ContextCompat.getDrawable(
requireContext(), R.drawable.ic_pause_to_play requireContext(), R.drawable.ic_pause_to_play
) as AnimatedVectorDrawable ) as AnimatedVectorDrawable
val iconPlayToPause = ContextCompat.getDrawable( val iconPlayToPause = ContextCompat.getDrawable(
requireContext(), R.drawable.ic_play_to_pause requireContext(), R.drawable.ic_play_to_pause
) as AnimatedVectorDrawable ) as AnimatedVectorDrawable
@ -59,6 +60,8 @@ class PlaybackFragment : BottomSheetDialogFragment() {
playbackModel.isPlaying.observe(viewLifecycleOwner) { playbackModel.isPlaying.observe(viewLifecycleOwner) {
if (it) { if (it) {
// Animate the playing status and switch the button to the accent color
// if its playing, and back to a inactive gray if not.
binding.playbackPlayPause.setImageDrawable(iconPauseToPlay) binding.playbackPlayPause.setImageDrawable(iconPauseToPlay)
iconPauseToPlay.start() iconPauseToPlay.start()
@ -67,7 +70,7 @@ class PlaybackFragment : BottomSheetDialogFragment() {
binding.playbackPlayPause.setImageDrawable(iconPlayToPause) binding.playbackPlayPause.setImageDrawable(iconPlayToPause)
iconPlayToPause.start() iconPlayToPause.start()
binding.playbackPlayPause.backgroundTintList = white binding.playbackPlayPause.backgroundTintList = inactiveColor
} }
} }

View file

@ -46,7 +46,7 @@ val accent = ACCENTS[5]
@ColorInt @ColorInt
fun getTransparentAccent(context: Context, @ColorRes color: Int, alpha: Int): Int { fun getTransparentAccent(context: Context, @ColorRes color: Int, alpha: Int): Int {
return ColorUtils.setAlphaComponent( return ColorUtils.setAlphaComponent(
ContextCompat.getColor(context, color), color.toColor(context),
alpha alpha
) )
} }

View file

@ -19,7 +19,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/background" android:background="@color/background"
android:theme="@style/ThemeOverlay.AppCompat.DayNight" android:theme="@style/Theme.Base"
android:padding="@dimen/padding_medium"> android:padding="@dimen/padding_medium">
<ImageView <ImageView

View file

@ -36,5 +36,7 @@
<item name="colorControlHighlight">@color/selection_color</item> <item name="colorControlHighlight">@color/selection_color</item>
</style> </style>
<style name="Theme.BottomSheet" parent="Theme.Design.BottomSheetDialog" /> <style name="Theme.BottomSheet" parent="Theme.Design.BottomSheetDialog">
<item name="android:colorPrimary">?android:attr/colorPrimary</item>
</style>
</resources> </resources>