Commit 30748b91 authored by aniket's avatar aniket

makes suggested changes

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