Переглянути джерело

feat: 整理项目并编译通过

DoggyZhang 4 місяців тому
батько
коміт
32b457c5dc

+ 13 - 15
frame/effect/build.gradle

@@ -10,10 +10,6 @@ ext {
     VERSION = '6.0.21'
 }
 
-if (project.FRAME_DEBUG != "true") {
-    apply from: "../../publish.gradle"
-}
-
 android {
     namespace 'com.adealink.frame.effect'
     compileSdk libs.versions.compileSdk.get().toInteger()
@@ -47,18 +43,20 @@ dependencies {
     implementation libs.androidx.appcompat
 
     //frame
-    compileOnly project(":external:SVGAPlayer")
-    compileOnly project(":external:animplayer")
+    api platform(libs.frame.bom)
+    api libs.frame.svga
+    api libs.frame.animplayer
 
-    compileOnly project(":frame:util")
-    compileOnly project(":frame:base")
-    compileOnly project(":frame:zero")
-    compileOnly project(":frame:coroutine")
-    compileOnly project(":frame:tceffect")
-    compileOnly project(":frame:storage")
-    compileOnly project(":frame:download")
-    compileOnly project(':frame:log')
-    compileOnly project(":frame:statistics")
+    api libs.frame.retrofit
+    api libs.frame.zero
+    api libs.frame.base
+    api libs.frame.data
+    api libs.frame.coroutine
+    api libs.frame.util
+    api libs.frame.storage
+    api libs.frame.download
+    api libs.frame.log
+    api libs.frame.statistics
 
     //exoplayer
     api libs.media3.exoplayer

+ 0 - 138
frame/effect/src/main/java/com/adealink/frame/effect/tc/TCEffectView.kt

@@ -1,138 +0,0 @@
-package com.adealink.frame.effect.tc
-
-import android.content.Context
-import android.os.Bundle
-import android.util.AttributeSet
-import android.view.Gravity
-import android.view.View
-import android.view.ViewGroup
-import android.widget.FrameLayout
-import com.adealink.frame.base.AppBase
-import com.adealink.frame.base.fastLazy
-import com.adealink.frame.effect.data.ERROR_ENTITY_NULL
-import com.adealink.frame.effect.data.IEffectEntity
-import com.adealink.frame.effect.data.INFINITE_LOOP
-import com.adealink.frame.effect.data.TAG_EFFECT_VIEW_TC
-import com.adealink.frame.effect.listener.IPlayListener
-import com.adealink.frame.effect.tc.data.TCEffectEntity
-import com.adealink.frame.effect.view.IEffectView
-import com.adealink.frame.tceffect.TCEffectManager
-import com.adealink.frame.util.runOnUiThread
-import com.tencent.tcmediax.tceffectplayer.api.TCEffectAnimView
-import com.tencent.tcmediax.tceffectplayer.api.TCEffectConfig
-import com.tencent.tcmediax.tceffectplayer.api.TCEffectPlayerConstant
-
-
-class TCEffectView @JvmOverloads constructor(
-    context: Context,
-    attrs: AttributeSet? = null,
-    defStyleAttr: Int = 0,
-) : FrameLayout(context, attrs, defStyleAttr), IEffectView {
-
-    private val tcEffectAnimView by fastLazy {
-        TCEffectAnimView(context)
-    }
-
-    override fun addToParent(parent: ViewGroup, params: ViewGroup.LayoutParams) {
-        parent.addView(this, params)
-    }
-
-    override fun removeFromParent(parent: ViewGroup) {
-        parent.removeView(this)
-    }
-
-    override fun setVisibility(visibility: Boolean) {
-        this.visibility = if (visibility) View.VISIBLE else View.GONE
-    }
-
-    override fun isVisibility(): Boolean {
-        return this.visibility == View.VISIBLE
-    }
-
-    override fun setMute(mute: Boolean) {
-        super.setMute(mute)
-        tcEffectAnimView.setMute(mute)
-    }
-
-    override fun play(entity: IEffectEntity<out IEffectView>?, l: IPlayListener?) {
-        val tcEffectEntity = entity as? TCEffectEntity
-        if (tcEffectEntity == null) {
-            l?.onError(ERROR_ENTITY_NULL)
-            return
-        }
-
-        tcEffectAnimView.setMute(entity.mute)
-        val lp = (tcEffectAnimView.layoutParams ?: layoutParams) as LayoutParams
-        lp.width = entity.width ?: ViewGroup.LayoutParams.MATCH_PARENT
-        lp.height = entity.height ?: ViewGroup.LayoutParams.MATCH_PARENT
-        if (tcEffectAnimView.parent == null) {
-            lp.gravity = Gravity.CENTER
-            addView(tcEffectAnimView, lp)
-        } else {
-            tcEffectAnimView.layoutParams = lp
-        }
-        tcEffectAnimView.visibility = View.VISIBLE
-        //tc循环次数要特殊处理 <=0代表无限循环
-        val loops = when {
-            entity.loop < 0 -> {
-                INFINITE_LOOP
-            }
-            entity.loop == 0 -> {
-                1
-            }
-            else -> {
-                entity.loop
-            }
-        }
-        tcEffectAnimView.setLoopCount(loops)
-        tcEffectAnimView.setScaleType(TCEffectPlayerConstant.ScaleType.CENTER_CROP)
-        tcEffectAnimView.setFetchResource(entity.fetchResource)
-        val tceConfigExtendMap: HashMap<String, Any> = hashMapOf(
-            TCEffectPlayerConstant.PARAM_OPTIONAL_STRING_EXTRA_LICENSE_KEY to TCEffectManager.getOldLicense()
-        )
-        tcEffectAnimView.setConfig(
-            TCEffectConfig.Builder().setExtendMapParams(tceConfigExtendMap)
-                .setCodecType(TCEffectConfig.CodecType.TX_LITEAV_SDK).build()
-        )
-        val animPlayListener = object : TCEffectAnimView.IAnimPlayListener {
-
-            override fun onPlayStart() {
-                AppBase.log.d(TAG_EFFECT_VIEW_TC, "onPlayStart")
-            }
-
-            override fun onPlayEnd() {
-                AppBase.log.d(TAG_EFFECT_VIEW_TC, "onPlayEnd")
-                runOnUiThread {
-                    tcEffectAnimView.visibility = GONE
-                    l?.onComplete()
-                }
-            }
-
-            override fun onPlayError(p0: Int) {
-                AppBase.log.e(TAG_EFFECT_VIEW_TC, "onPlayError, error:$p0")
-                runOnUiThread {
-                    l?.onError(p0)
-                }
-            }
-
-            override fun onPlayEvent(p0: Int, p1: Bundle?) {
-
-            }
-        }
-        tcEffectAnimView.setPlayListener(animPlayListener)
-        if (!TCEffectManager.isTcEffectEnable()) {
-            l?.onError(-1)
-            return
-        }
-        tcEffectAnimView.startPlay(tcEffectEntity.path)
-    }
-
-    override fun pause() {
-        tcEffectAnimView.pause()
-    }
-
-    override fun stop() {
-        tcEffectAnimView.stopPlay(true)
-    }
-
-}

+ 0 - 33
frame/effect/src/main/java/com/adealink/frame/effect/tc/data/TCEffectEntity.kt

@@ -1,33 +0,0 @@
-package com.adealink.frame.effect.tc.data
-
-import android.content.Context
-import android.util.AttributeSet
-import com.adealink.frame.effect.data.DEFAULT_EFFECT_TIMEOUT_MS
-import com.adealink.frame.effect.data.IEffectEntity
-import com.adealink.frame.effect.data.defaultPriority
-import com.adealink.frame.effect.listener.IPlayListener
-import com.adealink.frame.effect.tc.TCEffectView
-import com.tencent.tcmediax.tceffectplayer.api.mix.IFetchResource
-
-data class TCEffectEntity(
-    override val path: String,
-    override val loop: Int = 0,
-    val effectUrl: String? = null,
-    val mute: Boolean = false,
-    val width: Int? = null,
-    val height: Int? = null,
-    val fetchResource: IFetchResource? = null,
-    override val priority: String = defaultPriority,
-    override val playListener: IPlayListener? = null,
-    override val timeoutMS: Long = DEFAULT_EFFECT_TIMEOUT_MS,
-    override val playNow: Boolean = false
-) : IEffectEntity<TCEffectView>() {
-
-    override fun createEffectView(
-        ctx: Context,
-        attrs: AttributeSet?,
-        defStyleAttr: Int,
-    ): TCEffectView {
-        return TCEffectView(ctx, attrs, defStyleAttr)
-    }
-}

+ 1 - 2
frame/effect/src/main/java/com/adealink/frame/effect/view/IWeAnimView.kt

@@ -10,8 +10,7 @@ import com.adealink.frame.effect.stat.EffectStatEvent
 enum class AnimViewType(val value: String) {
     SVGA("1"),
     VAP("2"),
-    TC("3"),
-    MP4("4");
+    MP4("3");
 }
 
 interface IWeAnimView {

+ 1 - 17
frame/effect/src/main/java/com/adealink/frame/effect/view/WeAnimView.kt

@@ -22,13 +22,11 @@ import com.adealink.frame.effect.video.Mp4BoxType
 import com.adealink.frame.effect.video.hasBoxType
 import com.adealink.frame.effect.view.helper.IWeAnimViewHelper
 import com.adealink.frame.effect.view.helper.Mp4AnimViewHelper
-import com.adealink.frame.effect.view.helper.TCAnimViewHelper
 import com.adealink.frame.effect.view.helper.WeSVGAAnimViewHelper
 import com.adealink.frame.effect.view.helper.WeVapAnimViewHelper
 import com.adealink.frame.storage.constant.StorageFileWriteError
 import com.adealink.frame.storage.file.getCacheFilePathByUrl
 import com.adealink.frame.storageService
-import com.adealink.frame.tceffect.TCEffectManager
 import com.adealink.frame.util.AppUtil
 import com.adealink.frame.util.writeStreamToFile
 import kotlinx.coroutines.CoroutineScope
@@ -322,9 +320,6 @@ open class WeAnimView @JvmOverloads constructor(
             AnimViewType.VAP -> {
                 WeVapAnimViewHelper()
             }
-            AnimViewType.TC -> {
-                TCAnimViewHelper()
-            }
             AnimViewType.MP4 -> {
                 Mp4AnimViewHelper()
             }
@@ -338,24 +333,13 @@ open class WeAnimView @JvmOverloads constructor(
                 filePath.endsWith(
                     ".mp4",
                     ignoreCase = true
-                ) && !TCEffectManager.isTcEffectEnable() -> {
+                ) -> {
                     if (hasBoxType(filePath, Mp4BoxType.VAP)) {
                         AnimViewType.VAP
                     } else {
                         AnimViewType.MP4
                     }
                 }
-                filePath.endsWith(".tcmp4", ignoreCase = true) -> AnimViewType.TC
-                (filePath.endsWith(
-                    ".mp4",
-                    ignoreCase = true
-                ) && TCEffectManager.isTcEffectEnable()) -> {
-                    if (hasBoxType(filePath, Mp4BoxType.VAP, Mp4BoxType.TC)) {
-                        AnimViewType.TC
-                    } else {
-                        AnimViewType.MP4
-                    }
-                }
                 else -> null
             }
         }

+ 0 - 240
frame/effect/src/main/java/com/adealink/frame/effect/view/helper/TCAnimViewHelper.kt

@@ -1,240 +0,0 @@
-package com.adealink.frame.effect.view.helper
-
-import android.content.Context
-import android.graphics.Paint
-import android.os.Bundle
-import android.view.View
-import android.view.ViewGroup
-import android.widget.ImageView
-import androidx.core.view.isVisible
-import com.adealink.frame.base.AppBase
-import com.adealink.frame.effect.data.AnimExtraConfig
-import com.adealink.frame.effect.data.DynamicAnimImage
-import com.adealink.frame.effect.data.DynamicAnimText
-import com.adealink.frame.effect.data.IAnimDynamicProvider
-import com.adealink.frame.effect.data.INFINITE_LOOP
-import com.adealink.frame.effect.data.TAG_EFFECT_ANIM_VIEW_TC
-import com.adealink.frame.effect.view.IWeAnimPlayListener
-import com.adealink.frame.ext.safeParseColor
-import com.adealink.frame.tceffect.TCEffectManager
-import com.adealink.frame.util.runOnUiThread
-import com.tencent.tcmediax.tceffectplayer.api.TCEffectAnimView
-import com.tencent.tcmediax.tceffectplayer.api.TCEffectConfig
-import com.tencent.tcmediax.tceffectplayer.api.TCEffectPlayerConstant
-import com.tencent.tcmediax.tceffectplayer.api.data.TCEffectText
-import com.tencent.tcmediax.tceffectplayer.api.mix.IFetchResourceImgResult
-import com.tencent.tcmediax.tceffectplayer.api.mix.IFetchResourceTxtResult
-import java.lang.ref.WeakReference
-import com.tencent.tcmediax.tceffectplayer.api.mix.IFetchResource as ITCFetchResource
-
-class TCAnimViewHelper : IWeAnimViewHelper {
-    private var animViewRef: WeakReference<TCEffectAnimView?> = WeakReference(null)
-    private val animView: TCEffectAnimView?
-        get() {
-            return animViewRef.get()
-        }
-
-    private var animExtraConfig: AnimExtraConfig? = null
-    private var listener: IWeAnimPlayListener? = null
-    private var filePath: String? = null
-    private var playListener = object : TCEffectAnimView.IAnimPlayListener {
-        override fun onPlayStart() {
-            runOnUiThread {
-                listener?.onPlayStart()
-            }
-        }
-
-        override fun onPlayEnd() {
-            runOnUiThread {
-                listener?.onPlayEnd()
-            }
-        }
-
-        override fun onPlayError(p0: Int) {
-            runOnUiThread {
-                listener?.onPlayError(p0.toString())
-            }
-        }
-
-        override fun onPlayEvent(p0: Int, p1: Bundle?) {
-
-        }
-    }
-
-    override fun setFile(filePath: String, dynamicProvider: IAnimDynamicProvider?) {
-        AppBase.log.d(TAG_EFFECT_ANIM_VIEW_TC, "setFile, filePath:${filePath}")
-        this.filePath = filePath
-        var fetchResource: ITCFetchResource? = null
-        if (dynamicProvider != null) {
-            val textProviderMap = hashMapOf<String, DynamicAnimText>()
-            val imgProviderMap = hashMapOf<String, DynamicAnimImage>()
-            dynamicProvider.provideText { map ->
-                if (map.isNullOrEmpty()) {
-                    return@provideText
-                }
-                for (entry in map.entries) {
-                    textProviderMap[entry.key] = entry.value
-                }
-            }
-            dynamicProvider.provideImage { map ->
-                if (map.isNullOrEmpty()) {
-                    return@provideImage
-                }
-                for (entry in map.entries) {
-                    imgProviderMap[entry.key] = entry.value
-                }
-            }
-            fetchResource = object : ITCFetchResource {
-                override fun fetchImage(
-                    resource: com.tencent.tcmediax.tceffectplayer.api.mix.Resource,
-                    result: IFetchResourceImgResult
-                ) {
-                    result.fetch(imgProviderMap[resource.tag]?.bitmapSupplier?.invoke())
-                }
-
-                override fun fetchText(
-                    resource: com.tencent.tcmediax.tceffectplayer.api.mix.Resource,
-                    result: IFetchResourceTxtResult
-                ) {
-                    val resultText = textProviderMap[resource.tag]
-                    if (resultText == null) {
-                        // 使用loadTextForPlayer(null)时会显示占位tag文字,参考ludo游戏获胜宝箱动效,暂时先不用
-                        // result.loadTextForPlayer(null)
-                        result.fetch(null)
-                    } else {
-                        val tcEffectText = TCEffectText()
-                        tcEffectText.text = resultText.text
-                        tcEffectText.color = resultText.colorInt ?: safeParseColor(resultText.color)
-                        tcEffectText.alignment = when(resultText.textAlignment) {
-                            Paint.Align.LEFT -> TCEffectText.TEXT_ALIGNMENT_LEFT
-                            Paint.Align.RIGHT -> TCEffectText.TEXT_ALIGNMENT_RIGHT
-                            Paint.Align.CENTER -> TCEffectText.TEXT_ALIGNMENT_CENTER
-                        }
-                        if (resultText.fontBold) {
-                            tcEffectText.fontStyle = "bold"
-                        }
-                        result.loadTextForPlayer(tcEffectText)
-                    }
-                }
-
-                override fun releaseResource(resources: MutableList<com.tencent.tcmediax.tceffectplayer.api.mix.Resource>) {
-                    resources.forEach {
-                        it.bitmap?.recycle()
-                    }
-                }
-
-            }
-        }
-        animView?.setPlayListener(playListener)
-        animView?.setFetchResource(fetchResource)
-        if (animExtraConfig?.autoPlay == true) {
-            animView?.startPlay(filePath)
-        }
-    }
-
-    override fun startPlay() {
-        //目前resume支持不完整,直接开始重新播放
-        val filePath = filePath ?: return
-        if (animView?.isPlaying == true) {
-            return
-        }
-        AppBase.log.d(TAG_EFFECT_ANIM_VIEW_TC, "startPlay, filePath:${filePath}")
-        animView?.startPlay(filePath)
-    }
-
-    override fun pausePlay() {
-        animView?.pause()
-    }
-
-    override fun stopPlay() {
-        animView?.stopPlay(true)
-    }
-
-    override fun setListener(listener: IWeAnimPlayListener?) {
-        this.listener = listener
-    }
-
-    override fun setConfig(config: AnimExtraConfig) {
-        this.animExtraConfig = config
-        animView?.apply {
-            val tceConfigExtendMap: HashMap<String, Any> = hashMapOf(
-                TCEffectPlayerConstant.PARAM_OPTIONAL_STRING_EXTRA_LICENSE_KEY to TCEffectManager.getOldLicense()
-            )
-            setConfig(
-                TCEffectConfig.Builder()
-                    .setFreezeFrame(if (animExtraConfig?.isFreezeLast == true) TCEffectConfig.FREEZE_FRAME_LAST else TCEffectConfig.FREEZE_FRAME_NONE)
-                    .setCodecType(TCEffectConfig.CodecType.TX_LITEAV_SDK)
-                    .setExtendMapParams(tceConfigExtendMap).build()
-            )
-            val loopCnt = config.loop
-            //tc循环次数要特殊处理 <=0代表无限循环
-            val loops = when {
-                loopCnt < 0 -> {
-                    INFINITE_LOOP
-                }
-                loopCnt == 0 -> {
-                    1
-                }
-                else -> {
-                    loopCnt
-                }
-            }
-            setLoopCount(loops)
-            setScaleType(
-                getTCScaleTypeBy(
-                    config.scaleType
-                ))
-            setMute(config.mute)
-        }
-    }
-
-    override fun setMute(mute: Boolean) {
-        animView?.setMute(mute)
-    }
-
-    override fun createView(context: Context): View {
-        val animView = TCEffectAnimView(context)
-        this.animViewRef = WeakReference(animView)
-        return animView
-    }
-
-    override fun getView(context: Context): View? {
-        return animView
-    }
-
-    override fun show() {
-        animView?.visibility = View.VISIBLE
-    }
-
-    override fun gone() {
-        animView?.visibility = View.GONE
-    }
-
-    override fun removeFromParent() {
-        animView?.let {
-            it.setPlayListener(null)
-            (it.parent as? ViewGroup)?.removeView(it)
-        }
-    }
-
-    override fun onAttachedToWindow() {
-        startPlay()
-    }
-
-    override fun onDetachedFromWindow() {
-
-    }
-
-    private fun getTCScaleTypeBy(type: ImageView.ScaleType): TCEffectPlayerConstant.ScaleType? {
-        return when (type) {
-            ImageView.ScaleType.MATRIX -> null
-            ImageView.ScaleType.FIT_XY -> TCEffectPlayerConstant.ScaleType.FIT_XY
-            ImageView.ScaleType.FIT_START -> null
-            ImageView.ScaleType.FIT_CENTER -> TCEffectPlayerConstant.ScaleType.FIT_CENTER
-            ImageView.ScaleType.FIT_END -> null
-            ImageView.ScaleType.CENTER -> null
-            ImageView.ScaleType.CENTER_CROP -> TCEffectPlayerConstant.ScaleType.CENTER_CROP
-            ImageView.ScaleType.CENTER_INSIDE -> null
-        }
-    }
-}

+ 7 - 9
frame/statistics/build.gradle

@@ -11,10 +11,6 @@ ext {
     VERSION = '6.0.3'
 }
 
-if (project.FRAME_DEBUG != "true") {
-    apply from: "../../publish.gradle"
-}
-
 android {
     namespace 'com.adealink.frame.statistics'
     compileSdk libs.versions.compileSdk.get().toInteger()
@@ -66,11 +62,13 @@ dependencies {
     implementation libs.okhttp
 
     //frame
-    compileOnly project(":frame:zero")
-    compileOnly project(":frame:base")
-    compileOnly project(":frame:util")
-    compileOnly project(":frame:coroutine")
-    compileOnly project(":frame:data")
+    api platform(libs.frame.bom)
+    api libs.frame.retrofit
+    api libs.frame.zero
+    api libs.frame.base
+    api libs.frame.data
+    api libs.frame.coroutine
+    api libs.frame.util
 
     //test
     testImplementation libs.junit