Add unlisted visibility option as "quiet public"

closes #189, closes #103, closes #37
This commit is contained in:
Grishka 2024-03-18 20:34:23 +03:00
parent e59cf2afca
commit f888091e22
4 changed files with 19 additions and 8 deletions

View File

@ -915,6 +915,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
int id=item.getItemId();
if(id==R.id.vis_public){
statusVisibility=StatusPrivacy.PUBLIC;
}else if(id==R.id.vis_unlisted){
statusVisibility=StatusPrivacy.UNLISTED;
}else if(id==R.id.vis_followers){
statusVisibility=StatusPrivacy.PRIVATE;
}else if(id==R.id.vis_private){
@ -950,12 +952,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
private void applyPreferencesForPostVisibility(Preferences prefs, Bundle savedInstanceState){
// Only override the reply visibility if our preference is more private
if(prefs.postingDefaultVisibility.isLessVisibleThan(statusVisibility)){
// Map unlisted from the API onto public, because we don't have unlisted in the UI
statusVisibility=switch(prefs.postingDefaultVisibility){
case PUBLIC, UNLISTED -> StatusPrivacy.PUBLIC;
case PRIVATE -> StatusPrivacy.PRIVATE;
case DIRECT -> StatusPrivacy.DIRECT;
};
statusVisibility=prefs.postingDefaultVisibility;
}
// A saved privacy setting from a previous compose session wins over all
@ -973,12 +970,14 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
statusVisibility=StatusPrivacy.PUBLIC;
}
visibilityBtn.setText(switch(statusVisibility){
case PUBLIC, UNLISTED -> R.string.visibility_public;
case PUBLIC -> R.string.visibility_public;
case UNLISTED -> R.string.visibility_unlisted;
case PRIVATE -> R.string.visibility_followers_only;
case DIRECT -> R.string.visibility_private;
});
Drawable icon=getResources().getDrawable(switch(statusVisibility){
case PUBLIC, UNLISTED -> R.drawable.ic_public_20px;
case PUBLIC -> R.drawable.ic_public_20px;
case UNLISTED -> R.drawable.ic_clear_night_20px;
case PRIVATE -> R.drawable.ic_group_20px;
case DIRECT -> R.drawable.ic_alternate_email_20px;
}, getActivity().getTheme()).mutate();

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:fillColor="@android:color/white"
android:pathData="M10,16.583Q11.125,16.583 12.135,16.26Q13.146,15.938 14.021,15.271Q12.229,14.604 10.865,13.427Q9.5,12.25 8.656,10.74Q7.812,9.229 7.542,7.448Q7.271,5.667 7.667,3.812Q5.771,4.5 4.594,6.177Q3.417,7.854 3.417,10Q3.417,12.75 5.333,14.667Q7.25,16.583 10,16.583ZM10,18.333Q8.271,18.333 6.75,17.677Q5.229,17.021 4.104,15.896Q2.979,14.771 2.323,13.25Q1.667,11.729 1.667,10Q1.667,7 3.635,4.729Q5.604,2.458 8.521,1.854Q9.208,1.708 9.51,2.135Q9.812,2.562 9.562,3.312Q9.021,5 9.198,6.708Q9.375,8.417 10.177,9.875Q10.979,11.333 12.323,12.406Q13.667,13.479 15.438,13.917Q16.208,14.104 16.427,14.594Q16.646,15.083 16.167,15.604Q15.021,16.896 13.438,17.615Q11.854,18.333 10,18.333Z"/>
</vector>

View File

@ -2,6 +2,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/vis_public"
android:title="@string/visibility_public"/>
<item android:id="@+id/vis_unlisted"
android:title="@string/visibility_unlisted"/>
<item android:id="@+id/vis_followers"
android:title="@string/visibility_followers_only"/>
<item android:id="@+id/vis_private"

View File

@ -727,4 +727,5 @@
<string name="new_post_notifications_disabled">Youll no longer get notifications for new posts.</string>
<string name="mute_conversation">Mute conversation</string>
<string name="unmute_conversation">Unmute conversation</string>
<string name="visibility_unlisted">Quiet public</string>
</resources>