wordpress-mobile / AztecEditor-Android

A reusable native Android rich text editor component.
Mozilla Public License 2.0
700 stars 115 forks source link

Fix memory leak in EnhancedMovementMethod #1086

Closed khaykov closed 4 months ago

khaykov commented 4 months ago

Fix

With a help from Leak Canary I found a leak in EnhancedMovementMethod.

In this PR we are using weak reference for a click listener. Task list listener is not leaking, so it's ok to keep it as is.

Test

  1. Add link tap handler to aztec instance in Main Activity like this:
 aztec = Aztec.with(visualEditor, sourceEditor, toolbar, this)
            ....
            .setLinkTapEnabled(true)
            .setOnLinkTappedListener(object : AztecText.OnLinkTappedListener {
                override fun onLinkTapped(widget: View, url: String) {
                    val intent = Intent(Intent.ACTION_VIEW)
                    intent.data = Uri.parse(url)
                    startActivity(intent)
                }
            })
            ....
  1. Open the app in tap on the link.
  2. Confirm that it works and the browser is opened.

Review

@[USER_NAME]

Make sure strings will be translated: