mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 07:49:28 +00:00
Added "group members only" visibility level.
This commit is contained in:
parent
b094b196f0
commit
eed86ea221
@ -19,6 +19,11 @@ public enum PostVisibilityLevels {
|
||||
*/
|
||||
FRIENDS,
|
||||
|
||||
/**
|
||||
* Groups-members visible posts
|
||||
*/
|
||||
MEMBERS,
|
||||
|
||||
/**
|
||||
* Private post
|
||||
*/
|
||||
|
@ -320,22 +320,7 @@ public class PostsHelper {
|
||||
post.setComments_list(CommentsHelper.parse_json_array(json.getJSONArray("comments")));
|
||||
|
||||
//Determine the visibility level of the post
|
||||
switch (json.getString("visibility_level")){
|
||||
|
||||
case "public":
|
||||
post.setVisibilityLevel(PostVisibilityLevels.PUBLIC);
|
||||
break;
|
||||
|
||||
case "friends":
|
||||
post.setVisibilityLevel(PostVisibilityLevels.FRIENDS);
|
||||
break;
|
||||
|
||||
case "private":
|
||||
default :
|
||||
post.setVisibilityLevel(PostVisibilityLevels.PRIVATE);
|
||||
break;
|
||||
|
||||
}
|
||||
post.setVisibilityLevel(api_to_visibility_levels(json.getString("visibility_level")));
|
||||
|
||||
//Determine the type of the post
|
||||
switch (json.getString("kind")){
|
||||
@ -392,6 +377,33 @@ public class PostsHelper {
|
||||
return post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn API visibility level to PostVisibilityLevel
|
||||
*
|
||||
* @param level The level to transform
|
||||
* @return Matching visibility level
|
||||
*/
|
||||
private PostVisibilityLevels api_to_visibility_levels(String level){
|
||||
switch (level){
|
||||
|
||||
case "public":
|
||||
return PostVisibilityLevels.PUBLIC;
|
||||
|
||||
case "friends":
|
||||
return PostVisibilityLevels.FRIENDS;
|
||||
|
||||
case "members":
|
||||
return PostVisibilityLevels.MEMBERS;
|
||||
|
||||
case "private":
|
||||
return PostVisibilityLevels.PRIVATE;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("Unsupported kind of post visibility " +
|
||||
"level: '"+level+"' !");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a POST visibility level into a string ready for the API
|
||||
*
|
||||
@ -407,6 +419,9 @@ public class PostsHelper {
|
||||
case FRIENDS:
|
||||
return "friends";
|
||||
|
||||
case MEMBERS:
|
||||
return "members";
|
||||
|
||||
case PRIVATE:
|
||||
return "private";
|
||||
|
||||
|
@ -133,6 +133,10 @@ public class PostsAdapter extends ArrayAdapter<Post>{
|
||||
visibilityLevel.setText(R.string.post_visibility_friends);
|
||||
break;
|
||||
|
||||
case MEMBERS:
|
||||
visibilityLevel.setText(R.string.post_visibility_members);
|
||||
break;
|
||||
|
||||
case PRIVATE:
|
||||
default:
|
||||
visibilityLevel.setText(R.string.post_visibility_private);
|
||||
|
@ -202,4 +202,5 @@
|
||||
<string name="action_personal_page">My Page</string>
|
||||
<string name="notif_on_group_page">on the page of the group %1$s</string>
|
||||
<string name="err_get_groups_info">Could not get information about groups!</string>
|
||||
<string name="post_visibility_members">members</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user