The text now begones if the item is filtered!

This commit is contained in:
LucasGGamerM 2023-01-28 18:03:10 -03:00
parent 891016c8a8
commit cbae5c4192
5 changed files with 46 additions and 37 deletions

View File

@ -73,7 +73,7 @@ public class CacheController{
status.hasGapAfter=((flags & POST_FLAG_GAP_AFTER)!=0);
newMaxID=status.id;
for(Filter filter:filters){
if(filter.matches(status))
if(filter.matches(status) && status.filterRevealed)
continue outer;
}
result.add(status);

View File

@ -149,6 +149,10 @@ public class Status extends BaseModel implements DisplayItemsParent{
return strippedText;
}
public void setFilterRevealed(boolean filterRevealed) {
this.filterRevealed = filterRevealed;
}
public static Status ofFake(String id, String text, Instant createdAt) {
Status s = new Status();
s.id = id;

View File

@ -293,25 +293,16 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
@Override
public void onBind(HeaderStatusDisplayItem item){
if(item.status.filterRevealed){
}
name.setText(item.parsedName);
username.setText('@'+item.user.acct);
botIcon.setVisibility(item.user.bot ? View.VISIBLE : View.GONE);
botIcon.setColorFilter(username.getCurrentTextColor());
separator.setVisibility(View.VISIBLE);
// if(item.user.bot){
// SpannableStringBuilder ssb = new SpannableStringBuilder();
// ssb.append('@'+item.user.acct);
// ssb.append(" ");
// Drawable botIcon=username.getResources().getDrawable(R.drawable.ic_bot, itemView.getContext().getTheme()).mutate();
// botIcon.setBounds(0, 0, botIcon.getIntrinsicWidth(), botIcon.getIntrinsicHeight());
// botIcon.setTint(username.getCurrentTextColor());
// ssb.append(itemView.getContext().getString(R.string.manually_approves_followers), new ImageSpan(botIcon, ImageSpan.ALIGN_BASELINE), 0);
// username.setPaddingRelative(0,0,16,0);
// username.setText(ssb);
// }
// username.setCompoundDrawablesWithIntrinsicBounds(item.user.bot ? R.drawable.ic_fluent_bot_24_filled : 0, 0, 0, 0);
if (item.scheduledStatus!=null)
if (item.scheduledStatus.scheduledAt.isAfter(CreateStatus.DRAFTS_AFTER_INSTANT)) {

View File

@ -114,22 +114,34 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
@Override
public void onBind(TextStatusDisplayItem item){
if(!item.status.filterRevealed){
// text.setVisibility(View.GONE);
// spoilerTitle.setVisibility(View.GONE);
// spoilerTitleInline.setVisibility(View.GONE);
// spoilerHeader.setVisibility(View.GONE);
// spoilerOverlay.setVisibility(View.GONE);
// borderTop.setVisibility(View.GONE);
// borderBottom.setVisibility(View.GONE);
// textWrap.setVisibility(View.GONE);
// translateWrap.setVisibility(View.GONE);
// translateButton.setVisibility(View.GONE);
// translateInfo.setVisibility(View.GONE);
// translateProgress.setVisibility(View.GONE);
itemView.setVisibility(View.GONE);
text.setVisibility(View.GONE);
spoilerTitle.setVisibility(View.GONE);
spoilerTitleInline.setVisibility(View.GONE);
spoilerHeader.setVisibility(View.GONE);
spoilerOverlay.setVisibility(View.GONE);
borderTop.setVisibility(View.GONE);
borderBottom.setVisibility(View.GONE);
textWrap.setVisibility(View.GONE);
translateWrap.setVisibility(View.GONE);
translateButton.setVisibility(View.GONE);
translateInfo.setVisibility(View.GONE);
translateProgress.setVisibility(View.GONE);
// itemView.setVisibility(View.GONE);
return;
}else{
itemView.setVisibility(View.VISIBLE);
text.setVisibility(View.VISIBLE);
spoilerTitle.setVisibility(View.VISIBLE);
spoilerTitleInline.setVisibility(View.VISIBLE);
spoilerHeader.setVisibility(View.VISIBLE);
spoilerOverlay.setVisibility(View.VISIBLE);
borderTop.setVisibility(View.VISIBLE);
borderBottom.setVisibility(View.VISIBLE);
textWrap.setVisibility(View.VISIBLE);
// translateWrap.setVisibility(View.VISIBLE);
// translateButton.setVisibility(View.VISIBLE);
// translateInfo.setVisibility(View.VISIBLE);
// translateProgress.setVisibility(View.VISIBLE);
// itemView.setVisibility(View.VISIBLE);
}
text.setText(item.translated
? HtmlParser.parse(item.translation.content, item.status.emojis, item.status.mentions, item.status.tags, item.parentFragment.getAccountID())

View File

@ -31,15 +31,17 @@ public class StatusFilterPredicate implements Predicate<Status>{
.filter(filter->filter.expiresAt==null||filter.expiresAt.isAfter(Instant.now()))
.anyMatch(filter->filter.filterAction==Filter.FilterAction.HIDE);
// boolean filteredWithWarning=status.filtered.stream()
// .map(filterResult->filterResult.filter)
// .filter(filter->filter.expiresAt==null||filter.expiresAt.isAfter(Instant.now()))
// .anyMatch(filter->filter.filterAction==Filter.FilterAction.WARN);
//
// if(filteredWithWarning){
// status.filterRevealed = false;
// }
return !matches;
boolean filteredWithWarning=status.filtered.stream()
.map(filterResult->filterResult.filter)
.filter(filter->filter.expiresAt==null||filter.expiresAt.isAfter(Instant.now()))
.anyMatch(filter->filter.filterAction==Filter.FilterAction.WARN);
if(filteredWithWarning){
status.setFilterRevealed(false);
}else{
return !matches;
}
return true;
}
for(Filter filter:filters){
if(filter.matches(status))