Make text selectable in thread view

This commit is contained in:
Grishka 2022-04-07 18:33:39 +03:00
parent d6bb5b7b3a
commit 4bac1cbc06
4 changed files with 32 additions and 1 deletions

View File

@ -543,6 +543,10 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
}
public boolean isItemEnabled(String id){
return true;
}
@Override
public void onApplyWindowInsets(WindowInsets insets){
if(Build.VERSION.SDK_INT>=29 && insets.getTappableElementInsets().bottom==0 && wantsOverlaySystemNavigation()){

View File

@ -15,11 +15,14 @@ import org.joinmastodon.android.events.StatusDeletedEvent;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.StatusContext;
import org.joinmastodon.android.model.Status;
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.TextStatusDisplayItem;
import org.joinmastodon.android.ui.text.HtmlParser;
import org.joinmastodon.android.ui.utils.UiUtils;
import org.parceler.Parcels;
import java.util.Collections;
import java.util.List;
import me.grishka.appkit.api.SimpleCallback;
@ -38,6 +41,18 @@ public class ThreadFragment extends StatusListFragment{
setTitle(HtmlParser.parseCustomEmoji(getString(R.string.post_from_user, mainStatus.account.displayName), mainStatus.account.emojis));
}
@Override
protected List<StatusDisplayItem> buildDisplayItems(Status s){
List<StatusDisplayItem> items=super.buildDisplayItems(s);
if(s==mainStatus){
for(StatusDisplayItem item:items){
if(item instanceof TextStatusDisplayItem)
((TextStatusDisplayItem) item).textSelectable=true;
}
}
return items;
}
@Override
protected void doLoadData(int offset, int count){
currentRequest=new GetStatusContext(mainStatus.id)
@ -105,4 +120,9 @@ public class ThreadFragment extends StatusListFragment{
onAppendItems(Collections.singletonList(ev.status));
}
}
@Override
public boolean isItemEnabled(String id){
return !id.equals(mainStatus.id);
}
}

View File

@ -145,7 +145,7 @@ public abstract class StatusDisplayItem{
HASHTAG
}
public static abstract class Holder<T extends StatusDisplayItem> extends BindableViewHolder<T> implements UsableRecyclerView.Clickable{
public static abstract class Holder<T extends StatusDisplayItem> extends BindableViewHolder<T> implements UsableRecyclerView.DisableableClickable{
public Holder(View itemView){
super(itemView);
}
@ -162,5 +162,10 @@ public abstract class StatusDisplayItem{
public void onClick(){
item.parentFragment.onItemClick(item.parentID);
}
@Override
public boolean isEnabled(){
return item.parentFragment.isItemEnabled(item.parentID);
}
}
}

View File

@ -21,6 +21,7 @@ import me.grishka.appkit.imageloader.requests.ImageLoaderRequest;
public class TextStatusDisplayItem extends StatusDisplayItem{
private CharSequence text;
private CustomEmojiHelper emojiHelper=new CustomEmojiHelper();
public boolean textSelectable;
public final Status status;
public TextStatusDisplayItem(String parentID, CharSequence text, BaseStatusListFragment parentFragment, Status status){
@ -61,6 +62,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{
@Override
public void onBind(TextStatusDisplayItem item){
text.setText(item.text);
text.setTextIsSelectable(item.textSelectable);
text.setInvalidateOnEveryFrame(false);
if(!TextUtils.isEmpty(item.status.spoilerText)){
spoilerTitle.setText(item.status.spoilerText);