use material buttons in timeline (#1627)
* use material buttons in timeline * remove wrong switch option
This commit is contained in:
parent
b87a1711f2
commit
e5b78f65cf
15 changed files with 96 additions and 107 deletions
|
|
@ -19,9 +19,9 @@ import android.content.Context;
|
|||
import android.text.InputFilter;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ public class ConversationViewHolder extends StatusBaseViewHolder {
|
|||
private static final InputFilter[] NO_INPUT_FILTER = new InputFilter[0];
|
||||
|
||||
private TextView conversationNameTextView;
|
||||
private ToggleButton contentCollapseButton;
|
||||
private Button contentCollapseButton;
|
||||
private ImageView[] avatars;
|
||||
|
||||
private StatusDisplayOptions statusDisplayOptions;
|
||||
|
|
@ -145,18 +145,18 @@ public class ConversationViewHolder extends StatusBaseViewHolder {
|
|||
private void setupCollapsedState(boolean collapsible, boolean collapsed, boolean expanded, String spoilerText, final StatusActionListener listener) {
|
||||
/* input filter for TextViews have to be set before text */
|
||||
if (collapsible && (expanded || TextUtils.isEmpty(spoilerText))) {
|
||||
contentCollapseButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
contentCollapseButton.setOnClickListener(view -> {
|
||||
int position = getAdapterPosition();
|
||||
if (position != RecyclerView.NO_POSITION)
|
||||
listener.onContentCollapsedChange(isChecked, position);
|
||||
listener.onContentCollapsedChange(!collapsed, position);
|
||||
});
|
||||
|
||||
contentCollapseButton.setVisibility(View.VISIBLE);
|
||||
if (collapsed) {
|
||||
contentCollapseButton.setChecked(true);
|
||||
contentCollapseButton.setText(R.string.status_content_warning_show_more);
|
||||
content.setFilters(COLLAPSE_INPUT_FILTER);
|
||||
} else {
|
||||
contentCollapseButton.setChecked(false);
|
||||
contentCollapseButton.setText(R.string.status_content_warning_show_less);
|
||||
content.setFilters(NO_INPUT_FILTER);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -93,12 +93,14 @@ class StatusViewHolder(
|
|||
itemView.statusContentWarningDescription.text = emojiSpoiler
|
||||
itemView.statusContentWarningDescription.show()
|
||||
itemView.statusContentWarningButton.show()
|
||||
itemView.statusContentWarningButton.isChecked = viewState.isContentShow(status.id, true)
|
||||
itemView.statusContentWarningButton.setOnCheckedChangeListener { _, isViewChecked ->
|
||||
setContentWarningButtonText(viewState.isContentShow(status.id, true))
|
||||
itemView.statusContentWarningButton.setOnClickListener {
|
||||
status()?.let { status ->
|
||||
val contentShown = viewState.isContentShow(status.id, true)
|
||||
itemView.statusContentWarningDescription.invalidate()
|
||||
viewState.setContentShow(status.id, isViewChecked)
|
||||
setTextVisible(isViewChecked, status.content, status.mentions, status.emojis, adapterHandler)
|
||||
viewState.setContentShow(status.id, !contentShown)
|
||||
setTextVisible(!contentShown, status.content, status.mentions, status.emojis, adapterHandler)
|
||||
setContentWarningButtonText(!contentShown)
|
||||
}
|
||||
}
|
||||
setTextVisible(viewState.isContentShow(status.id, true), status.content, status.mentions, status.emojis, adapterHandler)
|
||||
|
|
@ -106,6 +108,13 @@ class StatusViewHolder(
|
|||
}
|
||||
}
|
||||
|
||||
private fun setContentWarningButtonText(contentShown: Boolean) {
|
||||
if(contentShown) {
|
||||
itemView.statusContentWarningButton.setText(R.string.status_content_warning_show_less)
|
||||
} else {
|
||||
itemView.statusContentWarningButton.setText(R.string.status_content_warning_show_more)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setTextVisible(expanded: Boolean,
|
||||
content: Spanned,
|
||||
|
|
@ -144,19 +153,19 @@ class StatusViewHolder(
|
|||
private fun setupCollapsedState(collapsible: Boolean, collapsed: Boolean, expanded: Boolean, spoilerText: String) {
|
||||
/* input filter for TextViews have to be set before text */
|
||||
if (collapsible && (expanded || TextUtils.isEmpty(spoilerText))) {
|
||||
itemView.buttonToggleContent.setOnCheckedChangeListener { _, isChecked ->
|
||||
itemView.buttonToggleContent.setOnClickListener{
|
||||
status()?.let { status ->
|
||||
viewState.setCollapsed(status.id, isChecked)
|
||||
viewState.setCollapsed(status.id, !collapsed)
|
||||
updateTextView()
|
||||
}
|
||||
}
|
||||
|
||||
itemView.buttonToggleContent.show()
|
||||
if (collapsed) {
|
||||
itemView.buttonToggleContent.isChecked = true
|
||||
itemView.buttonToggleContent.setText(R.string.status_content_show_more)
|
||||
itemView.statusContent.filters = COLLAPSE_INPUT_FILTER
|
||||
} else {
|
||||
itemView.buttonToggleContent.isChecked = false
|
||||
itemView.buttonToggleContent.setText(R.string.status_content_show_less)
|
||||
itemView.statusContent.filters = NO_INPUT_FILTER
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue