@@ -1,6 +1,8 @@
|
|||||||
package org.joinmastodon.android.model;
|
package org.joinmastodon.android.model;
|
||||||
|
|
||||||
import org.joinmastodon.android.GlobalUserPreferences;
|
import org.joinmastodon.android.GlobalUserPreferences;
|
||||||
|
import org.joinmastodon.android.MastodonApp;
|
||||||
|
import org.joinmastodon.android.R;
|
||||||
import org.jsoup.internal.StringUtil;
|
import org.jsoup.internal.StringUtil;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
@@ -8,9 +10,10 @@ import java.util.EnumSet;
|
|||||||
public class AltTextFilter extends LegacyFilter {
|
public class AltTextFilter extends LegacyFilter {
|
||||||
|
|
||||||
public AltTextFilter(FilterAction filterAction, EnumSet<FilterContext> filterContexts) {
|
public AltTextFilter(FilterAction filterAction, EnumSet<FilterContext> filterContexts) {
|
||||||
this.filterAction = filterAction;
|
this.filterAction=filterAction;
|
||||||
isRemote = false;
|
this.title=MastodonApp.context.getString(R.string.sk_no_alt_text);
|
||||||
context = filterContexts;
|
this.isRemote=false;
|
||||||
|
this.context=filterContexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -396,6 +396,8 @@ public abstract class StatusDisplayItem{
|
|||||||
List<StatusDisplayItem> nonGapItems=gap!=null ? items.subList(0, items.size()-1) : items;
|
List<StatusDisplayItem> nonGapItems=gap!=null ? items.subList(0, items.size()-1) : items;
|
||||||
WarningFilteredStatusDisplayItem warning=applyingFilter==null ? null :
|
WarningFilteredStatusDisplayItem warning=applyingFilter==null ? null :
|
||||||
new WarningFilteredStatusDisplayItem(parentID, fragment, statusForContent, nonGapItems, applyingFilter);
|
new WarningFilteredStatusDisplayItem(parentID, fragment, statusForContent, nonGapItems, applyingFilter);
|
||||||
|
if(warning!=null)
|
||||||
|
warning.inset=inset;
|
||||||
return applyingFilter==null ? items : new ArrayList<>(gap!=null
|
return applyingFilter==null ? items : new ArrayList<>(gap!=null
|
||||||
? List.of(warning, gap)
|
? List.of(warning, gap)
|
||||||
: Collections.singletonList(warning)
|
: Collections.singletonList(warning)
|
||||||
|
|||||||
@@ -8,14 +8,12 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||||
import org.joinmastodon.android.model.AltTextFilter;
|
|
||||||
import org.joinmastodon.android.model.Filter;
|
|
||||||
import org.joinmastodon.android.model.LegacyFilter;
|
import org.joinmastodon.android.model.LegacyFilter;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
|
import org.joinmastodon.android.ui.OutlineProviders;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
// Mind the gap!
|
|
||||||
public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{
|
public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{
|
||||||
public boolean loading;
|
public boolean loading;
|
||||||
public List<StatusDisplayItem> filteredItems;
|
public List<StatusDisplayItem> filteredItems;
|
||||||
@@ -24,8 +22,8 @@ public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{
|
|||||||
public WarningFilteredStatusDisplayItem(String parentID, BaseStatusListFragment<?> parentFragment, Status status, List<StatusDisplayItem> filteredItems, LegacyFilter applyingFilter){
|
public WarningFilteredStatusDisplayItem(String parentID, BaseStatusListFragment<?> parentFragment, Status status, List<StatusDisplayItem> filteredItems, LegacyFilter applyingFilter){
|
||||||
super(parentID, parentFragment);
|
super(parentID, parentFragment);
|
||||||
this.status=status;
|
this.status=status;
|
||||||
this.filteredItems = filteredItems;
|
this.filteredItems=filteredItems;
|
||||||
this.applyingFilter = applyingFilter;
|
this.applyingFilter=applyingFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,21 +41,24 @@ public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{
|
|||||||
super(context, R.layout.display_item_warning, parent);
|
super(context, R.layout.display_item_warning, parent);
|
||||||
warningWrap=findViewById(R.id.warning_wrap);
|
warningWrap=findViewById(R.id.warning_wrap);
|
||||||
showBtn=findViewById(R.id.reveal_btn);
|
showBtn=findViewById(R.id.reveal_btn);
|
||||||
showBtn.setOnClickListener(i -> item.parentFragment.onWarningClick(this));
|
showBtn.setOnClickListener(i->item.parentFragment.onWarningClick(this));
|
||||||
itemView.setOnClickListener(v->item.parentFragment.onWarningClick(this));
|
itemView.setOnClickListener(v->item.parentFragment.onWarningClick(this));
|
||||||
text=findViewById(R.id.text);
|
text=findViewById(R.id.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBind(WarningFilteredStatusDisplayItem item) {
|
public void onBind(WarningFilteredStatusDisplayItem item){
|
||||||
filteredItems = item.filteredItems;
|
filteredItems=item.filteredItems;
|
||||||
String title = item.applyingFilter instanceof AltTextFilter ? item.parentFragment.getString(R.string.sk_no_alt_text) : item.applyingFilter.title;
|
String title=item.applyingFilter.title;
|
||||||
text.setText(item.parentFragment.getString(R.string.sk_filtered, title));
|
text.setText(item.parentFragment.getString(R.string.sk_filtered, title));
|
||||||
|
|
||||||
|
if(item.inset){
|
||||||
|
itemView.setClipToOutline(true);
|
||||||
|
itemView.setOutlineProvider(OutlineProviders.roundedRect(12));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(){
|
public void onClick(){}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
|||||||
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.displayitems.LinkCardStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.LinkCardStatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.displayitems.MediaGridStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.MediaGridStatusDisplayItem;
|
||||||
|
import org.joinmastodon.android.ui.displayitems.WarningFilteredStatusDisplayItem;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -42,13 +43,16 @@ public class InsetStatusItemDecoration extends RecyclerView.ItemDecoration{
|
|||||||
boolean inset=(holder instanceof StatusDisplayItem.Holder<?> sdi) && sdi.getItem().inset;
|
boolean inset=(holder instanceof StatusDisplayItem.Holder<?> sdi) && sdi.getItem().inset;
|
||||||
if(inset){
|
if(inset){
|
||||||
if(rect.isEmpty()){
|
if(rect.isEmpty()){
|
||||||
if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder){
|
if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder || holder instanceof WarningFilteredStatusDisplayItem.Holder){
|
||||||
rect.set(child.getX(), i == 0 && pos > 0 && displayItems.get(pos - 1).inset ? V.dp(-10) : child.getY(), child.getX() + child.getWidth(), child.getY() + child.getHeight() + V.dp(4));
|
float topInset=i == 0 && pos > 0 && displayItems.get(pos - 1).inset ? V.dp(-10) : child.getY();
|
||||||
|
if(holder instanceof WarningFilteredStatusDisplayItem.Holder)
|
||||||
|
topInset-=V.dp(4);
|
||||||
|
rect.set(child.getX(), topInset, child.getX() + child.getWidth(), child.getY() + child.getHeight() + V.dp(4));
|
||||||
}else {
|
}else {
|
||||||
rect.set(child.getX(), i == 0 && pos > 0 && displayItems.get(pos - 1).inset ? V.dp(-10) : child.getY(), child.getX() + child.getWidth(), child.getY() + child.getHeight());
|
rect.set(child.getX(), i == 0 && pos > 0 && displayItems.get(pos - 1).inset ? V.dp(-10) : child.getY(), child.getX() + child.getWidth(), child.getY() + child.getHeight());
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder){
|
if(holder instanceof MediaGridStatusDisplayItem.Holder || holder instanceof LinkCardStatusDisplayItem.Holder || holder instanceof WarningFilteredStatusDisplayItem.Holder){
|
||||||
rect.bottom=Math.max(rect.bottom, child.getY()+child.getHeight()) + V.dp(4);
|
rect.bottom=Math.max(rect.bottom, child.getY()+child.getHeight()) + V.dp(4);
|
||||||
}else {
|
}else {
|
||||||
rect.bottom=Math.max(rect.bottom, child.getY()+child.getHeight());
|
rect.bottom=Math.max(rect.bottom, child.getY()+child.getHeight());
|
||||||
|
|||||||
@@ -29,8 +29,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:visibility="visible"
|
android:visibility="visible"/>
|
||||||
/>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user