Commit 30748b91 authored by aniket's avatar aniket

makes suggested changes

parent 9a820a67
......@@ -57,6 +57,7 @@ dependencies {
implementation libraries.kotlin
implementation libraries.coroutines
implementation libraries.coroutinesAndroid
implementation libraries.appCompat
implementation libraries.recyclerview
implementation libraries.design
......@@ -64,6 +65,7 @@ dependencies {
implementation libraries.cardView
implementation libraries.flexbox
implementation libraries.customTabs
implementation libraries.supportv4
implementation libraries.androidKtx
......
......@@ -532,8 +532,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override fun onNonEmojiKeyPressed(keyCode: Int) {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> with(text_message) {
if (selectionStart > 0) text!!.delete(selectionStart - 1, selectionStart)
KeyEvent.KEYCODE_BACK -> {
if (text_message.selectionStart > 0) text_message.text!!.delete(text_message.selectionStart - 1, text_message.selectionStart)
}
else -> throw IllegalArgumentException("pressed key not expected")
}
......
......@@ -80,7 +80,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
setupToolbar()
setupRecyclerView()
setUpFAB()
setupFab()
presenter.loadChatRooms()
}
......@@ -289,7 +289,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
sectionedAdapter?.setSections(sections.toArray(dummy))
}
private fun setUpFAB() {
private fun setupFab() {
create_new_channel_fab.setOnClickListener {
val intent = Intent(activity, CreateNewChannelActivity::class.java)
startActivity(intent)
......
......@@ -7,6 +7,7 @@ import chat.rocket.android.members.viewmodel.MemberViewModel
interface AddMembersView : LoadingView, MessageView {
/**
* Show members on the basis of query
*
* @param dataSet The list of members
* @param total The number of members returned
*/
......
......@@ -10,6 +10,7 @@ import android.support.v7.widget.RecyclerView
import android.view.MenuItem
import android.widget.EditText
import android.widget.Toast
import androidx.core.view.isVisible
import chat.rocket.android.R
import chat.rocket.android.createChannel.addMembers.presentation.AddMembersPresenter
import chat.rocket.android.createChannel.addMembers.presentation.AddMembersView
......@@ -43,8 +44,7 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
updateToolBar()
search_view.setText("")
} else {
Toast.makeText(this, getString(R.string.msg_member_already_added), Toast.LENGTH_LONG)
.show()
showMessage(getString(R.string.msg_member_already_added))
}
}
private lateinit var observableForSearchView: Disposable
......@@ -59,11 +59,15 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
setUpRecyclerView()
setOnClickListeners()
setInitialChips()
}
override fun onStart() {
super.onStart()
setUpObservableForSearchView()
}
override fun onDestroy() {
super.onDestroy()
override fun onStop() {
super.onStop()
//dispose off the rx disposables
observableForToolbarAction.dispose()
observableForSearchView.dispose()
......@@ -102,11 +106,11 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
}
override fun showLoading() {
progress_bar.setVisible(true)
view_loading.isVisible = true
}
override fun hideLoading() {
progress_bar.setVisible(false)
view_loading.isVisible = false
}
override fun showMessage(resId: Int) {
......
......@@ -11,7 +11,6 @@ import chat.rocket.core.RocketChatClient
import chat.rocket.core.internal.rest.createChannel
import javax.inject.Inject
class CreateNewChannelPresenter @Inject constructor(
private val view: CreateNewChannelView,
private val strategy: CancelStrategy,
......
......@@ -3,20 +3,28 @@ package chat.rocket.android.createChannel.presentation
import chat.rocket.android.core.behaviours.LoadingView
interface CreateNewChannelView : LoadingView {
/*
Show a message that a channel was successfully created
/**
* Show a message that a channel was successfully created
*/
fun showChannelCreatedSuccessfullyMessage()
/*
Show message and clear text in edit text
/**
* Show message and clear text in edit text
*
* @param resId Resource id of the message to be shown
*/
fun showMessageAndClearText(resId: Int)
/**
* Show message and clear text in edit text
*
* @param message Toast message to be shown
*/
fun showMessageAndClearText(message: String)
/*
Show error message
/**
* Show error message
*/
fun showErrorMessage()
......
......@@ -7,6 +7,7 @@ import android.os.Bundle
import android.support.design.chip.Chip
import android.support.v7.app.AppCompatActivity
import android.view.MenuItem
import androidx.core.view.isVisible
import chat.rocket.android.R
import chat.rocket.android.createChannel.addMembers.ui.AddMembersActivity
import chat.rocket.android.createChannel.presentation.CreateNewChannelPresenter
......@@ -38,8 +39,13 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
setUpOnClickListeners()
}
override fun onDestroy() {
super.onDestroy()
override fun onStart() {
super.onStart()
setUpToolbarObservable()
}
override fun onStop() {
super.onStop()
observableForToolbarAction.dispose()
}
......@@ -66,13 +72,13 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
}
override fun showLoading() {
view_loading.setVisible(true)
view_loading.isVisible = true
layout_container.alpha = 0.5f
layout_container.isEnabled = false
}
override fun hideLoading() {
view_loading.setVisible(false)
view_loading.isVisible = false
layout_container.alpha = 1.0f
layout_container.isEnabled = true
}
......@@ -96,7 +102,6 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
showMessageAndClearText(getString(R.string.msg_generic_error))
}
private fun refreshMembersChips() {
for (element in listOfUsers) {
val memberChip = Chip(this)
......@@ -114,6 +119,9 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
toolbar_action_text.text = getString(R.string.action_create_new_channel)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
private fun setUpToolbarObservable(){
observableForToolbarAction =
RxTextView.textChanges(channel_name_edit_text).subscribe { text ->
toolbar_action_text.isEnabled = (text.isNotEmpty() && listOfUsers.isNotEmpty())
......
......@@ -33,7 +33,7 @@
</android.support.design.chip.ChipGroup>
<com.wang.avi.AVLoadingIndicatorView
android:id="@+id/progress_bar"
android:id="@+id/view_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
......
......@@ -56,7 +56,7 @@ ext {
cardView : "com.android.support:cardview-v7:${versions.support}",
flexbox : "com.google.android:flexbox:${versions.flexbox}",
customTabs : "com.android.support:customtabs:${versions.support}",
supportv4 : "com.android.support:support-v4:${versions.support}",
androidKtx : "androidx.core:core-ktx:${versions.androidKtx}",
dagger : "com.google.dagger:dagger:${versions.dagger}",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment