diff --git a/app/src/main/java/org/jellyfin/androidtv/ui/ServerButtonView.kt b/app/src/main/java/org/jellyfin/androidtv/ui/ServerButtonView.kt index 3b5b8477fd..76273c29d1 100644 --- a/app/src/main/java/org/jellyfin/androidtv/ui/ServerButtonView.kt +++ b/app/src/main/java/org/jellyfin/androidtv/ui/ServerButtonView.kt @@ -20,6 +20,7 @@ class ServerButtonView @JvmOverloads constructor( init { isFocusable = true + isClickable = true descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS } diff --git a/app/src/main/java/org/jellyfin/androidtv/ui/home/HomeToolbarFragment.kt b/app/src/main/java/org/jellyfin/androidtv/ui/home/HomeToolbarFragment.kt index f672659fc8..3904a65c2a 100644 --- a/app/src/main/java/org/jellyfin/androidtv/ui/home/HomeToolbarFragment.kt +++ b/app/src/main/java/org/jellyfin/androidtv/ui/home/HomeToolbarFragment.kt @@ -1,17 +1,18 @@ package org.jellyfin.androidtv.ui.home import android.content.Intent +import android.graphics.PorterDuff import android.graphics.drawable.Drawable import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageButton -import androidx.core.view.isVisible import androidx.fragment.app.Fragment import com.bumptech.glide.Glide import com.bumptech.glide.request.target.CustomViewTarget import com.bumptech.glide.request.transition.Transition +import org.jellyfin.androidtv.R import org.jellyfin.androidtv.TvApp import org.jellyfin.androidtv.auth.SessionRepository import org.jellyfin.androidtv.databinding.FragmentToolbarHomeBinding @@ -40,7 +41,7 @@ class HomeToolbarFragment : Fragment() { activity?.startActivity(settingsIntent) } - binding.switchUsersContainer.setOnClickListener { + binding.switchUsers.setOnClickListener { switchUser() } @@ -55,25 +56,23 @@ class HomeToolbarFragment : Fragment() { private fun setUserImage(image: String?) { Glide.with(requireContext()) .load(image) + .placeholder(R.drawable.ic_switch_users) .centerInside() .circleCrop() - .into(object : CustomViewTarget(binding.switchUsersImage) { + .into(object : CustomViewTarget(binding.switchUsers) { override fun onLoadFailed(errorDrawable: Drawable?) { - binding.switchUsersImage.isVisible = false - binding.switchUsersIcon.isVisible = true - binding.switchUsersImage.setImageDrawable(null) + binding.switchUsers.imageTintMode = PorterDuff.Mode.SRC_IN + binding.switchUsers.setImageDrawable(errorDrawable) } override fun onResourceReady(resource: Drawable, transition: Transition?) { - binding.switchUsersImage.isVisible = true - binding.switchUsersIcon.isVisible = false - binding.switchUsersImage.setImageDrawable(resource) + binding.switchUsers.imageTintMode = null + binding.switchUsers.setImageDrawable(resource) } override fun onResourceCleared(placeholder: Drawable?) { - binding.switchUsersImage.isVisible = false - binding.switchUsersIcon.isVisible = true - binding.switchUsersImage.setImageDrawable(null) + binding.switchUsers.imageTintMode = PorterDuff.Mode.SRC_IN + binding.switchUsers.setImageDrawable(placeholder) } }) } diff --git a/app/src/main/res/layout/fragment_toolbar_home.xml b/app/src/main/res/layout/fragment_toolbar_home.xml index 9e4344fa91..375e7bf5f9 100644 --- a/app/src/main/res/layout/fragment_toolbar_home.xml +++ b/app/src/main/res/layout/fragment_toolbar_home.xml @@ -36,33 +36,12 @@ android:layout_width="8dp" android:layout_height="0dp" /> - - - - - - - + diff --git a/app/src/main/res/layout/view_button_server.xml b/app/src/main/res/layout/view_button_server.xml index c3f0ea7c35..0a4eaee732 100644 --- a/app/src/main/res/layout/view_button_server.xml +++ b/app/src/main/res/layout/view_button_server.xml @@ -3,6 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" style="@style/Button.Default" + android:clickable="false" android:layout_width="match_parent" android:layout_height="wrap_content" android:duplicateParentState="true"