This commit is contained in:
wangcongtao
2020-04-02 11:22:48 +08:00
parent e5aa098f83
commit 0626b8a1cb
6 changed files with 106 additions and 22 deletions

View File

@@ -43,9 +43,9 @@ public class AppFilterImpl implements AppFilter {
if ( !AppEnumHelper.isCustomizedApp( packageInfo.packageName ) ) {
return true;
}
// if ( noLaunchIntent( packageInfo ) ) {
// return true;
// }
if ( noLaunchIntent( packageInfo ) ) {
return true;
}
return false;
}

View File

@@ -1,5 +1,7 @@
package com.mogo.module.apps;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
@@ -11,6 +13,8 @@ import com.mogo.module.apps.applaunch.CardAppLauncher;
import com.mogo.module.apps.applaunch.GuideShowLauncher;
import com.mogo.module.apps.model.AppInfo;
import com.mogo.module.apps.model.AppsModel;
import com.mogo.module.apps.model.UnScannedApps;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.cardmanager.IMogoCardManager;
@@ -20,7 +24,6 @@ import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -40,14 +43,17 @@ public class AppsPresenter extends Presenter<AppsView> {
private IMogoAnalytics mAnalytics;
private AppLaunchFilter mLauncher;
private IMogoServiceApis mApis;
private IMogoCardManager mCardManager;
private IMogoStatusManager mMogoStatusManager;
public AppsPresenter(AppsView view) {
super(view);
mCardManager = (IMogoCardManager) ARouter.getInstance().build(MogoServicePaths.PATH_CARD_MANAGER).navigation(getContext());
mApis = (IMogoServiceApis)ARouter.getInstance().build( MogoServicePaths.PATH_SERVICE_APIS ).navigation(getContext());
mCardManager = mApis.getCardManagerApi();
CardAppLauncher cardAppLauncher = new CardAppLauncher(this, mCardManager);
GuideShowLauncher guideShowLauncher = new GuideShowLauncher();
GuideShowLauncher guideShowLauncher = new GuideShowLauncher(mApis.getMapServiceApi().getNavi( getContext() ));
cardAppLauncher.setNext(guideShowLauncher);
guideShowLauncher.setNext(new AppLauncher());
mLauncher = cardAppLauncher;
@@ -63,8 +69,8 @@ public class AppsPresenter extends Presenter<AppsView> {
}
});
mAnalytics = (IMogoAnalytics) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation(getContext());
mMogoStatusManager = (IMogoStatusManager) ARouter.getInstance().build(MogoServicePaths.PATH_STATUS_MANAGER).navigation();
mAnalytics = mApis.getAnalyticsApi();
mMogoStatusManager = mApis.getStatusManagerApi();
mMogoStatusManager.setAppListUIShow(TAG, true);
}
@@ -73,9 +79,10 @@ public class AppsPresenter extends Presenter<AppsView> {
AppsModel.getInstance(getContext()).load(appInfoList -> {
Logger.d(TAG, "apps: %s", appInfoList);
final Map<Integer, List<AppInfo>> result = addOthersEntrances( appInfoList );
UiThreadHandler.post(() -> {
if (mView != null) {
mView.renderApps(addGuideAppEntrance(appInfoList));
mView.renderApps( result );
}
});
});
@@ -83,7 +90,12 @@ public class AppsPresenter extends Presenter<AppsView> {
});
}
private Map<Integer, List<AppInfo>> addGuideAppEntrance(Map<Integer, List<AppInfo>> appInfoMap) {
/**
* 新增入口
* @param appInfoMap
* @return
*/
private Map<Integer, List<AppInfo>> addOthersEntrances( Map<Integer, List<AppInfo>> appInfoMap) {
Map<Integer, List<AppInfo>> result = new HashMap<>();
if ( appInfoMap != null && !appInfoMap.isEmpty() ) {
@@ -99,18 +111,60 @@ public class AppsPresenter extends Presenter<AppsView> {
}
}
if (result.isEmpty()) {
result.put(0, new ArrayList<>());
} else if (result.get(result.size() - 1) == null) {
result.put(result.size() - 1, new ArrayList<>());
} else if (result.get(result.size() - 1).size() == AppsConst.TOTAL_SIZE_EACH_PAGE) {
result.put(result.size(), new ArrayList<>());
// 手动添加无法识别到的app
List<AppInfo> apps = UnScannedApps.getUnScannedApps();
if ( apps != null && !apps.isEmpty() ) {
for ( AppInfo app : apps ) {
if ( app == null ) {
continue;
}
Set<Integer> keys = result.keySet();
boolean addFlag = true;
for ( Integer key : keys ) {
List<AppInfo> val = result.get( key );
// 无法扫描到蓝牙电话app这里手动添加
for ( AppInfo appInfo : val ) {
if ( appInfo == null ) {
continue;
}
if ( TextUtils.equals( appInfo.getPackageName(), app.getPackageName() ) ) {
addFlag = false;
break;
}
}
if ( !addFlag ) {
break;
}
}
if ( addFlag ) {
growthCapacity(result);
result.get(result.size() - 1).add(app);
}
}
}
// 添加逻辑
growthCapacity(result);
// 添加介绍入口
result.get(result.size() - 1).add(new AppInfo(GuideShowLauncher.APP_INFO_NAME_GUIDE_SHOW, getContext().getPackageName(), null, 0, null, R.drawable.module_apps_ic_guide_show));
return result;
}
/**
* 扩容
* @param target
*/
private void growthCapacity( Map<Integer, List<AppInfo>> target ){
if ( target == null ) {
return;
}
if (target.isEmpty()) {
target.put(0, new ArrayList<>());
} else if (target.get(target.size() - 1) == null) {
target.put(target.size() - 1, new ArrayList<>());
} else if (target.get(target.size() - 1).size() == AppsConst.TOTAL_SIZE_EACH_PAGE) {
target.put(target.size(), new ArrayList<>());
}
}
public void launch(AppInfo appInfo) {
if (appInfo == null) {
return;

View File

@@ -4,7 +4,7 @@ import android.app.Activity;
import android.content.Context;
import com.mogo.commons.voice.AIAssist;
import com.mogo.map.impl.amap.navi.NaviClient;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.module.apps.AppServiceHandler;
import com.mogo.module.apps.R;
import com.mogo.module.apps.model.AppInfo;
@@ -17,10 +17,16 @@ public class GuideShowLauncher extends BaseAppLauncher {
public static final String TAG = "GuideShowLauncher";
public static final String APP_INFO_NAME_GUIDE_SHOW = "新手引导";
private IMogoNavi mNavi;
public GuideShowLauncher( IMogoNavi navi ) {
this.mNavi = navi;
}
@Override
public void launch(Context context, AppInfo appInfo) {
if (appInfo != null && APP_INFO_NAME_GUIDE_SHOW.equals(appInfo.getName())) {
if (!NaviClient.getInstance(context).isNaviing()) {
if ( mNavi != null && !mNavi.isNaviing()) {
AppServiceHandler.getMogoGuideShow().playGuideVideo((Activity) context, (s) -> {
Logger.d(TAG, s);
return Unit.INSTANCE;

View File

@@ -77,7 +77,7 @@ public enum AppEnum {
LocalVideo( "本地视频", "com.zhidao.video", R.drawable.module_apps_ic_local_video ),
// 车辆信息
CanBus( "车辆信息", "com.zd.canbus", R.drawable.module_apps_ic_canbus ),
CanBus( "车辆信息", "com.nwd.can.setting", R.drawable.module_apps_ic_canbus ),
// 蓝牙电话
BT_PHONE( "蓝牙电话", "com.nwd.android.phone", R.drawable.module_apps_ic_bt_phone ),

View File

@@ -0,0 +1,24 @@
package com.mogo.module.apps.model;
import java.util.ArrayList;
import java.util.List;
/**
* @author congtaowang
* @since 2020-04-02
* <p>
* 扫描不到的app
*/
public class UnScannedApps {
private static List< AppInfo > sUnScannedApps = new ArrayList<>();
static {
sUnScannedApps.add( new AppInfo( AppEnum.BT_PHONE.getName(), AppEnum.BT_PHONE.getPkg(), null, 0, null, AppEnum.BT_PHONE.getIconResId() ) );
sUnScannedApps.add( new AppInfo( AppEnum.CanBus.getName(), AppEnum.CanBus.getPkg(), null, 0, null, AppEnum.CanBus.getIconResId() ) );
}
public static List< AppInfo > getUnScannedApps() {
return sUnScannedApps;
}
}

View File

@@ -280,7 +280,7 @@ public class MogoModulesManager implements MogoModulesHandler,
mSortedCards.remove( mEnableModuleName );
mSortedCards.add( 0, mEnableModuleName );
SharedPrefsMgr.getInstance( getContext() ).putString( KEY_SORTED_CARD_MODULES, GsonUtil.jsonFromObject( mSortedCards ) );
Log.i( TAG, "enable & disable card cost " + ( System.currentTimeMillis() - start1 ) + "ms" );
Logger.i( TAG, "enable & disable card cost " + ( System.currentTimeMillis() - start1 ) + "ms" );
CardIntroduceConfigs.broadcastCardIntroduce( mActivity, mEnableModuleName );
}
@@ -401,7 +401,7 @@ public class MogoModulesManager implements MogoModulesHandler,
}
}
}
Log.i( TAG, "onMapChanged event cost " + ( System.currentTimeMillis() - start ) + "ms" );
Logger.i( TAG, "onMapChanged event cost " + ( System.currentTimeMillis() - start ) + "ms" );
}
@Override