@@ -135,6 +135,20 @@ public void onSwitchChanged(Switch view, boolean isChecked) {
135135 view .setChecked (!isChecked );
136136 enabled = !isChecked ;
137137 }
138+
139+ if (enabled ) {
140+ if (!checkedList .isEmpty ()) {
141+ new BlurBehindDialogBuilder (activity , R .style .ThemeOverlay_MaterialAlertDialog_Centered_FullWidthButtons )
142+ .setMessage (R .string .use_recommended_message )
143+ .setPositiveButton (android .R .string .ok , (dialog , which ) -> checkRecommended ())
144+ .setNegativeButton (android .R .string .cancel , null )
145+ .show ();
146+ } else {
147+ checkRecommended ();
148+ }
149+ }
150+
151+ // If failed to enable module and checkedList is not empty, revert the change
138152 var tmpChkList = new HashSet <>(checkedList );
139153 if (isChecked && !tmpChkList .isEmpty () && !ConfigManager .setModuleScope (module .packageName , module .legacy , tmpChkList )) {
140154 view .setChecked (false );
@@ -230,10 +244,18 @@ private void checkRecommended() {
230244 fragment .showHint (R .string .module_is_not_activated_yet , false );
231245 return ;
232246 }
247+
248+ var tmpChkList = new HashSet <>(checkedList );
249+ tmpChkList .removeIf (i -> i .userId == module .userId );
250+ var tmpDenyList = new HashSet <>(denyList );
251+ // Filter recommended list to exclude deny list items
252+ for (ApplicationWithEquals app : recommendedList ) {
253+ if (!tmpDenyList .contains (app .packageName )) {
254+ tmpChkList .add (app );
255+ }
256+ }
257+
233258 fragment .runAsync (() -> {
234- var tmpChkList = new HashSet <>(checkedList );
235- tmpChkList .removeIf (i -> i .userId == module .userId );
236- tmpChkList .addAll (recommendedList );
237259 ConfigManager .setModuleScope (module .packageName , module .legacy , tmpChkList );
238260 checkedList = tmpChkList ;
239261 fragment .runOnUiThread (this ::notifyDataSetChanged );
0 commit comments