Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import android.view.WindowManager
import android.view.accessibility.AccessibilityEvent
import android.widget.FrameLayout
import androidx.annotation.UiThread
import com.facebook.common.logging.FLog
import com.facebook.react.R
import com.facebook.react.bridge.GuardedRunnable
import com.facebook.react.bridge.LifecycleEventListener
Expand Down Expand Up @@ -211,18 +210,11 @@ public class ReactModalHostView(context: ThemedReactContext) :

// If the existing Dialog is currently up, we may need to redraw it or we may be able to update
// the property without having to recreate the dialog
dialog?.let { nonNullDialog ->
val dialogContext: Context? =
ContextUtils.findContextOfType(nonNullDialog.context, Activity::class.java)
// TODO(T85755791): remove after investigation
FLog.e(TAG, "Updating existing dialog with context: $dialogContext")

if (propertyRequiresNewDialog) {
dismiss()
} else {
updateProperties()
return
}
if (propertyRequiresNewDialog) {
dismiss()
} else {
updateProperties()
return
}

// Reset the flag since we are going to create a new dialog
Expand All @@ -235,17 +227,13 @@ public class ReactModalHostView(context: ThemedReactContext) :
}

val currentActivity = getCurrentActivity()
val context = currentActivity ?: context
val newDialog = Dialog(context, theme)
val newDialog = Dialog(currentActivity ?: context, theme)
dialog = newDialog
Objects.requireNonNull<Window>(newDialog.window)
.setFlags(
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)

// TODO(T85755791): remove after investigation
FLog.e(TAG, "Creating new dialog from context: " + context + "@" + context.hashCode())

newDialog.setContentView(contentView)
updateProperties()

Expand All @@ -269,7 +257,8 @@ public class ReactModalHostView(context: ThemedReactContext) :
// We redirect the rest of the key events to the current activity, since the
// activity expects to receive those events and react to them, ie. in the case of
// the dev menu
val innerCurrentActivity = (context as ReactContext).currentActivity
val innerCurrentActivity =
(this@ReactModalHostView.context as ReactContext).currentActivity
if (innerCurrentActivity != null) {
return innerCurrentActivity.onKeyUp(keyCode, event)
}
Expand Down