Skip to content
Open
Show file tree
Hide file tree
Changes from 11 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
19 changes: 19 additions & 0 deletions AgoraCloudScene/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-parcelize'
id 'com.google.protobuf'
}

android {
Expand Down Expand Up @@ -49,6 +50,22 @@ android {
}
}


protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.21.12'
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option 'lite' // 生成精简版类
}
}
}
}
}

dependencies {
//implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "androidx.core:core-ktx:${rootProject.ext.dependencies.core_ktx}"
Expand Down Expand Up @@ -77,6 +94,8 @@ dependencies {
implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:custom-ui:12.0.0'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"

implementation 'com.google.protobuf:protobuf-javalite:3.21.12'
Copy link
Collaborator

@fenggit fenggit Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protobuf 不需要重复引用,底层core已经依赖了,可以直接使用

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

底层并没有依赖,无法使用

}

if (readyPublishMaven.toBoolean()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package io.agora.online.component

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import io.agora.agoraeducore.core.internal.framework.impl.managers.AgoraWidgetActiveObserver
import io.agora.agoraeducore.core.internal.framework.impl.managers.AgoraWidgetRoomPropsUpdateReq
import io.agora.online.component.common.AbsAgoraEduComponent
import io.agora.online.component.common.IAgoraUIProvider
import io.agora.online.databinding.FcrOnlineEduRttComponentBinding
import io.agora.online.options.AgoraEduOptionsComponent
import io.agora.online.options.AgoraEduRttOptionsComponent
import io.agora.online.widget.FcrWidgetManager.WIDGETS_RTT_ID
import io.agora.online.widget.rtt.FcrRttToolBoxWidget

class FcrRttToolBoxComponent : AbsAgoraEduComponent {
constructor(context: Context) : super(context)
constructor(context: Context, attr: AttributeSet) : super(context, attr)
constructor(context: Context, attr: AttributeSet, defStyleAttr: Int) : super(context, attr, defStyleAttr)


private var binding: FcrOnlineEduRttComponentBinding = FcrOnlineEduRttComponentBinding.inflate(LayoutInflater.from(context), this, true)

/**
* widget插件
*/
private var widget: FcrRttToolBoxWidget? = null

/**
* 界面上设置好的布局
*/
private var conversionStatusView: ViewGroup? = null
private var subtitleView: AgoraEduRttOptionsComponent? = null
private var agoraEduOptionsComponent: AgoraEduOptionsComponent? = null

/**
* 插件注册监听
*/
private val widgetActiveObserver = object : AgoraWidgetActiveObserver {
override fun onWidgetActive(widgetId: String) {
if (widget == null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

widget一直没有赋值操作

val widgetConfig = eduContext?.widgetContext()?.getWidgetConfig(widgetId)
widgetConfig?.let { config ->
val widget = eduContext?.widgetContext()?.create(config) as FcrRttToolBoxWidget?
widget?.init(binding.root, agoraUIProvider, agoraEduOptionsComponent!!, conversionStatusView!!, subtitleView!!)
}
}
}

override fun onWidgetInActive(widgetId: String) {
if (widget != null) {
ContextCompat.getMainExecutor(binding.root.context).execute {
widget!!.release()
Copy link
Collaborator

@fenggit fenggit Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议使用!!,容易崩

}
}
}
}

/**
* 重置工具准提
*/
fun resetEduRttToolBoxStatus() {
widget?.resetEduRttToolBoxStatus()
}

fun initView(
agoraUIProvider: IAgoraUIProvider, agoraEduOptionsComponent: AgoraEduOptionsComponent, conversionStatusView: ViewGroup,
subtitleView: AgoraEduRttOptionsComponent,
) {
super.initView(agoraUIProvider)
this.agoraEduOptionsComponent = agoraEduOptionsComponent
this.conversionStatusView = conversionStatusView
this.subtitleView = subtitleView
eduContext?.widgetContext()?.addWidgetActiveObserver(widgetActiveObserver, WIDGETS_RTT_ID)
eduContext?.widgetContext()?.setWidgetActive(WIDGETS_RTT_ID, AgoraWidgetRoomPropsUpdateReq(state = 1))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.text.SpannableString
import android.view.View
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
Expand Down Expand Up @@ -60,6 +61,13 @@ class AgoraUIDialog(context: Context) : Dialog(context, R.style.agora_full_scree
this.message.visibility = View.VISIBLE
this.message.text = message
}
fun setMessage(message: SpannableString) {
this.message.visibility = View.VISIBLE
this.message.text = message
}
fun setMessagePaddingHorizontal(messagePaddingHorizontal: Int) {
this.message.setPadding(messagePaddingHorizontal,this.message.paddingTop,messagePaddingHorizontal,this.message.paddingBottom)
}

fun setIconResource(iconResource: Int) {
this.icon.visibility = View.VISIBLE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package io.agora.online.component.dialog

import android.content.Context
import android.text.SpannableString
import android.view.View

class AgoraUIDialogBuilder(private val context: Context) {
private var title: String? = null
private var message: String? = null
private var messageSpan: SpannableString? = null
private var positiveText: String? = null
private var negativeText: String? = null
private var iconResource: Int? = null
private var messagePaddingHorizontal: Int? = null
private var positiveListener: View.OnClickListener? = null
private var negativeListener: View.OnClickListener? = null
private var mCancelable: Boolean? = null
Expand All @@ -28,6 +31,16 @@ class AgoraUIDialogBuilder(private val context: Context) {
return this
}

fun message(message: SpannableString): AgoraUIDialogBuilder {
this.messageSpan = message
return this
}

fun messagePaddingHorizontal(messagePaddingHorizontal: Int): AgoraUIDialogBuilder {
this.messagePaddingHorizontal = messagePaddingHorizontal
return this
}

fun positiveText(text: String): AgoraUIDialogBuilder {
this.positiveText = text
return this
Expand Down Expand Up @@ -57,6 +70,8 @@ class AgoraUIDialogBuilder(private val context: Context) {
val dialog = AgoraUIDialog(context)
title?.let { dialog.setTitle(it) }
message?.let { dialog.setMessage(it) }
messageSpan?.let { dialog.setMessage(it) }
messagePaddingHorizontal?.let { dialog.setMessagePaddingHorizontal(it) }
positiveText?.let { dialog.setPositiveButtonText(it) }
positiveListener?.let { dialog.setPositiveClick(it) }
negativeText?.let { dialog.setNegativeButtonText(it) }
Expand Down Expand Up @@ -138,4 +153,28 @@ class AgoraUICustomDialogBuilder(private val context: Context) {
}
return dialog
}
}
}

class AgoraUIRttSettingBuilder(private val context: Context) {
private var listener: AgoraUIRttSettingDialogListener? = null
fun build(): AgoraUIRttSettingDialog {
val dialog = AgoraUIRttSettingDialog(context)
listener?.let { dialog.setListener(it) }
return dialog
}

/**
* 设置监听
*/
fun setListener(listener: AgoraUIRttSettingDialogListener): AgoraUIRttSettingBuilder {
this.listener = listener
return this
}
}

class AgoraUIRttConversionDialogBuilder(private val context: Context) {
fun build(): AgoraUIRttConversionDialog {
val dialog = AgoraUIRttConversionDialog(context)
return dialog
}
}
Loading