导航按钮
This commit is contained in:
@@ -8,6 +8,7 @@ import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
@@ -61,6 +62,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
private TextView mEnterApp;
|
||||
private TextView mConsult;
|
||||
private View mHandler;
|
||||
private ImageView mHandlerIcon;
|
||||
|
||||
private boolean mLargeStyle = true;
|
||||
|
||||
@@ -116,7 +118,8 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
} );
|
||||
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 );
|
||||
mHandler = mWindowManagerView.findViewById( R.id.module_widgets_app_handler_container );
|
||||
mHandlerIcon = mWindowManagerView.findViewById( R.id.module_widgets_app_handler );
|
||||
}
|
||||
try {
|
||||
if ( mWindowManagerView.isShowing() ) {
|
||||
@@ -131,20 +134,31 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
}
|
||||
|
||||
private void chooseAction( View root, float xPos, float yPos ) {
|
||||
if ( isInViewArea( mEnterApp, xPos, yPos ) ) {
|
||||
if ( isInViewArea( root, mEnterApp, xPos, yPos ) ) {
|
||||
enterApp( root.getContext() );
|
||||
} else if ( isInViewArea( mHandler, xPos, yPos ) ) {
|
||||
} else if ( isInViewArea( root, mHandler, xPos, yPos ) ) {
|
||||
handleStyle( mHandler.getContext() );
|
||||
} else if ( isInViewArea( mConsult, xPos, yPos ) ) {
|
||||
} else if ( isInViewArea( root, 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() ) {
|
||||
private boolean isInViewArea( View root, View target, float xPos, float yPos ) {
|
||||
int loc[] = new int[2];
|
||||
root.getLocationOnScreen( loc );
|
||||
int rootX = loc[0];
|
||||
int rootY = loc[1];
|
||||
|
||||
target.getLocationOnScreen( loc );
|
||||
int targetX = loc[0];
|
||||
int targetY = loc[1];
|
||||
int targetWidth = target.getMeasuredWidth();
|
||||
int targetHeight = target.getMeasuredHeight();
|
||||
|
||||
if ( xPos + rootX >= targetX
|
||||
&& xPos + rootX <= targetX + targetWidth
|
||||
&& yPos + rootY >= targetY
|
||||
&& yPos + rootY <= targetY + targetHeight ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -156,7 +170,7 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
* @param context
|
||||
*/
|
||||
private void consultUser( Context context ) {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
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() ) {
|
||||
@@ -174,10 +188,12 @@ class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
|
||||
mEnterApp.setText( R.string.module_widgets_app_entrance_short );
|
||||
mConsult.setText( R.string.module_widgets_app_consult_short );
|
||||
mLargeStyle = false;
|
||||
mHandlerIcon.setImageResource( R.drawable.module_widgets_app_handler_open );
|
||||
} else {
|
||||
mEnterApp.setText( R.string.module_widgets_app_entrance_text );
|
||||
mConsult.setText( R.string.module_widgets_app_entrance_consult );
|
||||
mLargeStyle = true;
|
||||
mHandlerIcon.setImageResource( R.drawable.module_widgets_app_handler_close );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user