This commit is contained in:
zhongchao
2022-11-10 16:54:26 +08:00
parent 5322d03ec1
commit 2156d2cd18
148 changed files with 147 additions and 19811 deletions

View File

@@ -8,8 +8,8 @@ import android.view.WindowManager;
import androidx.annotation.NonNull;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.function.hmi.R;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.module.common.R;
/**
* 浮在各种wm上面的dialog基类调用了window.setType

View File

@@ -0,0 +1,56 @@
package com.mogo.eagle.core.function.hmi.dialog;
import android.app.Dialog;
import android.view.View;
import android.view.ViewGroup;
/**
* 采用Dialog实现接口
*/
class DialogImpl implements IWindowManagerView {
private Dialog dialog;
private View contentView;
@Override
public void init(WindowManagerView.WMViewParams params) {
dialog = new BaseFloatDialog(params.mContext);
contentView = params.mContentView;
dialog.setContentView(contentView);
}
@Override
public boolean isShowing() {
return dialog.isShowing();
}
@Override
public void handleTouchEvent(OnViewClickListener listener) {
// do nothings.
}
@Override
public void show() {
dialog.show();
}
@Override
public void update(WindowManagerView.WMViewParams params) {
}
@Override
public void update() {
}
@Override
public void hide() {
/*
* 取得view的父组件然后移除view
*/
if (contentView != null) {
((ViewGroup) contentView.getParent()).removeView(contentView);
}
dialog.dismiss();
}
}

View File

@@ -0,0 +1,49 @@
package com.mogo.eagle.core.function.hmi.dialog;
import android.view.View;
public interface IWindowManagerView {
/**
* 初始化
*
* @param params contentView包装类
*/
void init( WindowManagerView.WMViewParams params );
/**
* 是否显示
*
* @return true - 显示中
*/
boolean isShowing();
/**
* 支持手势拖动,该操作只支持触发点击操作
*/
void handleTouchEvent(OnViewClickListener listener);
/**
* 显示
*/
void show();
/**
* 更新界面位置或大小
* @param params 具体参数
*/
void update(WindowManagerView.WMViewParams params);
/**
* 刷新
*/
void update();
/**
* 隐藏
*/
void hide();
public interface OnViewClickListener {
void onClick( View view, float xPos, float yPos );
}
}

View File

@@ -7,8 +7,8 @@ import android.widget.TextView;
import androidx.annotation.StringRes;
import com.mogo.module.common.R;
import com.mogo.module.common.wm.WindowManagerView;
import com.mogo.eagle.core.function.hmi.R;
/**
* @author congtaowang

View File

@@ -0,0 +1,118 @@
package com.mogo.eagle.core.function.hmi.dialog;
import android.content.Context;
import android.graphics.PixelFormat;
import android.os.Build;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
/**
* 采用windowManager实现接口
*/
class WindowManagerImpl implements IWindowManagerView {
private WindowManager mWindowManager;
private WindowManager.LayoutParams mLayoutParams;
private WindowManagerView.WMViewParams mParams;
private boolean isShowing;
private View rootView;
private float mLastX, mLastY;
private int mOldOffsetX, mOldOffsetY;
@Override
public void init( WindowManagerView.WMViewParams params ) {
mParams = params;
mWindowManager = ( WindowManager ) mParams.mContext.getApplicationContext().getSystemService( Context.WINDOW_SERVICE );
generateLayoutParams();
}
private void generateLayoutParams(){
mLayoutParams = new WindowManager.LayoutParams();
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ) {
mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
} else {
mLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
}
mLayoutParams.format = PixelFormat.TRANSLUCENT;
mLayoutParams.gravity = mParams.mGravity;
mLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
mLayoutParams.width = mParams.mWidth;
mLayoutParams.height = mParams.mHeight;
mOldOffsetX = mLayoutParams.x = mParams.mX;
mOldOffsetY = mLayoutParams.y = mParams.mY;
mLayoutParams.dimAmount = 0.5f;
}
@Override
public boolean isShowing() {
return isShowing;
}
@Override
public void handleTouchEvent(OnViewClickListener listener) {
mParams.mContentView.setOnTouchListener( ( v, event ) -> {
final int action = event.getAction();
float x = event.getX();
float y = event.getY();
if ( action == MotionEvent.ACTION_DOWN ) {
mLastX = x;
mLastY = y;
} else if ( action == MotionEvent.ACTION_MOVE ) {
mLayoutParams.x += ( int ) ( x - mLastX ) / 3; // 减小偏移量,防止过度抖动
mLayoutParams.y += ( int ) ( y - mLastY ) / 3; // 减小偏移量,防止过度抖动
mWindowManager.updateViewLayout( mParams.mContentView, mLayoutParams );
} else if ( action == MotionEvent.ACTION_UP ) {
int newOffsetX = mLayoutParams.x;
int newOffsetY = mLayoutParams.y;
// 只要按钮一动位置不是很大,就认为是点击事件
if ( Math.abs( mOldOffsetX - newOffsetX ) <= 20
&& Math.abs( mOldOffsetY - newOffsetY ) <= 20 ) {
if ( listener != null ) {
listener.onClick( mParams.mContentView, x, y );
}
return false;
}
mOldOffsetX = newOffsetX;
mOldOffsetY = newOffsetY;
}
return true;
} );
}
@Override
public void show() {
if ( !isShowing ) {
isShowing = true;
rootView = mParams.mContentView;
mWindowManager.addView( mParams.mContentView, mLayoutParams );
}
}
@Override
public void update(WindowManagerView.WMViewParams params) {
if (isShowing) {
mParams = params;
generateLayoutParams();
mWindowManager.updateViewLayout(rootView,mLayoutParams);
}
}
@Override
public void update() {
if ( isShowing ) {
mWindowManager.updateViewLayout(rootView,mLayoutParams);
}
}
@Override
public void hide() {
if ( isShowing && mParams != null ) {
mWindowManager.removeView( mParams.mContentView );
isShowing = false;
}
}
}

View File

@@ -0,0 +1,136 @@
package com.mogo.eagle.core.function.hmi.dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
/**
* @author congtaowang
* @since 2020-05-21
* <p>
* 往 window manager 添加view
*/
public class WindowManagerView {
private WMViewParams mParams;
private IWindowManagerView mManagerView;
private WindowManagerView( WMViewParams params, IWindowManagerView view ) {
this.mParams = params;
mManagerView = view;
view.init( params );
}
public boolean isShowing() {
return mManagerView.isShowing();
}
public < T extends View > T findViewById( @IdRes int id ) {
return mParams.mContentView.findViewById( id );
}
public void attachTouchEvent( IWindowManagerView.OnViewClickListener listener ) {
mManagerView.handleTouchEvent(listener);
}
public void show() {
mManagerView.show();
}
public void dismiss() {
mManagerView.hide();
}
public static class Builder {
private WMViewParams mParams = null;
public Builder( Context context ) {
mParams = new WMViewParams();
mParams.mContext = context;
}
public Builder contentView( View contentView ) {
mParams.mContentView = contentView;
return this;
}
public Builder contentView( @LayoutRes int contentViewId ) {
mParams.mContentView = LayoutInflater.from( mParams.mContext ).inflate( contentViewId, null );
return this;
}
public Builder size( int width, int height ) {
mParams.mWidth = width;
mParams.mHeight = height;
return this;
}
public Builder position( int x, int y ) {
mParams.mX = x;
mParams.mY = y;
return this;
}
public Builder gravity( int gravity ) {
mParams.mGravity = gravity;
return this;
}
/**
* 默认dialog实现
*
* @return
*/
public WindowManagerView build() {
return showInDialog();
}
public WindowManagerView showInDialog() {
if ( mParams.mContentView == null ) {
throw new NullPointerException( "WMViewParams#mContentView must not be null." );
}
return new WindowManagerView( mParams, new DialogImpl() );
}
public WindowManagerView showInWindowManager() {
if ( mParams.mContentView == null ) {
throw new NullPointerException( "WMViewParams#mContentView must not be null." );
}
return new WindowManagerView( mParams, new WindowManagerImpl() );
}
}
public static class WMViewParams {
public View mContentView;
public Context mContext;
public int mWidth;
public int mHeight;
public int mX;
public int mY;
public int mGravity;
}
public void exchangeSizeAndPosition(int width, int height, int x, int y) {
if (isShowing()) {
mParams.mX = x;
mParams.mY = y;
mParams.mWidth = width;
mParams.mHeight = height;
mManagerView.update(mParams);
}
}
public void update(){
if ( mManagerView != null) {
mManagerView.update();
}
}
}

View File

@@ -288,7 +288,6 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
*/
protected void loadOthersModules() {
// 加载地图,触发地图加载完毕回调,在初始化其他卡片模块,保证卡片模块可以正确获取地图相关服务。
MogoModulesManager.getInstance().loadModules();
MogoModulesManager.getInstance().loadFunctionModules();
mPresenter.delayOperations();
MogoModulesManager.getInstance().loadFunctionModulesServer();
@@ -305,8 +304,8 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
* 启动后台服务
*/
private void startBaseService() {
Intent intentMainServicee = new Intent(this, MogoMainService.class);
startService(intentMainServicee);
Intent intentMainService = new Intent(this, MogoMainService.class);
startService(intentMainService);
// USB 摄像头行车记录仪进程
// Intent intentCarcorderService = new Intent(this, CarcorderService.class);

View File

@@ -10,6 +10,8 @@ import com.elegant.utils.UiThreadHandler;
import com.mogo.cloud.socket.SocketBuildConfig;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.module.MogoModule;
import com.mogo.commons.module.MogoModulePaths;
import com.mogo.commons.voice.AIAssist;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.constants.MoGoConfig;
@@ -24,8 +26,6 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.util.ProcessUtils;
import com.mogo.map.MapApiPath;
import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
import com.zhidao.support.obu.ami.AmiClientManager;
import com.zhjt.mogo_core_function_devatools.monitor.db.CpuInfo;
import com.zhjt.mogo_core_function_devatools.monitor.db.MemInfo;
@@ -136,7 +136,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
MogoModulePaths.addModuleFunction(new MogoModule("/och/api", "IMoGoFunctionProvider"));
MogoModulePaths.addBaseModule(new MogoModule(MapApiPath.PATH, "CustomMapApiBuilder"));
//todo emArrow 此处业务调用放置map module MogoModulePaths.addBaseModule(new MogoModule(ServiceConst.PATH_REFRESH_STRATEGY, ServiceConst.PATH_REFRESH_STRATEGY));
// MogoModulePaths.addBaseModule(new MogoModule(V2XConst.PATH_V2X_UI, V2XConst.MODULE_NAME));
// OBU 模块

View File

@@ -8,11 +8,6 @@ package com.mogo.eagle.core.function.main.cards;
*/
public interface MogoModulesHandler {
/**
* 加载模块
*/
void loadModules();
/**
* 架构升级v1.1加载功能模块
*/

View File

@@ -5,18 +5,14 @@ import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_HMI
import android.app.Application;
import android.content.Context;
import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.module.MogoModule;
import com.mogo.commons.module.MogoModulePaths;
import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.function.main.MainActivity;
import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper;
import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import java.util.Collection;
import java.util.HashMap;
@@ -35,18 +31,15 @@ public class MogoModulesManager implements MogoModulesHandler {
private MainActivity mActivity;
private Application mApp;
private Map<MogoModule, IMogoModuleProvider> mModuleProviders = new HashMap<>();
// 空间换效率
private Map<String, IMogoModuleProvider> mModuleNameProviders = new HashMap<>();
private static final byte[] obj = new byte[0];
// 架构升级后的加载功能模块的方式
private Map<MogoModule, IMoGoFunctionProvider> mModuleFunctionProviders = new HashMap<>();
private Map<String, IMoGoFunctionProvider> mModuleNameFunctionProviders = new HashMap<>();
private final Map<MogoModule, IMoGoFunctionProvider> mModuleFunctionProviders = new HashMap<>();
private final Map<String, IMoGoFunctionProvider> mModuleNameFunctionProviders = new HashMap<>();
// 架构升级后的加载功能模块的方式
private Map<MogoModule, IMoGoFunctionServerProvider> mModuleFunctionServerProviders = new HashMap<>();
private Map<String, IMoGoFunctionServerProvider> mModuleNameFunctionServerProviders = new HashMap<>();
private final Map<MogoModule, IMoGoFunctionServerProvider> mModuleFunctionServerProviders = new HashMap<>();
private final Map<String, IMoGoFunctionServerProvider> mModuleNameFunctionServerProviders = new HashMap<>();
private static volatile MogoModulesManager sInstance;
@@ -55,7 +48,7 @@ public class MogoModulesManager implements MogoModulesHandler {
public static MogoModulesManager getInstance() {
if (sInstance == null) {
synchronized (MogoModulesManager.class) {
synchronized (obj) {
if (sInstance == null) {
sInstance = new MogoModulesManager();
}
@@ -84,21 +77,6 @@ public class MogoModulesManager implements MogoModulesHandler {
return mApp;
}
@Override
public void loadModules() {
final List<MogoModule> modules = MogoModulePaths.getModules();
if (modules != null && !modules.isEmpty()) {
for (MogoModule module : modules) {
CallerLogger.INSTANCE.d(M_HMI + TAG, "module.getPath():" + module.getPath() + " name: " + module.getName());
IMogoModuleProvider provider = load(module.getPath());
if (provider != null) {
mModuleProviders.put(module, provider);
mModuleNameProviders.put(module.getName(), provider);
}
}
}
}
@Override
public void loadFunctionModules() {
final List<MogoModule> modules = MogoModulePaths.getModuleFunctions();
@@ -151,15 +129,6 @@ public class MogoModulesManager implements MogoModulesHandler {
}
}
private IMogoModuleProvider load(String path) {
try {
return (IMogoModuleProvider) ARouter.getInstance().build(path).navigation(getContext());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private IMoGoFunctionProvider loadFunction(String path) {
try {
return (IMoGoFunctionProvider) ARouter.getInstance().build(path).navigation(getContext());
@@ -178,45 +147,8 @@ public class MogoModulesManager implements MogoModulesHandler {
}
}
private void addFragment(IMogoModuleProvider provider, int containerId) {
if (provider == null) {
CallerLogger.INSTANCE.e(M_HMI + TAG, "add fragment fail cause provider == null, container is " + ResourcesHelper.getResNameById(getApplicationContext(), containerId));
return;
}
Fragment fragment = null;
fragment = mActivity.getSupportFragmentManager().findFragmentByTag(provider.getModuleName());
if (fragment == null) {
fragment = provider.createFragment(getContext(), null);
}
if (fragment == null) {
CallerLogger.INSTANCE.e(M_HMI + TAG, "add fragment fail cause fragment == null, container is " + ResourcesHelper.getResNameById(getApplicationContext(), containerId));
return;
}
mActivity.getSupportFragmentManager().beginTransaction()
.replace(containerId, fragment, provider.getModuleName())
.commitAllowingStateLoss();
}
@Override
public void onDestroy() {
if (mModuleNameProviders != null) {
Collection<IMogoModuleProvider> modules = mModuleNameProviders.values();
if (modules != null) {
for (IMogoModuleProvider module : modules) {
try {
CallerLogger.INSTANCE.d(M_HMI + TAG, "destroy module: " + module.getModuleName());
module.onDestroy();
} catch (Exception e) {
CallerLogger.INSTANCE.e(M_HMI + TAG, e + " onDestroy");
}
}
}
mModuleNameProviders.clear();
}
if (mModuleProviders != null) {
mModuleProviders.clear();
}
if (mModuleFunctionProviders != null) {
Collection<IMoGoFunctionProvider> modules = mModuleFunctionProviders.values();
if (modules != null) {

View File

@@ -35,7 +35,6 @@ public
class MogoMainService extends Service implements IMogoLocationListener {
private static final String TAG = "MogoMainService";
private IMogoServiceApis mServiceApis;
/**
* 主模块管控定位,可以向各个模块发送统一定位信息
@@ -45,7 +44,6 @@ class MogoMainService extends Service implements IMogoLocationListener {
@Override
public void onCreate() {
CallerLogger.INSTANCE.d(M_HMI + TAG, "基本服务启动");
mServiceApis = MogoApisHandler.getInstance().getApis();
initAndStartLocation();
UiThreadHandler.postDelayed(() -> {
CallerLogger.INSTANCE.d(M_HMI + TAG, "5秒已过启动基础服务……");
@@ -106,6 +104,5 @@ class MogoMainService extends Service implements IMogoLocationListener {
mLocationClient.destroy();
mLocationClient = null;
}
mServiceApis = null;
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/dp_30" />
<gradient android:startColor="#3F4057" android:endColor="#2A2B38"/>
</shape>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="180"
android:endColor="#3E7FFC"
android:startColor="#5CC1FF" />
<corners android:bottomLeftRadius="@dimen/dp_30" />
</shape>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="180"
android:endColor="#50526E"
android:startColor="#333F4057" />
<corners android:bottomRightRadius="@dimen/dp_30" />
</shape>

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_99000000"
android:layout_gravity="center">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="@dimen/dp_790"
android:layout_height="@dimen/dp_440"
android:layout_gravity="center"
android:background="@drawable/module_commons_shape_dlg_round_bkg">
<TextView
android:id="@+id/module_commons_wm_dialog_content"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_56"
android:layout_marginTop="@dimen/dp_134"
android:maxLines="1"
android:textColor="@android:color/white"
android:textSize="@dimen/sp_40"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="是否退出导航导航导航导航导航导航导航导航导航导航导航导航导航导航导航导航?" />
<TextView
android:id="@+id/module_commons_wm_dialog_button_ok"
android:layout_width="@dimen/dp_395"
android:layout_height="@dimen/dp_128"
android:background="@drawable/module_commons_shape_left_btn_bkg"
android:gravity="center"
android:textColor="@android:color/white"
android:textSize="@dimen/dp_40"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
tools:text="确认" />
<TextView
android:id="@+id/module_commons_wm_dialog_button_cancel"
android:layout_width="@dimen/dp_395"
android:layout_height="@dimen/dp_128"
android:background="@drawable/module_commons_shape_right_btn_bkg"
android:gravity="center"
android:textColor="@android:color/white"
android:textSize="@dimen/dp_40"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
tools:text="取消" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>

View File

@@ -53,4 +53,19 @@
<attr name="defaultColor" format="color"/> <!--档位默认色值-->
<attr name="selectColor" format="color"/> <!--当前档位色值-->
</declare-styleable>
<style name="BaseFloatDialogStyle" parent="@android:style/Theme.Dialog">
<item name="android:windowIsFloating">true</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimAmount">0.6</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:fullBright">@android:color/transparent</item>
<item name="android:fullDark">@android:color/transparent</item>
<item name="android:topBright">@android:color/transparent</item>
<item name="android:topDark">@android:color/transparent</item>
<item name="android:borderlessButtonStyle">@android:color/transparent</item>
</style>
</resources>

View File

@@ -40,6 +40,7 @@
<color name="color_FF2966EC">#FF2966EC</color>
<color name="color_FFA7B6F0">#FFA7B6F0</color>
<color name="color_B3FFFFFF">#B3FFFFFF</color>
<color name="color_99000000">#99000000</color>
<color name="version_latest_start_color">#6D7BAF</color>