Skip to content

Commit

Permalink
Merge pull request #20944 from wordpress-mobile/issue/Comment-Details…
Browse files Browse the repository at this point in the history
…-Menu-redesign

Comment details menu redesign
  • Loading branch information
Antonis Lilis authored Jun 7, 2024
2 parents 9f6e573 + 78a2b09 commit 5493500
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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<EnabledActions> mEnabledActions = EnumSet.allOf(EnabledActions.class);

@Nullable protected CommentDetailFragmentBinding mBinding = null;

private final OnActionClickListener mOnActionClickListener = new OnActionClickListener() {
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -901,6 +895,11 @@ public void onDestroy() {
*/
public interface OnActionClickListener {
void onEditCommentClicked();

void onUserInfoClicked();

void onShareClicked();

void onChangeStatusClicked();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<EnabledActions>

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -155,7 +160,7 @@ abstract class SharedCommentDetailFragment : CommentDetailFragment() {
)
}

private fun showModerationBottomSheet() {
override fun showModerationBottomSheet() {
ModerationBottomSheetDialogFragment.newInstance(
ModerationBottomSheetDialogFragment.CommentState(
canModerate = enabledActions.canModerate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,15 +23,15 @@ object CommentActionPopupHandler {
popupWindow.dismiss()
}
textShare.setOnClickListener {
ToastUtils.showToast(it.context, "not yet implemented")
listener?.onShareClicked()
popupWindow.dismiss()
}
textEditComment.setOnClickListener {
listener?.onEditCommentClicked()
popupWindow.dismiss()
}
textChangeStatus.setOnClickListener {
ToastUtils.showToast(it.context, "not yet implemented")
listener?.onChangeStatusClicked()
popupWindow.dismiss()
}
}.root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand Down Expand Up @@ -531,7 +533,7 @@ class NotificationsDetailListFragment : ListFragment(), NotificationFragment {
}
}

fun setOnEditCommentListener(listener: CommentDetailFragment.OnActionClickListener){
fun setOnEditCommentListener(listener: CommentDetailFragment.OnActionClickListener) {
onActionClickListener = listener
}

Expand Down

0 comments on commit 5493500

Please sign in to comment.