Skip to content

Commit

Permalink
Merge pull request #1035 from PhenoApps/printer_connection_improvements
Browse files Browse the repository at this point in the history
Skip blank names in bluetooth device chooser
  • Loading branch information
trife authored Sep 8, 2024
2 parents 3d36017 + cec624e commit 59833a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,19 @@ public void onNothingSelected(AdapterView<?> arg0) {

}
connectPrinter.setOnClickListener(view -> {

mBluetoothUtil.choose(getContext(), new BluetoothChooseCallback() {
@Override
public void onDeviceChosen(String newDeviceName) {
saveDeviceNamePreference(newDeviceName);
}
});

if (checkPermissions(mActivity)) {
mBluetoothUtil.choose(getContext(), new BluetoothChooseCallback() {
@Override
public void onDeviceChosen(String newDeviceName) {
saveDeviceNamePreference(newDeviceName);
}
});
} else {
Toast.makeText(getContext(), R.string.permission_ask_bluetooth, Toast.LENGTH_SHORT).show();
}
});

/*
/*j
* This section handles print events. TODO: Create a label prototype based class. Move most of this logic to a function/class. chaneylc 8/26/2020
* More info on prototyping: https://refactoring.guru/design-patterns/prototype
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ class BluetoothUtil {

val input = RadioGroup(ctx)

pairedDevices.forEachIndexed { _, t ->
val button = RadioButton(ctx)
button.text = t.name
input.addView(button)
map[button.id] = t
pairedDevices.forEach { device ->
val deviceName = device.name
if (!deviceName.isNullOrBlank()) {
val button = RadioButton(ctx)
button.text = deviceName
input.addView(button)
map[button.id] = device
}
}

val builder = AlertDialog.Builder(ctx, R.style.AppAlertDialog).apply {
Expand Down

0 comments on commit 59833a2

Please sign in to comment.