liuzhenxing1118 3 年之前
父节点
当前提交
10fcc850cd

+ 8 - 0
app/build.gradle

@@ -33,6 +33,13 @@ android {
     }
 }
 
+String SDK_DIR = System.getenv("ANDROID_SDK_HOME")
+if(SDK_DIR == null) {
+    Properties properties = new Properties()
+    properties.load(new FileInputStream(project.rootProject.file("local.properties")))
+    SDK_DIR = properties.get('sdk.dir')
+}
+
 dependencies {
     implementation 'androidx.appcompat:appcompat:1.4.1'
     implementation 'com.google.android.material:material:1.6.0'
@@ -41,6 +48,7 @@ dependencies {
     androidTestImplementation 'androidx.test.ext:junit:1.1.3'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
 
+    compileOnly(files("${SDK_DIR}/platforms/android-24/data/layoutlib.jar"))
     implementation(fileTree("libs"))
     //implementation fileTree(include: ['*.jar'], dir: 'main/libs')
     //implementation 'com.xplora.xplibcommon:xplibcommon'

+ 0 - 1
app/src/main/AndroidManifest.xml

@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.xplora.xplauncher"
-    android:sharedUserId="android.uid.system"
     >
 
     <uses-permission android:name="android.permission.VIBRATE" />

+ 2 - 0
app/src/main/java/com/xplora/xplauncher/activity/MainActivity.java

@@ -315,6 +315,8 @@ public class MainActivity extends BaseActivity {
 
     //更改是否显示删除按钮
     private void changeDeleteStatus() {
+        if (DataManager.getIsFactoryMode())
+            return;
         mDeleteBtnStatus = mDeleteBtnStatus == 0 ? 1 : 0;
         for (int i = 2; i < mPagerViews.size(); i++) {
             AppsPager pager = (AppsPager)mPagerViews.get(i);

+ 57 - 3
app/src/main/java/com/xplora/xplauncher/data/DataManager.java

@@ -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;
     }

+ 1 - 0
app/src/main/java/com/xplora/xplauncher/utils/Constant.java

@@ -15,6 +15,7 @@ public class Constant {
     public static String PACKAGE_NAME = "com.xplora.xplauncher";
     public static String PACKAGE_NAME_FILTER = "com.xplora.";
     public static String PACKAGE_NAME_FILTER_LAUNCHER = "com.xplora.xplauncher";
+    public static String PACKAGE_NAME_FILTER_ONBOARDING = "com.xplora.xponboarding";
     public static String FORMAT_DATE = "MM.dd.EEE";
 
     public static String FACE_SELECT = "face_select_";

+ 9 - 0
app/src/main/res/values/arrays.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string-array name="xp_package_name">
+        <item>com.xplora.factorymode</item>
+        <item>com.xplora.xpchat</item>
+        <item>com.xplora.xpsettings</item>
+        <item>com.xplora.xpaddfriend</item>
+    </string-array>
+</resources>