mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Created post create form.
This commit is contained in:
parent
a4e8ada1c7
commit
0558f77aed
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;*/
|
||||
/* }*/
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ListView android:id="@+id/posts_list"
|
||||
<org.communiquons.android.comunic.client.ui.views.NestedListView android:id="@+id/posts_list"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/fragment_user_page"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
style="@style/UserPageHeader"
|
||||
@ -21,19 +21,37 @@
|
||||
android:id="@+id/user_account_image"
|
||||
android:layout_width="@dimen/account_image_default_width"
|
||||
android:layout_height="@dimen/account_image_default_height"
|
||||
android:src="@drawable/default_account_image"
|
||||
android:contentDescription="@string/user_image_description"/>
|
||||
android:contentDescription="@string/user_image_description"
|
||||
android:src="@drawable/default_account_image" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_account_name"
|
||||
style="@style/UserPageName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="User name"/>
|
||||
tools:text="User name" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/create_post_button"
|
||||
style="@style/AddUserPostButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/btn_show_create_form_description"
|
||||
android:src="@android:drawable/ic_menu_add" />
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<!-- Include post creation form -->
|
||||
<include
|
||||
android:id="@+id/create_post_form"
|
||||
layout="@layout/post_create_form" />
|
||||
|
||||
<!-- User posts -->
|
||||
<FrameLayout
|
||||
android:id="@+id/user_posts"
|
||||
@ -41,4 +59,8 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"/>
|
||||
|
||||
</LinearLayout>
|
22
app/src/main/res/layout/post_create_form.xml
Normal file
22
app/src/main/res/layout/post_create_form.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<!-- New post content -->
|
||||
<EditText
|
||||
android:id="@+id/new_post_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textMultiLine"
|
||||
android:hint="@string/new_post_hint"
|
||||
android:lines="3"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small" />
|
||||
|
||||
<!-- Submit post -->
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/post_action_send"
|
||||
android:layout_gravity="end" />
|
||||
</LinearLayout>
|
@ -119,4 +119,7 @@
|
||||
<string name="popup_deletepost_cancel">No</string>
|
||||
<string name="popup_deletepost_confirm">Yes</string>
|
||||
<string name="err_delete_post">An error occurred while trying to delete post! Please try again later…</string>
|
||||
<string name="new_post_hint">New post…</string>
|
||||
<string name="post_action_send">Send</string>
|
||||
<string name="btn_show_create_form_description">Show / Hide create post form.</string>
|
||||
</resources>
|
||||
|
@ -27,6 +27,10 @@
|
||||
<item name="android:paddingEnd">5dp</item>
|
||||
</style>
|
||||
|
||||
<style name="AddUserPostButton">
|
||||
<item name="android:layout_gravity">center_vertical</item>
|
||||
</style>
|
||||
|
||||
<!-- Posts style -->
|
||||
<!-- Post container -->
|
||||
<style name="PostContainer">
|
||||
|
Loading…
Reference in New Issue
Block a user