Search in sources :

Example 51 with AbstractPreferenceController

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;
    }
}
Also used : Context(android.content.Context) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Indexable(com.android.settings.search.Indexable) Fragment(android.app.Fragment)

Example 52 with AbstractPreferenceController

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;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) ArrayList(java.util.ArrayList) AssistGestureSettingsPreferenceController(com.android.settings.gestures.AssistGestureSettingsPreferenceController)

Example 53 with AbstractPreferenceController

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();
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo) Test(org.junit.Test)

Example 54 with AbstractPreferenceController

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;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) AutoTimeZonePreferenceController(com.android.settings.datetime.AutoTimeZonePreferenceController) TimePreferenceController(com.android.settings.datetime.TimePreferenceController) AutoTimePreferenceController(com.android.settings.datetime.AutoTimePreferenceController) TimeZonePreferenceController(com.android.settings.datetime.TimeZonePreferenceController) AutoTimeZonePreferenceController(com.android.settings.datetime.AutoTimeZonePreferenceController) TimeFormatPreferenceController(com.android.settings.datetime.TimeFormatPreferenceController) DatePreferenceController(com.android.settings.datetime.DatePreferenceController) ArrayList(java.util.ArrayList) Activity(android.app.Activity) AutoTimePreferenceController(com.android.settings.datetime.AutoTimePreferenceController) Intent(android.content.Intent)

Example 55 with AbstractPreferenceController

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;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) SwipeToNotificationPreferenceController(com.android.settings.gestures.SwipeToNotificationPreferenceController) ArrayList(java.util.ArrayList)

Aggregations

AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)298 ArrayList (java.util.ArrayList)211 Test (org.junit.Test)75 Context (android.content.Context)29 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)29 UserInfo (android.content.pm.UserInfo)28 SettingsActivity (com.android.settings.SettingsActivity)15 StorageManager (android.os.storage.StorageManager)14 StorageItemPreferenceController (com.android.settings.deviceinfo.storage.StorageItemPreferenceController)14 StorageManagerVolumeProvider (com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)14 PreferenceScreen (android.support.v7.preference.PreferenceScreen)12 AdditionalSystemUpdatePreferenceController (com.android.settings.deviceinfo.AdditionalSystemUpdatePreferenceController)12 TimeoutPreferenceController (com.android.settings.display.TimeoutPreferenceController)10 Activity (android.app.Activity)9 AmbientDisplayConfiguration (com.android.internal.hardware.AmbientDisplayConfiguration)9 AmbientDisplayPreferenceController (com.android.settings.display.AmbientDisplayPreferenceController)9 AutoBrightnessPreferenceController (com.android.settings.display.AutoBrightnessPreferenceController)9 Config (org.robolectric.annotation.Config)7 Bundle (android.os.Bundle)6 SecondaryUserController (com.android.settings.deviceinfo.storage.SecondaryUserController)6