瀏覽代碼

1.修改App列表显示规则

20241218TB223FC(测试jar包)
wangwanlei 10 月之前
父節點
當前提交
3f3f35f85f
共有 1 個檔案被更改,包括 23 行新增19 行删除
  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 查看文件

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

Loading…
取消
儲存