mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 15:05:44 +03:00
Merge pull request #2053 from nextcloud/feature/7331/silentSend
add silent send option
This commit is contained in:
commit
ec9e5b4b23
7 changed files with 105 additions and 7 deletions
|
@ -338,7 +338,8 @@ public interface NcApi {
|
|||
@Url String url,
|
||||
@Field("message") CharSequence message,
|
||||
@Field("actorDisplayName") String actorDisplayName,
|
||||
@Field("replyTo") Integer replyTo);
|
||||
@Field("replyTo") Integer replyTo,
|
||||
@Field("silent") Boolean sendWithoutNotification);
|
||||
|
||||
@GET
|
||||
Observable<Response<ChatShareOverall>> getSharedItems(@Header("Authorization") String authorization, @Url String url,
|
||||
|
|
|
@ -57,6 +57,7 @@ import android.text.TextUtils
|
|||
import android.text.TextWatcher
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
|
@ -68,8 +69,10 @@ import android.view.animation.LinearInterpolator
|
|||
import android.widget.AbsListView
|
||||
import android.widget.ImageButton
|
||||
import android.widget.ImageView
|
||||
import android.widget.PopupMenu
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.view.ContextThemeWrapper
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.content.PermissionChecker
|
||||
|
@ -835,7 +838,14 @@ class ChatController(args: Bundle) :
|
|||
activity?.let { AttachmentDialog(it, this).show() }
|
||||
}
|
||||
|
||||
binding.messageInputView.button.setOnClickListener { v -> submitMessage() }
|
||||
binding.messageInputView.button.setOnClickListener { submitMessage(false) }
|
||||
|
||||
if (CapabilitiesUtil.hasSpreedFeatureCapability(conversationUser, "silent-send")) {
|
||||
binding.messageInputView.button.setOnLongClickListener {
|
||||
showSendButtonMenu()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
binding.messageInputView.button.contentDescription = resources?.getString(
|
||||
R.string
|
||||
|
@ -858,6 +868,27 @@ class ChatController(args: Bundle) :
|
|||
super.onViewBound(view)
|
||||
}
|
||||
|
||||
private fun showSendButtonMenu() {
|
||||
val popupMenu = PopupMenu(
|
||||
ContextThemeWrapper(view?.context, R.style.ChatSendButtonMenu),
|
||||
binding.messageInputView.button,
|
||||
Gravity.END
|
||||
)
|
||||
popupMenu.inflate(R.menu.chat_send_menu)
|
||||
|
||||
popupMenu.setOnMenuItemClickListener { item: MenuItem ->
|
||||
when (item.itemId) {
|
||||
R.id.send_without_notification -> submitMessage(true)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
popupMenu.setForceShowIcon(true)
|
||||
}
|
||||
popupMenu.show()
|
||||
}
|
||||
|
||||
private fun startPlayback(message: ChatMessage) {
|
||||
|
||||
if (!this.isAttached) {
|
||||
|
@ -1879,7 +1910,7 @@ class ChatController(args: Bundle) :
|
|||
})
|
||||
}
|
||||
|
||||
private fun submitMessage() {
|
||||
private fun submitMessage(sendWithoutNotification: Boolean) {
|
||||
if (binding.messageInputView.inputEditText != null) {
|
||||
val editable = binding.messageInputView.inputEditText!!.editableText
|
||||
val mentionSpans = editable.getSpans(
|
||||
|
@ -1904,13 +1935,14 @@ class ChatController(args: Bundle) :
|
|||
view
|
||||
?.findViewById<RelativeLayout>(R.id.quotedChatMessageView)
|
||||
?.visibility == View.VISIBLE
|
||||
) replyMessageId else null
|
||||
) replyMessageId else null,
|
||||
sendWithoutNotification
|
||||
)
|
||||
cancelReply()
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendMessage(message: CharSequence, replyTo: Int?) {
|
||||
private fun sendMessage(message: CharSequence, replyTo: Int?, sendWithoutNotification: Boolean) {
|
||||
|
||||
if (conversationUser != null) {
|
||||
val apiVersion = ApiUtils.getChatApiVersion(conversationUser, intArrayOf(1))
|
||||
|
@ -1920,7 +1952,8 @@ class ChatController(args: Bundle) :
|
|||
ApiUtils.getUrlForChat(apiVersion, conversationUser.baseUrl, roomToken),
|
||||
message,
|
||||
conversationUser.displayName,
|
||||
replyTo
|
||||
replyTo,
|
||||
sendWithoutNotification
|
||||
)
|
||||
?.subscribeOn(Schedulers.io())
|
||||
?.observeOn(AndroidSchedulers.mainThread())
|
||||
|
|
|
@ -90,7 +90,7 @@ class DirectReplyReceiver : BroadcastReceiver() {
|
|||
val apiVersion = ApiUtils.getChatApiVersion(currentUser, intArrayOf(1))
|
||||
val url = ApiUtils.getUrlForChat(apiVersion, currentUser.baseUrl, roomToken)
|
||||
|
||||
ncApi!!.sendChatMessage(credentials, url, replyMessage, currentUser.displayName, null)
|
||||
ncApi!!.sendChatMessage(credentials, url, replyMessage, currentUser.displayName, null, false)
|
||||
?.subscribeOn(Schedulers.io())
|
||||
?.observeOn(AndroidSchedulers.mainThread())
|
||||
?.subscribe(object : Observer<GenericOverall> {
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<!--
|
||||
@author Google LLC
|
||||
Copyright (C) 2021 Google LLC
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20,18.69L7.84,6.14 5.27,3.49 4,4.76l2.8,2.8v0.01c-0.52,0.99 -0.8,2.16 -0.8,3.42v5l-2,2v1h13.73l2,2L21,19.72l-1,-1.03zM12,22c1.11,0 2,-0.89 2,-2h-4c0,1.11 0.89,2 2,2zM18,14.68L18,11c0,-3.08 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68c-0.15,0.03 -0.29,0.08 -0.42,0.12 -0.1,0.03 -0.2,0.07 -0.3,0.11h-0.01c-0.01,0 -0.01,0 -0.02,0.01 -0.23,0.09 -0.46,0.2 -0.68,0.31 0,0 -0.01,0 -0.01,0.01L18,14.68z"/>
|
||||
</vector>
|
26
app/src/main/res/menu/chat_send_menu.xml
Normal file
26
app/src/main/res/menu/chat_send_menu.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Nextcloud Talk application
|
||||
~
|
||||
~ @author Marcel Hibbe
|
||||
~ Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/send_without_notification"
|
||||
android:icon="@drawable/ic_baseline_notifications_off_24"
|
||||
android:title="@string/send_without_notification" />
|
||||
</menu>
|
|
@ -519,5 +519,6 @@
|
|||
<string name="title_attachments">Attachments</string>
|
||||
|
||||
<string name="reactions_tab_all">All</string>
|
||||
<string name="send_without_notification">Send without notification</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
<item name="android:seekBarStyle">@style/Nextcloud.Material.Incoming.SeekBar</item>
|
||||
<item name="seekBarStyle">@style/Nextcloud.Material.Incoming.SeekBar</item>
|
||||
<item name="bottomSheetDialogTheme">@style/ThemeOverlay.App.BottomSheetDialog</item>
|
||||
<item name="popupMenuStyle">@style/ChatSendButtonMenu</item>
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.AppTheme.PopupMenu" parent="ThemeOverlay.MaterialComponents.Dark">
|
||||
|
@ -52,6 +53,16 @@
|
|||
<item name="iconTint">@color/fontAppbar</item>
|
||||
</style>
|
||||
|
||||
<style name="ChatSendButtonMenu" parent="@style/Widget.AppCompat.PopupMenu">
|
||||
<item name="android:dropDownVerticalOffset">-90dp</item>
|
||||
<item name="android:colorPrimary">@color/fg_inverse</item>
|
||||
<item name="android:textColorSecondary">@color/fontAppbar</item>
|
||||
<item name="android:itemBackground">@color/appbar</item>
|
||||
<item name="android:background">@color/appbar</item>
|
||||
<item name="android:textColor">@color/high_emphasis_text</item>
|
||||
<item name="iconTint">@color/fontAppbar</item>
|
||||
</style>
|
||||
|
||||
<style name="BottomNavigationView" parent="@style/Widget.MaterialComponents.BottomNavigationView">
|
||||
<item name="elevation">1dp</item>
|
||||
</style>
|
||||
|
|
Loading…
Reference in a new issue