66import android .app .Activity ;
77import android .bluetooth .BluetoothAdapter ;
88import android .bluetooth .BluetoothDevice ;
9- import android .bluetooth .BluetoothGatt ;
10- import android .bluetooth .BluetoothGattCallback ;
119import android .bluetooth .BluetoothManager ;
12- import android .bluetooth .le .BluetoothLeScanner ;
13- import android .bluetooth .le .ScanCallback ;
14- import android .bluetooth .le .ScanFilter ;
15- import android .bluetooth .le .ScanRecord ;
16- import android .bluetooth .le .ScanResult ;
17- import android .bluetooth .le .ScanSettings ;
1810import android .content .BroadcastReceiver ;
1911import android .content .Context ;
2012import android .content .Intent ;
2719import android .location .LocationManager ;
2820import android .os .Build ;
2921import android .os .Bundle ;
30- import android .os .Handler ;
31- import android .os .Looper ;
32- import android .os .Parcelable ;
3322import android .provider .Settings ;
3423import android .util .Log ;
3524import android .view .KeyEvent ;
6453import com .samsung .microbit .ui .PopUp ;
6554import com .samsung .microbit .ui .adapter .LEDAdapter ;
6655import com .samsung .microbit .utils .BLEConnectionHandler ;
67- import com .samsung .microbit .utils .ServiceUtils ;
6856import com .samsung .microbit .utils .Utils ;
6957import com .samsung .microbit .utils .BLEPair ;
7058
7462import java .util .Arrays ;
7563import java .util .List ;
7664import java .util .Set ;
77- import java .util .UUID ;
7865
7966import pl .droidsonroids .gif .GifImageView ;
8067
81- import static android .bluetooth .BluetoothAdapter .STATE_CONNECTED ;
82- import static android .bluetooth .BluetoothAdapter .STATE_DISCONNECTED ;
83- import static android .bluetooth .BluetoothAdapter .STATE_CONNECTING ;
84- import static android .bluetooth .BluetoothAdapter .STATE_DISCONNECTING ;
8568import static com .samsung .microbit .BuildConfig .DEBUG ;
8669
8770/**
@@ -140,7 +123,7 @@ private enum PAIRING_STATE {
140123 LinearLayout bottomPairButton ;
141124
142125 // Connected Device Status
143- Button deviceConnectionStatusBtn ;
126+ TextView deviceConnectionStatusTextView ;
144127
145128 private int currentOrientation ;
146129
@@ -676,7 +659,7 @@ private void setupFontStyle() {
676659 Typeface defaultTypeface = application .getTypeface ();
677660 Typeface robotoTypeface = application .getRobotoTypeface ();
678661
679- deviceConnectionStatusBtn .setTypeface (defaultTypeface );
662+ deviceConnectionStatusTextView .setTypeface (defaultTypeface );
680663
681664 // Connect Screen
682665 TextView appBarTitle = (TextView ) findViewById (R .id .flash_projects_title_txt );
@@ -750,7 +733,7 @@ private void setupFontStyle() {
750733 */
751734 private void initViews () {
752735 logi ("initViews" );
753- deviceConnectionStatusBtn = ( Button ) findViewById (R .id .connected_device_status_button );
736+ deviceConnectionStatusTextView = findViewById (R .id .connected_device_status );
754737 bottomPairButton = (LinearLayout ) findViewById (R .id .ll_pairing_activity_screen );
755738 pairButtonView = (LinearLayout ) findViewById (R .id .pairButtonView );
756739 pairTipView = (LinearLayout ) findViewById (R .id .pairTipView );
@@ -759,7 +742,6 @@ private void initViews() {
759742 pairSearchView = (LinearLayout ) findViewById (R .id .pairSearchView );
760743
761744 //Setup on click listeners.
762- deviceConnectionStatusBtn .setOnClickListener (this );
763745 findViewById (R .id .pairButton ).setOnClickListener (this );
764746
765747 findViewById (R .id .viewPairStep1AnotherWay ).setOnClickListener (this );
@@ -776,7 +758,7 @@ private void initViews() {
776758 }
777759
778760 private void releaseViews () {
779- deviceConnectionStatusBtn = null ;
761+ deviceConnectionStatusTextView = null ;
780762 bottomPairButton = null ;
781763 pairButtonView = null ;
782764 pairTipView = null ;
@@ -1045,33 +1027,6 @@ private Drawable getDrawableResource(int resID) {
10451027 return ContextCompat .getDrawable (this , resID );
10461028 }
10471029
1048- /**
1049- * Updates connection status UI according to current connection status.
1050- */
1051- private void updateConnectionStatus () {
1052- ConnectedDevice connectedDevice = BluetoothUtils .getPairedMicrobit (this );
1053- Drawable mDeviceDisconnectedImg ;
1054- Drawable mDeviceConnectedImg ;
1055-
1056- mDeviceDisconnectedImg = getDrawableResource (R .drawable .device_status_disconnected );
1057- mDeviceConnectedImg = getDrawableResource (R .drawable .device_status_connected );
1058-
1059- if (!connectedDevice .mStatus ) {
1060- // Device is not connected
1061- deviceConnectionStatusBtn .setBackgroundResource (R .drawable .grey_btn );
1062- deviceConnectionStatusBtn .setTextColor (Color .WHITE );
1063- deviceConnectionStatusBtn .setCompoundDrawablesWithIntrinsicBounds (null , null , mDeviceDisconnectedImg , null );
1064- deviceConnectionStatusBtn .setContentDescription ("Micro:bit not connected " + connectedDevice .mName + "is " + getStatusString (connectedDevice .mStatus ));
1065-
1066- } else {
1067- // Device is connected
1068- deviceConnectionStatusBtn .setBackgroundResource (R .drawable .white_btn_devices_status_connected );
1069- deviceConnectionStatusBtn .setTextColor (Color .BLACK );
1070- deviceConnectionStatusBtn .setCompoundDrawablesWithIntrinsicBounds (null , null , mDeviceConnectedImg , null );
1071- deviceConnectionStatusBtn .setContentDescription ("Currently connected Micro:bit " + connectedDevice .mName + "is " + getStatusString (connectedDevice .mStatus ));
1072- }
1073- }
1074-
10751030 /**
10761031 * Converts status state from boolean to its String representation.
10771032 *
@@ -1091,14 +1046,9 @@ private void updatePairedDeviceCard() {
10911046 ConnectedDevice connectedDevice = BluetoothUtils .getPairedMicrobit (this );
10921047 if (connectedDevice .mName == null ) {
10931048 // No device is Paired
1094- deviceConnectionStatusBtn .setBackgroundResource (R .drawable .grey_btn );
1095- deviceConnectionStatusBtn .setText ("-" );
1096- deviceConnectionStatusBtn .setCompoundDrawablesWithIntrinsicBounds (null , null , null , null );
1097- deviceConnectionStatusBtn .setOnClickListener (null );
1049+ deviceConnectionStatusTextView .setText ("-" );
10981050 } else {
1099- deviceConnectionStatusBtn .setText (connectedDevice .mName );
1100- updateConnectionStatus ();
1101- deviceConnectionStatusBtn .setOnClickListener (this );
1051+ deviceConnectionStatusTextView .setText (connectedDevice .mName );
11021052 }
11031053 logi ("updatePairedDeviceCard End" );
11041054 }
@@ -1469,18 +1419,6 @@ public void onClick(final View v) {
14691419 onFinish ( RESULT_CANCELED );
14701420 break ;
14711421
1472- case R .id .connected_device_status_button :
1473- logi ("onClick() :: connectBtn" );
1474- Toast .makeText (MBApp .getApp (), getString (R .string .no_longer_required_to_connect ), Toast .LENGTH_LONG ).show ();
1475-
1476- // if(!BluetoothChecker.getInstance().isBluetoothON()) {
1477- // setActivityState(PairingActivityState.STATE_ENABLE_BT_FOR_CONNECT);
1478- // enableBluetooth();
1479- // return;
1480- // }
1481- // toggleConnection();
1482- break ;
1483-
14841422 //TODO: there is no ability to delete paired device on Connect screen, so add or remove the case.
14851423 // Delete Microbit
14861424 case R .id .deleteBtn :
@@ -1669,7 +1607,7 @@ protected void onDestroy() {
16691607
16701608 releaseViews ();
16711609
1672- Utils .unbindDrawables (findViewById (R .id .connected_device_status_button ));
1610+ Utils .unbindDrawables (findViewById (R .id .connected_device_status ));
16731611 Utils .unbindDrawables (findViewById (R .id .pairButtonView ));
16741612
16751613 Utils .unbindDrawables (findViewById (R .id .pairTipView ));
0 commit comments