SettingsActivityPresenter implements PackageListAdapter.onPackageToggleListener { @Override public void onPackageToggle(String packageName, boolean activated) { if (activated) { activatedPackages.add(packageName); } else { activatedPackages.remove(packageName); } preferences.edit().putStringSet(Constants.ACTIVATED_PACKAGES, activatedPackages).apply(); } @Inject  SettingsActivityPresenter(Context context, SharedPreferences preferences,
      ApplicationsInfoStore applicationsInfoStore); SettingsActivityPresenter setView(SettingsView settingsView); void execute(); void onSearch(final String query); void onDestroy(); @Override void onPackageToggle(String packageName, boolean activated);  }
@Test public void testOnPackageToggle() throws Exception { assertTrue(sharedPreferences.getStringSet(Constants.ACTIVATED_PACKAGES, new HashSet<String>()) .isEmpty()); settingsActivityPresenter.onPackageToggle(mockString, true); assertTrue(sharedPreferences.getStringSet(Constants.ACTIVATED_PACKAGES, new HashSet<String>()) .contains(mockString)); settingsActivityPresenter.onPackageToggle(mockString, false); assertFalse(sharedPreferences.getStringSet(Constants.ACTIVATED_PACKAGES, new HashSet<String>()) .contains(mockString)); }