Skip to content
Merged
19 changes: 19 additions & 0 deletions aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,6 +46,7 @@ import android.text.style.SuggestionSpan
import android.util.AttributeSet
import android.util.DisplayMetrics
import android.util.TypedValue
import android.view.DragEvent
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.MotionEvent
Expand DownExpand Up@@ -254,6 +255,7 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
private var onVideoInfoRequestedListener: OnVideoInfoRequestedListener? = null
private var onAztecKeyListener: OnAztecKeyListener? = null
private var onVisibilityChangeListener: OnVisibilityChangeListener? = null
private var dragEventManager: DragEventManager? = null
var externalLogger: AztecLog.ExternalLogger? = null

private var isViewInitialized = false
Expand DownExpand Up@@ -356,6 +358,19 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
fun beforeMediaDeleted(attrs: AztecAttributes) {}
}

interface DragEventManager {
fun shouldProcessDragEvent(event: DragEvent?): Boolean
}

override fun onDragEvent(event: DragEvent?): Boolean {
val shouldProcessDragEvent = dragEventManager?.shouldProcessDragEvent(event)
if (shouldProcessDragEvent == true) {
return super.onDragEvent(event)
} else {
return false
}
}

/**
* Listens to keyboard events and calls the `shouldOverrideBackSpace` before each backspace event.
*/
Expand DownExpand Up@@ -1209,6 +1224,10 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
this.onVisibilityChangeListener = listener
}

fun setDragEventManager(listener: DragEventManager) {
this.dragEventManager = listener
}

override fun onKeyPreIme(keyCode: Int, event: KeyEvent): Boolean {
if (event.keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_UP) {
onImeBackListener?.onImeBack()
Expand Down
10 changes: 10 additions & 0 deletions media-placeholders/build.gradle
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,6 +32,12 @@ android {
includeAndroidResources = true
}
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.14"
}
}

dependencies {
Expand All@@ -41,6 +47,10 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutinesVersion"
testImplementation "junit:junit:$jUnitVersion"
testImplementation "org.robolectric:robolectric:$robolectricVersion"
implementation 'androidx.compose.material3:material3:1.3.1'
implementation 'androidx.compose.foundation:foundation:1.7.5'
implementation 'androidx.compose.ui:ui:1.7.5'
implementation 'androidx.compose.ui:ui-tooling-preview:1.7.5'
}

dependencyAnalysis {
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
package org.wordpress.aztec.placeholders

import androidx.compose.runtime.Composable
import org.wordpress.aztec.AztecAttributes

interface ComposePlaceholderAdapter : PlaceholderManager.PlaceholderAdapter {
/**
* Use this method to draw the placeholder using Jetpack Compose.
* @param placeholderUuid the placeholder UUID
* @param attrs aztec attributes of the view
*/
@Composable
fun Placeholder(
placeholderUuid: String,
attrs: AztecAttributes,
)
}
Loading