mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Fix hijacking of navigation bar color when opening emoji keyboard.
This commit is contained in:
@@ -50,6 +50,7 @@ import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.app.ActivityOptionsCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.pm.ShortcutManagerCompat
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.core.view.isInvisible
|
||||
@@ -336,6 +337,7 @@ import org.thoughtcrime.securesms.util.PlayStoreUtil
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.thoughtcrime.securesms.util.SignalLocalMetrics
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.ThemeUtil
|
||||
import org.thoughtcrime.securesms.util.ViewUtil
|
||||
import org.thoughtcrime.securesms.util.WindowUtil
|
||||
import org.thoughtcrime.securesms.util.atMidnight
|
||||
@@ -1573,12 +1575,6 @@ class ConversationFragment :
|
||||
binding.conversationItemRecycler.invalidateItemDecorations()
|
||||
}
|
||||
|
||||
val navColor = if (wallpaperEnabled) {
|
||||
R.color.conversation_navigation_wallpaper
|
||||
} else {
|
||||
R.color.signal_colorBackground
|
||||
}
|
||||
|
||||
binding.scrollDateHeader.setBackgroundResource(
|
||||
if (wallpaperEnabled) R.drawable.sticky_date_header_background_wallpaper else R.drawable.sticky_date_header_background
|
||||
)
|
||||
@@ -1591,10 +1587,20 @@ class ConversationFragment :
|
||||
)
|
||||
|
||||
if (!inputPanel.isHidden) {
|
||||
binding.navBar.setBackgroundColor(ContextCompat.getColor(requireContext(), navColor))
|
||||
setNavBarBackgroundColor(chatWallpaper)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setNavBarBackgroundColor(chatWallpaper: ChatWallpaper?) {
|
||||
val navColor = if (chatWallpaper != null) {
|
||||
R.color.conversation_navigation_wallpaper
|
||||
} else {
|
||||
R.color.signal_colorBackground
|
||||
}
|
||||
|
||||
binding.navBar.setBackgroundColor(ContextCompat.getColor(requireContext(), navColor))
|
||||
}
|
||||
|
||||
private fun presentChatColors(chatColors: ChatColors) {
|
||||
recyclerViewColorizer.setChatColors(chatColors)
|
||||
binding.scrollToMention.setUnreadCountBackgroundTint(chatColors.asSingleColor())
|
||||
@@ -4496,7 +4502,9 @@ class ConversationFragment :
|
||||
|
||||
private object MediaKeyboardFragmentCreator : InputAwareConstraintLayout.FragmentCreator {
|
||||
override val id: Int = 2
|
||||
override fun create(): Fragment = KeyboardPagerFragment()
|
||||
override fun create(): Fragment = KeyboardPagerFragment().apply {
|
||||
arguments = bundleOf(KeyboardPagerFragment.ARG_SET_NAV_COLOR to false)
|
||||
}
|
||||
}
|
||||
|
||||
private inner class KeyboardEvents :
|
||||
@@ -4508,10 +4516,12 @@ class ConversationFragment :
|
||||
}
|
||||
|
||||
override fun onInputShown() {
|
||||
binding.navBar.setBackgroundColor(ThemeUtil.getThemedColor(requireContext(), R.attr.mediaKeyboardBottomBarBackgroundColor))
|
||||
isEnabled = true
|
||||
}
|
||||
|
||||
override fun onInputHidden() {
|
||||
setNavBarBackgroundColor(viewModel.wallpaperSnapshot)
|
||||
isEnabled = false
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ import kotlin.reflect.KClass
|
||||
|
||||
class KeyboardPagerFragment : Fragment(), InputAwareConstraintLayout.InputFragment {
|
||||
|
||||
companion object {
|
||||
val ARG_SET_NAV_COLOR = "args.setNavColor"
|
||||
}
|
||||
|
||||
private lateinit var emojiButton: View
|
||||
private lateinit var stickerButton: View
|
||||
private lateinit var gifButton: View
|
||||
@@ -33,6 +37,9 @@ class KeyboardPagerFragment : Fragment(), InputAwareConstraintLayout.InputFragme
|
||||
private val fragments: MutableMap<KClass<*>, Fragment> = mutableMapOf()
|
||||
private var currentFragment: Fragment? = null
|
||||
|
||||
private val shouldSetNavColor: Boolean
|
||||
get() = arguments?.getBoolean(ARG_SET_NAV_COLOR) ?: true
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return themedInflate(R.layout.keyboard_pager_fragment, inflater, container)
|
||||
}
|
||||
@@ -59,11 +66,13 @@ class KeyboardPagerFragment : Fragment(), InputAwareConstraintLayout.InputFragme
|
||||
}
|
||||
|
||||
override fun onHiddenChanged(hidden: Boolean) {
|
||||
getWindow()?.let { window ->
|
||||
if (hidden) {
|
||||
WindowUtil.setNavigationBarColor(requireContext(), window, ThemeUtil.getThemedColor(requireContext(), android.R.attr.navigationBarColor))
|
||||
} else {
|
||||
WindowUtil.setNavigationBarColor(requireContext(), window, ThemeUtil.getThemedColor(requireContext(), R.attr.mediaKeyboardBottomBarBackgroundColor))
|
||||
if (shouldSetNavColor) {
|
||||
getWindow()?.let { window ->
|
||||
if (hidden) {
|
||||
WindowUtil.setNavigationBarColor(requireContext(), window, ThemeUtil.getThemedColor(requireContext(), android.R.attr.navigationBarColor))
|
||||
} else {
|
||||
WindowUtil.setNavigationBarColor(requireContext(), window, ThemeUtil.getThemedColor(requireContext(), R.attr.mediaKeyboardBottomBarBackgroundColor))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user