Merge remote-tracking branch 'origin/feature/v1.0.0' into feature/v1.0.0

This commit is contained in:
zhangyuanzhen
2020-02-26 15:10:57 +08:00
20 changed files with 265 additions and 54 deletions

2
.idea/misc.xml generated
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
</project>

View File

@@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.view.View;
import android.view.animation.BounceInterpolator;
import android.view.animation.Interpolator;
import com.amap.api.maps.model.BitmapDescriptor;
@@ -12,6 +13,7 @@ import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.animation.Animation;
import com.amap.api.maps.model.animation.ScaleAnimation;
import com.amap.api.maps.model.animation.TranslateAnimation;
import com.mogo.map.MogoLatLng;
import com.mogo.map.impl.amap.utils.ObjectUtils;
@@ -310,4 +312,19 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
public MogoMarkerOptions getMogoMarkerOptions() {
return mMogoMarkerOptions;
}
@Override
public void startScaleAnimation( float fromX, float toX, float fromY, float toY, int duration, Interpolator interpolator ) {
if ( isDestroyed() ) {
return;
}
ScaleAnimation animationScale = new ScaleAnimation(fromX, toX, fromY, toY);
animationScale.setDuration(duration);
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
animationScale.setInterpolator(interpolator);
mMarker.setAnimation( animationScale );
mMarker.startAnimation();
}
}

View File

@@ -227,8 +227,23 @@ public interface IMogoMarker {
/**
* Marker 配置
*
* @return
*/
MogoMarkerOptions getMogoMarkerOptions();
/**
* 开始缩放动画
*
* @param duration
* @param interpolator
*/
void startScaleAnimation( float fromX,
float toX,
float fromY,
float toY,
int duration,
Interpolator interpolator );
}

View File

@@ -17,6 +17,7 @@ import com.mogo.module.apps.model.AppInfo;
import com.mogo.module.apps.view.PagerSlidingTabStripV2;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.utils.logger.Logger;
import java.util.List;
@@ -38,6 +39,7 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
private View mExit;
private IMogoFragmentManager mMogoFragmentManager;
private IMogoStatusManager mMogoStatusManager;
private View mLoadingView;
private PagerSlidingTabStripV2 mIndicator;
@@ -64,6 +66,7 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
@Override
public void onStateChanged( @NonNull View bottomSheet, int newState ) {
if ( newState == BottomSheetBehavior.STATE_COLLAPSED ) {
mMogoStatusManager.setAppListUIShow( TAG, false );
mMogoFragmentManager.pop();
}
}
@@ -90,6 +93,8 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
super.onActivityCreated( savedInstanceState );
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation();
mMogoStatusManager = ( IMogoStatusManager ) ARouter.getInstance().build( MogoServicePaths.PATH_STATUS_MANAGER ).navigation();
mMogoStatusManager.setAppListUIShow( TAG, true );
}
@Override

View File

@@ -1,6 +1,5 @@
package com.mogo.module.extensions;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
@@ -13,8 +12,10 @@ import androidx.annotation.Nullable;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.commons.voice.AIAssist;
import com.mogo.module.extensions.anim.AnimWrapper;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
/**
* @author congtaowang
@@ -26,8 +27,10 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
private static final String TAG = "ExtensionsFragment";
public static final int MAX_DISPLAY_MSG_AMOUNT = 99;
private ImageView mVoiceIcon;
private AnimationDrawable mAnim;
private AnimWrapper mAnim = new AnimWrapper();
private TextView mVoiceMsg;
private TextView mTime;
@@ -42,6 +45,7 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
private TextView mMsgCounter;
private IMogoAnalytics mAnalytics;
private IMogoFragmentManager mMogoFragmentManager;
@Override
protected int getLayoutId() {
@@ -51,7 +55,7 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
@Override
protected void initViews() {
mVoiceIcon = findViewById( R.id.module_ext_id_voice );
mAnim = ( AnimationDrawable ) mVoiceIcon.getBackground();
mAnim.initAnim( mVoiceIcon );
mVoiceMsg = findViewById( R.id.module_ext_id_voice_msg );
mVoiceIcon.setOnClickListener( view -> {
@@ -87,22 +91,28 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
super.onActivityCreated( savedInstanceState );
mAnalytics = ( IMogoAnalytics ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_ANALYTICS ).navigation( getContext() );
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation( getContext() );
mMogoFragmentManager.addMainFragmentStackTransactionListener( size -> {
// 主页 fragment 栈变化的时候,改变动画状态
if ( size == 0 ) {
mAnim.start();
} else {
mAnim.stop();
}
} );
}
@Override
public void onResume() {
super.onResume();
if ( mAnim != null ) {
mAnim.start();
}
mAnim.start();
}
@Override
public void onStop() {
super.onStop();
if ( mAnim != null ) {
mAnim.stop();
}
mAnim.stop();
}
@Override
@@ -131,7 +141,7 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
@Override
public void renderMsgInfo( boolean hasMsg, int amount ) {
mMsgContainer.setVisibility( hasMsg ? View.VISIBLE : View.GONE );
mMsgCounter.setText( amount > 99 ? getString( R.string.module_ext_str_dots ) : String.valueOf( amount ) );
mMsgCounter.setText( amount > MAX_DISPLAY_MSG_AMOUNT ? getString( R.string.module_ext_str_dots ) : String.valueOf( amount ) );
}
@Override

View File

@@ -0,0 +1,14 @@
package com.mogo.module.extensions.anim;
/**
* @author congtaowang
* @since 2020-02-26
* <p>
* 描述
*/
public interface Anim {
void start();
void stop();
}

View File

@@ -0,0 +1,68 @@
package com.mogo.module.extensions.anim;
import android.graphics.drawable.AnimationDrawable;
import android.os.Build;
import android.widget.ImageView;
import com.mogo.module.extensions.R;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
/**
* @author congtaowang
* @since 2020-02-26
* <p>
* 描述
*/
public class AnimWrapper implements Anim {
private static final String TAG = "AnimWrapper";
private ImageView mTarget;
private Anim mDelegate;
private boolean mIsStarted = false;
public AnimWrapper() {
}
public void initAnim( ImageView target ) {
mTarget = target;
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
ThreadPoolService.execute( () -> {
final AnimationDrawable drawable = new AnimationDrawable();
for ( int i = 0; i < AnimRes.sRes.length; i++ ) {
drawable.addFrame( target.getResources().getDrawable( AnimRes.sRes[i] ), 100 );
}
UiThreadHandler.post( () -> {
target.setBackground( drawable );
mDelegate = new OthersAnim( drawable );
start();
} );
} );
} else {
mTarget.setImageResource( R.drawable.mogo_tts_icon_00000 );
}
}
@Override
public synchronized void start() {
if ( mDelegate != null && !mIsStarted ) {
mIsStarted = true;
mDelegate.start();
Logger.d( TAG, "开启小智动画" );
}
}
@Override
public void stop() {
if ( mDelegate != null ) {
mIsStarted = false;
mDelegate.stop();
Logger.d( TAG, "停止小智动画" );
}
}
public void release() {
mDelegate = null;
}
}

View File

@@ -0,0 +1,20 @@
package com.mogo.module.extensions.anim;
/**
* @author congtaowang
* @since 2020-02-26
* <p>
* 描述
*/
public class KitkatAnim implements Anim{
@Override
public void start() {
}
@Override
public void stop() {
}
}

View File

@@ -0,0 +1,32 @@
package com.mogo.module.extensions.anim;
import android.graphics.drawable.AnimationDrawable;
/**
* @author congtaowang
* @since 2020-02-26
* <p>
* 描述
*/
public class OthersAnim implements Anim{
private AnimationDrawable mDrawable;
public OthersAnim( AnimationDrawable drawable ) {
this.mDrawable = drawable;
}
@Override
public void start() {
if ( mDrawable != null ) {
mDrawable.start();
}
}
@Override
public void stop() {
if ( mDrawable != null ) {
mDrawable.stop();
}
}
}

View File

@@ -14,8 +14,7 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="@dimen/module_ext_voice_icon_width"
android:layout_height="@dimen/module_ext_voice_icon_height"
android:background="@drawable/module_ext_frame_anim_voice"/>
android:layout_height="@dimen/module_ext_voice_icon_height"/>
<!-- <com.mogo.module.extensions.anim.JSurfaceView-->
<!-- />-->

View File

@@ -5,11 +5,16 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.map.IMogoMap;
import com.mogo.map.IMogoUiSettings;
import com.mogo.map.MogoMapView;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.service.statusmanager.StatusDescriptor;
/**
* @author congtaowang
@@ -17,12 +22,15 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
* <p>
* 地图图层,地图操作都在这个图层完成
*/
public class MapFragment extends MvpFragment< MapView, MapPresenter > implements MapView {
public class MapFragment extends MvpFragment< MapView, MapPresenter > implements MapView, IMogoStatusChangedListener {
private static final String TAG = "MapFragment";
private MogoMapView mMogoMapView;
private IMogoMap mMogoMap;
private IMogoStatusManager mMogoStatusManager;
private boolean mIsControllerByOthersStatus = false;
@Override
protected int getLayoutId() {
@@ -36,8 +44,9 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
//mMogoMap.getUIController().showMyLocation( true );
}
@Override protected void initViews(Bundle savedInstanceState) {
super.initViews(savedInstanceState);
@Override
protected void initViews( Bundle savedInstanceState ) {
super.initViews( savedInstanceState );
mMogoMapView = findViewById( R.id.module_map_id_map );
mMogoMapView.onCreate( savedInstanceState );
mMogoMap = mMogoMapView.getMap();
@@ -58,11 +67,16 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
// mMogoMapView.onCreate( savedInstanceState );
//}
initMapView();
mMogoStatusManager = ( IMogoStatusManager ) ARouter.getInstance().build( MogoServicePaths.PATH_STATUS_MANAGER ).navigation( getContext() );
mMogoStatusManager.registerStatusChangedListener( TAG, StatusDescriptor.APP_LIST_UI, this );
}
@Override
public void onPause() {
super.onPause();
if ( mIsControllerByOthersStatus ) {
return;
}
if ( mMogoMapView != null ) {
mMogoMapView.onPause();
}
@@ -71,6 +85,9 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
@Override
public void onResume() {
super.onResume();
if ( mIsControllerByOthersStatus ) {
return;
}
if ( mMogoMapView != null ) {
mMogoMapView.onResume();
}
@@ -117,6 +134,18 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
return mMogoMap.getUIController();
}
@Override
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
if ( descriptor == StatusDescriptor.APP_LIST_UI ) {
mIsControllerByOthersStatus = isTrue;
if ( isTrue ) {
mMogoMapView.onPause();
} else {
mMogoMapView.onResume();
}
}
}
@Override
public void onDestroyView() {
super.onDestroyView();

View File

@@ -64,7 +64,7 @@ public class MapPresenter extends Presenter<MapView> implements
int type = intent.getIntExtra("EXTRA_TYPE", -1);
int opera_type = intent.getIntExtra("EXTRA_OPERA", -1);
Logger.d("NaviManager", "key_type" + key_type, null);
Logger.d("NaviManager", "key_type" + key_type);
if (key_type == 10027) {
if (type == 0) {
@@ -211,7 +211,7 @@ public class MapPresenter extends Presenter<MapView> implements
@Override
public void onCmdSelected(String cmd) {
Logger.d(TAG, cmd, null);
Logger.d(TAG, cmd);
switch (cmd) {
case VoiceConstants.CMD_MAP_TRAFFIC_MODE_UN_WAKEUP:
case VoiceConstants.CMD_MAP_TRAFFIC_MODE:

View File

@@ -120,11 +120,6 @@ public class MogoServiceProvider implements IMogoModuleProvider,
*/
private boolean mLoopRequest = false;
/**
* 刷新补偿间隔
*/
private long mLoopInterval = 10_000L;
private Handler mHandler = new Handler( Looper.getMainLooper() ) {
@Override
public void handleMessage( @NonNull Message msg ) {

View File

@@ -25,12 +25,12 @@ public class ServiceConst {
/**
* 倒计时间隔
*/
public static final int DECREASE_INTERVAL = 1_000;
public static final int DECREASE_INTERVAL = 10_000;
/**
* 刷新失败补偿消息
*/
public static final int MSG_LOOP_REQUEST = 10_000;
public static final int MSG_LOOP_REQUEST = 0x101;
/**
* 刷新失败补偿时间间隔

View File

@@ -7,10 +7,7 @@ import android.text.TextUtils;
import android.view.animation.BounceInterpolator;
import android.view.animation.OvershootInterpolator;
import com.amap.api.maps.model.animation.Animation;
import com.amap.api.maps.model.animation.ScaleAnimation;
import com.mogo.map.MogoLatLng;
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
import com.mogo.map.location.MogoLocation;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
@@ -229,18 +226,8 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
}
mogoMarker.setToTop();
try {
// 使用TranslateAnimation,填写一个需要移动的目标点
ScaleAnimation animationScale = new ScaleAnimation(0.6f, 1f, 0.6f, 1f);
animationScale.setDuration(1000);
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
animationScale.setInterpolator(new BounceInterpolator());
// 设置动画
if (mogoMarker instanceof AMapMarkerWrapper) {
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animationScale);
((AMapMarkerWrapper) mogoMarker).getMarker().startAnimation();
}
} catch (Exception e) {
mogoMarker.startScaleAnimation( 0.6f, 1f, 0.6f, 1f,1000, new BounceInterpolator( ) );
} catch( Exception e ){
Logger.e(TAG, e, "error.");
}
}
@@ -260,17 +247,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
return;
}
try {
// 使用TranslateAnimation,填写一个需要移动的目标点
ScaleAnimation animationScale = new ScaleAnimation(1f, 0.6f, 1f, 0.6f);
animationScale.setDuration(300);
animationScale.setFillMode(Animation.FILL_MODE_FORWARDS);
animationScale.setInterpolator(new OvershootInterpolator());
// 设置动画
if (mogoMarker instanceof AMapMarkerWrapper) {
((AMapMarkerWrapper) mogoMarker).getMarker().setAnimation(animationScale);
((AMapMarkerWrapper) mogoMarker).getMarker().startAnimation();
}
mogoMarker.startScaleAnimation( 1f, 0.6f, 1f, 0.6f,300, new OvershootInterpolator( ) );
} catch (Exception e) {
Logger.e(TAG, e, "error.");
}

View File

@@ -1,6 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.alibaba.arouter'
android {

View File

@@ -1,6 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.alibaba.arouter'
android {

View File

@@ -60,6 +60,12 @@ public interface IMogoStatusManager extends IProvider {
*/
boolean isSearchUIShow();
/**
* APP 列表是否显示
* @return
*/
boolean isAppListUIShow();
/**
* 设置小智语音UI状态
*
@@ -114,6 +120,13 @@ public interface IMogoStatusManager extends IProvider {
*/
void setSearchUIShow( String tag, boolean isShow );
/**
* app 列表是否显示
* @param tag
* @param isShow
*/
void setAppListUIShow( String tag, boolean isShow );
/**
* 注册监听
*

View File

@@ -41,5 +41,10 @@ public enum StatusDescriptor {
/**
* 搜索页面
*/
SEARCH_UI;
SEARCH_UI,
/**
* app 列表
*/
APP_LIST_UI;
}

View File

@@ -84,6 +84,11 @@ public class MogoStatusManager implements IMogoStatusManager {
return get_bool_val( StatusDescriptor.SEARCH_UI );
}
@Override
public boolean isAppListUIShow() {
return get_bool_val( StatusDescriptor.APP_LIST_UI );
}
private boolean get_bool_val( StatusDescriptor descriptor ) {
Boolean val = mStatus.get( descriptor );
return val == null ? false : val;
@@ -141,6 +146,13 @@ public class MogoStatusManager implements IMogoStatusManager {
recordStatusModifier( tag, StatusDescriptor.SEARCH_UI );
}
@Override
public void setAppListUIShow( String tag, boolean isShow ) {
mStatus.put( StatusDescriptor.APP_LIST_UI, isShow );
invokeStatusChangedListener( StatusDescriptor.APP_LIST_UI, isShow );
recordStatusModifier( tag, StatusDescriptor.APP_LIST_UI );
}
private void invokeStatusChangedListener( StatusDescriptor descriptor, boolean status ) {
if ( mListeners.containsKey( descriptor ) ) {
Iterator< IMogoStatusChangedListener > iterator = mListeners.get( descriptor ).iterator();