Send message also if device is not connected.
This commit is contained in:
parent
7d29fa9be9
commit
85a235d35a
3 changed files with 3 additions and 13 deletions
|
@ -112,6 +112,4 @@
|
|||
<!-- Notification text for incoming message -->
|
||||
<string name="notification_message">New message!</string>
|
||||
|
||||
<string name="toast_user_not_connected">User is not connected. Cannot send message.</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -109,9 +109,8 @@ class ChatFragment extends ListFragment with OnClickListener {
|
|||
val text = messageText.getText.toString.trim
|
||||
if (!text.isEmpty) {
|
||||
val message = new Text(text.toString)
|
||||
val success = chatService.sendTo(address, message)
|
||||
if (success)
|
||||
messageText.getText.clear()
|
||||
chatService.sendTo(address, message)
|
||||
messageText.getText.clear()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.preference.PreferenceManager
|
|||
import android.support.v4.app.NotificationCompat
|
||||
import android.support.v4.content.LocalBroadcastManager
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import com.nutomic.ensichat.R
|
||||
import com.nutomic.ensichat.activities.MainActivity
|
||||
import com.nutomic.ensichat.bluetooth.BluetoothInterface
|
||||
|
@ -119,12 +118,7 @@ class ChatService extends Service {
|
|||
/**
|
||||
* Sends a new message to the given target address.
|
||||
*/
|
||||
def sendTo(target: Address, body: MessageBody): Boolean = {
|
||||
if (!btInterface.getConnections.contains(target)) {
|
||||
Toast.makeText(this, R.string.toast_user_not_connected, Toast.LENGTH_SHORT).show()
|
||||
return false
|
||||
}
|
||||
|
||||
def sendTo(target: Address, body: MessageBody): Unit = {
|
||||
Future {
|
||||
val messageId = preferences.getLong("message_id", 0)
|
||||
val header = new ContentHeader(crypto.localAddress, target, seqNumGenerator.next(),
|
||||
|
@ -136,7 +130,6 @@ class ChatService extends Service {
|
|||
router.onReceive(encrypted)
|
||||
onNewMessage(msg)
|
||||
}.onFailure {case e => throw e}
|
||||
true
|
||||
}
|
||||
|
||||
private def sendVia(nextHop: Address, msg: Message) =
|
||||
|
|
Reference in a new issue