Commit 72d5665d by Jeong Gilmo

#32919 バーコードリーダー

- カメラからバーコードを読み取る機能のライブラリーの追加
- バーコードを読み取るカメラ機能と連携する機能追加
- カメラから読み取ったバーコードのデータをCMSに転送機能の追加
parent bbfc0958
...@@ -216,5 +216,7 @@ ...@@ -216,5 +216,7 @@
<!-- ABookCheck1.0.0 Sato --> <!-- ABookCheck1.0.0 Sato -->
<activity android:name="jp.agentec.abook.abv.ui.home.activity.PairingSettingActivity" <activity android:name="jp.agentec.abook.abv.ui.home.activity.PairingSettingActivity"
android:theme="@style/AppTheme"/> android:theme="@style/AppTheme"/>
<activity android:name="jp.agentec.abook.abv.ui.home.activity.BarCodeReaderActivity"
android:theme="@style/AppTheme"/>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -1383,5 +1383,6 @@ ...@@ -1383,5 +1383,6 @@
<string name="msg_ble_not_connect">接続が停止しました。</string> <string name="msg_ble_not_connect">接続が停止しました。</string>
<string name="msg_ble_connect_error">%sと接続されていません。\n%sと接続状態を設定画面の機器連携から確認してください。</string> <string name="msg_ble_connect_error">%sと接続されていません。\n%sと接続状態を設定画面の機器連携から確認してください。</string>
<string name="msg_permission_dialog_bluetooth">ブルートゥース利用権限が必要です。\nアプリ設定画面へ遷移します。</string> <string name="msg_permission_dialog_bluetooth">ブルートゥース利用権限が必要です。\nアプリ設定画面へ遷移します。</string>
<string name="sensor">センサー</string>
<string name="barcode">バーコード</string>
</resources> </resources>
...@@ -1384,5 +1384,6 @@ ...@@ -1384,5 +1384,6 @@
<string name="msg_ble_not_connect">접속이 정지되었습니다.</string> <string name="msg_ble_not_connect">접속이 정지되었습니다.</string>
<string name="msg_ble_connect_error">%s랑 접속되지않습니다.\n%s와의 접속상태를 설정화면의 기기연결에서 확인해주세요.</string> <string name="msg_ble_connect_error">%s랑 접속되지않습니다.\n%s와의 접속상태를 설정화면의 기기연결에서 확인해주세요.</string>
<string name="msg_permission_dialog_bluetooth">블루투스이용권한이 필요합니다.\n설정화면으로 이동합니다.</string> <string name="msg_permission_dialog_bluetooth">블루투스이용권한이 필요합니다.\n설정화면으로 이동합니다.</string>
<string name="sensor">센서</string>
<string name="barcode">바코드</string>
</resources> </resources>
\ No newline at end of file
...@@ -1383,5 +1383,6 @@ ...@@ -1383,5 +1383,6 @@
<string name="msg_ble_not_connect">The connection has stopped.</string> <string name="msg_ble_not_connect">The connection has stopped.</string>
<string name="msg_ble_connect_error">Not connected with% %s. \nCheck %s and connection status from the device linkage on the setting screen.</string> <string name="msg_ble_connect_error">Not connected with% %s. \nCheck %s and connection status from the device linkage on the setting screen.</string>
<string name="msg_permission_dialog_bluetooth">You need Bluetooth access authority. \nIt changes to the application setting.</string> <string name="msg_permission_dialog_bluetooth">You need Bluetooth access authority. \nIt changes to the application setting.</string>
<string name="sensor">Sensor</string>
<string name="barcode">Barcode</string>
</resources> </resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="@drawable/setting_bg">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/toolbar_layout"
style="@style/OperationSearchToolBar"
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:id="@+id/tv_toolbar_title"
style="@style/DialogToolBarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/barcode"
android:textColor="@color/edt_text"
android:textSize="@dimen/opeartion_title_text_size" />
<ImageButton
android:id="@+id/close_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/ic_operation_close"
android:onClick="onClickCloseView" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.honeywell.barcode.HSMDecodeComponent
android:id="@+id/hsm_decodeComponent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<EditText
android:id="@+id/editTextDisplay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:ems="10"
android:gravity="top"
android:inputType="textMultiLine" >
<requestFocus />
</EditText>
</LinearLayout>
</LinearLayout>
</LinearLayout>
package jp.agentec.abook.abv.ui.home.activity;
import com.honeywell.barcode.HSMDecodeComponent;
import com.honeywell.barcode.HSMDecodeResult;
import com.honeywell.barcode.HSMDecoder;
import com.honeywell.barcode.Symbology;
import com.honeywell.license.ActivationManager;
import com.honeywell.license.ActivationResult;
import com.honeywell.plugins.PluginResultListener;
import com.honeywell.plugins.decode.DecodeResultListener;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.home.plugin.BarCodeReaderCustomPlugin;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import jp.agentec.abook.abv.ui.home.plugin.BarCodeReaderCustomPluginResultListener;
/* The purpose of this sample code is to show the multiple different ways you can use bar code scanning functionality in your application.
* Bar code scanning can be achieved in the following 3 ways:
* 1) You can let HSMDecoder handle everything for you by simply calling hsmDecoder.scanBarcode();
* 2) You can embed an HSMDecodeComponent into your own activity and size it how you see fit
* 3) You can create a custom SwiftPlugin to completely control the look and operation of a scan event.
* This custom plug-in must be registered with HSMDecoder and can be used with either method 1 or 2 mentioned above.
*/
public class BarCodeReaderActivity extends Activity implements DecodeResultListener, BarCodeReaderCustomPluginResultListener {
public HSMDecoder hsmDecoder;
private EditText editTextDisplay;
private HSMDecodeComponent decCom;
private int scanCount = 0;
public static final String BARCODE_READING_DATA = "barcode_data";
private static final String TAG = "BarCodeReaderActivity";
@Override
public void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
//initialize GUI
initGuiElements();
//activate the API with your license key
ActivationResult activationResult = ActivationManager.activate(this, "trial-image-areyn-12062017");
Toast.makeText(this, "Activation Result: " + activationResult, Toast.LENGTH_LONG).show();
//get the singleton instance of the decoder
hsmDecoder = HSMDecoder.getInstance(this);
Logger.d(TAG, "isDecodingEnabled !!!! [ " + hsmDecoder.isDecodingEnabled());
// Toast.makeText(this, "Activation isDecodingEnabled: " + hsmDecoder.isDecodingEnabled(), Toast.LENGTH_LONG).show();
//set all decoder related settings
setSymbology();
hsmDecoder.enableFlashOnDecode(false);
hsmDecoder.enableSound(true);
hsmDecoder.enableAimer(true);
hsmDecoder.setAimerColor(Color.RED);
hsmDecoder.setOverlayTextColor(Color.WHITE);
hsmDecoder.addResultListener(this);
} catch(Exception e) {
e.printStackTrace();
}
}
public static void onDisposeInstance() {
HSMDecoder.disposeInstance();
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
onDisposeInstance();
finish();
} else {
return super.onKeyUp(keyCode, event);
}
return false;
}
@Override
public void onHSMDecodeResult(HSMDecodeResult[] barcodeData) {
//handle results from the default decoding functionality
displayBarcodeData(barcodeData);
}
@Override
public void onCustomPluginResult(HSMDecodeResult[] barcodeData) {
//handle results from your custom plug-in
displayBarcodeData(barcodeData);
}
private void displayBarcodeData(HSMDecodeResult[] barcodeData) {
Toast.makeText(this, "barcodeData.length : [%d]" + barcodeData.length, Toast.LENGTH_LONG).show();
if( barcodeData.length > 0) {
HSMDecodeResult firstResult = barcodeData[0];
String msg = "Scan Count: " + ++scanCount + "\n\n" +
"onHSMDecodeResult\n" +
"Data: " + firstResult.getBarcodeData() + "\n" +
"Symbology: " + firstResult.getSymbology() + "\n" +
"Length: " + firstResult.getBarcodeDataLength() + "\n" +
"Decode Time: " + firstResult.getDecodeTime() + "ms";
if (scanCount == 1) {
hsmDecoder.enableSound(false);
editTextDisplay.setText(msg);
Toast.makeText(this, "Activation Result: " + msg, Toast.LENGTH_LONG).show();
final String readingBarcodeData = firstResult.getBarcodeData();
ABookAlertDialog saveDialog = AlertDialogUtil.createAlertDialog(this, getString(R.string.barcode));
saveDialog.setMessage(readingBarcodeData);
saveDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.confirm), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onDisposeInstance();
// Okボタンタップし、保存作業の処理
Intent intent = new Intent();
intent.putExtra(BARCODE_READING_DATA, readingBarcodeData);
setResult(Activity.RESULT_OK, intent);
finish();
}
});
saveDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// cancelボタンタップし、処理
scanCount = 0;
hsmDecoder.enableSound(true);
}
});
saveDialog.show();
}
}
}
// Setting Activity screen
private void initGuiElements() {
//stop the device from going to sleep and hide the title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.barcode_reader);
decCom = (HSMDecodeComponent)findViewById(R.id.hsm_decodeComponent);
editTextDisplay = (EditText)findViewById(R.id.editTextDisplay);
editTextDisplay.setEnabled(false);
editTextDisplay.setTextColor(Color.WHITE);
}
//set all decoder related settings
private void setSymbology() {
hsmDecoder.enableSymbology(Symbology.UPCA);
hsmDecoder.enableSymbology(Symbology.CODE128);
hsmDecoder.enableSymbology(Symbology.CODE39);
hsmDecoder.enableSymbology(Symbology.QR);
hsmDecoder.enableSymbology(Symbology.EAN8);
hsmDecoder.enableSymbology(Symbology.MENU_TYPE_INT);
hsmDecoder.enableSymbology(Symbology.MENU_TYPE_CHAR);
hsmDecoder.enableSymbology(Symbology.MENU_TYPE_ARRAY);
hsmDecoder.enableSymbology(Symbology.MENU_TYPE_MASK);
hsmDecoder.enableSymbology(Symbology.UPCA_2CHAR_ADDENDA);
hsmDecoder.enableSymbology(Symbology.UPCA_5CHAR_ADDENDA);
hsmDecoder.enableSymbology(Symbology.UPCE0);
hsmDecoder.enableSymbology(Symbology.UPCE1);
hsmDecoder.enableSymbology(Symbology.UPCE_EXPAND);
hsmDecoder.enableSymbology(Symbology.UPCE_2CHAR_ADDENDA);
hsmDecoder.enableSymbology(Symbology.UPCE_5CHAR_ADDENDA);
hsmDecoder.enableSymbology(Symbology.EAN8_2CHAR_ADDENDA);
hsmDecoder.enableSymbology(Symbology.EAN8_5CHAR_ADDENDA);
hsmDecoder.enableSymbology(Symbology.EAN13);
hsmDecoder.enableSymbology(Symbology.EAN13_2CHAR_ADDENDA);
hsmDecoder.enableSymbology(Symbology.EAN13_5CHAR_ADDENDA);
hsmDecoder.enableSymbology(Symbology.EAN13_ISBN);
hsmDecoder.enableSymbology(Symbology.GS1_128);
hsmDecoder.enableSymbology(Symbology.C128_ISBT);
hsmDecoder.enableSymbology(Symbology.COUPON_CODE);
hsmDecoder.enableSymbology(Symbology.TRIOPTIC);
hsmDecoder.enableSymbology(Symbology.I25);
hsmDecoder.enableSymbology(Symbology.S25);
hsmDecoder.enableSymbology(Symbology.IATA25);
hsmDecoder.enableSymbology(Symbology.M25);
hsmDecoder.enableSymbology(Symbology.CODE93);
hsmDecoder.enableSymbology(Symbology.CODE11);
hsmDecoder.enableSymbology(Symbology.CODABAR);
hsmDecoder.enableSymbology(Symbology.TELEPEN);
hsmDecoder.enableSymbology(Symbology.MSI);
hsmDecoder.enableSymbology(Symbology.RSS_14);
hsmDecoder.enableSymbology(Symbology.RSS_LIMITED);
hsmDecoder.enableSymbology(Symbology.RSS_EXPANDED);
hsmDecoder.enableSymbology(Symbology.CODABLOCK_F);
hsmDecoder.enableSymbology(Symbology.PDF417);
hsmDecoder.enableSymbology(Symbology.MICROPDF);
hsmDecoder.enableSymbology(Symbology.COMPOSITE);
hsmDecoder.enableSymbology(Symbology.COMPOSITE_WITH_UPC);
hsmDecoder.enableSymbology(Symbology.AZTEC);
hsmDecoder.enableSymbology(Symbology.MAXICODE);
hsmDecoder.enableSymbology(Symbology.DATAMATRIX);
hsmDecoder.enableSymbology(Symbology.DATAMATRIX_RECTANGLE);
hsmDecoder.enableSymbology(Symbology.NEC25);
hsmDecoder.enableSymbology(Symbology.GRID);
hsmDecoder.enableSymbology(Symbology.DOT);
hsmDecoder.enableSymbology(Symbology.HANXIN);
hsmDecoder.enableSymbology(Symbology.HK25);
hsmDecoder.enableSymbology(Symbology.KOREA_POST);
}
// 閉じるボタンの処理
public void onClickCloseView(View v) {
onDisposeInstance();
finish();
}
}
\ No newline at end of file
package jp.agentec.abook.abv.ui.home.plugin;
import java.util.List;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.honeywell.barcode.HSMDecodeResult;
import com.honeywell.plugins.PluginResultListener;
import com.honeywell.plugins.SwiftPlugin;
import jp.agentec.abook.abv.launcher.android.R;
/*
* This plug-in does nothing more than render text in the middle of the screen and silently return decode results to its listeners
*/
public class BarCodeReaderCustomPlugin extends SwiftPlugin
{
private TextView tvMessage;
private int clickCount = 0;
public BarCodeReaderCustomPlugin(Context context)
{
super(context);
}
@Override
public void onStart()
{
super.onStart();
}
@Override
protected void onStop()
{
super.onStop();
}
@Override
public void onDestroy()
{
super.onDestroy();
}
@Override
public void onDecode(HSMDecodeResult[] results)
{
super.onDecode(results);
notifyListeners(results);
}
@Override
protected void onDecodeFailed()
{
super.onDecodeFailed();
}
@Override
protected void onImage(byte[] image, int width, int height)
{
super.onImage(image, width, height);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
super.onSizeChanged(w, h, oldw, oldh);
}
private void notifyListeners(HSMDecodeResult[] results)
{
//tells all plug-in monitor event listeners we have a result (used by the system)
this.finish();
//notify all plug-in listeners we have a result
List<PluginResultListener> listeners = this.getResultListeners();
for(PluginResultListener listener : listeners)
((BarCodeReaderCustomPluginResultListener)listener).onCustomPluginResult(results);
}
}
package jp.agentec.abook.abv.ui.home.plugin;
import com.honeywell.barcode.HSMDecodeResult;
import com.honeywell.plugins.PluginResultListener;
//this interface defines how the custom plug-in will return results to its listeners (must extend PluginResultListener)
public interface BarCodeReaderCustomPluginResultListener extends PluginResultListener
{
public void onCustomPluginResult(HSMDecodeResult[] barcodeData);
}
\ No newline at end of file
...@@ -136,7 +136,7 @@ import jp.agentec.abook.abv.ui.common.util.PatternStringUtil; ...@@ -136,7 +136,7 @@ import jp.agentec.abook.abv.ui.common.util.PatternStringUtil;
import jp.agentec.abook.abv.ui.common.view.ABVEditText; import jp.agentec.abook.abv.ui.common.view.ABVEditText;
import jp.agentec.abook.abv.ui.common.view.ABVPopupListWindow; import jp.agentec.abook.abv.ui.common.view.ABVPopupListWindow;
import jp.agentec.abook.abv.ui.common.vo.Size; import jp.agentec.abook.abv.ui.common.vo.Size;
//import jp.agentec.abook.abv.ui.home.activity.BarCodeReaderActivity; import jp.agentec.abook.abv.ui.home.activity.BarCodeReaderActivity;
import jp.agentec.abook.abv.ui.home.activity.PairingSettingActivity; import jp.agentec.abook.abv.ui.home.activity.PairingSettingActivity;
import jp.agentec.abook.abv.ui.home.helper.ABookCheckWebViewHelper; import jp.agentec.abook.abv.ui.home.helper.ABookCheckWebViewHelper;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper; import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
...@@ -3770,31 +3770,31 @@ public class ContentViewActivity extends ABVContentViewActivity { ...@@ -3770,31 +3770,31 @@ public class ContentViewActivity extends ABVContentViewActivity {
mUploadMessage.onReceiveValue(result); mUploadMessage.onReceiveValue(result);
break; break;
// 機器連携と繋がる処理 get DeviceInfo // 機器連携と繋がる処理 get DeviceInfo
case REQUEST_ENABLEBLUETOOTH: // Bluetooth有効化要求 // case REQUEST_ENABLEBLUETOOTH: // Bluetooth有効化要求
if( Activity.RESULT_CANCELED == resultCode ) // if( Activity.RESULT_CANCELED == resultCode )
{ // 有効にされなかった // { // 有効にされなかった
ABVToastUtil.showMakeText(getApplicationContext(), R.string.bluetooth_is_not_working, Toast.LENGTH_SHORT); // ABVToastUtil.showMakeText(getApplicationContext(), R.string.bluetooth_is_not_working, Toast.LENGTH_SHORT);
return; // return;
} // }
break; // break;
case REQUEST_CONNECTDEVICE: // デバイス接続要求 // case REQUEST_CONNECTDEVICE: // デバイス接続要求
String strDeviceName; // String strDeviceName;
if( Activity.RESULT_OK == resultCode ) { // if( Activity.RESULT_OK == resultCode ) {
// デバイスリストアクティビティからの情報の取得 // // デバイスリストアクティビティからの情報の取得
strDeviceName = intent.getStringExtra( PairingSettingActivity.EXTRAS_DEVICE_NAME ); // strDeviceName = intent.getStringExtra( PairingSettingActivity.EXTRAS_DEVICE_NAME );
mDeviceAddress = intent.getStringExtra( PairingSettingActivity.EXTRAS_DEVICE_ADDRESS ); // mDeviceAddress = intent.getStringExtra( PairingSettingActivity.EXTRAS_DEVICE_ADDRESS );
setUserPref(strDeviceName, mDeviceAddress, 1); // setUserPref(strDeviceName, mDeviceAddress, 1);
} else { // } else {
strDeviceName = ""; // strDeviceName = "";
mDeviceAddress = ""; // mDeviceAddress = "";
setUserPref(strDeviceName, mDeviceAddress, 0); // setUserPref(strDeviceName, mDeviceAddress, 0);
}
break;
// case REQUEST_BARCODE_READER: // バーコードレーダから読み取ったデータの処理
// if (Activity.RESULT_OK == resultCode) {
// setBarCodeData(intent.getStringExtra(BarCodeReaderActivity.BARCODE_READING_DATA));
// } // }
// break; // break;
case REQUEST_BARCODE_READER: // バーコードレーダから読み取ったデータの処理
if (Activity.RESULT_OK == resultCode) {
setBarCodeData(intent.getStringExtra(BarCodeReaderActivity.BARCODE_READING_DATA));
}
break;
} }
mUploadMessage = null; mUploadMessage = null;
} }
......
configurations.maybeCreate("default")
artifacts.add("default", file('SwiftDecoderMobile.aar'))
\ No newline at end of file
include ':ABVJE_BL', ':ABVJE_Launcher_Android', ':ABVJE_Res_Default_Android', ':ABVJE_UI_Android' include ':ABVJE_BL', ':ABVJE_Launcher_Android', ':ABVJE_Res_Default_Android', ':ABVJE_UI_Android', ':SwiftDecoderMobile'
include ':xwalk_core_library' include ':xwalk_core_library'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment