Skip to content

Commit

Permalink
Merge pull request #747 from PhenoApps/print_trait_improvements
Browse files Browse the repository at this point in the history
clean up logging
  • Loading branch information
trife authored Sep 25, 2023
2 parents 8698c22 + 5a3b3c5 commit 874588d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

public class LabelPrintTraitLayout extends BaseTraitLayout {

private static final String TAG = LabelPrintTraitLayout.class.getSimpleName();

static public String type = "zebra label print";

private String[] options;
Expand Down Expand Up @@ -219,7 +221,7 @@ public void loadLayout() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int pos, long arg3) {
Log.d(CollectActivity.TAG, labelsize.getSelectedItem().toString());
Log.d(TAG, labelsize.getSelectedItem().toString());

if (labelsize.getSelectedItem().toString().equals("3\" x 2\" detailed") || labelsize.getSelectedItem().toString().equals("2\" x 1\" detailed")) {
((View) textfield2.getParent()).setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -300,7 +302,6 @@ public void onNothingSelected(AdapterView<?> arg0) {
mBluetoothUtil.choose(getContext(), new BluetoothChooseCallback() {
@Override
public void onDeviceChosen(String newDeviceName) {
Log.d("LabelPrintTraitLayout", "Chosen printerName is " + newDeviceName);
saveDeviceNamePreference(newDeviceName);
}
});
Expand Down Expand Up @@ -432,12 +433,12 @@ public void onDeviceChosen(String newDeviceName) {
* A local broadcast receiver is used to communicate with the print thread within this utility class.
*/
String printerName = getPrefs().getString(GeneralKeys.LABEL_PRINT_DEVICE_NAME, null);
Log.d("LabelPrintTraitLayout", "retrieved printerName is " + printerName);
Log.d(TAG, "retrieved printerName is " + printerName);
if (printerName == null) {
mBluetoothUtil.choose(getContext(), new BluetoothChooseCallback() {
@Override
public void onDeviceChosen(String newDeviceName) {
Log.d("LabelPrintTraitLayout", "Chosen printerName is " + newDeviceName);
Log.d(TAG, "Chosen printerName is " + newDeviceName);
saveDeviceNamePreference(newDeviceName);
mBluetoothUtil.print(getContext(), newDeviceName, size, labels);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import android.widget.RadioButton
import android.widget.RadioGroup
import androidx.appcompat.app.AlertDialog
import com.fieldbook.tracker.R
import com.fieldbook.tracker.preferences.GeneralKeys

interface BluetoothChooseCallback {
fun onDeviceChosen(deviceName: String)
}
//Bluetooth Utility class for printing ZPL code and choosing bluetooth devices to print from.
class BluetoothUtil {

private val TAG = BluetoothUtil::class.simpleName

private val mBluetoothAdapter: BluetoothAdapter? by lazy {
BluetoothAdapter.getDefaultAdapter()
}
Expand Down Expand Up @@ -55,9 +56,8 @@ class BluetoothUtil {

if (input.checkedRadioButtonId == -1) return@setPositiveButton
else {
Log.d("BluetoothUtil", "Setting mBtName")
deviceName = map[input.checkedRadioButtonId]?.name ?: ""
Log.d("BluetoothUtil", "Selected Bluetooth Device: $deviceName")
Log.d(TAG, "Selected Bluetooth Device: $deviceName")
callback.onDeviceChosen(deviceName)
}
}
Expand All @@ -72,9 +72,9 @@ class BluetoothUtil {
* button is pressed.
*/
fun print(ctx: Context, printerName: String, size: String, labelCommand: List<String>) {
Log.d("BluetoothUtil", "Label Command is: $labelCommand")
Log.d(TAG, "Label zpl is: $labelCommand")
if (labelCommand.isNotEmpty()) {
Log.d("BluetoothUtil", "printing to $printerName")
Log.d(TAG, "Sending label zpl to $printerName")
PrintThread(ctx, printerName).print(size, labelCommand)
}
}
Expand Down

0 comments on commit 874588d

Please sign in to comment.