From 5b3874e2cfae09355b0f67543f667b25491b4f8d Mon Sep 17 00:00:00 2001
From: priagungs <priagungsatyagama@gmail.com>
Date: Sun, 24 Feb 2019 15:34:30 +0700
Subject: [PATCH] initialized detail chatroom activity and modified some
 margins

---
 android/app/src/main/AndroidManifest.xml      | 15 ++-
 .../chatman/activity/ChatRoomActivity.java    | 72 ++++++++++++++
 .../com/chatman/activity/MainActivity.java    | 15 +++
 .../com/chatman/adapter/ChatListAdapter.java  |  7 ++
 .../main/res/layout/activity_chat_room.xml    | 99 +++++++++++++++++++
 .../app/src/main/res/layout/fragment_bot.xml  | 35 ++++---
 6 files changed, 219 insertions(+), 24 deletions(-)
 create mode 100644 android/app/src/main/java/com/chatman/activity/ChatRoomActivity.java
 create mode 100644 android/app/src/main/res/layout/activity_chat_room.xml

diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index f646c85..f722392 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -9,18 +9,17 @@
         android:roundIcon="@mipmap/chatman_launcher_round"
         android:supportsRtl="true"
         android:theme="@style/AppTheme">
-        <!-- <service -->
-        <!-- android:name=".service.PushNotificationService" -->
-        <!-- android:enabled="true" -->
-        <!-- android:exported="true"/> -->
+        <activity android:name=".activity.ChatRoomActivity"
+            android:label="@string/app_name"
+            android:theme="@style/AppTheme.NoActionBar"></activity>
+
         <!--
  Set custom default icon. This is used when no icon is set for incoming notification messages.
      See README(https://goo.gl/l4GJaQ) for more.
         -->
-         <meta-data
-         android:name="com.google.firebase.messaging.default_notification_icon"
-         android:resource="@mipmap/chatman_launcher_round" />
-        <!-- &lt;!&ndash; Set color used with incoming notification messages. This is used when no color is set for the incoming -->
+        <meta-data
+            android:name="com.google.firebase.messaging.default_notification_icon"
+            android:resource="@mipmap/chatman_launcher_round" /> <!-- &lt;!&ndash; Set color used with incoming notification messages. This is used when no color is set for the incoming -->
         <!-- notification message. See README(https://goo.gl/6BKBk7) for more. &ndash;&gt; -->
         <!-- <meta-data -->
         <!-- android:name="com.google.firebase.messaging.default_notification_color" -->
diff --git a/android/app/src/main/java/com/chatman/activity/ChatRoomActivity.java b/android/app/src/main/java/com/chatman/activity/ChatRoomActivity.java
new file mode 100644
index 0000000..86babf7
--- /dev/null
+++ b/android/app/src/main/java/com/chatman/activity/ChatRoomActivity.java
@@ -0,0 +1,72 @@
+package com.chatman.activity;
+
+import android.content.Intent;
+import android.os.Build;
+import android.support.v4.content.ContextCompat;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.Toolbar;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.TextView;
+
+import com.chatman.R;
+
+public class ChatRoomActivity extends AppCompatActivity {
+
+    private Toolbar toolbar;
+    private RecyclerView chatRv;
+    private EditText chatEt;
+    private ImageButton chatSend;
+    private TextView toolbarName;
+
+    private String chatRoomId;
+
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_chat_room);
+
+        toolbar = findViewById(R.id.toolbar);
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
+                getWindow().setStatusBarColor(ContextCompat
+                        .getColor(this, android.R.color.black));
+            }
+            else {
+                getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+                getWindow().setStatusBarColor(ContextCompat
+                        .getColor(this, R.color.white));
+            }
+
+        }
+        setSupportActionBar(toolbar);
+        this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+        chatRv = findViewById(R.id.chat_rv);
+        chatEt = findViewById(R.id.chat_et);
+        chatSend = findViewById(R.id.chat_send);
+        toolbarName = findViewById(R.id.toolbar_name);
+        if (savedInstanceState != null) {
+
+        }
+        else {
+            Intent intent = getIntent();
+            toolbarName.setText(intent.getStringExtra("name"));
+            chatRoomId = intent.getStringExtra("chatRoomId");
+        }
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        switch (item.getItemId()) {
+            case android.R.id.home:
+                this.finish();
+                return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+}
diff --git a/android/app/src/main/java/com/chatman/activity/MainActivity.java b/android/app/src/main/java/com/chatman/activity/MainActivity.java
index 2fa8566..b8e0339 100644
--- a/android/app/src/main/java/com/chatman/activity/MainActivity.java
+++ b/android/app/src/main/java/com/chatman/activity/MainActivity.java
@@ -2,15 +2,18 @@ package com.chatman.activity;
 
 import android.content.Context;
 import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.design.widget.BottomNavigationView;
 import android.support.v4.app.Fragment;
+import android.support.v4.content.ContextCompat;
 import android.support.v4.view.GravityCompat;
 import android.support.v4.widget.DrawerLayout;
 import android.support.v7.app.AppCompatActivity;
 import android.support.v7.widget.Toolbar;
 import android.view.MenuItem;
+import android.view.View;
 import android.widget.ImageView;
 
 import com.bumptech.glide.Glide;
@@ -53,6 +56,18 @@ public class MainActivity extends AppCompatActivity implements
         ImageView toolbarImage = findViewById(R.id.toolbar_image);
         Glide.with(this).load(getImage("logo")).fitCenter().into(toolbarImage);
         setSupportActionBar(toolbar);
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
+                getWindow().setStatusBarColor(ContextCompat
+                        .getColor(this, android.R.color.black));
+            }
+            else {
+                getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+                getWindow().setStatusBarColor(ContextCompat
+                        .getColor(this, R.color.white));
+            }
+
+        }
         context = this;
 
         // Bottom Navigation Bar
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 e9c8349..ba9a0fa 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.content.Context;
+import android.content.Intent;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -14,6 +15,7 @@ import android.widget.Toast;
 
 import com.bumptech.glide.Glide;
 import com.chatman.R;
+import com.chatman.activity.ChatRoomActivity;
 import com.chatman.model.ChatList;
 
 import java.util.ArrayList;
@@ -44,6 +46,11 @@ public class ChatListAdapter extends RecyclerView.Adapter<ChatListAdapter.ChatLi
             @Override
             public void onClick(View view) {
                 String chatRoomId = items.get(position).getIdChatRoom();
+                String name = items.get(position).getName();
+                Intent intent = new Intent(context, ChatRoomActivity.class);
+                intent.putExtra("name", name);
+                intent.putExtra("chatRoomId", chatRoomId);
+                context.startActivity(intent);
                 Toast.makeText(context, "Show "+nama+" chat room", Toast.LENGTH_SHORT).show();
         }
         });
diff --git a/android/app/src/main/res/layout/activity_chat_room.xml b/android/app/src/main/res/layout/activity_chat_room.xml
new file mode 100644
index 0000000..118f966
--- /dev/null
+++ b/android/app/src/main/res/layout/activity_chat_room.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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=".activity.ChatRoomActivity">
+
+    <android.support.v7.widget.Toolbar
+        android:id="@+id/toolbar"
+        android:layout_width="match_parent"
+        android:layout_height="?attr/actionBarSize"
+        android:background="@android:color/white"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:popupTheme="@style/AppTheme.PopupOverlay">
+
+        <android.support.constraint.ConstraintLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:foregroundGravity="center">
+
+            <TextView
+                android:id="@+id/toolbar_name"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="18sp"
+                android:textStyle="bold"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="parent" />
+
+
+        </android.support.constraint.ConstraintLayout>
+
+    </android.support.v7.widget.Toolbar>
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/chat_rv"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="8dp"
+        android:layout_marginBottom="8dp"
+        app:layout_constraintBottom_toTopOf="@+id/constraintLayout"
+        app:layout_constraintHorizontal_bias="0.0"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/toolbar">
+
+    </android.support.v7.widget.RecyclerView>
+
+    <android.support.constraint.ConstraintLayout
+        android:id="@+id/constraintLayout"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:minHeight="56dp"
+        android:orientation="horizontal"
+        app:layout_constraintBottom_toBottomOf="parent">
+
+        <EditText
+            android:id="@+id/chat_et"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="16dp"
+            android:layout_marginRight="16dp"
+            android:layout_marginBottom="8dp"
+            android:layout_weight="9"
+            android:hint="@string/message"
+
+            android:inputType="textCapSentences|textMultiLine"
+            android:maxLength="2000"
+            android:maxLines="4"
+            android:minHeight="56dp"
+            android:scrollHorizontally="false"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintRight_toLeftOf="@id/chat_send"
+            app:layout_constraintTop_toTopOf="parent" />
+
+
+        <ImageButton
+            android:id="@+id/chat_send"
+            android:layout_width="36dp"
+            android:layout_height="36dp"
+            android:layout_marginRight="16dp"
+            android:layout_marginBottom="16dp"
+            android:background="@drawable/my_custom_selector"
+            android:clickable="true"
+            android:contentDescription="@string/send_message_button"
+            android:focusable="true"
+            android:scaleType="fitCenter"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintRight_toRightOf="parent" />
+
+
+    </android.support.constraint.ConstraintLayout>
+
+</android.support.constraint.ConstraintLayout>
\ No newline at end of file
diff --git a/android/app/src/main/res/layout/fragment_bot.xml b/android/app/src/main/res/layout/fragment_bot.xml
index 55402a9..a97fa3a 100644
--- a/android/app/src/main/res/layout/fragment_bot.xml
+++ b/android/app/src/main/res/layout/fragment_bot.xml
@@ -25,36 +25,39 @@
         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_marginLeft="16dp"
+            android:layout_marginRight="16dp"
+            android:layout_marginBottom="8dp"
             android:layout_weight="9"
             android:hint="@string/message"
+
             android:inputType="textCapSentences|textMultiLine"
-            android:maxLines ="4"
-            android:maxLength ="2000"
-            android:scrollHorizontally="false"/>
+            android:maxLength="2000"
+            android:maxLines="4"
+            android:minHeight="56dp"
+            android:scrollHorizontally="false"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintRight_toLeftOf="@id/chat_bot_room_send"
+            app:layout_constraintTop_toTopOf="parent" />
 
 
         <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:layout_marginRight="16dp"
+            android:layout_marginBottom="16dp"
             android:background="@drawable/my_custom_selector"
+            android:clickable="true"
             android:contentDescription="@string/send_message_button"
-            android:layout_marginBottom="10dp"
-            android:layout_marginRight="10dp" />
+            android:focusable="true"
+            android:scaleType="fitCenter"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintRight_toRightOf="parent" />
 
 
     </android.support.constraint.ConstraintLayout>
-- 
GitLab