Allow attachments to be added when draft was not created on API yet

This was also the behavior before the saveDraft refactoring took place,
as despite the logic in `AddAttachmentsActivity` seems to be in place to
avoid it, the `PostMessageServiceFactory` was posting a
`DraftCreatedEvent` which when received in `AddAttachmentsActivity`
would set mDraftCreated field to true (even if the draft was just local
like in the case of no connectivity).
The mentioned logic that received the DraftCreatedEvent was deleted by
commit 779a328 as part of this refactoring.
This same behavior is achieved by not considering `isLocalMessageId` to
comptute EXTRA_DRAFT_CREATED boolean.

Except for an edge case for which the user clicks the "add attachments"
menu immediately after opening the composer, this condition will always
be true. Tracked in a task to be completely removed after this refactoring

MAILAND-1281
This commit is contained in:
Marino Meneghel 2020-12-29 13:40:33 +01:00
parent 94d301e3d1
commit ea86bb83cb
2 changed files with 2 additions and 4 deletions

View File

@ -97,8 +97,6 @@ public class AddAttachmentsActivity extends BaseStoragePermissionActivity implem
private static final int REQUEST_CODE_TAKE_PHOTO = 2;
private static final String STATE_PHOTO_PATH = "STATE_PATH_TO_PHOTO";
private MessagesDatabase messagesDatabase;
private AttachmentListAdapter mAdapter;
@BindView(R.id.progress_layout)
View mProgressLayout;
@ -193,7 +191,7 @@ public class AddAttachmentsActivity extends BaseStoragePermissionActivity implem
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
messagesDatabase = MessagesDatabaseFactory.Companion.getInstance(
MessagesDatabase messagesDatabase = MessagesDatabaseFactory.Companion.getInstance(
getApplicationContext()).getDatabase();
ActionBar actionBar = getSupportActionBar();

View File

@ -2145,7 +2145,7 @@ public class ComposeMessageActivity
public void onChanged(@Nullable List<LocalAttachment> attachments) {
String draftId = composeMessageViewModel.getDraftId();
Intent intent = AppUtil.decorInAppIntent(new Intent(ComposeMessageActivity.this, AddAttachmentsActivity.class));
intent.putExtra(AddAttachmentsActivity.EXTRA_DRAFT_CREATED, !TextUtils.isEmpty(draftId) && !MessageUtils.INSTANCE.isLocalMessageId(draftId));
intent.putExtra(AddAttachmentsActivity.EXTRA_DRAFT_CREATED, !TextUtils.isEmpty(draftId));
intent.putParcelableArrayListExtra(AddAttachmentsActivity.EXTRA_ATTACHMENT_LIST, new ArrayList<>(attachments));
intent.putExtra(AddAttachmentsActivity.EXTRA_DRAFT_ID, draftId);
startActivityForResult(intent, REQUEST_CODE_ADD_ATTACHMENTS);