Refactoring

pull/184/head
M66B 4 years ago
parent 083a829df8
commit e9f2bfe3ac

@ -170,13 +170,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swExternalSearch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
PackageManager pm = getContext().getPackageManager();
pm.setComponentEnabledSetting(
new ComponentName(getContext(), ActivitySearch.class),
checked
? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
Helper.enableComponent(getContext(), ActivitySearch.class, checked);
}
});

@ -455,6 +455,20 @@ public class Helper {
return (ris != null && ris.size() > 0);
}
static void enableComponent(Context context, Class<?> clazz, boolean wether) {
enableComponent(context, clazz.getName(), wether);
}
static void enableComponent(Context context, String name, boolean wether) {
PackageManager pm = context.getPackageManager();
pm.setComponentEnabledSetting(
new ComponentName(context, name),
wether
? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
}
// View
static Intent getChooser(Context context, Intent intent) {

Loading…
Cancel
Save