|
@@ -5,13 +5,15 @@ import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.content.pm.PackageManager;
|
|
|
import android.content.pm.ResolveInfo;
|
|
|
-import android.database.ContentObserver;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
+import android.os.SystemProperties;
|
|
|
import android.provider.Settings;
|
|
|
import android.telephony.TelephonyManager;
|
|
|
+import android.util.Log;
|
|
|
import android.widget.ImageView;
|
|
|
|
|
|
+import com.xplora.xplauncher.R;
|
|
|
import com.xplora.xplauncher.model.AppModel;
|
|
|
import com.xplora.xplauncher.model.ContactBean;
|
|
|
import com.xplora.xplauncher.model.RecentBean;
|
|
@@ -21,9 +23,12 @@ import com.xplora.xplauncher.utils.ResUtils;
|
|
|
import com.xplora.xplauncher.utils.ToolsUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
public class DataManager extends Application {
|
|
|
+ public String TAG = "losion :" + getClass().getSimpleName();
|
|
|
public static Context sContext;
|
|
|
private static int mFaceIndex = 0;
|
|
|
private static int mAppNameType = 0; //是否显示 app 名称
|
|
@@ -43,7 +48,14 @@ public class DataManager extends Application {
|
|
|
|
|
|
public void initData() {
|
|
|
List<AppModel> appModelList = loadInstalledApps();
|
|
|
- mInstalledAppsList = sortAppList(appModelList);
|
|
|
+ List<AppModel> sortAppList = sortAppList(appModelList);
|
|
|
+ if (getIsFactoryMode()) {
|
|
|
+ //xp应用提前
|
|
|
+ mInstalledAppsList = sortAppList;
|
|
|
+ } else {
|
|
|
+ //过滤非xp应用
|
|
|
+ mInstalledAppsList = filterPackageName(sortAppList);
|
|
|
+ }
|
|
|
|
|
|
loadQuickApps();
|
|
|
loadWeatherIndex();
|
|
@@ -64,6 +76,7 @@ public class DataManager extends Application {
|
|
|
model.setAppLabel((String) info.loadLabel(pm));
|
|
|
model.setAppIcon((Drawable) info.loadIcon(pm));
|
|
|
appModelList.add(model);
|
|
|
+ Log.d("losion", "loadInstalledApps: " + model.getPackageName());
|
|
|
}
|
|
|
return appModelList;
|
|
|
}
|
|
@@ -130,6 +143,10 @@ public class DataManager extends Application {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static void insertFactoryApp() {
|
|
|
+ getAppModel("com.xplora.factorymode");
|
|
|
+ }
|
|
|
+
|
|
|
public static List<AppModel> getQuickAppsWithIndex(int index) {
|
|
|
int fromIndex = index * Constant.COUNT_VIEW_APP;
|
|
|
int toIndex = (fromIndex + Constant.COUNT_VIEW_APP);
|
|
@@ -190,7 +207,8 @@ public class DataManager extends Application {
|
|
|
String packageName = model.getPackageName();
|
|
|
boolean isXP = packageName.startsWith(Constant.PACKAGE_NAME_FILTER);
|
|
|
boolean isLauncher = packageName.equals(Constant.PACKAGE_NAME_FILTER_LAUNCHER);
|
|
|
- if (isXP && !isLauncher) {
|
|
|
+ boolean isOnboarding = packageName.equals(Constant.PACKAGE_NAME_FILTER_ONBOARDING);
|
|
|
+ if (isXP && !isLauncher && !isOnboarding) {
|
|
|
ret.add(model);
|
|
|
}
|
|
|
}
|
|
@@ -210,6 +228,37 @@ public class DataManager extends Application {
|
|
|
}
|
|
|
|
|
|
public List<AppModel> sortAppList(List<AppModel> appModelList) {
|
|
|
+ String[] sortStrings = getResources().getStringArray(R.array.xp_package_name);
|
|
|
+ ArrayList<String> sortList = new ArrayList<String>(sortStrings.length);
|
|
|
+ Collections.addAll(sortList, sortStrings);
|
|
|
+
|
|
|
+ for (int i = 0; i < appModelList.size()-1; i++) {
|
|
|
+ for (int j = 0; j < appModelList.size()-1-i; j++) {
|
|
|
+ int beforeIndex = sortList.indexOf(appModelList.get(j).getPackageName());
|
|
|
+ int afterIndex = sortList.indexOf(appModelList.get(j+1).getPackageName());
|
|
|
+
|
|
|
+ //1、都在配置表中,判断index;
|
|
|
+ //2、前一个不在配置表,后一个在配置表
|
|
|
+ if ((afterIndex >= 0 && beforeIndex > afterIndex) || (beforeIndex < 0 && afterIndex >= 0)) {
|
|
|
+ AppModel model = appModelList.get(j);
|
|
|
+ appModelList.set(j, appModelList.get(j+1));
|
|
|
+ appModelList.set(j+1, model);
|
|
|
+ } else {
|
|
|
+ //将xp提前
|
|
|
+ boolean isbeforeXP = appModelList.get(j).getPackageName().startsWith(Constant.PACKAGE_NAME_FILTER);
|
|
|
+ boolean isafterXP = appModelList.get(j+1).getPackageName().startsWith(Constant.PACKAGE_NAME_FILTER);
|
|
|
+ if (!isbeforeXP && isafterXP) {
|
|
|
+ AppModel model = appModelList.get(j);
|
|
|
+ appModelList.set(j, appModelList.get(j+1));
|
|
|
+ appModelList.set(j+1, model);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return appModelList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<AppModel> sortAppListEx(List<AppModel> appModelList) {
|
|
|
for (int i = 0; i < appModelList.size()-1; i++) {
|
|
|
for (int j = 0; j < appModelList.size()-1-i; j++) {
|
|
|
boolean isbeforeXP = appModelList.get(j).getPackageName().startsWith(Constant.PACKAGE_NAME_FILTER);
|
|
@@ -300,6 +349,11 @@ public class DataManager extends Application {
|
|
|
return Settings.Global.getInt(sContext.getContentResolver(), MetaData.KEY_APP_NAME, 0);
|
|
|
}
|
|
|
|
|
|
+ public static boolean getIsFactoryMode() {
|
|
|
+ //是否为产线模式
|
|
|
+ return SystemProperties.getBoolean("persist.sys.factoryimage", false);
|
|
|
+ }
|
|
|
+
|
|
|
public static void loadWeatherIndex() {
|
|
|
mWeatherIndex = 0;
|
|
|
}
|