Allow only forwarding of regualr text messages

Also go back directly to the conversation list. Go back history is
reseted.

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2021-07-20 10:46:43 +02:00 committed by Andy Scherzinger
parent b3d0ebf577
commit 00915e56ff
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
2 changed files with 10 additions and 6 deletions

View File

@ -95,6 +95,7 @@ import com.facebook.imagepipeline.image.CloseableImage
import com.google.android.flexbox.FlexboxLayout import com.google.android.flexbox.FlexboxLayout
import com.nextcloud.talk.R import com.nextcloud.talk.R
import com.nextcloud.talk.activities.MagicCallActivity import com.nextcloud.talk.activities.MagicCallActivity
import com.nextcloud.talk.activities.MainActivity
import com.nextcloud.talk.adapters.messages.IncomingLocationMessageViewHolder import com.nextcloud.talk.adapters.messages.IncomingLocationMessageViewHolder
import com.nextcloud.talk.adapters.messages.IncomingPreviewMessageViewHolder import com.nextcloud.talk.adapters.messages.IncomingPreviewMessageViewHolder
import com.nextcloud.talk.adapters.messages.IncomingVoiceMessageViewHolder import com.nextcloud.talk.adapters.messages.IncomingVoiceMessageViewHolder
@ -2061,7 +2062,7 @@ class ChatController(args: Bundle) :
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
android.R.id.home -> { android.R.id.home -> {
router.popCurrentController() (activity as MainActivity).resetConversationsList()
return true return true
} }
R.id.conversation_video_call -> { R.id.conversation_video_call -> {
@ -2168,6 +2169,7 @@ class ChatController(args: Bundle) :
R.id.action_forward_message -> { R.id.action_forward_message -> {
val bundle = Bundle() val bundle = Bundle()
bundle.putBoolean("forwardMessage", true) bundle.putBoolean("forwardMessage", true)
bundle.putString("forwardMessageText", message?.text)
getRouter().pushController( getRouter().pushController(
RouterTransaction.with(ConversationsListController(bundle)).pushChangeHandler RouterTransaction.with(ConversationsListController(bundle)).pushChangeHandler
(HorizontalChangeHandler()).popChangeHandler(HorizontalChangeHandler())) (HorizontalChangeHandler()).popChangeHandler(HorizontalChangeHandler()))
@ -2311,6 +2313,10 @@ class ChatController(args: Bundle) :
(message as ChatMessage).user.id.substring(6) != currentConversation?.actorId && (message as ChatMessage).user.id.substring(6) != currentConversation?.actorId &&
currentConversation?.type != Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL currentConversation?.type != Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL
menu.findItem(R.id.action_delete_message).isVisible = isShowMessageDeletionButton(message) menu.findItem(R.id.action_delete_message).isVisible = isShowMessageDeletionButton(message)
menu.findItem(R.id.action_forward_message).isVisible = ChatMessage.MessageType.REGULAR_TEXT_MESSAGE.equals(
(message as ChatMessage)
.getMessageType()
)
if (menu.hasVisibleItems()) { if (menu.hasVisibleItems()) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
setForceShowIcon(true) setForceShowIcon(true)

View File

@ -139,6 +139,7 @@ public class ConversationsListController extends BaseController implements Searc
public static final String TAG = "ConvListController"; public static final String TAG = "ConvListController";
public static final int ID_DELETE_CONVERSATION_DIALOG = 0; public static final int ID_DELETE_CONVERSATION_DIALOG = 0;
private static final String KEY_SEARCH_QUERY = "ContactsController.searchQuery"; private static final String KEY_SEARCH_QUERY = "ContactsController.searchQuery";
private final Bundle bundle;
@Inject @Inject
UserUtils userUtils; UserUtils userUtils;
@ -209,6 +210,7 @@ public class ConversationsListController extends BaseController implements Searc
super(); super();
setHasOptionsMenu(true); setHasOptionsMenu(true);
forwardMessage = bundle.getBoolean("forwardMessage"); forwardMessage = bundle.getBoolean("forwardMessage");
this.bundle = bundle;
} }
@Override @Override
@ -760,7 +762,7 @@ public class ConversationsListController extends BaseController implements Searc
shareToScreenWasShown = true; shareToScreenWasShown = true;
handleSharedData(); handleSharedData();
}else if (forwardMessage) { }else if (forwardMessage) {
forwardMessage(); openConversation(bundle.getString("forwardMessageText"));
} else { } else {
openConversation(); openConversation();
} }
@ -768,10 +770,6 @@ public class ConversationsListController extends BaseController implements Searc
return true; return true;
} }
private void forwardMessage() {
System.out.println("Add code to forward a message here");
}
private void handleSharedData() { private void handleSharedData() {
collectDataFromIntent(); collectDataFromIntent();
if (!textToPaste.isEmpty()) { if (!textToPaste.isEmpty()) {