Skip to content

Commit

Permalink
Add unlisted visibility option as "quiet public"
Browse files Browse the repository at this point in the history
closes #189, closes #103, closes #37
  • Loading branch information
grishka committed Mar 18, 2024
1 parent e59cf2a commit f888091
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,8 @@ private void onVisibilityClick(View v){
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){
Expand Down Expand Up @@ -950,12 +952,7 @@ private void loadDefaultStatusVisibility(Bundle savedInstanceState){
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
Expand All @@ -973,12 +970,14 @@ private void updateVisibilityIcon(){
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();
Expand Down
9 changes: 9 additions & 0 deletions mastodon/src/main/res/drawable/ic_clear_night_20px.xml
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 2 additions & 0 deletions mastodon/src/main/res/menu/compose_visibility.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions mastodon/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -727,4 +727,5 @@
<string name="new_post_notifications_disabled">You’ll 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>

0 comments on commit f888091

Please sign in to comment.