From 740d29f8fb8f55469fef655508df4b982ac21731 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Fri, 29 Mar 2019 20:40:35 +0400 Subject: [PATCH] ChatActivity UI fixes --- .../influence/views/ChatActivity.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/github/chronosx88/influence/views/ChatActivity.java b/app/src/main/java/io/github/chronosx88/influence/views/ChatActivity.java index 66e19be..26c2674 100644 --- a/app/src/main/java/io/github/chronosx88/influence/views/ChatActivity.java +++ b/app/src/main/java/io/github/chronosx88/influence/views/ChatActivity.java @@ -2,6 +2,7 @@ package io.github.chronosx88.influence.views; import android.content.Intent; import android.os.Bundle; +import android.view.MenuItem; import android.widget.EditText; import android.widget.ImageButton; import android.widget.TextView; @@ -35,9 +36,11 @@ public class ChatActivity extends AppCompatActivity implements IChatViewContract Intent intent = getIntent(); presenter = new ChatPresenter(this, intent.getStringExtra("chatID")); - Toolbar toolbar = findViewById(R.id.toolbar_chat_activity); setSupportActionBar(toolbar); + getSupportActionBar().setTitle(""); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); messageList = findViewById(R.id.message_list); chatAdapter = new ChatAdapter(); presenter.updateAdapter(); @@ -48,10 +51,11 @@ public class ChatActivity extends AppCompatActivity implements IChatViewContract sendMessageButton = findViewById(R.id.send_button); sendMessageButton.setOnClickListener((v) -> { presenter.sendMessage(messageTextEdit.getText().toString()); + messageTextEdit.setText(""); + messageList.scrollToPosition(chatAdapter.getItemCount()-1); }); contactUsernameTextView.setText(intent.getStringExtra("contactUsername")); - - + messageList.scrollToPosition(chatAdapter.getItemCount()-1); } @Override @@ -69,4 +73,14 @@ public class ChatActivity extends AppCompatActivity implements IChatViewContract chatAdapter.notifyDataSetChanged(); }); } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch(item.getItemId()) { + case android.R.id.home: + finish(); + return true; + } + return super.onOptionsItemSelected(item); + } }