Compare commits

...

4 Commits

Author SHA1 Message Date
LucasGGamerM cbae5c4192 The text now begones if the item is filtered! 2023-01-28 18:03:10 -03:00
LucasGGamerM 891016c8a8 Its a step closer to working 2023-01-28 17:33:05 -03:00
LucasGGamerM ea8a4ae487 It now completely hides posts which have filters with warnings applied to them 2023-01-28 15:05:42 -03:00
LucasGGamerM c51f1be15c Adding something 2023-01-28 09:05:21 -03:00
8 changed files with 149 additions and 15 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

@ -502,6 +502,17 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
revealSpoiler(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);
}
protected void revealSpoiler(Status status, String itemID){
status.spoilerRevealed=true;
TextStatusDisplayItem.Holder text=findHolderOfType(itemID, TextStatusDisplayItem.Holder.class);

View File

@ -60,6 +60,8 @@ public class Status extends BaseModel implements DisplayItemsParent{
public transient boolean spoilerRevealed;
public transient boolean hasGapAfter;
public transient boolean filterRevealed = true;
private transient String strippedText;
@Override
@ -147,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

@ -113,6 +113,36 @@ 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);
return;
}else{
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())
: item.text);

View File

@ -30,7 +30,18 @@ public class StatusFilterPredicate implements Predicate<Status>{
.map(filterResult->filterResult.filter)
.filter(filter->filter.expiresAt==null||filter.expiresAt.isAfter(Instant.now()))
.anyMatch(filter->filter.filterAction==Filter.FilterAction.HIDE);
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))

View File

@ -143,4 +143,44 @@
</org.joinmastodon.android.ui.views.HeaderSubtitleLinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:visibility="visible"
android:gravity="center_vertical"
android:id="@+id/filter_spoiler"
android:layoutDirection="locale">
<TextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="8dp"
android:paddingVertical="8dp"
android:gravity="center_vertical"
android:textColor="?android:textColorPrimary"
android:textSize="16sp" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_weight="0"
android:layout_marginEnd="16dp"
android:maxWidth="140dp"
android:background="@drawable/bg_button_new_posts"
android:elevation="0dp"
android:ellipsize="middle"
android:fontFamily="sans-serif-medium"
android:singleLine="true"
android:stateListAnimator="@null"
android:textColor="?android:textColorPrimary"
android:textSize="16sp"
tools:text="@string/sk_color_palette_pink" />
</LinearLayout>
</RelativeLayout>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:gravity="center_vertical"
android:layoutDirection="locale">
<ImageView
android:id="@+id/icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginHorizontal="16dp"
android:importantForAccessibility="no"
android:tint="?android:textColorPrimary"
tools:src="@drawable/ic_fluent_star_24_regular"/>
<TextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="16dp"
android:paddingVertical="8dp"
android:textSize="16sp"
android:textColor="?android:textColorPrimary"
tools:text="Filtered LMAO"/>
<Button
android:id="@+id/show_anyway"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:paddingHorizontal="8dp"
android:visibility="invisible"
android:backgroundTint="?colorBackgroundLightest"
android:layout_gravity="right|center_vertical"
android:tooltipText="@string/mo_personal_note_confirm"
android:contentDescription="@string/mo_personal_note_confirm"
android:drawableStart="@drawable/ic_fluent_checkmark_24_regular"
/>
</LinearLayout>