diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java index 2836884..d1a07b2 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/GetUsersHelper.java @@ -400,6 +400,8 @@ public class GetUsersHelper { //Get account creation time advancedUserInfo.setAccount_creation_time(userObject.getInt("account_creation_time")); + //Check if user can post text or this page or not + advancedUserInfo.setCanPostText(userObject.getBoolean("can_post_texts")); } catch (JSONException e){ e.printStackTrace(); diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/models/AdvancedUserInfo.java b/app/src/main/java/org/communiquons/android/comunic/client/data/models/AdvancedUserInfo.java index 0a0c3a0..9e2d204 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/models/AdvancedUserInfo.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/models/AdvancedUserInfo.java @@ -12,6 +12,7 @@ public class AdvancedUserInfo extends UserInfo { //Private fields private int account_creation_time; private boolean accessForbidden = false; + private boolean canPostText; /** * Get the account creation time @@ -48,4 +49,22 @@ public class AdvancedUserInfo extends UserInfo { public void setAccessForbidden(boolean accessForbidden) { this.accessForbidden = accessForbidden; } + + /** + * Set whether the current user can post a text on this user page or not + * + * @param canPostText TRUE to allow / FALSE to deny + */ + public void setCanPostText(boolean canPostText) { + this.canPostText = canPostText; + } + + /** + * Check whether the user can post text on this user page + * + * @return TRUE : yes / FALSE no + */ + public boolean isCanPostText() { + return canPostText; + } } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java index 50e0763..328c27b 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java @@ -260,6 +260,10 @@ public class UserPageFragment extends Fragment implements PostsCreateFormFragmen ImageLoadHelper.remove(user_image); ImageLoadHelper.load(getActivity(), userInfo.getAcountImageURL(), user_image); + //Check if the user can post text on this page + mCreatePostButton.setVisibility(userInfo.isCanPostText() ? View.VISIBLE : View.GONE); + + //Load the list of posts of the user load_posts(); }