Search in sources :

Example 1 with MasterSwitchController

use of com.android.settings.widget.MasterSwitchController in project android_packages_apps_Settings by crdroidandroid.

the class BluetoothEnablerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    when(mBluetoothManager.getBluetoothAdapter()).thenReturn(mBluetoothAdapter);
    mSwitch = new Switch(mContext);
    mMasterSwitchPreference = new MasterSwitchPreference(mContext);
    mMasterSwitchController = spy(new MasterSwitchController(mMasterSwitchPreference));
    mBluetoothEnabler = new BluetoothEnabler(mContext, mMasterSwitchController, mMetricsFeatureProvider, mBluetoothManager, 123, mRestrictionUtils);
    PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(mock(View.class));
    when(holder.findViewById(R.id.switchWidget)).thenReturn(mSwitch);
    mMasterSwitchPreference.onBindViewHolder(holder);
}
Also used : MasterSwitchPreference(com.android.settings.widget.MasterSwitchPreference) Switch(android.widget.Switch) MasterSwitchController(com.android.settings.widget.MasterSwitchController) PreferenceViewHolder(android.support.v7.preference.PreferenceViewHolder) View(android.view.View) Before(org.junit.Before)

Example 2 with MasterSwitchController

use of com.android.settings.widget.MasterSwitchController in project android_packages_apps_Settings by SudaMod.

the class AutomaticStorageManagementSwitchPreferenceController method onResume.

@Override
public void onResume() {
    if (!isAvailable()) {
        return;
    }
    boolean isStorageManagerEnabled = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, 0) != 0;
    mSwitch.setChecked(isStorageManagerEnabled);
    if (mSwitch != null) {
        mSwitchController = new MasterSwitchController(mSwitch);
        mSwitchController.setListener(this);
        mSwitchController.startListening();
    }
}
Also used : MasterSwitchController(com.android.settings.widget.MasterSwitchController)

Example 3 with MasterSwitchController

use of com.android.settings.widget.MasterSwitchController in project android_packages_apps_Settings by SudaMod.

the class BluetoothEnablerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    when(mBluetoothManager.getBluetoothAdapter()).thenReturn(mBluetoothAdapter);
    mSwitch = new Switch(mContext);
    mMasterSwitchPreference = new MasterSwitchPreference(mContext);
    mMasterSwitchController = spy(new MasterSwitchController(mMasterSwitchPreference));
    mBluetoothEnabler = new BluetoothEnabler(mContext, mMasterSwitchController, mMetricsFeatureProvider, mBluetoothManager, 123, mRestrictionUtils);
    PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(mock(View.class));
    when(holder.findViewById(R.id.switchWidget)).thenReturn(mSwitch);
    mMasterSwitchPreference.onBindViewHolder(holder);
}
Also used : MasterSwitchPreference(com.android.settings.widget.MasterSwitchPreference) Switch(android.widget.Switch) MasterSwitchController(com.android.settings.widget.MasterSwitchController) PreferenceViewHolder(android.support.v7.preference.PreferenceViewHolder) View(android.view.View) Before(org.junit.Before)

Example 4 with MasterSwitchController

use of com.android.settings.widget.MasterSwitchController in project android_packages_apps_Settings by DirtyUnicorns.

the class BluetoothEnablerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    when(mBluetoothManager.getBluetoothAdapter()).thenReturn(mBluetoothAdapter);
    mSwitch = new Switch(mContext);
    mMasterSwitchPreference = new MasterSwitchPreference(mContext);
    mMasterSwitchController = spy(new MasterSwitchController(mMasterSwitchPreference));
    mBluetoothEnabler = new BluetoothEnabler(mContext, mMasterSwitchController, mMetricsFeatureProvider, mBluetoothManager, 123, mRestrictionUtils);
    PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(mock(View.class));
    when(holder.findViewById(R.id.switchWidget)).thenReturn(mSwitch);
    mMasterSwitchPreference.onBindViewHolder(holder);
}
Also used : MasterSwitchPreference(com.android.settings.widget.MasterSwitchPreference) Switch(android.widget.Switch) MasterSwitchController(com.android.settings.widget.MasterSwitchController) PreferenceViewHolder(android.support.v7.preference.PreferenceViewHolder) View(android.view.View) Before(org.junit.Before)

Example 5 with MasterSwitchController

use of com.android.settings.widget.MasterSwitchController in project platform_packages_apps_Settings by BlissRoms.

the class BluetoothEnablerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    when(mBluetoothManager.getBluetoothAdapter()).thenReturn(mBluetoothAdapter);
    mSwitch = new Switch(mContext);
    mMasterSwitchPreference = new MasterSwitchPreference(mContext);
    mMasterSwitchController = spy(new MasterSwitchController(mMasterSwitchPreference));
    mBluetoothEnabler = new BluetoothEnabler(mContext, mMasterSwitchController, mMetricsFeatureProvider, mBluetoothManager, 123, mRestrictionUtils);
    PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(mock(View.class));
    when(holder.findViewById(R.id.switchWidget)).thenReturn(mSwitch);
    mMasterSwitchPreference.onBindViewHolder(holder);
}
Also used : MasterSwitchPreference(com.android.settings.widget.MasterSwitchPreference) Switch(android.widget.Switch) MasterSwitchController(com.android.settings.widget.MasterSwitchController) PreferenceViewHolder(android.support.v7.preference.PreferenceViewHolder) View(android.view.View) Before(org.junit.Before)

Aggregations

MasterSwitchController (com.android.settings.widget.MasterSwitchController)11 PreferenceViewHolder (android.support.v7.preference.PreferenceViewHolder)5 View (android.view.View)5 Switch (android.widget.Switch)5 MasterSwitchPreference (com.android.settings.widget.MasterSwitchPreference)5 Before (org.junit.Before)5