diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java index 907e3007d1..636cf85304 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java @@ -3,6 +3,7 @@ package com.mogo.commons; import android.app.Application; import android.content.Context; import android.text.TextUtils; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -59,7 +60,7 @@ public abstract class AbsMogoApplication extends Application { public void onCreate() { super.onCreate(); // 在设置皮肤布局填充器之前进行克隆一个出来 - mLayoutInflaterNoSkin = LayoutInflater.from(this).cloneInContext(this); + mLayoutInflaterNoSkin = LayoutInflater.from(new ContextThemeWrapper(this, R.style.Theme_AppCompat)).cloneInContext(new ContextThemeWrapper(this, R.style.Theme_AppCompat)); sApp = this; initARouter(); if ( shouldInit() ) { 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 4a439ba53d..e23dc28f2f 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 @@ -83,7 +83,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme @Override protected void beforeSetContentView( Bundle savedInstanceState ) { init(); - //installSkinManager( savedInstanceState ); + installSkinManager( savedInstanceState ); } /** diff --git a/modules/mogo-module-smp/src/main/AndroidManifest.xml b/modules/mogo-module-smp/src/main/AndroidManifest.xml index 32b3a76248..32b078729c 100644 --- a/modules/mogo-module-smp/src/main/AndroidManifest.xml +++ b/modules/mogo-module-smp/src/main/AndroidManifest.xml @@ -1,4 +1,11 @@ + + + + \ No newline at end of file diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java new file mode 100644 index 0000000000..1b566a3a78 --- /dev/null +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java @@ -0,0 +1,134 @@ +package com.mogo.module.small.map; + +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; +import android.os.RemoteException; +import android.view.Gravity; +import android.view.WindowManager; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.mogo.module.common.entity.MogoSnapshotSetData; +import com.mogo.module.common.machinevision.IMachineVisionInterface; +import com.mogo.module.common.wm.WindowManagerView; +import com.mogo.utils.logger.Logger; + +/** + * @author donghongyu + * @date 12/10/20 1:35 PM + */ +public class SmallMapService extends Service { + private static final String TAG = "MachineVisionMapService"; + private IBinder mBinder; + + private WindowManagerView mWindowManagerView; + private SmallMapDirectionView mSmallMapDirectionView; + + @Override + public void onCreate() { + super.onCreate(); + Logger.d(TAG, "onCreate"); + addSmallMapView(); + } + + @Nullable + @Override + public IBinder onBind(Intent intent) { + Logger.d(TAG, "onBind"); + mBinder = new SmallMapServiceBinder(); + return mBinder; + } + + @Override + public void onRebind(Intent intent) { + super.onRebind(intent); + addSmallMapView(); + Logger.d(TAG, "onRebind"); + } + + @Override + public boolean onUnbind(Intent intent) { + Logger.d(TAG, "onUnbind"); + if (mWindowManagerView != null && mWindowManagerView.isShowing()) { + mWindowManagerView.dismiss(); + } + mWindowManagerView = null; + return true; + } + + @Override + public void onDestroy() { + super.onDestroy(); + Logger.d(TAG, "onDestroy"); + if (mWindowManagerView != null) { + mWindowManagerView.dismiss(); + } + } + + /** + * 添加小地图View + */ + private void addSmallMapView() { + Logger.d(TAG, "addSmallMapView"); + + // 初始化小地图控件 + mSmallMapDirectionView = new SmallMapDirectionView(getApplicationContext()); + + mWindowManagerView = new WindowManagerView.Builder(getApplicationContext()) + .contentView(mSmallMapDirectionView) + .size( + WindowManager.LayoutParams.WRAP_CONTENT, + WindowManager.LayoutParams.WRAP_CONTENT + ) + .position( + getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_x), + getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_y) + ) + .gravity(Gravity.TOP | Gravity.LEFT) + .showInWindowManager(); + mWindowManagerView.show(); + } + + + /** + * 小地图与大地图之间进程通讯 + */ + public class SmallMapServiceBinder extends IMachineVisionInterface.Stub { + + @Override + public void linkToDeath(@NonNull DeathRecipient recipient, int flags) { + super.linkToDeath(recipient, flags); + Logger.d(TAG, "linkToDeath"); + + } + + @Override + public boolean unlinkToDeath(@NonNull DeathRecipient recipient, int flags) { + Logger.d(TAG, "unlinkToDeath"); + + return super.unlinkToDeath(recipient, flags); + } + + @Override + public void postData(MogoSnapshotSetData data) throws RemoteException { + Logger.d(TAG, "postData"); + + } + + @Override + public void hideViewIfExist() throws RemoteException { + Logger.d(TAG, "hideViewIfExist"); + + } + + @Override + public void showViewIfExist() throws RemoteException { + Logger.d(TAG, "showViewIfExist"); + + } + + + } +} diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java index d5449144b5..10fb9139b9 100644 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java @@ -1,24 +1,22 @@ package com.mogo.module.small.map; import android.content.Context; +import android.content.Intent; import android.os.Bundle; import android.util.Log; -import android.view.Gravity; import android.view.View; -import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import com.alibaba.android.arouter.facade.annotation.Route; +import com.mogo.commons.AbsMogoApplication; import com.mogo.module.common.MogoApisHandler; -import com.mogo.module.common.wm.WindowManagerView; import com.mogo.service.MogoServicePaths; import com.mogo.service.map.IMogoSmallMapProvider; import com.mogo.service.module.ModuleType; import com.mogo.service.statusmanager.IMogoStatusChangedListener; import com.mogo.service.statusmanager.StatusDescriptor; -import com.mogo.utils.logger.Logger; /** * @author donghongyu @@ -28,11 +26,9 @@ import com.mogo.utils.logger.Logger; public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusChangedListener { private final String TAG = "SmallVisionProvider"; + private Intent mSmallMapServiceIntent; private Context mContext; - private WindowManagerView mWindowManagerView; - private SmallMapDirectionView mSmallMapDirectionView; - @Override public Fragment createFragment(Context context, Bundle data) { return null; @@ -80,22 +76,22 @@ public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusCh public void onDestroy() { Log.d(TAG, "小地图模块销毁……"); hidePanel(); - // 释放组件内存 - mSmallMapDirectionView = null; - mWindowManagerView = null; } @Override public void showPanel() { Log.d(TAG, "小地图模块触发展示……"); - addSmallMapView(); + if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { + mSmallMapServiceIntent = new Intent(mContext, SmallMapService.class); + mContext.startService(mSmallMapServiceIntent); + } } @Override public void hidePanel() { Log.d(TAG, "小地图模块触发隐藏……"); - if (mWindowManagerView != null && mWindowManagerView.isShowing()) { - mWindowManagerView.dismiss(); + if (mSmallMapServiceIntent != null) { + AbsMogoApplication.getApp().stopService(mSmallMapServiceIntent); } } @@ -126,33 +122,4 @@ public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusCh } } } - - - /** - * 添加小地图View - */ - private void addSmallMapView() { - Logger.d(TAG, "addSmallMapView"); - // 初始化小地图控件 - if (mSmallMapDirectionView == null) { - mSmallMapDirectionView = new SmallMapDirectionView(mContext); - } - - if (mWindowManagerView == null) { - mWindowManagerView = new WindowManagerView.Builder(mContext) - .contentView(mSmallMapDirectionView) - .size( - WindowManager.LayoutParams.WRAP_CONTENT, - WindowManager.LayoutParams.WRAP_CONTENT - ) - .position( - mContext.getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_x), - mContext.getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_y) - ) - .gravity(Gravity.TOP | Gravity.LEFT) - .showInWindowManager(); - } - mWindowManagerView.show(); - } - } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/RoundLayout.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/RoundLayout.java index b0645b5823..a32e369284 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/RoundLayout.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/RoundLayout.java @@ -80,6 +80,14 @@ public class RoundLayout extends RelativeLayout implements IMogoSkinCompatSuppor super.draw(canvas); } + @Override + public void setBackgroundResource(int resId) { + super.setBackgroundResource(resId); + if (mBackgroundTintHelper != null) { + mBackgroundTintHelper.onSetBackgroundResource(resId); + } + } + @Override public void applySkin() { if (mBackgroundTintHelper != null) {