mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 02:08:40 +00:00
Fix case where dialog could be shown after user leaves fragment.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms.conversation.mutiselect.forward
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
@@ -206,6 +207,11 @@ class MultiselectForwardFragment :
|
||||
handler?.removeCallbacksAndMessages(null)
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
dismissibleDialog?.dismissNow()
|
||||
super.onDismiss(dialog)
|
||||
}
|
||||
|
||||
private fun displayFirstSendConfirmation() {
|
||||
SignalStore.tooltips().markMultiForwardDialogSeen()
|
||||
|
||||
|
||||
@@ -68,26 +68,43 @@ public final class SimpleProgressDialog {
|
||||
|
||||
ThreadUtil.runOnMainDelayed(showRunnable, delayMs);
|
||||
|
||||
return () -> {
|
||||
ThreadUtil.cancelRunnableOnMain(showRunnable);
|
||||
ThreadUtil.runOnMain(() -> {
|
||||
AlertDialog alertDialog = dialogAtomicReference.getAndSet(null);
|
||||
if (alertDialog != null) {
|
||||
long beenShowingForMs = System.currentTimeMillis() - shownAt.get();
|
||||
long remainingTimeMs = minimumShowTimeMs - beenShowingForMs;
|
||||
return new DismissibleDialog() {
|
||||
@Override
|
||||
public void dismiss() {
|
||||
ThreadUtil.cancelRunnableOnMain(showRunnable);
|
||||
ThreadUtil.runOnMain(() -> {
|
||||
AlertDialog alertDialog = dialogAtomicReference.getAndSet(null);
|
||||
if (alertDialog != null) {
|
||||
long beenShowingForMs = System.currentTimeMillis() - shownAt.get();
|
||||
long remainingTimeMs = minimumShowTimeMs - beenShowingForMs;
|
||||
|
||||
if (remainingTimeMs > 0) {
|
||||
ThreadUtil.runOnMainDelayed(alertDialog::dismiss, remainingTimeMs);
|
||||
} else {
|
||||
if (remainingTimeMs > 0) {
|
||||
ThreadUtil.runOnMainDelayed(alertDialog::dismiss, remainingTimeMs);
|
||||
} else {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissNow() {
|
||||
ThreadUtil.cancelRunnableOnMain(showRunnable);
|
||||
ThreadUtil.runOnMain(() -> {
|
||||
AlertDialog alertDialog = dialogAtomicReference.getAndSet(null);
|
||||
if (alertDialog != null) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public interface DismissibleDialog {
|
||||
@AnyThread
|
||||
void dismiss();
|
||||
|
||||
@AnyThread
|
||||
void dismissNow();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user