Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

760 chat sendbutton visual feedback #812

Merged
merged 7 commits into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,21 @@ class ChatFragmentTest : AbstractUITest() {
fragment.prependData(listOf(message))
onView(withText("MESSAGE")).check(ViewAssertions.matches(isDisplayed()))
}

@Test
fun deactivateSendButton() {
launch()
onView(withId(R.id.bt_send)).perform(click())
fragment.adapter.data shouldMatch hasSize(equalTo(0))

}

@Test
fun activateSendButton() {
launch()
onView(withId(R.id.etText)).perform(setText("My Message"))
onView(withId(R.id.bt_send)).perform(click())
fragment.adapter.data shouldMatch hasSize(equalTo(1))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.net.Uri
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -65,6 +66,15 @@ class ChatFragment : ChatView, BaseFragment(), AnkoLogger {

lateinit var emojiPopup: EmojiPopup

val textWatcher = object : TextWatcher {
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
toggleSendButton()
}

override fun afterTextChanged(text: Editable?) {}
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}
}

override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
contactKeyId = arguments.getString(ARG_CONTACT) ?: throw IllegalArgumentException(
Expand Down Expand Up @@ -142,6 +152,8 @@ class ChatFragment : ChatView, BaseFragment(), AnkoLogger {
}

bt_send.onClick { presenter.sendMessage() }
toggleSendButton()
etText.addTextChangedListener(textWatcher)
action_add_contact.setOnClickListener { presenter.handleContactAddClick() }
action_ignore_contact.setOnClickListener { presenter.handleContactIgnoreClick() }
emojiPopup = EmojiPopup.Builder.fromRootView(chat_root)
Expand All @@ -155,6 +167,17 @@ class ChatFragment : ChatView, BaseFragment(), AnkoLogger {
}
}


fun toggleSendButton() {
if (messageText.isBlank()) {
bt_send.isEnabled = false
bt_send.setImageResource(R.drawable.ic_send_grey_24dp)
} else {
bt_send.isEnabled = true
bt_send.setImageResource(R.drawable.ic_send_grey_active_24dp)
}
}

override fun onBackPressed(): Boolean {
if (emojiPopup.isShowing) {
emojiPopup.dismiss()
Expand Down Expand Up @@ -193,7 +216,7 @@ class ChatFragment : ChatView, BaseFragment(), AnkoLogger {
if (swipeRefresh.isEnabled) {
contact_chat_list.addItemDecoration(headerDecor)
}
if(!loadMore){
if (!loadMore) {
scrollToBottom()
}
idle()
Expand Down Expand Up @@ -249,3 +272,4 @@ class ChatFragment : ChatView, BaseFragment(), AnkoLogger {
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#96000000"
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</vector>
2 changes: 1 addition & 1 deletion qabelbox/src/main/res/drawable/ic_send_grey_24dp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#96000000"
android:fillColor="#b3b3b3"
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</vector>
1 change: 1 addition & 0 deletions qabelbox/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<color name="white">#ffffffff</color>
<color name="grey_text_color">#ff555555</color>
<color name="light_gray">#b3b3b3</color>
<color name="dark_gray">#ff555555</color>
<color name="default_text_color">#cc000000</color>
<color name="button_semi_transparent">#09000000</color>
<color name="bg_welcome_semitransparent">#6b3ca0b3</color>
Expand Down