Initial commit

This commit is contained in:
wangcongtao
2019-12-23 15:08:04 +08:00
commit 80cc1248b2
210 changed files with 17746 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package com.mogo.commons;
import android.app.Application;
/**
* @author congtaowang
* @since 2019-12-23
* <p>
* 描述
*/
public class AbsMogoApplication extends Application {
private static Application sApp;
@Override
public void onCreate() {
super.onCreate();
sApp = this;
}
public static Application getApp() {
return sApp;
}
}

View File

@@ -0,0 +1,12 @@
package com.mogo.commons.data;
import java.io.Serializable;
/**
* Created by congtaowang on 2019/1/7.
*/
public class BaseData implements Serializable, Cloneable {
public int code = -1;
public String msg;
}

View File

@@ -0,0 +1,18 @@
package com.mogo.commons.network;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
/**
* @author congtaowang
* @since 2019-08-30
* <p>
* 信任所有域名
*/
public class AllAllowedHostnameVerifier implements HostnameVerifier {
@Override
public boolean verify( String hostname, SSLSession session ) {
return true;
}
}

View File

@@ -0,0 +1,30 @@
package com.mogo.commons.network;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.X509TrustManager;
/**
* @author congtaowang
* @since 2019-08-30
* <p>
* 描述
*/
public class X509TrustManagerImpl implements X509TrustManager {
@Override
public void checkClientTrusted( X509Certificate[] chain, String authType ) throws CertificateException {
}
@Override
public void checkServerTrusted( X509Certificate[] chain, String authType ) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
}

View File

@@ -0,0 +1,102 @@
package com.mogo.commons.voice;
import android.content.Context;
import com.zhidao.auto.platform.voice.VoiceClient;
import java.util.HashMap;
import java.util.Map;
/**
* @author congtaowang
* @since 2019-10-03
* <p>
* 语音助手通信助手
*/
public class AIAssist implements VoiceClient.VoiceCmdCallBack {
private static volatile AIAssist sInstance;
public static AIAssist getInstance( Context context ) {
if ( sInstance == null ) {
synchronized ( AIAssist.class ) {
if ( sInstance == null ) {
sInstance = new AIAssist( context );
}
}
}
return sInstance;
}
public synchronized void release() {
sInstance = null;
}
private final VoiceClient mVoiceClient;
private Map< String, IMogoVoiceCmdCallBack > mUnWakeupCmdMap = new HashMap<>();
private AIAssist( Context context ) {
// private constructor
mVoiceClient = new VoiceClient( context.getApplicationContext() );
mVoiceClient.setCallBack( this );
}
@Override
public void onCmdSelected( String cmd ) {
final IMogoVoiceCmdCallBack cmdCallBack = mUnWakeupCmdMap.get( cmd );
if ( cmdCallBack != null ) {
cmdCallBack.onCmdSelected( cmd );
}
}
@Override
public void onCmdAction( String speakText ) {
}
@Override
public void onCmdCancel( String speakText ) {
}
@Override
public void onSpeakEnd( String speakText ) {
IMogoVoiceCmdCallBack callBack = mUnWakeupCmdMap.get( speakText );
if ( callBack != null ) {
callBack.onSpeakEnd( speakText );
}
}
@Override
public void onSpeakSelectTimeOut( String speakText ) {
IMogoVoiceCmdCallBack callBack = mUnWakeupCmdMap.get( speakText );
if ( callBack != null ) {
callBack.onSpeakSelectTimeOut( speakText );
}
}
public void speakTTSVoice( String text ) {
try {
mVoiceClient.speakDefault( text );
} catch ( Exception e ) {
}
}
public void registerUnWakeupCommand( String cmd, String[] cmdWords, IMogoVoiceCmdCallBack callBack ) {
mUnWakeupCmdMap.put( cmd, callBack );
mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
}
public void unregisterUnWakeupCommand( String cmd ) {
mUnWakeupCmdMap.remove( cmd );
mVoiceClient.unRegisterCustomWakeupCmd( cmd );
}
public void registerTTSCallback( String tts, IMogoVoiceCmdCallBack cmdCallBack ) {
mUnWakeupCmdMap.put( tts, cmdCallBack );
}
public void unregisterTTSCallback( String tts ) {
mUnWakeupCmdMap.remove( tts );
}
}

View File

@@ -0,0 +1,38 @@
package com.mogo.commons.voice;
public interface IMogoVoiceCmdCallBack {
/**
* 免唤醒命令响应回调
*
* @param cmd
*/
void onCmdSelected( String cmd );
/**
* 语音播报临时免唤醒“确定”命令
*
* @param speakText 播报内容
*/
void onCmdAction( String speakText );
/**
* 语音播报临时免唤醒“取消”命令
*
* @param speakText 播报内容
*/
void onCmdCancel( String speakText );
/**
* 语音播报完毕
*
* @param speakText 播报内容
*/
void onSpeakEnd( String speakText );
/**
* 语音播报完临时命令选择超时
*
* @param speakText 播报内容
*/
void onSpeakSelectTimeOut( String speakText );
}