diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java index ed71c3b2620d..7d9856428fcc 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java @@ -43,10 +43,10 @@ import org.wordpress.android.fluxc.tools.FluxCImageLoader; import org.wordpress.android.fluxc.tools.FormattableContentMapper; import org.wordpress.android.models.Note; -import org.wordpress.android.models.Note.EnabledActions; import org.wordpress.android.models.UserSuggestion; import org.wordpress.android.models.usecases.LocalCommentCacheUpdateHandler; import org.wordpress.android.ui.ActivityId; +import org.wordpress.android.ui.ActivityLauncher; import org.wordpress.android.ui.CollapseFullScreenDialogFragment; import org.wordpress.android.ui.ViewPagerFragment; import org.wordpress.android.ui.comments.CommentActions.OnCommentActionListener; @@ -80,7 +80,6 @@ import org.wordpress.android.util.image.ImageManager; import org.wordpress.android.util.image.ImageType; -import java.util.EnumSet; import java.util.List; import javax.inject.Inject; @@ -115,7 +114,6 @@ public abstract class CommentDetailFragment extends ViewPagerFragment implements @Nullable protected Note mNote; @Nullable private SuggestionAdapter mSuggestionAdapter; @Nullable private SuggestionServiceConnectionManager mSuggestionServiceConnectionManager; - @Nullable private String mRestoredReplyText; protected boolean mIsUsersBlog = false; protected boolean mShouldFocusReplyField; @Nullable private String mPreviousStatus; @@ -138,13 +136,6 @@ public abstract class CommentDetailFragment extends ViewPagerFragment implements @Nullable private OnNoteCommentActionListener mOnNoteCommentActionListener; @NonNull protected CommentSource mCommentSource; // this will be non-null when onCreate() - /* - * these determine which actions (moderation, replying, marking as spam) to enable - * for this comment - all actions are enabled when opened from the comment list, only - * changed when opened from a notification - */ - @NonNull private EnumSet mEnabledActions = EnumSet.allOf(EnabledActions.class); - @Nullable protected CommentDetailFragmentBinding mBinding = null; private final OnActionClickListener mOnActionClickListener = new OnActionClickListener() { @@ -154,10 +145,22 @@ public abstract class CommentDetailFragment extends ViewPagerFragment implements @Override public void onUserInfoClicked() { UserProfileBottomSheetFragment.newInstance(getUserProfileUiState()) - .show(getChildFragmentManager(), UserProfileBottomSheetFragment.TAG); + .show(getChildFragmentManager(), UserProfileBottomSheetFragment.TAG); + } + + @Override public void onShareClicked() { + if (getContext() != null) { + ActivityLauncher.openShareIntent(getContext(), mComment.getUrl(), null); + } + } + + @Override public void onChangeStatusClicked() { + showModerationBottomSheet(); } }; + abstract void showModerationBottomSheet(); + abstract UserProfileUiState getUserProfileUiState(); @Override @@ -725,15 +728,6 @@ private void showCommentAsNotification( binding.textContent.setVisibility(View.GONE); - /* - * determine which actions to enable for this comment - if the comment is from this user's - * blog then all actions will be enabled, but they won't be if it's a reply to a comment - * this user made on someone else's blog - */ - if (note != null) { - mEnabledActions = note.getEnabledCommentActions(); - } - if (comment != null) { setComment(site, comment); } else if (note != null) { @@ -901,6 +895,11 @@ public void onDestroy() { */ public interface OnActionClickListener { void onEditCommentClicked(); + void onUserInfoClicked(); + + void onShareClicked(); + + void onChangeStatusClicked(); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/SharedCommentDetailFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/comments/SharedCommentDetailFragment.kt index 448136c009b6..4e6e61b5c192 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/SharedCommentDetailFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/SharedCommentDetailFragment.kt @@ -60,6 +60,11 @@ abstract class SharedCommentDetailFragment : CommentDetailFragment() { @Inject lateinit var meGravatarLoader: MeGravatarLoader + /* + * these determine which actions (moderation, replying, marking as spam) to enable + * for this comment - all actions are enabled when opened from the comment list, only + * changed when opened from a notification + */ abstract val enabledActions: EnumSet override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -155,7 +160,7 @@ abstract class SharedCommentDetailFragment : CommentDetailFragment() { ) } - private fun showModerationBottomSheet() { + override fun showModerationBottomSheet() { ModerationBottomSheetDialogFragment.newInstance( ModerationBottomSheetDialogFragment.CommentState( canModerate = enabledActions.canModerate(), diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/CommentActionPopupHandler.kt b/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/CommentActionPopupHandler.kt index 984007e7d176..8725bc84d8a5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/CommentActionPopupHandler.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/unified/CommentActionPopupHandler.kt @@ -8,7 +8,6 @@ import android.widget.PopupWindow import org.wordpress.android.R import org.wordpress.android.databinding.CommentActionsBinding import org.wordpress.android.ui.comments.CommentDetailFragment -import org.wordpress.android.util.ToastUtils object CommentActionPopupHandler { @JvmStatic @@ -24,7 +23,7 @@ object CommentActionPopupHandler { popupWindow.dismiss() } textShare.setOnClickListener { - ToastUtils.showToast(it.context, "not yet implemented") + listener?.onShareClicked() popupWindow.dismiss() } textEditComment.setOnClickListener { @@ -32,7 +31,7 @@ object CommentActionPopupHandler { popupWindow.dismiss() } textChangeStatus.setOnClickListener { - ToastUtils.showToast(it.context, "not yet implemented") + listener?.onChangeStatusClicked() popupWindow.dismiss() } }.root diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailListFragment.kt index c261b9bd9c7e..db32e4a6f641 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailListFragment.kt @@ -195,7 +195,9 @@ class NotificationsDetailListFragment : ListFragment(), NotificationFragment { this.footerView = footerView } - private val mOnNoteBlockTextClickListener = NoteBlockTextClickListener(this, notification, onActionClickListener) + private val mOnNoteBlockTextClickListener by lazy { + NoteBlockTextClickListener(this, notification, onActionClickListener) + } private val mOnGravatarClickedListener = object : OnGravatarClickedListener { override fun onGravatarClicked(siteId: Long, userId: Long, siteUrl: String?) { @@ -531,7 +533,7 @@ class NotificationsDetailListFragment : ListFragment(), NotificationFragment { } } - fun setOnEditCommentListener(listener: CommentDetailFragment.OnActionClickListener){ + fun setOnEditCommentListener(listener: CommentDetailFragment.OnActionClickListener) { onActionClickListener = listener }