Conversations message auto-scroll

This commit is contained in:
Pierre 2017-12-20 17:48:47 +01:00
parent e04ec17272
commit 485f9f5f4c
6 changed files with 64 additions and 5 deletions

View File

@ -72,6 +72,11 @@ public class ConversationFragment extends Fragment
*/ */
private ConversationRefreshRunnable refreshRunnable; private ConversationRefreshRunnable refreshRunnable;
/**
* Converstion message listView
*/
private ListView convMessListView;
/** /**
* Conversation messages helper * Conversation messages helper
*/ */
@ -121,7 +126,7 @@ public class ConversationFragment extends Fragment
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
//Conversation messages listView //Conversation messages listView
ListView convMessListView = view.findViewById(R.id.fragment_conversation_messageslist); convMessListView = view.findViewById(R.id.fragment_conversation_messageslist);
//Need user ID //Need user ID
int userID = new AccountUtils(getActivity()).get_current_user_id(); int userID = new AccountUtils(getActivity()).get_current_user_id();

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape
android:shape="rectangle" >
<solid android:color="#3949ab" >
</solid>
<corners android:radius="5dp" >
</corners>
</shape>
</item>
<item>
<shape
android:shape="rectangle" >
<solid android:color="@color/conversation_user_messages_background">
</solid>
<corners android:radius="5dp" >
</corners>
</shape>
</item>
</selector>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape
android:shape="rectangle" >
<solid android:color="#C0C0C0" >
</solid>
<corners android:radius="5dp" >
</corners>
</shape>
</item>
<item>
<shape
android:shape="rectangle" >
<solid android:color="@color/conversation_otheruser_messages_background">
</solid>
<corners android:radius="5dp" >
</corners>
</shape>
</item>
</selector>

View File

@ -9,6 +9,8 @@
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:divider="@null" android:divider="@null"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
/> />
</LinearLayout> </LinearLayout>

View File

@ -34,7 +34,8 @@
android:layout_height="26dp" android:layout_height="26dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:src="@drawable/default_account_image" /> android:src="@drawable/default_account_image"
android:contentDescription="@string/user_image_description"/>
<TextView <TextView
android:id="@+id/fragment_conversation_message_item_content" android:id="@+id/fragment_conversation_message_item_content"
@ -42,11 +43,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_toEndOf="@id/fragment_conversation_message_item_accountimage" android:layout_toEndOf="@id/fragment_conversation_message_item_accountimage"
android:background="@color/conversation_otheruser_messages_background"
android:padding="5dp" android:padding="5dp"
android:paddingEnd="15dp" android:paddingEnd="15dp"
android:paddingStart="15dp" android:paddingStart="15dp"
android:textColor="@color/conversation_otheruser_messages_textColor" android:textColor="@color/conversation_otheruser_messages_textColor"
android:background="@drawable/fragment_conversation_message_otheruser_bg"
tools:text="A message" /> tools:text="A message" />
</RelativeLayout> </RelativeLayout>
@ -67,6 +68,7 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_gravity="end" android:layout_gravity="end"
android:layout_marginStart="5dp" android:layout_marginStart="5dp"
android:contentDescription="@string/user_image_description"
android:src="@drawable/default_account_image" /> android:src="@drawable/default_account_image" />
<TextView <TextView
@ -75,7 +77,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_toStartOf="@id/fragment_conversation_message_item_accountimage_right" android:layout_toStartOf="@id/fragment_conversation_message_item_accountimage_right"
android:background="@color/conversation_user_messages_background" android:background="@drawable/fragment_conversation_message_currentuser_bg"
android:padding="5dp" android:padding="5dp"
android:paddingEnd="15dp" android:paddingEnd="15dp"
android:paddingStart="15dp" android:paddingStart="15dp"

View File

@ -12,6 +12,6 @@
<!-- Conversation messages --> <!-- Conversation messages -->
<color name="conversation_user_messages_background">#3F51B5</color> <color name="conversation_user_messages_background">#3F51B5</color>
<color name="conversation_user_messages_textColor">#FFFFFF</color> <color name="conversation_user_messages_textColor">#FFFFFF</color>
<color name="conversation_otheruser_messages_background">#aaa</color> <color name="conversation_otheruser_messages_background">#D8D8D8</color>
<color name="conversation_otheruser_messages_textColor">#000000</color> <color name="conversation_otheruser_messages_textColor">#000000</color>
</resources> </resources>