mirror of
				https://github.com/pierre42100/ComunicAndroid
				synced 2025-11-04 11:34:06 +00:00 
			
		
		
		
	Display posts visibility level.
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -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")){
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -88,13 +88,35 @@ public class PostsAdapter extends ArrayAdapter<Post>{
 | 
			
		||||
            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);
 | 
			
		||||
 
 | 
			
		||||
@@ -44,6 +44,20 @@
 | 
			
		||||
 | 
			
		||||
        </LinearLayout>
 | 
			
		||||
 | 
			
		||||
        <!-- Separator -->
 | 
			
		||||
        <View
 | 
			
		||||
            android:layout_width="0dp"
 | 
			
		||||
            android:layout_height="0dp"
 | 
			
		||||
            android:layout_weight="1"/>
 | 
			
		||||
 | 
			
		||||
        <!-- Post visibility level -->
 | 
			
		||||
        <TextView
 | 
			
		||||
            android:id="@+id/post_visibility"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            tools:text="Public"
 | 
			
		||||
            style="@style/PostVisibility"/>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    </LinearLayout>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -97,4 +97,7 @@
 | 
			
		||||
    <string name="dialog_loading_msg">Loading…</string>
 | 
			
		||||
    <string name="navigation_bottom_user_item">User</string>
 | 
			
		||||
    <string name="err_get_user_posts">Couldn\'t get user posts !</string>
 | 
			
		||||
    <string name="post_visibility_public">public</string>
 | 
			
		||||
    <string name="post_visibility_friends">friends</string>
 | 
			
		||||
    <string name="post_visibility_private">private</string>
 | 
			
		||||
</resources>
 | 
			
		||||
 
 | 
			
		||||
@@ -51,6 +51,11 @@
 | 
			
		||||
        <item name="android:paddingLeft">10dp</item>
 | 
			
		||||
    </style>
 | 
			
		||||
 | 
			
		||||
    <!-- Post visibility -->
 | 
			
		||||
    <style name="PostVisibility">
 | 
			
		||||
        <item name="android:paddingEnd">2dp</item>
 | 
			
		||||
    </style>
 | 
			
		||||
 | 
			
		||||
    <!-- Post content -->
 | 
			
		||||
    <style name="PostContent">
 | 
			
		||||
        <item name="android:textAlignment">center</item>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user