Update bluetooth preference to take user to new screen
This CL removes the toggle from the bluetooth preference and instead takes users to a new dedicated screen for toggling bluetooth status. On this screen we show a different summary text depending on whether bluetooth and bluetooth scanning are on/off. Also, we were able to delegate most of the UI/bluetooth handling to already existing classes. Test: robotests Bug: 77543471 Merged-In: I036a3992bbd78896da8364b55ecc51afc4464b6e Change-Id: I036a3992bbd78896da8364b55ecc51afc4464b6e
This commit is contained in:
@@ -37,9 +37,11 @@ import android.view.View;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.bluetooth.BluetoothSwitchPreferenceController.SwitchController;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settings.widget.SwitchBarController;
|
||||
import com.android.settings.widget.SwitchWidgetController;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
|
||||
@@ -77,9 +79,11 @@ public class BluetoothEnablerTest {
|
||||
private LocalBluetoothManager mBluetoothManager;
|
||||
@Mock
|
||||
private LocalBluetoothAdapter mBluetoothAdapter;
|
||||
@Mock
|
||||
private SwitchWidgetController.OnSwitchChangeListener mCallback;
|
||||
|
||||
private Context mContext;
|
||||
private SwitchController mSwitchController;
|
||||
private SwitchWidgetController mSwitchController;
|
||||
private BluetoothEnabler mBluetoothEnabler;
|
||||
|
||||
@Before
|
||||
@@ -89,7 +93,7 @@ public class BluetoothEnablerTest {
|
||||
when(mBluetoothManager.getBluetoothAdapter()).thenReturn(mBluetoothAdapter);
|
||||
|
||||
mRestrictedSwitchPreference = new RestrictedSwitchPreference(mContext);
|
||||
mSwitchController = spy(new SwitchController(mRestrictedSwitchPreference));
|
||||
mSwitchController = spy(new SwitchBarController(new SwitchBar(mContext)));
|
||||
mBluetoothEnabler = new BluetoothEnabler(
|
||||
mContext,
|
||||
mSwitchController,
|
||||
@@ -99,6 +103,7 @@ public class BluetoothEnablerTest {
|
||||
mRestrictionUtils);
|
||||
mHolder = PreferenceViewHolder.createInstanceForTests(mock(View.class));
|
||||
mRestrictedSwitchPreference.onBindViewHolder(mHolder);
|
||||
mBluetoothEnabler.setToggleCallback(mCallback);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,6 +115,15 @@ public class BluetoothEnablerTest {
|
||||
verify(mMetricsFeatureProvider).action(mContext, 123, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSwitchToggled_shouldTriggerCallback() {
|
||||
// WHEN the switch is toggled...
|
||||
mBluetoothEnabler.onSwitchToggled(false);
|
||||
|
||||
// THEN the callback is triggered
|
||||
verify(mCallback).onSwitchToggled(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maybeEnforceRestrictions_noRestrictions() {
|
||||
// GIVEN there are no restrictions set...
|
||||
|
Reference in New Issue
Block a user