@@ -21,6 +21,7 @@ import com.mogo.utils.logger.Logger
|
|||||||
/**
|
/**
|
||||||
* @author donghongyu
|
* @author donghongyu
|
||||||
* @date 2021/8/5 5:29 下午
|
* @date 2021/8/5 5:29 下午
|
||||||
|
* 弹窗Window 管理
|
||||||
*/
|
*/
|
||||||
internal class WarningFloatWindowHelper(
|
internal class WarningFloatWindowHelper(
|
||||||
val context: Context,
|
val context: Context,
|
||||||
@@ -62,8 +63,8 @@ internal class WarningFloatWindowHelper(
|
|||||||
// 设置浮窗以外的触摸事件可以传递给后面的窗口、不自动获取焦点
|
// 设置浮窗以外的触摸事件可以传递给后面的窗口、不自动获取焦点
|
||||||
flags = if (config.immersionStatusBar)
|
flags = if (config.immersionStatusBar)
|
||||||
// 没有边界限制,允许窗口扩展到屏幕外
|
// 没有边界限制,允许窗口扩展到屏幕外
|
||||||
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||||
else WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
else WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
||||||
width = WindowManager.LayoutParams.WRAP_CONTENT
|
width = WindowManager.LayoutParams.WRAP_CONTENT
|
||||||
height = WindowManager.LayoutParams.WRAP_CONTENT
|
height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||||
|
|
||||||
@@ -142,7 +143,7 @@ internal class WarningFloatWindowHelper(
|
|||||||
.enterAnim()?.apply {
|
.enterAnim()?.apply {
|
||||||
// 可以延伸到屏幕外,动画结束按需去除该属性,不然旋转屏幕可能置于屏幕外部
|
// 可以延伸到屏幕外,动画结束按需去除该属性,不然旋转屏幕可能置于屏幕外部
|
||||||
params.flags =
|
params.flags =
|
||||||
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||||
|
|
||||||
addListener(object : Animator.AnimatorListener {
|
addListener(object : Animator.AnimatorListener {
|
||||||
override fun onAnimationRepeat(animation: Animator?) {}
|
override fun onAnimationRepeat(animation: Animator?) {}
|
||||||
@@ -152,7 +153,7 @@ internal class WarningFloatWindowHelper(
|
|||||||
if (!config.immersionStatusBar) {
|
if (!config.immersionStatusBar) {
|
||||||
// 不需要延伸到屏幕外了,防止屏幕旋转的时候,浮窗处于屏幕外
|
// 不需要延伸到屏幕外了,防止屏幕旋转的时候,浮窗处于屏幕外
|
||||||
params.flags =
|
params.flags =
|
||||||
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +188,7 @@ internal class WarningFloatWindowHelper(
|
|||||||
if (config.isAnim) return
|
if (config.isAnim) return
|
||||||
config.isAnim = true
|
config.isAnim = true
|
||||||
params.flags =
|
params.flags =
|
||||||
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||||
animator.addListener(object : Animator.AnimatorListener {
|
animator.addListener(object : Animator.AnimatorListener {
|
||||||
override fun onAnimationRepeat(animation: Animator?) {}
|
override fun onAnimationRepeat(animation: Animator?) {}
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,17 @@ package com.mogo.eagle.core.function.hmi.ui.setting
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.inputmethod.InputMethodManager
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import com.mogo.eagle.core.data.constants.MoGoOBUConfig
|
||||||
import com.mogo.eagle.core.data.obu.ObuStatusInfo
|
import com.mogo.eagle.core.data.obu.ObuStatusInfo
|
||||||
import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener
|
import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener
|
||||||
|
import com.mogo.eagle.core.function.call.obu.CallerOBUManager
|
||||||
import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager
|
import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager
|
||||||
import com.mogo.eagle.core.function.hmi.R
|
import com.mogo.eagle.core.function.hmi.R
|
||||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||||
import com.mogo.eagle.core.utilcode.util.KeyboardUtils
|
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||||
|
import com.mogo.utils.storage.SharedPrefsMgr
|
||||||
import kotlinx.android.synthetic.main.view_debug_setting.view.*
|
import kotlinx.android.synthetic.main.view_debug_setting.view.*
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiaoyuzhou
|
* @author xiaoyuzhou
|
||||||
@@ -46,16 +47,20 @@ class DebugSettingView @JvmOverloads constructor(
|
|||||||
|
|
||||||
private fun initView() {
|
private fun initView() {
|
||||||
tvObuInfo.text = CallerObuListenerManager.getObuStatusInfo()
|
tvObuInfo.text = CallerObuListenerManager.getObuStatusInfo()
|
||||||
etObuIP.setOnClickListener {
|
btnSetObuIP.setOnClickListener {
|
||||||
//获取焦点
|
val obuIP = etObuIP.text.toString()
|
||||||
etObuIP.isFocusable = true;
|
if (obuIP.isNotEmpty()) {
|
||||||
etObuIP.isFocusableInTouchMode = true;
|
CallerOBUManager.resetObuIpAddress(obuIP)
|
||||||
etObuIP.requestFocus();
|
} else {
|
||||||
|
ToastUtils.showShort("请输入正确的IP地址")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onObuStatusResponse(obuStatusInfo: ObuStatusInfo) {
|
override fun onObuStatusResponse(obuStatusInfo: ObuStatusInfo) {
|
||||||
tvObuInfo.text = GsonUtils.toJson(obuStatusInfo)
|
tvObuInfo.text = GsonUtils.toJson(obuStatusInfo)
|
||||||
|
etObuIP.setText(obuStatusInfo.connectIP)
|
||||||
|
etObuIP.text?.let { etObuIP.setSelection(it.length) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<EditText
|
<androidx.appcompat.widget.AppCompatEditText
|
||||||
android:id="@+id/etObuIP"
|
android:id="@+id/etObuIP"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
android:textSize="@dimen/dp_34" />
|
android:textSize="@dimen/dp_34" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
android:id="@+id/btnSetObuIP"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package com.mogo.eagle.core.function.obu.mogo
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.alibaba.android.arouter.facade.annotation.Route
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
|
import com.mogo.eagle.core.data.constants.MoGoOBUConfig
|
||||||
import com.mogo.eagle.core.function.api.obu.IMoGoObuProvider
|
import com.mogo.eagle.core.function.api.obu.IMoGoObuProvider
|
||||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||||
import com.mogo.service.MogoServicePaths
|
import com.mogo.service.MogoServicePaths
|
||||||
|
import com.mogo.utils.storage.SharedPrefsMgr
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiaoyuzhou
|
* @author xiaoyuzhou
|
||||||
@@ -14,9 +16,22 @@ import com.mogo.service.MogoServicePaths
|
|||||||
class MoGoObuProvider : IMoGoObuProvider {
|
class MoGoObuProvider : IMoGoObuProvider {
|
||||||
private val TAG = "MoGoObuProvider"
|
private val TAG = "MoGoObuProvider"
|
||||||
|
|
||||||
|
private var mContext: Context? = null
|
||||||
|
|
||||||
override fun init(context: Context) {
|
override fun init(context: Context) {
|
||||||
LogUtils.dTag(TAG, "初始化蘑菇自研OBU……")
|
LogUtils.dTag(TAG, "初始化蘑菇自研OBU……")
|
||||||
|
mContext = context
|
||||||
MogoPrivateObuManager.INSTANCE.init(context)
|
val ipAddress =
|
||||||
|
SharedPrefsMgr.getInstance(context).getString(MoGoOBUConfig.OBU_IP, "192.168.1.199")
|
||||||
|
MogoPrivateObuManager.INSTANCE.init(context, ipAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun connect(ipAddress: String) {
|
||||||
|
mContext?.let {
|
||||||
|
// 保存本地OBU IP地址
|
||||||
|
SharedPrefsMgr.getInstance(it).putString(MoGoOBUConfig.OBU_IP, ipAddress)
|
||||||
|
MogoPrivateObuManager.INSTANCE.connectObu(it, ipAddress)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -41,18 +41,33 @@ class MogoPrivateObuManager private constructor() {
|
|||||||
private var mContext: Context? = null
|
private var mContext: Context? = null
|
||||||
private var mObuStatusInfo = ObuStatusInfo()
|
private var mObuStatusInfo = ObuStatusInfo()
|
||||||
|
|
||||||
fun init(context: Context?) {
|
fun init(context: Context, ipAddress: String) {
|
||||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
|
Logger.d(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
|
||||||
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
|
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
|
||||||
.navigation(context) as IMogoServiceApis
|
.navigation(context) as IMogoServiceApis
|
||||||
mContext = context
|
mContext = context
|
||||||
mIMogoMapService = mMogoServiceApis!!.mapServiceApi
|
mIMogoMapService = mMogoServiceApis!!.mapServiceApi
|
||||||
|
|
||||||
//自研obu
|
connectObu(context, ipAddress)
|
||||||
MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP)
|
|
||||||
MogoObuManager.getInstance().registerListener(mogoObuListener)
|
MogoObuManager.getInstance().registerListener(mogoObuListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun connectObu(context: Context, ipAddress: String) {
|
||||||
|
//自研obu初始化
|
||||||
|
mObuStatusInfo.connectIP = ipAddress
|
||||||
|
if (!MogoObuManager.getInstance().isConnected) {
|
||||||
|
MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP)
|
||||||
|
} else {
|
||||||
|
MogoObuManager.getInstance().disConnect()
|
||||||
|
try {
|
||||||
|
Thread.sleep(500)
|
||||||
|
MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val mogoObuListener: OnMogoObuListener = object : OnMogoObuListener() {
|
private val mogoObuListener: OnMogoObuListener = object : OnMogoObuListener() {
|
||||||
// OBU连接成功
|
// OBU连接成功
|
||||||
override fun onConnected() {
|
override fun onConnected() {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.mogo.eagle.core.data.constants
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiaoyuzhou
|
||||||
|
* @date 2021/10/11 8:24 下午
|
||||||
|
* OBU 配置常量
|
||||||
|
*/
|
||||||
|
object MoGoOBUConfig {
|
||||||
|
const val OBU_IP = "OBU_IP"
|
||||||
|
}
|
||||||
@@ -9,5 +9,6 @@ import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider
|
|||||||
*/
|
*/
|
||||||
interface IMoGoObuProvider : IMoGoFunctionServerProvider {
|
interface IMoGoObuProvider : IMoGoFunctionServerProvider {
|
||||||
|
|
||||||
|
fun connect(ipAddress: String)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.mogo.eagle.core.function.call.obu
|
||||||
|
|
||||||
|
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||||
|
import com.mogo.eagle.core.function.api.obu.IMoGoObuProvider
|
||||||
|
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@author xiaoyuzhou
|
||||||
|
*@date 2021/10/11 8:30 下午
|
||||||
|
*/
|
||||||
|
object CallerOBUManager {
|
||||||
|
private val providerApi: IMoGoObuProvider
|
||||||
|
get() = CallerBase.getApiInstance(
|
||||||
|
IMoGoObuProvider::class.java,
|
||||||
|
MogoServicePaths.PATH_V2X_OBU_MOGO
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重新设置OBU链接IP
|
||||||
|
*
|
||||||
|
* @param ipAddress 新的IP地址
|
||||||
|
*/
|
||||||
|
fun resetObuIpAddress(ipAddress: String) {
|
||||||
|
providerApi.connect(ipAddress)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
package com.mogo.module.navi.ui.base;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import com.mogo.utils.SoftKeyBoardJobber;
|
|
||||||
import com.mogo.utils.statusbar.Eyes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author congtaowang
|
|
||||||
* @since 2019-10-02
|
|
||||||
* <p>
|
|
||||||
* 地图 activity 基类
|
|
||||||
*/
|
|
||||||
public class BaseActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
//@Override
|
|
||||||
//public Context getContext() {
|
|
||||||
// return this;
|
|
||||||
//}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
|
||||||
super.onCreate( savedInstanceState );
|
|
||||||
Eyes.setStatusBarStyle( this, false, Color.parseColor( "#66000000" ), true );
|
|
||||||
getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN );
|
|
||||||
hideSystemUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void hideSystemUI() {
|
|
||||||
//隐藏虚拟按键
|
|
||||||
if ( Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19 ) { // lower api
|
|
||||||
View v = this.getWindow().getDecorView();
|
|
||||||
v.setSystemUiVisibility( View.GONE );
|
|
||||||
} else if ( Build.VERSION.SDK_INT >= 19 ) {
|
|
||||||
//for new api versions.
|
|
||||||
View decorView = getWindow().getDecorView();
|
|
||||||
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
|
||||||
decorView.setSystemUiVisibility( uiOptions );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean enableDispatchTouchEventToDismissSoftKeyBoard() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean dispatchTouchEvent( MotionEvent ev ) {
|
|
||||||
if ( ev.getAction() == MotionEvent.ACTION_DOWN && enableDispatchTouchEventToDismissSoftKeyBoard() ) {
|
|
||||||
SoftKeyBoardJobber.hideIfNecessary( this, ev );
|
|
||||||
return super.dispatchTouchEvent( ev );
|
|
||||||
}
|
|
||||||
// 必不可少,否则所有的组件都不会有TouchEvent了
|
|
||||||
if ( getWindow().superDispatchTouchEvent( ev ) ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return onTouchEvent( ev );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user