Skip to content

Commit

Permalink
Merge pull request #6741 from KalleStruik/comment-hearts
Browse files Browse the repository at this point in the history
Show hearts in comments
  • Loading branch information
Stypox authored Aug 1, 2021
2 parents 551e8df + bfac73b commit d42a534
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.schabi.newpipe.info_list.holder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import org.schabi.newpipe.R;
Expand Down Expand Up @@ -31,11 +33,13 @@

public class CommentsInfoItemHolder extends CommentsMiniInfoItemHolder {
public final TextView itemTitleView;
private final ImageView itemHeartView;

public CommentsInfoItemHolder(final InfoItemBuilder infoItemBuilder, final ViewGroup parent) {
super(infoItemBuilder, R.layout.list_comments_item, parent);

itemTitleView = itemView.findViewById(R.id.itemTitleView);
itemHeartView = itemView.findViewById(R.id.detail_heart_image_view);
}

@Override
Expand All @@ -49,5 +53,7 @@ public void updateFromItem(final InfoItem infoItem,
final CommentsInfoItem item = (CommentsInfoItem) infoItem;

itemTitleView.setText(item.getUploaderName());

itemHeartView.setVisibility(item.isHeartedByUploader() ? View.VISIBLE : View.GONE);
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable-night/ic_heart.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FF5252"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_heart.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#E53935"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
</vector>
14 changes: 13 additions & 1 deletion app/src/main/res/layout/list_comments_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@
tools:ignore="RtlHardcoded"
tools:text="12M" />

<ImageView
android:id="@+id/detail_heart_image_view"
android:layout_width="@dimen/video_item_detail_heart_image_size"
android:layout_height="@dimen/video_item_detail_heart_image_size"
android:layout_below="@id/itemCommentContentView"
android:layout_marginLeft="@dimen/video_item_detail_heart_margin"
android:layout_toRightOf="@+id/detail_thumbs_up_count_view"
android:contentDescription="@string/detail_heart_img_view_description"
android:visibility="gone"
tools:visibility="visible"
app:srcCompat="@drawable/ic_heart" />


<!--we can uncomment below code if we need dislike button and count in future-->

Expand Down Expand Up @@ -105,7 +117,7 @@
android:layout_height="wrap_content"
android:layout_below="@id/itemCommentContentView"
android:layout_marginLeft="12dp"
android:layout_toRightOf="@id/detail_thumbs_up_count_view"
android:layout_toRightOf="@id/detail_heart_image_view"
android:lines="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="@dimen/video_item_search_upload_date_text_size"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@
<dimen name="video_item_detail_sub_channel_image_size">16dp</dimen>
<dimen name="video_item_detail_like_image_height">18sp</dimen>
<dimen name="video_item_detail_like_image_width">18sp</dimen>
<dimen name="video_item_detail_heart_image_size">18sp</dimen>
<dimen name="channel_avatar_size">70dp</dimen>
<dimen name="sub_channel_avatar_size">35dp</dimen>
<dimen name="mini_player_height">60dp</dimen>
<!-- Paddings & Margins -->
<dimen name="video_item_detail_like_margin">5dp</dimen>
<dimen name="video_item_detail_heart_margin">5dp</dimen>
<dimen name="video_item_detail_error_panel_margin">50dp</dimen>
<!-- Control panel -->
<dimen name="detail_control_text_size">12sp</dimen>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@
<string name="metadata_privacy_unlisted">Unlisted</string>
<string name="metadata_privacy_private">Private</string>
<string name="metadata_privacy_internal">Internal</string>
<string name="detail_heart_img_view_description">Hearted by creator</string>
<string name="open_website_license">Open website</string>
<string name="tablet_mode_title">Tablet mode</string>
<string name="on">On</string>
Expand Down

0 comments on commit d42a534

Please sign in to comment.