Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
Updating with the new APIs introduced in Datawedge 6.4: http://techdo…
Browse files Browse the repository at this point in the history
  • Loading branch information
darryncampbell committed Sep 19, 2017
1 parent c1342d3 commit 2974423
Show file tree
Hide file tree
Showing 2 changed files with 267 additions and 14 deletions.
105 changes: 93 additions & 12 deletions app/src/main/java/com/zebra/datawedgeexerciser/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public class MainActivity extends AppCompatActivity {
private static final String EXTRA_KEY_VALUE_NOTIFICATION_STATUS = "STATUS";
private static final String EXTRA_KEY_VALUE_NOTIFICATION_PROFILE_NAME = "PROFILE_NAME";

// 6.4 API and up Extras sent to Datawedge
private static final String EXTRA_GET_DATAWEDGE_STATUS = "com.symbol.datawedge.api.GET_DATAWEDGE_STATUS";
// 6.4 API and up Parameter keys and values associated with extras received from Datawedge
private static final String EXTRA_RESULT_GET_DATAWEDGE_STATUS = "com.symbol.datawedge.api.RESULT_GET_DATAWEDGE_STATUS";

// private variables not related to the intent API
private String mActiveProfile = "";
private static final String EXTRA_PROFILE_NAME = "DW API Exerciser Profile";
Expand Down Expand Up @@ -243,7 +248,7 @@ public void onClick(View v) {

// RegisterForNotification / UnregisterForNotification(6.3 API)
final Button btnRegisterUnregisterForNotifications = (Button) findViewById(R.id.btnRegisterUnregisterNotifications63);
final CheckBox checkRegisterForNotifications = (CheckBox) findViewById(R.id.checkRegisterUnregisterNotifications);
final CheckBox checkRegisterForNotifications = (CheckBox) findViewById(R.id.checkRegisterUnregisterScannerNotifications);
btnRegisterUnregisterForNotifications.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Bundle extras = new Bundle();
Expand Down Expand Up @@ -310,7 +315,7 @@ public void onClick(View v) {
boolean checkValue = checkEnableCommonDecoders.isChecked();
Spinner spinnerScannerForSetConfig = (Spinner) findViewById(R.id.spinnerScannerForSetConfig);
int selectedScanner = spinnerScannerForSetConfig.getSelectedItemPosition();
String currentDeviceId = "" + selectedScanner;
String currentDeviceId = "" + selectedScanner; // Should really get this from enumerate_scanners but I just assume a contiguous ID is assigned
String decoderValue = "false";
String status = "disabled";
if (checkValue)
Expand Down Expand Up @@ -339,7 +344,7 @@ public void onClick(View v) {
appConfig.putStringArray("ACTIVITY_LIST", new String[]{"*"});
profileConfig.putParcelableArray("APP_LIST", new Bundle[]{appConfig});
sendDataWedgeIntentWithExtra(ACTION_DATAWEDGE_FROM_6_2, EXTRA_SET_CONFIG, profileConfig);
Toast.makeText(getApplicationContext(), "EAN8, EAN13 and UPCA are now " + status + " in profile " + EXTRA_PROFILE_NAME, Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "EAN8, EAN13 and UPCA are now " + status + " in profile " + mActiveProfile, Toast.LENGTH_LONG).show();
}
});

Expand Down Expand Up @@ -412,6 +417,51 @@ public void onClick(View v) {
}
});

// Set Config (6.4 API)
Button btnSetConfig64 = (Button) findViewById(R.id.btnSetConfig64);
btnSetConfig64.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final CheckBox checkEnableCommonDecoders64 = (CheckBox) findViewById(R.id.checkSetConfig64EnableCommonDecoders);
boolean checkValue = checkEnableCommonDecoders64.isChecked();
String decoderValue = "false";
String status = "disabled";
if (checkValue)
{
decoderValue = "true";
status = "enabled";
}
// Note, another example of SetConfig can be found under the CreateProfile test
Bundle profileConfig = new Bundle();
profileConfig.putString("PROFILE_NAME", mActiveProfile);
profileConfig.putString("PROFILE_ENABLED", "true");
profileConfig.putString("CONFIG_MODE", "UPDATE");
Bundle barcodeConfig = new Bundle();
barcodeConfig.putString("PLUGIN_NAME", "BARCODE");
barcodeConfig.putString("RESET_CONFIG", "true");
Bundle barcodeProps = new Bundle();
//barcodeProps.putString("current-device-id", currentDeviceId); // current-device-id is DW 6.3 only, replaced by scanner_selection
barcodeProps.putString("scanner_selection", "auto"); // Could also specify a number here, the id returned from ENUMERATE_SCANNERS.
// Do NOT use "Auto" here (with a capital 'A'), it must be lower case.
barcodeProps.putString("scanner_input_enabled", "true");
barcodeProps.putString("decoder_ean8", decoderValue);
barcodeProps.putString("decoder_ean13", decoderValue);
barcodeProps.putString("decoder_upca", decoderValue);
barcodeConfig.putBundle("PARAM_LIST", barcodeProps);
profileConfig.putBundle("PLUGIN_CONFIG", barcodeConfig);
sendDataWedgeIntentWithExtra(ACTION_DATAWEDGE_FROM_6_2, EXTRA_SET_CONFIG, profileConfig);
Toast.makeText(getApplicationContext(), "EAN8, EAN13 and UPCA are now " + status + " in profile " + mActiveProfile, Toast.LENGTH_LONG).show();
}
});

// GetDatawedgeStatus (6.4 API)
final Button btnGetDatawedgeStatus = (Button) findViewById(R.id.btnGetDatawedgeStatus);
btnGetDatawedgeStatus.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
sendDataWedgeIntentWithExtra(ACTION_DATAWEDGE_FROM_6_2, EXTRA_GET_DATAWEDGE_STATUS, EXTRA_EMPTY);
}
});


// Create a filter for the broadcast intent
// Not ideal to put this here but we want to receive broadcast intents from the ZXing activity
IntentFilter filter = new IntentFilter();
Expand All @@ -424,6 +474,7 @@ public void onClick(View v) {
filter.addAction(getResources().getString(R.string.activity_action_from_service));
registerReceiver(myBroadcastReceiver, filter);

sendDataWedgeIntentWithExtra(ACTION_DATAWEDGE_FROM_6_2, EXTRA_GET_VERSION_INFO, EXTRA_EMPTY);
AsyncTask.execute(new Runnable() {
@Override
public void run() {
Expand Down Expand Up @@ -479,10 +530,10 @@ public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Bundle b = intent.getExtras();
// This is useful for debugging to verify the format of received intents from DataWedge
//for (String key : b.keySet())
//{
// Log.v(LOG_TAG, key);
//}
for (String key : b.keySet())
{
Log.v(LOG_TAG, key);
}
if (action.equals(ACTION_ENUMERATEDLIST))
{
// 6.0 API Enumerate Scanners
Expand Down Expand Up @@ -526,6 +577,8 @@ else if (action.equals(ACTION_RESULT_DATAWEDGE_FROM_6_2))
txtActiveProfile.setText(activeProfile);
TextView txtActiveProfile63 = (TextView) findViewById(R.id.txtActiveProfile63);
txtActiveProfile63.setText("Act on Profile: " + activeProfile);
TextView txtSetConfig64ActiveProfile = (TextView) findViewById(R.id.txtSetConfig64ActiveProfile);
txtSetConfig64ActiveProfile.setText("Act on Profile: " + activeProfile);
mActiveProfile = activeProfile;
}
else if (intent.hasExtra(EXTRA_RESULT_GET_PROFILE_LIST))
Expand Down Expand Up @@ -571,6 +624,12 @@ else if (intent.hasExtra(EXTRA_RESULT_GET_VERSION_INFO))
TextView txtReceivedVersions = (TextView) findViewById(R.id.txtReceivedVersions);
txtReceivedVersions.setText(userReadableVersion);
Log.i(LOG_TAG, "DataWedge Version info: " + userReadableVersion);
if (DWVersion.compareTo("6.3.0") >= 1)
enableUiFor63();
if (DWVersion.compareTo("6.4.0") >= 1)
enableUiFor64();
if (DWVersion.compareTo("6.5.0") >= 1)
enableUiFor65();
}
else if (intent.hasExtra(EXTRA_RESULT_ENUMERATE_SCANNERS))
{
Expand Down Expand Up @@ -598,11 +657,12 @@ else if (intent.hasExtra(EXTRA_RESULT_ENUMERATE_SCANNERS))
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerScannerForSetConfig.setAdapter(adapter);
Log.i(LOG_TAG, "Scanners on device: " + userFriendlyScanners);

// We trigger this callback in onResume - use this to determine that this device supports the 6.3 APIs
TextView txtHeading63Description = (TextView) findViewById(R.id.txtHeading63Description);
txtHeading63Description.setText("These will work on any Zebra device running DataWedge 6.3 or higher");
enableUiFor63();
}
else if(intent.hasExtra(EXTRA_RESULT_GET_DATAWEDGE_STATUS))
{
String datawedgeStatus = intent.getStringExtra(EXTRA_RESULT_GET_DATAWEDGE_STATUS);
Log.i(LOG_TAG, "Datawedge status is: " + datawedgeStatus);
Toast.makeText(getApplicationContext(), "Datawedge status is: " + datawedgeStatus, Toast.LENGTH_LONG).show();
}
}
else if (action.equals(ACTION_RESULT_NOTIFICATION))
Expand Down Expand Up @@ -688,6 +748,9 @@ private void displayScanResult(Intent initiatingIntent, String howDataReceived)

private void enableUiFor63()
{
TextView txtHeading63Description = (TextView) findViewById(R.id.txtHeading63Description);
txtHeading63Description.setText("These will work on any Zebra device running DataWedge 6.3 or higher");

// Enable the UI elements which are specific to the DataWedge 6.3 UI
Button btnGetVersionInfo = (Button) findViewById(R.id.btnGetVersionInfo63);
btnGetVersionInfo.setEnabled(true);
Expand All @@ -712,4 +775,22 @@ private void enableUiFor63()
Button btnSwitchToProfile = (Button) findViewById(R.id.btnSwitchToProfile63);
btnSwitchToProfile.setEnabled(true);
}

private void enableUiFor64()
{
TextView txtHeading64Description = (TextView) findViewById(R.id.txtHeading64Description);
txtHeading64Description.setText("These will work on any Zebra device running DataWedge 6.4 or higher");

Button btnSetConfig64 = (Button) findViewById(R.id.btnSetConfig64);
btnSetConfig64.setEnabled(true);
Button btnGetDatawedgeStatus = (Button) findViewById(R.id.btnGetDatawedgeStatus);
btnGetDatawedgeStatus.setEnabled(true);
}

private void enableUiFor65()
{
//TextView txtHeading65Description = (TextView) findViewById(R.id.txtHeading65Description);
//txtHeading65Description.setText("These will work on any Zebra device running DataWedge 6.5 or higher");

}
}
176 changes: 174 additions & 2 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -706,9 +706,9 @@
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/checkRegisterUnregisterNotifications"
android:id="@+id/checkRegisterUnregisterScannerNotifications"
android:layout_gravity="center_vertical|right"
android:text="Register for Notifications?"
android:text="Scanner Notifications?"
android:checked="true"/>

</LinearLayout>
Expand Down Expand Up @@ -1156,6 +1156,178 @@

</TableRow>

<View
android:layout_height="2dip"
android:background="@color/zebraBlue" />

<!-- 6.4 APIs -->

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="5dp"
android:paddingBottom="5dp">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="3">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="DataWedge 6.4 APIs"
android:id="@+id/txtHeading6.4" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="YOUR DEVICE DOES NOT SUPPORT 6.4 APIS"
android:id="@+id/txtHeading64Description" />

</LinearLayout>

</TableRow>

<TableRow
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:paddingTop="5dp"
android:paddingBottom="5dp">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="2">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Set Config (auto Scanner)"
android:id="@+id/txtSetConfig64Title" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Act on Profile: NOT SUPPORTED"
android:id="@+id/txtSetConfig64ActiveProfile" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Select Scanner (auto)"
android:id="@+id/txtSetConfig64SelectScanner" />

<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/checkSetConfig64EnableCommonDecoders"
android:layout_gravity="center_vertical|right"
android:text="Enable common decoders?"
android:checked="true"/>

</LinearLayout>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Send"
android:id="@+id/btnSetConfig64"
android:background="@color/zebraBlue"
android:textColor="@color/zebraWhite"
android:paddingRight="10dp"
android:layout_gravity="center"
android:enabled="false"
/>

</TableRow>

<View
android:layout_height="2dip"
android:background="@color/zebraBlue" />

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="5dp"
android:paddingBottom="5dp">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="2"
android:layout_gravity="center_vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Get Datawedge Status"
android:id="@+id/txtGetDatawedgeStatus" />

</LinearLayout>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Send"
android:id="@+id/btnGetDatawedgeStatus"
android:background="@color/zebraBlue"
android:textColor="@color/zebraWhite"
android:paddingRight="10dp"
android:enabled="false"
/>

</TableRow>

<!-- New functionality in 6.5 APIs -->

<!--View
android:layout_height="2dip"
android:background="@color/zebraBlue" /-->

<!-- 6.5 APIs -->

<!--TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="3">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="DataWedge 6.5 APIs"
android:id="@+id/txtHeading6.5" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="YOUR DEVICE DOES NOT SUPPORT 6.5 APIS"
android:id="@+id/txtHeading65Description" />
</LinearLayout>
</TableRow-->

<!-- New functionality in 6.5 APIs -->

</TableLayout>
</LinearLayout>
</ScrollView>
Expand Down

0 comments on commit 2974423

Please sign in to comment.