Skip to content

Commit

Permalink
improving the chat section
Browse files Browse the repository at this point in the history
  • Loading branch information
YassineBOUJNAH committed Jun 3, 2020
1 parent 52cdfed commit caa297b
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@ public MessageAdapter(@NonNull FirestoreRecyclerOptions<Message> options) {

@Override
protected void onBindViewHolder(@NonNull MessageHolder holder, int position, @NonNull Message model) {
holder.text.setText(model.getMessage());
if(model.getUserSender().compareTo(getCurrentUser().getEmail()+"") != 0){
holder.text.setBackgroundColor(0xC0C0C0);
CoordinatorLayout.LayoutParams lllp= (CoordinatorLayout.LayoutParams) holder.text.getLayoutParams();
lllp.gravity= Gravity.LEFT;
holder.text.setLayoutParams(lllp);
//holder.text.setTextSize(20);
//holder.text.setBackgroundColor(0xC0C0C0);
// CoordinatorLayout.LayoutParams lllp= (CoordinatorLayout.LayoutParams) holder.text.getLayoutParams();
// lllp.gravity= Gravity.LEFT;
//holder.text.setLayoutParams(lllp);
//holder.text.setBackground(holder.text.getContext().getResources().getDrawable(R.drawable.rounded_message2));
holder.text2.setText(model.getMessage());
holder.text2.setPadding(35,35,35,35);
}
else {
holder.text.setText(model.getMessage());
holder.text.setPadding(35,35,35,35);
}

}
Expand All @@ -44,11 +51,12 @@ public MessageHolder onCreateViewHolder(ViewGroup parent, int viewType) {
class MessageHolder extends RecyclerView.ViewHolder{

TextView text;
TextView text2;

public MessageHolder(View itemView){
super(itemView);
text = itemView.findViewById(R.id.message_item_text);

text2 = itemView.findViewById(R.id.message_item_text2);
}
}

Expand Down
18 changes: 18 additions & 0 deletions app/src/main/res/drawable/rounded_message.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="https://schemas.android.com/apk/res/android" >
<stroke
android:width="1dp"
android:color="#22BE87" />
<solid android:color="#22BE87" />

<padding
android:left="1dp"
android:right="1dp"
android:bottom="1dp"
android:top="1dp" />

<corners android:topLeftRadius="15dp"
android:topRightRadius="15dp"
android:bottomLeftRadius="15dp"
android:bottomRightRadius="3dp"/>
</shape>
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/rounded_message2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="https://schemas.android.com/apk/res/android" >
<stroke
android:width="1dp"
android:color="#EAEDED" />
<solid android:color="#EAEDED" />

<padding
android:left="1dp"
android:right="1dp"
android:bottom="1dp"
android:top="1dp" />

<corners android:topLeftRadius="15dp"
android:topRightRadius="15dp"
android:bottomLeftRadius="3dp"
android:bottomRightRadius="15dp"/>

</shape>
7 changes: 7 additions & 0 deletions app/src/main/res/font/courgette.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="https://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="Courgette"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>
20 changes: 18 additions & 2 deletions app/src/main/res/layout/activity_chat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="https://schemas.android.com/apk/res-auto"
tools:context=".DoctorHomeActivity">
tools:context=".DoctorHomeActivity"
android:background="#FFFFFF">


<!-- RECYCLER VIEW CONTAINER -->
<LinearLayout
Expand All @@ -14,6 +16,20 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_above="@id/activity_mentor_chat_add_message_container">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#22BEA9">
<TextView
android:layout_marginTop="8dp"
android:layout_marginLeft="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="30dp"
android:fontFamily="@font/courgette"
android:textColor="#FFFFFF"
android:text="Messages" />
</LinearLayout>
<!-- RECYCLER VIEW -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/activity_mentor_chat_recycler_view"
Expand All @@ -33,7 +49,7 @@
<!-- TEXT MESSAGE EDIT TEXT -->
<com.google.android.material.textfield.TextInputLayout
android:layout_width="300dp"
android:layout_height="36dp">
android:layout_height="55dp">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/activity_mentor_chat_message_edit_text"
Expand Down
32 changes: 26 additions & 6 deletions app/src/main/res/layout/message_chat_item.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="https://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content">
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="https://schemas.android.com/apk/res-auto"
xmlns:card_view="https://schemas.android.com/tools"
app:cardBackgroundColor="#FFFFFF"
card_view:cardPreventCornerOverlap="false"
app:cardElevation="0dp">

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_margin="5px"
card_view:cardPreventCornerOverlap="false">

<TextView
android:id="@+id/message_item_text"
android:layout_width="wrap_content"
android:maxWidth="200dp"
android:layout_height="wrap_content"
android:text="message"
android:text=""
android:layout_gravity="right"
android:background="#4267B2"
android:textSize="25dp"
android:padding="10dp"
android:fontFamily="@font/courgette"
android:background="@drawable/rounded_message"
android:textSize="18dp"
android:shadowRadius="@android:integer/config_shortAnimTime"/>

<TextView
android:id="@+id/message_item_text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:background="@drawable/rounded_message2"
android:fontFamily="@font/roboto"
android:maxWidth="200dp"
android:shadowRadius="@android:integer/config_shortAnimTime"
android:text=""
android:textSize="18dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.cardview.widget.CardView>
1 change: 1 addition & 0 deletions app/src/main/res/values/preloaded_fonts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<resources>
<array name="preloaded_fonts" translatable="false">
<item>@font/amita</item>
<item>@font/courgette</item>
</array>
</resources>

0 comments on commit caa297b

Please sign in to comment.