fix deleting notifications
closes sk22#677 closes sk22#633
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package org.joinmastodon.android.ui.displayitems;
|
package org.joinmastodon.android.ui.displayitems;
|
||||||
|
|
||||||
import static org.joinmastodon.android.MastodonApp.context;
|
import static org.joinmastodon.android.MastodonApp.context;
|
||||||
import static org.joinmastodon.android.model.Notification.Type.PLEROMA_EMOJI_REACTION;
|
|
||||||
import static org.joinmastodon.android.ui.utils.UiUtils.generateFormattedString;
|
import static org.joinmastodon.android.ui.utils.UiUtils.generateFormattedString;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
@@ -9,7 +8,6 @@ import android.app.Activity;
|
|||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
@@ -24,6 +22,7 @@ import org.joinmastodon.android.api.session.AccountLocalPreferences;
|
|||||||
import org.joinmastodon.android.api.session.AccountSession;
|
import org.joinmastodon.android.api.session.AccountSession;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||||
|
import org.joinmastodon.android.fragments.NotificationsListFragment;
|
||||||
import org.joinmastodon.android.fragments.ProfileFragment;
|
import org.joinmastodon.android.fragments.ProfileFragment;
|
||||||
import org.joinmastodon.android.model.Emoji;
|
import org.joinmastodon.android.model.Emoji;
|
||||||
import org.joinmastodon.android.model.Notification;
|
import org.joinmastodon.android.model.Notification;
|
||||||
@@ -116,7 +115,7 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Holder extends StatusDisplayItem.Holder<NotificationHeaderStatusDisplayItem> implements ImageLoaderViewHolder{
|
public static class Holder extends StatusDisplayItem.Holder<NotificationHeaderStatusDisplayItem> implements ImageLoaderViewHolder{
|
||||||
private final ImageView icon, avatar;
|
private final ImageView icon, avatar, deleteNotification;
|
||||||
private final TextView text, timestamp;
|
private final TextView text, timestamp;
|
||||||
private final int selectableItemBackground;
|
private final int selectableItemBackground;
|
||||||
|
|
||||||
@@ -126,9 +125,15 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
avatar=findViewById(R.id.avatar);
|
avatar=findViewById(R.id.avatar);
|
||||||
text=findViewById(R.id.text);
|
text=findViewById(R.id.text);
|
||||||
timestamp=findViewById(R.id.timestamp);
|
timestamp=findViewById(R.id.timestamp);
|
||||||
|
deleteNotification=findViewById(R.id.delete_notification);
|
||||||
|
|
||||||
avatar.setOutlineProvider(OutlineProviders.roundedRect(8));
|
avatar.setOutlineProvider(OutlineProviders.roundedRect(8));
|
||||||
avatar.setClipToOutline(true);
|
avatar.setClipToOutline(true);
|
||||||
|
deleteNotification.setOnClickListener(v->UiUtils.confirmDeleteNotification(activity, item.parentFragment.getAccountID(), item.notification, ()->{
|
||||||
|
if (item.parentFragment instanceof NotificationsListFragment fragment) {
|
||||||
|
fragment.removeNotification(item.notification);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
itemView.setOnClickListener(this::onItemClick);
|
itemView.setOnClickListener(this::onItemClick);
|
||||||
TypedValue outValue = new TypedValue();
|
TypedValue outValue = new TypedValue();
|
||||||
@@ -177,10 +182,13 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
case POLL -> R.attr.colorPoll;
|
case POLL -> R.attr.colorPoll;
|
||||||
default -> android.R.attr.colorAccent;
|
default -> android.R.attr.colorAccent;
|
||||||
})));
|
})));
|
||||||
|
deleteNotification.setVisibility(GlobalUserPreferences.enableDeleteNotifications && item.notification != null ? View.VISIBLE : View.GONE);
|
||||||
itemView.setBackgroundResource(item.notification.type != Notification.Type.POLL
|
itemView.setBackgroundResource(item.notification.type != Notification.Type.POLL
|
||||||
&& item.notification.type != Notification.Type.REPORT ?
|
&& item.notification.type != Notification.Type.REPORT ?
|
||||||
selectableItemBackground : 0);
|
selectableItemBackground : 0);
|
||||||
itemView.setClickable(item.notification.type != Notification.Type.POLL);
|
itemView.setClickable(item.notification.type != Notification.Type.POLL);
|
||||||
|
itemView.setPaddingRelative(itemView.getPaddingStart(), itemView.getPaddingTop(),
|
||||||
|
GlobalUserPreferences.enableDeleteNotifications ? V.dp(4) : V.dp(16), itemView.getPaddingBottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onItemClick(View v) {
|
public void onItemClick(View v) {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import org.joinmastodon.android.model.LegacyFilter;
|
|||||||
import org.joinmastodon.android.model.FilterAction;
|
import org.joinmastodon.android.model.FilterAction;
|
||||||
import org.joinmastodon.android.model.FilterContext;
|
import org.joinmastodon.android.model.FilterContext;
|
||||||
import org.joinmastodon.android.model.FilterResult;
|
import org.joinmastodon.android.model.FilterResult;
|
||||||
|
import org.joinmastodon.android.model.Notification;
|
||||||
import org.joinmastodon.android.model.Poll;
|
import org.joinmastodon.android.model.Poll;
|
||||||
import org.joinmastodon.android.model.ScheduledStatus;
|
import org.joinmastodon.android.model.ScheduledStatus;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
@@ -145,7 +146,7 @@ public abstract class StatusDisplayItem{
|
|||||||
Status statusForContent=status.getContentStatus();
|
Status statusForContent=status.getContentStatus();
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
ScheduledStatus scheduledStatus = parentObject instanceof ScheduledStatus ? (ScheduledStatus) parentObject : null;
|
ScheduledStatus scheduledStatus = parentObject instanceof ScheduledStatus s ? s : null;
|
||||||
|
|
||||||
HeaderStatusDisplayItem header=null;
|
HeaderStatusDisplayItem header=null;
|
||||||
boolean hideCounts=!AccountSessionManager.get(accountID).getLocalPreferences().showInteractionCounts;
|
boolean hideCounts=!AccountSessionManager.get(accountID).getLocalPreferences().showInteractionCounts;
|
||||||
@@ -201,7 +202,7 @@ public abstract class StatusDisplayItem{
|
|||||||
if((flags & FLAG_CHECKABLE)!=0)
|
if((flags & FLAG_CHECKABLE)!=0)
|
||||||
items.add(header=new CheckableHeaderStatusDisplayItem(parentID, statusForContent.account, statusForContent.createdAt, fragment, accountID, statusForContent, null));
|
items.add(header=new CheckableHeaderStatusDisplayItem(parentID, statusForContent.account, statusForContent.createdAt, fragment, accountID, statusForContent, null));
|
||||||
else
|
else
|
||||||
items.add(header=new HeaderStatusDisplayItem(parentID, statusForContent.account, statusForContent.createdAt, fragment, accountID, statusForContent, null, null, scheduledStatus));
|
items.add(header=new HeaderStatusDisplayItem(parentID, statusForContent.account, statusForContent.createdAt, fragment, accountID, statusForContent, null, parentObject instanceof Notification n ? n : null, scheduledStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
LegacyFilter applyingFilter=null;
|
LegacyFilter applyingFilter=null;
|
||||||
|
|||||||
@@ -3,8 +3,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:paddingRight="16dp"
|
android:paddingHorizontal="16dp">
|
||||||
android:paddingLeft="16dp">
|
<!-- paddingEnd is set programmatically (depending on item.inset) -->
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/buttons"
|
android:id="@+id/buttons"
|
||||||
@@ -72,6 +72,17 @@
|
|||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/more"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:background="?android:actionBarItemBackground"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:tint="?colorM3OnSurfaceVariant"
|
||||||
|
android:tooltipText="@string/more_options"
|
||||||
|
android:contentDescription="@string/more_options"
|
||||||
|
android:src="@drawable/ic_fluent_more_vertical_20_filled" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/delete_notification"
|
android:id="@+id/delete_notification"
|
||||||
android:layout_width="36dp"
|
android:layout_width="36dp"
|
||||||
@@ -83,17 +94,6 @@
|
|||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:src="@drawable/ic_fluent_dismiss_20_filled"
|
android:src="@drawable/ic_fluent_dismiss_20_filled"
|
||||||
android:tint="?colorM3OnSurfaceVariant" />
|
android:tint="?colorM3OnSurfaceVariant" />
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/more"
|
|
||||||
android:layout_width="36dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:background="?android:actionBarItemBackground"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:tint="?colorM3OnSurfaceVariant"
|
|
||||||
android:tooltipText="@string/more_options"
|
|
||||||
android:contentDescription="@string/more_options"
|
|
||||||
android:src="@drawable/ic_fluent_more_vertical_20_filled" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingHorizontal="16dp">
|
||||||
|
<!-- paddingEnd is set programmatically (depending on enableDeleteNotifications) -->
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
android:layout_height="64dp"
|
android:layout_height="64dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:background="?android:selectableItemBackground"
|
android:background="?android:selectableItemBackground">
|
||||||
android:paddingHorizontal="16dp">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/icon"
|
android:id="@+id/icon"
|
||||||
@@ -61,3 +69,17 @@
|
|||||||
</org.joinmastodon.android.ui.views.HeaderSubtitleLinearLayout>
|
</org.joinmastodon.android.ui.views.HeaderSubtitleLinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/delete_notification"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:background="?android:actionBarItemBackground"
|
||||||
|
android:contentDescription="@string/sk_delete_notification"
|
||||||
|
android:tooltipText="@string/sk_delete_notification"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/ic_fluent_dismiss_20_filled"
|
||||||
|
android:tint="?colorM3OnSurfaceVariant" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user