Skip to content

Commit e235288

Browse files
committed
Add ability to hide Polycentric/platform comments, ratings and live chat. Closes #1486, #2550
1 parent c14d258 commit e235288

4 files changed

Lines changed: 127 additions & 47 deletions

File tree

app/src/main/java/com/futo/platformplayer/Settings.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,14 @@ class Settings : FragmentedStorageFileJson() {
640640
@FormField(R.string.default_recommendations, FieldForm.TOGGLE, R.string.default_recommendations_description, 0)
641641
var recommendationsDefault: Boolean = false;
642642

643+
@AdvancedField
644+
@FormField(R.string.hide_polycentric_comments, FieldForm.TOGGLE, R.string.hide_polycentric_comments_description, 0)
645+
var hidePolycentricComments: Boolean = false;
646+
647+
@AdvancedField
648+
@FormField(R.string.hide_platform_comments, FieldForm.TOGGLE, R.string.hide_platform_comments_description, 0)
649+
var hidePlatformComments: Boolean = false;
650+
643651
@AdvancedField
644652
@FormField(R.string.hide_recommendations, FieldForm.TOGGLE, R.string.hide_recommendations_description, 0)
645653
var hideRecommendations: Boolean = false;
@@ -1065,6 +1073,18 @@ class Settings : FragmentedStorageFileJson() {
10651073
@FormField(R.string.watch_later_add_start, FieldForm.TOGGLE, R.string.watch_later_add_start_description, 4)
10661074
var watchLaterAddStart: Boolean = true;
10671075

1076+
@AdvancedField
1077+
@FormField(R.string.hide_polycentric_likes, FieldForm.TOGGLE, R.string.hide_polycentric_likes_description, 0)
1078+
var hidePolycentricLikes: Boolean = false;
1079+
1080+
@AdvancedField
1081+
@FormField(R.string.hide_platform_likes, FieldForm.TOGGLE, R.string.hide_platform_likes_description, 0)
1082+
var hidePlatformLikes: Boolean = false;
1083+
1084+
@AdvancedField
1085+
@FormField(R.string.hide_chat, FieldForm.TOGGLE, R.string.hide_chat_description, 0)
1086+
var hideChat: Boolean = false;
1087+
10681088
@FormField(R.string.enable_polycentric, FieldForm.TOGGLE, R.string.can_be_disabled_when_you_are_experiencing_issues, 5)
10691089
var polycentricEnabled: Boolean = true;
10701090

app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt

Lines changed: 74 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ class VideoDetailView : ConstraintLayout {
10361036
}
10371037
else null
10381038
},
1039-
if(video?.isLive ?: false)
1039+
if(!Settings.instance.other.hideChat && video?.isLive ?: false)
10401040
RoundButton(context, R.drawable.ic_chat, context.getString(R.string.live_chat), TAG_LIVECHAT) {
10411041
video?.let {
10421042
try {
@@ -1047,7 +1047,7 @@ class VideoDetailView : ConstraintLayout {
10471047
}
10481048
}
10491049
_slideUpOverlay?.hide();
1050-
} else if(video is JSVideoDetails && (video as JSVideoDetails).hasVODEvents())
1050+
} else if(!Settings.instance.other.hideChat && video is JSVideoDetails && (video as JSVideoDetails).hasVODEvents())
10511051
RoundButton(context, R.drawable.ic_chat, context.getString(R.string.vod_chat), TAG_VODCHAT) {
10521052
video?.let {
10531053
try {
@@ -1645,10 +1645,29 @@ class VideoDetailView : ConstraintLayout {
16451645
if (Settings.instance.comments.recommendationsDefault && !Settings.instance.comments.hideRecommendations) {
16461646
setTabIndex(2, true)
16471647
} else {
1648-
when (Settings.instance.comments.defaultCommentSection) {
1649-
0 -> if (Settings.instance.other.polycentricEnabled) setTabIndex(0, true) else setTabIndex(1, true)
1650-
1 -> setTabIndex(1, true)
1651-
2 -> setTabIndex(StateMeta.instance.getLastCommentSection(), true)
1648+
val index = when (Settings.instance.comments.defaultCommentSection) {
1649+
2 -> StateMeta.instance.getLastCommentSection()
1650+
else -> Settings.instance.comments.defaultCommentSection
1651+
}
1652+
when (index) {
1653+
0 -> {
1654+
if (Settings.instance.other.polycentricEnabled && !Settings.instance.comments.hidePolycentricComments) {
1655+
setTabIndex(0, true)
1656+
} else {
1657+
if (Settings.instance.comments.hidePlatformComments) {
1658+
setTabIndex(null, true)
1659+
} else {
1660+
setTabIndex(1, true)
1661+
}
1662+
}
1663+
}
1664+
1 -> {
1665+
if (Settings.instance.comments.hidePlatformComments) {
1666+
setTabIndex(null, true)
1667+
} else {
1668+
setTabIndex(1, true)
1669+
}
1670+
}
16521671
}
16531672
}
16541673
}
@@ -1714,7 +1733,7 @@ class VideoDetailView : ConstraintLayout {
17141733

17151734
_rating.visibility = View.GONE;
17161735

1717-
if (StatePolycentric.instance.enabled && !(video is LocalVideoDetails)) {
1736+
if (StatePolycentric.instance.enabled && !(video is LocalVideoDetails) && !Settings.instance.other.hidePolycentricLikes) {
17181737
fragment.lifecycleScope.launch(Dispatchers.IO) {
17191738
try {
17201739
val queryReferencesResponse = ApiMethods.getQueryReferences(
@@ -1781,34 +1800,40 @@ class VideoDetailView : ConstraintLayout {
17811800
}
17821801
}
17831802

1784-
when (video.rating) {
1785-
is RatingLikeDislikes -> {
1786-
val r = video.rating as RatingLikeDislikes;
1787-
_layoutRating.visibility = View.VISIBLE;
1803+
if (Settings.instance.other.hidePlatformLikes) {
1804+
_layoutRating.visibility = View.GONE;
1805+
_imageLikeIcon.visibility = View.GONE;
1806+
_imageDislikeIcon.visibility = View.GONE;
1807+
} else {
1808+
when (video.rating) {
1809+
is RatingLikeDislikes -> {
1810+
val r = video.rating as RatingLikeDislikes;
1811+
_layoutRating.visibility = View.VISIBLE;
17881812

1789-
_textLikes.visibility = View.VISIBLE;
1790-
_imageLikeIcon.visibility = View.VISIBLE;
1791-
_textLikes.text = r.likes.toHumanNumber();
1813+
_textLikes.visibility = View.VISIBLE;
1814+
_imageLikeIcon.visibility = View.VISIBLE;
1815+
_textLikes.text = r.likes.toHumanNumber();
17921816

1793-
_imageDislikeIcon.visibility = View.VISIBLE;
1794-
_textDislikes.visibility = View.VISIBLE;
1795-
_textDislikes.text = r.dislikes.toHumanNumber();
1796-
}
1817+
_imageDislikeIcon.visibility = View.VISIBLE;
1818+
_textDislikes.visibility = View.VISIBLE;
1819+
_textDislikes.text = r.dislikes.toHumanNumber();
1820+
}
17971821

1798-
is RatingLikes -> {
1799-
val r = video.rating as RatingLikes;
1800-
_layoutRating.visibility = View.VISIBLE;
1822+
is RatingLikes -> {
1823+
val r = video.rating as RatingLikes;
1824+
_layoutRating.visibility = View.VISIBLE;
18011825

1802-
_textLikes.visibility = View.VISIBLE;
1803-
_imageLikeIcon.visibility = View.VISIBLE;
1804-
_textLikes.text = r.likes.toHumanNumber();
1826+
_textLikes.visibility = View.VISIBLE;
1827+
_imageLikeIcon.visibility = View.VISIBLE;
1828+
_textLikes.text = r.likes.toHumanNumber();
18051829

1806-
_imageDislikeIcon.visibility = View.GONE;
1807-
_textDislikes.visibility = View.GONE;
1808-
}
1830+
_imageDislikeIcon.visibility = View.GONE;
1831+
_textDislikes.visibility = View.GONE;
1832+
}
18091833

1810-
else -> {
1811-
_layoutRating.visibility = View.GONE;
1834+
else -> {
1835+
_layoutRating.visibility = View.GONE;
1836+
}
18121837
}
18131838
}
18141839

@@ -1860,17 +1885,19 @@ class VideoDetailView : ConstraintLayout {
18601885
_liveChat?.stop();
18611886
_liveChat = null;
18621887
var gotLive = false;
1863-
if (video.isLive && video.live != null) {
1864-
loadLiveChat(video);
1865-
gotLive = true;
1866-
}
1867-
if (video.isLive && video.live == null && !video.video.videoSources.any()) {
1868-
startLiveTry(video);
1869-
gotLive = true;
1870-
}
1871-
if(!gotLive && video is JSVideoDetails && video.hasVODEvents()) {
1872-
Logger.i(TAG, "Loading VOD chat");
1873-
loadVODChat(video);
1888+
if (!Settings.instance.other.hideChat) {
1889+
if (video.isLive && video.live != null) {
1890+
loadLiveChat(video);
1891+
gotLive = true;
1892+
}
1893+
if (video.isLive && video.live == null && !video.video.videoSources.any()) {
1894+
startLiveTry(video);
1895+
gotLive = true;
1896+
}
1897+
if (!gotLive && video is JSVideoDetails && video.hasVODEvents()) {
1898+
Logger.i(TAG, "Loading VOD chat");
1899+
loadVODChat(video);
1900+
}
18741901
}
18751902

18761903
_player.updateNextPrevious();
@@ -1887,8 +1914,6 @@ class VideoDetailView : ConstraintLayout {
18871914
_buttonSubscribe.visibility = View.VISIBLE
18881915
_buttonMore.visibility = View.VISIBLE
18891916
_buttonPins.visibility = View.VISIBLE
1890-
_layoutRating.visibility = View.VISIBLE
1891-
_rating.visibility = View.VISIBLE;
18921917
_layoutChangeBottomSection.visibility = View.VISIBLE
18931918
}
18941919

@@ -3043,6 +3068,12 @@ class VideoDetailView : ConstraintLayout {
30433068
return
30443069
}
30453070

3071+
val polycentricCommentsHidden = Settings.instance.comments.hidePolycentricComments || !Settings.instance.other.polycentricEnabled
3072+
_buttonPolycentric.visibility = if (polycentricCommentsHidden) View.GONE else View.VISIBLE
3073+
3074+
val platformCommentsHidden = Settings.instance.comments.hidePlatformComments
3075+
_buttonPlatform.visibility = if (platformCommentsHidden) View.GONE else View.VISIBLE
3076+
30463077
val recommendationsHidden = Settings.instance.comments.hideRecommendations
30473078
_buttonRecommended.visibility = if (recommendationsHidden) View.GONE else View.VISIBLE
30483079

@@ -3633,4 +3664,4 @@ class VideoDetailView : ConstraintLayout {
36333664
private val _buttonPinStore = FragmentedStorage.get<StringArrayStorage>("videoPinnedButtons");
36343665
private var _lastOfflinePlaybackToastTime: Long = 0
36353666
}
3636-
}
3667+
}

app/src/main/java/com/futo/platformplayer/fragment/mainactivity/special/CommentsModalBottomSheet.kt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,29 @@ class CommentsModalBottomSheet : BottomSheetDialogFragment() {
205205
if (Settings.instance.comments.recommendationsDefault && !Settings.instance.comments.hideRecommendations) {
206206
setTabIndex(2, true)
207207
} else {
208-
when (Settings.instance.comments.defaultCommentSection) {
209-
0 -> if (Settings.instance.other.polycentricEnabled) setTabIndex(0, true) else setTabIndex(1, true)
210-
1 -> setTabIndex(1, true)
211-
2 -> setTabIndex(StateMeta.instance.getLastCommentSection(), true)
208+
val index = when (Settings.instance.comments.defaultCommentSection) {
209+
2 -> StateMeta.instance.getLastCommentSection()
210+
else -> Settings.instance.comments.defaultCommentSection
211+
}
212+
when (index) {
213+
0 -> {
214+
if (Settings.instance.other.polycentricEnabled && !Settings.instance.comments.hidePolycentricComments) {
215+
setTabIndex(0, true)
216+
} else {
217+
if (Settings.instance.comments.hidePlatformComments) {
218+
setTabIndex(null, true)
219+
} else {
220+
setTabIndex(1, true)
221+
}
222+
}
223+
}
224+
1 -> {
225+
if (Settings.instance.comments.hidePlatformComments) {
226+
setTabIndex(null, true)
227+
} else {
228+
setTabIndex(1, true)
229+
}
230+
}
212231
}
213232
}
214233

app/src/main/res/values/strings.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,12 @@
497497
<string name="playlist_allow_dups_description">Allow adding duplicate videos to playlists</string>
498498
<string name="watch_later_add_start">Add new videos to the beginning of Watch Later</string>
499499
<string name="watch_later_add_start_description">When adding videos to Watch Later add them to the beginning of the list instead of the end</string>
500+
<string name="hide_polycentric_likes">Hide Polycentric likes</string>
501+
<string name="hide_polycentric_likes_description">Fully hide Polycentric rating</string>
502+
<string name="hide_platform_likes">Hide platform likes</string>
503+
<string name="hide_platform_likes_description">Fully hide platform rating</string>
504+
<string name="hide_chat">Hide chat</string>
505+
<string name="hide_chat_description">Fully hide the chat button and popup</string>
500506
<string name="already_in_watch_later">Already in watch later</string>
501507
<string name="enable_polycentric">Enable Polycentric</string>
502508
<string name="polycentric_local_cache">Enable Polycentric Local Caching</string>
@@ -519,6 +525,10 @@
519525
<string name="prefer_original_audio">Prefer Original Audio</string>
520526
<string name="prefer_original_audio_description">Use original audio instead of preferred language when it is known</string>
521527
<string name="default_comment_section">Default Comment Section</string>
528+
<string name="hide_polycentric_comments">Hide Polycentric Comments</string>
529+
<string name="hide_polycentric_comments_description">Fully hide the Polycentric comments tab.</string>
530+
<string name="hide_platform_comments">Hide Platform Comments</string>
531+
<string name="hide_platform_comments_description">Fully hide the platform comments tab.</string>
522532
<string name="hide_recommendations">Hide Recommendations</string>
523533
<string name="hide_recommendations_description">Fully hide the recommendations tab.</string>
524534
<string name="default_recommendations">Recommendations as Default</string>

0 commit comments

Comments
 (0)