Fix issue with content warnings not being expanded from a11y delegate (#1167)

This commit is contained in:
Ivan Kupalov 2019-03-30 08:10:34 +00:00 committed by Konrad Pozniak
parent 631a21c5a9
commit 85c265414d
2 changed files with 9 additions and 1 deletions

View File

@ -124,6 +124,10 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
username.setText(usernameText);
}
public void toggleContentWarning() {
contentWarningButton.toggle();
}
protected void setSpoilerAndContent(boolean expanded,
@NonNull Spanned content,
@Nullable String spoilerText,

View File

@ -15,6 +15,7 @@ import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.Accessibilit
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.adapter.StatusBaseViewHolder
import com.keylesspalace.tusky.interfaces.StatusActionListener
import com.keylesspalace.tusky.viewdata.StatusViewData
@ -115,7 +116,10 @@ class ListStatusAccessibilityDelegate(
statusActionListener.onViewMedia(pos, 3, null)
}
R.id.action_expand_cw -> {
statusActionListener.onExpandedChange(true, pos)
// Toggling it directly to avoid animations
// which cannot be disabled for detaild status for some reason
val holder = recyclerView.getChildViewHolder(host) as StatusBaseViewHolder
holder.toggleContentWarning()
// Stop and restart narrator before it reads old description.
// Would be nice if we could *just* read the content here but doesn't seem
// to be possible.