Browse Source

1.不再默认生成应用商店

2.添加应用列表隐藏规则
20241218TB223FC(测试jar包)
wangwanlei 10 months ago
parent
commit
45739b7a0e

+ 26
- 8
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt View File

28
 import com.bumptech.glide.Glide
28
 import com.bumptech.glide.Glide
29
 import com.bumptech.glide.request.target.CustomViewTarget
29
 import com.bumptech.glide.request.target.CustomViewTarget
30
 import com.bumptech.glide.request.transition.Transition
30
 import com.bumptech.glide.request.transition.Transition
31
+import com.google.gson.reflect.TypeToken
31
 import com.hjq.toast.Toaster
32
 import com.hjq.toast.Toaster
32
 import com.kongzue.dialogx.dialogs.CustomDialog
33
 import com.kongzue.dialogx.dialogs.CustomDialog
33
 import com.kongzue.dialogx.interfaces.OnBindView
34
 import com.kongzue.dialogx.interfaces.OnBindView
51
 import com.xhly.manageapp.bean.EventLog
52
 import com.xhly.manageapp.bean.EventLog
52
 import com.xhly.manageapp.bean.SocketMsgBean
53
 import com.xhly.manageapp.bean.SocketMsgBean
53
 import com.xhly.manageapp.bean.app.AppInstallBean
54
 import com.xhly.manageapp.bean.app.AppInstallBean
55
+import com.xhly.manageapp.bean.app.AppModel
54
 import com.xhly.manageapp.bean.log.LogPushBean
56
 import com.xhly.manageapp.bean.log.LogPushBean
55
 import com.xhly.manageapp.bean.log.LogdOperateBean
57
 import com.xhly.manageapp.bean.log.LogdOperateBean
56
 import com.xhly.manageapp.bean.log.UpdateBean
58
 import com.xhly.manageapp.bean.log.UpdateBean
139
         // csdkManagerUtils.csdkManager.enableAccessibility("com.xhly.manageapp","com.xhly.manageapp.service.TestService",true)
141
         // csdkManagerUtils.csdkManager.enableAccessibility("com.xhly.manageapp","com.xhly.manageapp.service.TestService",true)
140
 
142
 
141
         viewModel.listAppData.observe(this) { modelList ->
143
         viewModel.listAppData.observe(this) { modelList ->
142
-            //存储商店应用包名到本地
144
+            //存储商店应用包名到本地,并且存储商店应用列表数据到本地集合
143
             val appNameList = arrayListOf<String>()
145
             val appNameList = arrayListOf<String>()
144
             val whiteList = arrayListOf<String>()
146
             val whiteList = arrayListOf<String>()
145
             modelList.forEach {
147
             modelList.forEach {
149
                 }
151
                 }
150
             }
152
             }
151
             ManageApplication.addAppWhiteRule(whiteList)
153
             ManageApplication.addAppWhiteRule(whiteList)
152
-            spUtils.saveJson(Const.APPSTOREKEY, appNameList)
154
+            spUtils.saveJson(Const.APPSTOREDATAKEY,modelList)
153
             //获得应用集合,必装应用和推荐应用,再加上预装应用(预装应用直接隐藏),其余应用需要静默卸载,必装应用需要进行静默下载和安装。安装应用从forceapp接口获取
155
             //获得应用集合,必装应用和推荐应用,再加上预装应用(预装应用直接隐藏),其余应用需要静默卸载,必装应用需要进行静默下载和安装。安装应用从forceapp接口获取
154
             val appList = AppUtils.GetAppList(this)
156
             val appList = AppUtils.GetAppList(this)
155
             val firstAppList = arrayListOf<String>()
157
             val firstAppList = arrayListOf<String>()
936
 
938
 
937
     private fun updateAppRv() {
939
     private fun updateAppRv() {
938
         try {
940
         try {
939
-            //获得预装应用和商店应用,商店应用和预装重叠直接显示,其余预装直接隐藏
941
+            //获得预装应用和商店应用,商店应用(隐藏图标的不显示)和预装重叠直接显示,其余预装直接隐藏
940
             var schoolDeviceSetBean: SchoolDeviceSetBean? = null
942
             var schoolDeviceSetBean: SchoolDeviceSetBean? = null
941
             schoolDeviceSetBean = StrategyUtils.getSchoolDeviceSetBean(this)
943
             schoolDeviceSetBean = StrategyUtils.getSchoolDeviceSetBean(this)
942
             val storeList = arrayListOf<String>()
944
             val storeList = arrayListOf<String>()
945
+            val storeRemoveList= arrayListOf<String>()
943
             try {
946
             try {
944
-                val fromJson = spUtils.getFromJson(Const.APPSTOREKEY, ArrayList<String>().javaClass)
945
-                if (fromJson != null) {
946
-                    storeList.addAll(fromJson as ArrayList<String>)
947
+                val type = object : TypeToken<List<AppModel>>() {}.type
948
+                val appModelList = spUtils.getFromJsonType(
949
+                    Const.APPSTOREDATAKEY,
950
+                    ArrayList<AppModel>().javaClass,
951
+                    type
952
+                ) as ArrayList<AppModel>
953
+                if (appModelList != null) {
954
+                    appModelList.filter { it.showico==1}.forEach {
955
+                        storeList.add(it.appPackage)
956
+                    }
957
+                    appModelList.filter { it.showico==0}.forEach {
958
+                        storeRemoveList.add(it.appPackage)
959
+                    }
947
                 }
960
                 }
948
             } catch (e: Exception) {
961
             } catch (e: Exception) {
949
                 LogShow("商店应用为空")
962
                 LogShow("商店应用为空")
960
                         ArrayList<String>().javaClass
973
                         ArrayList<String>().javaClass
961
                     ) as ArrayList<String>
974
                     ) as ArrayList<String>
962
                 currentList.forEach { pkg ->
975
                 currentList.forEach { pkg ->
963
-                    //学校控制之外的预装应用加入移除集合,应用商店列表包含的不需要加入移除集合
976
+                    //获得预装,在学校控制和应用商店显示以外的app加入移除集合
964
                     if (!Const.schoolSetAppList.contains(pkg) && !storeList.contains(pkg)) {
977
                     if (!Const.schoolSetAppList.contains(pkg) && !storeList.contains(pkg)) {
965
                         appList.filter { it.packageName == pkg }.forEach {
978
                         appList.filter { it.packageName == pkg }.forEach {
966
                             removeList.add(it)
979
                             removeList.add(it)
971
 
984
 
972
             }
985
             }
973
             //如果包含应用商店也移除,因为会在自定义app中添加
986
             //如果包含应用商店也移除,因为会在自定义app中添加
974
-            appList.filter { it.packageName == Const.STOREAPPPKG }.forEach {
987
+           /* appList.filter { it.packageName == Const.STOREAPPPKG }.forEach {
975
                 removeList.add(it)
988
                 removeList.add(it)
989
+            }*/
990
+
991
+            //移除应用列表隐藏的应用
992
+            storeRemoveList.forEach {pkg->
993
+                appList.removeIf { it.packageName==pkg }
976
             }
994
             }
977
             //移除学校控制之外预装应用
995
             //移除学校控制之外预装应用
978
             appList.removeAll(removeList)
996
             appList.removeAll(removeList)

+ 2
- 2
app/src/main/java/com/xhly/manageapp/utils/CustomAppUtils.kt View File

11
 class CustomAppUtils {
11
 class CustomAppUtils {
12
     public fun getCustomAppList(context: Context): ArrayList<AppInfo> {
12
     public fun getCustomAppList(context: Context): ArrayList<AppInfo> {
13
         val appList= arrayListOf<AppInfo>()
13
         val appList= arrayListOf<AppInfo>()
14
-        appList.add(getCusomAppBean(
14
+     /*   appList.add(getCusomAppBean(
15
             context.getString(R.string.appstore),
15
             context.getString(R.string.appstore),
16
             Const.STOREAPPPKG,
16
             Const.STOREAPPPKG,
17
             AppCompatResources.getDrawable(context,R.drawable.icon_store)!!
17
             AppCompatResources.getDrawable(context,R.drawable.icon_store)!!
18
-        ))
18
+        ))*/
19
         appList.add(getCusomAppBean(
19
         appList.add(getCusomAppBean(
20
             context.getString(R.string.speed),
20
             context.getString(R.string.speed),
21
             Const.CUSTOMSPEEDAPP,
21
             Const.CUSTOMSPEEDAPP,

+ 14
- 4
app/src/main/java/com/xhly/manageapp/utils/StrategyUtils.kt View File

13
 import com.xhly.corelib.utils.SharedPreferencesUtils
13
 import com.xhly.corelib.utils.SharedPreferencesUtils
14
 import com.xhly.corelib.utils.hourToCurrentDateLong
14
 import com.xhly.corelib.utils.hourToCurrentDateLong
15
 import com.xhly.manageapp.ManageApplication
15
 import com.xhly.manageapp.ManageApplication
16
+import com.xhly.manageapp.bean.app.AppModel
16
 import com.xhly.manageapp.bean.school.SchoolDeviceSetBean
17
 import com.xhly.manageapp.bean.school.SchoolDeviceSetBean
17
 import com.xhly.manageapp.bean.strategy.AppTimeManageBean
18
 import com.xhly.manageapp.bean.strategy.AppTimeManageBean
18
 import com.xhly.manageapp.bean.strategy.StrategyBean
19
 import com.xhly.manageapp.bean.strategy.StrategyBean
325
     public fun clearAppData(context: Context) {
326
     public fun clearAppData(context: Context) {
326
         try {
327
         try {
327
             val spUtils by lazy { SharedPreferencesUtils.getInstance(context) }
328
             val spUtils by lazy { SharedPreferencesUtils.getInstance(context) }
328
-            val strings = spUtils.getFromJson(
329
-                Const.APPSTOREKEY,
330
-                ArrayList<String>().javaClass
331
-            ) as ArrayList<String>
329
+            val type = object : TypeToken<List<AppModel>>() {}.type
330
+            val appModelList = spUtils.getFromJsonType(
331
+                Const.APPSTOREDATAKEY,
332
+                ArrayList<AppModel>().javaClass,
333
+                type
334
+            ) as ArrayList<AppModel>
335
+
336
+            val strings= arrayListOf<String>()
337
+            appModelList.forEach {
338
+                if (it.cached==1){
339
+                    strings.add(it.appPackage)
340
+                }
341
+            }
332
             ManageApplication.clearAppData(strings)
342
             ManageApplication.clearAppData(strings)
333
         }catch (e:Exception){
343
         }catch (e:Exception){
334
 
344
 

Loading…
Cancel
Save