use of com.android.settingslib.core.lifecycle.Lifecycle in project android_packages_apps_Settings by SudaMod.
the class LockscreenDashboardFragment method getPreferenceControllers.
@Override
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
final Lifecycle lifecycle = getLifecycle();
final LockScreenNotificationPreferenceController notificationController = new LockScreenNotificationPreferenceController(context, KEY_LOCK_SCREEN_NOTIFICATON, KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE_HEADER, KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE);
lifecycle.addObserver(notificationController);
controllers.add(notificationController);
final AddUserWhenLockedPreferenceController addUserWhenLockedController = new AddUserWhenLockedPreferenceController(context);
lifecycle.addObserver(addUserWhenLockedController);
controllers.add(addUserWhenLockedController);
mOwnerInfoPreferenceController = new OwnerInfoPreferenceController(context, this, lifecycle);
controllers.add(mOwnerInfoPreferenceController);
return controllers;
}
use of com.android.settingslib.core.lifecycle.Lifecycle in project android_packages_apps_Settings by DirtyUnicorns.
the class AutoRotatePreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
mContentResolver = RuntimeEnvironment.application.getContentResolver();
mLifecycle = new Lifecycle();
mPreference = new SwitchPreference(RuntimeEnvironment.application);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mContext.getContentResolver()).thenReturn(mContentResolver);
mController = new AutoRotatePreferenceController(mContext, mLifecycle);
}
use of com.android.settingslib.core.lifecycle.Lifecycle in project android_packages_apps_Settings by DirtyUnicorns.
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;
}
use of com.android.settingslib.core.lifecycle.Lifecycle in project android_packages_apps_Settings by DirtyUnicorns.
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);
}
use of com.android.settingslib.core.lifecycle.Lifecycle in project android_packages_apps_Settings by DirtyUnicorns.
the class ManageApplicationsTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mAppReset = new RoboMenuItem(R.id.reset_app_preferences);
ReflectionHelpers.setStaticField(ApplicationsState.class, "sInstance", mState);
when(mState.newSession(any())).thenReturn(mSession);
mBgLooper = Looper.myLooper();
when(mState.getBackgroundLooper()).thenReturn(mBgLooper);
mFragment = new ManageApplications();
ReflectionHelpers.setField(mFragment, "mLifecycle", new Lifecycle());
}
Aggregations