From 0480da9aa03a6a052439631f7a0f35798cc8b246 Mon Sep 17 00:00:00 2001 From: Krunal Patel Date: Tue, 6 Dec 2022 13:39:20 +0530 Subject: [PATCH 1/2] Show/Hide exact view count with description toggle --- .../github/libretube/ui/fragments/PlayerFragment.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index b44c89105..cceb69b2b 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -463,10 +463,20 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { // hide the description and chapters binding.playerDescriptionArrow.animate().rotation(0F).setDuration(250).start() binding.descLinLayout.visibility = View.GONE + + // show formated short view count + val viewInfo = context?.getString(R.string.views, streams.views.formatShort()) + + if (!isLive) TextUtils.SEPARATOR + streams.uploadDate else "" + binding.playerViewsInfo.text = viewInfo } else { // show the description and chapters binding.playerDescriptionArrow.animate().rotation(180F).setDuration(250).start() binding.descLinLayout.visibility = View.VISIBLE + + // show exact view count + val viewInfo = context?.getString(R.string.views, String.format("%,d", streams.views)) + + if (!isLive) TextUtils.SEPARATOR + streams.uploadDate else "" + binding.playerViewsInfo.text = viewInfo } if (this::chapters.isInitialized && chapters.isNotEmpty()) { val chapterIndex = getCurrentChapterIndex() From b8eca1f7a6c5ec2fe87e121d0be0b8206f598af6 Mon Sep 17 00:00:00 2001 From: Krunal Patel Date: Tue, 6 Dec 2022 15:14:24 +0530 Subject: [PATCH 2/2] Move duplicate string to variable viewInfo --- .../github/libretube/ui/fragments/PlayerFragment.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index cceb69b2b..1e9c2aee7 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -459,25 +459,24 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { } private fun toggleDescription() { + var viewInfo = if (!isLive) TextUtils.SEPARATOR + streams.uploadDate else "" if (binding.descLinLayout.isVisible) { // hide the description and chapters binding.playerDescriptionArrow.animate().rotation(0F).setDuration(250).start() binding.descLinLayout.visibility = View.GONE // show formated short view count - val viewInfo = context?.getString(R.string.views, streams.views.formatShort()) + - if (!isLive) TextUtils.SEPARATOR + streams.uploadDate else "" - binding.playerViewsInfo.text = viewInfo + viewInfo = getString(R.string.views, streams.views.formatShort()) + viewInfo } else { // show the description and chapters binding.playerDescriptionArrow.animate().rotation(180F).setDuration(250).start() binding.descLinLayout.visibility = View.VISIBLE // show exact view count - val viewInfo = context?.getString(R.string.views, String.format("%,d", streams.views)) + - if (!isLive) TextUtils.SEPARATOR + streams.uploadDate else "" - binding.playerViewsInfo.text = viewInfo + viewInfo = getString(R.string.views, String.format("%,d", streams.views)) + viewInfo } + binding.playerViewsInfo.text = viewInfo + if (this::chapters.isInitialized && chapters.isNotEmpty()) { val chapterIndex = getCurrentChapterIndex() // scroll to the current chapter in the chapterRecView in the description