Merge branch 'feat_overview_mode_290' into dev_robotaxi-d-app-module_290_220715_2.9.0

全览模式合并到远端290
This commit is contained in:
liujing
2022-07-20 11:54:05 +08:00
67 changed files with 2555 additions and 488 deletions

View File

@@ -149,4 +149,9 @@ public class MoGoHandAdasMsgManager implements
@Override
public void onAutopilotDataException(long timestamp) {
}
@Override
public void onAutopilotAcc(float carAcc) {
}
}

View File

@@ -95,6 +95,7 @@ public class BindingcarProvider implements IMoGoBindingcarProvider {
private void driverScreen(String macAddress, String widevineIDWithMd5) {
long currentHour = System.currentTimeMillis() / (1000 * 60);
long oldHour = SharedPrefsMgr.getInstance(mContext).getLong("typeDriver", 0);
Log.d("liyz", "driverScreen --------> ");
//如果2分钟内频繁调需要拦截业务导致的会多次请求工控机信息
if (HmiBuildConfig.isShowSnBindingView) {
if (currentHour - oldHour > 1) {
@@ -107,6 +108,7 @@ public class BindingcarProvider implements IMoGoBindingcarProvider {
private void passengerScreen(String macAddress, String widevineIDWithMd5) {
long currentHour = System.currentTimeMillis() / (1000 * 60);
long oldHour = SharedPrefsMgr.getInstance(mContext).getLong("typePassenger", 0);
Log.d("liyz", "passengerScreen --------> ");
//如果2分钟内频繁调需要拦截业务导致的会多次请求工控机信息
if (HmiBuildConfig.isShowSnBindingView) {
if (currentHour - oldHour > 1) {

View File

@@ -66,6 +66,11 @@ internal class CanImpl(ctx: Context): IFlow<CanStatus>(ctx), IMoGoAutopilotVehic
send(CanStatus(false))
}
override fun onAutopilotAcc(carAcc: Float) {
send(CanStatus(isCanEnabled()))
timeOutCheck()
}
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) {
super.onAutopilotGuardian(guardianInfo)
send(CanStatus(isCanEnabled()))

View File

@@ -1956,6 +1956,10 @@ class DebugSettingView @JvmOverloads constructor(
}
}
override fun onAutopilotAcc(carAcc: Float) {
}
/**
* 吐司提示
*/

View File

@@ -176,6 +176,15 @@ public class SteeringWheelView extends ConstraintLayout {
Log.d(TAG, "刹车灯:" + String.valueOf(brakeLight));
}
/**
* 车辆加速度
* @param carAcc
*/
@Override
public void onAutopilotAcc(float carAcc) {
}
/**
* 方向盘转向角 左+右-
* @param steering
@@ -223,7 +232,7 @@ public class SteeringWheelView extends ConstraintLayout {
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "档位" + gear.toString());
Log.d(TAG, "乘客屏档位" + gear.toString());
if (tapPositionView != null) {
tapPositionView.updateWithGear(gear);
}

View File

@@ -1,6 +1,7 @@
package com.mogo.eagle.core.function.hmi.ui.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.Log;
@@ -30,6 +31,7 @@ public class TapPositionView extends ConstraintLayout {
private TextView tabR;
private TextView tabN;
private TextView tabD;
private TypedArray typedArray;
public TapPositionView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
@@ -39,90 +41,48 @@ public class TapPositionView extends ConstraintLayout {
tabR = findViewById(R.id.tap_r);
tabN = findViewById(R.id.tap_n);
tabD = findViewById(R.id.tap_d);
typedArray = context.obtainStyledAttributes(attrs, R.styleable.TapPositionView);
}
public void updateWithGear(@NotNull Chassis.GearPosition gear) {
if (tabP != null && tabR != null && tabN != null && tabD != null) {
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
taxiGear(gear);
} else {
busGear(gear);
int defaultColor = typedArray.getColor(R.styleable.TapPositionView_defaultColor, -1);
int selectColor = typedArray.getColor(R.styleable.TapPositionView_selectColor, -1);
Log.d(TAG, "gear:" + gear);
switch (gear) {
case GEAR_NONE:
tabP.setTextColor(defaultColor);
tabR.setTextColor(defaultColor);
tabN.setTextColor(defaultColor);
tabD.setTextColor(defaultColor);
break;
case GEAR_P:
tabP.setTextColor(selectColor);
tabR.setTextColor(defaultColor);
tabN.setTextColor(defaultColor);
tabD.setTextColor(defaultColor);
break;
case GEAR_R:
tabR.setTextColor(selectColor);
tabP.setTextColor(defaultColor);
tabN.setTextColor(defaultColor);
tabD.setTextColor(defaultColor);
break;
case GEAR_N:
tabN.setTextColor(selectColor);
tabR.setTextColor(defaultColor);
tabP.setTextColor(defaultColor);
tabD.setTextColor(defaultColor);
break;
case GEAR_D:
tabD.setTextColor(selectColor);
tabN.setTextColor(defaultColor);
tabR.setTextColor(defaultColor);
tabP.setTextColor(defaultColor);
break;
default:
break;
}
}
}
private void busGear(@NotNull Chassis.GearPosition gear) {
switch (gear) {
case GEAR_NONE:
tabP.setTextColor(Color.parseColor("#6E8EC9"));
tabR.setTextColor(Color.parseColor("#6E8EC9"));
tabN.setTextColor(Color.parseColor("#6E8EC9"));
tabD.setTextColor(Color.parseColor("#6E8EC9"));
break;
case GEAR_P:
tabP.setTextColor(Color.parseColor("#0043FF"));
tabR.setTextColor(Color.parseColor("#6E8EC9"));
tabN.setTextColor(Color.parseColor("#6E8EC9"));
tabD.setTextColor(Color.parseColor("#6E8EC9"));
break;
case GEAR_R:
tabR.setTextColor(Color.parseColor("#0043FF"));
tabP.setTextColor(Color.parseColor("#6E8EC9"));
tabN.setTextColor(Color.parseColor("#6E8EC9"));
tabD.setTextColor(Color.parseColor("#6E8EC9"));
break;
case GEAR_N:
tabN.setTextColor(Color.parseColor("#0043FF"));
tabR.setTextColor(Color.parseColor("#6E8EC9"));
tabP.setTextColor(Color.parseColor("#6E8EC9"));
tabD.setTextColor(Color.parseColor("#6E8EC9"));
break;
case GEAR_D:
tabD.setTextColor(Color.parseColor("#0043FF"));
tabN.setTextColor(Color.parseColor("#6E8EC9"));
tabR.setTextColor(Color.parseColor("#6E8EC9"));
tabP.setTextColor(Color.parseColor("#6E8EC9"));
break;
default:
break;
}
}
private void taxiGear(@NotNull Chassis.GearPosition gear) {
switch (gear) {
case GEAR_NONE:
tabP.setTextColor(Color.parseColor("#FF6E8EC9"));
tabR.setTextColor(Color.parseColor("#FF6E8EC9"));
tabN.setTextColor(Color.parseColor("#FF6E8EC9"));
tabD.setTextColor(Color.parseColor("#FF6E8EC9"));
break;
case GEAR_P:
tabP.setTextColor(Color.parseColor("#FFFFFFFF"));
tabR.setTextColor(Color.parseColor("#FF6E8EC9"));
tabN.setTextColor(Color.parseColor("#FF6E8EC9"));
tabD.setTextColor(Color.parseColor("#FF6E8EC9"));
break;
case GEAR_R:
tabR.setTextColor(Color.parseColor("#FFFFFFFF"));
tabP.setTextColor(Color.parseColor("#FF6E8EC9"));
tabN.setTextColor(Color.parseColor("#FF6E8EC9"));
tabD.setTextColor(Color.parseColor("#FF6E8EC9"));
break;
case GEAR_N:
tabN.setTextColor(Color.parseColor("#FFFFFFFF"));
tabR.setTextColor(Color.parseColor("#FF6E8EC9"));
tabP.setTextColor(Color.parseColor("#FF6E8EC9"));
tabD.setTextColor(Color.parseColor("#FF6E8EC9"));
break;
case GEAR_D:
tabD.setTextColor(Color.parseColor("#FFFFFFFF"));
tabN.setTextColor(Color.parseColor("#FF6E8EC9"));
tabR.setTextColor(Color.parseColor("#FF6E8EC9"));
tabP.setTextColor(Color.parseColor("#FF6E8EC9"));
break;
default:
break;
}
}
}

View File

@@ -0,0 +1,173 @@
package com.mogo.eagle.core.function.hmi.ui.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager;
import com.mogo.eagle.core.function.hmi.R;
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import org.jetbrains.annotations.NotNull;
import java.math.BigDecimal;
import chassis.Chassis;
/**
* @author Jing
* @description 速度 加速度 档位 刹车 油门状态值
* @since: 6/24/22
*/
public class TrafficDataView extends ConstraintLayout {
private static final String TAG = "TrafficDataView";
private TapPositionView tapPositionView;
private TextView speedTextView;
private TextView accTextView;
private ImageView speedImage;
//圆弧颜色
private int mArcColor;
public TrafficDataView(@NonNull Context context) {
super(context);
}
public TrafficDataView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initView(context);
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener);
}
public TrafficDataView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public TrafficDataView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
private void initView(@NonNull Context context) {
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
// LayoutInflater.from(context).inflate(R.layout.hmi_traffic_data, this);
} else {
}
LayoutInflater.from(context).inflate(R.layout.hmi_traffic_data, this);
tapPositionView = findViewById(R.id.traffic_position);
speedImage = findViewById(R.id.speedImage);
speedTextView = findViewById(R.id.speedTextView);
accTextView = findViewById(R.id.speedAccTextView);
}
private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() {
/**
* 车辆转向灯
* @param lightSwitch
*/
@Override
public void onAutopilotLightSwitchData(@org.jetbrains.annotations.Nullable Chassis.LightSwitch lightSwitch) {
Log.d(TAG, "车辆转向灯:" + lightSwitch.toString());
}
/**
* 刹车灯
* @param brakeLight
*/
@Override
public void onAutopilotBrakeLightData(boolean brakeLight) {
Log.d(TAG, "刹车灯:" + String.valueOf(brakeLight));
}
/**
* 方向盘转向角 左+右-
* @param steering
*/
@Override
public void onAutopilotSteeringData(float steering) {
Log.d(TAG, "steering原始值====" + String.valueOf(steering));
if (Math.abs(steering) < 1) {
steering = 0;
}
float steeringValue = steering;
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "steering忽略小数点后====" + String.valueOf((int) steeringValue));
}
});
}
/**
* 档位
* @param gear
*/
@Override
public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) {
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "司机屏档位" + gear.toString());
if (tapPositionView != null) {
tapPositionView.updateWithGear(gear);
}
}
});
}
@Override
public void onAutopilotDataException(long timestamp) {
}
@Override
public void onAutopilotAcc(float carAcc) {
Log.d(TAG, "司机屏加速度:" + carAcc);
java.text.DecimalFormat myformat = new java.text.DecimalFormat("0.00");
String accStr = myformat.format(carAcc);
accTextView.setText("a: " + accStr);
}
};
/**
* 设置弧形颜色
*
* @param value 颜色值
*/
public void setArcColor(int value) {
mArcColor = value;
}
/**
* 设置数据
*
* @param value 当前绘制的值
*/
public void setValues(int value) {
}
/**
* value呈现
*/
public void updateSpeedWithValue(int newSpeed) {
if (speedTextView != null) {
speedTextView.setText(String.valueOf(newSpeed));
}
if (speedImage != null) {
speedImage.setBackgroundResource(newSpeed > 60 ? R.drawable.traffic_data_speed_warning : R.drawable.traffic_data_speed);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -51,7 +51,7 @@
android:layout_marginTop="@dimen/dp_72"
android:layout_marginRight="-16px"
android:gravity="right"
android:text="180°"
android:text="0°"
android:textColor="#415479"
android:textSize="@dimen/dp_38"
android:visibility="invisible"
@@ -65,7 +65,7 @@
android:layout_marginLeft="-16px"
android:layout_marginTop="@dimen/dp_72"
android:gravity="left"
android:text="180°"
android:text="0°"
android:textColor="#415479"
android:textSize="@dimen/dp_38"
app:layout_constraintLeft_toRightOf="@+id/steering_circular"
@@ -87,6 +87,8 @@
android:layout_width="@dimen/dp_390"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_42"
app:defaultColor = "@color/p_default_txt_color"
app:selectColor="@color/bus_p_select_txt_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"

View File

@@ -88,6 +88,8 @@
android:layout_width="@dimen/dp_272"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_30"
app:defaultColor="@color/p_default_txt_color"
app:selectColor="@color/dark_mode_select_txt_color"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/steering_circular_alpha" />

View File

@@ -12,7 +12,7 @@
android:gravity="center"
android:text="P"
android:textAlignment="center"
android:textColor="#6E8EC9"
android:textColor="@color/p_default_txt_color"
android:textSize="@dimen/dp_46"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
@@ -27,7 +27,7 @@
android:gravity="center"
android:text="R"
android:textAlignment="center"
android:textColor="#6E8EC9"
android:textColor="@color/p_default_txt_color"
android:textSize="@dimen/dp_46"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
@@ -42,7 +42,7 @@
android:gravity="center"
android:text="N"
android:textAlignment="center"
android:textColor="#6E8EC9"
android:textColor="@color/p_default_txt_color"
android:textSize="@dimen/dp_46"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
@@ -57,7 +57,7 @@
android:gravity="center"
android:text="D"
android:textAlignment="center"
android:textColor="#0043FF"
android:textColor="@color/p_default_txt_color"
android:textSize="@dimen/dp_46"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"

View File

@@ -0,0 +1,85 @@
<?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="@dimen/dp_616"
android:layout_height="@dimen/dp_320"
android:background="@drawable/traffic_data_back">
<ImageView
android:id="@+id/speedImage"
android:layout_width="@dimen/dp_270"
android:layout_height="@dimen/dp_270"
android:layout_marginLeft="@dimen/dp_46"
android:background="@drawable/traffic_data_speed"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/speedTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80px"
android:text="0"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="@dimen/dp_70"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="@+id/speedImage"
app:layout_constraintRight_toRightOf="@+id/speedImage"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/kmTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_176"
android:text="KM/H"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="@dimen/dp_30"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="@+id/speedImage"
app:layout_constraintRight_toRightOf="@+id/speedImage"
app:layout_constraintTop_toTopOf="parent" />
<com.mogo.eagle.core.function.hmi.ui.widget.TapPositionView
android:id="@+id/traffic_position"
android:layout_width="@dimen/dp_220"
app:defaultColor="@color/acc_default_txt_color"
app:selectColor="@color/dark_mode_select_txt_color"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_28"
android:layout_marginTop="@dimen/dp_80"
android:layout_marginRight="@dimen/dp_80"
app:layout_constraintLeft_toRightOf="@+id/speedImage"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/brakeStatus"
android:layout_width="@dimen/dp_66"
android:layout_height="@dimen/dp_68"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_174"
android:layout_marginBottom="@dimen/dp_57"
android:src="@drawable/traffic_data_empty"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/speedImage"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/speedAccTextView"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_56"
android:layout_marginLeft="@dimen/dp_42"
android:layout_marginTop="@dimen/dp_190"
android:text="a: "
android:textAlignment="viewStart"
android:textColor="#fff"
android:textSize="@dimen/dp_40"
app:layout_constraintLeft_toLeftOf="@+id/brakeStatus"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -6,4 +6,5 @@
<color name="notice_check_dialog_bg_color">#E63B4577</color>
<color name="notice_traffic_line">#555C7E</color>
<color name="notice_dialog_back">#3B4577</color>
<color name="acc_default_txt_color">#FF343C63</color>
</resources>

View File

@@ -49,4 +49,8 @@
<attr name="progress" format="integer" /> <!--圆环进度-->
</declare-styleable>
<declare-styleable name="TapPositionView">
<attr name="defaultColor" format="color"/> <!--档位默认色值-->
<attr name="selectColor" format="color"/> <!--当前档位色值-->
</declare-styleable>
</resources>

View File

@@ -60,4 +60,9 @@
<color name="hmi_light_blue_alpha_00">#D945D3FF</color>
<color name="hmi_light_blue_alpha_ff">#D93261B6</color>
<color name="hmi_clear_00">#00FFFFFF</color>
<color name="acc_default_txt_color">#FF343C63</color>
<color name="bus_p_select_txt_color">#0043FF</color>
<color name="p_default_txt_color">#FF6E8EC9</color>
<color name="dark_mode_select_txt_color">#FFFFFFFF</color>
</resources>

View File

@@ -211,6 +211,7 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
@Override
public void onDestroyView() {
CallerSkinModeListenerManager.INSTANCE.removeListener(TAG);
CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(TAG);
if (mMogoMapView != null) {
mMogoMapView.onDestroy();
mMogoMapView = null;

View File

@@ -203,7 +203,7 @@ public class AMapCustomView
// options.setTilt((int) tilt);
//自车车标
options.setCarBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.module_small_map_view_my_location_logo));
// options.setFourCornersBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.amap_custom_corner));
options.setFourCornersBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.amap_custom_corner));
options.setStartPointBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.module_small_map_view_dir_start));
options.setWayPointBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.icon_module_small_map_four_corners));
options.setEndPointBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.module_small_map_view_dir_end));
@@ -212,11 +212,11 @@ public class AMapCustomView
//路线纹理自定义
RouteOverlayOptions routeOverlayOptions = new RouteOverlayOptions();
routeOverlayOptions.setTurnArrowIs3D(false);
// routeOverlayOptions.setUnknownTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.custtexture_no));//未知路段
// routeOverlayOptions.setSmoothTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.amap_custom_smooth_route));
// routeOverlayOptions.setJamTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.custtexture_bad));//拥堵路段
// routeOverlayOptions.setVeryJamTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.custtexture_grayred));//超级拥堵路段
// routeOverlayOptions.setPassRoute(BitmapFactory.decodeResource(getResources(), R.drawable.amap_custom_pass_route));//走过的路段
routeOverlayOptions.setUnknownTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.custtexture_no));//未知路段
routeOverlayOptions.setSmoothTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.amap_custom_smooth_route));
routeOverlayOptions.setJamTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.custtexture_bad));//拥堵路段
routeOverlayOptions.setVeryJamTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.custtexture_grayred));//超级拥堵路段
routeOverlayOptions.setPassRoute(BitmapFactory.decodeResource(getResources(), R.drawable.amap_custom_pass_route));//走过的路段
options.setRouteOverlayOptions(routeOverlayOptions);
mAMapNaviView.setViewOptions(options);
}
@@ -691,8 +691,8 @@ public class AMapCustomView
// 加载自定义样式
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
.setEnable(true)
.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext()))
.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext()));
.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(),"over_view_style.data"))
.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(),"over_view_style_extra.data"));
// 设置自定义样式
mAMap.setCustomMapStyle(customMapStyleOptions);
}

View File

@@ -0,0 +1,121 @@
package com.mogo.eagle.core.function.smp;
import com.amap.api.maps.AMapUtils;
import com.amap.api.maps.model.LatLng;
import com.amap.api.navi.model.NaviLatLng;
import com.autonavi.amap.mapcore.IPoint;
import com.autonavi.amap.mapcore.MapProjection;
/**
* 包名: com.amap.navi.demo.util
* <p>
* 创建时间2018/4/19
* 项目名称NaviDemo
*
* @author guibao.ggb
* @email guibao.ggb@alibaba-inc.com
* <p>
* 类说明:
*/
public class NaviUtil {
public static float calculateDistance(NaviLatLng start, NaviLatLng end) {
double x1 = start.getLongitude();
double y1 = start.getLatitude();
double x2 = end.getLongitude();
double y2 = end.getLatitude();
return AMapUtils.calculateLineDistance(new LatLng(y1, x1), new LatLng(y2, x2));
}
public static NaviLatLng getPointForDis(NaviLatLng sPt, NaviLatLng ePt, double dis) {
double lSegLength = calculateDistance(sPt, ePt);
NaviLatLng pt = new NaviLatLng();
double preResult = dis / lSegLength;
pt.setLatitude(((ePt.getLatitude() - sPt.getLatitude()) * preResult + sPt.getLatitude()));
pt.setLongitude(((ePt.getLongitude() - sPt.getLongitude()) * preResult + sPt.getLongitude()));
return pt;
}
/**
* 根据经纬度计算需要偏转的角度
*
* @param startPoi
* @param secondPoi
* @return
*/
public static float getRotate(NaviLatLng startPoi, NaviLatLng secondPoi) {
float rotate = 0;
try {
IPoint point1 = new IPoint();
IPoint point2 = new IPoint();
MapProjection.lonlat2Geo(startPoi.getLongitude(), startPoi.getLatitude(), point1);
MapProjection.lonlat2Geo(secondPoi.getLongitude(), secondPoi.getLatitude(), point2);
double x1 = point1.x;
double x2 = point2.x;
double y1 = point1.y;
double y2 = point2.y;
rotate = (float) (Math.atan2(y2 - y1, x2 - x1) / Math.PI * 180);
rotate = rotate + 90;
return rotate;
} catch (Exception e) {
e.printStackTrace();
}
return rotate;
}
public static final int MAXZOOMLEVEL = 20;
public static final int PIXELSPERTILE = 256;
public static final double MINLATITUDE = -85.0511287798;
public static final double MAXLATITUDE = 85.0511287798;
public static final double MINLONGITUDE = -180;
public static final double MAXLONGITUDE = 180;
public static final int EARTHRADIUSINMETERS = 6378137;
public static final int TILESPLITLEVEL = 0;
public static final double EarthCircumferenceInMeters = 2 * Math.PI
* EARTHRADIUSINMETERS;
public static double clip(double n, double minValue, double maxValue) {
return Math.min(Math.max(n, minValue), maxValue);
}
public static IPoint lonlat2Geo(double latitude, double longitude,
int levelOfDetail) {
IPoint rPnt = new IPoint();
latitude = clip(latitude, MINLATITUDE, MAXLATITUDE) * Math.PI / 180;
longitude = clip(longitude, MINLONGITUDE, MAXLONGITUDE) * Math.PI / 180;
double sinLatitude = Math.sin(latitude);
double xMeters = EARTHRADIUSINMETERS * longitude;
double lLog = Math.log((1 + sinLatitude) / (1 - sinLatitude));
double yMeters = EARTHRADIUSINMETERS / 2 * lLog;
long numPixels = (long) PIXELSPERTILE << levelOfDetail;
double metersPerPixel = EarthCircumferenceInMeters / numPixels;
rPnt.x = (int) clip((EarthCircumferenceInMeters / 2 + xMeters)
/ metersPerPixel + 0.5, 0, numPixels - 1);
long tmp = (long) (EarthCircumferenceInMeters / 2 - yMeters);
rPnt.y = (int) clip((double) tmp / metersPerPixel + 0.5, 0,
numPixels - 1);
return rPnt;
}
public static String formatKM(int d) {
if (d == 0) {
return "0米";
} else if (d < 100) {
return d + "";
} else if ((100 <= d) && (d < 1000)) {
return d + "";
} else if ((1000 <= d) && (d < 10000)) {
return (d / 10) * 10 / 1000.0D + "公里";
} else if ((10000 <= d) && (d < 100000)) {
return (d / 100) * 100 / 1000.0D + "公里";
}
return (d / 1000) + "公里";
}
}

View File

@@ -1,356 +0,0 @@
package com.mogo.eagle.core.function.smp;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_MAP;
import android.content.Context;
import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.RelativeLayout;
import androidx.annotation.Nullable;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdate;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.CoordinateConverter;
import com.amap.api.maps.TextureMapView;
import com.amap.api.maps.UiSettings;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.CameraPosition;
import com.amap.api.maps.model.CustomMapStyleOptions;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.LatLngBounds;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.Polyline;
import com.amap.api.maps.model.PolylineOptions;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.map.R;
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils;
import com.mogo.eagle.core.function.smp.view.ISmallMapDirectionView;
import com.mogo.eagle.core.widget.RoundLayout;
import com.mogo.module.common.utils.DrivingDirectionUtils;
import java.util.ArrayList;
import java.util.List;
/**
* 小地图的方向View
*
* @author donghongyu
* @date 12/14/20 4:40 PM
*/
public class SmallMapDirectionView
extends RelativeLayout
implements IMoGoMapLocationListener, ISmallMapDirectionView {
//小地图名称
public static final String TAG = "SmallMapDirectionView";
private RoundLayout rlSmallMapBorder;
private TextureMapView mAMapNaviView;
private AMap mAMap;
private Marker mCarMarker;
private Marker mStartMarker;
private Marker mEndMarker;
private int zoomLevel = 15;
private final List<LatLng> mCoordinatesLatLng = new ArrayList<>();
private final List<MogoLatLng> mCoordinatesLatLngCurrent = new ArrayList<>();
private Polyline mPolyline;
private CameraUpdate mCameraUpdate;
private Context mContext;
public SmallMapDirectionView(Context context) {
this(context, null);
}
public SmallMapDirectionView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public SmallMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
try {
initView(context);
} catch (Exception e) {
e.printStackTrace();
}
}
private void initView(Context context) {
mContext = context;
View smpView = LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
mAMapNaviView = smpView.findViewById(R.id.aMapNaviView);
// rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder);
// rlSmallMapBorder.addView(mAMapNaviView);
initAMapView();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG);
}
private void initAMapView() {
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
mAMap = mAMapNaviView.getMap();
// 关闭地图文字标注
mAMap.showMapText(false);
// 设置导航地图模式aMap是地图控制器对象。
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
// 关闭显示实时路况图层aMap是地图控制器对象。
mAMap.setTrafficEnabled(false);
// 设置 锚点 图标
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo))
.anchor(0.5f, 0.5f));
mStartMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start)));
mEndMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end)));
// 加载自定义样式
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
.setEnable(true)
.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext()))
.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext()));
// 设置自定义样式
mAMap.setCustomMapStyle(customMapStyleOptions);
//设置希望展示的地图缩放级别
mAMap.moveCamera(mCameraUpdate);
// 设置地图的样式
UiSettings uiSettings = mAMap.getUiSettings();
uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
uiSettings.setAllGesturesEnabled(false);// 所有手势
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
mAMap.setOnMapLoadedListener(() -> {
CallerLogger.INSTANCE.d(M_MAP + TAG, "smp---onMapLoaded");
// 加载自定义样式
CustomMapStyleOptions customMapStyleOptions1 = new CustomMapStyleOptions()
.setEnable(true)
.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext()))
.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext()));
// 设置自定义样式
mAMap.setCustomMapStyle(customMapStyleOptions1);
mAMapNaviView.getMap().setPointToCenter(mAMapNaviView.getWidth() / 2, mAMapNaviView.getHeight() / 2);
});
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return true;
}
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from) {
if (location == null) {
return;
}
if (mCarMarker == null){
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo))
.anchor(0.5f, 0.5f));
}
if(mCarMarker == null){
return;
}
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
//更新车辆位置
mCarMarker.setPosition(currentLatLng);
CameraPosition cameraPosition;
if (mCoordinatesLatLng.size() > 1) {
// mCoordinatesLatLngCurrent.clear();
// for (LatLng lng : mCoordinatesLatLng) {
// MogoLatLng mogoLatLng = new MogoLatLng(lng.latitude, lng.longitude);
// mCoordinatesLatLngCurrent.add(mogoLatLng);
// }
// removeLoction(latLng);
// 结束位置
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
// 与结束位置进行 GeoHash 0-12
// GeoHash endGeoHash = GeoHash.withCharacterPrecision(endLatLng.latitude, endLatLng.longitude, 7);
// GeoHash currentGeoHash = GeoHash.withCharacterPrecision(currentLatLng.latitude, currentLatLng.longitude, 7);
float calculateDistance = CoordinateUtils.calculateLineDistance(
endLatLng.latitude, endLatLng.longitude,
currentLatLng.latitude, currentLatLng.longitude
);
CallerLogger.INSTANCE.d(M_MAP + TAG, "calculateDistance=" + calculateDistance);
if (calculateDistance <= 5) {
clearPolyline();
mCoordinatesLatLng.clear();
}
cameraPosition = new CameraPosition.Builder().target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
} else {
//设置希望展示的地图缩放级别
cameraPosition = new CameraPosition.Builder().target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
// mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, zoomLevel));
}
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
private void removeLocation(Location latLng) {
for (LatLng l : mCoordinatesLatLng) {
if (!isPointOnCarFront(latLng, l)) {
mCoordinatesLatLng.remove(l);
}
}
}
public static boolean isPointOnCarFront(Location carLocal, LatLng pointLocal) {
double carLon = carLocal.getLongitude();
double carLat = carLocal.getLatitude();
double poiLon = pointLocal.longitude;
double poiLat = pointLocal.latitude;
float carAngle = carLocal.getBearing();
// 计算车辆与点之间的夹角
int diffAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
carLon, carLat, poiLon, poiLat, (int) carAngle);
return diffAngle <= 90;
}
@Override
public void drawablePolyline() {
clearPolyline();
// mCoordinatesLatLng.clear();
// List<LatLng> latLngs = CoordinateConverterFrom84ForList(mContext,coordinates);
// mCoordinatesLatLng.addAll(latLngs);
// for (LatLng coordinate : mCoordinatesLatLng) {
// mCoordinatesLatLng.add(new LatLng(coordinate.getLat(), coordinate.getLon()));
// }
if (mAMap != null) {
if (mCoordinatesLatLng.size() > 2) {
// 设置开始结束Marker位置
mStartMarker.setPosition(mCoordinatesLatLng.get(0));
mEndMarker.setPosition(mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1));
mStartMarker.setToTop();
mStartMarker.setVisible(true);
mEndMarker.setVisible(true);
mEndMarker.setToTop();
//存放所有点的经纬度
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
for (int i = 0; i < mCoordinatesLatLng.size(); i++) {
//把所有点都include进去LatLng类型
boundsBuilder.include(mCoordinatesLatLng.get(i));
}
//第二个参数为四周留空宽度
mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(boundsBuilder.build(), 30));
// 绘制线
mPolyline = mAMap.addPolyline(
new PolylineOptions()
.addAll(mCoordinatesLatLng)
.color(Color.argb(255, 31, 127, 255))
.width(12));
}
// else {
// //设置希望展示的地图缩放级别
// mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mCoordinatesLatLng.get(0), zoomLevel));
// }
}
}
public LatLng CoordinateConverterFrom84(Context mContext, MogoLatLng mogoLatLng) {
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
mCoordinateConverter.coord(new LatLng(mogoLatLng.lat, mogoLatLng.lon));
return mCoordinateConverter.convert();
}
public List<LatLng> CoordinateConverterFrom84ForList(Context mContext, List<MogoLatLng> mogoLatLngList) {
List<LatLng> list = new ArrayList<>();
for (MogoLatLng m : mogoLatLngList) {
LatLng mogoLatLng = CoordinateConverterFrom84(mContext, m);
list.add(mogoLatLng);
}
return list;
}
@Override
public void clearPolyline() {
// mCoordinatesLatLng.clear();
if (mPolyline != null) {
mPolyline.remove();
}
if (mStartMarker != null) {
mStartMarker.setVisible(false);
}
if (mEndMarker != null) {
mEndMarker.setVisible(false);
}
}
public void resetPolyLine() {
mCoordinatesLatLng.clear();
if (mPolyline != null) {
mPolyline.remove();
}
if (mStartMarker != null) {
mStartMarker.setVisible(false);
}
if (mEndMarker != null) {
mEndMarker.setVisible(false);
}
}
public void onCreateView(Bundle savedInstanceState) {
if (mAMapNaviView != null) {
mAMapNaviView.onCreate(savedInstanceState);
}
}
public void onResume() {
if (mAMapNaviView != null) {
mAMapNaviView.onResume();
}
}
public void onPause() {
if (mAMapNaviView != null) {
mAMapNaviView.onPause();
}
}
public void onDestroy() {
if (mAMapNaviView != null) {
mAMapNaviView.onDestroy();
}
}
public void convert(List<MogoLatLng> coordinates) {
mCoordinatesLatLng.clear();
List<LatLng> latLngs = CoordinateConverterFrom84ForList(mContext, coordinates);
mCoordinatesLatLng.addAll(latLngs);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mogo.eagle.core.function.smp.SmallMapDirectionView
<com.mogo.eagle.core.function.smp.AMapCustomView
android:id="@+id/smallMapDirectionView"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@@ -12,8 +12,8 @@
<dimen name="module_map_display_overview_right_margin">200px</dimen>
<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_width">700px</dimen>
<dimen name="module_small_map_border_view_width">550px</dimen>
<dimen name="module_small_map_view_width">360px</dimen>
<dimen name="module_small_map_view_width">660px</dimen>
</resources>

View File

@@ -12,7 +12,7 @@
<dimen name="module_map_display_overview_right_margin">100px</dimen>
<dimen name="module_small_map_padding">30px</dimen>
<dimen name="module_small_map_view_border_width">288px</dimen>
<dimen name="module_small_map_border_view_width">450px</dimen>
<dimen name="module_small_map_view_width">260px</dimen>
<dimen name="module_small_map_view_border_width">588px</dimen>
<dimen name="module_small_map_border_view_width">550px</dimen>
<dimen name="module_small_map_view_width">560px</dimen>
</resources>