Search in sources :

Example 21 with Lifecycle

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

the class ConnectedDeviceDashboardFragment method getPreferenceControllers.

@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
    final List<AbstractPreferenceController> controllers = new ArrayList<>();
    final Lifecycle lifecycle = getLifecycle();
    final NfcPreferenceController nfcPreferenceController = new NfcPreferenceController(context);
    lifecycle.addObserver(nfcPreferenceController);
    controllers.add(nfcPreferenceController);
    mUsbPrefController = new UsbModePreferenceController(context, new UsbBackend(context));
    lifecycle.addObserver(mUsbPrefController);
    controllers.add(mUsbPrefController);
    final BluetoothMasterSwitchPreferenceController bluetoothPreferenceController = new BluetoothMasterSwitchPreferenceController(context, Utils.getLocalBtManager(context), this, (SettingsActivity) getActivity());
    lifecycle.addObserver(bluetoothPreferenceController);
    controllers.add(bluetoothPreferenceController);
    SmsMirroringFeatureProvider smsMirroringFeatureProvider = FeatureFactory.getFactory(context).getSmsMirroringFeatureProvider();
    AbstractPreferenceController smsMirroringController = smsMirroringFeatureProvider.getController(context);
    controllers.add(smsMirroringController);
    return controllers;
}
Also used : BluetoothMasterSwitchPreferenceController(com.android.settings.bluetooth.BluetoothMasterSwitchPreferenceController) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) ArrayList(java.util.ArrayList) NfcPreferenceController(com.android.settings.nfc.NfcPreferenceController) UsbBackend(com.android.settings.deviceinfo.UsbBackend)

Example 22 with Lifecycle

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

the class AccountHeaderPreferenceControllerTest method onResume_shouldDisplayAccountInEntityHeader.

@Test
public void onResume_shouldDisplayAccountInEntityHeader() {
    final Lifecycle lifecycle = new Lifecycle();
    final Account account = new Account("name1@abc.com", "com.abc");
    Bundle args = new Bundle();
    args.putParcelable(AccountDetailDashboardFragment.KEY_ACCOUNT, account);
    args.putParcelable(AccountDetailDashboardFragment.KEY_USER_HANDLE, UserHandle.CURRENT);
    mController = new AccountHeaderPreferenceController(RuntimeEnvironment.application, lifecycle, mActivity, mFragment, args);
    assertThat(mController.isAvailable()).isTrue();
    when(mScreen.findPreference(anyString())).thenReturn(mHeaderPreference);
    mController.displayPreference(mScreen);
    lifecycle.onResume();
    final CharSequence label = ((TextView) mHeaderPreference.findViewById(R.id.entity_header_title)).getText();
    assertThat(label).isEqualTo(account.name);
}
Also used : Account(android.accounts.Account) Bundle(android.os.Bundle) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) TextView(android.widget.TextView) Test(org.junit.Test)

Example 23 with Lifecycle

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

the class LocationPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mLifecycle = new Lifecycle();
    mController = new LocationPreferenceController(mContext, mLifecycle);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
}
Also used : Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Before(org.junit.Before)

Example 24 with Lifecycle

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

the class VpnPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mConnectivityManager);
    when(mBinder.queryLocalInterface("android.net.IConnectivityManager")).thenReturn(mConnectivityManagerService);
    ShadowServiceManager.addService(Context.CONNECTIVITY_SERVICE, mBinder);
    when(mScreen.findPreference(anyString())).thenReturn(mPreference);
    mController = spy(new VpnPreferenceController(mContext));
    mLifecycle = new Lifecycle();
    mLifecycle.addObserver(mController);
}
Also used : Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Before(org.junit.Before)

Example 25 with Lifecycle

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

the class BatteryHeaderPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mLifecycle = new Lifecycle();
    mContext = spy(RuntimeEnvironment.application);
    mBatteryMeterView = new BatteryMeterView(mContext);
    mBatteryPercentText = new TextView(mContext);
    mSummary = new TextView(mContext);
    ShadowEntityHeaderController.setUseMock(mEntityHeaderController);
    mSummary2 = new TextView(mContext);
    mBatteryIntent = new Intent();
    mBatteryIntent.putExtra(BatteryManager.EXTRA_LEVEL, BATTERY_LEVEL);
    mBatteryIntent.putExtra(BatteryManager.EXTRA_SCALE, 100);
    mBatteryIntent.putExtra(BatteryManager.EXTRA_PLUGGED, 1);
    doReturn(mBatteryIntent).when(mContext).registerReceiver(any(), any());
    mBatteryLayoutPref = new LayoutPreference(mContext, R.layout.battery_header);
    doReturn(mBatteryLayoutPref).when(mPreferenceScreen).findPreference(BatteryHeaderPreferenceController.KEY_BATTERY_HEADER);
    mBatteryInfo.batteryLevel = BATTERY_LEVEL;
    mController = new BatteryHeaderPreferenceController(mContext, mActivity, mPreferenceFragment, mLifecycle);
    mController.mBatteryMeterView = mBatteryMeterView;
    mController.mBatteryPercentText = mBatteryPercentText;
    mController.mSummary1 = mSummary;
    mController.mSummary2 = mSummary2;
}
Also used : LayoutPreference(com.android.settings.applications.LayoutPreference) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) TextView(android.widget.TextView) Intent(android.content.Intent) 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