Fix theming issues w/PlaybackFragment
Fix some theme issues with PlaybackFragment
This commit is contained in:
parent
f884adc39d
commit
d8042ef159
6 changed files with 12 additions and 7 deletions
|
@ -8,7 +8,6 @@ import org.oxycblt.auxio.theme.accent
|
|||
|
||||
// FIXME: Fix bug where fast navigation will break the fade animation and
|
||||
// lead to nothing being displayed [Possibly Un-fixable]
|
||||
|
||||
class MainActivity : AppCompatActivity(R.layout.activity_main) {
|
||||
|
||||
override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? {
|
||||
|
|
|
@ -30,6 +30,7 @@ class CompactPlaybackFragment : Fragment() {
|
|||
val iconPauseToPlay = ContextCompat.getDrawable(
|
||||
requireContext(), R.drawable.ic_pause_to_play
|
||||
) as AnimatedVectorDrawable
|
||||
|
||||
val iconPlayToPause = ContextCompat.getDrawable(
|
||||
requireContext(), R.drawable.ic_play_to_pause
|
||||
) as AnimatedVectorDrawable
|
||||
|
@ -65,9 +66,9 @@ class CompactPlaybackFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Animate this icon
|
||||
playbackModel.isPlaying.observe(viewLifecycleOwner) {
|
||||
if (it) {
|
||||
// Animate the icon transition when the playing status switches
|
||||
binding.playbackControls.setImageDrawable(iconPauseToPlay)
|
||||
iconPauseToPlay.start()
|
||||
} else {
|
||||
|
|
|
@ -28,11 +28,12 @@ class PlaybackFragment : BottomSheetDialogFragment() {
|
|||
val binding = FragmentPlaybackBinding.inflate(inflater)
|
||||
|
||||
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(
|
||||
requireContext(), R.drawable.ic_pause_to_play
|
||||
) as AnimatedVectorDrawable
|
||||
|
||||
val iconPlayToPause = ContextCompat.getDrawable(
|
||||
requireContext(), R.drawable.ic_play_to_pause
|
||||
) as AnimatedVectorDrawable
|
||||
|
@ -59,6 +60,8 @@ class PlaybackFragment : BottomSheetDialogFragment() {
|
|||
|
||||
playbackModel.isPlaying.observe(viewLifecycleOwner) {
|
||||
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)
|
||||
iconPauseToPlay.start()
|
||||
|
||||
|
@ -67,7 +70,7 @@ class PlaybackFragment : BottomSheetDialogFragment() {
|
|||
binding.playbackPlayPause.setImageDrawable(iconPlayToPause)
|
||||
iconPlayToPause.start()
|
||||
|
||||
binding.playbackPlayPause.backgroundTintList = white
|
||||
binding.playbackPlayPause.backgroundTintList = inactiveColor
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ val accent = ACCENTS[5]
|
|||
@ColorInt
|
||||
fun getTransparentAccent(context: Context, @ColorRes color: Int, alpha: Int): Int {
|
||||
return ColorUtils.setAlphaComponent(
|
||||
ContextCompat.getColor(context, color),
|
||||
color.toColor(context),
|
||||
alpha
|
||||
)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/background"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.DayNight"
|
||||
android:theme="@style/Theme.Base"
|
||||
android:padding="@dimen/padding_medium">
|
||||
|
||||
<ImageView
|
||||
|
|
|
@ -36,5 +36,7 @@
|
|||
<item name="colorControlHighlight">@color/selection_color</item>
|
||||
</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>
|
Loading…
Reference in a new issue