feat(StatusDisplay): add toolTip/ContentDescription to visibilty icon

This commit is contained in:
FineFindus 2023-01-09 21:02:00 +01:00
parent 369902ffe5
commit 6c1424055f
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
2 changed files with 15 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package org.joinmastodon.android.ui.displayitems;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.TextUtils; import android.text.TextUtils;
@ -100,6 +101,11 @@ public class ExtendedFooterStatusDisplayItem extends StatusDisplayItem{
case PRIVATE -> R.drawable.ic_fluent_people_checkmark_20_regular; case PRIVATE -> R.drawable.ic_fluent_people_checkmark_20_regular;
case DIRECT -> R.drawable.ic_fluent_mention_24_regular; case DIRECT -> R.drawable.ic_fluent_mention_24_regular;
}); });
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
visibility.setTooltipText(UiUtils.getVisibilityText(s));
}
visibility.setContentDescription(UiUtils.getVisibilityText(s));
} }
@Override @Override

View File

@ -1004,4 +1004,13 @@ public class UiUtils{
return false; return false;
} }
} }
public static String getVisibilityText(Status status) {
return MastodonApp.context.getString(switch (status.visibility) {
case PUBLIC -> R.string.visibility_public;
case UNLISTED -> R.string.sk_visibility_unlisted;
case PRIVATE -> R.string.visibility_followers_only;
case DIRECT -> R.string.visibility_private;
});
}
} }