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

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into new_1055
Browse files Browse the repository at this point in the history
shubhsherl authored Jan 3, 2019
2 parents dcbc8ee + e9ed8e2 commit 5a87ffa
Showing 18 changed files with 220 additions and 117 deletions.
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Bug report
about: Create a bug report to help us improve

---

## Describe the bug
<!-- A clear and concise description of what the bug is. -->

## To Reproduce
<!--Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error -->

## Expected behavior
<!-- A clear and concise description of what you expected to happen. -->

## Logs
<!-- Please add logs in case of any crash or applicable error. -->

## Screenshots
<!-- If applicable, add screenshots to help explain your problem. -->

## Devices and Versions

<!-- Version can be found by opening the side menu and then clicking on "Settings" and then "About" -->
Your Rocket.Chat.Android version: (e.g. 2.1.0)
Your Rocket.Chat Server version: (e.g. 0.63.1-develop)

<!-- Found a bug? List all devices that reproduced it and all that doesn't -->
Mobile device model and OS version: (e.g. "Nexus 7 - Android 6.0.1")

## Additional context
<!-- Add any other context about the problem here. -->

17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/chore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Chore
about: Issues related to docs, workflow, dependency and others

---

## Describe the chore
<!-- A clear and concise description of what you want to do. -->

## Devices and Versions

<!-- Version can be found by opening the side menu and then clicking on "Settings" and then "About" -->
Your Rocket.Chat.Android version: (e.g. 2.1.0)
Your Rocket.Chat Server version: (e.g. 0.63.1-develop)

<!-- Found a bug? List all devices that reproduced it and all that doesn't -->
Mobile device model and OS version: (e.g. "Nexus 7 - Android 6.0.1")
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Feature request
about: Suggest an idea for this project

---

## Describe the feature you'd like
<!-- A clear and concise description of what you want to happen. -->

## Devices and Versions

<!-- Version can be found by opening the side menu and then clicking on "Settings" and then "About" -->
Your Rocket.Chat.Android version: (e.g. 2.1.0)
Your Rocket.Chat Server version: (e.g. 0.63.1-develop)

<!-- Found a bug? List all devices that reproduced it and all that doesn't -->
Mobile device model and OS version: (e.g. "Nexus 7 - Android 6.0.1")

## Screenshots
<!-- Add screenshots to provide context or UI mockup. -->

## Additional context
<!-- Add any other context about the problem here. -->

4 changes: 3 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -4,4 +4,6 @@
<!-- INSTRUCTION: Inform the issue number that this PR closes, or remove the line below -->
Closes #ISSUE_NUMBER

<!-- INSTRUCTION: Tell us more about your PR with screen shots if you can -->
#### Changes: [Add here what changes were made in this issue and if possible provide links.]

#### Screenshots or GIF for the change:
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ This repository contains all the code related to the Android native application

## How to build

- 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.
- 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.
- 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.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ android {
applicationId "chat.rocket.android"
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
versionCode 2054
versionCode 2055
versionName "3.2.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
Original file line number Diff line number Diff line change
@@ -317,8 +317,8 @@ class ChatRoomPresenter @Inject constructor(
launchUI(strategy) {
try {
// ignore message for now, will receive it on the stream
val id = UUID.randomUUID().toString()
if (messageId == null) {
val id = UUID.randomUUID().toString()
val username = userHelper.username()
val newMessage = Message(
id = id,
@@ -371,13 +371,12 @@ class ChatRoomPresenter @Inject constructor(
} else {
client.updateMessage(chatRoomId, messageId, text)
}

clearUnfinishedMessage()
view.enableSendMessageButton()
clearDraftMessage()
} catch (ex: Exception) {
Timber.d(ex, "Error sending message...")
Timber.e(ex, "Error sending message...")
jobSchedulerInteractor.scheduleSendingMessages()
} finally {
view.clearMessageComposition(true)
view.enableSendMessageButton()
}
}
@@ -1265,10 +1264,9 @@ class ChatRoomPresenter @Inject constructor(
launchUI(strategy) {
val viewModelStreamedMessage = mapper.map(
streamedMessage, RoomUiModel(
roles = chatRoles, isBroadcast = chatIsBroadcast, isRoom = true
)
roles = chatRoles, isBroadcast = chatIsBroadcast, isRoom = true
)
)

val roomMessages = messagesRepository.getByRoomId(streamedMessage.roomId)
val index = roomMessages.indexOfFirst { msg -> msg.id == streamedMessage.id }
if (index > -1) {
@@ -1294,13 +1292,13 @@ class ChatRoomPresenter @Inject constructor(
*
* @param unfinishedMessage The unfinished message to save.
*/
fun saveUnfinishedMessage(unfinishedMessage: String) {
fun saveDraftMessage(unfinishedMessage: String) {
if (unfinishedMessage.isNotBlank()) {
localRepository.save(draftKey, unfinishedMessage)
}
}

fun clearUnfinishedMessage() {
fun clearDraftMessage() {
localRepository.clear(draftKey)
}
/**
@@ -1309,7 +1307,7 @@ class ChatRoomPresenter @Inject constructor(
*
* @return Returns the unfinished message, null otherwise.
*/
fun getUnfinishedMessage(): String? {
fun getDraftUnfinishedMessage(): String? {
return localRepository.get(draftKey)
}
}
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Bundle
@@ -308,7 +307,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
showToolbarTitle(chatRoomName)
showToolbarChatRoomIcon(chatRoomType)
}
getUnfinishedMessage()
getDraftMessage()

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

presenter.saveUnfinishedMessage(text_message.text.toString())
presenter.saveDraftMessage(text_message.text.toString())
handler.removeCallbacksAndMessages(null)
unsubscribeComposeTextMessage()
presenter.disconnect()
@@ -437,6 +436,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
presenter.loadActiveMembers(chatRoomId, chatRoomType, filterSelfOut = true)
empty_chat_view.isVisible = adapter.itemCount == 0
dismissEmojiKeyboard()
}
}

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

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

override fun showNewMessage(message: List<BaseUiModel<*>>, isMessageReceived: Boolean) {
ui {
adapter.prependData(message)
if (isMessageReceived && button_fab.isVisible) {
newMessageCount++

if (newMessageCount <= 99)
text_count.text = newMessageCount.toString()
else
text_count.text = "99+"

text_count.isVisible = true
} else if (!button_fab.isVisible)
recycler_view.scrollToPosition(0)
verticalScrollOffset.set(0)
empty_chat_view.isVisible = adapter.itemCount == 0
}
}

override fun disableSendMessageButton() {
ui { button_send.isEnabled = false }
}
@@ -544,6 +526,28 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}

override fun showNewMessage(message: List<BaseUiModel<*>>, isMessageReceived: Boolean) {
ui {
adapter.prependData(message)
if (isMessageReceived && button_fab.isVisible) {
newMessageCount++
if (newMessageCount <= 99) {
text_count.text = newMessageCount.toString()
} else {
text_count.text = "99+"
}
text_count.isVisible = true
}

else if (!button_fab.isVisible) {
recycler_view.scrollToPosition(0)
}
verticalScrollOffset.set(0)
empty_chat_view.isVisible = adapter.itemCount == 0
dismissEmojiKeyboard()
}
}

override fun dispatchUpdateMessage(index: Int, message: List<BaseUiModel<*>>) {
ui {
// TODO - investigate WHY we get a empty list here
@@ -556,6 +560,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
} else {
showNewMessage(message, true)
}
dismissEmojiKeyboard()
}
}

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

private fun setReactionButtonIcon(@DrawableRes drawableId: Int) {
button_add_reaction.setImageResource(drawableId)
button_add_reaction.tag = drawableId
button_add_reaction_or_show_keyboard.setImageResource(drawableId)
button_add_reaction_or_show_keyboard.tag = drawableId
}

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

subscribeComposeTextMessage()
emojiKeyboardPopup = EmojiKeyboardPopup(activity!!, activity!!.findViewById(R.id.fragment_container))

emojiKeyboardPopup.listener = this

text_message.listener = object : ComposerEditText.ComposerEditTextListener {
override fun onKeyboardOpened() {}
override fun onKeyboardOpened() {
KeyboardHelper.showSoftKeyboard(text_message)
}

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

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

button_add_reaction.setOnClickListener { _ ->
openEmojiKeyboardPopup()
}
button_add_reaction_or_show_keyboard.setOnClickListener { toggleKeyboard() }

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

private fun getUnfinishedMessage() {
val unfinishedMessage = presenter.getUnfinishedMessage()
private fun getDraftMessage() {
val unfinishedMessage = presenter.getDraftUnfinishedMessage()
if (unfinishedMessage.isNotNullNorEmpty()) {
text_message.setText(unfinishedMessage)
}
@@ -969,19 +975,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
presenter.loadCommands()
}

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

fun openEmojiKeyboard() {
// If keyboard is visible, simply show the popup
if (emojiKeyboardPopup.isKeyboardOpen) {
emojiKeyboardPopup.showAtBottom()
} else {
// Open the text keyboard first and immediately after that show the emoji popup
text_message.isFocusableInTouchMode = true
text_message.requestFocus()
emojiKeyboardPopup.showAtBottomPending()
KeyboardHelper.showSoftKeyboard(text_message)
}
setReactionButtonIcon(R.drawable.ic_keyboard_black_24dp)
}

fun dismissEmojiKeyboard() {
// Check if the keyboard was ever initialized.
// It may be the case when you are looking a not joined room
12 changes: 3 additions & 9 deletions app/src/main/res/drawable/ic_keyboard_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -7,13 +7,7 @@

<path
android:fillColor="#000000"
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" />
<path
android:pathData="M0,0 L24,0 L24,24 L0,24 Z M-24,0 L0,0 L0,24 L0,24 Z" />
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" />

<path android:pathData="M0,0 L24,0 L24,24 L0,24 Z M-24,0 L0,0 L0,24 L0,24 Z" />
</vector>
Loading

0 comments on commit 5a87ffa

Please sign in to comment.