use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by crdroidandroid.
the class DashboardFragmentSearchIndexProviderInspector method isSharingPreferenceControllers.
public static boolean isSharingPreferenceControllers(Class clazz) {
final Context context = RuntimeEnvironment.application;
final Fragment fragment;
try {
fragment = Fragment.instantiate(context, clazz.getName());
} catch (Throwable e) {
// Can't do much with exception, assume the test passed.
return true;
}
if (!(fragment instanceof DashboardFragment)) {
return true;
}
final Indexable.SearchIndexProvider provider = DatabaseIndexingUtils.getSearchIndexProvider(clazz);
if (provider == null) {
return true;
}
final List<AbstractPreferenceController> controllersFromSearchIndexProvider;
final List<AbstractPreferenceController> controllersFromFragment;
try {
controllersFromSearchIndexProvider = provider.getPreferenceControllers(context);
} catch (Throwable e) {
// Can't do much with exception, assume the test passed.
return true;
}
try {
controllersFromFragment = ((DashboardFragment) fragment).getPreferenceControllers(context);
} catch (Throwable e) {
// Can't do much with exception, assume the test passed.
return true;
}
if (controllersFromFragment == controllersFromSearchIndexProvider) {
return true;
} else if (controllersFromFragment != null && controllersFromSearchIndexProvider != null) {
return controllersFromFragment.size() == controllersFromSearchIndexProvider.size();
} else {
return false;
}
}
use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by crdroidandroid.
the class ManageAssist method buildPreferenceControllers.
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new DefaultAssistPreferenceController(context, "default_assist", true));
controllers.add(new AssistGestureSettingsPreferenceController(context, lifecycle, KEY_ASSIST, true));
controllers.add(new AssistContextPreferenceController(context, lifecycle));
controllers.add(new AssistScreenshotPreferenceController(context, lifecycle));
controllers.add(new AssistFlashScreenPreferenceController(context, lifecycle));
controllers.add(new DefaultVoiceInputPreferenceController(context, lifecycle));
return controllers;
}
use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by crdroidandroid.
the class SecondaryUserControllerTest method dontAddPrimaryProfileAsASecondaryProfile.
@Test
public void dontAddPrimaryProfileAsASecondaryProfile() throws Exception {
ArrayList<UserInfo> userInfos = new ArrayList<>();
// The primary UserInfo may be a different object with a different name... but represent the
// same user!
UserInfo primaryUserRenamed = new UserInfo();
primaryUserRenamed.name = "Owner";
primaryUserRenamed.flags = UserInfo.FLAG_PRIMARY;
userInfos.add(primaryUserRenamed);
when(mUserManager.getPrimaryUser()).thenReturn(mPrimaryUser);
when(mUserManager.getUsers()).thenReturn(userInfos);
List<AbstractPreferenceController> controllers = SecondaryUserController.getSecondaryUserControllers(mContext, mUserManager);
assertThat(controllers).hasSize(1);
// We should have the NoSecondaryUserController.
assertThat(controllers.get(0) instanceof SecondaryUserController).isFalse();
}
use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by crdroidandroid.
the class DateTimeSettings method getPreferenceControllers.
@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
final Activity activity = getActivity();
final Intent intent = activity.getIntent();
final boolean isFromSUW = intent.getBooleanExtra(EXTRA_IS_FROM_SUW, false);
final AutoTimeZonePreferenceController autoTimeZonePreferenceController = new AutoTimeZonePreferenceController(activity, this, /* UpdateTimeAndDateCallback */
isFromSUW);
final AutoTimePreferenceController autoTimePreferenceController = new AutoTimePreferenceController(activity, this);
controllers.add(autoTimeZonePreferenceController);
controllers.add(autoTimePreferenceController);
controllers.add(new TimeFormatPreferenceController(activity, this, /* UpdateTimeAndDateCallback */
isFromSUW));
controllers.add(new TimeZonePreferenceController(activity, autoTimeZonePreferenceController));
controllers.add(new TimePreferenceController(activity, this, /* UpdateTimeAndDateCallback */
autoTimePreferenceController));
controllers.add(new DatePreferenceController(activity, this, /* UpdateTimeAndDateCallback */
autoTimePreferenceController));
return controllers;
}
use of com.android.settingslib.core.AbstractPreferenceController in project android_packages_apps_Settings by crdroidandroid.
the class ConfigureNotificationSettings method buildPreferenceControllers.
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
final BadgingNotificationPreferenceController badgeController = new BadgingNotificationPreferenceController(context);
final PulseNotificationPreferenceController pulseController = new PulseNotificationPreferenceController(context);
final LockScreenNotificationPreferenceController lockScreenNotificationController = new LockScreenNotificationPreferenceController(context, KEY_LOCKSCREEN, KEY_LOCKSCREEN_WORK_PROFILE_HEADER, KEY_LOCKSCREEN_WORK_PROFILE);
if (lifecycle != null) {
lifecycle.addObserver(pulseController);
lifecycle.addObserver(lockScreenNotificationController);
}
controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle, KEY_SWIPE_DOWN));
controllers.add(badgeController);
controllers.add(pulseController);
controllers.add(lockScreenNotificationController);
controllers.add(new NotificationRingtonePreferenceController(context) {
@Override
public String getPreferenceKey() {
return KEY_NOTI_DEFAULT_RINGTONE;
}
});
return controllers;
}
Aggregations