Search in sources :

Example 91 with Lifecycle

use of com.android.settingslib.core.lifecycle.Lifecycle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AppInfoDashboardFragment method createPreferenceControllers.

@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
    retrieveAppEntry();
    if (mPackageInfo == null) {
        return null;
    }
    final String packageName = getPackageName();
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    final Lifecycle lifecycle = getSettingsLifecycle();
    // The following are controllers for preferences that needs to refresh the preference state
    // when app state changes.
    controllers.add(new AppHeaderViewPreferenceController(context, this, packageName, lifecycle));
    for (AbstractPreferenceController controller : controllers) {
        mCallbacks.add((Callback) controller);
    }
    // The following are controllers for preferences that don't need to refresh the preference
    // state when app state changes.
    mInstantAppButtonPreferenceController = new InstantAppButtonsPreferenceController(context, this, packageName, lifecycle);
    controllers.add(mInstantAppButtonPreferenceController);
    mAppButtonsPreferenceController = new AppButtonsPreferenceController((SettingsActivity) getActivity(), this, lifecycle, packageName, mState, REQUEST_UNINSTALL, REQUEST_REMOVE_DEVICE_ADMIN);
    controllers.add(mAppButtonsPreferenceController);
    controllers.add(new AppBatteryPreferenceController(context, this, packageName, lifecycle));
    controllers.add(new AppMemoryPreferenceController(context, this, lifecycle));
    controllers.add(new DefaultHomeShortcutPreferenceController(context, packageName));
    controllers.add(new DefaultBrowserShortcutPreferenceController(context, packageName));
    controllers.add(new DefaultPhoneShortcutPreferenceController(context, packageName));
    controllers.add(new DefaultEmergencyShortcutPreferenceController(context, packageName));
    controllers.add(new DefaultSmsShortcutPreferenceController(context, packageName));
    return controllers;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) ArrayList(java.util.ArrayList) SettingsActivity(com.android.settings.SettingsActivity)

Example 92 with Lifecycle

use of com.android.settingslib.core.lifecycle.Lifecycle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LockStyleSettings method createPreferenceControllers.

@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    final Lifecycle lifecycle = getSettingsLifecycle();
    mOwnerInfoPreferenceController = new OwnerInfoPreferenceController(context, this, lifecycle);
    controllers.add(mOwnerInfoPreferenceController);
    return controllers;
}
Also used : AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) OwnerInfoPreferenceController(com.android.settings.security.OwnerInfoPreferenceController) ArrayList(java.util.ArrayList)

Example 93 with Lifecycle

use of com.android.settingslib.core.lifecycle.Lifecycle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothDashboardFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    SettingsActivity activity = (SettingsActivity) getActivity();
    mSwitchBar = activity.getSwitchBar();
    mController = new BluetoothSwitchPreferenceController(activity, new SwitchBarController(mSwitchBar), mFooterPreference);
    Lifecycle lifecycle = getSettingsLifecycle();
    if (lifecycle != null) {
        lifecycle.addObserver(mController);
    }
}
Also used : BluetoothSwitchPreferenceController(com.android.settings.bluetooth.BluetoothSwitchPreferenceController) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) SettingsActivity(com.android.settings.SettingsActivity) SwitchBarController(com.android.settings.widget.SwitchBarController)

Example 94 with Lifecycle

use of com.android.settingslib.core.lifecycle.Lifecycle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DashboardFragment method onAttach.

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    mSuppressInjectedTileKeys = Arrays.asList(context.getResources().getStringArray(R.array.config_suppress_injected_tile_keys));
    mDashboardFeatureProvider = FeatureFactory.getFactory(context).getDashboardFeatureProvider(context);
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    // Load preference controllers from code
    final List<AbstractPreferenceController> controllersFromCode = createPreferenceControllers(context);
    // Load preference controllers from xml definition
    final List<BasePreferenceController> controllersFromXml = PreferenceControllerListHelper.getPreferenceControllersFromXml(context, getPreferenceScreenResId());
    // Filter xml-based controllers in case a similar controller is created from code already.
    final List<BasePreferenceController> uniqueControllerFromXml = PreferenceControllerListHelper.filterControllers(controllersFromXml, controllersFromCode);
    // Add unique controllers to list.
    if (controllersFromCode != null) {
        controllers.addAll(controllersFromCode);
    }
    controllers.addAll(uniqueControllerFromXml);
    // And wire up with lifecycle.
    final Lifecycle lifecycle = getSettingsLifecycle();
    uniqueControllerFromXml.stream().filter(controller -> controller instanceof LifecycleObserver).forEach(controller -> lifecycle.addObserver((LifecycleObserver) controller));
    mPlaceholderPreferenceController = new DashboardTilePlaceholderPreferenceController(context);
    controllers.add(mPlaceholderPreferenceController);
    for (AbstractPreferenceController controller : controllers) {
        addPreferenceController(controller);
    }
    checkUiBlocker(controllers);
}
Also used : PreferenceGroup(androidx.preference.PreferenceGroup) SettingsPreferenceFragment(com.android.settings.SettingsPreferenceFragment) Context(android.content.Context) Arrays(java.util.Arrays) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Indexable(com.android.settings.search.Indexable) SettingsBaseActivity(com.android.settings.core.SettingsBaseActivity) Map(java.util.Map) BasePreferenceController(com.android.settings.core.BasePreferenceController) ArraySet(android.util.ArraySet) Log(android.util.Log) ArrayMap(android.util.ArrayMap) R(com.android.settings.R) PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceControllerListHelper(com.android.settings.core.PreferenceControllerListHelper) Collection(java.util.Collection) LifecycleObserver(com.android.settingslib.core.lifecycle.LifecycleObserver) Set(java.util.Set) SettingsEnums(android.app.settings.SettingsEnums) TextUtils(android.text.TextUtils) FeatureFactory(com.android.settings.overlay.FeatureFactory) CallSuper(androidx.annotation.CallSuper) Preference(androidx.preference.Preference) List(java.util.List) DashboardCategory(com.android.settingslib.drawer.DashboardCategory) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Tile(com.android.settingslib.drawer.Tile) PreferenceManager(androidx.preference.PreferenceManager) Activity(android.app.Activity) VisibleForTesting(androidx.annotation.VisibleForTesting) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) BasePreferenceController(com.android.settings.core.BasePreferenceController) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) ArrayList(java.util.ArrayList) LifecycleObserver(com.android.settingslib.core.lifecycle.LifecycleObserver)

Example 95 with Lifecycle

use of com.android.settingslib.core.lifecycle.Lifecycle in project android_packages_apps_Settings by omnirom.

the class BluetoothQualityDialogPreferenceControllerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mBluetoothA2dpConfigStore = spy(new BluetoothA2dpConfigStore());
    mActiveDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
    mController = new BluetoothQualityDialogPreferenceController(mContext, mLifecycle, mBluetoothA2dpConfigStore);
    mPreference = new BluetoothQualityDialogPreference(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    mController.displayPreference(mScreen);
    mCodecConfigAAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, BluetoothCodecConfig.SAMPLE_RATE_48000 | BluetoothCodecConfig.SAMPLE_RATE_88200, BluetoothCodecConfig.BITS_PER_SAMPLE_NONE, BluetoothCodecConfig.CHANNEL_MODE_NONE, 0, 0, 0, 0);
    mCodecConfigLDAC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT, BluetoothCodecConfig.SAMPLE_RATE_96000, BluetoothCodecConfig.BITS_PER_SAMPLE_NONE, BluetoothCodecConfig.CHANNEL_MODE_NONE, 1001, 0, 0, 0);
    when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
}
Also used : BluetoothA2dpConfigStore(com.android.settings.development.BluetoothA2dpConfigStore) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) BluetoothCodecConfig(android.bluetooth.BluetoothCodecConfig) Before(org.junit.Before)

Aggregations

Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)259 Before (org.junit.Before)218 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)33 ArrayList (java.util.ArrayList)32 PreferenceManager (androidx.preference.PreferenceManager)16 Preference (androidx.preference.Preference)15 TextView (android.widget.TextView)11 SettingsActivity (com.android.settings.SettingsActivity)10 Handler (android.os.Handler)9 LinkProperties (android.net.LinkProperties)8 Network (android.net.Network)8 NetworkRequest (android.net.NetworkRequest)8 LockScreenNotificationPreferenceController (com.android.settings.notification.LockScreenNotificationPreferenceController)8 BluetoothManager (android.bluetooth.BluetoothManager)7 Intent (android.content.Intent)7 PreferenceCategory (androidx.preference.PreferenceCategory)7 SwitchBar (com.android.settings.widget.SwitchBar)7 BluetoothCodecConfig (android.bluetooth.BluetoothCodecConfig)6 Bundle (android.os.Bundle)6 RecyclerView (android.support.v7.widget.RecyclerView)6