diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index fa26ce060..e874cb32a 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -42,6 +42,7 @@ import android.view.animation.DecelerateInterpolator; import android.widget.FrameLayout; import android.widget.RelativeLayout; +import android.widget.TextView; import android.widget.Toast; import androidx.annotation.AttrRes; @@ -360,6 +361,44 @@ public void onChange(final boolean selfChange) { public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { binding = FragmentVideoDetailBinding.inflate(inflater, container, false); + binding.detailsPanel.setOnClickListener(view -> { + if (currentInfo == null) { + return; + } + + final Context context = requireContext(); + + final ReturnYouTubeDislikeInfo rydInfo = currentInfo.getRydInfo(); + + if (rydInfo == null) { + return; + } + + final View alertDialogView = LayoutInflater.from(activity) + .inflate(R.layout.dialog_return_youtube_dislike_info, null); + // like count + final TextView likeCountTextView = alertDialogView.findViewById(R.id.likeCount); + likeCountTextView.setText(Localization.localizeNumber(activity, rydInfo.likes)); + // dislike count + final TextView dislikeCountTextView = alertDialogView.findViewById(R.id.dislikeCount); + dislikeCountTextView.setText(Localization.localizeNumber(activity, rydInfo.dislikes)); + // ratio + final TextView ratioTextView = alertDialogView.findViewById(R.id.ratio); + ratioTextView.setText(Localization.localizeRating(activity, rydInfo.rating)); + // view count + final TextView viewCountTextView = alertDialogView.findViewById(R.id.viewCount); + viewCountTextView.setText(Localization.localizeNumber(activity, rydInfo.viewCount)); + + final AlertDialog alertDialog = + new AlertDialog.Builder(context) + .setView(alertDialogView) + .setPositiveButton(context.getString(R.string.close), (dialog, i) -> { + dialog.dismiss(); + }) + .create(); + + alertDialog.show(); + }); return binding.getRoot(); } diff --git a/app/src/main/java/org/schabi/newpipe/util/Localization.java b/app/src/main/java/org/schabi/newpipe/util/Localization.java index c4034252d..f5c25a872 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -158,6 +158,12 @@ public static String localizeWatchingCount(final Context context, final long wat localizeNumber(context, watchingCount)); } + public static String localizeRating(final Context context, final double number) { + final NumberFormat nf = NumberFormat.getInstance(getAppLocale(context)); + nf.setMaximumFractionDigits(2); + return nf.format(number) + " / 5"; + } + public static String shortCount(final Context context, final long count) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { return CompactDecimalFormat.getInstance(getAppLocale(context), diff --git a/app/src/main/res/layout/dialog_return_youtube_dislike_info.xml b/app/src/main/res/layout/dialog_return_youtube_dislike_info.xml new file mode 100644 index 000000000..31f899503 --- /dev/null +++ b/app/src/main/res/layout/dialog_return_youtube_dislike_info.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_video_detail.xml b/app/src/main/res/layout/fragment_video_detail.xml index 1a4711581..d06dd9da9 100644 --- a/app/src/main/res/layout/fragment_video_detail.xml +++ b/app/src/main/res/layout/fragment_video_detail.xml @@ -319,7 +319,9 @@ android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:paddingLeft="6dp" - android:paddingRight="6dp"> + android:paddingRight="6dp" + android:clickable="true" + android:focusable="true"> 14sp 13sp 13sp + 16sp 12sp 32dp