diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/enums/PostVisibilityLevels.java b/app/src/main/java/org/communiquons/android/comunic/client/data/enums/PostVisibilityLevels.java index 2412955..52b72df 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/enums/PostVisibilityLevels.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/enums/PostVisibilityLevels.java @@ -19,6 +19,11 @@ public enum PostVisibilityLevels { */ FRIENDS, + /** + * Groups-members visible posts + */ + MEMBERS, + /** * Private post */ diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java index 1f1bb55..5cd7149 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/PostsHelper.java @@ -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"; diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java index c9837c7..e9a4bf4 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/adapters/PostsAdapter.java @@ -133,6 +133,10 @@ public class PostsAdapter extends ArrayAdapter{ 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); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7b84d80..6e00ae9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -202,4 +202,5 @@ My Page on the page of the group %1$s Could not get information about groups! + members