Skip to content
Snippets Groups Projects
Commit f4896532 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Fix TV grid background on focus change

parent a7c5100e
No related branches found
No related tags found
1 merge request!1079Fix TV grid background on focus change
Pipeline #133707 passed with stage
in 3 minutes and 3 seconds
<?xml version="1.0" encoding="utf-8"?>
<!--
~ *************************************************************************
~ tv_card_background_focused.xml
~ **************************************************************************
~ Copyright © 2021 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/tv_card_content"/>
<corners android:radius="3dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ *************************************************************************
~ tv_card_background_transition.xml
~ **************************************************************************
~ Copyright © 2021 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The drawables used here can be solid colors, gradients, shapes, images, etc. -->
<item android:drawable="@drawable/tv_card_background" />
<item android:drawable="@drawable/tv_card_background_focused" />
</transition>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ *************************************************************************
~ tv_list_background_transition.xml
~ **************************************************************************
~ Copyright © 2021 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The drawables used here can be solid colors, gradients, shapes, images, etc. -->
<item android:drawable="@color/tv_card_content_dark" />
<item android:drawable="@color/tv_card_content" />
</transition>
\ No newline at end of file
......@@ -26,6 +26,7 @@ package org.videolan.television.ui.browser
import android.animation.ArgbEvaluator
import android.animation.ValueAnimator
import android.graphics.drawable.TransitionDrawable
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
......@@ -57,15 +58,8 @@ object TvAdapterUtils {
container.animate().scaleX(1f).scaleY(1f)
}
if (isList) {
val colorFrom = ContextCompat.getColor(container.context, R.color.tv_card_content_dark)
val colorTo = ContextCompat.getColor(container.context, R.color.tv_card_content)
val colorAnimation = if (hasFocus) ValueAnimator.ofObject(ArgbEvaluator(), colorFrom, colorTo) else ValueAnimator.ofObject(ArgbEvaluator(), colorTo, colorFrom)
colorAnimation.duration = 250 // milliseconds
colorAnimation.addUpdateListener { animator -> container.setBackgroundColor(animator.animatedValue as Int) }
colorAnimation.start()
(container.background as? TransitionDrawable)?.let {
if (hasFocus) it.startTransition(250) else it.reverseTransition(250)
}
}
}
\ No newline at end of file
......@@ -67,7 +67,7 @@
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/tv_card_background"
android:background="@drawable/tv_card_background_transition"
android:clickable="true"
android:focusable="true"
android:longClickable="true"
......
......@@ -98,7 +98,7 @@
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/tv_card_content_dark"
android:background="@drawable/tv_list_background_transition"
android:clickable="true"
android:focusable="true"
android:longClickable="true"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment