From c6b62b729a34a54368a906833eeaa278b358c085 Mon Sep 17 00:00:00 2001 From: Jarvis Lin Date: Mon, 22 Apr 2024 15:29:40 +0700 Subject: [PATCH 001/106] Replace tab with a popup window --- .../NotificationsListFragment.kt | 52 +++++++------ .../main/res/drawable/chevron_right_small.xml | 9 +++ .../res/layout/notification_filter_popup.xml | 73 +++++++++++++++++++ .../layout/notifications_list_fragment.xml | 21 +++--- 4 files changed, 122 insertions(+), 33 deletions(-) create mode 100644 WordPress/src/main/res/drawable/chevron_right_small.xml create mode 100644 WordPress/src/main/res/layout/notification_filter_popup.xml diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt index f19db050beea..e62184440af9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt @@ -24,9 +24,6 @@ import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.adapter.FragmentStateAdapter import androidx.viewpager2.widget.MarginPageTransformer import com.google.android.material.appbar.AppBarLayout.LayoutParams -import com.google.android.material.tabs.TabLayout.OnTabSelectedListener -import com.google.android.material.tabs.TabLayout.Tab -import com.google.android.material.tabs.TabLayoutMediator import dagger.hilt.android.AndroidEntryPoint import org.greenrobot.eventbus.EventBus import org.wordpress.android.R @@ -35,6 +32,7 @@ import org.wordpress.android.analytics.AnalyticsTracker.NOTIFICATIONS_SELECTED_F import org.wordpress.android.analytics.AnalyticsTracker.Stat.NOTIFICATIONS_MARK_ALL_READ_TAPPED import org.wordpress.android.analytics.AnalyticsTracker.Stat.NOTIFICATION_MENU_TAPPED import org.wordpress.android.analytics.AnalyticsTracker.Stat.NOTIFICATION_TAPPED_SEGMENTED_CONTROL +import org.wordpress.android.databinding.NotificationFilterPopupBinding import org.wordpress.android.databinding.NotificationsListFragmentBinding import org.wordpress.android.fluxc.store.AccountStore import org.wordpress.android.models.JetpackPoweredScreen @@ -102,27 +100,10 @@ class NotificationsListFragment : Fragment(R.layout.notifications_list_fragment) super.onViewCreated(view, savedInstanceState) setHasOptionsMenu(true) binding = NotificationsListFragmentBinding.bind(view).apply { - toolbarMain.setTitle(R.string.notifications_screen_title) + toolbarTitle.setOnClickListener { showFilterPopup(toolbarTitle) } (requireActivity() as AppCompatActivity).setSupportActionBar(toolbarMain) - tabLayout.addOnTabSelectedListener(object : OnTabSelectedListener { - override fun onTabSelected(tab: Tab) { - val tabPosition = TabPosition.values().getOrNull(tab.position) ?: All - AnalyticsTracker.track( - NOTIFICATION_TAPPED_SEGMENTED_CONTROL, hashMapOf( - NOTIFICATIONS_SELECTED_FILTER to tabPosition.filter.toString() - ) - ) - lastTabPosition = tab.position - } - - override fun onTabUnselected(tab: Tab) = Unit - override fun onTabReselected(tab: Tab) = Unit - }) viewPager.adapter = NotificationsFragmentAdapter(this@NotificationsListFragment) - TabLayoutMediator(tabLayout, viewPager) { tab, position -> - tab.text = TabPosition.values().getOrNull(position)?.let { getString(it.titleRes) } ?: "" - }.attach() viewPager.setPageTransformer( MarginPageTransformer(resources.getDimensionPixelSize(R.dimen.margin_extra_large)) ) @@ -153,6 +134,32 @@ class NotificationsListFragment : Fragment(R.layout.notifications_list_fragment) } } + private fun showFilterPopup(anchorView: View) { + val popupWindow = PopupWindow(requireContext(), null, R.style.WordPress) + popupWindow.isOutsideTouchable = true + popupWindow.elevation = resources.getDimension(R.dimen.popup_over_toolbar_elevation) + popupWindow.contentView = NotificationFilterPopupBinding.inflate(LayoutInflater.from(requireContext())) + .apply { + textFilterAll.setOnClickListener(getFilterClickListener(TabPosition.All, popupWindow)) + textFilterUnread.setOnClickListener(getFilterClickListener(TabPosition.Unread, popupWindow)) + textFilterComments.setOnClickListener(getFilterClickListener(TabPosition.Comment, popupWindow)) + textFilterFollows.setOnClickListener(getFilterClickListener(TabPosition.Follow, popupWindow)) + textFilterLikes.setOnClickListener(getFilterClickListener(TabPosition.Like, popupWindow)) + }.root + popupWindow.showAsDropDown(anchorView) + } + + private fun getFilterClickListener(filter: TabPosition, popupWindow: PopupWindow) = View.OnClickListener { + AnalyticsTracker.track( + NOTIFICATION_TAPPED_SEGMENTED_CONTROL, hashMapOf( + NOTIFICATIONS_SELECTED_FILTER to filter.toString() + ) + ) + lastTabPosition = filter.ordinal + binding?.viewPager?.currentItem = filter.ordinal + popupWindow.dismiss() + } + override fun onDestroyView() { super.onDestroyView() binding = null @@ -165,11 +172,9 @@ class NotificationsListFragment : Fragment(R.layout.notifications_list_fragment) if (!accountStore.hasAccessToken()) { showConnectJetpackView() connectJetpack.visibility = View.VISIBLE - tabLayout.visibility = View.GONE viewPager.visibility = View.GONE } else { connectJetpack.visibility = View.GONE - tabLayout.visibility = View.VISIBLE viewPager.visibility = View.VISIBLE fetchRemoteNotes() } @@ -200,7 +205,6 @@ class NotificationsListFragment : Fragment(R.layout.notifications_list_fragment) private fun NotificationsListFragmentBinding.setSelectedTab(position: Int) { lastTabPosition = position - tabLayout.getTabAt(lastTabPosition)?.select() } private fun NotificationsListFragmentBinding.setNotificationPermissionWarning() { diff --git a/WordPress/src/main/res/drawable/chevron_right_small.xml b/WordPress/src/main/res/drawable/chevron_right_small.xml new file mode 100644 index 000000000000..1fec4c8d19fd --- /dev/null +++ b/WordPress/src/main/res/drawable/chevron_right_small.xml @@ -0,0 +1,9 @@ + + + diff --git a/WordPress/src/main/res/layout/notification_filter_popup.xml b/WordPress/src/main/res/layout/notification_filter_popup.xml new file mode 100644 index 000000000000..a50a7706e161 --- /dev/null +++ b/WordPress/src/main/res/layout/notification_filter_popup.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + diff --git a/WordPress/src/main/res/layout/notifications_list_fragment.xml b/WordPress/src/main/res/layout/notifications_list_fragment.xml index c41b912eec2e..6eceec2f13a8 100644 --- a/WordPress/src/main/res/layout/notifications_list_fragment.xml +++ b/WordPress/src/main/res/layout/notifications_list_fragment.xml @@ -26,16 +26,19 @@ android:layout_width="match_parent" android:layout_height="@dimen/toolbar_height" app:layout_scrollFlags="scroll|enterAlways" - app:theme="@style/WordPress.ActionBar" /> + app:theme="@style/WordPress.ActionBar"> - + + Date: Tue, 23 Apr 2024 08:55:37 +0700 Subject: [PATCH 002/106] Update the tab position --- .../android/ui/notifications/NotificationsListFragment.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt index e62184440af9..63654e375324 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt @@ -205,6 +205,7 @@ class NotificationsListFragment : Fragment(R.layout.notifications_list_fragment) private fun NotificationsListFragmentBinding.setSelectedTab(position: Int) { lastTabPosition = position + binding?.viewPager?.currentItem = position } private fun NotificationsListFragmentBinding.setNotificationPermissionWarning() { From 67f372f4e4be2463e3119cb03c147d3a06de497b Mon Sep 17 00:00:00 2001 From: Jarvis Lin Date: Tue, 23 Apr 2024 09:45:15 +0700 Subject: [PATCH 003/106] Update title when switch to different tab --- .../ui/notifications/NotificationsListFragment.kt | 12 ++++++++++++ .../main/res/layout/notifications_list_fragment.xml | 2 +- WordPress/src/main/res/values/strings.xml | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt index 63654e375324..aa69c9689e8f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt @@ -157,6 +157,11 @@ class NotificationsListFragment : Fragment(R.layout.notifications_list_fragment) ) lastTabPosition = filter.ordinal binding?.viewPager?.currentItem = filter.ordinal + binding?.toolbarTitle?.text = if (filter == All) { + getString(R.string.notifications_screen_spinner_title) + } else { + getString(filter.titleRes) + } popupWindow.dismiss() } @@ -206,6 +211,13 @@ class NotificationsListFragment : Fragment(R.layout.notifications_list_fragment) private fun NotificationsListFragmentBinding.setSelectedTab(position: Int) { lastTabPosition = position binding?.viewPager?.currentItem = position + TabPosition.entries.getOrNull(position)?.let { + toolbarTitle.text = if (it == All) { + getString(R.string.notifications_screen_spinner_title) + } else { + getString(it.titleRes) + } + } } private fun NotificationsListFragmentBinding.setNotificationPermissionWarning() { diff --git a/WordPress/src/main/res/layout/notifications_list_fragment.xml b/WordPress/src/main/res/layout/notifications_list_fragment.xml index 6eceec2f13a8..3baa16a733ed 100644 --- a/WordPress/src/main/res/layout/notifications_list_fragment.xml +++ b/WordPress/src/main/res/layout/notifications_list_fragment.xml @@ -34,7 +34,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center_vertical" - android:text="@string/notifications_screen_title" + android:text="@string/notifications_screen_spinner_title" android:textColor="?attr/colorOnSurface" app:drawableEndCompat="@drawable/chevron_right_small" app:drawableTint="?attr/colorOnSurface" /> diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 5a8276aa9c16..91fa3bcd55a4 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -35,6 +35,7 @@ Me Reader Notifications + All Notifications Sharing buttons File details Person detail From 7e4143e4761327e20428b62874c2b0c59fe538c8 Mon Sep 17 00:00:00 2001 From: Jarvis Lin Date: Tue, 23 Apr 2024 10:21:51 +0700 Subject: [PATCH 004/106] Disable swiping for the viewpager --- .../android/ui/notifications/NotificationsListFragment.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt index aa69c9689e8f..55f06dba4363 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragment.kt @@ -104,6 +104,7 @@ class NotificationsListFragment : Fragment(R.layout.notifications_list_fragment) (requireActivity() as AppCompatActivity).setSupportActionBar(toolbarMain) viewPager.adapter = NotificationsFragmentAdapter(this@NotificationsListFragment) + viewPager.isUserInputEnabled = false viewPager.setPageTransformer( MarginPageTransformer(resources.getDimensionPixelSize(R.dimen.margin_extra_large)) ) From c6d3c0e0a7fcd677663f4beef80c36475f203013 Mon Sep 17 00:00:00 2001 From: Jarvis Lin Date: Tue, 23 Apr 2024 10:29:55 +0700 Subject: [PATCH 005/106] Extract dimens values --- WordPress/src/main/res/layout/notification_filter_popup.xml | 4 ++-- WordPress/src/main/res/values/dimens.xml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/res/layout/notification_filter_popup.xml b/WordPress/src/main/res/layout/notification_filter_popup.xml index a50a7706e161..c3cbe08567f2 100644 --- a/WordPress/src/main/res/layout/notification_filter_popup.xml +++ b/WordPress/src/main/res/layout/notification_filter_popup.xml @@ -7,7 +7,7 @@ app:cardCornerRadius="@dimen/notifications_popup_radius"> @@ -25,7 +25,7 @@ android:id="@+id/divider" android:layout_width="match_parent" android:layout_height="1px" - android:layout_marginVertical="8dp" + android:layout_marginVertical="@dimen/margin_medium" android:background="@color/grey_300" app:layout_constraintTop_toBottomOf="@+id/text_mark_all_as_read" /> diff --git a/WordPress/src/main/res/values/dimens.xml b/WordPress/src/main/res/values/dimens.xml index fc0ffbbda68e..4f6c20ca66e4 100644 --- a/WordPress/src/main/res/values/dimens.xml +++ b/WordPress/src/main/res/values/dimens.xml @@ -288,6 +288,7 @@ 44dp 48dp 180dp + 200dp 3dp 5dp From a1fe1f515aaca319d2fd99be8d5c59f5cad46668 Mon Sep 17 00:00:00 2001 From: Jarvis Lin Date: Tue, 23 Apr 2024 14:03:59 +0700 Subject: [PATCH 006/106] Update the UI of header --- .../ui/engagement/EngagedPeopleAdapter.kt | 5 +- .../engagement/EngagedPeopleListFragment.kt | 12 +- .../ui/engagement/LikedItemViewHolder.kt | 9 +- .../notifications/blocks/HeaderNoteBlock.java | 14 +- .../src/main/res/layout/note_block_header.xml | 130 +++++++----------- 5 files changed, 75 insertions(+), 95 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleAdapter.kt b/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleAdapter.kt index e41fcb620a1b..705f373414b8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleAdapter.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleAdapter.kt @@ -12,7 +12,8 @@ import org.wordpress.android.viewmodel.ResourceProvider class EngagedPeopleAdapter constructor( private val imageManager: ImageManager, - private val resourceProvider: ResourceProvider + private val resourceProvider: ResourceProvider, + private val type: ListScenarioType ) : Adapter() { private var itemsList = listOf() @@ -36,7 +37,7 @@ class EngagedPeopleAdapter constructor( override fun onBindViewHolder(holder: EngagedPeopleViewHolder, position: Int) { val item = itemsList[position] when (item) { - is LikedItem -> (holder as LikedItemViewHolder).bind(item) + is LikedItem -> (holder as LikedItemViewHolder).bind(item, type) is Liker -> (holder as LikerViewHolder).bind(item) is NextLikesPageLoader -> (holder as NextPageLoadViewHolder).bind(item) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListFragment.kt index 3c5937d693f3..551b9d6f045f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListFragment.kt @@ -73,6 +73,7 @@ class EngagedPeopleListFragment : Fragment() { private lateinit var loadingView: View private lateinit var rootView: View private lateinit var emptyView: ActionableEmptyView + private val listScenario by lazy { requireNotNull(arguments?.getParcelableCompat(KEY_LIST_SCENARIO)) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -94,8 +95,6 @@ class EngagedPeopleListFragment : Fragment() { loadingView = view.findViewById(R.id.loading_view) emptyView = view.findViewById(R.id.actionable_empty_view) - val listScenario = requireNotNull(arguments?.getParcelableCompat(KEY_LIST_SCENARIO)) - val layoutManager = LinearLayoutManager(activity) savedInstanceState?.getParcelableCompat(KEY_LIST_STATE)?.let { @@ -115,6 +114,7 @@ class EngagedPeopleListFragment : Fragment() { bottomSheet.show(childFragmentManager, USER_PROFILE_BOTTOM_SHEET_TAG) } } + HideBottomSheet -> { bottomSheet?.apply { this.dismiss() } } @@ -164,10 +164,12 @@ class EngagedPeopleListFragment : Fragment() { readerTracker ) } + is PreviewSiteByUrl -> { val url = event.siteUrl openUrl(this, url, event.source) } + is PreviewCommentInReader -> { ReaderActivityLauncher.showReaderComments( this, @@ -177,9 +179,11 @@ class EngagedPeopleListFragment : Fragment() { event.source.sourceDescription ) } + is PreviewPostInReader -> { ReaderActivityLauncher.showReaderPostDetail(this, event.siteId, event.postId) } + is OpenUserProfileBottomSheet -> { userProfileViewModel.onBottomSheetOpen(event.userProfile, event.onClick, event.source) } @@ -217,6 +221,7 @@ class EngagedPeopleListFragment : Fragment() { serviceRequest.postId, null ) + is RequestComment -> ReaderCommentService.startServiceForComment( this, serviceRequest.siteId, @@ -239,7 +244,8 @@ class EngagedPeopleListFragment : Fragment() { private fun setupAdapter(items: List) { val adapter = recycler.adapter as? EngagedPeopleAdapter ?: EngagedPeopleAdapter( imageManager, - resourceProvider + resourceProvider, + listScenario.type ).also { recycler.adapter = it } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikedItemViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikedItemViewHolder.kt index d86bbfe11fc2..6d2d317caf26 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikedItemViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikedItemViewHolder.kt @@ -5,6 +5,7 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView +import androidx.core.view.isGone import org.wordpress.android.R import org.wordpress.android.ui.engagement.AuthorName.AuthorNameCharSequence import org.wordpress.android.ui.engagement.AuthorName.AuthorNameString @@ -19,25 +20,23 @@ class LikedItemViewHolder( parent: ViewGroup, private val imageManager: ImageManager ) : EngagedPeopleViewHolder(parent, R.layout.note_block_header) { - private val name = itemView.findViewById(R.id.header_user) private val snippet = itemView.findViewById(R.id.header_snippet) private val avatar = itemView.findViewById(R.id.header_avatar) private val rootView = itemView.findViewById(R.id.header_root_view) - fun bind(likedItem: LikedItem) { + fun bind(likedItem: LikedItem, type: ListScenarioType) { val authorName = when (val author = likedItem.author) { is AuthorNameString -> author.nameString is AuthorNameCharSequence -> author.nameCharSequence } - this.name.text = authorName this.snippet.text = likedItem.postOrCommentText val avatarUrl = WPAvatarUtils.rewriteAvatarUrl( likedItem.authorAvatarUrl, - rootView.context.resources.getDimensionPixelSize(R.dimen.avatar_sz_small) + rootView.context.resources.getDimensionPixelSize(R.dimen.avatar_sz_extra_small) ) - + avatar.isGone = type == ListScenarioType.LOAD_POST_LIKES imageManager.loadIntoCircle(this.avatar, ImageType.AVATAR_WITH_BACKGROUND, avatarUrl) if (!TextUtils.isEmpty(likedItem.authorPreferredSiteUrl) || likedItem.authorPreferredSiteId > 0) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderNoteBlock.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderNoteBlock.java index 603b977d059c..fbe7060a71fe 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderNoteBlock.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderNoteBlock.java @@ -63,7 +63,7 @@ public View configureView(View view) { for (NoteBlockClickableSpan span : spans) { span.enableColors(view.getContext()); } - noteBlockHolder.mNameTextView.setText(spannable); +// noteBlockHolder.mNameTextView.setText(spannable); if (mImageType == ImageType.AVATAR_WITH_BACKGROUND) { mImageManager.loadIntoCircle(noteBlockHolder.mAvatarImageView, mImageType, getAvatarUrl()); } else { @@ -104,10 +104,10 @@ public void onClick(View v) { noteBlockHolder.mSnippetTextView.setText(getSnippet()); if (mIsComment) { - View footerView = view.findViewById(R.id.header_footer); - View footerCommentView = view.findViewById(R.id.header_footer_comment); - footerView.setVisibility(View.GONE); - footerCommentView.setVisibility(View.VISIBLE); +// View footerView = view.findViewById(R.id.header_footer); +// View footerCommentView = view.findViewById(R.id.header_footer_comment); +// footerView.setVisibility(View.GONE); +// footerCommentView.setVisibility(View.VISIBLE); } return view; @@ -145,14 +145,14 @@ public void setIsComment(Boolean isComment) { } private class NoteHeaderBlockHolder { - private final TextView mNameTextView; +// private final TextView mNameTextView; private final TextView mSnippetTextView; private final ImageView mAvatarImageView; NoteHeaderBlockHolder(View view) { View rootView = view.findViewById(R.id.header_root_view); rootView.setOnClickListener(mOnClickListener); - mNameTextView = view.findViewById(R.id.header_user); +// mNameTextView = view.findViewById(R.id.header_user); mSnippetTextView = view.findViewById(R.id.header_snippet); mAvatarImageView = view.findViewById(R.id.header_avatar); } diff --git a/WordPress/src/main/res/layout/note_block_header.xml b/WordPress/src/main/res/layout/note_block_header.xml index 9f5e9ad31fb9..5bf129ed8b08 100644 --- a/WordPress/src/main/res/layout/note_block_header.xml +++ b/WordPress/src/main/res/layout/note_block_header.xml @@ -1,89 +1,63 @@ - + android:layout_height="wrap_content"> - - - + android:id="@+id/header_root_view" + android:layout_marginHorizontal="16dp" + android:foreground="?attr/selectableItemBackground" + app:cardBackgroundColor="@color/black_translucent_10" + app:cardCornerRadius="18dp" + app:cardElevation="0dp"> - - - - - + + + + + + - - - - - - - - - - - - - - - - - + android:lines="1" + android:paddingVertical="8dp" + android:textColor="?attr/colorOnSurface" + android:textSize="14sp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/header_arrow" + app:layout_constraintStart_toEndOf="@+id/header_avatar" + app:layout_constraintTop_toTopOf="parent" + app:layout_goneMarginStart="16dp" + tools:text="Snippet" /> + + + From 8d8ee412af2fbb4021837d9b64b0a0833b4f3fd2 Mon Sep 17 00:00:00 2001 From: Jarvis Lin Date: Tue, 23 Apr 2024 16:14:53 +0700 Subject: [PATCH 007/106] Extract dimens for the UI of header --- .../ui/engagement/LikedItemViewHolder.kt | 12 ++++++++- .../src/main/res/layout/note_block_header.xml | 26 +++++++++---------- WordPress/src/main/res/values/dimens.xml | 2 ++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikedItemViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikedItemViewHolder.kt index 6d2d317caf26..2db9be159217 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikedItemViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikedItemViewHolder.kt @@ -5,6 +5,8 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView +import androidx.cardview.widget.CardView +import androidx.core.content.ContextCompat import androidx.core.view.isGone import org.wordpress.android.R import org.wordpress.android.ui.engagement.AuthorName.AuthorNameCharSequence @@ -12,6 +14,7 @@ import org.wordpress.android.ui.engagement.AuthorName.AuthorNameString import org.wordpress.android.ui.engagement.EngageItem.LikedItem import org.wordpress.android.util.WPAvatarUtils import org.wordpress.android.util.extensions.getDrawableResIdFromAttribute +import org.wordpress.android.util.extensions.isDarkTheme import org.wordpress.android.util.image.ImageManager import org.wordpress.android.util.image.ImageType import com.google.android.material.R as MaterialR @@ -22,7 +25,7 @@ class LikedItemViewHolder( ) : EngagedPeopleViewHolder(parent, R.layout.note_block_header) { private val snippet = itemView.findViewById(R.id.header_snippet) private val avatar = itemView.findViewById(R.id.header_avatar) - private val rootView = itemView.findViewById(R.id.header_root_view) + private val rootView = itemView.findViewById(R.id.header_root_view) fun bind(likedItem: LikedItem, type: ListScenarioType) { val authorName = when (val author = likedItem.author) { @@ -71,5 +74,12 @@ class LikedItemViewHolder( likedItem.likedItemPostId ) } + val isDarkTheme = itemView.resources.configuration.isDarkTheme() + val color = ContextCompat.getColor( + itemView.context, + if (isDarkTheme) R.color.white_translucent_10 + else R.color.black_translucent_10 + ) + rootView.setCardBackgroundColor(color) } } diff --git a/WordPress/src/main/res/layout/note_block_header.xml b/WordPress/src/main/res/layout/note_block_header.xml index 5bf129ed8b08..aa4bdeef28c9 100644 --- a/WordPress/src/main/res/layout/note_block_header.xml +++ b/WordPress/src/main/res/layout/note_block_header.xml @@ -9,10 +9,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/header_root_view" - android:layout_marginHorizontal="16dp" + android:layout_marginHorizontal="@dimen/margin_extra_large" android:foreground="?attr/selectableItemBackground" app:cardBackgroundColor="@color/black_translucent_10" - app:cardCornerRadius="18dp" + app:cardCornerRadius="@dimen/notifications_like_header_radius" app:cardElevation="0dp"> diff --git a/WordPress/src/main/res/values/dimens.xml b/WordPress/src/main/res/values/dimens.xml index fc0ffbbda68e..9ce8d1edf651 100644 --- a/WordPress/src/main/res/values/dimens.xml +++ b/WordPress/src/main/res/values/dimens.xml @@ -288,6 +288,8 @@ 44dp 48dp 180dp + 18dp + 20dp 3dp 5dp From 0cf71570a0370773eed1dd7bcf024f1a0d5d34a9 Mon Sep 17 00:00:00 2001 From: Jarvis Lin Date: Wed, 24 Apr 2024 10:46:40 +0700 Subject: [PATCH 008/106] Remove useless code --- .../ui/notifications/blocks/HeaderNoteBlock.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderNoteBlock.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderNoteBlock.java index fbe7060a71fe..33bdc7f15d58 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderNoteBlock.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderNoteBlock.java @@ -63,7 +63,6 @@ public View configureView(View view) { for (NoteBlockClickableSpan span : spans) { span.enableColors(view.getContext()); } -// noteBlockHolder.mNameTextView.setText(spannable); if (mImageType == ImageType.AVATAR_WITH_BACKGROUND) { mImageManager.loadIntoCircle(noteBlockHolder.mAvatarImageView, mImageType, getAvatarUrl()); } else { @@ -102,14 +101,7 @@ public void onClick(View v) { } noteBlockHolder.mSnippetTextView.setText(getSnippet()); - - if (mIsComment) { -// View footerView = view.findViewById(R.id.header_footer); -// View footerCommentView = view.findViewById(R.id.header_footer_comment); -// footerView.setVisibility(View.GONE); -// footerCommentView.setVisibility(View.VISIBLE); - } - + return view; } @@ -145,14 +137,12 @@ public void setIsComment(Boolean isComment) { } private class NoteHeaderBlockHolder { -// private final TextView mNameTextView; private final TextView mSnippetTextView; private final ImageView mAvatarImageView; NoteHeaderBlockHolder(View view) { View rootView = view.findViewById(R.id.header_root_view); rootView.setOnClickListener(mOnClickListener); -// mNameTextView = view.findViewById(R.id.header_user); mSnippetTextView = view.findViewById(R.id.header_snippet); mAvatarImageView = view.findViewById(R.id.header_avatar); } From 92bd9e0e28d4b5b27ca794664bfbd4ff6ee979fa Mon Sep 17 00:00:00 2001 From: Jarvis Lin Date: Tue, 23 Apr 2024 14:34:18 +0700 Subject: [PATCH 009/106] Update the UI of list item --- .../ui/engagement/EngagedPeopleAdapter.kt | 2 +- .../android/ui/engagement/LikerViewHolder.kt | 12 +++++++- WordPress/src/main/res/layout/liker_user.xml | 30 ++++++------------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleAdapter.kt b/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleAdapter.kt index e41fcb620a1b..fbfada757fe6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleAdapter.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleAdapter.kt @@ -37,7 +37,7 @@ class EngagedPeopleAdapter constructor( val item = itemsList[position] when (item) { is LikedItem -> (holder as LikedItemViewHolder).bind(item) - is Liker -> (holder as LikerViewHolder).bind(item) + is Liker -> (holder as LikerViewHolder).bind(item, position) is NextLikesPageLoader -> (holder as NextPageLoadViewHolder).bind(item) } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikerViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikerViewHolder.kt index e4fc6b615215..7270449dad0e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikerViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/engagement/LikerViewHolder.kt @@ -22,7 +22,17 @@ class LikerViewHolder( private val likerAvatar = itemView.findViewById(R.id.user_avatar) private val likerRootView = itemView.findViewById(R.id.liker_root_view) - fun bind(liker: Liker) { + fun bind(liker: Liker, position: Int) { + val isFirstLiker = position == 1 + itemView.layoutParams = (itemView.layoutParams as ViewGroup.MarginLayoutParams).apply { + topMargin = resourceProvider.getDimensionPixelSize( + if (isFirstLiker) { + R.dimen.margin_small + } else { + R.dimen.margin_none + } + ) + } this.likerName.text = liker.name this.likerLogin.text = if (liker.login.isNotBlank()) { resourceProvider.getString(R.string.at_username, liker.login) diff --git a/WordPress/src/main/res/layout/liker_user.xml b/WordPress/src/main/res/layout/liker_user.xml index 86fa4a32ffe9..05d50dcfc3bf 100644 --- a/WordPress/src/main/res/layout/liker_user.xml +++ b/WordPress/src/main/res/layout/liker_user.xml @@ -6,21 +6,19 @@ android:id="@+id/liker_root_view" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingVertical="8dp" android:background="?android:selectableItemBackground" android:clickable="true" - android:contentDescription="@null" - android:focusable="true" - android:orientation="horizontal" - android:gravity="center_vertical"> + android:focusable="true"> @@ -50,21 +49,10 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" - android:includeFontPadding="true" - android:layout_marginTop="2dp" + android:fontFamily="sans-serif-medium" android:singleLine="true" android:textAppearance="?attr/textAppearanceBody2" android:textColor="@color/material_on_surface_emphasis_medium" tools:text="bobross" /> - - - - From e6fc53c3a95d2a3f3c97e26a9f82a73f11211308 Mon Sep 17 00:00:00 2001 From: Jarvis Lin Date: Tue, 23 Apr 2024 14:42:18 +0700 Subject: [PATCH 010/106] Update the item attrs --- WordPress/src/main/res/layout/liker_user.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/WordPress/src/main/res/layout/liker_user.xml b/WordPress/src/main/res/layout/liker_user.xml index 05d50dcfc3bf..8b0a2c7e267a 100644 --- a/WordPress/src/main/res/layout/liker_user.xml +++ b/WordPress/src/main/res/layout/liker_user.xml @@ -26,7 +26,7 @@ android:layout_width="0dp" android:layout_height="match_parent" android:orientation="vertical" - android:layout_marginStart="@dimen/margin_extra_large" + android:layout_marginHorizontal="@dimen/margin_extra_large" app:layout_constraintStart_toEndOf="@+id/user_avatar" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" @@ -38,7 +38,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" - android:fontFamily="sans-serif-medium" android:singleLine="true" android:textAppearance="?attr/textAppearanceBody2" android:textColor="@color/material_on_surface_emphasis_high_type" @@ -49,7 +48,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" - android:fontFamily="sans-serif-medium" android:singleLine="true" android:textAppearance="?attr/textAppearanceBody2" android:textColor="@color/material_on_surface_emphasis_medium" From 21563209b0caefd2368cdb24008cbc802fbc8ecf Mon Sep 17 00:00:00 2001 From: Jarvis Lin Date: Tue, 23 Apr 2024 15:52:21 +0700 Subject: [PATCH 011/106] Handle the CTA of Share a post --- .../engagement/EngagedPeopleListFragment.kt | 19 +++++++++++++++ .../layout/engaged_people_list_fragment.xml | 24 +++++++++++++++++++ WordPress/src/main/res/values/styles.xml | 6 +++++ 3 files changed, 49 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListFragment.kt index 551b9d6f045f..2e8eb3dbc373 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/engagement/EngagedPeopleListFragment.kt @@ -6,15 +6,18 @@ import android.os.Parcelable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.lifecycle.Lifecycle.State import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.google.android.material.button.MaterialButton import com.google.android.material.snackbar.Snackbar import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.ui.ActionableEmptyView +import org.wordpress.android.ui.ActivityLauncher import org.wordpress.android.ui.WPWebViewActivity import org.wordpress.android.ui.engagement.BottomSheetAction.HideBottomSheet import org.wordpress.android.ui.engagement.BottomSheetAction.ShowBottomSheet @@ -73,6 +76,8 @@ class EngagedPeopleListFragment : Fragment() { private lateinit var loadingView: View private lateinit var rootView: View private lateinit var emptyView: ActionableEmptyView + private lateinit var divider: View + private lateinit var shareButton: MaterialButton private val listScenario by lazy { requireNotNull(arguments?.getParcelableCompat(KEY_LIST_SCENARIO)) } override fun onCreate(savedInstanceState: Bundle?) { @@ -94,6 +99,8 @@ class EngagedPeopleListFragment : Fragment() { recycler = view.findViewById(R.id.recycler) loadingView = view.findViewById(R.id.loading_view) emptyView = view.findViewById(R.id.actionable_empty_view) + divider = view.findViewById(R.id.divider) + shareButton = view.findViewById(R.id.button_share_post) val layoutManager = LinearLayoutManager(activity) @@ -253,6 +260,18 @@ class EngagedPeopleListFragment : Fragment() { val recyclerViewState = recycler.layoutManager?.onSaveInstanceState() adapter.loadData(items) recycler.layoutManager?.onRestoreInstanceState(recyclerViewState) + + val likeItem = items.first { it is EngageItem.LikedItem } as EngageItem.LikedItem + val visible = listScenario.type == ListScenarioType.LOAD_POST_LIKES + divider.isVisible = visible + shareButton.isVisible = visible + shareButton.setOnClickListener { + ActivityLauncher.openShareIntent( + it.context, + likeItem.likedItemSiteUrl, + likeItem.postOrCommentText.toString() + ) + } } private fun showSnackbar(holder: SnackbarMessageHolder) { diff --git a/WordPress/src/main/res/layout/engaged_people_list_fragment.xml b/WordPress/src/main/res/layout/engaged_people_list_fragment.xml index 191a338bbb3a..d79f648514cb 100644 --- a/WordPress/src/main/res/layout/engaged_people_list_fragment.xml +++ b/WordPress/src/main/res/layout/engaged_people_list_fragment.xml @@ -13,6 +13,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toTopOf="@+id/divider" + app:layout_constraintVertical_bias="0" android:fadeScrollbars="true" android:scrollbars="vertical" /> @@ -51,4 +53,26 @@ android:textSize="@dimen/text_sz_double_extra_large" /> + + + + diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 8d4b9bcc7cd7..2ee51d3f3a4a 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -1832,6 +1832,12 @@ ?attr/colorOnBackground + + - - - - - - - + + + +