diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/AIAssist.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/AIAssist.java
index b88f42196d..4d87c8b577 100644
--- a/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/AIAssist.java
+++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/voice/AIAssist.java
@@ -3,6 +3,7 @@ package com.mogo.commons.voice;
import android.content.Context;
import com.alibaba.android.arouter.launcher.ARouter;
+import com.mogo.eagle.core.utilcode.util.ToastUtils;
import com.mogo.tts.base.IMogoTTS;
import com.mogo.tts.base.MogoTTSConstants;
import com.mogo.tts.base.PreemptType;
@@ -46,7 +47,12 @@ public class AIAssist {
private AIAssist( Context context ) {
- mTTS = ( IMogoTTS ) ARouter.getInstance().build( MogoTTSConstants.API_PATH ).navigation( context.getApplicationContext() );
+ try {
+ mTTS = ( IMogoTTS ) ARouter.getInstance().build( MogoTTSConstants.API_PATH ).navigation( context.getApplicationContext() );
+ } catch (Exception e) {
+ e.printStackTrace();
+ ToastUtils.showShort("TTS 模块初始化异常");
+ }
}
/**
diff --git a/gradle.properties b/gradle.properties
index 6d32052ada..38e83a1ca9 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -37,7 +37,7 @@ kapt.include.compile.classpath=false
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
-android.jetifier.blacklist=module-service-2.1.10.aar
+android.jetifier.blacklist=module-service-2.1.12.aar
## maven 配置
RELEASE_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-releases/
SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
@@ -89,102 +89,102 @@ applicationName=IntelligentPilot
versionCode=80007
versionName=8.0.15
################# 新架构模块Maven版本管理 #################
-MOGO_CORE_FUNCTION_AUTOPILOT_VERSION=0.0.52
-MOGO_CORE_FUNCTION_CHECK_VERSION=0.0.52
-MOGO_CORE_FUNCTION_HMI_VERSION=0.0.52
-MOGO_CORE_FUNCTION_MAIN_VERSION=0.0.52
-MOGO_CORE_FUNCTION_MAP_VERSION=0.0.52
-MOGO_CORE_FUNCTION_MONITORING_VERSION=0.0.52
-MOGO_CORE_FUNCTION_NOTICE_VERSION=0.0.52
-MOGO_CORE_FUNCTION_OBU_MOGO_VERSION=0.0.52
-MOGO_CORE_FUNCTION_SMP_VERSION=0.0.52
-MOGO_CORE_FUNCTION_V2X_VERSION=0.0.52
-MOGO_CORE_DATA_VERSION=0.0.52
-MOGO_CORE_FUNCTION_API_VERSION=0.0.52
-MOGO_CORE_FUNCTION_CALL_VERSION=0.0.52
-MOGO_CORE_RES_VERSION=0.0.52
-MOGO_CORE_UTILS_VERSION=0.0.52
-MOGO_CORE_NETWORK_VERSION=0.0.52
+MOGO_CORE_FUNCTION_AUTOPILOT_VERSION=0.0.54
+MOGO_CORE_FUNCTION_CHECK_VERSION=0.0.54
+MOGO_CORE_FUNCTION_HMI_VERSION=0.0.54
+MOGO_CORE_FUNCTION_MAIN_VERSION=0.0.54
+MOGO_CORE_FUNCTION_MAP_VERSION=0.0.54
+MOGO_CORE_FUNCTION_MONITORING_VERSION=0.0.54
+MOGO_CORE_FUNCTION_NOTICE_VERSION=0.0.54
+MOGO_CORE_FUNCTION_OBU_MOGO_VERSION=0.0.54
+MOGO_CORE_FUNCTION_SMP_VERSION=0.0.54
+MOGO_CORE_FUNCTION_V2X_VERSION=0.0.54
+MOGO_CORE_DATA_VERSION=0.0.54
+MOGO_CORE_FUNCTION_API_VERSION=0.0.54
+MOGO_CORE_FUNCTION_CALL_VERSION=0.0.54
+MOGO_CORE_RES_VERSION=0.0.54
+MOGO_CORE_UTILS_VERSION=0.0.54
+MOGO_CORE_NETWORK_VERSION=0.0.54
################# 旧版本架构模块版本 #################
## 工程内模块
-MOGO_COMMONS_VERSION=2.1.10
-MOGO_UTILS_VERSION=2.1.10
-MAP_AMAP_VERSION=2.1.10
-MAP_AUTONAVI_VERSION=2.1.10
-MOGO_MAP_VERSION=2.1.10
-MOGO_MAP_API_VERSION=2.1.10
-MOGO_SERVICE_VERSION=2.1.10
-MOGO_SERVICE_API_VERSION=2.1.10
-MOGO_CONNECTION_VERSION=2.1.10
-MOGO_MODULE_APPS_VERSION=2.1.10
-MOGO_MODULE_NAVI_VERSION=2.1.10
-MOGO_MODULE_SHARE_VERSION=2.1.10
-MOGO_MODULE_COMMON_VERSION=2.1.10
-MOGO_MODULE_MAIN_VERSION=2.1.10
-MOGO_MODULE_MAP_VERSION=2.1.10
-MOGO_MODULE_SERVICE_VERSION=2.1.10
-MOGO_MODULE_EXTENSIONS_VERSION=2.1.10
-MOGO_MODULE_SEARCH_VERSION=2.1.10
-MOGO_MODULE_BACK_VERSION=2.1.10
-MOGO_MODULE_V2X_VERSION=2.1.10
+MOGO_COMMONS_VERSION=2.1.12
+MOGO_UTILS_VERSION=2.1.12
+MAP_AMAP_VERSION=2.1.12
+MAP_AUTONAVI_VERSION=2.1.12
+MOGO_MAP_VERSION=2.1.12
+MOGO_MAP_API_VERSION=2.1.12
+MOGO_SERVICE_VERSION=2.1.12
+MOGO_SERVICE_API_VERSION=2.1.12
+MOGO_CONNECTION_VERSION=2.1.12
+MOGO_MODULE_APPS_VERSION=2.1.12
+MOGO_MODULE_NAVI_VERSION=2.1.12
+MOGO_MODULE_SHARE_VERSION=2.1.12
+MOGO_MODULE_COMMON_VERSION=2.1.12
+MOGO_MODULE_MAIN_VERSION=2.1.12
+MOGO_MODULE_MAP_VERSION=2.1.12
+MOGO_MODULE_SERVICE_VERSION=2.1.12
+MOGO_MODULE_EXTENSIONS_VERSION=2.1.12
+MOGO_MODULE_SEARCH_VERSION=2.1.12
+MOGO_MODULE_BACK_VERSION=2.1.12
+MOGO_MODULE_V2X_VERSION=2.1.12
# 探路
-MOGO_MODULE_TANLU_VERSION=2.1.10
+MOGO_MODULE_TANLU_VERSION=2.1.12
# 推送
-MOGO_MODULE_PUSH_VERSION=2.1.10
-MOGO_MODULE_PUSH_BASE_VERSION=2.1.10
-MOGO_MODULE_PUSH_NOOP_VERSION=2.1.10
+MOGO_MODULE_PUSH_VERSION=2.1.12
+MOGO_MODULE_PUSH_BASE_VERSION=2.1.12
+MOGO_MODULE_PUSH_NOOP_VERSION=2.1.12
# 探路上报和分享模块
-TANLULIB_VERSION=2.1.10
-MOGO_TANLU_API_VERSION=2.1.10
+TANLULIB_VERSION=2.1.12
+MOGO_TANLU_API_VERSION=2.1.12
#左侧面板模块
-MOGO_MODULE_LEFT_PANEL_VERSION=2.1.10
-MOGO_MODULE_LEFT_PANEL_NOOP_VERSION=2.1.10
+MOGO_MODULE_LEFT_PANEL_VERSION=2.1.12
+MOGO_MODULE_LEFT_PANEL_NOOP_VERSION=2.1.12
# 小控件
-MOGO_MODULE_WIDGETS_VERSION=2.1.10
+MOGO_MODULE_WIDGETS_VERSION=2.1.12
# obu
-MOGO_MODULE_OBU_VERSION=2.1.10
-MOGO_MODULE_OBU_MOGO_VERSION=2.1.10
+MOGO_MODULE_OBU_VERSION=2.1.12
+MOGO_MODULE_OBU_MOGO_VERSION=2.1.12
# monitor
-MOGO_MODULE_MONITOR_VERSION=2.1.10
+MOGO_MODULE_MONITOR_VERSION=2.1.12
# bugly
-CRASHREPORT_VERSION=2.1.10
-CRASHREPORT_BUGLY_VERSION=2.1.10
-CRASHREPORT_NOOP_VERSION=2.1.10
-CRASHREPORT_UPGRADE_VERSION=2.1.10
+CRASHREPORT_VERSION=2.1.12
+CRASHREPORT_BUGLY_VERSION=2.1.12
+CRASHREPORT_NOOP_VERSION=2.1.12
+CRASHREPORT_UPGRADE_VERSION=2.1.12
## tts
-TTS_BASE_VERSION=2.1.10
-TTS_DI_VERSION=2.1.10
-TTS_ZHI_VERSION=2.1.10
-TTS_PAD_VERSION=2.1.10
-TTS_NOOP_VERSION=2.1.10
+TTS_BASE_VERSION=2.1.12
+TTS_DI_VERSION=2.1.12
+TTS_ZHI_VERSION=2.1.12
+TTS_PAD_VERSION=2.1.12
+TTS_NOOP_VERSION=2.1.12
# 自研地图
-MAP_CUSTOM_VERSION=2.1.10
-MOGO_MODULE_ADAS_VERSION=2.1.10
+MAP_CUSTOM_VERSION=2.1.12
+MOGO_MODULE_ADAS_VERSION=2.1.12
# 基础服务实现:passport、socket、location
-MOGO_BASE_WEBSOCKET_SDK_VERSION=2.1.10
-MOGO_BASE_SERVICES_APK_VERSION=2.1.10
-MOGO_BASE_SERVICES_SDK_VERSION=2.1.10
-MOGO_MODULE_CHAT_VERSION=2.1.10
+MOGO_BASE_WEBSOCKET_SDK_VERSION=2.1.12
+MOGO_BASE_SERVICES_APK_VERSION=2.1.12
+MOGO_BASE_SERVICES_SDK_VERSION=2.1.12
+MOGO_MODULE_CHAT_VERSION=2.1.12
# 车聊聊
-MOGO_MODULE_CARCHATTING_VERSION=2.1.10
+MOGO_MODULE_CARCHATTING_VERSION=2.1.12
# 车聊聊接口
-MOGO_MODULE_CARCHATTINGPROVIDER_VERSION=2.1.10
+MOGO_MODULE_CARCHATTINGPROVIDER_VERSION=2.1.12
# 皮肤
-MOGO_SKIN_SUPPORT_VERSION=2.1.10
-MOGO_SKIN_LIGHT_VERSION=2.1.10
-MOGO_SKIN_SUPPORT_IMPL_VERSION=2.1.10
-MOGO_SKIN_SUPPORT_NOOP_VERSION=2.1.10
-SKIN_SUPPORT_VERSION=2.1.10
-SKIN_SUPPORT_APPCOMPAT_VERSION=2.1.10
-SKIN_SUPPORT_CARDVIEW_VERSION=2.1.10
-SKIN_SUPPORT_CONSTRAINT_LAYOUT_VERSION=2.1.10
-SKIN_SUPPORT_DESIGN_VERSION=2.1.10
+MOGO_SKIN_SUPPORT_VERSION=2.1.12
+MOGO_SKIN_LIGHT_VERSION=2.1.12
+MOGO_SKIN_SUPPORT_IMPL_VERSION=2.1.12
+MOGO_SKIN_SUPPORT_NOOP_VERSION=2.1.12
+SKIN_SUPPORT_VERSION=2.1.12
+SKIN_SUPPORT_APPCOMPAT_VERSION=2.1.12
+SKIN_SUPPORT_CARDVIEW_VERSION=2.1.12
+SKIN_SUPPORT_CONSTRAINT_LAYOUT_VERSION=2.1.12
+SKIN_SUPPORT_DESIGN_VERSION=2.1.12
# OCH
-MOGO_OCH_VERSION=2.1.10-test
+MOGO_OCH_VERSION=2.1.12-test
MOGO_OCH_BUS_VERSION=2.0.66
MOGO_OCH_NOOP_VERSION=2.0.66
MOGO_OCH_TAXI_VERSION=2.0.66
# mogoAiCloud sdk services
-MOGO_AICLOUD_SERVICES_SDK_VERSION=2.1.10
+MOGO_AICLOUD_SERVICES_SDK_VERSION=2.1.12
################# 旧版本架构模块版本 #################
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/TextWatcherAdapter.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/TextWatcherAdapter.java
deleted file mode 100644
index 469b5f538d..0000000000
--- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/TextWatcherAdapter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.mogo.module.common;
-
-import android.text.Editable;
-import android.text.TextWatcher;
-
-/**
- * @author congtaowang
- * @since 2019-10-02
- *
- * 描述
- */
-public class TextWatcherAdapter implements TextWatcher {
-
- @Override
- public void beforeTextChanged( CharSequence s, int start, int count, int after ) {
-
- }
-
- @Override
- public void onTextChanged( CharSequence s, int start, int before, int count ) {
-
- }
-
- @Override
- public void afterTextChanged( Editable s ) {
-
- }
-}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/dialog/BaseFloatDialog.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/dialog/BaseFloatDialog.java
index 67fa1b3b64..6fa4d7d6e0 100644
--- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/dialog/BaseFloatDialog.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/dialog/BaseFloatDialog.java
@@ -34,11 +34,11 @@ public class BaseFloatDialog extends Dialog {
private void addFlag() {
// TODO 这里需要申请悬浮床权限
-// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
-// getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
-// } else {
-// getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
-// }
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
+ } else {
+ getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
+ }
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
| WindowManager.LayoutParams.FLAG_LOCAL_FOCUS_MODE);
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java
index 99a93a83ca..79d0e2993c 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java
@@ -31,7 +31,6 @@ import com.mogo.map.location.IMogoLocationListener;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.api.CallChatApi;
-import com.mogo.module.common.enums.EventTypeEnum;
import com.mogo.module.common.map.MapCenterPointStrategy;
import com.mogo.module.common.map.Scene;
import com.mogo.module.main.cards.MogoModulesManager;
@@ -132,14 +131,14 @@ public class MainActivity extends MvpActivity implement
if (CallChatApi.getInstance().getApiProvider() != null) {
CallChatApi.getInstance().getApiProvider().initVehicleTeamContainer("init", R.id.module_main_id_message_history_fragment_container, this);
}
-// //申请悬浮窗权限
-// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-// // 检查是否有悬浮窗权限
-// if (Settings.canDrawOverlays(this)) {
-// return;
-// }
-// PermissionsDialogUtils.openAppDetails(this, "显示悬浮窗", REQUEST_CODE_DIALOG);
-// }
+ //申请悬浮窗权限
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ // 检查是否有悬浮窗权限
+ if (Settings.canDrawOverlays(this)) {
+ return;
+ }
+ PermissionsDialogUtils.openAppDetails(this, "显示悬浮窗", REQUEST_CODE_DIALOG);
+ }
}
// 隐藏布局
diff --git a/modules/mogo-module-push/src/main/java/com/mogo/module/push/view/FloatViewOrigin.kt b/modules/mogo-module-push/src/main/java/com/mogo/module/push/view/FloatViewOrigin.kt
deleted file mode 100644
index 703f4affd1..0000000000
--- a/modules/mogo-module-push/src/main/java/com/mogo/module/push/view/FloatViewOrigin.kt
+++ /dev/null
@@ -1,568 +0,0 @@
-package com.mogo.module.push.view
-
-import android.animation.Animator
-import android.animation.ObjectAnimator
-import android.annotation.SuppressLint
-import android.content.Context
-import android.graphics.PixelFormat
-import android.os.Build
-import android.os.Handler
-import android.os.Looper
-import android.view.*
-import android.widget.FrameLayout
-import android.widget.ImageView
-import android.widget.Scroller
-import android.widget.TextView
-import androidx.annotation.LayoutRes
-import androidx.core.animation.doOnEnd
-import androidx.core.view.isVisible
-import com.elegant.analytics.utils.Logger
-import com.mogo.commons.voice.AIAssist
-import com.mogo.module.push.Config
-import com.mogo.module.push.R
-import com.mogo.module.push.model.PushBean
-import com.mogo.module.push.utils.AnalyticsUtils
-import com.mogo.module.push.utils.stringConverterBitmap
-import com.mogo.module.push.view.roundimage.RoundedImageView
-import com.mogo.module.push.viewmodel.PushViewModel
-import com.mogo.service.windowview.IMogoTopViewManager
-import com.mogo.service.windowview.IMogoTopViewStatusListener
-import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper
-import com.mogo.utils.ThreadPoolService
-import com.mogo.utils.UiThreadHandler
-import com.mogo.utils.glide.GlideApp
-
-class FloatViewOrigin constructor(
- private val pushViewModel: PushViewModel,
- private val context: Context
-) {
-
- companion object {
- const val TYPE_TOP_VIEW = 1
- const val TYPE_WINDOW_MANAGER = 2
- const val TAG: String = "FloatViewOrigin.kt"
- }
-
- interface PushViewController {
- fun show(bean: PushBean?)
- fun hide()
- fun timer(time: Int)
- fun inflateView(@LayoutRes layoutId: Int)
- }
-
- abstract inner class PushViewOrigin(context: Context) : FrameLayout(context),
- PushViewController {
- private lateinit var appIcon: ImageView
- private lateinit var titleIconContainer: View
- private lateinit var pushTitle: TextView
- private lateinit var pushImage: RoundedImageView
- private lateinit var pushContent: TextView
- private lateinit var pushTimer: TextView
- private lateinit var pushButtonLeft: TextView
- private lateinit var pushButtonRight: TextView
- lateinit var pushButton: View
-
- override fun inflateView(layoutId: Int) {
- LayoutInflater.from(context).inflate(layoutId, this, true)
- appIcon = findViewById(R.id.module_push_app_icon)
- pushTitle = findViewById(R.id.module_push_title)
- pushImage = findViewById(R.id.module_push_image)
- pushContent = findViewById(R.id.module_push_content)
- pushButtonLeft = findViewById(R.id.module_push_button_left)
- pushButtonRight = findViewById(R.id.module_push_button_right)
- pushTimer = findViewById(R.id.module_push_timer)
- titleIconContainer = findViewById(R.id.module_push_app_icon_title)
- pushButton = findViewById(R.id.module_push_buttons)
- setOnClickListener {
- pushViewModel.dealCmd(PushViewModel.VOICE_ACTION_PUSH_MAIN, "1")
- turnNextMessage()
- }
- pushButtonLeft.setOnClickListener {
- pushViewModel.dealCmd(PushViewModel.VOICE_ACTION_PUSH_LEFT, "1")
- turnNextMessage()
- }
- pushButtonRight.setOnClickListener {
- pushViewModel.dealCmd(PushViewModel.VOICE_ACTION_PUSH_RIGHT, "1")
- turnNextMessage()
- }
- }
-
- private fun turnNextMessage() {
- pushViewModel.pushBean?.apply {
- showTimeout = 0
- updateTimer()
- }
- }
-
- fun hasButtons(bean: PushBean?): Boolean {
- bean?.buttons?.forEach {
- if (it.text.isNotEmpty()) {
- return true
- }
- }
- return false
- }
-
- fun hasTextContent(bean: PushBean?): Boolean =
- bean?.content?.isEmpty()?.not() ?: false
-
- fun hasImgContent(bean: PushBean?): Boolean = bean?.QRCode?.isEmpty()?.not() ?: false
-
- open fun setBean(bean: PushBean) {
- // app icon
- if (bean.appIcon.isNotEmpty()) {
- appIcon.visible()
- GlideApp.with(this).load(bean.appIcon).into(appIcon)
- } else {
- appIcon.gone()
- }
-
- // title
- pushTitle.text = bean.title
-
- // decrease timer
- pushTimer.text = if (bean.showTimeout > 99) "" else "${bean.showTimeout}s"
-
- // image
- if (bean.imageUrl.isEmpty() && bean.QRCode.isEmpty()) {
- pushImage.gone()
- } else if (bean.imageUrl.isNotEmpty()) {
- val params = pushImage.layoutParams
- params.width = getImgWidth()
- params.height = getImgHeight()
- pushImage.layoutParams = params
- pushImage.visible()
- GlideApp.with(this).load(bean.imageUrl).into(pushImage)
- } else if (bean.QRCode.isNotEmpty()) {
- val params = pushImage.layoutParams
- params.width = getQrImgWidth()
- params.height = getQrImgHeight()
- pushImage.layoutParams = params
- ThreadPoolService.execute {
- val bmp = stringConverterBitmap(
- bean.QRCode,
- getQrImgWidth(),
- getQrImgHeight()
- )
- UiThreadHandler.post {
- pushImage.setImageBitmap(bmp)
- pushImage.visible()
- }
- }
- }
-
- // button
- pushButton.gone()
- pushButtonLeft.gone()
- pushButtonRight.gone()
- if (!bean.buttons.isNullOrEmpty()) {
- if (bean.buttons[0].text.isNotEmpty()) {
- pushButton.visible()
- pushButtonLeft.text = bean.buttons[0].text
- pushButtonLeft.visible()
- }
- if (bean.buttons.size > 1 && bean.buttons[1].text.isNotEmpty()) {
- pushButtonRight.text = bean.buttons[1].text
- pushButtonRight.visible()
- }
- }
-
- // content
- if (bean.content.isEmpty()) {
- pushContent.gone()
- } else {
- pushContent.text = bean.content
- pushContent.visible()
- }
-
- // tts
- if (bean.tts.isNotEmpty()) {
- AIAssist.getInstance(context).speakTTSVoice(bean.tts)
- }
- }
-
- abstract fun getImgWidth(): Int
- abstract fun getImgHeight(): Int
- abstract fun getQrImgWidth(): Int
- abstract fun getQrImgHeight(): Int
-
- @SuppressLint("SetTextI18n")
- override fun timer(time: Int) {
- Logger.d(TAG, "time = $time")
- pushTimer.text = "${time}s"
- }
-
- override fun show(bean: PushBean?) {
- isAddWindow = true
- uiHandler.removeCallbacks(delayClosePush)
- }
-
- override fun hide() {
- isAddWindow = false
- }
- }
-
- open inner class PushViewInTopView(context: Context) : PushViewOrigin(context) {
-
- private val mTopViewManager: IMogoTopViewManager = getApis(context).topViewManager
-
- init {
- inflateView(R.layout.module_push_item_origin)
- }
-
- private var topViewStatusListener = object : IMogoTopViewStatusListener {
- override fun onViewRemoved(view: View?) {
- isAddWindow = false
- if (pushViewModel.pushBean?.showTimeout ?: 0 > 0) {
- if (getApis(context).statusManagerApi.isV2XShow) {
- // 被中断的消息,需要再次被显示一次
- uiHandler.removeCallbacks(delayClosePush)
- pushViewModel.push()
- pushViewModel.pushMessageFinish()
- return
- }
- }
- pushViewModel.pushBean?.showTimeout = 0
- updateTimer()
- }
-
- override fun onViewAdded(view: View?) {
- if (pushViewModel.pushBean != null) {
- startClosePush()
- }
- }
-
- override fun beforeViewRemoveAnim(view: View?) {
- }
-
- override fun beforeViewAddAnim(view: View?) {
- }
- }
-
- override fun show(bean: PushBean?) {
- super.show(bean)
- mLastVisibleType = TYPE_TOP_VIEW
- mTopViewManager.addView(this, topViewStatusListener)
- setBean(bean!!)
- }
-
- override fun hide() {
- super.hide()
- mTopViewManager.removeView(this)
- }
-
- override fun getImgWidth(): Int =
- context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_width)
-
- override fun getImgHeight(): Int =
- context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
-
- override fun getQrImgWidth(): Int =
- context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
-
- override fun getQrImgHeight(): Int =
- context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
- }
-
- inner class PushViewInWindowView(context: Context) : PushViewOrigin(context), View.OnTouchListener {
-
- private val mContentContainer: View
- private val mWindowManager =
- context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
-
- private val params = WindowManager.LayoutParams()
-
- init {
-
- @Suppress("DEPRECATION")
- params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
- params.flags = (WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
- or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
- or WindowManager.LayoutParams.FLAG_LOCAL_FOCUS_MODE
- or WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
- or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
- params.width = WindowManager.LayoutParams.WRAP_CONTENT
- params.height = WindowManager.LayoutParams.WRAP_CONTENT
- params.gravity = Gravity.START or Gravity.BOTTOM
- params.format = PixelFormat.TRANSLUCENT
- params.x = context.resources.getDimensionPixelSize(R.dimen.module_push_window_x)
- params.y = context.resources.getDimensionPixelSize(R.dimen.module_push_window_x)
- if (Build.VERSION.SDK_INT > 25) {
- params.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
- }
-
- inflateView(R.layout.module_push_item_vertical)
- mContentContainer = findViewById(R.id.module_push_content_container)
- setOnTouchListener(this)
- }
-
- override fun show(bean: PushBean?) {
- super.show(bean)
- mLastVisibleType = TYPE_WINDOW_MANAGER
- setBean(bean!!)
-
- try {
- mWindowManager.addView(this, params)
- } catch (e: Exception) {
- mWindowManager.updateViewLayout(this, params)
- }
- translationXAnimation(
- -ResourcesHelper.getDimension(context, R.dimen.module_push_ui_width_vertical),
- 0f
- ) {
- if (pushViewModel.pushBean != null) {
- startClosePush()
- }
- }
- }
-
- private fun translationXAnimation(
- from: Float,
- to: Float,
- doOnEnd: (animator: Animator) -> Unit
- ) {
- val transitionXAnimator: ObjectAnimator =
- ObjectAnimator.ofFloat(
- this,
- View.TRANSLATION_X,
- from,
- to
- )
- transitionXAnimator.duration = 200
- transitionXAnimator.doOnEnd(doOnEnd)
- transitionXAnimator.start()
- }
-
- override fun setBean(bean: PushBean) {
- super.setBean(bean)
- var paddingBottom = 0
- if (pushButton.isVisible) {
- paddingBottom =
- context.resources.getDimensionPixelSize(R.dimen.module_push_content_paddingBottom_vertical)
- }
- mContentContainer.setPadding(0, 0, 0, paddingBottom)
- }
-
- override fun hide() {
- super.hide()
- translationXAnimation(
- this.x,
- -ResourcesHelper.getDimension(context, R.dimen.module_push_ui_width_vertical)
- ) {
- Logger.d(TAG, "here")
- this.x = 0f
- mWindowManager.removeViewImmediate(this)
- }
- }
-
- override fun onTouch(v: View?, ev: MotionEvent?): Boolean {
-
- if (mLastVisibleType != TYPE_WINDOW_MANAGER) {
- return false
- }
- when (ev?.action) {
- MotionEvent.ACTION_DOWN -> {
- needInterceptClick = false
- startX = ev.x
- }
- MotionEvent.ACTION_MOVE -> {
- moveX = startX - ev.x
- scrollBy(moveX.toInt(), 0)
- startX = ev.x
- if (scrollX < 0) {
- scrollTo(0, 0)
- }
- if (!needInterceptClick && scrollX > 20) {
- needInterceptClick = true
- }
- invalidate()
- }
- MotionEvent.ACTION_UP -> {
- if (scrollX > 0) {
- mScroller.startScroll(scrollX, 0, width - scrollX, 0)
- invalidate()
- return true
- }
- if (needInterceptClick) {
- return true
- }
- }
- else -> {
- startX = 0f
- moveX = 0f
- }
- }
- return false
- }
-
- override fun computeScroll() {
- if (mScroller.computeScrollOffset()) {
- scrollTo(mScroller.currX, mScroller.currY)
- invalidate()
- } else {
- if (mScroller.currX == 0) {
- return
- }
- mScroller.finalX = 0
- removeCallbacks(delayClosePush)
- if (isAddWindow) {
- if (currentBean != null) {
- AnalyticsUtils.track(Config.NEWS_CARD_SWIPE, "trigger_type", "1")
- }
- mWindowManager.removeView(this)
- isAddWindow = false
- }
- pushViewModel.pushBean?.showTimeout = 0
- updateTimer()
- }
- }
-
- override fun getImgWidth(): Int =
- context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_width_vertical)
-
- override fun getImgHeight(): Int =
- context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height_vertical)
-
- override fun getQrImgWidth(): Int =
- context.resources.getDimensionPixelSize(R.dimen.module_push_image_qr_size_vertical)
-
- override fun getQrImgHeight(): Int =
- context.resources.getDimensionPixelSize(R.dimen.module_push_image_qr_size_vertical)
- }
-
- private val delayClosePush: Runnable
- private var isAddWindow = false
- private val uiHandler = Handler(Looper.getMainLooper())
-
- private var startX = 0f
- private var moveX = 0f
- private val mScroller: Scroller = Scroller(context)
- private var needInterceptClick = false
- private var pause = false
-
- private var currentBean: PushBean? = null
-
-
- private var mLastVisibleType = -1
- private var pushViewController: PushViewController? = null
-
- init {
- delayClosePush = Runnable {
- updateTimer()
- }
- }
-
- fun pushBeanChanged(bean: PushBean?) {
- uiHandler.post {
- uiHandler.removeCallbacks(delayClosePush)
- if (bean == null) {
- if (currentBean != null) {
- AnalyticsUtils.track(Config.NEWS_CARD_DISAPPEAR, "title", currentBean!!.title)
- }
- hide()
- } else {
- show(bean)
- AnalyticsUtils.track(Config.NEWS_CARD_SHOW, "title", bean.title)
- }
- currentBean = bean
- }
- }
-
- private fun updateTimer() {
- uiHandler.removeCallbacks(delayClosePush)
- val time = pushViewModel.pushBean?.showTimeout ?: 0
- if (time > 0) {
- pushViewModel.pushBean!!.showTimeout--
- pushViewController?.timer(time)
- uiHandler.postDelayed(delayClosePush, 1000)
- } else {
- pushViewController?.timer(0)
- pushViewModel.pushMessageFinish(true)
- }
- }
-
- private fun show(bean: PushBean) {
- if (isAddWindow) {
- if (getApis(context).statusManagerApi.isMainPageOnResume) {
- if (mLastVisibleType != TYPE_TOP_VIEW) {
- hide()
- (pushViewController as View).postDelayed({
- show(bean)
- }, 750L)
- } else {
- showByTopView(bean)
- }
- } else {
- if (mLastVisibleType != TYPE_WINDOW_MANAGER) {
- hide()
- (pushViewController as View).postDelayed({
- show(bean)
- }, 750L)
- } else {
- showByWindowManager(bean)
- }
- }
- startClosePush()
- } else {
- if (getApis(context).statusManagerApi.isMainPageOnResume) {
- showByTopView(bean)
- } else {
- showByWindowManager(bean)
- }
- }
- }
-
- private fun showByTopView(bean: PushBean) {
- if (pushViewController !is PushViewInTopView) {
- pushViewController = PushViewInTopView(context)
- }
- pushViewController?.show(bean)
- }
-
- private fun showByWindowManager(bean: PushBean?) {
- if (pushViewController !is PushViewInWindowView) {
- pushViewController = PushViewInWindowView(context)
- }
- pushViewController?.show(bean)
- }
-
- private fun startClosePush() {
- uiHandler.removeCallbacks(delayClosePush)
- uiHandler.postDelayed(
- delayClosePush,
- 1000L
- )
- }
-
-
- fun hide() {
- if (!isAddWindow) {
- return
- }
- try {
- pushViewController?.hide()
- } catch (e: Exception) {
- e.printStackTrace()
- }
- }
-
-
- fun pauseTimer(on: Boolean) {
- if (on) {
- uiHandler.removeCallbacks(delayClosePush)
- } else {
- updateTimer()
- uiHandler.post {
- if (on) {
- pause = true
- uiHandler.removeCallbacks(delayClosePush)
- } else if (pause) {
- pause = false
- updateTimer()
- }
- }
- }
- }
-
- fun isAddWindow(): Boolean = isAddWindow
-}
\ No newline at end of file
diff --git a/tts/tts-pad/build.gradle b/tts/tts-pad/build.gradle
index 07f707c572..2d9319be5e 100644
--- a/tts/tts-pad/build.gradle
+++ b/tts/tts-pad/build.gradle
@@ -53,9 +53,11 @@ dependencies {
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
implementation rootProject.ext.dependencies.ttsbase
implementation rootProject.ext.dependencies.mogoutils
+ implementation rootProject.ext.dependencies.mogo_core_utils
} else {
implementation project(":tts:tts-base")
implementation project(":foudations:mogo-utils")
+ implementation project(':core:mogo-core-utils')
}
}
diff --git a/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java b/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java
index 49518e86f0..717229c0d5 100644
--- a/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java
+++ b/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java
@@ -24,6 +24,7 @@ import com.aispeech.lite.AuthType;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.cloud.commons.BuildConfig;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
+import com.mogo.eagle.core.utilcode.util.ToastUtils;
import com.mogo.tts.base.IMogoTTS;
import com.mogo.tts.base.IMogoTTSCallback;
import com.mogo.tts.base.MogoTTSConstants;
@@ -48,7 +49,7 @@ import java.util.concurrent.ConcurrentHashMap;
*
* 描述
*/
-@Route( path = MogoTTSConstants.API_PATH )
+@Route(path = MogoTTSConstants.API_PATH)
public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener {
private static final String TAG = "PadTTS";
@@ -59,12 +60,12 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
private Context mContext;
public synchronized void release() {
- Logger.d( TAG, "release" );
- if ( mCmdMap != null && !mCmdMap.isEmpty() && mVoiceClient != null ) {
- for ( String cmd : mCmdMap.keySet() ) {
+ Logger.d(TAG, "release");
+ if (mCmdMap != null && !mCmdMap.isEmpty() && mVoiceClient != null) {
+ for (String cmd : mCmdMap.keySet()) {
try {
- mVoiceClient.unRegisterCustomWakeupCmd( cmd );
- } catch ( Exception e ) {
+ mVoiceClient.unRegisterCustomWakeupCmd(cmd);
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -83,13 +84,13 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
private VoiceClient mVoiceClient;
private MogoVoiceManager mogoVoiceManager;
// 免唤醒指令
- private Map< String, List< IMogoTTSCallback > > mCmdMap = new HashMap<>();
+ private Map> mCmdMap = new HashMap<>();
// 问答指令
- private Map< String, IMogoTTSCallback > mQAndAMap = new HashMap<>();
+ private Map mQAndAMap = new HashMap<>();
// 单独的语音播放
- private Map< String, IMogoTTSCallback > mSpeakVoiceMap = new HashMap<>();
+ private Map mSpeakVoiceMap = new HashMap<>();
- private Map< String, String[] > mCacheUnWakeupCommands = new ConcurrentHashMap<>();
+ private Map mCacheUnWakeupCommands = new ConcurrentHashMap<>();
private static final String TTS_BACK_RES_ZHILING = "zhilingf_common_back_ce_local.v2.1.0.bin";
private int audioRecorderType = DUILiteConfig.TYPE_COMMON_MIC;
@@ -101,65 +102,70 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
public static final String TTS_BACK_RES_GUODGM = "tts/guodgm_common_back_ce_local.v2.1.0.bin";
private AILocalTTSEngine mEngine;
private AILocalTTSIntent mAILocalTTSIntent;
- private String[] mBackResBinArray = new String[]{TTS_BACK_RES_ZHILING,TTS_BACK_RES_GUODGM};
+ private String[] mBackResBinArray = new String[]{TTS_BACK_RES_ZHILING, TTS_BACK_RES_GUODGM};
// 单独的语音播放
private boolean mHasAuth;
private void initFlushStatus() {
- if ( !mHasFlush ) {
- mHasFlush = isVoiceServiceReady( mContext );
+ if (!mHasFlush) {
+ mHasFlush = isVoiceServiceReady(mContext);
}
}
private void initTtsConfig() {
- Logger.d(TAG, "initTtsConfig");
- //在线授权配置
- AuthConfig.Builder onlineBuilder = new AuthConfig.Builder()
- .setType(AuthType.ONLINE)
- .setCustomDeviceName(MoGoAiCloudClientConfig.getInstance().getSn());
+ try {
+ Logger.d(TAG, "initTtsConfig");
+ //在线授权配置
+ AuthConfig.Builder onlineBuilder = new AuthConfig.Builder()
+ .setType(AuthType.ONLINE)
+ .setCustomDeviceName(MoGoAiCloudClientConfig.getInstance().getSn());
- //echo 配置
- EchoConfig echoConfig = new EchoConfig.Builder()
- .setAecResource(ECHO_RES)// 2mic AEC资源
- .setChannels(2)//设置音频通道数
- .setMicNumber(1)//设置mic数
- .setSavedDirPath("/sdcard/aispeech/aecPcmFile/")//设置echo前后音频保存路径
- .create();
+ //echo 配置
+ EchoConfig echoConfig = new EchoConfig.Builder()
+ .setAecResource(ECHO_RES)// 2mic AEC资源
+ .setChannels(2)//设置音频通道数
+ .setMicNumber(1)//设置mic数
+ .setSavedDirPath("/sdcard/aispeech/aecPcmFile/")//设置echo前后音频保存路径
+ .create();
- if (BuildConfig.DEBUG){
- DUILiteSDK.openLog();//开启日志,需要在sdk init 之前调用
+ if (BuildConfig.DEBUG) {
+ DUILiteSDK.openLog();//开启日志,需要在sdk init 之前调用
+ }
+
+ DUILiteSDK.init(mContext, new DUILiteConfig.Builder()
+ .setApiKey("113cc31f6385113cc31f6385618c86f5")
+ .setProductId("278586132")
+ .setProductKey("1fe5930844b488a8d32d9ef7717be7dc")
+ .setProductSecret("f601ecc407986b548ac8ab2a9144162e")
+ .setAuthConfig(onlineBuilder.create())//授权配置
+ // .setRecorderConfig(recorderConfig)//设置录音配置
+ // .setUploadConfig(uploadConfig)//设置日志上传配置
+ // .setTtsCacheDir("/sdcard/speech/cache") //设置tts cache文件存放目录
+ .setEchoConfig(echoConfig)
+ .create(), new DUILiteSDK.InitListener() {
+ @Override
+ public void success() {
+ Logger.d(TAG, "授权成功");
+ mHasAuth = true;
+ initTtsEngine();
+ }
+
+ @Override
+ public void error(String errorCode, final String errorInfo) {
+ Logger.e(TAG, "error code : " + errorCode + " , error info :" + errorInfo);
+ // throw new IllegalStateException("授权失败,请检查授权配置");
+ }
+ });
+
+ boolean isAuthorized = DUILiteSDK.isAuthorized(mContext);//查询授权状态,DUILiteSDK.init之后随时可以调
+ Logger.d(TAG, "DUILite SDK is isAuthorized ? " + isAuthorized);
+
+ String core_version = DUILiteSDK.getCoreVersion();//获取内核版本号
+ Logger.d(TAG, "core version is: " + core_version);
+ } catch (Exception e) {
+ e.printStackTrace();
+ ToastUtils.showShort("PadTTS 模块初始化异常");
}
-
- DUILiteSDK.init(mContext, new DUILiteConfig.Builder()
- .setApiKey("113cc31f6385113cc31f6385618c86f5")
- .setProductId("278586132")
- .setProductKey("1fe5930844b488a8d32d9ef7717be7dc")
- .setProductSecret("f601ecc407986b548ac8ab2a9144162e")
- .setAuthConfig(onlineBuilder.create())//授权配置
-// .setRecorderConfig(recorderConfig)//设置录音配置
-// .setUploadConfig(uploadConfig)//设置日志上传配置
-// .setTtsCacheDir("/sdcard/speech/cache") //设置tts cache文件存放目录
- .setEchoConfig(echoConfig)
- .create(), new DUILiteSDK.InitListener() {
- @Override
- public void success() {
- Logger.d(TAG, "授权成功");
- mHasAuth = true;
- initTtsEngine();
- }
-
- @Override
- public void error(String errorCode, final String errorInfo) {
- Logger.e(TAG, "error code : " + errorCode + " , error info :" + errorInfo);
-// throw new IllegalStateException("授权失败,请检查授权配置");
- }
- });
-
- boolean isAuthorized = DUILiteSDK.isAuthorized(mContext);//查询授权状态,DUILiteSDK.init之后随时可以调
- Logger.d(TAG, "DUILite SDK is isAuthorized ? " + isAuthorized);
-
- String core_version = DUILiteSDK.getCoreVersion();//获取内核版本号
- Logger.d(TAG, "core version is: " + core_version);
}
private void initTtsEngine() {
@@ -212,10 +218,10 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
/**
* 初始化
*/
- private void initSpeech( Context context ) {
+ private void initSpeech(Context context) {
Logger.d(TAG, "initSpeech");
mogoVoiceManager = MogoVoiceManagerImpl.getInstance();
- mogoVoiceManager.init( context, new OnConnStatusListener() {
+ mogoVoiceManager.init(context, new OnConnStatusListener() {
@Override
public void onSuccess() {
mInitReady = true;
@@ -225,7 +231,7 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
public void onFailed() {
}
- } );
+ });
}
/**
@@ -239,78 +245,78 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
}
@Override
- public void onCmdSelected( String cmd ) {
- if ( !mCmdMap.containsKey( cmd ) ) {
+ public void onCmdSelected(String cmd) {
+ if (!mCmdMap.containsKey(cmd)) {
return;
}
- Logger.d( TAG, "received command: %s", cmd );
+ Logger.d(TAG, "received command: %s", cmd);
- Iterator< IMogoTTSCallback > iterator = null;
+ Iterator iterator = null;
try {
- List< IMogoTTSCallback > cmdCallBacks = mCmdMap.get( cmd );
- iterator = new ArrayList<>( cmdCallBacks ).iterator();
- } catch ( Exception e ) {
+ List cmdCallBacks = mCmdMap.get(cmd);
+ iterator = new ArrayList<>(cmdCallBacks).iterator();
+ } catch (Exception e) {
e.printStackTrace();
}
- while ( iterator != null && iterator.hasNext() ) {
+ while (iterator != null && iterator.hasNext()) {
IMogoTTSCallback callBack = iterator.next();
- if ( callBack != null ) {
- callBack.onCmdSelected( cmd );
+ if (callBack != null) {
+ callBack.onCmdSelected(cmd);
}
}
}
@Override
- public void onCmdAction( String speakText ) {
- if ( !TextUtils.isEmpty( mLastQAndASpeakText ) ) {
- IMogoTTSCallback cmdCallBack = mQAndAMap.remove( mLastQAndASpeakText );
- if ( cmdCallBack != null ) {
- cmdCallBack.onCmdAction( speakText );
+ public void onCmdAction(String speakText) {
+ if (!TextUtils.isEmpty(mLastQAndASpeakText)) {
+ IMogoTTSCallback cmdCallBack = mQAndAMap.remove(mLastQAndASpeakText);
+ if (cmdCallBack != null) {
+ cmdCallBack.onCmdAction(speakText);
}
}
}
@Override
- public void onCmdCancel( String speakText ) {
- if ( !TextUtils.isEmpty( mLastQAndASpeakText ) ) {
- IMogoTTSCallback cmdCallBack = mQAndAMap.remove( mLastQAndASpeakText );
- if ( cmdCallBack != null ) {
- cmdCallBack.onCmdCancel( speakText );
+ public void onCmdCancel(String speakText) {
+ if (!TextUtils.isEmpty(mLastQAndASpeakText)) {
+ IMogoTTSCallback cmdCallBack = mQAndAMap.remove(mLastQAndASpeakText);
+ if (cmdCallBack != null) {
+ cmdCallBack.onCmdCancel(speakText);
}
}
}
@Override
- public void onSpeakEnd( String speakText ) {
- if ( mQAndAMap.containsKey( speakText ) ) {
+ public void onSpeakEnd(String speakText) {
+ if (mQAndAMap.containsKey(speakText)) {
mLastQAndASpeakText = speakText;
- IMogoTTSCallback cmdCallBack = mQAndAMap.get( speakText );
- if ( cmdCallBack != null ) {
- cmdCallBack.onSpeakEnd( speakText );
+ IMogoTTSCallback cmdCallBack = mQAndAMap.get(speakText);
+ if (cmdCallBack != null) {
+ cmdCallBack.onSpeakEnd(speakText);
return;
}
}
- IMogoTTSCallback callBack = mSpeakVoiceMap.remove( speakText );
- if ( callBack != null ) {
- callBack.onSpeakEnd( speakText );
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove(speakText);
+ if (callBack != null) {
+ callBack.onSpeakEnd(speakText);
}
}
@Override
- public void onSpeakSelectTimeOut( String speakText ) {
- if ( mQAndAMap.containsKey( speakText ) ) {
- if ( TextUtils.equals( speakText, mLastQAndASpeakText ) ) {
+ public void onSpeakSelectTimeOut(String speakText) {
+ if (mQAndAMap.containsKey(speakText)) {
+ if (TextUtils.equals(speakText, mLastQAndASpeakText)) {
mLastQAndASpeakText = null;
}
- IMogoTTSCallback cmdCallBack = mQAndAMap.remove( speakText );
- if ( cmdCallBack != null ) {
- cmdCallBack.onSpeakSelectTimeOut( speakText );
+ IMogoTTSCallback cmdCallBack = mQAndAMap.remove(speakText);
+ if (cmdCallBack != null) {
+ cmdCallBack.onSpeakSelectTimeOut(speakText);
return;
}
}
- IMogoTTSCallback callBack = mSpeakVoiceMap.remove( speakText );
- if ( callBack != null ) {
- callBack.onSpeakSelectTimeOut( speakText );
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove(speakText);
+ if (callBack != null) {
+ callBack.onSpeakSelectTimeOut(speakText);
}
}
@@ -319,7 +325,7 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
*
* @param text
*/
- public void speakTTSVoice( String text, IMogoTTSCallback callBack ) {
+ public void speakTTSVoice(String text, IMogoTTSCallback callBack) {
speakTTSVoice(text);
// try {
// initFlushStatus();
@@ -337,11 +343,11 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
*
* @param text
*/
- public void speakTTSVoice( String text ) {
- Logger.d( TAG, "speakTTSVoice");
+ public void speakTTSVoice(String text) {
+ Logger.d(TAG, "speakTTSVoice");
if (mEngine != null && mHasAuth) {
// 合成并播放
- mEngine.speak(text,"1024",mAILocalTTSIntent);
+ mEngine.speak(text, "1024", mAILocalTTSIntent);
// 合成音频,不播放,同时输出实时pcm音频,音频回调在onSynthesizeDataArrived接口
// mEngine.synthesize(mAILocalTTSIntent, text, "1024");
}
@@ -353,14 +359,14 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
* @param text 播报内容
* @param type 播报策略
*/
- public void speakTTSVoice( String text, PreemptType type, IMogoTTSCallback callBack ) {
+ public void speakTTSVoice(String text, PreemptType type, IMogoTTSCallback callBack) {
try {
initFlushStatus();
- if ( mHasFlush ) {
- mSpeakVoiceMap.put( text, callBack );
+ if (mHasFlush) {
+ mSpeakVoiceMap.put(text, callBack);
VoiceClient.PreemptType preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_NONE;
- if ( type != null ) {
- switch ( type ) {
+ if (type != null) {
+ switch (type) {
case PREEMPT_TYPE_NEXT:
preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_NEXT;
break;
@@ -378,7 +384,7 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
speakTTSVoice(text);
// mVoiceClient.speakTypeText( text, preemptType );
}
- } catch ( Exception e ) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -388,10 +394,10 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
*
* @param tts 播报内容
*/
- public void speakQAndACmd( String tts, IMogoTTSCallback callBack ) {
+ public void speakQAndACmd(String tts, IMogoTTSCallback callBack) {
initFlushStatus();
- if ( mHasFlush ) {
- mQAndAMap.put( tts, callBack );
+ if (mHasFlush) {
+ mQAndAMap.put(tts, callBack);
speakTTSVoice(tts);
// mVoiceClient.speakTtsAndRegistCmd( tts );
}
@@ -404,10 +410,10 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
* @param okCmds 确认命令唤醒词
* @param cancelCmds 取消命令唤醒词
*/
- public void speakQAndACmd( String tts, String[] okCmds, String[] cancelCmds, IMogoTTSCallback callBack ) {
+ public void speakQAndACmd(String tts, String[] okCmds, String[] cancelCmds, IMogoTTSCallback callBack) {
initFlushStatus();
- if ( mHasFlush ) {
- mQAndAMap.put( tts, callBack );
+ if (mHasFlush) {
+ mQAndAMap.put(tts, callBack);
speakTTSVoice(tts);
// mVoiceClient.speakTtsAndRegistCmd( tts, okCmds, cancelCmds );
}
@@ -420,19 +426,19 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
* @param cmdWords
* @param callBack
*/
- public void registerUnWakeupCommand( String cmd, String[] cmdWords, IMogoTTSCallback callBack ) {
- if ( !mCmdMap.containsKey( cmd ) ) {
- mCmdMap.put( cmd, new ArrayList<>() );
+ public void registerUnWakeupCommand(String cmd, String[] cmdWords, IMogoTTSCallback callBack) {
+ if (!mCmdMap.containsKey(cmd)) {
+ mCmdMap.put(cmd, new ArrayList<>());
}
- mCmdMap.get( cmd ).add( callBack );
+ mCmdMap.get(cmd).add(callBack);
initFlushStatus();
- if ( mHasFlush ) {
- mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
- mCacheUnWakeupCommands.remove( cmd );
+ if (mHasFlush) {
+ mVoiceClient.registerCustomWakeupCmd(cmd, cmdWords);
+ mCacheUnWakeupCommands.remove(cmd);
}
- Logger.i( TAG, "cache un wakeup command2. %s", cmd );
- mCacheUnWakeupCommands.put( cmd, cmdWords );
+ Logger.i(TAG, "cache un wakeup command2. %s", cmd);
+ mCacheUnWakeupCommands.put(cmd, cmdWords);
}
/**
@@ -441,14 +447,14 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
* @param cmd
* @param cmdWords
*/
- private void registerUnWakeupCommand( String cmd, String[] cmdWords ) {
+ private void registerUnWakeupCommand(String cmd, String[] cmdWords) {
initFlushStatus();
- if ( mHasFlush ) {
- mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
- mCacheUnWakeupCommands.remove( cmd );
+ if (mHasFlush) {
+ mVoiceClient.registerCustomWakeupCmd(cmd, cmdWords);
+ mCacheUnWakeupCommands.remove(cmd);
}
- Logger.i( TAG, "cache un wakeup command. %s", cmd );
- mCacheUnWakeupCommands.put( cmd, cmdWords );
+ Logger.i(TAG, "cache un wakeup command. %s", cmd);
+ mCacheUnWakeupCommands.put(cmd, cmdWords);
}
/**
@@ -456,14 +462,14 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
*
* @param cmd
*/
- public synchronized void unregisterUnWakeupCommand( String cmd ) {
- mCmdMap.remove( cmd );
+ public synchronized void unregisterUnWakeupCommand(String cmd) {
+ mCmdMap.remove(cmd);
try {
- mVoiceClient.unRegisterCustomWakeupCmd( cmd );
- } catch ( Exception e ) {
+ mVoiceClient.unRegisterCustomWakeupCmd(cmd);
+ } catch (Exception e) {
e.printStackTrace();
}
- mCacheUnWakeupCommands.remove( cmd );
+ mCacheUnWakeupCommands.remove(cmd);
}
/**
@@ -471,88 +477,88 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
*
* @param cmd
*/
- public synchronized void unregisterUnWakeupCommand( String cmd, IMogoTTSCallback callBack ) {
- if ( mCmdMap.containsKey( cmd ) ) {
- List< IMogoTTSCallback > callBacks = mCmdMap.get( cmd );
- if ( callBacks != null ) {
- callBacks.remove( callBack );
+ public synchronized void unregisterUnWakeupCommand(String cmd, IMogoTTSCallback callBack) {
+ if (mCmdMap.containsKey(cmd)) {
+ List callBacks = mCmdMap.get(cmd);
+ if (callBacks != null) {
+ callBacks.remove(callBack);
}
- if ( callBacks.isEmpty() ) {
- mCmdMap.remove( cmd );
+ if (callBacks.isEmpty()) {
+ mCmdMap.remove(cmd);
try {
- mVoiceClient.unRegisterCustomWakeupCmd( cmd );
- } catch ( Exception e ) {
+ mVoiceClient.unRegisterCustomWakeupCmd(cmd);
+ } catch (Exception e) {
e.printStackTrace();
}
- mCacheUnWakeupCommands.remove( cmd );
+ mCacheUnWakeupCommands.remove(cmd);
}
}
}
- public static void startAssistant( Context context ) {
- startAssistant( context, 1 );
+ public static void startAssistant(Context context) {
+ startAssistant(context, 1);
}
/**
* @param context
* @param status window_start_cancel 0 - 结束, 1 - 显示, 2 - 未激活调试进入
*/
- public static void startAssistant( Context context, int status ) {
+ public static void startAssistant(Context context, int status) {
Logger.w(TAG, "startAssistant status = %d", status);
final Intent intent = new Intent();
- intent.setFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES );
- intent.setAction( "pvetec.intent.action.txz.switch" );
- intent.putExtra( "window_start_cancel", status );
- intent.putExtra( "extra_switch_type", "window_start_cancel" );
- Logger.d( TAG, "status = %d", status );
- context.sendBroadcast( intent );
+ intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ intent.setAction("pvetec.intent.action.txz.switch");
+ intent.putExtra("window_start_cancel", status);
+ intent.putExtra("extra_switch_type", "window_start_cancel");
+ Logger.d(TAG, "status = %d", status);
+ context.sendBroadcast(intent);
}
public synchronized void flush() {
- if ( mCacheUnWakeupCommands.isEmpty() ) {
+ if (mCacheUnWakeupCommands.isEmpty()) {
return;
}
mHasFlush = true;
- Logger.d( TAG, "flush cache voice command when voice service ready." );
- final Map< String, String[] > tmp = new HashMap<>( mCacheUnWakeupCommands );
- for ( String cmd : tmp.keySet() ) {
- registerUnWakeupCommand( cmd, tmp.get( cmd ) );
+ Logger.d(TAG, "flush cache voice command when voice service ready.");
+ final Map tmp = new HashMap<>(mCacheUnWakeupCommands);
+ for (String cmd : tmp.keySet()) {
+ registerUnWakeupCommand(cmd, tmp.get(cmd));
}
}
- private boolean isVoiceServiceReady( Context context ) {
- if ( isProcessRunning( context, getPackageUid( context, "com.zhidao.speech" ) )) {
- Logger.d( TAG, "pad txz is voiceServiceReady" );
+ private boolean isVoiceServiceReady(Context context) {
+ if (isProcessRunning(context, getPackageUid(context, "com.zhidao.speech"))) {
+ Logger.d(TAG, "pad txz is voiceServiceReady");
return true;
- } else if ( isProcessRunning( context, getPackageUid( context, "com.txznet.txz" ) )
- && isProcessRunning( context, getPackageUid( context, "com.txznet.adapter" ) ) ) {
- Logger.d( TAG, "txz is voiceServiceReady" );
+ } else if (isProcessRunning(context, getPackageUid(context, "com.txznet.txz"))
+ && isProcessRunning(context, getPackageUid(context, "com.txznet.adapter"))) {
+ Logger.d(TAG, "txz is voiceServiceReady");
return true;
}
return true;
}
- public void speakTTSAndDuck( String text ) {
- speakTTSAndDuck( text, null );
+ public void speakTTSAndDuck(String text) {
+ speakTTSAndDuck(text, null);
}
- public void speakTTSAndDuck( String text, IMogoTTSCallback callBack ) {
+ public void speakTTSAndDuck(String text, IMogoTTSCallback callBack) {
try {
- if ( mInitReady ) {
- mSpeakVoiceMap.put( text, callBack );
- mogoVoiceManager.toSpeak( text, -3, this );
+ if (mInitReady) {
+ mSpeakVoiceMap.put(text, callBack);
+ mogoVoiceManager.toSpeak(text, -3, this);
}
- } catch ( Exception e ) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
- public void shutUp( String ttsId, String text ) {
+ public void shutUp(String ttsId, String text) {
try {
- mSpeakVoiceMap.remove( text );
- mogoVoiceManager.shutUp( ttsId );
- } catch ( Exception e ) {
+ mSpeakVoiceMap.remove(text);
+ mogoVoiceManager.shutUp(ttsId);
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -565,44 +571,44 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
mVoiceClient.breakOffSpeak();
}
- public void clearTTSCallback( String text ) {
+ public void clearTTSCallback(String text) {
try {
- mSpeakVoiceMap.remove( text );
- } catch ( Exception e ) {
+ mSpeakVoiceMap.remove(text);
+ } catch (Exception e) {
e.printStackTrace();
}
}
@Override
- public void onTtsStart( String ttsId, String text ) {
- IMogoTTSCallback callBack = mSpeakVoiceMap.get( text );
- if ( callBack != null ) {
- callBack.onTTSStart( ttsId, text );
+ public void onTtsStart(String ttsId, String text) {
+ IMogoTTSCallback callBack = mSpeakVoiceMap.get(text);
+ if (callBack != null) {
+ callBack.onTTSStart(ttsId, text);
}
}
@Override
- public void onTtsFinish( String ttsId, String text ) {
- IMogoTTSCallback callBack = mSpeakVoiceMap.remove( text );
- if ( callBack != null ) {
- callBack.onTTSEnd( ttsId, text );
+ public void onTtsFinish(String ttsId, String text) {
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove(text);
+ if (callBack != null) {
+ callBack.onTTSEnd(ttsId, text);
}
}
@Override
- public void onTtsError( String ttsId, String text ) {
- IMogoTTSCallback callBack = mSpeakVoiceMap.remove( text );
- if ( callBack != null ) {
- callBack.onTTSError( ttsId, text );
+ public void onTtsError(String ttsId, String text) {
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove(text);
+ if (callBack != null) {
+ callBack.onTTSError(ttsId, text);
}
}
@Override
- public void init( Context context ) {
- if ( context != null ) {
+ public void init(Context context) {
+ if (context != null) {
mContext = context.getApplicationContext();
- mVoiceClient = new VoiceClient( mContext );
- mVoiceClient.setCallBack( this );
+ mVoiceClient = new VoiceClient(mContext);
+ mVoiceClient.setCallBack(this);
initFlushStatus();
initTtsConfig();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@@ -618,20 +624,20 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
}
@Override
- public void startAIAssist( Context context ) {
- startAssistant( context, 1 );
+ public void startAIAssist(Context context) {
+ startAssistant(context, 1);
}
@Override
- public void startAIAssist( Context context, int status ) {
+ public void startAIAssist(Context context, int status) {
Logger.w(TAG, "startAIAssist status = %d", status);
final Intent intent = new Intent();
- intent.setFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES );
- intent.setAction( "pvetec.intent.action.txz.switch" );
- intent.putExtra( "window_start_cancel", status );
- intent.putExtra( "extra_switch_type", "window_start_cancel" );
- Logger.d( TAG, "status = %d", status );
- context.sendBroadcast( intent );
+ intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+ intent.setAction("pvetec.intent.action.txz.switch");
+ intent.putExtra("window_start_cancel", status);
+ intent.putExtra("extra_switch_type", "window_start_cancel");
+ Logger.d(TAG, "status = %d", status);
+ context.sendBroadcast(intent);
}
private static class AILocalTTSListenerImpl implements AITTSListener {
@@ -684,29 +690,30 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsList
}
}
- public static boolean isProcessRunning( Context context, int uid ) {
- if ( context == null ) {
+ public static boolean isProcessRunning(Context context, int uid) {
+ if (context == null) {
return false;
}
- ActivityManager am = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
- List< ActivityManager.RunningServiceInfo > runningServiceInfos = am.getRunningServices( 200 );
- if ( runningServiceInfos.size() > 0 ) {
- for ( ActivityManager.RunningServiceInfo appProcess : runningServiceInfos ) {
- if ( uid == appProcess.uid ) {
+ ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+ List runningServiceInfos = am.getRunningServices(200);
+ if (runningServiceInfos.size() > 0) {
+ for (ActivityManager.RunningServiceInfo appProcess : runningServiceInfos) {
+ if (uid == appProcess.uid) {
return true;
}
}
}
return false;
}
+
//获取已安装应用的 uid,-1 表示未安装此应用或程序异常
- public static int getPackageUid( Context context, String packageName ) {
+ public static int getPackageUid(Context context, String packageName) {
try {
- ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo( packageName, 0 );
- if ( applicationInfo != null ) {
+ ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(packageName, 0);
+ if (applicationInfo != null) {
return applicationInfo.uid;
}
- } catch ( Exception e ) {
+ } catch (Exception e) {
return -1;
}
return -1;