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();
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<corners android:bottomLeftRadius="@dimen/module_widgets_app_bkg_corner" android:bottomRightRadius="@dimen/module_widgets_app_bkg_corner" android:topLeftRadius="0px" android:topRightRadius="0px" />
|
||||
<solid android:color="#3D3F44" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<corners android:bottomLeftRadius="0px" android:bottomRightRadius="0px" android:topLeftRadius="@dimen/module_widgets_app_bkg_corner" android:topRightRadius="@dimen/module_widgets_app_bkg_corner" />
|
||||
<solid android:color="#3D3F44" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -1,17 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/module_widgets_app_entrance_root"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/module_widgets_app_entrance_img_bkg"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_widgets_app_handler_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/module_widgets_app_entrance_size"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_widgets_app_entrance_text"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/module_widgets_app_entrance_textSize" />
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/module_widgets_app_handler_bkg">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_widgets_app_handler"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:src="@drawable/ic_1" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/module_widgets_app_body_bkg">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_widgets_app_entrance"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="@dimen/module_widgets_app_entrance_paddingLeft"
|
||||
android:paddingTop="@dimen/module_widgets_app_entrance_paddingTop"
|
||||
android:paddingRight="@dimen/module_widgets_app_entrance_paddingLeft"
|
||||
android:paddingBottom="@dimen/module_widgets_app_entrance_paddingTop"
|
||||
android:text="@string/module_widgets_app_entrance_text"
|
||||
android:textColor="@color/module_widgets_app_entrance_textColor"
|
||||
android:textSize="@dimen/module_widgets_app_entrance_textSize"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<View
|
||||
android:layout_width="1px"
|
||||
android:layout_height="50px"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="#7FFFFFFF" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_widgets_app_consult"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="@dimen/module_widgets_app_entrance_paddingLeft"
|
||||
android:paddingTop="@dimen/module_widgets_app_entrance_paddingTop"
|
||||
android:paddingRight="@dimen/module_widgets_app_entrance_paddingLeft"
|
||||
android:paddingBottom="@dimen/module_widgets_app_entrance_paddingTop"
|
||||
android:text="@string/module_widgets_app_entrance_consult"
|
||||
android:textColor="@color/module_widgets_app_entrance_textColor"
|
||||
android:textSize="@dimen/module_widgets_app_entrance_textSize"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,11 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_widgets_app_entrance_textSize">20px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_textSize">22px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_padding">15px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_corner_size">2px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_y">505px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_x">501px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingTop">10px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingLeft">15px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingTop">20px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingLeft">27px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_size">71px</dimen>
|
||||
<dimen name="module_widgets_app_bkg_corner">4px</dimen>
|
||||
</resources>
|
||||
@@ -1,11 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_widgets_app_entrance_textSize">20px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_textSize">22px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_padding">15px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_corner_size">2px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_y">505px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_x">501px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingTop">10px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingLeft">15px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingTop">20px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingLeft">27px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_size">71px</dimen>
|
||||
<dimen name="module_widgets_app_bkg_corner">4px</dimen>
|
||||
</resources>
|
||||
@@ -5,7 +5,8 @@
|
||||
<dimen name="module_widgets_app_entrance_corner_size">4px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_y">48px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_x">1000px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingTop">10px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingLeft">15px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingTop">37px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingLeft">50px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_size">71px</dimen>
|
||||
<dimen name="module_widgets_app_bkg_corner">8px</dimen>
|
||||
</resources>
|
||||
@@ -5,7 +5,8 @@
|
||||
<dimen name="module_widgets_app_entrance_corner_size">4px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_y">48px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_x">1000px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingTop">10px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingLeft">15px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingTop">37px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingLeft">50px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_size">71px</dimen>
|
||||
<dimen name="module_widgets_app_bkg_corner">8px</dimen>
|
||||
</resources>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="module_widgets_app_entrance_textColor">#FFFFFF</color>
|
||||
</resources>
|
||||
@@ -1,11 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_widgets_app_entrance_textSize">40px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_textSize">22px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_padding">30px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_corner_size">4px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_y">48px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_x">1000px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingTop">10px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingLeft">15px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingTop">20px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_paddingLeft">27px</dimen>
|
||||
<dimen name="module_widgets_app_entrance_size">71px</dimen>
|
||||
<dimen name="module_widgets_app_bkg_corner">4px</dimen>
|
||||
</resources>
|
||||
@@ -1,4 +1,7 @@
|
||||
<resources>
|
||||
<string name="app_name">mogo-module-service</string>
|
||||
<string name="module_widgets_app_entrance_text">切换辅助驾驶</string>
|
||||
<string name="module_widgets_app_entrance_text">辅助驾驶模式</string>
|
||||
<string name="module_widgets_app_entrance_consult">咨询终点车友</string>
|
||||
<string name="module_widgets_app_entrance_short">辅</string>
|
||||
<string name="module_widgets_app_consult_short">咨</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user