diff --git a/android/app/src/main/java/com/chatman/BotFragment.java b/android/app/src/main/java/com/chatman/BotFragment.java index 335c477001b5261012790647e55fe892a18eef8d..00361eb6d7388774e8cc70d9bd58f8588d5f7433 100644 --- a/android/app/src/main/java/com/chatman/BotFragment.java +++ b/android/app/src/main/java/com/chatman/BotFragment.java @@ -4,12 +4,32 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.app.Fragment; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.Button; -import android.widget.TextView; + +import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.Toast; + +import com.chatman.adapter.ChatAdapter; +import com.chatman.adapter.ChatListAdapter; +import com.chatman.helper.FirebaseHelper; +import com.chatman.helper.PreferencesHelper; +import com.chatman.model.Chat; +import com.chatman.model.User; +import com.google.firebase.database.DataSnapshot; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.ValueEventListener; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; /** @@ -23,6 +43,13 @@ import android.widget.TextView; public class BotFragment extends Fragment { private OnFragmentInteractionListener mListener; + private ImageButton sentButton; + private EditText message; + private Context context; + private RecyclerView recycler; + private ChatAdapter adapter; + private List<Chat> chatList; + private static final String BOT_KEY = "BOT_KEY"; public BotFragment() { // Required empty public constructor @@ -37,17 +64,77 @@ public class BotFragment extends Fragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + context = getContext(); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_bot, container, false); + + sentButton = view.findViewById(R.id.chat_bot_room_send); + message = view.findViewById(R.id.chat_bot_room_et); + + sentButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (!message.getText().toString().equals("")){ + Toast.makeText(context, "Send: "+message.getText().toString(), Toast.LENGTH_SHORT).show(); + Chat sendMessage = new Chat(PreferencesHelper.getUserFirebaseKey(context), PreferencesHelper.getUserName(context), BOT_KEY, Calendar.getInstance().getTime(), message.getText().toString()); + String key = FirebaseHelper.dbMessage.push().getKey(); + FirebaseHelper.dbMessage.child(key).setValue(sendMessage); + + // BALASAN DARI BOT + Chat botMessage = new Chat(BOT_KEY, "ChatMan Bot", PreferencesHelper.getUserFirebaseKey(context), Calendar.getInstance().getTime(), "Halo! Selamat datang di ChatMan"); + String botKey = FirebaseHelper.dbMessage.push().getKey(); + FirebaseHelper.dbMessage.child(botKey).setValue(botMessage); + + } + } + }); + // Inflate the layout for this fragment return view; } + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + + // Recycler View + recycler = view.findViewById(R.id.chat_bot_room_rv); + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity()); + linearLayoutManager.setReverseLayout(false); + linearLayoutManager.setStackFromEnd(false); + recycler.setLayoutManager(linearLayoutManager); + adapter = new ChatAdapter(chatList); + recycler.setAdapter(adapter); + + + FirebaseHelper.dbMessage.addValueEventListener(new ValueEventListener() { + @Override + public void onDataChange(@NonNull DataSnapshot dataSnapshot) { + getAllChat(dataSnapshot); + adapter.notifyDataSetChanged(); + } + + @Override + public void onCancelled(@NonNull DatabaseError databaseError) { + + } + }); + } + + private void getAllChat(DataSnapshot dataSnapshot) { + chatList = new ArrayList<>(); + for (DataSnapshot ds : dataSnapshot.getChildren()) { + if (ds.getValue(Chat.class).getIdSender().equals(PreferencesHelper.getUserFirebaseKey(context)) || ds.getValue(Chat.class).getIdReceiver().equals(PreferencesHelper.getUserFirebaseKey(context))) { + chatList.add(ds.getValue(Chat.class)); + } + } + adapter = new ChatAdapter(chatList); + recycler.setAdapter(adapter); + } + public void onButtonPressed(Uri uri) { if (mListener != null) { mListener.onFragmentInteraction(uri); @@ -86,4 +173,6 @@ public class BotFragment extends Fragment { void onFragmentInteraction(Uri uri); } + + } diff --git a/android/app/src/main/java/com/chatman/HomeFragment.java b/android/app/src/main/java/com/chatman/HomeFragment.java index 3eeacaa808afc82741dbea66d720ed539a4508e1..9a773b70643c288146a1ecdd3636c79978e770d9 100644 --- a/android/app/src/main/java/com/chatman/HomeFragment.java +++ b/android/app/src/main/java/com/chatman/HomeFragment.java @@ -117,52 +117,52 @@ public class HomeFragment extends Fragment { )); chatLists.add(new ChatList( R.drawable.priagung, - "Priagung Satyagama", + "Priagung Satyagama2", "Woi sini ke sekre 2 temani diriku yang kesepian" )); chatLists.add(new ChatList( R.drawable.rama, - "Yusuf Rahmat Pratama", + "Yusuf Rahmat Pratama2", "Eh, gmn gmn?" )); chatLists.add(new ChatList( R.drawable.priagung, - "Priagung Satyagama", + "Priagung Satyagama3", "Woi sini ke sekre 2 temani diriku yang kesepian" )); chatLists.add(new ChatList( R.drawable.rama, - "Yusuf Rahmat Pratama", + "Yusuf Rahmat Pratama3", "Eh, gmn gmn?" )); chatLists.add(new ChatList( R.drawable.priagung, - "Priagung Satyagama", + "Priagung Satyagama4", "Woi sini ke sekre 2 temani diriku yang kesepian" )); chatLists.add(new ChatList( R.drawable.rama, - "Yusuf Rahmat Pratama", + "Yusuf Rahmat Pratama4", "Eh, gmn gmn?" )); chatLists.add(new ChatList( R.drawable.priagung, - "Priagung Satyagama", + "Priagung Satyagama5", "Woi sini ke sekre 2 temani diriku yang kesepian" )); chatLists.add(new ChatList( R.drawable.rama, - "Yusuf Rahmat Pratama", + "Yusuf Rahmat Pratama5", "Eh, gmn gmn?" )); chatLists.add(new ChatList( R.drawable.priagung, - "Priagung Satyagama", + "Priagung Satyagama6", "Woi sini ke sekre 2 temani diriku yang kesepian" )); chatLists.add(new ChatList( R.drawable.rama, - "Yusuf Rahmat Pratama", + "Yusuf Rahmat Pratama6", "Eh, gmn gmn?" )); return chatLists; diff --git a/android/app/src/main/java/com/chatman/adapter/ChatAdapter.java b/android/app/src/main/java/com/chatman/adapter/ChatAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..478b325f5a64e11a620afd559fdfb5b1f43d70da --- /dev/null +++ b/android/app/src/main/java/com/chatman/adapter/ChatAdapter.java @@ -0,0 +1,166 @@ +package com.chatman.adapter; + + +import android.content.Context; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + + +import com.bumptech.glide.Glide; +import com.chatman.R; +import com.chatman.helper.PreferencesHelper; +import com.chatman.model.Chat; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + + +public class ChatAdapter extends RecyclerView.Adapter { + + private static final int VIEW_TYPE_MESSAGE_SENT = 1; + private static final int VIEW_TYPE_MESSAGE_RECEIVED = 2; + + private List<Chat> items = new ArrayList<>(); + private int itemLayoutSent = R.layout.item_message_sent; + private int itemLayoutReceived = R.layout.item_message_received; + private Context context; + private String currentUser; + + public ChatAdapter(List<Chat> items) { + this.items = items; + } + +// @Override +// public SentMessageHolder onCreateViewHolder(ViewGroup parent, int viewType) { +// return new SentMessageHolder(LayoutInflater.from(parent.getContext()).inflate(itemLayoutSent, parent, false)); +// } + +// @Override +// public void onBindViewHolder(SentMessageHolder holder, int position) { +// holder.bind(items.get(position)); +// } + + public void addItems(List<Chat> items) { + this.items.addAll(items); + notifyDataSetChanged(); + } + + @Override + public int getItemCount() { + if (items == null) { + return 0; + } + return items.size(); + } + + // Determines the appropriate ViewType according to the sender of the message. + @Override + public int getItemViewType(int position) { + Chat message = (Chat) items.get(position); + + if (message.getIdSender().equals(currentUser)) { + // If the current user is the sender of the message + return VIEW_TYPE_MESSAGE_SENT; + } else { + // If some other user sent the message + return VIEW_TYPE_MESSAGE_RECEIVED; + } + } + + // Inflates the appropriate layout according to the ViewType. + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + context = parent.getContext(); + currentUser = PreferencesHelper.getUserFirebaseKey(context); + View view; + + if (viewType == VIEW_TYPE_MESSAGE_SENT) { + view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.item_message_sent, parent, false); + return new SentMessageHolder(view); + } else if (viewType == VIEW_TYPE_MESSAGE_RECEIVED) { + view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.item_message_received, parent, false); + return new ReceivedMessageHolder(view); + } + + return null; + } + + // Passes the message object to a ViewHolder so that the contents can be bound to UI. + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + Chat message = (Chat) items.get(position); + + switch (holder.getItemViewType()) { + case VIEW_TYPE_MESSAGE_SENT: + ((SentMessageHolder) holder).bind(message); + break; + case VIEW_TYPE_MESSAGE_RECEIVED: + ((ReceivedMessageHolder) holder).bind(message); + } + } + + private class SentMessageHolder extends RecyclerView.ViewHolder { + private TextView messageText; + private TextView timeText; + + SentMessageHolder(View itemView) { + super(itemView); + messageText = (TextView) itemView.findViewById(R.id.sent_text_message_body); + timeText = (TextView) itemView.findViewById(R.id.sent_text_message_time); + } + + void bind(Chat message) { + messageText.setText(message.getMessage()); + + // Format the stored timestamp into a readable String using method. + DateFormat dateFormat = new SimpleDateFormat("HH:mm"); + String strDate = dateFormat.format(message.getDate()); + timeText.setText(strDate); + } + } + + private class ReceivedMessageHolder extends RecyclerView.ViewHolder { + private TextView messageText, timeText, nameText; + private ImageView profileImage; + + ReceivedMessageHolder(View itemView) { + super(itemView); + + messageText = (TextView) itemView.findViewById(R.id.received_text_message_body); + timeText = (TextView) itemView.findViewById(R.id.received_text_message_time); + nameText = (TextView) itemView.findViewById(R.id.received_text_message_name); + profileImage = (ImageView) itemView.findViewById(R.id.received_image_message_profile); + } + + void bind(Chat message) { + messageText.setText(message.getMessage()); + + // Format the stored timestamp into a readable String using method. + DateFormat dateFormat = new SimpleDateFormat("HH:mm"); + String strDate = dateFormat.format(message.getDate()); + timeText.setText(strDate); + + nameText.setText(message.getNameSender()); + + // Insert the profile image from the URL into the ImageView. + Glide.with(itemView).load(R.drawable.robotic).into(profileImage); + } + + } + +// public int getImage(String imageName) { +// +// int drawableResourceId = context.getResources().getIdentifier(imageName, "drawable", context.getPackageName()); +// +// return drawableResourceId; +// } +} \ No newline at end of file diff --git a/android/app/src/main/java/com/chatman/adapter/ChatListAdapter.java b/android/app/src/main/java/com/chatman/adapter/ChatListAdapter.java index f04453210c52173db2c8ca69d8cf6047f503490a..eb590217d11d469e6b6441a66171973a7b400535 100644 --- a/android/app/src/main/java/com/chatman/adapter/ChatListAdapter.java +++ b/android/app/src/main/java/com/chatman/adapter/ChatListAdapter.java @@ -2,6 +2,7 @@ package com.chatman.adapter; import android.app.AlertDialog; +import android.content.Context; import android.content.DialogInterface; import android.support.v4.app.Fragment; import android.support.v7.app.AppCompatActivity; @@ -10,7 +11,9 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.RelativeLayout; import android.widget.TextView; +import android.widget.Toast; import com.bumptech.glide.Glide; @@ -28,6 +31,7 @@ public class ChatListAdapter extends RecyclerView.Adapter<ChatListAdapter.ChatLi private List<ChatList> items = new ArrayList<>(); private int itemLayout = R.layout.item_chat_list; + private Context context; public ChatListAdapter(List<ChatList> items) { this.items = items; @@ -35,12 +39,20 @@ public class ChatListAdapter extends RecyclerView.Adapter<ChatListAdapter.ChatLi @Override public ChatListHolder onCreateViewHolder(ViewGroup parent, int viewType) { + context = parent.getContext(); return new ChatListHolder(LayoutInflater.from(parent.getContext()).inflate(itemLayout, parent, false)); } @Override public void onBindViewHolder(ChatListHolder holder, int position) { holder.bind(items.get(position)); + final String nama = holder.chatListName.getText().toString(); + holder.chatListBackground.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Toast.makeText(context, "Show "+nama+" chat room", Toast.LENGTH_SHORT).show(); + } + }); } public void addItems(List<ChatList> items) { @@ -56,8 +68,8 @@ public class ChatListAdapter extends RecyclerView.Adapter<ChatListAdapter.ChatLi return items.size(); } - public class ChatListHolder extends RecyclerView.ViewHolder implements View.OnClickListener { - + public class ChatListHolder extends RecyclerView.ViewHolder { + private RelativeLayout chatListBackground; private TextView chatListName; private TextView chatListLastMessage; private ImageView chatListImage; @@ -71,6 +83,7 @@ public class ChatListAdapter extends RecyclerView.Adapter<ChatListAdapter.ChatLi chatListImage = itemView.findViewById(R.id.chat_list_avatar); chatListLastMessage = itemView.findViewById(R.id.chat_list_last_message); chatListName = itemView.findViewById(R.id.chat_list_name); + chatListBackground = itemView.findViewById(R.id.chat_list_rl); } public void bind(ChatList item) { @@ -79,23 +92,5 @@ public class ChatListAdapter extends RecyclerView.Adapter<ChatListAdapter.ChatLi chatListName.setText(item.getName()); } - @Override - public void onClick(View view) { -// AppCompatActivity activity = (AppCompatActivity) view.getContext(); -// Fragment myFragment = new MyFragment(); -// activity.getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, myFragment).addToBackStack(null).commit(); - } - -// public boolean loadFragment(Fragment fragment) { -// switching fragment -// if (fragment != null) { -// ((MainActivity) getActivity())getSupportFragmentManager() -// .beginTransaction() -// .replace(R.id.fragment_container, fragment) -// .commit(); -// return true; -// } -// return false; -// } } } \ No newline at end of file diff --git a/android/app/src/main/java/com/chatman/helper/FirebaseHelper.java b/android/app/src/main/java/com/chatman/helper/FirebaseHelper.java index 8e7905a489eb06d2255c33b78592fa447c947b21..005c3faac65686d2aaebcd1b26fa6b81ba10a3b6 100644 --- a/android/app/src/main/java/com/chatman/helper/FirebaseHelper.java +++ b/android/app/src/main/java/com/chatman/helper/FirebaseHelper.java @@ -6,8 +6,10 @@ import com.google.firebase.database.FirebaseDatabase; public class FirebaseHelper { private static final String DB_USER = "user"; + private static final String DB_MESSAGE = "message"; public static String USER_KEY, USER_EMAIL, USER_NAMA, USER_PASSWORD; private static DatabaseReference reference = FirebaseDatabase.getInstance().getReference(); public static final DatabaseReference dbUser = reference.child(DB_USER); + public static final DatabaseReference dbMessage = reference.child(DB_MESSAGE); } diff --git a/android/app/src/main/java/com/chatman/model/Chat.java b/android/app/src/main/java/com/chatman/model/Chat.java index ecb083b637e0c916d08f94dacd4da6f051359ae8..d01bc267e9a3bf0b1c9d46be1d646d830f30ad2d 100644 --- a/android/app/src/main/java/com/chatman/model/Chat.java +++ b/android/app/src/main/java/com/chatman/model/Chat.java @@ -4,12 +4,17 @@ import java.util.Date; public class Chat { private String idSender; + private String nameSender; private String idReceiver; private Date date; private String message; - public Chat(String idSender, String idReceiver, Date date, String message) { + public Chat() { + } + + public Chat(String idSender, String nameSender, String idReceiver, Date date, String message) { this.idSender = idSender; + this.nameSender = nameSender; this.idReceiver = idReceiver; this.date = date; this.message = message; @@ -23,6 +28,14 @@ public class Chat { this.idSender = idSender; } + public String getNameSender() { + return nameSender; + } + + public void setNameSender(String nameSender) { + this.nameSender = nameSender; + } + public String getIdReceiver() { return idReceiver; } diff --git a/android/app/src/main/java/com/chatman/model/ChatList.java b/android/app/src/main/java/com/chatman/model/ChatList.java index 49536ab97e576853276143a20bc7cba9cfdc14ba..4d9e40a6a1c70abd8480fd6fbf41f6e9c634df04 100644 --- a/android/app/src/main/java/com/chatman/model/ChatList.java +++ b/android/app/src/main/java/com/chatman/model/ChatList.java @@ -6,6 +6,8 @@ public class ChatList { private String lastMessage; // Todo : tambahin atribut KEY atau apalah supaya ntar waktu ditekan, ke fragmentnya bisa dipass KEY itu terus data di dalam fragmentnya diambil berdasarkan KEY tersebut + public ChatList() { + } public ChatList(int avatarResource, String name, String lastMessage) { this.avatarResource = avatarResource; diff --git a/android/app/src/main/java/com/chatman/model/ChatRoom.java b/android/app/src/main/java/com/chatman/model/ChatRoom.java index fb68f0348b25f2ca90f60dca2c8ec2781a2c1e22..8bc59850cbf9651132d438a82953ab67af9a8584 100644 --- a/android/app/src/main/java/com/chatman/model/ChatRoom.java +++ b/android/app/src/main/java/com/chatman/model/ChatRoom.java @@ -6,6 +6,9 @@ public class ChatRoom { private String idSender; private List<Chat> messages; + public ChatRoom() { + } + public ChatRoom(String idSender, List<Chat> messages) { this.idSender = idSender; this.messages = messages; diff --git a/android/app/src/main/res/drawable/my_custom_selector.xml b/android/app/src/main/res/drawable/my_custom_selector.xml new file mode 100644 index 0000000000000000000000000000000000000000..fb9a45081ad4ccc27ea56eae55cf20c007c888d1 --- /dev/null +++ b/android/app/src/main/res/drawable/my_custom_selector.xml @@ -0,0 +1,19 @@ +<selector + xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:drawable="@drawable/right_arrow_clicked" + android:state_focused="true" + android:state_pressed="true"/> + <item + android:drawable="@drawable/right_arrow_clicked" + android:state_focused="false" + android:state_pressed="true"/> + <item + android:drawable="@drawable/right_arrow_idle" + android:state_focused="true" + android:state_pressed="false"/> + <item + android:drawable="@drawable/right_arrow_idle" + android:state_focused="false" + android:state_pressed="false"/> +</selector> \ No newline at end of file diff --git a/android/app/src/main/res/drawable/right_arrow_clicked.png b/android/app/src/main/res/drawable/right_arrow_clicked.png new file mode 100644 index 0000000000000000000000000000000000000000..b6c90cfe73e4697610432c7eea6bc3033cc2b61b Binary files /dev/null and b/android/app/src/main/res/drawable/right_arrow_clicked.png differ diff --git a/android/app/src/main/res/drawable/right_arrow_idle.png b/android/app/src/main/res/drawable/right_arrow_idle.png new file mode 100644 index 0000000000000000000000000000000000000000..8fcb4a462a013e1a1f054c1b99b280e4edbbee2b Binary files /dev/null and b/android/app/src/main/res/drawable/right_arrow_idle.png differ diff --git a/android/app/src/main/res/drawable/rounded_rectangle_green.xml b/android/app/src/main/res/drawable/rounded_rectangle_green.xml new file mode 100644 index 0000000000000000000000000000000000000000..134effe53af91a24dc1ea6c5d89635d99b04e1d1 --- /dev/null +++ b/android/app/src/main/res/drawable/rounded_rectangle_green.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + + <!-- View background color --> + <solid + android:color="@color/colorAccent" > + </solid> + + <!-- The radius makes the corners rounded --> + <corners + android:radius="20dp"> + </corners> +</shape> + diff --git a/android/app/src/main/res/drawable/rounded_rectangle_orange.xml b/android/app/src/main/res/drawable/rounded_rectangle_orange.xml new file mode 100644 index 0000000000000000000000000000000000000000..ef340ba09d065934882b2678c1af55c287e398c6 --- /dev/null +++ b/android/app/src/main/res/drawable/rounded_rectangle_orange.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + + <!-- View background color --> + <solid + android:color="#FF6E00" > + </solid> + + <!-- The radius makes the corners rounded --> + <corners + android:radius="20dp"> + </corners> +</shape> + diff --git a/android/app/src/main/res/drawable/send.png b/android/app/src/main/res/drawable/send.png new file mode 100644 index 0000000000000000000000000000000000000000..32a338e01b3f19ff86d8d91c5f05ca2d90a8ce8b Binary files /dev/null and b/android/app/src/main/res/drawable/send.png differ diff --git a/android/app/src/main/res/layout/fragment_bot.xml b/android/app/src/main/res/layout/fragment_bot.xml index abf2be519d08e0c5dd395d865bd67daa4b3646ad..cc353d20993ca1bb0a125141b0ab740ef08a97ca 100644 --- a/android/app/src/main/res/layout/fragment_bot.xml +++ b/android/app/src/main/res/layout/fragment_bot.xml @@ -1,21 +1,62 @@ <?xml version="1.0" encoding="utf-8"?> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto" tools:context=".BotFragment"> - <!-- TODO: Update blank fragment layout --> - <TextView - android:id="@+id/tv_hello" + <android.support.v7.widget.RecyclerView + android:id="@+id/chat_bot_room_rv" android:layout_width="match_parent" - android:layout_height="match_parent" - android:text="Bot fragment" /> + android:layout_height="wrap_content" + android:layout_marginBottom="56dp" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent"> + + </android.support.v7.widget.RecyclerView> - <Button - android:id="@+id/btn" - android:layout_width="wrap_content" + <android.support.constraint.ConstraintLayout + android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="tombol"/> + android:minHeight="56dp" + app:layout_constraintBottom_toBottomOf="parent" + android:orientation="horizontal"> + + <EditText + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintRight_toLeftOf="@id/chat_bot_room_send" + android:id="@+id/chat_bot_room_et" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:minHeight="56dp" + + android:layout_weight="9" + android:hint="@string/message" + android:inputType="textCapSentences|textMultiLine" + android:maxLines ="4" + android:maxLength ="2000" + android:scrollHorizontally="false"/> + + + <ImageButton + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintRight_toRightOf="parent" + android:id="@+id/chat_bot_room_send" + android:layout_width="36dp" + android:layout_height="36dp" + android:scaleType="fitCenter" + android:clickable="true" + android:focusable="true" + android:background="@drawable/my_custom_selector" + android:contentDescription="@string/send_message_button" + android:layout_marginBottom="10dp" + android:layout_marginRight="10dp" /> + + + </android.support.constraint.ConstraintLayout> -</FrameLayout> \ No newline at end of file +</android.support.constraint.ConstraintLayout> diff --git a/android/app/src/main/res/layout/item_chat_list.xml b/android/app/src/main/res/layout/item_chat_list.xml index f314d555a8d57ddf9b04e69d6a2768448d291bb4..0cc2a6f7e4a6c52f4b76eb59bcfabeffe652f4da 100644 --- a/android/app/src/main/res/layout/item_chat_list.xml +++ b/android/app/src/main/res/layout/item_chat_list.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <RelativeLayout + android:id="@+id/chat_list_rl" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" diff --git a/android/app/src/main/res/layout/item_message_received.xml b/android/app/src/main/res/layout/item_message_received.xml new file mode 100644 index 0000000000000000000000000000000000000000..4d830f9978dc2d35f44d5024d4edef0e3be374f6 --- /dev/null +++ b/android/app/src/main/res/layout/item_message_received.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> + +<android.support.constraint.ConstraintLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="8dp"> + + <de.hdodenhof.circleimageview.CircleImageView + android:id="@+id/received_image_message_profile" + android:layout_width="32dp" + android:layout_height="32dp" + app:layout_constraintTop_toTopOf="parent" + android:layout_marginStart="8dp" + app:layout_constraintLeft_toLeftOf="parent" /> + + <TextView + android:id="@+id/received_text_message_name" + android:text="John Doe" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="12sp" + app:layout_constraintLeft_toRightOf="@+id/received_image_message_profile" + android:layout_marginStart="8dp" + app:layout_constraintTop_toTopOf="parent" + android:layout_marginTop="4dp" /> + + <TextView + android:id="@+id/received_text_message_body" + android:text="hi man, how are you?" + android:background="@drawable/rounded_rectangle_orange" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:maxWidth="240dp" + android:padding="8dp" + android:textColor="#ffffff" + android:layout_marginTop="4dp" + app:layout_constraintTop_toBottomOf="@+id/received_text_message_name" + app:layout_constraintLeft_toRightOf="@+id/received_image_message_profile" + android:layout_marginStart="8dp" /> + + <TextView + android:id="@+id/received_text_message_time" + android:text="11:40" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="10sp" + app:layout_constraintLeft_toRightOf="@+id/received_text_message_body" + android:layout_marginStart="4dp" + app:layout_constraintBottom_toBottomOf="@+id/received_text_message_body" /> + +</android.support.constraint.ConstraintLayout> \ No newline at end of file diff --git a/android/app/src/main/res/layout/item_message_sent.xml b/android/app/src/main/res/layout/item_message_sent.xml new file mode 100644 index 0000000000000000000000000000000000000000..92fc7a2aac591a96b2c7c634af6132b8f8dbd332 --- /dev/null +++ b/android/app/src/main/res/layout/item_message_sent.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<android.support.constraint.ConstraintLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="8dp"> + + <TextView + android:id="@+id/sent_text_message_body" + android:text="hello, hello!" + android:background="@drawable/rounded_rectangle_green" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:maxWidth="240dp" + android:padding="8dp" + android:textColor="#ffffff" + android:layout_marginEnd="8dp" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <TextView + android:id="@+id/sent_text_message_time" + android:text="11:40" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="10sp" + android:layout_marginEnd="4dp" + app:layout_constraintBottom_toBottomOf="@+id/sent_text_message_body" + app:layout_constraintRight_toLeftOf="@+id/sent_text_message_body" /> + +</android.support.constraint.ConstraintLayout> \ No newline at end of file diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 7109671efb656a17b380c2ca0a1471693d65f8e6..0e30d9f2789748a58706a044462dc9a4f799eab2 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -41,5 +41,8 @@ <string name="notification_updated">Notification Updated!</string> <string name="notification_channel_name">Mascot Notification</string> + + <string name="send_message_button">Send message button</string> + <string name="message">Message</string> </resources>