mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-23 01:00:04 +02:00
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:
parent
658685b2c7
commit
b809dfecfd
6 changed files with 41 additions and 11 deletions
|
@ -167,11 +167,16 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
title = context.getString(R.string.notif_poll);
|
title = context.getString(R.string.notif_poll);
|
||||||
}
|
}
|
||||||
if (notification.relatedNotifications != null && notification.relatedNotifications.size() > 0) {
|
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) {
|
for (Notification relativeNotif : notification.relatedNotifications) {
|
||||||
NotificationsRelatedAccountsBinding notificationsRelatedAccountsBinding = NotificationsRelatedAccountsBinding.inflate(LayoutInflater.from(context));
|
NotificationsRelatedAccountsBinding notificationsRelatedAccountsBinding = NotificationsRelatedAccountsBinding.inflate(LayoutInflater.from(context));
|
||||||
MastodonHelper.loadPPMastodon(notificationsRelatedAccountsBinding.profilePicture, relativeNotif.account);
|
MastodonHelper.loadPPMastodon(notificationsRelatedAccountsBinding.profilePicture, relativeNotif.account);
|
||||||
notificationsRelatedAccountsBinding.acc.setText(relativeNotif.account.acct);
|
notificationsRelatedAccountsBinding.acc.setText(relativeNotif.account.username);
|
||||||
notificationsRelatedAccountsBinding.relatedAccountContainer.setOnClickListener(v -> {
|
notificationsRelatedAccountsBinding.relatedAccountContainer.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(context, ProfileActivity.class);
|
Intent intent = new Intent(context, ProfileActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
|
@ -182,7 +187,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
// start the new activity
|
// start the new activity
|
||||||
context.startActivity(intent, options.toBundle());
|
context.startActivity(intent, options.toBundle());
|
||||||
});
|
});
|
||||||
holderStatus.bindingNotification.otherAccounts.addView(notificationsRelatedAccountsBinding.getRoot());
|
holderStatus.bindingNotification.relatedAccounts.addView(notificationsRelatedAccountsBinding.getRoot());
|
||||||
}
|
}
|
||||||
holderStatus.bindingNotification.otherAccounts.setVisibility(View.VISIBLE);
|
holderStatus.bindingNotification.otherAccounts.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -185,6 +185,7 @@ public class FragmentMastodonNotification extends Fragment {
|
||||||
binding.noAction.setVisibility(View.GONE);
|
binding.noAction.setVisibility(View.GONE);
|
||||||
binding.recyclerView.setVisibility(View.VISIBLE);
|
binding.recyclerView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
flagLoading = notifications.notifications.size() < MastodonHelper.notificationsPerCall(requireActivity());
|
||||||
if (aggregateNotification) {
|
if (aggregateNotification) {
|
||||||
notifications.notifications = aggregateNotifications(notifications.notifications);
|
notifications.notifications = aggregateNotifications(notifications.notifications);
|
||||||
}
|
}
|
||||||
|
@ -196,7 +197,6 @@ public class FragmentMastodonNotification extends Fragment {
|
||||||
}
|
}
|
||||||
this.notifications = notifications.notifications;
|
this.notifications = notifications.notifications;
|
||||||
notificationAdapter = new NotificationAdapter(this.notifications);
|
notificationAdapter = new NotificationAdapter(this.notifications);
|
||||||
flagLoading = notifications.notifications.size() < MastodonHelper.notificationsPerCall(requireActivity());
|
|
||||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(requireActivity());
|
LinearLayoutManager mLayoutManager = new LinearLayoutManager(requireActivity());
|
||||||
binding.recyclerView.setLayoutManager(mLayoutManager);
|
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||||
binding.recyclerView.setAdapter(notificationAdapter);
|
binding.recyclerView.setAdapter(notificationAdapter);
|
||||||
|
@ -239,7 +239,10 @@ public class FragmentMastodonNotification extends Fragment {
|
||||||
int refPosition = 0;
|
int refPosition = 0;
|
||||||
for (int i = 0; i < notifications.size(); i++) {
|
for (int i = 0; i < notifications.size(); i++) {
|
||||||
if (i != refPosition) {
|
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.size() > 0) {
|
||||||
if (notificationList.get(notificationList.size() - 1).relatedNotifications == null) {
|
if (notificationList.get(notificationList.size() - 1).relatedNotifications == null) {
|
||||||
notificationList.get(notificationList.size() - 1).relatedNotifications = new ArrayList<>();
|
notificationList.get(notificationList.size() - 1).relatedNotifications = new ArrayList<>();
|
||||||
|
@ -269,6 +272,9 @@ public class FragmentMastodonNotification extends Fragment {
|
||||||
binding.loadingNextElements.setVisibility(View.GONE);
|
binding.loadingNextElements.setVisibility(View.GONE);
|
||||||
if (currentFragment.notifications != null && fetched_notifications != null && fetched_notifications.notifications != null) {
|
if (currentFragment.notifications != null && fetched_notifications != null && fetched_notifications.notifications != null) {
|
||||||
flagLoading = fetched_notifications.notifications.size() < MastodonHelper.notificationsPerCall(requireActivity());
|
flagLoading = fetched_notifications.notifications.size() < MastodonHelper.notificationsPerCall(requireActivity());
|
||||||
|
if (aggregateNotification) {
|
||||||
|
fetched_notifications.notifications = aggregateNotifications(fetched_notifications.notifications);
|
||||||
|
}
|
||||||
int startId = 0;
|
int startId = 0;
|
||||||
//There are some statuses present in the timeline
|
//There are some statuses present in the timeline
|
||||||
if (currentFragment.notifications.size() > 0) {
|
if (currentFragment.notifications.size() > 0) {
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="12dp"
|
android:layout_marginHorizontal="6dp"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="6dp"
|
||||||
app:cardElevation="2dp">
|
app:cardElevation="2dp">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
android:id="@+id/card_status_container"
|
android:id="@+id/card_status_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="@dimen/card_margin"
|
||||||
|
android:layout_marginTop="@dimen/card_margin"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
|
@ -35,6 +37,7 @@
|
||||||
android:layout_alignBottom="@+id/status"
|
android:layout_alignBottom="@+id/status"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
android:gravity="center_vertical"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/status">
|
app:layout_constraintTop_toBottomOf="@+id/status">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
@ -43,19 +46,29 @@
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<HorizontalScrollView
|
<HorizontalScrollView
|
||||||
android:id="@+id/related_accounts"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
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>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:visibility="gone"
|
||||||
android:id="@+id/container_transparent"
|
android:id="@+id/container_transparent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:background="@color/black"
|
android:background="@color/black"
|
||||||
android:elevation="5dp"
|
android:elevation="5dp"
|
||||||
android:visibility="gone" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -3,15 +3,19 @@
|
||||||
android:id="@+id/related_account_container"
|
android:id="@+id/related_account_container"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/profile_picture"
|
android:id="@+id/profile_picture"
|
||||||
|
android:padding="2dp"
|
||||||
android:layout_width="30dp"
|
android:layout_width="30dp"
|
||||||
android:layout_height="30dp" />
|
android:layout_height="30dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
android:id="@+id/acc"
|
android:id="@+id/acc"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:padding="2dp"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
|
@ -1599,6 +1599,8 @@
|
||||||
<string name="display">Display</string>
|
<string name="display">Display</string>
|
||||||
<string name="bottom_menu">Bottom menu</string>
|
<string name="bottom_menu">Bottom menu</string>
|
||||||
<string name="top_menu">Top bar 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>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue