Refresh recipient after viewing system contact details.

They might have changed the name or otherwise edited the contact, so we
want to try to keep things in sync.
master
Greyson Parrelli 2020-07-17 09:45:24 -04:00
parent 293a339fed
commit 4c04991b70
2 changed files with 8 additions and 1 deletions

View File

@ -61,6 +61,7 @@ public class ManageRecipientFragment extends LoggingFragment {
private static final int REQUEST_CODE_RETURN_FROM_MEDIA = 405;
private static final int REQUEST_CODE_ADD_CONTACT = 588;
private static final int REQUEST_CODE_VIEW_CONTACT = 610;
private ManageRecipientViewModel viewModel;
private GroupMemberListView sharedGroupList;
@ -259,6 +260,8 @@ public class ManageRecipientFragment extends LoggingFragment {
applyMediaCursorFactory();
} else if (requestCode == REQUEST_CODE_ADD_CONTACT) {
viewModel.onAddedToContacts();
} else if (requestCode == REQUEST_CODE_VIEW_CONTACT) {
viewModel.onFinishedViewingContact();
}
}
@ -267,7 +270,7 @@ public class ManageRecipientFragment extends LoggingFragment {
contactText.setText(R.string.ManageRecipientActivity_this_person_is_in_your_contacts);
contactIcon.setVisibility(View.VISIBLE);
contactRow.setOnClickListener(v -> {
startActivity(new Intent(Intent.ACTION_VIEW, recipient.getContactUri()));
startActivityForResult(new Intent(Intent.ACTION_VIEW, recipient.getContactUri()), REQUEST_CODE_VIEW_CONTACT);
});
} else {
contactText.setText(R.string.ManageRecipientActivity_add_to_system_contacts);

View File

@ -261,6 +261,10 @@ public final class ManageRecipientViewModel extends ViewModel {
manageRecipientRepository.refreshRecipient();
}
void onFinishedViewingContact() {
manageRecipientRepository.refreshRecipient();
}
static final class MediaCursor {
private final long threadId;
@NonNull private final CursorFactory mediaCursorFactory;