opt
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.mogo.commons.voice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.zhidao.auto.platform.voice.VoiceClient;
|
||||
|
||||
@@ -202,4 +203,13 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack {
|
||||
List< IMogoVoiceCmdCallBack > callBacks = mCmdMap.get( cmd );
|
||||
callBacks.remove( callBack );
|
||||
}
|
||||
|
||||
public static void startAssistant(Context context) {
|
||||
final Intent intent = new Intent();
|
||||
intent.setFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES );
|
||||
intent.setAction( "pvetec.intent.action.txz.switch" );
|
||||
intent.putExtra( "window_start_cancel", 1 );
|
||||
intent.putExtra( "extra_switch_type", "window_start_cancel" );
|
||||
context.sendBroadcast( intent );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,12 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.module.extensions.anim.AnimRes;
|
||||
import com.mogo.module.extensions.anim.JSurfaceView;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -36,6 +40,8 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
|
||||
private View mMsgContainer;
|
||||
private TextView mMsgCounter;
|
||||
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_ext_layout_extensions;
|
||||
@@ -47,8 +53,11 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
|
||||
mVoiceMsg = findViewById( R.id.module_ext_id_voice_msg );
|
||||
|
||||
mVoiceIcon.setOnClickListener( view -> {
|
||||
mVoiceMsg.performClick();
|
||||
} );
|
||||
mVoiceMsg.setOnClickListener( view -> {
|
||||
AIAssist.startAssistant( getContext() );
|
||||
} );
|
||||
mVoiceMsg.setOnClickListener( view -> {} );
|
||||
|
||||
mTime = findViewById( R.id.module_ext_id_time );
|
||||
mDate = findViewById( R.id.module_ext_id_date );
|
||||
@@ -65,6 +74,15 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
|
||||
mMsgCounter = findViewById( R.id.module_ext_id_msg_counter );
|
||||
|
||||
mVoiceIcon.setFrames( AnimRes.sRes );
|
||||
|
||||
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation( getContext() );
|
||||
mMogoFragmentManager.addMainFragmentStackTransactionListener( size -> {
|
||||
if ( size == 0 ) {
|
||||
mVoiceIcon.setVisibility( View.VISIBLE );
|
||||
} else {
|
||||
mVoiceIcon.setVisibility( View.INVISIBLE );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -51,7 +51,7 @@ public class JSurfaceView extends SurfaceView implements Runnable, SurfaceHolder
|
||||
private void init() {
|
||||
mHolder = getHolder();
|
||||
mHolder.addCallback( this );
|
||||
setZOrderOnTop( false );
|
||||
setZOrderOnTop( true );
|
||||
mHolder.setFormat( PixelFormat.TRANSLUCENT );
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class JSurfaceView extends SurfaceView implements Runnable, SurfaceHolder
|
||||
return;
|
||||
}
|
||||
//绘制透明色
|
||||
mCanvas.drawColor( Color.parseColor( "#1F000000" ) );
|
||||
mCanvas.drawColor( Color.TRANSPARENT, PorterDuff.Mode.CLEAR );
|
||||
Bitmap mBitmap = BitmapFactory.decodeResource( getResources(), mFrames[mCurrentPos % mFrames.length] );
|
||||
|
||||
Paint paint = new Paint();
|
||||
|
||||
@@ -24,14 +24,12 @@ import com.mogo.module.main.cards.MogoModulesManager;
|
||||
import com.mogo.module.main.cards.OnPageChangeListenerAdapter;
|
||||
import com.mogo.module.main.cards.OrientedViewPager;
|
||||
import com.mogo.module.main.cards.VerticalStackTransformer;
|
||||
import com.mogo.module.main.fragmentmanager.FragmentStack;
|
||||
import com.mogo.module.main.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.module.main.windowview.WindowViewHandler;
|
||||
import com.mogo.module.map.VoiceConstants;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.impl.fragmentmanager.FragmentStack;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -54,6 +52,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
private IMogoMapUIController mMogoMapUIController;
|
||||
private MogoModulesHandler mMogoModuleHandler;
|
||||
private IMogoCardManager mMogoCardManager;
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
|
||||
private OrientedViewPager mCardsContainer;
|
||||
private CardModulesAdapter mCardModulesAdapter;
|
||||
@@ -95,15 +94,13 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
}
|
||||
} );
|
||||
|
||||
FragmentStack.getInstance().init( this, R.id.module_main_id_search_fragment );
|
||||
FragmentStack.getInstance().setFragmentStackTransactionListener( new FragmentStackTransactionListener() {
|
||||
@Override
|
||||
public void onTransaction() {
|
||||
if ( FragmentStack.getInstance().isEmpty() ) {
|
||||
show();
|
||||
} else if ( FragmentStack.getInstance().getStackSize() == 1 ) {
|
||||
hide();
|
||||
}
|
||||
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation( this );
|
||||
mMogoFragmentManager.init( this, R.id.module_main_id_search_fragment );
|
||||
mMogoFragmentManager.registerMainFragmentStackTransactionListener( ( size ) -> {
|
||||
if ( size == 0 ) {
|
||||
show();
|
||||
} else if ( size == 1 ) {
|
||||
hide();
|
||||
}
|
||||
} );
|
||||
mHeader = findViewById( R.id.module_main_id_header_fragment_container );
|
||||
@@ -226,7 +223,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if ( FragmentStack.getInstance().isEmpty() ) {
|
||||
super.onBackPressed();
|
||||
return;
|
||||
}
|
||||
FragmentStack.getInstance().pop();
|
||||
|
||||
@@ -32,8 +32,9 @@ import java.util.Map;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MapPresenter extends Presenter< MapView >
|
||||
implements IMogoIntentListener, IMogoVoiceCmdCallBack {
|
||||
public class MapPresenter extends Presenter< MapView > implements
|
||||
IMogoIntentListener,
|
||||
IMogoVoiceCmdCallBack {
|
||||
|
||||
private static final String TAG = "MapPresenter";
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ class ChoosePathFragment : BaseFragment(), IMogoNaviListener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
fun newInstance(searchPoi: MogoLatLng): Fragment {
|
||||
var bundle = Bundle()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.module.main.fragmentmanager;
|
||||
package com.mogo.service.fragmentmanager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -8,5 +8,8 @@ package com.mogo.module.main.fragmentmanager;
|
||||
*/
|
||||
public interface FragmentStackTransactionListener {
|
||||
|
||||
void onTransaction();
|
||||
/**
|
||||
* @param size 栈内的fragment数量
|
||||
*/
|
||||
void onTransaction( int size );
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.service.fragmentmanager;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
/**
|
||||
@@ -33,4 +35,26 @@ public interface IMogoFragmentManager extends IProvider {
|
||||
* 退出栈中所有fragment
|
||||
*/
|
||||
void clearAll();
|
||||
|
||||
/**
|
||||
* 主页注册栈变化监听
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void registerMainFragmentStackTransactionListener( FragmentStackTransactionListener listener );
|
||||
|
||||
/**
|
||||
* 其他注册栈变化监听
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void addMainFragmentStackTransactionListener( FragmentStackTransactionListener listener );
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
* @param activity
|
||||
* @param containerId
|
||||
*/
|
||||
void init( AppCompatActivity activity, int containerId );
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.module.main.fragmentmanager;
|
||||
package com.mogo.service.impl.fragmentmanager;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
@@ -7,8 +7,11 @@ import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
@@ -31,6 +34,7 @@ public class FragmentStack {
|
||||
private FragmentDescriptor mCurrentFragment;
|
||||
|
||||
private FragmentStackTransactionListener mFragmentStackTransactionListener;
|
||||
private List< FragmentStackTransactionListener > mFragmentStackTransactionListeners = new ArrayList<>();
|
||||
|
||||
private FragmentStack() {
|
||||
}
|
||||
@@ -82,9 +86,12 @@ public class FragmentStack {
|
||||
mFragmentStack.push( descriptor );
|
||||
mCurrentFragment = descriptor;
|
||||
|
||||
if ( descriptor.isNotifyMainModule() && getFragmentStackTransactionListener() != null ) {
|
||||
getFragmentStackTransactionListener().onTransaction();
|
||||
if ( descriptor.isNotifyMainModule() ) {
|
||||
if ( mFragmentStackTransactionListener != null ) {
|
||||
mFragmentStackTransactionListener.onTransaction(getStackSize());
|
||||
}
|
||||
}
|
||||
invokeCallback();
|
||||
}
|
||||
|
||||
public void pop() {
|
||||
@@ -100,9 +107,12 @@ public class FragmentStack {
|
||||
}
|
||||
if ( mFragmentStack.isEmpty() ) {
|
||||
mFragmentTransaction.commitAllowingStateLoss();
|
||||
if ( mCurrentFragment.isNotifyMainModule() && getFragmentStackTransactionListener() != null ) {
|
||||
getFragmentStackTransactionListener().onTransaction();
|
||||
if ( mCurrentFragment.isNotifyMainModule() ) {
|
||||
if ( mFragmentStackTransactionListener != null ) {
|
||||
mFragmentStackTransactionListener.onTransaction(getStackSize());
|
||||
}
|
||||
}
|
||||
invokeCallback();
|
||||
mCurrentFragment = null;
|
||||
return;
|
||||
}
|
||||
@@ -112,12 +122,23 @@ public class FragmentStack {
|
||||
mFragmentTransaction.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
if ( mCurrentFragment.isNotifyMainModule() && getFragmentStackTransactionListener() != null ) {
|
||||
getFragmentStackTransactionListener().onTransaction();
|
||||
if ( mCurrentFragment.isNotifyMainModule() ) {
|
||||
if ( mFragmentStackTransactionListener != null ) {
|
||||
mFragmentStackTransactionListener.onTransaction(getStackSize());
|
||||
}
|
||||
}
|
||||
invokeCallback();
|
||||
mCurrentFragment = fragment;
|
||||
}
|
||||
|
||||
private void invokeCallback() {
|
||||
if ( mFragmentStackTransactionListeners != null ) {
|
||||
for ( FragmentStackTransactionListener fragmentStackTransactionListener : mFragmentStackTransactionListeners ) {
|
||||
fragmentStackTransactionListener.onTransaction(getStackSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return mFragmentStack.isEmpty();
|
||||
}
|
||||
@@ -126,8 +147,8 @@ public class FragmentStack {
|
||||
return mFragmentStack.size();
|
||||
}
|
||||
|
||||
public FragmentStackTransactionListener getFragmentStackTransactionListener() {
|
||||
return mFragmentStackTransactionListener;
|
||||
public void addFragmentStackTransactionListener( FragmentStackTransactionListener fragmentStackTransactionListener ) {
|
||||
this.mFragmentStackTransactionListeners.add( fragmentStackTransactionListener );
|
||||
}
|
||||
|
||||
public void setFragmentStackTransactionListener( FragmentStackTransactionListener fragmentStackTransactionListener ) {
|
||||
@@ -145,8 +166,9 @@ public class FragmentStack {
|
||||
mFragmentTransaction.commitAllowingStateLoss();
|
||||
mFragmentStack.clear();
|
||||
mCurrentFragment = null;
|
||||
if ( getFragmentStackTransactionListener() != null ) {
|
||||
getFragmentStackTransactionListener().onTransaction();
|
||||
if ( mFragmentStackTransactionListener != null ) {
|
||||
mFragmentStackTransactionListener.onTransaction(getStackSize());
|
||||
}
|
||||
invokeCallback();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mogo.module.main.fragmentmanager;
|
||||
package com.mogo.service.impl.fragmentmanager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.fragmentmanager.FragmentDescriptor;
|
||||
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
|
||||
/**
|
||||
@@ -36,6 +39,21 @@ public class MogoFragmentManager implements IMogoFragmentManager {
|
||||
FragmentStack.getInstance().clearAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMainFragmentStackTransactionListener( FragmentStackTransactionListener listener ) {
|
||||
FragmentStack.getInstance().setFragmentStackTransactionListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMainFragmentStackTransactionListener( FragmentStackTransactionListener listener ) {
|
||||
FragmentStack.getInstance().addFragmentStackTransactionListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( AppCompatActivity activity, int containerId ) {
|
||||
FragmentStack.getInstance().init( activity, containerId );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
Reference in New Issue
Block a user