add api
This commit is contained in:
@@ -34,7 +34,6 @@ public class AppNavigatorFragment extends MvpFragment< AppNavigatorView, AppNavi
|
||||
private View mCarSettings;
|
||||
private View mApps;
|
||||
|
||||
private AppsFragment mAppsFragment;
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.module.apps.model.AppsModel;
|
||||
import com.mogo.module.apps.utils.LaunchUtils;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
@@ -39,6 +40,8 @@ public class AppNavigatorPresenter extends Presenter< AppNavigatorView > impleme
|
||||
super.onCreate( owner );
|
||||
mIntentManager = ( IMogoIntentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_INTENT_MANAGER ).navigation( getContext() );
|
||||
mMogoStatusManager = ( IMogoStatusManager ) ARouter.getInstance().build( MogoServicePaths.PATH_STATUS_MANAGER ).navigation( getContext() );
|
||||
// 预加载应用列表,空间换时间
|
||||
AppsModel.getInstance(getContext()).load( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,7 +57,7 @@ public class AppsAdapter extends BaseAdapter {
|
||||
}
|
||||
AppInfo appInfo = getItem( position );
|
||||
if ( appInfo.getIconResId() <= 0 ) {
|
||||
holder.mIcon.setImageDrawable( appInfo.getIcon() );
|
||||
holder.mIcon.setImageResource( R.drawable.module_apps_ic_default_icon );
|
||||
} else {
|
||||
holder.mIcon.setImageResource( appInfo.getIconResId() );
|
||||
}
|
||||
|
||||
@@ -16,68 +16,70 @@ import com.mogo.module.apps.R;
|
||||
public enum AppEnum {
|
||||
|
||||
//"QQ音乐",
|
||||
QQMusic( "com.pvetec.musics", R.drawable.module_apps_ic_qq_music ),
|
||||
QQMusic( "QQ音乐","com.pvetec.musics", R.drawable.module_apps_ic_qq_music ),
|
||||
|
||||
//"车聊聊",
|
||||
Im( "com.zhidao.imdemo", R.drawable.module_apps_ic_im ),
|
||||
Im( "车聊聊","com.zhidao.imdemo", R.drawable.module_apps_ic_im ),
|
||||
|
||||
//"探路",
|
||||
RoadCondition( "com.zhidao.roadcondition", R.drawable.module_apps_ic_road_condition ),
|
||||
RoadConditionSlit( "com.zhidao.roadcondition.split", R.drawable.module_apps_ic_road_condition ),
|
||||
RoadCondition( "探路","com.zhidao.roadcondition", R.drawable.module_apps_ic_road_condition ),
|
||||
RoadConditionSlit( "探路","com.zhidao.roadcondition.split", R.drawable.module_apps_ic_road_condition ),
|
||||
|
||||
//"福利",
|
||||
Welfare( "com.zhidaohulian.welfare.car", R.drawable.module_apps_ic_welfare ),
|
||||
Welfare( "福利","com.zhidaohulian.welfare.car", R.drawable.module_apps_ic_welfare ),
|
||||
|
||||
//"蘑菇小队",
|
||||
Fleet( "com.zhidao.fleet", R.drawable.module_apps_ic_fleet ),
|
||||
Fleet( "蘑菇小队","com.zhidao.fleet", R.drawable.module_apps_ic_fleet ),
|
||||
|
||||
//"行车记录仪",
|
||||
CarCorder( "com.zhidao.carcorder", R.drawable.module_apps_ic_carcorder ),
|
||||
CarCorder( "行车记录仪","com.zhidao.carcorder", R.drawable.module_apps_ic_carcorder ),
|
||||
|
||||
//"懒人听书",
|
||||
Lrts( "com.zhidao.lrts", R.drawable.module_apps_ic_lrts ),
|
||||
Lrts( "懒人听书","com.zhidao.lrts", R.drawable.module_apps_ic_lrts ),
|
||||
|
||||
//"一键清理",
|
||||
CleanMaster( "com.zhidao.cleanmaster", R.drawable.module_apps_ic_clean_master ),
|
||||
CleanMaster( "一键清理","com.zhidao.cleanmaster", R.drawable.module_apps_ic_clean_master ),
|
||||
|
||||
//"系统升级",
|
||||
Fota( "com.abupdate.fota_demo_iot", R.drawable.module_apps_ic_fota ),
|
||||
Fota( "系统升级","com.abupdate.fota_demo_iot", R.drawable.module_apps_ic_fota ),
|
||||
|
||||
//"微信车机助手",
|
||||
WechatHelper( "com.zhidao.wechathelper", R.drawable.module_apps_ic_wechat ),
|
||||
WechatHelper( "微信车机助手","com.zhidao.wechathelper", R.drawable.module_apps_ic_wechat ),
|
||||
|
||||
//"爱奇艺HD",
|
||||
Qiyi( "com.qiyi.video.pad", R.drawable.module_apps_ic_qiyi ),
|
||||
Qiyi( "爱奇艺HD","com.qiyi.video.pad", R.drawable.module_apps_ic_qiyi ),
|
||||
|
||||
//"喜马拉雅",
|
||||
Ximalaya( "com.ximalaya.ting.android.car", R.drawable.module_apps_ic_ximalaya ),
|
||||
Ximalaya( "喜马拉雅","com.ximalaya.ting.android.car", R.drawable.module_apps_ic_ximalaya ),
|
||||
|
||||
//"均衡器",
|
||||
Equlizer( "com.zhidao.equalizer", R.drawable.module_apps_ic_equlizer ),
|
||||
Equlizer( "均衡器","com.zhidao.equalizer", R.drawable.module_apps_ic_equlizer ),
|
||||
|
||||
//"方控学习",
|
||||
SteerProduct( "com.zd.steerproduct", R.drawable.module_apps_ic_stee_product ),
|
||||
SteerProduct( "方控学习","com.zd.steerproduct", R.drawable.module_apps_ic_stee_product ),
|
||||
|
||||
//"蓝牙音乐",
|
||||
BTMusic( "com.nwd.bt.music", R.drawable.module_apps_ic_bt ),
|
||||
BTMusic( "蓝牙音乐","com.nwd.bt.music", R.drawable.module_apps_ic_bt ),
|
||||
|
||||
//"车载设置",
|
||||
CarSettings( "com.zhidao.settings", R.drawable.module_apps_ic_car_setting ),
|
||||
CarSettings( "车载设置","com.zhidao.settings", R.drawable.module_apps_ic_car_setting ),
|
||||
|
||||
//"AUX",
|
||||
AUX( "com.nwd.auxin", R.drawable.module_apps_ic_aux ),
|
||||
AUX( "AUX","com.nwd.auxin", R.drawable.module_apps_ic_aux ),
|
||||
|
||||
//FM
|
||||
FM( " com.nwd.radio", R.drawable.module_apps_ic_fm ),
|
||||
FM( "FM","com.nwd.radio", R.drawable.module_apps_ic_fm ),
|
||||
|
||||
// 新鲜事
|
||||
FreshThings( "com.zhidao.fresh.things", R.drawable.module_apps_ic_fresh_things ),
|
||||
FreshThings( "新鲜事","com.zhidao.fresh.things", R.drawable.module_apps_ic_fresh_things ),
|
||||
;
|
||||
|
||||
private String mName;
|
||||
private String mPkg;
|
||||
private int mIconResId;
|
||||
|
||||
AppEnum( String pkg, int iconResId ) {
|
||||
AppEnum( String name, String pkg, int iconResId ) {
|
||||
this.mName = name;
|
||||
this.mPkg = pkg;
|
||||
this.mIconResId = iconResId;
|
||||
}
|
||||
@@ -89,4 +91,8 @@ public enum AppEnum {
|
||||
public int getIconResId() {
|
||||
return mIconResId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,12 @@ public class AppEnumHelper {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static String getTargetName(String pkg){
|
||||
AppEnum appEnum = sCustomizedApps.get( pkg );
|
||||
if ( appEnum != null ) {
|
||||
return appEnum.getName();
|
||||
}
|
||||
return pkg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,12 +74,13 @@ public class AppsModel {
|
||||
if ( !mPagedApps.containsKey( page ) ) {
|
||||
mPagedApps.put( page, new ArrayList<>() );
|
||||
}
|
||||
String appName = packageInfo.applicationInfo.loadLabel( packageManager ).toString();
|
||||
String appName = getApplicationName( packageManager, packageInfo );
|
||||
String packageName = packageInfo.packageName;
|
||||
String versionName = packageInfo.versionName;
|
||||
int versionCode = packageInfo.versionCode;
|
||||
Drawable appIcon = packageInfo.applicationInfo.loadIcon( packageManager );
|
||||
AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, appIcon, AppEnumHelper.getCustomizedAppIconResId( packageName ) );
|
||||
// 不加载默认图标,避免不必要的开销,因为现在应用列表图标都是定制的啊~~~~
|
||||
// Drawable appIcon = packageInfo.applicationInfo.loadIcon( packageManager );
|
||||
AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, null, AppEnumHelper.getCustomizedAppIconResId( packageName ) );
|
||||
mPagedApps.get( page ).add( appInfo );
|
||||
}
|
||||
if ( callback != null ) {
|
||||
@@ -102,7 +103,7 @@ public class AppsModel {
|
||||
final PackageManager packageManager = mContext.getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo( packageName, 0 );
|
||||
if ( !mAppFilter.filter( packageInfo ) ) {
|
||||
String appName = packageInfo.applicationInfo.loadLabel( packageManager ).toString();
|
||||
String appName = getApplicationName( packageManager, packageInfo );
|
||||
String versionName = packageInfo.versionName;
|
||||
int versionCode = packageInfo.versionCode;
|
||||
Drawable appIcon = packageInfo.applicationInfo.loadIcon( packageManager );
|
||||
@@ -119,6 +120,14 @@ public class AppsModel {
|
||||
}
|
||||
}
|
||||
|
||||
private String getApplicationName( PackageManager packageManager, PackageInfo packageInfo ) {
|
||||
String name = packageManager.getApplicationLabel( packageInfo.applicationInfo ).toString();
|
||||
if ( name.startsWith( "com." ) || name.split( "." ).length > 3 ) {
|
||||
return AppEnumHelper.getTargetName( packageInfo.packageName );
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private int getPageIndex( String packageName, boolean add ) {
|
||||
int totalPages = mPagedApps.size();
|
||||
if ( add ) {
|
||||
|
||||
Reference in New Issue
Block a user