fix issue with visibility button

closes sk22#740
This commit is contained in:
sk 2023-08-28 23:24:56 +02:00
parent 83e84836b5
commit cc46e09853
2 changed files with 15 additions and 6 deletions

View File

@ -188,6 +188,10 @@ public class Status extends BaseModel implements DisplayItemsParent, Searchable{
return strippedText; return strippedText;
} }
public boolean hasSpoiler(){
return !TextUtils.isEmpty(spoilerText);
}
@NonNull @NonNull
@Override @Override
public Status clone(){ public Status clone(){

View File

@ -192,7 +192,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
} }
} }
boolean isPixelfed = item.parentFragment.isInstancePixelfed(); boolean isPixelfed = item.parentFragment.isInstancePixelfed();
boolean textEmpty = TextUtils.isEmpty(item.status.content) && TextUtils.isEmpty(item.status.spoilerText); boolean textEmpty = TextUtils.isEmpty(item.status.content) && !item.status.hasSpoiler();
if(!redraft && (isPixelfed || textEmpty)){ if(!redraft && (isPixelfed || textEmpty)){
// pixelfed doesn't support /statuses/:id/source :/ // pixelfed doesn't support /statuses/:id/source :/
if (isPixelfed) { if (isPixelfed) {
@ -324,11 +324,16 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
deleteNotification.setVisibility(GlobalUserPreferences.enableDeleteNotifications && item.notification!=null && !item.inset ? View.VISIBLE : View.GONE); deleteNotification.setVisibility(GlobalUserPreferences.enableDeleteNotifications && item.notification!=null && !item.inset ? View.VISIBLE : View.GONE);
if (item.hasVisibilityToggle){ if (item.hasVisibilityToggle){
boolean disabled = !item.status.sensitiveRevealed || boolean hidden = !item.status.sensitiveRevealed || (item.status.hasSpoiler() && !item.status.spoilerRevealed);
(!TextUtils.isEmpty(item.status.spoilerText) &&
!item.status.spoilerRevealed); // doing this because V.setVisibilityAnimated ignores changes between INVISIBLE and GONE
visibility.setEnabled(!disabled); int newVis=hidden ? View.INVISIBLE : View.VISIBLE;
V.setVisibilityAnimated(visibility, disabled ? View.INVISIBLE : View.VISIBLE); if(newVis==View.INVISIBLE && visibility.getVisibility()==View.GONE)
visibility.setVisibility(newVis);
else
V.setVisibilityAnimated(visibility, newVis);
visibility.setEnabled(!hidden);
visibility.setContentDescription(item.parentFragment.getString(item.status.sensitiveRevealed ? R.string.spoiler_hide : R.string.spoiler_show)); visibility.setContentDescription(item.parentFragment.getString(item.status.sensitiveRevealed ? R.string.spoiler_hide : R.string.spoiler_show));
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){ if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
visibility.setTooltipText(visibility.getContentDescription()); visibility.setTooltipText(visibility.getContentDescription());