Merge "Shown toast when BT turned on"
This commit is contained in:
committed by
Android (Google) Code Review
commit
e68598380e
@@ -431,6 +431,8 @@
|
|||||||
<string name="connected_device_previously_connected_title">Previously connected devices</string>
|
<string name="connected_device_previously_connected_title">Previously connected devices</string>
|
||||||
<!-- Preference screen title for Bluetooth preference to open paired but no connection list [CHAR LIMIT=none]-->
|
<!-- Preference screen title for Bluetooth preference to open paired but no connection list [CHAR LIMIT=none]-->
|
||||||
<string name="connected_device_previously_connected_screen_title">Previously connected</string>
|
<string name="connected_device_previously_connected_screen_title">Previously connected</string>
|
||||||
|
<!-- Toast text for hint user bluetooth is turned on [CHAR LIMIT=none]-->
|
||||||
|
<string name="connected_device_bluetooth_turned_on_toast">Bluetooth turned on</string>
|
||||||
|
|
||||||
<!-- Date & time settings screen title -->
|
<!-- Date & time settings screen title -->
|
||||||
<string name="date_and_time">Date & time</string>
|
<string name="date_and_time">Date & time</string>
|
||||||
|
@@ -22,6 +22,7 @@ import android.bluetooth.BluetoothAdapter;
|
|||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.widget.Toast;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -166,6 +167,9 @@ public class BluetoothPairingDetail extends DeviceListPreferenceFragment impleme
|
|||||||
public void onBluetoothStateChanged(int bluetoothState) {
|
public void onBluetoothStateChanged(int bluetoothState) {
|
||||||
super.onBluetoothStateChanged(bluetoothState);
|
super.onBluetoothStateChanged(bluetoothState);
|
||||||
updateContent(bluetoothState);
|
updateContent(bluetoothState);
|
||||||
|
if (bluetoothState == BluetoothAdapter.STATE_ON) {
|
||||||
|
showBluetoothTurnedOnToast();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -205,4 +209,9 @@ public class BluetoothPairingDetail extends DeviceListPreferenceFragment impleme
|
|||||||
return KEY_AVAIL_DEVICES;
|
return KEY_AVAIL_DEVICES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void showBluetoothTurnedOnToast() {
|
||||||
|
Toast.makeText(getContext(), R.string.connected_device_bluetooth_turned_on_toast,
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -192,4 +192,13 @@ public class BluetoothPairingDetailTest {
|
|||||||
// Verify that clean up only happen once at initialization
|
// Verify that clean up only happen once at initialization
|
||||||
verify(mAvailableDevicesCategory, times(1)).removeAll();
|
verify(mAvailableDevicesCategory, times(1)).removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onBluetoothStateChanged_whenTurnedOnBTShowToast() {
|
||||||
|
doNothing().when(mFragment).updateContent(anyInt());
|
||||||
|
|
||||||
|
mFragment.onBluetoothStateChanged(BluetoothAdapter.STATE_ON);
|
||||||
|
|
||||||
|
verify(mFragment).showBluetoothTurnedOnToast();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user