Skip to content

Commit dce11d8

Browse files
committed
fix: unabkle to send forwarded message
1 parent 7d1cc8c commit dce11d8

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

app/src/main/java/co/tinode/tindroid/MessagesFragment.java

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
import androidx.appcompat.app.AlertDialog;
6262
import androidx.appcompat.app.AppCompatActivity;
6363
import androidx.appcompat.widget.AppCompatImageButton;
64-
import androidx.appcompat.widget.AppCompatImageView;
6564
import androidx.core.content.ContextCompat;
6665
import androidx.core.content.FileProvider;
6766
import androidx.core.view.ContentInfoCompat;
@@ -499,7 +498,7 @@ public void onResume() {
499498

500499
mRefresher.setRefreshing(false);
501500

502-
updateFormValues(args);
501+
updateFormValues();
503502
activity.sendNoteRead(0);
504503
}
505504

@@ -726,7 +725,7 @@ public void onLongPress(MotionEvent e) {
726725
return audio;
727726
}
728727

729-
private void updateFormValues(Bundle args) {
728+
private void updateFormValues() {
730729
if (!isAdded()) {
731730
return;
732731
}
@@ -762,20 +761,6 @@ private void updateFormValues(Bundle args) {
762761
acs.isReader(Acs.Side.GIVEN) ? View.GONE : View.VISIBLE);
763762
}
764763

765-
if (args != null) {
766-
mMessageToSend = args.getString(MESSAGE_TO_SEND);
767-
mReplySeqID = args.getInt(MESSAGE_REPLY_ID);
768-
mReply = (Drafty) args.getSerializable(MESSAGE_REPLY);
769-
mContentToForward = (Drafty) args.getSerializable(ForwardToFragment.CONTENT_TO_FORWARD);
770-
mForwardSender = (Drafty) args.getSerializable(ForwardToFragment.FORWARDING_FROM_USER);
771-
// Clear used arguments.
772-
args.remove(MESSAGE_TO_SEND);
773-
args.remove(MESSAGE_REPLY_ID);
774-
args.remove(MESSAGE_REPLY);
775-
args.remove(ForwardToFragment.CONTENT_TO_FORWARD);
776-
args.remove(ForwardToFragment.FORWARDING_FROM_USER);
777-
}
778-
779764
if (!mTopic.isWriter() || mTopic.isBlocked() || mTopic.isDeleted()) {
780765
setSendPanelVisible(activity, R.id.sendMessageDisabled);
781766
} else if (mContentToForward != null) {
@@ -1138,7 +1123,7 @@ public PromisedReply<ServerMessage> onSuccess(ServerMessage result) {
11381123
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
11391124
startActivity(intent);
11401125
} else {
1141-
activity.runOnUiThread(() -> updateFormValues(null));
1126+
activity.runOnUiThread(() -> updateFormValues());
11421127
}
11431128
return null;
11441129
}
@@ -1155,7 +1140,7 @@ public PromisedReply<ServerMessage> onSuccess(ServerMessage result) {
11551140
@SuppressLint("NotifyDataSetChanged")
11561141
void notifyDataSetChanged(boolean meta) {
11571142
if (meta) {
1158-
updateFormValues(null);
1143+
updateFormValues();
11591144
} else {
11601145
mMessagesAdapter.notifyDataSetChanged();
11611146
}
@@ -1361,14 +1346,35 @@ private void showContentToForward(Activity activity, Drafty sender, Drafty conte
13611346
}
13621347

13631348
void topicChanged(String topicName, boolean reset) {
1349+
boolean changed = (mTopicName == null || !mTopicName.equals(topicName));
13641350
mTopicName = topicName;
13651351
if (mTopicName != null) {
13661352
//noinspection unchecked
13671353
mTopic = (ComTopic<VxCard>) Cache.getTinode().getTopic(mTopicName);
13681354
} else {
13691355
mTopic = null;
13701356
}
1371-
updateFormValues(getArguments());
1357+
1358+
if (changed) {
1359+
Bundle args = getArguments();
1360+
if (args != null) {
1361+
mMessageToSend = args.getString(MESSAGE_TO_SEND);
1362+
mReplySeqID = args.getInt(MESSAGE_REPLY_ID);
1363+
mReply = (Drafty) args.getSerializable(MESSAGE_REPLY);
1364+
mContentToForward = (Drafty) args.getSerializable(ForwardToFragment.CONTENT_TO_FORWARD);
1365+
mForwardSender = (Drafty) args.getSerializable(ForwardToFragment.FORWARDING_FROM_USER);
1366+
Log.i(TAG, "topicChanged " + mContentToForward, new Exception("stacktrace"));
1367+
1368+
// Clear used arguments.
1369+
args.remove(MESSAGE_TO_SEND);
1370+
args.remove(MESSAGE_REPLY_ID);
1371+
args.remove(MESSAGE_REPLY);
1372+
args.remove(ForwardToFragment.CONTENT_TO_FORWARD);
1373+
args.remove(ForwardToFragment.FORWARDING_FROM_USER);
1374+
}
1375+
}
1376+
1377+
updateFormValues();
13721378
if (reset) {
13731379
runMessagesLoader(mTopicName);
13741380
}
@@ -1404,7 +1410,7 @@ public ContentInfoCompat onReceiveContent(@NonNull View view, @NonNull ContentIn
14041410
Operation op = AttachmentHandler.enqueueMsgAttachmentUploadRequest(activity,
14051411
AttachmentHandler.ARG_OPERATION_IMAGE, args);
14061412
if (op != null) {
1407-
op.getResult().addListener((Runnable) () -> {
1413+
op.getResult().addListener(() -> {
14081414
if (activity.isFinishing() || activity.isDestroyed()) {
14091415
return;
14101416
}

0 commit comments

Comments
 (0)