115115import org .schabi .newpipe .util .NavigationHelper ;
116116import org .schabi .newpipe .util .PermissionHelper ;
117117import org .schabi .newpipe .util .PlayButtonHelper ;
118+ import org .schabi .newpipe .util .ServiceHelper ;
118119import org .schabi .newpipe .util .StreamTypeUtil ;
119120import org .schabi .newpipe .util .ThemeHelper ;
120121import org .schabi .newpipe .util .external_communication .KoreUtils ;
@@ -174,6 +175,7 @@ public final class VideoDetailFragment
174175 @ NonNull
175176 final List <Integer > tabContentDescriptions = new ArrayList <>();
176177 private boolean tabSettingsChanged = false ;
178+ private boolean showDislikes = true ;
177179 private int lastAppBarVerticalOffset = Integer .MAX_VALUE ; // prevents useless updates
178180
179181 private final SharedPreferences .OnSharedPreferenceChangeListener preferenceChangeListener =
@@ -187,6 +189,11 @@ public final class VideoDetailFragment
187189 } else if (getString (R .string .show_description_key ).equals (key )) {
188190 showDescription = sharedPreferences .getBoolean (key , true );
189191 tabSettingsChanged = true ;
192+ } else if (getString (R .string .show_dislike_key ).equals (key )) {
193+ showDislikes = sharedPreferences .getBoolean (key , true );
194+ if (currentInfo != null && binding != null ) {
195+ updateLikeDislikeViews (currentInfo );
196+ }
190197 }
191198 };
192199
@@ -322,6 +329,7 @@ public void onCreate(final Bundle savedInstanceState) {
322329 showComments = prefs .getBoolean (getString (R .string .show_comments_key ), true );
323330 showRelatedItems = prefs .getBoolean (getString (R .string .show_next_video_key ), true );
324331 showDescription = prefs .getBoolean (getString (R .string .show_description_key ), true );
332+ showDislikes = ServiceHelper .isFetchDislikeEnabled (activity );
325333 selectedTabTag = prefs .getString (
326334 getString (R .string .stream_info_selected_tab_key ), COMMENTS_TAB_TAG );
327335 prefs .registerOnSharedPreferenceChangeListener (preferenceChangeListener );
@@ -1558,35 +1566,7 @@ public void handleResult(@NonNull final StreamInfo info) {
15581566 binding .detailViewCountView .setVisibility (View .GONE );
15591567 }
15601568
1561- if (info .getDislikeCount () == -1 && info .getLikeCount () == -1 ) {
1562- binding .detailThumbsDownImgView .setVisibility (View .VISIBLE );
1563- binding .detailThumbsUpImgView .setVisibility (View .VISIBLE );
1564- binding .detailThumbsUpCountView .setVisibility (View .GONE );
1565- binding .detailThumbsDownCountView .setVisibility (View .GONE );
1566-
1567- binding .detailThumbsDisabledView .setVisibility (View .VISIBLE );
1568- } else {
1569- if (info .getDislikeCount () >= 0 ) {
1570- binding .detailThumbsDownCountView .setText (Localization
1571- .shortCount (activity , info .getDislikeCount ()));
1572- binding .detailThumbsDownCountView .setVisibility (View .VISIBLE );
1573- binding .detailThumbsDownImgView .setVisibility (View .VISIBLE );
1574- } else {
1575- binding .detailThumbsDownCountView .setVisibility (View .GONE );
1576- binding .detailThumbsDownImgView .setVisibility (View .GONE );
1577- }
1578-
1579- if (info .getLikeCount () >= 0 ) {
1580- binding .detailThumbsUpCountView .setText (Localization .shortCount (activity ,
1581- info .getLikeCount ()));
1582- binding .detailThumbsUpCountView .setVisibility (View .VISIBLE );
1583- binding .detailThumbsUpImgView .setVisibility (View .VISIBLE );
1584- } else {
1585- binding .detailThumbsUpCountView .setVisibility (View .GONE );
1586- binding .detailThumbsUpImgView .setVisibility (View .GONE );
1587- }
1588- binding .detailThumbsDisabledView .setVisibility (View .GONE );
1589- }
1569+ updateLikeDislikeViews (info );
15901570
15911571 if (info .getDuration () > 0 ) {
15921572 binding .detailDurationView .setText (Localization .getDurationString (info .getDuration ()));
@@ -1646,6 +1626,38 @@ public void handleResult(@NonNull final StreamInfo info) {
16461626 noVideoStreams ? R .drawable .ic_headset_shadow : R .drawable .ic_play_arrow_shadow );
16471627 }
16481628
1629+ private void updateLikeDislikeViews (@ NonNull final StreamInfo info ) {
1630+ if ((info .getDislikeCount () == -1 || !showDislikes ) && info .getLikeCount () == -1 ) {
1631+ binding .detailThumbsDownImgView .setVisibility (showDislikes ? View .VISIBLE : View .GONE );
1632+ binding .detailThumbsUpImgView .setVisibility (View .VISIBLE );
1633+ binding .detailThumbsUpCountView .setVisibility (View .GONE );
1634+ binding .detailThumbsDownCountView .setVisibility (View .GONE );
1635+
1636+ binding .detailThumbsDisabledView .setVisibility (View .VISIBLE );
1637+ } else {
1638+ if (showDislikes && info .getDislikeCount () >= 0 ) {
1639+ binding .detailThumbsDownCountView .setText (Localization
1640+ .shortCount (activity , info .getDislikeCount ()));
1641+ binding .detailThumbsDownCountView .setVisibility (View .VISIBLE );
1642+ binding .detailThumbsDownImgView .setVisibility (View .VISIBLE );
1643+ } else {
1644+ binding .detailThumbsDownCountView .setVisibility (View .GONE );
1645+ binding .detailThumbsDownImgView .setVisibility (View .GONE );
1646+ }
1647+
1648+ if (info .getLikeCount () >= 0 ) {
1649+ binding .detailThumbsUpCountView .setText (Localization .shortCount (activity ,
1650+ info .getLikeCount ()));
1651+ binding .detailThumbsUpCountView .setVisibility (View .VISIBLE );
1652+ binding .detailThumbsUpImgView .setVisibility (View .VISIBLE );
1653+ } else {
1654+ binding .detailThumbsUpCountView .setVisibility (View .GONE );
1655+ binding .detailThumbsUpImgView .setVisibility (View .GONE );
1656+ }
1657+ binding .detailThumbsDisabledView .setVisibility (View .GONE );
1658+ }
1659+ }
1660+
16491661 private void displayUploaderAsSubChannel (final StreamInfo info ) {
16501662 binding .detailSubChannelTextView .setText (info .getUploaderName ());
16511663 binding .detailSubChannelTextView .setVisibility (View .VISIBLE );
0 commit comments