Skip to content

Commit 3874e16

Browse files
committed
Added support for showing when a comment has received a heart from the creator of a video.
1 parent 39722a5 commit 3874e16

6 files changed

Lines changed: 42 additions & 1 deletion

File tree

app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.text.util.Linkify;
88
import android.view.View;
99
import android.view.ViewGroup;
10+
import android.widget.ImageView;
1011
import android.widget.RelativeLayout;
1112
import android.widget.TextView;
1213

@@ -45,6 +46,7 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
4546
private final TextView itemContentView;
4647
private final TextView itemLikesCountView;
4748
private final TextView itemDislikesCountView;
49+
private final ImageView itemHeartView;
4850
private final TextView itemPublishedTime;
4951

5052
private String commentText;
@@ -80,6 +82,7 @@ public String transformUrl(final Matcher match, final String url) {
8082
itemDislikesCountView = itemView.findViewById(R.id.detail_thumbs_down_count_view);
8183
itemPublishedTime = itemView.findViewById(R.id.itemPublishedTime);
8284
itemContentView = itemView.findViewById(R.id.itemCommentContentView);
85+
itemHeartView = itemView.findViewById(R.id.detail_heart_img_view);
8386

8487
downloadThumbnailKey = infoItemBuilder.getContext().
8588
getString(R.string.download_thumbnail_key);
@@ -152,6 +155,10 @@ public void updateFromItem(final InfoItem infoItem,
152155
itemPublishedTime.setText(item.getTextualUploadDate());
153156
}
154157

158+
if (item.isHeartedByUploader()) {
159+
itemHeartView.setVisibility(View.VISIBLE);
160+
}
161+
155162
itemView.setOnClickListener(view -> {
156163
toggleEllipsize();
157164
if (itemBuilder.getOnCommentsSelectedListener() != null) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:tint="#FFFFFF"
5+
android:viewportWidth="24.0"
6+
android:viewportHeight="24.0">
7+
<path
8+
android:fillColor="#FF000000"
9+
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"/>
10+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FF000000"
8+
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"/>
9+
</vector>

app/src/main/res/layout/list_comments_item.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@
7171
tools:ignore="RtlHardcoded"
7272
tools:text="12M" />
7373

74+
<ImageView
75+
android:id="@+id/detail_heart_img_view"
76+
android:layout_width="@dimen/video_item_detail_heart_image_width"
77+
android:layout_height="@dimen/video_item_detail_heart_image_height"
78+
android:layout_below="@id/itemCommentContentView"
79+
android:layout_marginLeft="@dimen/video_item_detail_heart_margin"
80+
android:layout_toRightOf="@+id/detail_thumbs_up_count_view"
81+
android:contentDescription="@string/detail_heart_img_view_description"
82+
android:visibility="gone"
83+
app:srcCompat="@drawable/ic_heart" />
84+
7485

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

@@ -105,7 +116,7 @@
105116
android:layout_height="wrap_content"
106117
android:layout_below="@id/itemCommentContentView"
107118
android:layout_marginLeft="12dp"
108-
android:layout_toRightOf="@id/detail_thumbs_up_count_view"
119+
android:layout_toRightOf="@id/detail_heart_img_view"
109120
android:lines="1"
110121
android:textAppearance="?android:attr/textAppearanceSmall"
111122
android:textSize="@dimen/video_item_search_upload_date_text_size"

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@
8181
<dimen name="video_item_detail_sub_channel_image_size">16dp</dimen>
8282
<dimen name="video_item_detail_like_image_height">18sp</dimen>
8383
<dimen name="video_item_detail_like_image_width">18sp</dimen>
84+
<dimen name="video_item_detail_heart_image_width">18sp</dimen>
85+
<dimen name="video_item_detail_heart_image_height">18sp</dimen>
8486
<dimen name="channel_avatar_size">70dp</dimen>
8587
<dimen name="sub_channel_avatar_size">35dp</dimen>
8688
<dimen name="mini_player_height">60dp</dimen>
8789
<!-- Paddings & Margins -->
8890
<dimen name="video_item_detail_like_margin">5dp</dimen>
91+
<dimen name="video_item_detail_heart_margin">5dp</dimen>
8992
<dimen name="video_item_detail_error_panel_margin">50dp</dimen>
9093
<!-- Control panel -->
9194
<dimen name="detail_control_text_size">12sp</dimen>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@
749749
<string name="metadata_privacy_unlisted">Unlisted</string>
750750
<string name="metadata_privacy_private">Private</string>
751751
<string name="metadata_privacy_internal">Internal</string>
752+
<string name="detail_heart_img_view_description">Hearted by creator</string>
752753
<string name="open_website_license">Open website</string>
753754
<string name="tablet_mode_title">Tablet mode</string>
754755
<string name="on">On</string>

0 commit comments

Comments
 (0)