Skip to content

Commit

Permalink
Pairing status connection icon and toast
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-grace committed May 2, 2024
1 parent eaea9ad commit 8a917f0
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ private void initViews() {
pairSearchView = (LinearLayout) findViewById(R.id.pairSearchView);

//Setup on click listeners.
deviceConnectionStatusBtn.setOnClickListener(this);
findViewById(R.id.pairButton).setOnClickListener(this);

findViewById(R.id.viewPairStep1AnotherWay).setOnClickListener(this);
Expand Down Expand Up @@ -1050,24 +1049,17 @@ private Drawable getDrawableResource(int resID) {
*/
private void updateConnectionStatus() {
ConnectedDevice connectedDevice = BluetoothUtils.getPairedMicrobit(this);
Drawable mDeviceDisconnectedImg;
Drawable mDeviceConnectedImg;

mDeviceDisconnectedImg = getDrawableResource(R.drawable.device_status_disconnected);
mDeviceConnectedImg = getDrawableResource(R.drawable.device_status_connected);

if(!connectedDevice.mStatus) {
// Device is not connected
deviceConnectionStatusBtn.setBackgroundResource(R.drawable.grey_btn);
deviceConnectionStatusBtn.setTextColor(Color.WHITE);
deviceConnectionStatusBtn.setCompoundDrawablesWithIntrinsicBounds(null, null, mDeviceDisconnectedImg, null);
deviceConnectionStatusBtn.setContentDescription("Micro:bit not connected " + connectedDevice.mName + "is " + getStatusString(connectedDevice.mStatus));

} else {
// Device is connected
deviceConnectionStatusBtn.setBackgroundResource(R.drawable.white_btn_devices_status_connected);
deviceConnectionStatusBtn.setTextColor(Color.BLACK);
deviceConnectionStatusBtn.setCompoundDrawablesWithIntrinsicBounds(null, null, mDeviceConnectedImg, null);
deviceConnectionStatusBtn.setContentDescription("Currently connected Micro:bit " + connectedDevice.mName + "is " + getStatusString(connectedDevice.mStatus));
}
}
Expand All @@ -1093,12 +1085,9 @@ private void updatePairedDeviceCard() {
// No device is Paired
deviceConnectionStatusBtn.setBackgroundResource(R.drawable.grey_btn);
deviceConnectionStatusBtn.setText("-");
deviceConnectionStatusBtn.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
deviceConnectionStatusBtn.setOnClickListener(null);
} else {
deviceConnectionStatusBtn.setText(connectedDevice.mName);
updateConnectionStatus();
deviceConnectionStatusBtn.setOnClickListener(this);
}
logi("updatePairedDeviceCard End");
}
Expand Down Expand Up @@ -1469,18 +1458,6 @@ public void onClick(final View v) {
onFinish( RESULT_CANCELED);
break;

case R.id.connected_device_status_button:
logi("onClick() :: connectBtn");
Toast.makeText(MBApp.getApp(), getString(R.string.no_longer_required_to_connect), Toast.LENGTH_LONG).show();

// if(!BluetoothChecker.getInstance().isBluetoothON()) {
// setActivityState(PairingActivityState.STATE_ENABLE_BT_FOR_CONNECT);
// enableBluetooth();
// return;
// }
// toggleConnection();
break;

//TODO: there is no ability to delete paired device on Connect screen, so add or remove the case.
// Delete Microbit
case R.id.deleteBtn:
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/pairing_device_state.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
android:id="@+id/connected_device_status_button"
style="@style/pairing_device_state_button_style"
android:background="@drawable/grey_btn"
android:contentDescription="@null"
android:drawableRight="@drawable/device_status_disconnected" />
android:contentDescription="@null" />
</LinearLayout>
1 change: 0 additions & 1 deletion app/src/main/res/layout/projects_app_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:nextFocusDown="@+id/connectedIndicatorIcon"
android:text="@string/flash"
android:textSize="@dimen/app_bar_title_text_size"
android:textColor="@android:color/white" />
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@
<string name="v1_button_label">V1</string>
<string name="v2_button_label">V2</string>

<string name="no_longer_required_to_connect">It is no longer necessary to connect to your micro:bit before flashing</string>
<string name="desc_edit_project_btn">Edit project</string>
<string name="edit">Edit</string>

Expand Down

0 comments on commit 8a917f0

Please sign in to comment.