diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/PostsListFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/PostsListFragment.java index 7070eab..11a82b2 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/PostsListFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/PostsListFragment.java @@ -25,7 +25,6 @@ import org.communiquons.android.comunic.client.data.UsersInfo.UserInfo; import org.communiquons.android.comunic.client.data.comments.Comment; import org.communiquons.android.comunic.client.data.comments.CommentsHelper; import org.communiquons.android.comunic.client.data.posts.Post; -import org.communiquons.android.comunic.client.data.posts.PostUserAccess; import org.communiquons.android.comunic.client.data.posts.PostsHelper; import org.communiquons.android.comunic.client.data.posts.PostsList; import org.communiquons.android.comunic.client.data.utils.StringsUtils; @@ -101,6 +100,7 @@ public class PostsListFragment extends Fragment */ PostsHelper mPostsHelper; + /** * Comments helper */ @@ -174,6 +174,7 @@ public class PostsListFragment extends Fragment //Notify data set update mPostsAdapter.notifyDataSetChanged(); + } @Override 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 c0321a3..d0de622 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 @@ -96,6 +96,16 @@ public class UserPageFragment extends Fragment { */ private PostsListFragment mPostsListFragment; + /** + * Create a post on user page button + */ + private ImageView mCreatePostButton; + + /** + * Create a post on user page form + */ + private View mCreatePostForm; + @Override public void onCreate(@Nullable Bundle savedInstanceState) { @@ -127,6 +137,20 @@ public class UserPageFragment extends Fragment { //Get the user views user_image = view.findViewById(R.id.user_account_image); user_name = view.findViewById(R.id.user_account_name); + + //Get the view related to the create post form + mCreatePostButton = view.findViewById(R.id.create_post_button); + mCreatePostForm = view.findViewById(R.id.create_post_form); + + //Trigger the form + mCreatePostForm.setVisibility(View.GONE); + mCreatePostButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mCreatePostForm.setVisibility( + mCreatePostForm.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); + } + }); } @Override diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/views/NestedListView.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/views/NestedListView.java new file mode 100644 index 0000000..85924f6 --- /dev/null +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/views/NestedListView.java @@ -0,0 +1,98 @@ +package org.communiquons.android.comunic.client.ui.views; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.ListView; + +/** + * Nested ListView class + * + * @from https://stackoverflow.com/a/17503823 + * @author Muhammad Aamir Ali + * @author Pierre HUBERT + */ + +public class NestedListView extends ListView /*implements View.OnTouchListener, AbsListView.OnScrollListener*/ { + + /*/** + * Debug tag + *//* + private static final String TAG = "NestedListView"; + + private int listViewTouchAction; + private static final int MAXIMUM_LIST_ITEMS_VIEWABLE = 99; + + + private int lastItemCounted = 0; + private int itemsHeight = 2;*/ + + + public NestedListView(Context context, AttributeSet attrs) { + super(context, attrs); + /*listViewTouchAction = -1; + setOnScrollListener(this); + setOnTouchListener(this);*/ + } + + /*@Override + public void onScroll(AbsListView view, int firstVisibleItem, + int visibleItemCount, int totalItemCount) { + + /*if (getAdapter() != null && getAdapter().getCount() > MAXIMUM_LIST_ITEMS_VIEWABLE) { + if (listViewTouchAction == MotionEvent.ACTION_MOVE) { + scrollBy(0, -1); + } + }*//* + } + + @Override + public void onScrollStateChanged(AbsListView view, int scrollState) { + } + + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + if(getAdapter() == null) + return; + + /*View view = null; + + for(int i = lastItemCounted; i < getLastVisiblePosition() || i < 2; i++){ + if(getAdapter().getCount() < i+1) + break; + + view = getAdapter().getView(i, view, this); + + view.measure(widthMeasureSpec, heightMeasureSpec); + itemsHeight += view.getMeasuredHeight(); + + lastItemCounted++; + } + + //Add average height for the remaining items + itemsHeight += (lastItemCounted - getAdapter().getCount() + 1)*(itemsHeight/(lastItemCounted+1)); + + setMeasuredDimension(getMeasuredWidth(), itemsHeight);*//* + + + + //setMeasuredDimension(getMeasuredWidth(), 700); + + } + + @Override + public boolean onTouch(View v, MotionEvent event) { + + /*if (getAdapter() != null && getAdapter().getCount() > MAXIMUM_LIST_ITEMS_VIEWABLE) { + if (listViewTouchAction == MotionEvent.ACTION_MOVE) { + scrollBy(0, 1); + } + } + //return false;*/ + /* Log.v(TAG, "scroll:" ); + v.getParent().requestDisallowInterceptTouchEvent(false); + return false;*/ + /* }*/ +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_postslist.xml b/app/src/main/res/layout/fragment_postslist.xml index e29fecf..f9c9fe7 100644 --- a/app/src/main/res/layout/fragment_postslist.xml +++ b/app/src/main/res/layout/fragment_postslist.xml @@ -1,5 +1,5 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> + android:contentDescription="@string/user_image_description" + android:src="@drawable/default_account_image" /> + tools:text="User name" /> + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/post_create_form.xml b/app/src/main/res/layout/post_create_form.xml new file mode 100644 index 0000000..29b1f4b --- /dev/null +++ b/app/src/main/res/layout/post_create_form.xml @@ -0,0 +1,22 @@ + + + + + + + +