Skip to content

Commit f7c8ea3

Browse files
committed
Pairing/Projects - disable connection
1 parent ce52abb commit f7c8ea3

File tree

2 files changed

+78
-76
lines changed

2 files changed

+78
-76
lines changed

app/src/main/java/com/samsung/microbit/ui/activity/PairingActivity.java

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -790,9 +790,10 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
790790
case RESULT_OK:
791791
if (activityState == PairingActivityState.STATE_ENABLE_BT_FOR_PAIRING) {
792792
proceedAfterBlePermissionGranted();
793-
} else if (activityState == PairingActivityState.STATE_ENABLE_BT_FOR_CONNECT) {
794-
toggleConnection();
795793
}
794+
// else if (activityState == PairingActivityState.STATE_ENABLE_BT_FOR_CONNECT) {
795+
// toggleConnection();
796+
// }
796797
break;
797798
case RESULT_CANCELED:
798799
//Change state back to Idle
@@ -1139,37 +1140,37 @@ public void startWithPairing() {
11391140
/**
11401141
* Enables or disables connection with a currently paired micro:bit board.
11411142
*/
1142-
public void toggleConnection() {
1143-
ConnectedDevice currentDevice = BluetoothUtils.getPairedMicrobit(this);
1144-
Log.v(TAG, "currentDevice.toString()");
1145-
1146-
if(currentDevice.mAddress != null) {
1147-
boolean currentState = currentDevice.mStatus;
1148-
1149-
if(!currentState) {
1150-
setActivityState(PairingActivityState.STATE_CONNECTING);
1151-
requestPermissions.clear();
1152-
PopUp.show(getString(R.string.init_connection),
1153-
"",
1154-
R.drawable.message_face, R.drawable.blue_btn,
1155-
PopUp.GIFF_ANIMATION_NONE,
1156-
PopUp.TYPE_SPINNER,
1157-
null, null);
1158-
1159-
ServiceUtils.sendConnectDisconnectMessage(true);
1160-
} else {
1161-
setActivityState(PairingActivityState.STATE_DISCONNECTING);
1162-
PopUp.show(getString(R.string.disconnecting),
1163-
"",
1164-
R.drawable.message_face, R.drawable.blue_btn,
1165-
PopUp.GIFF_ANIMATION_NONE,
1166-
PopUp.TYPE_SPINNER,
1167-
null, null);
1168-
1169-
ServiceUtils.sendConnectDisconnectMessage(false);
1170-
}
1171-
}
1172-
}
1143+
// private void toggleConnection() {
1144+
// ConnectedDevice currentDevice = BluetoothUtils.getPairedMicrobit(this);
1145+
// Log.v(TAG, "currentDevice.toString()");
1146+
//
1147+
// if(currentDevice.mAddress != null) {
1148+
// boolean currentState = currentDevice.mStatus;
1149+
//
1150+
// if(!currentState) {
1151+
// setActivityState(PairingActivityState.STATE_CONNECTING);
1152+
// requestPermissions.clear();
1153+
// PopUp.show(getString(R.string.init_connection),
1154+
// "",
1155+
// R.drawable.message_face, R.drawable.blue_btn,
1156+
// PopUp.GIFF_ANIMATION_NONE,
1157+
// PopUp.TYPE_SPINNER,
1158+
// null, null);
1159+
//
1160+
// ServiceUtils.sendConnectDisconnectMessage(true);
1161+
// } else {
1162+
// setActivityState(PairingActivityState.STATE_DISCONNECTING);
1163+
// PopUp.show(getString(R.string.disconnecting),
1164+
// "",
1165+
// R.drawable.message_face, R.drawable.blue_btn,
1166+
// PopUp.GIFF_ANIMATION_NONE,
1167+
// PopUp.TYPE_SPINNER,
1168+
// null, null);
1169+
//
1170+
// ServiceUtils.sendConnectDisconnectMessage(false);
1171+
// }
1172+
// }
1173+
// }
11731174

11741175
@Override
11751176
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
@@ -1326,12 +1327,12 @@ public void onClick(final View v) {
13261327
logi("onClick() :: connectBtn");
13271328
Toast.makeText(MBApp.getApp(), getString(R.string.no_longer_required_to_connect), Toast.LENGTH_LONG).show();
13281329

1329-
if(!BluetoothChecker.getInstance().isBluetoothON()) {
1330-
setActivityState(PairingActivityState.STATE_ENABLE_BT_FOR_CONNECT);
1331-
enableBluetooth();
1332-
return;
1333-
}
1334-
toggleConnection();
1330+
// if(!BluetoothChecker.getInstance().isBluetoothON()) {
1331+
// setActivityState(PairingActivityState.STATE_ENABLE_BT_FOR_CONNECT);
1332+
// enableBluetooth();
1333+
// return;
1334+
// }
1335+
// toggleConnection();
13351336
break;
13361337

13371338
//TODO: there is no ability to delete paired device on Connect screen, so add or remove the case.

app/src/main/java/com/samsung/microbit/ui/activity/ProjectActivity.java

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -911,10 +911,11 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
911911
if (resultCode == Activity.RESULT_OK) {
912912
if (flash) {
913913
proceedAfterBlePermissionGrantedAndBleEnabled();
914-
} else if (connect) {
915-
setActivityState(FlashActivityState.STATE_IDLE);
916-
toggleConnection();
917914
}
915+
// else if (connect) {
916+
// setActivityState(FlashActivityState.STATE_IDLE);
917+
// toggleConnection();
918+
// }
918919
}
919920
else if (resultCode == Activity.RESULT_CANCELED) {
920921
setActivityState(FlashActivityState.STATE_IDLE);
@@ -1061,32 +1062,32 @@ public void onClick(View v) {
10611062
/**
10621063
* Allows to enable or disable connection to a micro:bit board.
10631064
*/
1064-
private void toggleConnection() {
1065-
ConnectedDevice connectedDevice = BluetoothUtils.getPairedMicrobit(this);
1066-
if(connectedDevice.mPattern != null) {
1067-
if(connectedDevice.mStatus) {
1068-
setActivityState(FlashActivityState.STATE_DISCONNECTING);
1069-
PopUp.show(getString(R.string.disconnecting),
1070-
"",
1071-
R.drawable.flash_face, R.drawable.blue_btn,
1072-
PopUp.GIFF_ANIMATION_NONE,
1073-
PopUp.TYPE_SPINNER,
1074-
null, null);
1075-
ServiceUtils.sendConnectDisconnectMessage(false);
1076-
} else {
1077-
mRequestPermissions.clear();
1078-
setActivityState(FlashActivityState.STATE_CONNECTING);
1079-
PopUp.show(getString(R.string.init_connection),
1080-
"",
1081-
R.drawable.flash_face, R.drawable.blue_btn,
1082-
PopUp.GIFF_ANIMATION_NONE,
1083-
PopUp.TYPE_SPINNER,
1084-
null, null);
1085-
1086-
ServiceUtils.sendConnectDisconnectMessage(true);
1087-
}
1088-
}
1089-
}
1065+
// private void toggleConnection() {
1066+
// ConnectedDevice connectedDevice = BluetoothUtils.getPairedMicrobit(this);
1067+
// if(connectedDevice.mPattern != null) {
1068+
// if(connectedDevice.mStatus) {
1069+
// setActivityState(FlashActivityState.STATE_DISCONNECTING);
1070+
// PopUp.show(getString(R.string.disconnecting),
1071+
// "",
1072+
// R.drawable.flash_face, R.drawable.blue_btn,
1073+
// PopUp.GIFF_ANIMATION_NONE,
1074+
// PopUp.TYPE_SPINNER,
1075+
// null, null);
1076+
// ServiceUtils.sendConnectDisconnectMessage(false);
1077+
// } else {
1078+
// mRequestPermissions.clear();
1079+
// setActivityState(FlashActivityState.STATE_CONNECTING);
1080+
// PopUp.show(getString(R.string.init_connection),
1081+
// "",
1082+
// R.drawable.flash_face, R.drawable.blue_btn,
1083+
// PopUp.GIFF_ANIMATION_NONE,
1084+
// PopUp.TYPE_SPINNER,
1085+
// null, null);
1086+
//
1087+
// ServiceUtils.sendConnectDisconnectMessage(true);
1088+
// }
1089+
// }
1090+
// }
10901091

10911092
/**
10921093
* Sends a project to flash on a micro:bit board. If bluetooth is off then turn it on.
@@ -1878,14 +1879,14 @@ public void onClick(View v) {
18781879
};
18791880

18801881

1881-
View.OnClickListener reconnectHandler = new View.OnClickListener() {
1882-
@Override
1883-
public void onClick(View v) {
1884-
logi("reconnectOkHandler");
1885-
PopUp.hide();
1886-
toggleConnection();
1887-
}
1888-
};
1882+
// View.OnClickListener reconnectHandler = new View.OnClickListener() {
1883+
// @Override
1884+
// public void onClick(View v) {
1885+
// logi("reconnectOkHandler");
1886+
// PopUp.hide();
1887+
// toggleConnection();
1888+
// }
1889+
// };
18891890

18901891
/**
18911892
* Represents a broadcast receiver that allows to handle states of

0 commit comments

Comments
 (0)