Its once again almost working

This commit is contained in:
LucasGGamerM 2023-01-28 20:19:41 -03:00
parent 0473062bc2
commit 9a55f847b9
4 changed files with 46 additions and 11 deletions

View File

@ -42,6 +42,7 @@ import org.joinmastodon.android.ui.displayitems.PollFooterStatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.PollOptionStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.PollOptionStatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem; import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.TextStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.TextStatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.WarningFilteredStatusDisplayItem;
import org.joinmastodon.android.ui.photoviewer.PhotoViewer; import org.joinmastodon.android.ui.photoviewer.PhotoViewer;
import org.joinmastodon.android.ui.photoviewer.PhotoViewerHost; import org.joinmastodon.android.ui.photoviewer.PhotoViewerHost;
import org.joinmastodon.android.ui.utils.UiUtils; import org.joinmastodon.android.ui.utils.UiUtils;
@ -513,6 +514,28 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
updateImagesSpoilerState(status, itemID); updateImagesSpoilerState(status, itemID);
} }
// public void onRevealFilteredClick(TextStatusDisplayItem.Holder holder){
// Status status=holder.getItem().status;
// revealFiltered(status, holder.getItemID());
// }
public void onRevealFilteredClick(WarningFilteredStatusDisplayItem.Holder holder){
Status status=holder.getItem().status;
revealFiltered(status, holder.getItemID());
}
protected void revealFiltered(Status status, String itemID){
status.filterRevealed=true;
TextStatusDisplayItem.Holder text=findHolderOfType(itemID, TextStatusDisplayItem.Holder.class);
if(text!=null)
adapter.notifyItemChanged(text.getAbsoluteAdapterPosition()-getMainAdapterOffset());
HeaderStatusDisplayItem.Holder header=findHolderOfType(itemID, HeaderStatusDisplayItem.Holder.class);
if(header!=null)
header.rebind();
updateImagesSpoilerState(status, itemID);
}
public void onVisibilityIconClick(HeaderStatusDisplayItem.Holder holder){ public void onVisibilityIconClick(HeaderStatusDisplayItem.Holder holder){
Status status=holder.getItem().status; Status status=holder.getItem().status;
status.spoilerRevealed=!status.spoilerRevealed; status.spoilerRevealed=!status.spoilerRevealed;
@ -543,6 +566,13 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
public void onGapClick(GapStatusDisplayItem.Holder item){} public void onGapClick(GapStatusDisplayItem.Holder item){}
public void onWarningClick(WarningFilteredStatusDisplayItem.Holder warningItem){
// Status status = warningItem.getItem().status;
// String itemID = warningItem.getItemID();
warningItem.itemView.setVisibility(View.GONE);
// adapter.notifyItemChanged();
}
public String getAccountID(){ public String getAccountID(){
return accountID; return accountID;
} }

View File

@ -98,6 +98,14 @@ public abstract class StatusDisplayItem{
args.putString("account", accountID); args.putString("account", accountID);
ScheduledStatus scheduledStatus = parentObject instanceof ScheduledStatus ? (ScheduledStatus) parentObject : null; ScheduledStatus scheduledStatus = parentObject instanceof ScheduledStatus ? (ScheduledStatus) parentObject : null;
List<Filter> filters=AccountSessionManager.getInstance().getAccount(accountID).wordFilters.stream().filter(f->f.context.contains(Filter.FilterContext.HOME)).collect(Collectors.toList());
StatusFilterPredicate filterPredicate = new StatusFilterPredicate(filters);
if(!filterPredicate.testWithWarning(status)){
if(!status.filterRevealed){
items.add(new WarningFilteredStatusDisplayItem(parentID, fragment, status));
}
}
if(status.reblog!=null){ if(status.reblog!=null){
boolean isOwnPost = AccountSessionManager.getInstance().isSelf(fragment.getAccountID(), status.account); boolean isOwnPost = AccountSessionManager.getInstance().isSelf(fragment.getAccountID(), status.account);
items.add(new ReblogOrReplyLineStatusDisplayItem(parentID, fragment, fragment.getString(R.string.user_boosted, status.account.displayName), status.account.emojis, R.drawable.ic_fluent_arrow_repeat_all_20_filled, isOwnPost ? status.visibility : null, i->{ items.add(new ReblogOrReplyLineStatusDisplayItem(parentID, fragment, fragment.getString(R.string.user_boosted, status.account.displayName), status.account.emojis, R.drawable.ic_fluent_arrow_repeat_all_20_filled, isOwnPost ? status.visibility : null, i->{
@ -131,14 +139,6 @@ public abstract class StatusDisplayItem{
))); )));
} }
List<Filter> filters=AccountSessionManager.getInstance().getAccount(accountID).wordFilters.stream().filter(f->f.context.contains(Filter.FilterContext.HOME)).collect(Collectors.toList());
StatusFilterPredicate filterPredicate = new StatusFilterPredicate(filters);
if(!filterPredicate.testWithWarning(status)){
if(!status.filterRevealed){
items.add(new WarningFilteredStatusDisplayItem(parentID, fragment, status));
return items;
}
}
HeaderStatusDisplayItem header; HeaderStatusDisplayItem header;
items.add(header=new HeaderStatusDisplayItem(parentID, statusForContent.account, statusForContent.createdAt, fragment, accountID, statusForContent, null, notification, scheduledStatus)); items.add(header=new HeaderStatusDisplayItem(parentID, statusForContent.account, statusForContent.createdAt, fragment, accountID, statusForContent, null, notification, scheduledStatus));
if(!TextUtils.isEmpty(statusForContent.content)) if(!TextUtils.isEmpty(statusForContent.content))
@ -178,11 +178,14 @@ public abstract class StatusDisplayItem{
if(status.hasGapAfter && !(fragment instanceof ThreadFragment)) if(status.hasGapAfter && !(fragment instanceof ThreadFragment))
items.add(new GapStatusDisplayItem(parentID, fragment)); items.add(new GapStatusDisplayItem(parentID, fragment));
} }
int i=1; int i=1;
for(StatusDisplayItem item:items){ for(StatusDisplayItem item:items){
item.inset=inset; item.inset=inset;
item.index=i++; item.index=i++;
} }
return items; return items;
} }

View File

@ -27,14 +27,16 @@ public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{
} }
public static class Holder extends StatusDisplayItem.Holder<WarningFilteredStatusDisplayItem>{ public static class Holder extends StatusDisplayItem.Holder<WarningFilteredStatusDisplayItem>{
public final View warningWrap;
public final ProgressBar progress; public final ProgressBar progress;
public final TextView text; public final TextView text;
public Holder(Context context, ViewGroup parent){ public Holder(Context context, ViewGroup parent){
super(context, R.layout.display_item_warning, parent); super(context, R.layout.display_item_warning, parent);
warningWrap=findViewById(R.id.warning_wrap);
progress=findViewById(R.id.progress); progress=findViewById(R.id.progress);
text=findViewById(R.id.text); text=findViewById(R.id.text);
// itemView.setForeground(new SawtoothTearDrawable(context)); // itemView.setOnClickListener(v->item.parentFragment.onRevealFilteredClick(this));
} }
@Override @Override
@ -44,8 +46,7 @@ public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{
@Override @Override
public void onClick(){ public void onClick(){
item.status.filterRevealed = true; item.parentFragment.onWarningClick(this);
// item.parentFragment.onGapClick(this);
} }
} }
} }

View File

@ -2,6 +2,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="75dp" android:layout_height="75dp"
android:id="@+id/warning_wrap"
android:background="@drawable/bg_timeline_gap"> android:background="@drawable/bg_timeline_gap">
<TextView <TextView