Browse Source

1.修改App列表显示规则

20241218TB223FC(测试jar包)
wangwanlei 10 months ago
parent
commit
3f3f35f85f
1 changed files with 23 additions and 19 deletions
  1. 23
    19
      app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt

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

58
 import com.xhly.manageapp.bean.user.UserBean
58
 import com.xhly.manageapp.bean.user.UserBean
59
 import com.xhly.manageapp.broadcastreceiver.AppInstallReceiver
59
 import com.xhly.manageapp.broadcastreceiver.AppInstallReceiver
60
 import com.xhly.manageapp.service.ManageAccessibilityService
60
 import com.xhly.manageapp.service.ManageAccessibilityService
61
+import com.xhly.manageapp.service.websocket.AppSocket
61
 import com.xhly.manageapp.ui.ManageActivity
62
 import com.xhly.manageapp.ui.ManageActivity
62
 import com.xhly.manageapp.ui.login.activity.LoginActivity
63
 import com.xhly.manageapp.ui.login.activity.LoginActivity
63
 import com.xhly.manageapp.ui.main.viewmodel.MainViewModel
64
 import com.xhly.manageapp.ui.main.viewmodel.MainViewModel
181
             spUtils.saveJson(Const.STRATEGYBEANKEY, it)
182
             spUtils.saveJson(Const.STRATEGYBEANKEY, it)
182
             StrategyUtils.setStrategy(it)
183
             StrategyUtils.setStrategy(it)
183
             useTimeStrategy()
184
             useTimeStrategy()
184
-            updateStrategyFlag=true
185
-            if (updateTimeFlag){
186
-                showSucessToast()
187
-                updateStrategyFlag=false
188
-            }
189
         }
185
         }
190
         viewModel.appStrategyData.observe(this) {
186
         viewModel.appStrategyData.observe(this) {
191
             //存储app时间策略
187
             //存储app时间策略
192
             spUtils.saveJson(Const.APPSTRATEGYBEANKEY, it)
188
             spUtils.saveJson(Const.APPSTRATEGYBEANKEY, it)
193
-            updateTimeFlag=true
194
-            if (updateStrategyFlag){
195
-                showSucessToast()
196
-                updateTimeFlag=false
197
-            }
189
+            showSucessToast()
198
         }
190
         }
199
         viewModel.padInfoData.observe(this) {
191
         viewModel.padInfoData.observe(this) {
200
             //存储信息上传时间
192
             //存储信息上传时间
873
 
865
 
874
     private fun updateAppRv() {
866
     private fun updateAppRv() {
875
         try {
867
         try {
868
+            //获得预装应用和商店应用,商店应用和预装重叠直接显示,其余预装直接隐藏
876
             var schoolDeviceSetBean: SchoolDeviceSetBean? = null
869
             var schoolDeviceSetBean: SchoolDeviceSetBean? = null
877
             schoolDeviceSetBean = StrategyUtils.getSchoolDeviceSetBean(this)
870
             schoolDeviceSetBean = StrategyUtils.getSchoolDeviceSetBean(this)
871
+            val storeList= arrayListOf<String>()
872
+            try {
873
+                val fromJson = spUtils.getFromJson(Const.APPSTOREKEY, ArrayList<String>().javaClass)
874
+                if (fromJson!=null){
875
+                    storeList.addAll(fromJson as ArrayList<String>)
876
+                }
877
+            }catch (e:Exception){
878
+                LogShow("商店应用为空")
879
+            }
878
             dataList.clear()
880
             dataList.clear()
879
             var appList = AppUtils.GetAppList(this)
881
             var appList = AppUtils.GetAppList(this)
880
             //获得预装应用直接隐藏
882
             //获得预装应用直接隐藏
883
+            val removeList = arrayListOf<AppInfo>()
881
             try {
884
             try {
882
                 //获得预装应用的包名
885
                 //获得预装应用的包名
883
                 val currentList =
886
                 val currentList =
885
                         Const.FIRSTAPPLIST,
888
                         Const.FIRSTAPPLIST,
886
                         ArrayList<String>().javaClass
889
                         ArrayList<String>().javaClass
887
                     ) as ArrayList<String>
890
                     ) as ArrayList<String>
888
-                val removeList = arrayListOf<AppInfo>()
889
                 currentList.forEach { pkg ->
891
                 currentList.forEach { pkg ->
890
-                    //学校控制之外的预装应用加入移除集合
891
-                    if (!Const.schoolSetAppList.contains(pkg)) {
892
+                    //学校控制之外的预装应用加入移除集合,应用商店列表包含的不需要加入移除集合
893
+                    if (!Const.schoolSetAppList.contains(pkg)&&!storeList.contains(pkg)) {
892
                         appList.filter { it.packageName == pkg }.forEach {
894
                         appList.filter { it.packageName == pkg }.forEach {
893
                             removeList.add(it)
895
                             removeList.add(it)
894
                         }
896
                         }
895
                     }
897
                     }
896
                 }
898
                 }
897
-                //如果包含应用商店也移除,因为会在自定义app中添加
898
-                appList.filter { it.packageName == Const.STOREAPPPKG}.forEach {
899
-                    removeList.add(it)
900
-                }
901
-                //移除学校控制之外预装应用
902
-                appList.removeAll(removeList)
903
             } catch (e: Exception) {
899
             } catch (e: Exception) {
904
 
900
 
905
             }
901
             }
902
+            //如果包含应用商店也移除,因为会在自定义app中添加
903
+            appList.filter { it.packageName == Const.STOREAPPPKG}.forEach {
904
+                removeList.add(it)
905
+            }
906
+            //移除学校控制之外预装应用
907
+            appList.removeAll(removeList)
908
+
906
             appList.addAll(CustomAppUtils().getCustomAppList(this))
909
             appList.addAll(CustomAppUtils().getCustomAppList(this))
907
             //获得学校设置,设置应用显示(部分回合预装重合,由学校设置判断是否显示)
910
             //获得学校设置,设置应用显示(部分回合预装重合,由学校设置判断是否显示)
908
             if (schoolDeviceSetBean != null) {
911
             if (schoolDeviceSetBean != null) {
1030
         deleteSharedPreferences(SharedPreferencesUtils.SP_FILE_NAME)
1033
         deleteSharedPreferences(SharedPreferencesUtils.SP_FILE_NAME)
1031
         Const.USERID = null
1034
         Const.USERID = null
1032
         Const.USERNAME = ""
1035
         Const.USERNAME = ""
1036
+        AppSocket.onDestroy()
1033
         startIntentActivity(LoginActivity().javaClass)
1037
         startIntentActivity(LoginActivity().javaClass)
1034
         finish()
1038
         finish()
1035
     }
1039
     }

Loading…
Cancel
Save