From 206a24ad7d89db51127a62df2d65a933f2a44a7b Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 14 Oct 2022 12:25:43 +0200 Subject: [PATCH] fix sharing channels --- .../github/libretube/ui/adapters/CommentsAdapter.kt | 2 -- .../com/github/libretube/ui/dialogs/ShareDialog.kt | 10 +++++----- .../github/libretube/ui/fragments/ChannelFragment.kt | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt index 4424c1ddd..94aec72c5 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt @@ -117,8 +117,6 @@ class CommentsAdapter( Toast.makeText(root.context, R.string.copied, Toast.LENGTH_SHORT).show() true } - - // if (isRepliesAdapter && comments) } } diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt index 3c39f4670..dbd9d9e28 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt @@ -32,9 +32,9 @@ class ShareDialog( // add instanceUrl option if custom instance frontend url available if (instanceUrl != "") shareOptions += getString(R.string.instance) - if (position != null) { + if (shareObjectType == ShareObjectType.VIDEO && position != null) { binding = DialogShareBinding.inflate(layoutInflater) - binding!!.timeCodeSwitch.isChecked = PreferenceHelper.getBoolean( + binding?.timeCodeSwitch?.isChecked = PreferenceHelper.getBoolean( PreferenceKeys.SHARE_WITH_TIME_CODE, true ) @@ -51,14 +51,14 @@ class ShareDialog( // only available for custom instances else -> instanceUrl } - var path = when (shareObjectType) { + val path = when (shareObjectType) { ShareObjectType.VIDEO -> "/watch?v=$id" ShareObjectType.PLAYLIST -> "/playlist?list=$id" - else -> "/c/$id" + else -> "/channel/$id" } var url = "$host$path" - if (binding != null && binding!!.timeCodeSwitch.isChecked) { + if (shareObjectType == ShareObjectType.VIDEO && binding!!.timeCodeSwitch.isChecked) { url += "&t=$position" } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt index 3cc22c92c..409f2a265 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/ChannelFragment.kt @@ -127,7 +127,7 @@ class ChannelFragment : BaseFragment() { } binding.channelShare.setOnClickListener { - val shareDialog = ShareDialog(response.name!!, ShareObjectType.CHANNEL) + val shareDialog = ShareDialog(response.id!!.toID(), ShareObjectType.CHANNEL) shareDialog.show(childFragmentManager, ShareDialog::class.java.name) } }