diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/RoundLayout.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/RoundLayout.java index 23418c8b9e..20150f4a19 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/RoundLayout.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/RoundLayout.java @@ -3,6 +3,8 @@ package com.mogo.module.common.view; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.PaintFlagsDrawFilter; import android.graphics.Path; import android.graphics.RectF; import android.util.AttributeSet; @@ -19,11 +21,10 @@ import com.mogo.skin.support.helper.MogoSkinCompatBackgroundHelperDelegate; * desc : * version: 1.0 */ -public class RoundLayout extends RelativeLayout implements IMogoSkinCompatSupportable { +public class RoundLayout extends RelativeLayout { private float roundLayoutRadius = 14f; private Path roundPath; private RectF rectF; - private MogoSkinCompatBackgroundHelperDelegate mBackgroundTintHelper; public RoundLayout(Context context) { this(context, null); @@ -41,9 +42,6 @@ public class RoundLayout extends RelativeLayout implements IMogoSkinCompatSuppor typedArray.recycle(); init(); - - mBackgroundTintHelper = new MogoSkinCompatBackgroundHelperDelegate(this); - mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr); } @@ -75,16 +73,10 @@ public class RoundLayout extends RelativeLayout implements IMogoSkinCompatSuppor @Override public void draw(Canvas canvas) { if (roundLayoutRadius > 0f) { + canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG)); canvas.clipPath(roundPath); } super.draw(canvas); } - - @Override - public void applySkin() { - if (mBackgroundTintHelper != null) { - mBackgroundTintHelper.applySkin(); - } - } } diff --git a/modules/mogo-module-smp/build.gradle b/modules/mogo-module-smp/build.gradle index e3a46f8dd8..888a054935 100644 --- a/modules/mogo-module-smp/build.gradle +++ b/modules/mogo-module-smp/build.gradle @@ -38,6 +38,9 @@ dependencies { implementation rootProject.ext.dependencies.androidxappcompat implementation rootProject.ext.dependencies.androidxconstraintlayout implementation rootProject.ext.dependencies.arouter + + implementation rootProject.ext.dependencies.amapnavi3dmap + annotationProcessor rootProject.ext.dependencies.aroutercompiler if (Boolean.valueOf(RELEASE)) { api rootProject.ext.dependencies.mogomap diff --git a/modules/mogo-module-smp/src/main/AndroidManifest.xml b/modules/mogo-module-smp/src/main/AndroidManifest.xml index 649a2f531a..3d0a81ab9f 100644 --- a/modules/mogo-module-smp/src/main/AndroidManifest.xml +++ b/modules/mogo-module-smp/src/main/AndroidManifest.xml @@ -6,6 +6,6 @@ + /> \ No newline at end of file diff --git a/modules/mogo-module-smp/src/main/assets/small_map_style.data b/modules/mogo-module-smp/src/main/assets/small_map_style.data new file mode 100644 index 0000000000..75195b39a2 Binary files /dev/null and b/modules/mogo-module-smp/src/main/assets/small_map_style.data differ diff --git a/modules/mogo-module-smp/src/main/assets/small_map_style_extra.data b/modules/mogo-module-smp/src/main/assets/small_map_style_extra.data new file mode 100644 index 0000000000..6f65457911 Binary files /dev/null and b/modules/mogo-module-smp/src/main/assets/small_map_style_extra.data differ diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java index 0e5764968c..dddd20e2fe 100644 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java @@ -8,6 +8,15 @@ import android.widget.ImageView; 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.TextureMapView; +import com.amap.api.maps.UiSettings; +import com.amap.api.maps.model.BitmapDescriptor; +import com.amap.api.maps.model.BitmapDescriptorFactory; +import com.amap.api.maps.model.CustomMapStyleOptions; +import com.amap.api.maps.model.MyLocationStyle; import com.mogo.module.common.view.RoundLayout; import com.mogo.module.small.map.animation.DirectionRotateAnimation; @@ -20,6 +29,12 @@ import com.mogo.module.small.map.animation.DirectionRotateAnimation; public class SmallMapDirectionView extends RoundLayout { private ImageView mIvMapBorder; + private TextureMapView mTextureMapView; + private AMap mAMap; + private UiSettings mUiSettings; + private CameraUpdate mCameraUpdate; + private MyLocationStyle myLocationStyle; + private DirectionRotateAnimation mRotateAnimation; private int lastAngle = 0; @@ -37,9 +52,43 @@ public class SmallMapDirectionView extends RoundLayout { } private void initView(Context context) { + mRotateAnimation = new DirectionRotateAnimation(context, null); + LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this); mIvMapBorder = findViewById(R.id.ivMapBorder); - mRotateAnimation = new DirectionRotateAnimation(context, null); + mTextureMapView = findViewById(R.id.textureMapView); + + mTextureMapView.onCreate(null); + mAMap = mTextureMapView.getMap(); +// mAMap.setMapType(AMap.MAP_TYPE_NIGHT);//夜景地图,aMap是地图控制器对象。 + + mAMap.setCustomMapStyle(new CustomMapStyleOptions() + .setEnable(true) + .setStyleDataPath("file:///android_asset/small_map_style.data") + .setStyleExtraPath("file:///android_asset/small_map_style_extra.data") + ); + + myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);//连续定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动。(1秒1次定位)如果不设置myLocationType,默认也会执行此种模式。 + myLocationStyle.interval(2000); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。 + BitmapDescriptor location = BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo); + myLocationStyle.myLocationIcon(location); + mAMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style + mAMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。 + + //设置希望展示的地图缩放级别 + mCameraUpdate = CameraUpdateFactory.zoomTo(12); + mAMap.moveCamera(mCameraUpdate); + + mUiSettings = mAMap.getUiSettings(); + mUiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮 +// mUiSettings.setZoomGesturesEnabled(false);// 缩放手势 +// mUiSettings.setScrollGesturesEnabled(false);// 滑动手势 +// mUiSettings.setRotateGesturesEnabled(false);// 旋转手势 +// mUiSettings.setTiltGesturesEnabled(false);// 倾斜手势 + mUiSettings.setAllGesturesEnabled(false);// 所有手势 + mUiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮 + mUiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可 + } 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 index bdf5c46fa9..f50a457f25 100644 --- 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 @@ -32,7 +32,7 @@ public class SmallMapService extends Service { public void onCreate() { super.onCreate(); Logger.d(TAG, "onCreate"); - addMachineVisionMapView(); + addSmallMapView(); } @Nullable @@ -46,7 +46,7 @@ public class SmallMapService extends Service { @Override public void onRebind(Intent intent) { super.onRebind(intent); - addMachineVisionMapView(); + addSmallMapView(); Logger.d(TAG, "onRebind"); } @@ -69,8 +69,8 @@ public class SmallMapService extends Service { } } - private void addMachineVisionMapView() { - Logger.d(TAG, "addMachineVisionMapView"); + private void addSmallMapView() { + Logger.d(TAG, "addSmallMapView"); mWindowManagerView = new WindowManagerView.Builder(getApplicationContext()) .contentView(R.layout.module_small_map_direction_view) diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java deleted file mode 100644 index 32b0bddc35..0000000000 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.mogo.module.small.map; - -import android.content.Context; -import android.os.Build; -import android.os.Bundle; -import android.util.AttributeSet; -import android.view.View; -import android.view.ViewGroup; -import android.widget.FrameLayout; - -import androidx.annotation.Nullable; -import androidx.annotation.RequiresApi; - -import com.mogo.map.MogoBaseMapView; -import com.mogo.utils.logger.Logger; - -/** - * @author donghongyu - * @date 12/10/20 1:35 PM - */ -public class SmallMapView extends MogoBaseMapView { - - private static final String TAG = "SmallMapView"; - - public SmallMapView(Context context) { - this(context, null); - } - - public SmallMapView(Context context, @Nullable AttributeSet attrs) { - this(context, attrs, 0); - } - - public SmallMapView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } - - @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) - @Override - protected void addMapView(Context context) { - Logger.d(TAG, "addMapView"); - mMapView = SmallMapDelegateFactory.getMapView(context); - if (mMapView != null) { - final View mapView = mMapView.getMapView(); - if (mapView != null) { - mapView.setOutlineProvider(new TextureVideoViewOutlineProvider(360)); - mapView.setClipToOutline(true); - addView(mapView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - } else { - Logger.e(TAG, "create MapView instance failed."); - } - } else { - Logger.e(TAG, "create IMogoMapView instance failed."); - } - } - - - @Override - public void onCreate( Bundle bundle ) { - super.onCreate( bundle ); - Logger.d( TAG, "onCreate" ); - } - - @Override - public void onResume() { - super.onResume(); - Logger.d( TAG, "onResume" ); - } - - @Override - public void onPause() { - super.onPause(); - Logger.d( TAG, "onPause" ); - } - - @Override - public void onDestroy() { - super.onDestroy(); - Logger.d( TAG, "onDestroy" ); - } - - @Override - public void onSaveInstanceState( Bundle outState ) { - super.onSaveInstanceState( outState ); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - } - -} \ No newline at end of file diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/TextureVideoViewOutlineProvider.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/TextureVideoViewOutlineProvider.java deleted file mode 100644 index 45f82de108..0000000000 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/TextureVideoViewOutlineProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.mogo.module.small.map; - -import android.graphics.Outline; -import android.graphics.Rect; -import android.os.Build; -import android.util.Log; -import android.view.View; -import android.view.ViewOutlineProvider; - -import androidx.annotation.RequiresApi; - -/** - * @author donghongyu - * @date 12/15/20 8:47 PM - */ -@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) -public class TextureVideoViewOutlineProvider extends ViewOutlineProvider { - private float mRadius; - - public TextureVideoViewOutlineProvider(float radius) { - this.mRadius = radius; - } - - @Override - public void getOutline(View view, Outline outline) { - Log.w("OutlineProvider", "======getOutline======"); - Rect rect = new Rect(); - view.getGlobalVisibleRect(rect); - int leftMargin = 0; - int topMargin = 0; - Rect selfRect = new Rect(leftMargin, topMargin, - rect.right - rect.left - leftMargin, rect.bottom - rect.top - topMargin); - outline.setRoundRect(selfRect, mRadius); - } -} \ No newline at end of file diff --git a/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_my_location_logo.png b/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_my_location_logo.png new file mode 100644 index 0000000000..e17d0c5eee Binary files /dev/null and b/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_my_location_logo.png differ diff --git a/modules/mogo-module-smp/src/main/res/drawable/module_small_map_view_border.xml b/modules/mogo-module-smp/src/main/res/drawable/module_small_map_view_border.xml new file mode 100644 index 0000000000..a8b409b1d1 --- /dev/null +++ b/modules/mogo-module-smp/src/main/res/drawable/module_small_map_view_border.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml index b3703a522f..a5429f8ce3 100644 --- a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml +++ b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml @@ -1,5 +1,5 @@ - - @@ -26,4 +26,4 @@ android:layout_centerInParent="true" android:src="@drawable/module_small_map_view_border" /> - \ No newline at end of file + \ No newline at end of file diff --git a/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml index 41d38e65b4..c09710af88 100644 --- a/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml +++ b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml @@ -3,8 +3,8 @@ 400px 400px - 300px - 300px + 260px + 260px 1490px 650px