diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java index bcdb837..040e3ce 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/Post.java @@ -17,6 +17,7 @@ public class Post { private int post_time; private String content; private PostTypes type; + private PostVisibilityLevels visibilityLevel; //Files specific private String file_path_url; @@ -70,6 +71,16 @@ public class Post { return type; } + + //Set and get post visibility level + public void setVisibilityLevel(PostVisibilityLevels visibilityLevel) { + this.visibilityLevel = visibilityLevel; + } + + public PostVisibilityLevels getVisibilityLevel() { + return visibilityLevel; + } + //Set and get file path url public void setFile_path_url(String file_path_url) { this.file_path_url = file_path_url; diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostVisibilityLevels.java b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostVisibilityLevels.java new file mode 100644 index 0000000..9ff3411 --- /dev/null +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostVisibilityLevels.java @@ -0,0 +1,27 @@ +package org.communiquons.android.comunic.client.data.posts; + +/** + * Post visibility levels + * + * @author Pierre HUBERT + * Created by pierre on 2/3/18. + */ + +public enum PostVisibilityLevels { + + /** + * Public post + */ + PUBLIC, + + /** + * Friends-visible post + */ + FRIENDS, + + /** + * Private post + */ + PRIVATE + +} diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostsHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostsHelper.java index f3a8aa8..3eef14b 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostsHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/posts/PostsHelper.java @@ -86,6 +86,24 @@ public class PostsHelper { post.setPost_time(json.getInt("post_time")); post.setContent(json.getString("content")); + //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; + + } + //Determine the type of the post switch (json.getString("kind")){ 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 20f8505..a13f080 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 @@ -88,13 +88,35 @@ public class PostsAdapter extends ArrayAdapter{ ImageLoadManager.load(getContext(), userInfo.getAcountImageURL(), userAccountImage); } + //Set post creation time ((TextView) convertView.findViewById(R.id.post_creation_time)).setText(utils. timeToString(Utilities.time() - post.getPost_time())); + + //Set post visibility level + TextView visibilityLevel = convertView.findViewById(R.id.post_visibility); + switch (post.getVisibilityLevel()){ + + case PUBLIC: + visibilityLevel.setText(R.string.post_visibility_public); + break; + + case FRIENDS: + visibilityLevel.setText(R.string.post_visibility_friends); + break; + + case PRIVATE: + default: + visibilityLevel.setText(R.string.post_visibility_private); + break; + } + + //Set post content ((TextView) convertView.findViewById(R.id.post_content)).setText(Utilities.prepareStringTextView(post.getContent())); + //Set post image (if any) ImageView postImage = convertView.findViewById(R.id.post_image); postImage.setVisibility(View.GONE); diff --git a/app/src/main/res/layout/post_item.xml b/app/src/main/res/layout/post_item.xml index 8711d8f..2c7f826 100644 --- a/app/src/main/res/layout/post_item.xml +++ b/app/src/main/res/layout/post_item.xml @@ -44,6 +44,20 @@ + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4a5a6aa..a002a38 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -97,4 +97,7 @@ Loading… User Couldn\'t get user posts ! + public + friends + private diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index e36d431..8644854 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -51,6 +51,11 @@ 10dp + + +