Fix an issue where the add profile prompt wasn't dismissed.

This commit is contained in:
Greyson Parrelli 2020-05-19 10:06:11 -04:00 committed by Alex Hart
parent 34159fc9da
commit b80c339c5a
2 changed files with 11 additions and 2 deletions

View File

@ -407,7 +407,7 @@ public class ConversationFragment extends Fragment {
this.recipient = Recipient.live(getActivity().getIntent().getParcelableExtra(ConversationActivity.RECIPIENT_EXTRA));
this.threadId = this.getActivity().getIntent().getLongExtra(ConversationActivity.THREAD_ID_EXTRA, -1);
this.unknownSenderView = new UnknownSenderView(getActivity(), recipient.get(), threadId);
this.unknownSenderView = new UnknownSenderView(getActivity(), recipient.get(), threadId, () -> clearHeaderIfNotTyping(getListAdapter()));
conversationViewModel.onConversationDataAvailable(threadId, startingPosition);

View File

@ -17,11 +17,13 @@ public class UnknownSenderView extends FrameLayout {
private final @NonNull Recipient recipient;
private final long threadId;
private final Listener listener;
public UnknownSenderView(@NonNull Context context, @NonNull Recipient recipient, long threadId) {
public UnknownSenderView(@NonNull Context context, @NonNull Recipient recipient, long threadId, @NonNull Listener listener) {
super(context);
this.recipient = recipient;
this.threadId = threadId;
this.listener = listener;
inflate(context, R.layout.unknown_sender_view, this);
setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
@ -48,6 +50,7 @@ public class UnknownSenderView extends FrameLayout {
protected Void doInBackground(Void... params) {
DatabaseFactory.getRecipientDatabase(context).setBlocked(recipient.getId(), true);
if (threadId != -1) DatabaseFactory.getThreadDatabase(context).setHasSent(threadId, true);
listener.onActionTaken();
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@ -59,6 +62,7 @@ public class UnknownSenderView extends FrameLayout {
private void handleAdd() {
getContext().startActivity(RecipientExporter.export(recipient).asAddContactIntent());
if (threadId != -1) DatabaseFactory.getThreadDatabase(getContext()).setHasSent(threadId, true);
listener.onActionTaken();
}
private void handleProfileAccess() {
@ -74,6 +78,7 @@ public class UnknownSenderView extends FrameLayout {
protected Void doInBackground(Void... params) {
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient.getId(), true);
if (threadId != -1) DatabaseFactory.getThreadDatabase(context).setHasSent(threadId, true);
listener.onActionTaken();
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@ -81,4 +86,8 @@ public class UnknownSenderView extends FrameLayout {
.setNegativeButton(android.R.string.cancel, null)
.show();
}
public interface Listener {
void onActionTaken();
}
}