Skip to content
This repository was archived by the owner on Jun 7, 2020. It is now read-only.

Commit 5a87ffa

Browse files
authored
Merge branch 'develop' into new_1055
2 parents dcbc8ee + e9ed8e2 commit 5a87ffa

File tree

18 files changed

+220
-117
lines changed

18 files changed

+220
-117
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Bug report
3+
about: Create a bug report to help us improve
4+
5+
---
6+
7+
## Describe the bug
8+
<!-- A clear and concise description of what the bug is. -->
9+
10+
## To Reproduce
11+
<!--Steps to reproduce the behavior:
12+
1. Go to '...'
13+
2. Click on '....'
14+
3. Scroll down to '....'
15+
4. See error -->
16+
17+
## Expected behavior
18+
<!-- A clear and concise description of what you expected to happen. -->
19+
20+
## Logs
21+
<!-- Please add logs in case of any crash or applicable error. -->
22+
23+
## Screenshots
24+
<!-- If applicable, add screenshots to help explain your problem. -->
25+
26+
## Devices and Versions
27+
28+
<!-- Version can be found by opening the side menu and then clicking on "Settings" and then "About" -->
29+
Your Rocket.Chat.Android version: (e.g. 2.1.0)
30+
Your Rocket.Chat Server version: (e.g. 0.63.1-develop)
31+
32+
<!-- Found a bug? List all devices that reproduced it and all that doesn't -->
33+
Mobile device model and OS version: (e.g. "Nexus 7 - Android 6.0.1")
34+
35+
## Additional context
36+
<!-- Add any other context about the problem here. -->
37+

.github/ISSUE_TEMPLATE/chore.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Chore
3+
about: Issues related to docs, workflow, dependency and others
4+
5+
---
6+
7+
## Describe the chore
8+
<!-- A clear and concise description of what you want to do. -->
9+
10+
## Devices and Versions
11+
12+
<!-- Version can be found by opening the side menu and then clicking on "Settings" and then "About" -->
13+
Your Rocket.Chat.Android version: (e.g. 2.1.0)
14+
Your Rocket.Chat Server version: (e.g. 0.63.1-develop)
15+
16+
<!-- Found a bug? List all devices that reproduced it and all that doesn't -->
17+
Mobile device model and OS version: (e.g. "Nexus 7 - Android 6.0.1")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
5+
---
6+
7+
## Describe the feature you'd like
8+
<!-- A clear and concise description of what you want to happen. -->
9+
10+
## Devices and Versions
11+
12+
<!-- Version can be found by opening the side menu and then clicking on "Settings" and then "About" -->
13+
Your Rocket.Chat.Android version: (e.g. 2.1.0)
14+
Your Rocket.Chat Server version: (e.g. 0.63.1-develop)
15+
16+
<!-- Found a bug? List all devices that reproduced it and all that doesn't -->
17+
Mobile device model and OS version: (e.g. "Nexus 7 - Android 6.0.1")
18+
19+
## Screenshots
20+
<!-- Add screenshots to provide context or UI mockup. -->
21+
22+
## Additional context
23+
<!-- Add any other context about the problem here. -->
24+

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
<!-- INSTRUCTION: Inform the issue number that this PR closes, or remove the line below -->
55
Closes #ISSUE_NUMBER
66

7-
<!-- INSTRUCTION: Tell us more about your PR with screen shots if you can -->
7+
#### Changes: [Add here what changes were made in this issue and if possible provide links.]
8+
9+
#### Screenshots or GIF for the change:

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ This repository contains all the code related to the Android native application
1414

1515
## How to build
1616

17-
- You need to download the latest [Android Studio Preview](https://developer.android.com/studio/preview/) version since the stable IDE version does not support the [JetPack](https://developer.android.com/jetpack/) that is being used on this application.
1817
- Make sure that you have the latest **gradle** and the **android plugin** versions installed. Go to `File > Project Structure > Project` and make sure that you have the latest versions installed. Refer [this](https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle) to see the compatible versions.
1918
- Kotlin is already configured in the project. To check, go to `Tools > Kotlin > Configure Kotlin in project`. A message saying kotlin is already configured in the project pops up. You can update kotlin to the latest version by going to `Tools > Kotlin > Configure Kotlin updates` and download the latest version of kotlin.
2019

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ android {
1616
applicationId "chat.rocket.android"
1717
minSdkVersion versions.minSdk
1818
targetSdkVersion versions.targetSdk
19-
versionCode 2054
19+
versionCode 2055
2020
versionName "3.2.0"
2121
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2222
multiDexEnabled true

app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ class ChatRoomPresenter @Inject constructor(
317317
launchUI(strategy) {
318318
try {
319319
// ignore message for now, will receive it on the stream
320-
val id = UUID.randomUUID().toString()
321320
if (messageId == null) {
321+
val id = UUID.randomUUID().toString()
322322
val username = userHelper.username()
323323
val newMessage = Message(
324324
id = id,
@@ -371,13 +371,12 @@ class ChatRoomPresenter @Inject constructor(
371371
} else {
372372
client.updateMessage(chatRoomId, messageId, text)
373373
}
374-
375-
clearUnfinishedMessage()
376-
view.enableSendMessageButton()
374+
clearDraftMessage()
377375
} catch (ex: Exception) {
378-
Timber.d(ex, "Error sending message...")
376+
Timber.e(ex, "Error sending message...")
379377
jobSchedulerInteractor.scheduleSendingMessages()
380378
} finally {
379+
view.clearMessageComposition(true)
381380
view.enableSendMessageButton()
382381
}
383382
}
@@ -1265,10 +1264,9 @@ class ChatRoomPresenter @Inject constructor(
12651264
launchUI(strategy) {
12661265
val viewModelStreamedMessage = mapper.map(
12671266
streamedMessage, RoomUiModel(
1268-
roles = chatRoles, isBroadcast = chatIsBroadcast, isRoom = true
1269-
)
1267+
roles = chatRoles, isBroadcast = chatIsBroadcast, isRoom = true
1268+
)
12701269
)
1271-
12721270
val roomMessages = messagesRepository.getByRoomId(streamedMessage.roomId)
12731271
val index = roomMessages.indexOfFirst { msg -> msg.id == streamedMessage.id }
12741272
if (index > -1) {
@@ -1294,13 +1292,13 @@ class ChatRoomPresenter @Inject constructor(
12941292
*
12951293
* @param unfinishedMessage The unfinished message to save.
12961294
*/
1297-
fun saveUnfinishedMessage(unfinishedMessage: String) {
1295+
fun saveDraftMessage(unfinishedMessage: String) {
12981296
if (unfinishedMessage.isNotBlank()) {
12991297
localRepository.save(draftKey, unfinishedMessage)
13001298
}
13011299
}
13021300

1303-
fun clearUnfinishedMessage() {
1301+
fun clearDraftMessage() {
13041302
localRepository.clear(draftKey)
13051303
}
13061304
/**
@@ -1309,7 +1307,7 @@ class ChatRoomPresenter @Inject constructor(
13091307
*
13101308
* @return Returns the unfinished message, null otherwise.
13111309
*/
1312-
fun getUnfinishedMessage(): String? {
1310+
fun getDraftUnfinishedMessage(): String? {
13131311
return localRepository.get(draftKey)
13141312
}
13151313
}

app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import android.content.ClipData
66
import android.content.ClipboardManager
77
import android.content.Context
88
import android.content.Intent
9-
import android.content.res.Configuration
109
import android.graphics.drawable.Drawable
1110
import android.net.Uri
1211
import android.os.Bundle
@@ -308,7 +307,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
308307
showToolbarTitle(chatRoomName)
309308
showToolbarChatRoomIcon(chatRoomType)
310309
}
311-
getUnfinishedMessage()
310+
getDraftMessage()
312311

313312
analyticsManager.logScreenView(ScreenViewEvent.ChatRoom)
314313
}
@@ -323,7 +322,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
323322
recycler_view.removeOnScrollListener(onScrollListener)
324323
recycler_view.removeOnLayoutChangeListener(layoutChangeListener)
325324

326-
presenter.saveUnfinishedMessage(text_message.text.toString())
325+
presenter.saveDraftMessage(text_message.text.toString())
327326
handler.removeCallbacksAndMessages(null)
328327
unsubscribeComposeTextMessage()
329328
presenter.disconnect()
@@ -437,6 +436,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
437436
}
438437
presenter.loadActiveMembers(chatRoomId, chatRoomType, filterSelfOut = true)
439438
empty_chat_view.isVisible = adapter.itemCount == 0
439+
dismissEmojiKeyboard()
440440
}
441441
}
442442

@@ -445,6 +445,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
445445
adapter.clearData()
446446
adapter.prependData(dataSet)
447447
empty_chat_view.isVisible = adapter.itemCount == 0
448+
dismissEmojiKeyboard()
448449
}
449450

450451
override fun onRoomUpdated(roomUiModel: RoomUiModel) {
@@ -502,25 +503,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
502503
showMessage(getString(R.string.msg_invalid_file))
503504
}
504505

505-
override fun showNewMessage(message: List<BaseUiModel<*>>, isMessageReceived: Boolean) {
506-
ui {
507-
adapter.prependData(message)
508-
if (isMessageReceived && button_fab.isVisible) {
509-
newMessageCount++
510-
511-
if (newMessageCount <= 99)
512-
text_count.text = newMessageCount.toString()
513-
else
514-
text_count.text = "99+"
515-
516-
text_count.isVisible = true
517-
} else if (!button_fab.isVisible)
518-
recycler_view.scrollToPosition(0)
519-
verticalScrollOffset.set(0)
520-
empty_chat_view.isVisible = adapter.itemCount == 0
521-
}
522-
}
523-
524506
override fun disableSendMessageButton() {
525507
ui { button_send.isEnabled = false }
526508
}
@@ -544,6 +526,28 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
544526
}
545527
}
546528

529+
override fun showNewMessage(message: List<BaseUiModel<*>>, isMessageReceived: Boolean) {
530+
ui {
531+
adapter.prependData(message)
532+
if (isMessageReceived && button_fab.isVisible) {
533+
newMessageCount++
534+
if (newMessageCount <= 99) {
535+
text_count.text = newMessageCount.toString()
536+
} else {
537+
text_count.text = "99+"
538+
}
539+
text_count.isVisible = true
540+
}
541+
542+
else if (!button_fab.isVisible) {
543+
recycler_view.scrollToPosition(0)
544+
}
545+
verticalScrollOffset.set(0)
546+
empty_chat_view.isVisible = adapter.itemCount == 0
547+
dismissEmojiKeyboard()
548+
}
549+
}
550+
547551
override fun dispatchUpdateMessage(index: Int, message: List<BaseUiModel<*>>) {
548552
ui {
549553
// TODO - investigate WHY we get a empty list here
@@ -556,6 +560,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
556560
} else {
557561
showNewMessage(message, true)
558562
}
563+
dismissEmojiKeyboard()
559564
}
560565
}
561566

@@ -723,8 +728,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
723728
}
724729

725730
private fun setReactionButtonIcon(@DrawableRes drawableId: Int) {
726-
button_add_reaction.setImageResource(drawableId)
727-
button_add_reaction.tag = drawableId
731+
button_add_reaction_or_show_keyboard.setImageResource(drawableId)
732+
button_add_reaction_or_show_keyboard.tag = drawableId
728733
}
729734

730735
override fun showFileSelection(filter: Array<String>?) {
@@ -841,9 +846,13 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
841846

842847
subscribeComposeTextMessage()
843848
emojiKeyboardPopup = EmojiKeyboardPopup(activity!!, activity!!.findViewById(R.id.fragment_container))
849+
844850
emojiKeyboardPopup.listener = this
851+
845852
text_message.listener = object : ComposerEditText.ComposerEditTextListener {
846-
override fun onKeyboardOpened() {}
853+
override fun onKeyboardOpened() {
854+
KeyboardHelper.showSoftKeyboard(text_message)
855+
}
847856

848857
override fun onKeyboardClosed() {
849858
activity?.let {
@@ -860,7 +869,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
860869
var textMessage = citation ?: ""
861870
textMessage += text_message.textContent
862871
sendMessage(textMessage)
863-
clearMessageComposition(true)
864872
}
865873

866874
button_show_attachment_options.setOnClickListener {
@@ -875,9 +883,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
875883
hideAttachmentOptions()
876884
}
877885

878-
button_add_reaction.setOnClickListener { _ ->
879-
openEmojiKeyboardPopup()
880-
}
886+
button_add_reaction_or_show_keyboard.setOnClickListener { toggleKeyboard() }
881887

882888
button_take_a_photo.setOnClickListener {
883889
dispatchTakePictureIntent()
@@ -934,8 +940,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
934940
}
935941
}
936942

937-
private fun getUnfinishedMessage() {
938-
val unfinishedMessage = presenter.getUnfinishedMessage()
943+
private fun getDraftMessage() {
944+
val unfinishedMessage = presenter.getDraftUnfinishedMessage()
939945
if (unfinishedMessage.isNotNullNorEmpty()) {
940946
text_message.setText(unfinishedMessage)
941947
}
@@ -969,19 +975,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
969975
presenter.loadCommands()
970976
}
971977

972-
private fun openEmojiKeyboardPopup() {
978+
// Shows the emoji or the system keyboard.
979+
private fun toggleKeyboard() {
973980
if (!emojiKeyboardPopup.isShowing) {
974-
// If keyboard is visible, simply show the popup
975-
if (emojiKeyboardPopup.isKeyboardOpen) {
976-
emojiKeyboardPopup.showAtBottom()
977-
} else {
978-
// Open the text keyboard first and immediately after that show the emoji popup
979-
text_message.isFocusableInTouchMode = true
980-
text_message.requestFocus()
981-
emojiKeyboardPopup.showAtBottomPending()
982-
KeyboardHelper.showSoftKeyboard(text_message)
983-
}
984-
setReactionButtonIcon(R.drawable.ic_keyboard_black_24dp)
981+
openEmojiKeyboard()
985982
} else {
986983
// If popup is showing, simply dismiss it to show the underlying text keyboard
987984
dismissEmojiKeyboard()
@@ -1149,6 +1146,20 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
11491146
description = "This message was reported by a user from the Android app")
11501147
}
11511148

1149+
fun openEmojiKeyboard() {
1150+
// If keyboard is visible, simply show the popup
1151+
if (emojiKeyboardPopup.isKeyboardOpen) {
1152+
emojiKeyboardPopup.showAtBottom()
1153+
} else {
1154+
// Open the text keyboard first and immediately after that show the emoji popup
1155+
text_message.isFocusableInTouchMode = true
1156+
text_message.requestFocus()
1157+
emojiKeyboardPopup.showAtBottomPending()
1158+
KeyboardHelper.showSoftKeyboard(text_message)
1159+
}
1160+
setReactionButtonIcon(R.drawable.ic_keyboard_black_24dp)
1161+
}
1162+
11521163
fun dismissEmojiKeyboard() {
11531164
// Check if the keyboard was ever initialized.
11541165
// It may be the case when you are looking a not joined room

app/src/main/res/drawable/ic_keyboard_black_24dp.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@
77

88
<path
99
android:fillColor="#000000"
10-
android:pathData="M20,5 L4,5 C2.9,5,2.01,5.9,2.01,7 L2,17 C2,18.1,2.9,19,4,19 L20,19
11-
C21.1,19,22,18.1,22,17 L22,7 C22,5.9,21.1,5,20,5 Z M11,8 L13,8 L13,10 L11,10
12-
L11,8 Z M11,11 L13,11 L13,13 L11,13 L11,11 Z M8,8 L10,8 L10,10 L8,10 L8,8 Z
13-
M8,11 L10,11 L10,13 L8,13 L8,11 Z M7,13 L5,13 L5,11 L7,11 L7,13 Z M7,10 L5,10
14-
L5,8 L7,8 L7,10 Z M16,17 L8,17 L8,15 L16,15 L16,17 Z M16,13 L14,13 L14,11 L16,11
15-
L16,13 Z M16,10 L14,10 L14,8 L16,8 L16,10 Z M19,13 L17,13 L17,11 L19,11 L19,13 Z
16-
M19,10 L17,10 L17,8 L19,8 L19,10 Z" />
17-
<path
18-
android:pathData="M0,0 L24,0 L24,24 L0,24 Z M-24,0 L0,0 L0,24 L0,24 Z" />
10+
android:pathData="M20,5 L4,5 C2.9,5,2.01,5.9,2.01,7 L2,17 C2,18.1,2.9,19,4,19 L20,19 C21.1,19,22,18.1,22,17 L22,7 C22,5.9,21.1,5,20,5 Z M11,8 L13,8 L13,10 L11,10 L11,8 Z M11,11 L13,11 L13,13 L11,13 L11,11 Z M8,8 L10,8 L10,10 L8,10 L8,8 Z M8,11 L10,11 L10,13 L8,13 L8,11 Z M7,13 L5,13 L5,11 L7,11 L7,13 Z M7,10 L5,10 L5,8 L7,8 L7,10 Z M16,17 L8,17 L8,15 L16,15 L16,17 Z M16,13 L14,13 L14,11 L16,11 L16,13 Z M16,10 L14,10 L14,8 L16,8 L16,10 Z M19,13 L17,13 L17,11 L19,11 L19,13 Z M19,10 L17,10 L17,8 L19,8 L19,10 Z" />
11+
12+
<path android:pathData="M0,0 L24,0 L24,24 L0,24 Z M-24,0 L0,0 L0,24 L0,24 Z" />
1913
</vector>

0 commit comments

Comments
 (0)