stash
This commit is contained in:
@@ -2,18 +2,26 @@ package com.mogo.module.widgets;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.commons.voice.IMogoVoiceCmdCallBack;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.wm.WindowManagerView;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.utils.CommonUtils;
|
||||
import com.mogo.utils.LaunchUtils;
|
||||
import com.mogo.utils.ResourcesHelper;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -50,6 +58,12 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
private WindowManagerView mWindowManagerView;
|
||||
private Map< String, Object > mProperties = new HashMap<>();
|
||||
|
||||
private TextView mEnterApp;
|
||||
private TextView mConsult;
|
||||
private View mHandler;
|
||||
|
||||
private boolean mLargeStyle = true;
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
@@ -97,9 +111,12 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
.gravity( Gravity.LEFT | Gravity.TOP )
|
||||
.position( ResourcesHelper.getDimensionPixelSize( context, R.dimen.module_widgets_app_entrance_x ), ResourcesHelper.getDimensionPixelSize( AbsMogoApplication.getApp(), R.dimen.module_widgets_app_entrance_y ) )
|
||||
.showInWindowManager();
|
||||
mWindowManagerView.attachTouchEvent( view -> {
|
||||
enterApp( context );
|
||||
mWindowManagerView.attachTouchEvent( ( view, xPos, yPos ) -> {
|
||||
chooseAction( view, xPos, yPos );
|
||||
} );
|
||||
mEnterApp = mWindowManagerView.findViewById( R.id.module_widgets_app_entrance );
|
||||
mConsult = mWindowManagerView.findViewById( R.id.module_widgets_app_consult );
|
||||
mHandler = mWindowManagerView.findViewById( R.id.module_widgets_app_handler );
|
||||
}
|
||||
try {
|
||||
if ( mWindowManagerView.isShowing() ) {
|
||||
@@ -113,6 +130,62 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
}
|
||||
}
|
||||
|
||||
private void chooseAction( View root, float xPos, float yPos ) {
|
||||
if ( isInViewArea( mEnterApp, xPos, yPos ) ) {
|
||||
enterApp( root.getContext() );
|
||||
} else if ( isInViewArea( mHandler, xPos, yPos ) ) {
|
||||
handleStyle( mHandler.getContext() );
|
||||
} else if ( isInViewArea( mConsult, xPos, yPos ) ) {
|
||||
consultUser( root.getContext() );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInViewArea( View target, float xPos, float yPos ) {
|
||||
if ( xPos >= target.getLeft()
|
||||
&& xPos <= target.getRight()
|
||||
&& yPos >= target.getTop()
|
||||
&& yPos <= target.getBottom() ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 咨询用户
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
private void consultUser( Context context ) {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put( "type", 1 );
|
||||
MogoApisHandler.getInstance().getApis().getAnalyticsApi().track( "NAVI_Find_Mogoer", properties );
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isMainPageOnResume() ) {
|
||||
MogoApisHandler.getInstance().getApis().getOnlineCarPanelApi().showPanel();
|
||||
} else {
|
||||
Intent start = new Intent( Intent.ACTION_VIEW );
|
||||
start.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||
start.setData( Uri.parse( "mogo://launcher/main/switch2?type=showOnlineCarPanel" ) );
|
||||
context.startActivity( start );
|
||||
}
|
||||
}
|
||||
|
||||
private void handleStyle( Context context ) {
|
||||
if ( mLargeStyle ) {
|
||||
mEnterApp.setText( R.string.module_widgets_app_entrance_short );
|
||||
mConsult.setText( R.string.module_widgets_app_consult_short );
|
||||
mLargeStyle = false;
|
||||
} else {
|
||||
mEnterApp.setText( R.string.module_widgets_app_entrance_text );
|
||||
mConsult.setText( R.string.module_widgets_app_entrance_consult );
|
||||
mLargeStyle = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入app
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
private void enterApp( Context context ) {
|
||||
try {
|
||||
if ( DebugConfig.isLauncher() ) {
|
||||
@@ -162,7 +235,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
@Override
|
||||
public void onCmdSelected( String cmd ) {
|
||||
if ( TextUtils.equals( OPEN, cmd ) ) {
|
||||
Logger.d(TAG, "recognized open command.");
|
||||
Logger.d( TAG, "recognized open command." );
|
||||
enterApp( AbsMogoApplication.getApp() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@ package com.mogo.module.widgets;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.map.navi.IMogoNaviListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
@@ -60,7 +61,7 @@ class MogoWidgetManger implements IMogoNaviListener2, IMogoIntentListener, IMogo
|
||||
|
||||
public void init( Context context ) {
|
||||
mContext = context;
|
||||
mApis = ARouter.getInstance().navigation( IMogoServiceApis.class );
|
||||
mApis = MogoApisHandler.getInstance().getApis();
|
||||
initMapStatusListener();
|
||||
initStatusListener();
|
||||
initIntentListener();
|
||||
@@ -82,6 +83,7 @@ class MogoWidgetManger implements IMogoNaviListener2, IMogoIntentListener, IMogo
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
SpStorage.setNavigationTarget( "" );
|
||||
AutoNaviIntentHandler.getInstance().closeEntrance();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user