Merge branch 'dev2_smp_change' into dev2_aiSdk
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.mogo.launcher;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Process;
|
||||
@@ -121,6 +122,17 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
ARouter.getInstance().navigation(ITestCrashReportProvider.class);
|
||||
}
|
||||
Log.i("timer", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
|
||||
try {
|
||||
if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName("com.zhidao.speech.voice.pad",
|
||||
"com.zhidao.speech.MainActivity"));
|
||||
startActivity(intent);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,7 +225,7 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
// 设置是否是第三APP登录
|
||||
clientConfig.setThirdLogin(DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE);
|
||||
// 设置是否输出日志
|
||||
clientConfig.setShowDebugLog(true);
|
||||
clientConfig.setShowDebugLog(false);
|
||||
// 设置是否是直播推流的主播
|
||||
clientConfig.setAnchor(false);
|
||||
// 设置从蘑菇AI开放平台获取的APPKey
|
||||
|
||||
@@ -43,6 +43,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.rxjava
|
||||
implementation rootProject.ext.dependencies.accountsdk
|
||||
api rootProject.ext.dependencies.mogoaicloudrealtime
|
||||
implementation rootProject.ext.dependencies.amapnavi3dmap
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
|
||||
@@ -11,6 +11,8 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.android.internal.policy.MyPhoneLayoutInflater;
|
||||
import com.mogo.commons.analytics.AnalyticsUtils;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.device.Devices;
|
||||
@@ -59,9 +61,17 @@ public abstract class AbsMogoApplication extends Application {
|
||||
return sApp;
|
||||
}
|
||||
|
||||
public static AMapNaviView aMapNaviView;
|
||||
|
||||
public static AMapNaviView getMapNaviView() {
|
||||
return aMapNaviView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
aMapNaviView = new AMapNaviView(this);
|
||||
aMapNaviView.onCreate(null);
|
||||
// 在设置皮肤布局填充器之前进行克隆一个出来
|
||||
mLayoutInflaterNoSkin = LayoutInflater.from(new ContextThemeWrapper(this, R.style.Theme_AppCompat)).cloneInContext(new ContextThemeWrapper(this, R.style.Theme_AppCompat));
|
||||
sApp = this;
|
||||
|
||||
@@ -30,7 +30,6 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > >
|
||||
|
||||
@Override
|
||||
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||
hideBottomUIMenu();
|
||||
super.onCreate( savedInstanceState );
|
||||
beforeSetContentView(savedInstanceState);
|
||||
if ( DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD ) {
|
||||
@@ -43,6 +42,12 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > >
|
||||
getLifecycle().addObserver( mPresenter );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
hideBottomUIMenu();
|
||||
}
|
||||
|
||||
//隐藏导航栏
|
||||
protected void hideBottomUIMenu() {
|
||||
//隐藏虚拟按键
|
||||
|
||||
@@ -68,11 +68,15 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
|
||||
}
|
||||
|
||||
fun initCarCorderController() {
|
||||
zdCarCoderController =
|
||||
ZdCarCoderController.getInstance(AbsMogoApplication.getApp().applicationContext)
|
||||
zdCarCoderController.addCallback(this)
|
||||
zdCarCoderController.addVideoCallback(this)
|
||||
zdCarCoderController.init()
|
||||
try {
|
||||
zdCarCoderController =
|
||||
ZdCarCoderController.getInstance(AbsMogoApplication.getApp().applicationContext)
|
||||
zdCarCoderController.addCallback(this)
|
||||
zdCarCoderController.addVideoCallback(this)
|
||||
zdCarCoderController.init()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,10 +44,12 @@ dependencies {
|
||||
api rootProject.ext.dependencies.modulemain
|
||||
implementation rootProject.ext.dependencies.mogooch
|
||||
implementation rootProject.ext.dependencies.moduleservice
|
||||
implementation rootProject.ext.dependencies.moduleSmallMap
|
||||
} else {
|
||||
api project(":modules:mogo-module-main")
|
||||
implementation project(":OCH:mogo-och")
|
||||
implementation project(':modules:mogo-module-service')
|
||||
implementation project(':modules:mogo-module-smp')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.mogo.module.main.cards.MogoModulesManager;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.och.IMogoOCH;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.map.IMogoSmallMapProvider;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.service.v2x.IV2XListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -115,7 +116,9 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
@Override
|
||||
protected void loadOthersModules() {
|
||||
super.loadOthersModules();
|
||||
Logger.d(TAG, "loadOthersModules");
|
||||
loadOCHModule();
|
||||
loadSmpModule();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,6 +131,16 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载小地图模块
|
||||
*/
|
||||
private void loadSmpModule() {
|
||||
IMogoSmallMapProvider smp = ARouter.getInstance().navigation(IMogoSmallMapProvider.class);
|
||||
if (smp != null) {
|
||||
smp.init(this, R.id.module_main_id_smp_fragment);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
@@ -158,7 +171,6 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void warningChangedWithDirection(int type) {
|
||||
Log.d(TAG, "显示红色预警蒙层");
|
||||
@@ -227,7 +239,7 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
|
||||
super.onStatusChanged(descriptor,isTrue);
|
||||
super.onStatusChanged(descriptor, isTrue);
|
||||
if (isTrue) {
|
||||
mLeftShadowFrame.setVisibility(View.GONE);
|
||||
mApps.setVisibility(View.GONE);
|
||||
|
||||
@@ -229,6 +229,9 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
|
||||
MapCenterPointStrategy.setMapCenterPointByScene(mServiceApis.getMapServiceApi().getMapUIController(), Scene.AIMLESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载其它模块
|
||||
*/
|
||||
protected void loadOthersModules() {
|
||||
// 加载地图,触发地图加载完毕回调,在初始化其他卡片模块,保证卡片模块可以正确获取地图相关服务。
|
||||
loadContainerModules();
|
||||
|
||||
@@ -141,6 +141,12 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!--小地图视图-->
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_smp_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!--冷启动过渡Logo-->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/module_main_id_cover_up"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
-keep class com.mogo.module.small.map.SmallMapDirectionView{*;}
|
||||
-keep class com.amap.api.col.n3.*{*;}
|
||||
-keep class com.mogo.module.small.map.*{*;}
|
||||
-keep class com.android.internal.policy.MyPhoneLayoutInflater{*;}
|
||||
-keep class com.mogo.module.small.map.SmallVisionProvider{*;}
|
||||
-keep class com.amap.api.col.n3.*{*;}
|
||||
|
||||
|
||||
@@ -2,10 +2,4 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.module.small.map">
|
||||
|
||||
<!--<application>
|
||||
<service
|
||||
android:name=".SmallMapService"
|
||||
android:exported="false"
|
||||
/>
|
||||
</application>-->
|
||||
</manifest>
|
||||
@@ -1,186 +0,0 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package com.amap.api.col.n3;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.Resources.Theme;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.LayoutInflater.Factory;
|
||||
import android.view.View;
|
||||
import android.view.ViewStub;
|
||||
|
||||
import com.android.internal.policy.MyPhoneLayoutInflater;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public final class le2 extends ContextThemeWrapper {
|
||||
private Resources a = lg.a();
|
||||
private Theme b;
|
||||
private LayoutInflater c;
|
||||
private ClassLoader d;
|
||||
private int e;
|
||||
private static final String[] f = new String[]{"android.widget", "android.webkit", "android.app"};
|
||||
private le2.a g = new le2.a();
|
||||
private Factory h = new Factory() {
|
||||
public final View onCreateView(String var1, Context var2, AttributeSet var3) {
|
||||
return le2.this.a(var1, var2, var3);
|
||||
}
|
||||
};
|
||||
|
||||
public le2(Context var1, int var2, ClassLoader var3) {
|
||||
super(var1, var2);
|
||||
this.d = var3;
|
||||
this.b = lg.b();
|
||||
this.e = var2;
|
||||
super.onApplyThemeResource(this.b, this.e, true);
|
||||
(new StringBuilder("classloader:")).append(this.d);
|
||||
}
|
||||
|
||||
public final Resources getResources() {
|
||||
return this.a != null ? this.a : super.getResources();
|
||||
}
|
||||
|
||||
public final void a(int var1) {
|
||||
if (var1 != this.e) {
|
||||
this.e = var1;
|
||||
super.onApplyThemeResource(this.b, this.e, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final Theme getTheme() {
|
||||
return this.b != null ? this.b : super.getTheme();
|
||||
}
|
||||
|
||||
public final Object getSystemService(String var1) {
|
||||
if ("layout_inflater".equals(var1)) {
|
||||
if (this.c == null) {
|
||||
// 这里构建一个自己对的布局填充器
|
||||
// 与已经被修改的context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)
|
||||
// 隔离从而保证高德地图SDK能正常初始化
|
||||
LayoutInflater var2 = new MyPhoneLayoutInflater(getBaseContext());
|
||||
this.c = var2.cloneInContext(this);
|
||||
this.c.setFactory(this.h);
|
||||
this.c = this.c.cloneInContext(this);
|
||||
}
|
||||
|
||||
return this.c;
|
||||
} else {
|
||||
return super.getSystemService(var1);
|
||||
}
|
||||
}
|
||||
|
||||
private final View a(String var1, Context var2, AttributeSet var3) {
|
||||
if (this.g.a.contains(var1)) {
|
||||
return null;
|
||||
} else {
|
||||
Constructor var4;
|
||||
if ((var4 = (Constructor) this.g.b.get(var1)) == null) {
|
||||
Class var5 = null;
|
||||
boolean var6 = false;
|
||||
String var7 = "api.navi";
|
||||
|
||||
label71:
|
||||
{
|
||||
label70:
|
||||
{
|
||||
Throwable var10000;
|
||||
label79:
|
||||
{
|
||||
boolean var10001;
|
||||
try {
|
||||
if (var1.contains(var7)) {
|
||||
var5 = this.d.loadClass(var1);
|
||||
} else {
|
||||
String[] var17;
|
||||
int var8 = (var17 = f).length;
|
||||
int var9 = 0;
|
||||
|
||||
while (var9 < var8) {
|
||||
String var10 = var17[var9];
|
||||
|
||||
try {
|
||||
var5 = this.d.loadClass(var10 + "." + var1);
|
||||
break;
|
||||
} catch (Throwable var13) {
|
||||
++var9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (var5 == null) {
|
||||
break label71;
|
||||
}
|
||||
} catch (Throwable var15) {
|
||||
var10000 = var15;
|
||||
var10001 = false;
|
||||
break label79;
|
||||
}
|
||||
|
||||
if (var5 == ViewStub.class) {
|
||||
break label71;
|
||||
}
|
||||
|
||||
try {
|
||||
if (var5.getClassLoader() != this.d) {
|
||||
break label71;
|
||||
}
|
||||
break label70;
|
||||
} catch (Throwable var14) {
|
||||
var10000 = var14;
|
||||
var10001 = false;
|
||||
}
|
||||
}
|
||||
|
||||
Throwable var18 = var10000;
|
||||
(new StringBuilder("load view err:")).append(Log.getStackTraceString(var18));
|
||||
break label71;
|
||||
}
|
||||
|
||||
var6 = true;
|
||||
}
|
||||
|
||||
if (!var6) {
|
||||
this.g.a.add(var1);
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
var4 = var5.getConstructor(Context.class, AttributeSet.class);
|
||||
this.g.b.put(var1, var4);
|
||||
} catch (Throwable var12) {
|
||||
(new StringBuilder("create view err:")).append(Log.getStackTraceString(var12));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
View var16 = null;
|
||||
if (var4 != null) {
|
||||
var16 = (View) var4.newInstance(var2, var3);
|
||||
}
|
||||
|
||||
return var16;
|
||||
} catch (Throwable var11) {
|
||||
(new StringBuilder("create view err:")).append(Log.getStackTraceString(var11));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class a {
|
||||
public HashSet<String> a = new HashSet();
|
||||
public HashMap<String, Constructor<?>> b = new HashMap();
|
||||
|
||||
public a() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.amap.api.col.n3;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* 这里是为了解决 使用换肤框架后,高德地图初始化有问题加入的
|
||||
* 问题原因是:
|
||||
* skin 框架会替换 LayoutInflater 中的 setFactory2 从而导致高德 le 中的 setFactory 失效。
|
||||
* 解决方案为:
|
||||
* 直接通过内存地址替换整个 ArtMethod,来将需要修改的高德SDK中的方法指向我们修改过后的方法。
|
||||
*/
|
||||
public class lg2 extends lg {
|
||||
static le2 b;
|
||||
|
||||
public static View a(Context var0, int var1, ViewGroup var2) {
|
||||
XmlResourceParser var9 = a().getXml(var1);
|
||||
if (!a) {
|
||||
return LayoutInflater.from(var0).inflate(var9, var2);
|
||||
} else {
|
||||
try {
|
||||
if (b == null) {
|
||||
b = new le2(var0, c == -1 ? 0 : c, lg.class.getClassLoader());
|
||||
}
|
||||
b.a(c == -1 ? 0 : c);
|
||||
View var3 = LayoutInflater.from(b).inflate(var9, var2);
|
||||
return var3;
|
||||
} catch (Throwable var7) {
|
||||
var7.printStackTrace();
|
||||
np.c(var7, "ResourcesUtil", "selfInflate(Activity activity, int resource, ViewGroup root)");
|
||||
} finally {
|
||||
var9.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,10 @@ import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -18,6 +20,7 @@ import com.amap.api.navi.AMapNaviView;
|
||||
import com.amap.api.navi.AMapNaviViewOptions;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.view.RoundLayout;
|
||||
import com.mogo.utils.FileUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -31,8 +34,10 @@ import java.io.IOException;
|
||||
public class SmallMapDirectionView extends RelativeLayout {
|
||||
private String styleFilePath = "/mnt/sdcard/amap/small_map_style.data";
|
||||
|
||||
private RoundLayout rlSmallMapBorder;
|
||||
private AMapNaviView mAMapNaviView;
|
||||
private int zoomLevel = 15;
|
||||
private boolean mapIsLoaded = false;
|
||||
|
||||
public SmallMapDirectionView(Context context) {
|
||||
this(context, null);
|
||||
@@ -52,11 +57,11 @@ public class SmallMapDirectionView extends RelativeLayout {
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
|
||||
|
||||
AbsMogoApplication.getLayoutInflaterNoSkin().inflate(R.layout.module_small_map_view, this);
|
||||
|
||||
mAMapNaviView = findViewById(R.id.aMapNaviView);
|
||||
mAMapNaviView.onCreate(null);
|
||||
mAMapNaviView = AbsMogoApplication.getMapNaviView();
|
||||
rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder);
|
||||
rlSmallMapBorder.addView(mAMapNaviView);
|
||||
|
||||
// 车头朝上
|
||||
mAMapNaviView.setNaviMode(AMapNaviView.CAR_UP_MODE);
|
||||
@@ -133,7 +138,7 @@ public class SmallMapDirectionView extends RelativeLayout {
|
||||
// 2D模式
|
||||
options.setTilt(0);
|
||||
// 黑夜模式
|
||||
// options.setNaviNight(true);
|
||||
//options.setNaviNight(true);
|
||||
// 自定义地图样式
|
||||
options.setCustomMapStylePath(styleFilePath);
|
||||
mAMapNaviView.setViewOptions(options);
|
||||
@@ -143,23 +148,6 @@ public class SmallMapDirectionView extends RelativeLayout {
|
||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
aMap.moveCamera(cameraUpdate);
|
||||
|
||||
aMap.setOnMapLoadedListener(new AMap.OnMapLoadedListener() {
|
||||
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
//Log.w("onMapLoaded", "===onMapLoaded====");
|
||||
// 高德地图有bug,所以需要多次调用设置皮肤才能成功
|
||||
if (options != null) {
|
||||
options.setCustomMapStylePath(styleFilePath);
|
||||
mAMapNaviView.setViewOptions(options);
|
||||
}
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
aMap.moveCamera(cameraUpdate);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
// 判断是否有样式文件存在
|
||||
FileUtils.copy(
|
||||
@@ -205,6 +193,27 @@ public class SmallMapDirectionView extends RelativeLayout {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(500L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 高德地图有bug,所以需要多次调用设置皮肤才能成功
|
||||
if (options != null) {
|
||||
options.setCustomMapStylePath(styleFilePath);
|
||||
mAMapNaviView.setViewOptions(options);
|
||||
}
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
aMap.moveCamera(cameraUpdate);
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
||||
setOnClickListener(view -> {
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi()
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.mogo.module.small.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 2021/5/19 10:50 上午
|
||||
*/
|
||||
public class SmallMapFragment extends Fragment {
|
||||
private Context mContext;
|
||||
protected View mRootView;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if (mRootView == null) {
|
||||
mRootView = AbsMogoApplication.getLayoutInflaterNoSkin()
|
||||
.inflate(R.layout.module_small_map_fragment, container, false);
|
||||
} else {
|
||||
ViewGroup viewGroup = (ViewGroup) mRootView.getParent();
|
||||
if (viewGroup != null) {
|
||||
viewGroup.removeView(mRootView);
|
||||
}
|
||||
}
|
||||
return mRootView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.mogo.module.small.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.map.IMogoSmallMapProvider;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 12/10/20 1:34 PM
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_SMALL_MAP)
|
||||
public class SmallMapProvider implements IMogoSmallMapProvider, IMogoStatusChangedListener {
|
||||
private final String TAG = "SmallVisionProvider";
|
||||
|
||||
private Context mContext;
|
||||
private int mContainerId;
|
||||
private FragmentActivity mActivity;
|
||||
|
||||
private SmallMapFragment mSmallMapFragment;
|
||||
|
||||
@Override
|
||||
public void init(FragmentActivity activity, int containerId) {
|
||||
Log.d(TAG, "小地图模块初始化……init(FragmentActivity activity, int containerId)");
|
||||
mActivity = activity;
|
||||
mContainerId = containerId;
|
||||
|
||||
Logger.d(TAG, "addSmallMapView");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
Log.d(TAG, "小地图模块初始化……init(Context context)");
|
||||
mContext = context;
|
||||
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getStatusManagerApi()
|
||||
.registerStatusChangedListener(
|
||||
MogoServicePaths.PATH_SMALL_MAP,
|
||||
StatusDescriptor.VR_MODE,
|
||||
this);
|
||||
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getStatusManagerApi()
|
||||
.registerStatusChangedListener(
|
||||
MogoServicePaths.PATH_SMALL_MAP,
|
||||
StatusDescriptor.MAIN_PAGE_RESUME,
|
||||
this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPanel() {
|
||||
Log.d(TAG, "小地图模块触发展示……");
|
||||
if (mSmallMapFragment == null) {
|
||||
Logger.d(TAG, "准备add fragment======");
|
||||
mSmallMapFragment = new SmallMapFragment();
|
||||
mActivity.getSupportFragmentManager().beginTransaction().add(mContainerId, mSmallMapFragment).commit();
|
||||
return;
|
||||
}
|
||||
Logger.d(TAG, "准备show fragment");
|
||||
mActivity.getSupportFragmentManager().beginTransaction().show(mSmallMapFragment).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hidePanel() {
|
||||
Log.d(TAG, "小地图模块触发隐藏……");
|
||||
if (mSmallMapFragment != null) {
|
||||
Logger.d(TAG, "准备hide fragment");
|
||||
mActivity.getSupportFragmentManager().beginTransaction().hide(mSmallMapFragment).commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeAngle(double angle) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
|
||||
Log.d(TAG, "onStatusChanged……descriptor=" + descriptor + ",isTrue=" + isTrue);
|
||||
|
||||
if (descriptor == StatusDescriptor.VR_MODE) {
|
||||
if (isTrue) {
|
||||
showPanel();
|
||||
} else {
|
||||
hidePanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.mogo.module.small.map;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.view.Gravity;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
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 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");
|
||||
return null;
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
package com.mogo.module.small.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.amap.api.col.n3.lg;
|
||||
import com.amap.api.col.n3.lg2;
|
||||
import com.mogo.hook.HookManager;
|
||||
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;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 12/10/20 1:34 PM
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_SMALL_MAP)
|
||||
public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusChangedListener {
|
||||
private final String TAG = "SmallVisionProvider";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private WindowManagerView mWindowManagerView;
|
||||
private SmallMapDirectionView mSmallMapDirectionView;
|
||||
|
||||
@Override
|
||||
public Fragment createFragment(Context context, Bundle data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(Context context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return ModuleType.TYPE_SERVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
Log.d(TAG, "小地图模块初始化……");
|
||||
mContext = context;
|
||||
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getStatusManagerApi()
|
||||
.registerStatusChangedListener(
|
||||
MogoServicePaths.PATH_SMALL_MAP,
|
||||
StatusDescriptor.VR_MODE,
|
||||
this);
|
||||
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getStatusManagerApi()
|
||||
.registerStatusChangedListener(
|
||||
MogoServicePaths.PATH_SMALL_MAP,
|
||||
StatusDescriptor.MAIN_PAGE_RESUME,
|
||||
this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Log.d(TAG, "小地图模块销毁……");
|
||||
hidePanel();
|
||||
// 释放组件内存
|
||||
mSmallMapDirectionView = null;
|
||||
mWindowManagerView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPanel() {
|
||||
Log.d(TAG, "小地图模块触发展示……");
|
||||
addSmallMapView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hidePanel() {
|
||||
Log.d(TAG, "小地图模块触发隐藏……");
|
||||
if (mWindowManagerView != null && mWindowManagerView.isShowing()) {
|
||||
mWindowManagerView.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeAngle(double angle) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
|
||||
Log.d(TAG, "onStatusChanged……descriptor=" + descriptor + ",isTrue=" + isTrue);
|
||||
|
||||
if (descriptor == StatusDescriptor.VR_MODE) {
|
||||
if (isTrue) {
|
||||
showPanel();
|
||||
} else {
|
||||
hidePanel();
|
||||
}
|
||||
}
|
||||
if (descriptor == StatusDescriptor.MAIN_PAGE_RESUME) {
|
||||
// 只有 VR 模式下才进行展示
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (isTrue) {
|
||||
showPanel();
|
||||
} else {
|
||||
hidePanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加小地图View
|
||||
*/
|
||||
private void addSmallMapView() {
|
||||
Logger.d(TAG, "addSmallMapView");
|
||||
|
||||
try {
|
||||
// 替换高德地图的方法,解决因为加入换肤框架导致地图初始化失败
|
||||
Method srcMethod = lg.class.getDeclaredMethod("a", Context.class, int.class, ViewGroup.class);
|
||||
Method destMethod = lg2.class.getDeclaredMethod("a", Context.class, int.class, ViewGroup.class);
|
||||
HookManager.get().hookMethod(srcMethod, destMethod);
|
||||
Logger.d(TAG, "hook 高德地图成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 初始化小地图控件
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.mogo.module.small.map.SmallMapDirectionView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/smallMapDirectionView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.mogo.module.small.map.SmallMapDirectionView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -6,7 +6,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
tools:parentTag="RelativeLayout">
|
||||
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/module_small_map_view_border_width"
|
||||
android:layout_height="@dimen/module_small_map_view_border_height"
|
||||
@@ -16,16 +15,16 @@
|
||||
|
||||
<com.mogo.module.common.view.RoundLayout
|
||||
android:id="@+id/rlSmallMapBorder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/module_small_map_view_width"
|
||||
android:layout_height="@dimen/module_small_map_view_width"
|
||||
android:layout_centerInParent="true"
|
||||
app:roundLayoutRadius="360dp">
|
||||
|
||||
<com.amap.api.navi.AMapNaviView
|
||||
android:id="@+id/aMapNaviView"
|
||||
android:layout_width="@dimen/module_small_map_view_width"
|
||||
android:layout_height="@dimen/module_small_map_view_width" />
|
||||
|
||||
<!--TODO Hook方案在Pad上有问题,优先 效果,后面在看如何解决-->
|
||||
<!-- <com.amap.api.navi.AMapNaviView
|
||||
android:id="@+id/aMapNaviView"
|
||||
android:layout_width="@dimen/module_small_map_view_width"
|
||||
android:layout_height="@dimen/module_small_map_view_width" />-->
|
||||
</com.mogo.module.common.view.RoundLayout>
|
||||
|
||||
</merge>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_small_map_padding">40px</dimen>
|
||||
|
||||
<dimen name="module_small_map_view_border_width">400px</dimen>
|
||||
<dimen name="module_small_map_view_border_height">400px</dimen>
|
||||
|
||||
<dimen name="module_small_map_view_width">370px</dimen>
|
||||
<dimen name="module_small_map_view_height">370px</dimen>
|
||||
|
||||
<dimen name="module_small_map_view_x">1620px</dimen>
|
||||
<dimen name="module_small_map_view_y">780px</dimen>
|
||||
|
||||
<dimen name="module_small_map_big_view_x">0px</dimen>
|
||||
<dimen name="module_small_map_big_view_y">0px</dimen>
|
||||
<dimen name="module_small_map_big_view_width">1920px</dimen>
|
||||
<dimen name="module_small_map_big_view_height">1080px</dimen>
|
||||
</resources>
|
||||
@@ -2,14 +2,12 @@
|
||||
<resources>
|
||||
<dimen name="module_small_map_padding">30px</dimen>
|
||||
|
||||
<dimen name="module_small_map_border_view_width">400px</dimen>
|
||||
<dimen name="module_small_map_border_view_height">400px</dimen>
|
||||
|
||||
<dimen name="module_small_map_view_border_width">288px</dimen>
|
||||
<dimen name="module_small_map_view_border_height">288px</dimen>
|
||||
|
||||
<dimen name="module_small_map_view_width">260px</dimen>
|
||||
<dimen name="module_small_map_view_height">260px</dimen>
|
||||
|
||||
<dimen name="module_small_map_view_x">1620px</dimen>
|
||||
<dimen name="module_small_map_view_y">780px</dimen>
|
||||
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
package com.mogo.service.map;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 12/10/20 1:36 PM
|
||||
*/
|
||||
public interface IMogoSmallMapProvider extends IMogoModuleProvider {
|
||||
public interface IMogoSmallMapProvider extends IProvider {
|
||||
|
||||
/**
|
||||
* 初始化网约车容器
|
||||
*
|
||||
* @param activity
|
||||
* @param containerId 容器ID
|
||||
*/
|
||||
void init(FragmentActivity activity, @IdRes int containerId );
|
||||
|
||||
/**
|
||||
* 显示面板
|
||||
|
||||
Reference in New Issue
Block a user