@@ -21,6 +21,7 @@ import com.mogo.utils.logger.Logger
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 2021/8/5 5:29 下午
|
||||
* 弹窗Window 管理
|
||||
*/
|
||||
internal class WarningFloatWindowHelper(
|
||||
val context: Context,
|
||||
@@ -62,8 +63,8 @@ internal class WarningFloatWindowHelper(
|
||||
// 设置浮窗以外的触摸事件可以传递给后面的窗口、不自动获取焦点
|
||||
flags = if (config.immersionStatusBar)
|
||||
// 没有边界限制,允许窗口扩展到屏幕外
|
||||
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||
else WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||
else WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
||||
width = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
|
||||
@@ -142,7 +143,7 @@ internal class WarningFloatWindowHelper(
|
||||
.enterAnim()?.apply {
|
||||
// 可以延伸到屏幕外,动画结束按需去除该属性,不然旋转屏幕可能置于屏幕外部
|
||||
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 {
|
||||
override fun onAnimationRepeat(animation: Animator?) {}
|
||||
@@ -152,7 +153,7 @@ internal class WarningFloatWindowHelper(
|
||||
if (!config.immersionStatusBar) {
|
||||
// 不需要延伸到屏幕外了,防止屏幕旋转的时候,浮窗处于屏幕外
|
||||
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
|
||||
config.isAnim = true
|
||||
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 {
|
||||
override fun onAnimationRepeat(animation: Animator?) {}
|
||||
|
||||
|
||||
@@ -3,16 +3,17 @@ package com.mogo.eagle.core.function.hmi.ui.setting
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
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.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.hmi.R
|
||||
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 java.util.*
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -46,16 +47,20 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
|
||||
private fun initView() {
|
||||
tvObuInfo.text = CallerObuListenerManager.getObuStatusInfo()
|
||||
etObuIP.setOnClickListener {
|
||||
//获取焦点
|
||||
etObuIP.isFocusable = true;
|
||||
etObuIP.isFocusableInTouchMode = true;
|
||||
etObuIP.requestFocus();
|
||||
btnSetObuIP.setOnClickListener {
|
||||
val obuIP = etObuIP.text.toString()
|
||||
if (obuIP.isNotEmpty()) {
|
||||
CallerOBUManager.resetObuIpAddress(obuIP)
|
||||
} else {
|
||||
ToastUtils.showShort("请输入正确的IP地址")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onObuStatusResponse(obuStatusInfo: 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_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:id="@+id/etObuIP"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -37,6 +37,7 @@
|
||||
android:textSize="@dimen/dp_34" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSetObuIP"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.mogo.eagle.core.function.obu.mogo
|
||||
|
||||
import android.content.Context
|
||||
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.utilcode.util.LogUtils
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.utils.storage.SharedPrefsMgr
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -14,9 +16,22 @@ import com.mogo.service.MogoServicePaths
|
||||
class MoGoObuProvider : IMoGoObuProvider {
|
||||
private val TAG = "MoGoObuProvider"
|
||||
|
||||
private var mContext: Context? = null
|
||||
|
||||
override fun init(context: Context) {
|
||||
LogUtils.dTag(TAG, "初始化蘑菇自研OBU……")
|
||||
|
||||
MogoPrivateObuManager.INSTANCE.init(context)
|
||||
mContext = 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 mObuStatusInfo = ObuStatusInfo()
|
||||
|
||||
fun init(context: Context?) {
|
||||
fun init(context: Context, ipAddress: String) {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
|
||||
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
|
||||
.navigation(context) as IMogoServiceApis
|
||||
mContext = context
|
||||
mIMogoMapService = mMogoServiceApis!!.mapServiceApi
|
||||
|
||||
//自研obu
|
||||
MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP)
|
||||
connectObu(context, ipAddress)
|
||||
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() {
|
||||
// OBU连接成功
|
||||
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 {
|
||||
|
||||
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