1.1.3 广告需求

This commit is contained in:
wangcongtao
2020-08-25 10:25:47 +08:00
parent b19d4e21e4
commit 8c7508e385
9 changed files with 398 additions and 46 deletions

View File

@@ -2,11 +2,14 @@ package com.mogo.module.widgets;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.WindowManager;
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.wm.WindowManagerView;
import com.mogo.utils.CommonUtils;
import com.mogo.utils.LaunchUtils;
@@ -23,9 +26,10 @@ public
* <p>
* 描述
*/
class AutoNaviIntentHandler {
class AutoNaviIntentHandler implements IMogoVoiceCmdCallBack {
private static final String TAG = "AutoNaviIntentHandler";
public static final String OPEN = "OPEN_APP";
private static volatile AutoNaviIntentHandler sInstance;
@@ -94,26 +98,31 @@ class AutoNaviIntentHandler {
.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 -> {
try {
if ( DebugConfig.isLauncher() ) {
MogoWidgetManger.getInstance().getApis().getLauncherApi().backToLauncher( context );
} else {
LaunchUtils.launchByPkg( context, "com.mogo.launcher.app" );
}
if ( mProperties.isEmpty() ) {
mProperties.put( "appname", CommonUtils.getAppName( context ) );
mProperties.put( "appversion", CommonUtils.getVersionName( context ) );
mProperties.put( "from", 9 );
}
MogoWidgetManger.getInstance().getApis().getAnalyticsApi().track( "appenterfront", mProperties );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
enterApp( context );
} );
}
try {
mWindowManagerView.show();
MogoWidgetManger.getInstance().getApis().getAnalyticsApi().track( "NAVI_button_show", null );
AIAssist.getInstance( context ).registerUnWakeupCommand( OPEN, new String[]{"切换到辅助驾驶模式"}, this );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
}
private void enterApp( Context context ) {
try {
if ( DebugConfig.isLauncher() ) {
MogoWidgetManger.getInstance().getApis().getLauncherApi().backToLauncher( context );
} else {
LaunchUtils.launchByPkg( context, "com.mogo.launcher.app" );
}
if ( mProperties.isEmpty() ) {
mProperties.put( "appname", CommonUtils.getAppName( context ) );
mProperties.put( "appversion", CommonUtils.getVersionName( context ) );
mProperties.put( "from", 9 );
}
MogoWidgetManger.getInstance().getApis().getAnalyticsApi().track( "appenterfront", mProperties );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
@@ -125,6 +134,7 @@ class AutoNaviIntentHandler {
}
try {
mWindowManagerView.dismiss();
AIAssist.getInstance( AbsMogoApplication.getApp() ).unregisterUnWakeupCommand( OPEN, this );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
@@ -145,5 +155,12 @@ class AutoNaviIntentHandler {
intent.putExtra( "EXTRA_REQUEST_AUTO_STATE", 1 );
context.sendBroadcast( intent );
}
@Override
public void onCmdSelected( String cmd ) {
if ( TextUtils.equals( OPEN, cmd ) ) {
enterApp( AbsMogoApplication.getApp() );
}
}
}