mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +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,
|
FRIENDS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Groups-members visible posts
|
||||||
|
*/
|
||||||
|
MEMBERS,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private post
|
* Private post
|
||||||
*/
|
*/
|
||||||
|
@ -320,22 +320,7 @@ public class PostsHelper {
|
|||||||
post.setComments_list(CommentsHelper.parse_json_array(json.getJSONArray("comments")));
|
post.setComments_list(CommentsHelper.parse_json_array(json.getJSONArray("comments")));
|
||||||
|
|
||||||
//Determine the visibility level of the post
|
//Determine the visibility level of the post
|
||||||
switch (json.getString("visibility_level")){
|
post.setVisibilityLevel(api_to_visibility_levels(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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Determine the type of the post
|
//Determine the type of the post
|
||||||
switch (json.getString("kind")){
|
switch (json.getString("kind")){
|
||||||
@ -392,6 +377,33 @@ public class PostsHelper {
|
|||||||
return post;
|
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
|
* Turn a POST visibility level into a string ready for the API
|
||||||
*
|
*
|
||||||
@ -407,6 +419,9 @@ public class PostsHelper {
|
|||||||
case FRIENDS:
|
case FRIENDS:
|
||||||
return "friends";
|
return "friends";
|
||||||
|
|
||||||
|
case MEMBERS:
|
||||||
|
return "members";
|
||||||
|
|
||||||
case PRIVATE:
|
case PRIVATE:
|
||||||
return "private";
|
return "private";
|
||||||
|
|
||||||
|
@ -133,6 +133,10 @@ public class PostsAdapter extends ArrayAdapter<Post>{
|
|||||||
visibilityLevel.setText(R.string.post_visibility_friends);
|
visibilityLevel.setText(R.string.post_visibility_friends);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MEMBERS:
|
||||||
|
visibilityLevel.setText(R.string.post_visibility_members);
|
||||||
|
break;
|
||||||
|
|
||||||
case PRIVATE:
|
case PRIVATE:
|
||||||
default:
|
default:
|
||||||
visibilityLevel.setText(R.string.post_visibility_private);
|
visibilityLevel.setText(R.string.post_visibility_private);
|
||||||
|
@ -202,4 +202,5 @@
|
|||||||
<string name="action_personal_page">My Page</string>
|
<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="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="err_get_groups_info">Could not get information about groups!</string>
|
||||||
|
<string name="post_visibility_members">members</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user