From cac84ec7e86c68fb5d080cf3a8c368ace275fcf4 Mon Sep 17 00:00:00 2001 From: renhaoting <370797079@qq.com> Date: Thu, 30 Oct 2025 14:16:07 +0800 Subject: [PATCH] =?UTF-8?q?Call=20=E9=A1=B5=E9=9D=A2=E5=88=9D=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../remax/visualnovel/ui/chat/ChatActivity.kt | 67 ++++++++- .../remax/visualnovel/ui/chat/InputPanel.kt | 28 ++-- .../visualnovel/ui/chat/call/ChatCallView.kt | 48 ++++++ .../src/main/res/drawable/bg_chat_call.xml | 14 ++ .../main/res/layout/activity_actor_chat.xml | 49 +++++-- .../src/main/res/layout/chat_inputpanel.xml | 2 +- .../main/res/layout/layout_chat_call_view.xml | 133 +++++++++++++++++ .../app/src/main/res/raw/call_listening.json | 137 ++++++++++++++++++ .../app/src/main/res/values/colors.xml | 2 + .../app/src/main/res/values/strings.xml | 2 + 10 files changed, 455 insertions(+), 27 deletions(-) create mode 100644 VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/call/ChatCallView.kt create mode 100644 VisualNovel/app/src/main/res/drawable/bg_chat_call.xml create mode 100644 VisualNovel/app/src/main/res/layout/layout_chat_call_view.xml create mode 100644 VisualNovel/app/src/main/res/raw/call_listening.json diff --git a/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ChatActivity.kt b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ChatActivity.kt index e935808..30758a7 100644 --- a/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ChatActivity.kt +++ b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/ChatActivity.kt @@ -2,6 +2,8 @@ package com.remax.visualnovel.ui.chat import android.graphics.Point +import android.view.View.GONE +import android.view.View.VISIBLE import androidx.activity.viewModels import androidx.core.view.GravityCompat import androidx.lifecycle.Observer @@ -14,7 +16,6 @@ import com.hjq.permissions.permission.PermissionLists import com.hjq.permissions.permission.base.IPermission import com.remax.visualnovel.app.base.BaseBindingActivity import com.remax.visualnovel.utils.Routers -import com.remax.visualnovel.utils.StatusBarUtils import com.pengxr.modular.eventbus.generated.events.EventDefineOfUserEvents import com.remax.visualnovel.R import com.remax.visualnovel.databinding.ActivityActorChatBinding @@ -25,6 +26,7 @@ import com.remax.visualnovel.extension.launchAndLoadingCollect import com.remax.visualnovel.extension.launchWithRequest import com.remax.visualnovel.extension.toast import com.remax.visualnovel.manager.nim.NimManager +import com.remax.visualnovel.ui.chat.call.ChatCallView import com.remax.visualnovel.ui.chat.setting.model.ChatModelDialog import com.remax.visualnovel.ui.chat.ui.HoldToTalkDialog import com.remax.visualnovel.utils.RecordHelper @@ -38,7 +40,7 @@ import kotlin.getValue @AndroidEntryPoint @Route(path = Routers.CHAT) class ChatActivity : BaseBindingActivity() { - + private var mMode = MODE_TEXT private val chatViewModel by viewModels() private val mRecordAssist = RecordAssist() @@ -59,6 +61,7 @@ class ChatActivity : BaseBindingActivity() { with(binding) { initInputPanelEvents() + initCallViewEvents() } } @@ -95,6 +98,16 @@ class ChatActivity : BaseBindingActivity() { } } + private fun initCallViewEvents() { + with(binding.callView) { + setEventListener(object : ChatCallView.IEventListener { + override fun onExitCall() { + switchMode(MODE_TEXT) + } + }) + } + } + private fun initInputPanelEvents() { with(binding.inputPanel) { holdToTalk( @@ -108,6 +121,49 @@ class ChatActivity : BaseBindingActivity() { mRecordAssist.onTouchPointChanged(point) } ) + + setEventListener(object : InputPanel.IEventListener { + override fun onEnterCall() { + switchMode(MODE_CALL) + } + + override fun onEnterShortChat() { + // TODO("Not yet implemented") + } + + override fun onSendText(content: CharSequence) { + // TODO("Not yet implemented") + } + + override fun onMsgRvScroll2Bottom() { + // TODO("Not yet implemented") + } + + override fun onCheckVipStatus() { + // TODO("Not yet implemented") + } + }) + + } + } + + + private fun switchMode(newMode: Int) { + if (newMode != mMode) { + mMode = newMode + binding.run { + when (mMode) { + MODE_VOICE, MODE_TEXT -> { + callView.visibility = GONE + textVoiceChatContainer.visibility = VISIBLE + } + + MODE_CALL -> { + callView.visibility = VISIBLE + textVoiceChatContainer.visibility = GONE + } + } + } } } @@ -179,8 +235,12 @@ class ChatActivity : BaseBindingActivity() { companion object { - const val ACTOR_ID = "ACTOR_ID" + const val MODE_TEXT = 1 + const val MODE_VOICE = 2 + const val MODE_CALL = 3 + + const val ACTOR_ID = "ACTOR_ID" fun start(actorId: Int) { ARouter.getInstance() .build(Routers.CHAT) @@ -275,4 +335,5 @@ class ChatActivity : BaseBindingActivity() { } + } \ No newline at end of file diff --git a/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/InputPanel.kt b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/InputPanel.kt index 50dce26..5e32a5e 100644 --- a/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/InputPanel.kt +++ b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/InputPanel.kt @@ -6,10 +6,11 @@ import android.graphics.Point import android.util.AttributeSet import android.view.MotionEvent import android.widget.FrameLayout -import android.widget.Toast import com.dylanc.viewbinding.nonreflection.inflate import com.remax.visualnovel.R import com.remax.visualnovel.databinding.ChatInputpanelBinding +import com.remax.visualnovel.ui.chat.ChatActivity.Companion.MODE_TEXT +import com.remax.visualnovel.ui.chat.ChatActivity.Companion.MODE_VOICE class InputPanel @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) @@ -17,10 +18,15 @@ class InputPanel @JvmOverloads constructor(context: Context, attrs: AttributeSet private var binding: ChatInputpanelBinding private var mMode = MODE_TEXT + private lateinit var mEventListener: IEventListener - companion object { - private const val MODE_TEXT = 1; - private const val MODE_VOICE = 2; + + interface IEventListener { + fun onEnterCall() + fun onEnterShortChat() + fun onSendText(content: CharSequence) + fun onMsgRvScroll2Bottom() + fun onCheckVipStatus() } @@ -29,10 +35,10 @@ class InputPanel @JvmOverloads constructor(context: Context, attrs: AttributeSet binding.run { chatPopMenu.setMenuList(mutableListOf( PopMenuIconView.MenuItem(R.mipmap.chat_ai_talk) { - Toast.makeText(context, "聊天", Toast.LENGTH_SHORT).show() + mEventListener.onEnterShortChat() }, PopMenuIconView.MenuItem(R.mipmap.chat_ai_phone) { - Toast.makeText(context, "通话", Toast.LENGTH_SHORT).show() + mEventListener.onEnterCall() } )) @@ -42,20 +48,24 @@ class InputPanel @JvmOverloads constructor(context: Context, attrs: AttributeSet ivChatSend.setOnClickListener { chatEditView.clearText() + mEventListener.onSendText(chatEditView.text as CharSequence) } - ivChatDownload.setOnClickListener { - // TODO + ivGotoBottom.setOnClickListener { + mEventListener.onMsgRvScroll2Bottom() } ivChatVip.setOnClickListener { - // TODO + mEventListener.onCheckVipStatus() } } switchMode(mMode) } + fun setEventListener(listener: IEventListener) { + this.mEventListener = listener + } private fun switchMode(newMode: Int) { if (newMode != mMode) { diff --git a/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/call/ChatCallView.kt b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/call/ChatCallView.kt new file mode 100644 index 0000000..aab3c8c --- /dev/null +++ b/VisualNovel/app/src/main/java/com/remax/visualnovel/ui/chat/call/ChatCallView.kt @@ -0,0 +1,48 @@ +package com.remax.visualnovel.ui.chat.call + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.LinearLayout +import com.remax.visualnovel.databinding.LayoutChatCallViewBinding + + +class ChatCallView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : LinearLayout(context, attrs, defStyleAttr) { + + private var mBinding: LayoutChatCallViewBinding + + private lateinit var mEventListener: IEventListener + + + interface IEventListener { + fun onExitCall() + } + + + init { + mBinding = LayoutChatCallViewBinding.inflate(LayoutInflater.from(context), this, true) + setupClickListeners() + } + + + + private fun setupClickListeners() { + with (mBinding) { + tvHangUp.setOnClickListener { + mEventListener.onExitCall() + } + } + } + + fun setEventListener(listener: IEventListener) { + mEventListener = listener + } + + + + +} \ No newline at end of file diff --git a/VisualNovel/app/src/main/res/drawable/bg_chat_call.xml b/VisualNovel/app/src/main/res/drawable/bg_chat_call.xml new file mode 100644 index 0000000..2859a46 --- /dev/null +++ b/VisualNovel/app/src/main/res/drawable/bg_chat_call.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/VisualNovel/app/src/main/res/layout/activity_actor_chat.xml b/VisualNovel/app/src/main/res/layout/activity_actor_chat.xml index e2079a7..d5a4031 100644 --- a/VisualNovel/app/src/main/res/layout/activity_actor_chat.xml +++ b/VisualNovel/app/src/main/res/layout/activity_actor_chat.xml @@ -32,25 +32,46 @@ app:layout_constraintBottom_toBottomOf="parent" > - - - + + + + + + + diff --git a/VisualNovel/app/src/main/res/layout/chat_inputpanel.xml b/VisualNovel/app/src/main/res/layout/chat_inputpanel.xml index aed35a4..40b92df 100644 --- a/VisualNovel/app/src/main/res/layout/chat_inputpanel.xml +++ b/VisualNovel/app/src/main/res/layout/chat_inputpanel.xml @@ -108,7 +108,7 @@ > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualNovel/app/src/main/res/raw/call_listening.json b/VisualNovel/app/src/main/res/raw/call_listening.json new file mode 100644 index 0000000..c391481 --- /dev/null +++ b/VisualNovel/app/src/main/res/raw/call_listening.json @@ -0,0 +1,137 @@ +{ + "v": "5.6.10", + "fr": 24, + "ip": 0, + "op": 16, + "w": 56, + "h": 36, + "nm": "voice", + "ddd": 0, + "assets": [], + "layers": [ + { + "ddd": 0, + "ind": 1, + "ty": 4, + "nm": "Bar 1", + "sr": 1, + "ks": { + "o": {"a": 0, "k": 100, "ix": 11}, + "r": {"a": 0, "k": 0, "ix": 10}, + "p": {"a": 0, "k": [10, 18, 0], "ix": 2}, + "a": {"a": 0, "k": [0, 0, 0], "ix": 1}, + "s": {"a": 0, "k": [100, 100, 100], "ix": 6} + }, + "ao": 0, + "shapes": [ + { + "ty": "gr", + "it": [ + { + "ty": "rc", + "p": {"a": 0, "k": [0, 0], "ix": 3}, + "s": {"a": 0, "k": [6, 24], "ix": 2}, + "r": {"a": 0, "k": 3, "ix": 4} + }, + { + "ty": "fl", + "c": {"a": 0, "k": [0.227, 0.808, 0.337, 1], "ix": 4} + }, + { + "ty": "tr", + "p": {"a": 0, "k": [0, 0], "ix": 2}, + "a": {"a": 0, "k": [0, 0], "ix": 1}, + "s": {"a": 0, "k": [100, 100], "ix": 3}, + "r": {"a": 0, "k": 0, "ix": 6} + } + ], + "nm": "Bar Shape" + } + ], + "ip": 0, "op": 16, "st": 0, "bm": 0 + }, + { + "ddd": 0, + "ind": 2, + "ty": 4, + "nm": "Bar 2", + "sr": 1, + "ks": { + "o": {"a": 0, "k": 100, "ix": 11}, + "r": {"a": 0, "k": 0, "ix": 10}, + "p": {"a": 0, "k": [28, 18, 0], "ix": 2}, + "a": {"a": 0, "k": [0, 0, 0], "ix": 1}, + "s": {"a": 0, "k": [100, 100, 100], "ix": 6} + }, + "ao": 0, + "shapes": [ + { + "ty": "gr", + "it": [ + { + "ty": "rc", + "p": {"a": 0, "k": [0, 0], "ix": 3}, + "s": {"a": 0, "k": [6, 24], "ix": 2}, + "r": {"a": 0, "k": 3, "ix": 4} + }, + { + "ty": "fl", + "c": {"a": 0, "k": [0.227, 0.808, 0.337, 1], "ix": 4} + }, + { + "ty": "tr", + "p": {"a": 0, "k": [0, 0], "ix": 2}, + "a": {"a": 0, "k": [0, 0], "ix": 1}, + "s": {"a": 0, "k": [100, 100], "ix": 3}, + "r": {"a": 0, "k": 0, "ix": 6} + } + ], + "nm": "Bar Shape" + } + ], + "ip": 0, "op": 16, "st": 0, "bm": 0 + }, + { + "ddd": 0, + "ind": 3, + "ty": 4, + "nm": "Bar 3", + "sr": 1, + "ks": { + "o": {"a": 0, "k": 100, "ix": 11}, + "r": {"a": 0, "k": 0, "ix": 10}, + "p": {"a": 0, "k": [46, 18, 0], "ix": 2}, + "a": {"a": 0, "k": [0, 0, 0], "ix": 1}, + "s": {"a": 0, "k": [100, 100, 100], "ix": 6} + }, + "ao": 0, + "shapes": [ + { + "ty": "gr", + "it": [ + { + "ty": "rc", + "p": {"a": 0, "k": [0, 0], "ix": 3}, + "s": {"a": 0, "k": [6, 24], "ix": 2}, + "r": {"a": 0, "k": 3, "ix": 4} + }, + { + "ty": "fl", + "c": {"a": 0, "k": [0.227, 0.808, 0.337, 1], "ix": 4} + }, + { + "ty": "tr", + "p": {"a": 0, "k": [0, 0], "ix": 2}, + "a": {"a": 0, "k": [0, 0], "ix": 1}, + "s": {"a": 0, "k": [100, 100], "ix": 3}, + "r": {"a": 0, "k": 0, "ix": 6} + } + ], + "nm": "Bar Shape" + } + ], + "ip": 0, "op": 16, "st": 0, "bm": 0 + } + ], + "markers": [] +} \ No newline at end of file diff --git a/VisualNovel/app/src/main/res/values/colors.xml b/VisualNovel/app/src/main/res/values/colors.xml index 72ffb90..0ac51fa 100644 --- a/VisualNovel/app/src/main/res/values/colors.xml +++ b/VisualNovel/app/src/main/res/values/colors.xml @@ -192,6 +192,7 @@ #ff666666 #ff999999 #fff6f6f6 + #ff282828 #F6F6F6 @@ -208,6 +209,7 @@ #ff4876c9 #ffe5c4ff #ffc7dbff + #66eaeeff diff --git a/VisualNovel/app/src/main/res/values/strings.xml b/VisualNovel/app/src/main/res/values/strings.xml index bd289aa..3722d81 100644 --- a/VisualNovel/app/src/main/res/values/strings.xml +++ b/VisualNovel/app/src/main/res/values/strings.xml @@ -483,5 +483,7 @@ Chat buttle Unlocked Chat Mode + Connecting... + Network connection issue. Please check your connection and try again. \ No newline at end of file