comment #77 - Group notifications for boost and fav when they target the same message and are following them in the timeline

This commit is contained in:
Thomas 2022-05-21 19:04:07 +02:00
parent 658685b2c7
commit b809dfecfd
6 changed files with 41 additions and 11 deletions

View File

@ -167,11 +167,16 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
title = context.getString(R.string.notif_poll);
}
if (notification.relatedNotifications != null && notification.relatedNotifications.size() > 0) {
holderStatus.bindingNotification.otherAccounts.removeAllViews();
if (notification.type.equals("favourite")) {
holderStatus.bindingNotification.typeOfConcat.setText(R.string.also_favourite_by);
} else if (notification.type.equals("reblog")) {
holderStatus.bindingNotification.typeOfConcat.setText(R.string.also_boosted_by);
}
holderStatus.bindingNotification.relatedAccounts.removeAllViews();
for (Notification relativeNotif : notification.relatedNotifications) {
NotificationsRelatedAccountsBinding notificationsRelatedAccountsBinding = NotificationsRelatedAccountsBinding.inflate(LayoutInflater.from(context));
MastodonHelper.loadPPMastodon(notificationsRelatedAccountsBinding.profilePicture, relativeNotif.account);
notificationsRelatedAccountsBinding.acc.setText(relativeNotif.account.acct);
notificationsRelatedAccountsBinding.acc.setText(relativeNotif.account.username);
notificationsRelatedAccountsBinding.relatedAccountContainer.setOnClickListener(v -> {
Intent intent = new Intent(context, ProfileActivity.class);
Bundle b = new Bundle();
@ -182,7 +187,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
// start the new activity
context.startActivity(intent, options.toBundle());
});
holderStatus.bindingNotification.otherAccounts.addView(notificationsRelatedAccountsBinding.getRoot());
holderStatus.bindingNotification.relatedAccounts.addView(notificationsRelatedAccountsBinding.getRoot());
}
holderStatus.bindingNotification.otherAccounts.setVisibility(View.VISIBLE);
} else {

View File

@ -185,6 +185,7 @@ public class FragmentMastodonNotification extends Fragment {
binding.noAction.setVisibility(View.GONE);
binding.recyclerView.setVisibility(View.VISIBLE);
}
flagLoading = notifications.notifications.size() < MastodonHelper.notificationsPerCall(requireActivity());
if (aggregateNotification) {
notifications.notifications = aggregateNotifications(notifications.notifications);
}
@ -196,7 +197,6 @@ public class FragmentMastodonNotification extends Fragment {
}
this.notifications = notifications.notifications;
notificationAdapter = new NotificationAdapter(this.notifications);
flagLoading = notifications.notifications.size() < MastodonHelper.notificationsPerCall(requireActivity());
LinearLayoutManager mLayoutManager = new LinearLayoutManager(requireActivity());
binding.recyclerView.setLayoutManager(mLayoutManager);
binding.recyclerView.setAdapter(notificationAdapter);
@ -239,7 +239,10 @@ public class FragmentMastodonNotification extends Fragment {
int refPosition = 0;
for (int i = 0; i < notifications.size(); i++) {
if (i != refPosition) {
if (notifications.get(i).type.equals(notifications.get(refPosition).type) && (notifications.get(i).type.equals("favourite") || notifications.get(i).type.equals("reblog"))) {
if (notifications.get(i).type.equals(notifications.get(refPosition).type)
&& (notifications.get(i).type.equals("favourite") || notifications.get(i).type.equals("reblog"))
&& notifications.get(i).status.id.equals(notifications.get(refPosition).status.id)
) {
if (notificationList.size() > 0) {
if (notificationList.get(notificationList.size() - 1).relatedNotifications == null) {
notificationList.get(notificationList.size() - 1).relatedNotifications = new ArrayList<>();
@ -269,6 +272,9 @@ public class FragmentMastodonNotification extends Fragment {
binding.loadingNextElements.setVisibility(View.GONE);
if (currentFragment.notifications != null && fetched_notifications != null && fetched_notifications.notifications != null) {
flagLoading = fetched_notifications.notifications.size() < MastodonHelper.notificationsPerCall(requireActivity());
if (aggregateNotification) {
fetched_notifications.notifications = aggregateNotifications(fetched_notifications.notifications);
}
int startId = 0;
//There are some statuses present in the timeline
if (currentFragment.notifications.size() > 0) {

View File

@ -19,8 +19,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:layout_marginTop="12dp"
android:layout_marginHorizontal="6dp"
android:layout_marginTop="6dp"
app:cardElevation="2dp">
<androidx.constraintlayout.widget.ConstraintLayout

View File

@ -19,6 +19,8 @@
android:id="@+id/card_status_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/card_margin"
android:layout_marginTop="@dimen/card_margin"
android:orientation="vertical">
<include
@ -35,6 +37,7 @@
android:layout_alignBottom="@+id/status"
android:orientation="horizontal"
android:visibility="gone"
android:gravity="center_vertical"
app:layout_constraintTop_toBottomOf="@+id/status">
<androidx.appcompat.widget.AppCompatTextView
@ -43,19 +46,29 @@
android:layout_height="wrap_content" />
<HorizontalScrollView
android:id="@+id/related_accounts"
android:layout_marginStart="10dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
android:layout_weight="1">
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/related_accounts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
</androidx.appcompat.widget.LinearLayoutCompat>
<RelativeLayout
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_height="0dp"
android:visibility="gone"
android:id="@+id/container_transparent"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="@color/black"
android:elevation="5dp"
android:visibility="gone" />
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -3,15 +3,19 @@
android:id="@+id/related_account_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/profile_picture"
android:padding="2dp"
android:layout_width="30dp"
android:layout_height="30dp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/acc"
android:layout_marginStart="5dp"
android:padding="2dp"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1" />

View File

@ -1599,6 +1599,8 @@
<string name="display">Display</string>
<string name="bottom_menu">Bottom menu</string>
<string name="top_menu">Top bar menu</string>
<string name="also_favourite_by">"Also favourited by: "</string>
<string name="also_boosted_by">Also boosted by:</string>
</resources>