Commit 0ea53f1d by Kim Jinsung

WBS #55340 3-2.QRコード読み取り(Android)

parent 20fba104
......@@ -232,6 +232,9 @@
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<!-- @Form QRコードリーダー -->
<activity android:name="jp.agentec.abook.abv.ui.home.activity.CaptureQRCodeActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
<activity android:name="jp.agentec.abook.abv.ui.home.activity.CaptureQRCodeActivityDialog" android:theme="@android:style/Theme.Holo.Dialog.NoActionBar"/>
</application>
</manifest>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_enabled="false"
android:drawable="@drawable/ic_operation_qrcode_off"/>
<item
android:drawable="@drawable/ic_operation_qrcode_on"/>
</selector>
\ No newline at end of file
......@@ -1463,4 +1463,9 @@
<string name="dashboard">ダッシュボード</string>
<string name="failed_get_master_data">マスタデータの取得に失敗しました。画面を更新してください。</string>
<string name="title_qrcode_reader_view">QRコードリーダー</string>
<string name="msg_qrcode_not_operation_format">作業QRコードではありません。</string>
<string name="msg_qrcode_operation_not_found">作業が存在しません。</string>
<string name="msg_qrcode_disconnect_content_download">インターネットに接続されてないので同期できません。インターネットに接続してください。</string>
</resources>
......@@ -1476,4 +1476,10 @@
<string name="dashboard">Dashboard</string>
<string name="failed_get_master_data">Failed to get master data. Refresh Home screen.</string>
<string name="title_qrcode_reader_view">QR Code Reader</string>
<string name="msg_qrcode_not_operation_format">This is not operation QR code.</string>
<string name="msg_qrcode_operation_not_found">Working does not exist.</string>
<string name="msg_qrcode_disconnect_content_download">Synchronization process was failed because there are not connected to the internet. Please connect the internet.</string>
</resources>
\ No newline at end of file
......@@ -19,6 +19,7 @@ dependencies {
implementation 'com.google.guava:guava:18.0'
implementation 'com.google.zxing:core:3.2.1'
implementation 'org.jsoup:jsoup:1.9.2'
implementation 'com.journeyapps:zxing-android-embedded:3.0.1@aar'
implementation project(':FoxitRDK')
implementation project(':SwiftDecoderMobile')
implementation files('libs/sdaiflib.jar')
......
......@@ -54,12 +54,20 @@
<ImageButton
android:id="@+id/btn_batch_sync"
style="@style/ToolBarIcon"
android:layout_toLeftOf="@+id/btn_search"
android:layout_toLeftOf="@+id/btn_qrcode"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:src="@drawable/btn_operation_batch_sync"
android:visibility="gone" />
<ImageButton
android:id="@+id/btn_qrcode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@+id/btn_search"
android:background="@drawable/btn_operation_qrcode" />
<ImageButton
android:id="@+id/btn_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.journeyapps.barcodescanner.CompoundBarcodeView
android:id="@+id/bar_code_id"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/close"
android:onClick="onClick"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_qrcode_reader_view"
android:layout_centerInParent="true"
/>
</RelativeLayout>
</RelativeLayout>
......@@ -70,6 +70,7 @@ import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.launcher.android.ABVApplication;
import jp.agentec.abook.abv.launcher.android.ABVUIDataCache;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.PrefName;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.UserPrefKey;
import jp.agentec.abook.abv.ui.common.constant.ErrorCode;
......@@ -78,6 +79,7 @@ import jp.agentec.abook.abv.ui.common.constant.NaviConsts;
import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.common.util.Initializer;
import jp.agentec.abook.abv.ui.common.util.PatternStringUtil;
import jp.agentec.abook.abv.ui.home.activity.ChangePasswordActivity;
import jp.agentec.abook.abv.ui.home.activity.LoginActivity;
import jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper;
......@@ -977,4 +979,15 @@ public abstract class ABVActivity extends Activity {
}
return true;
}
/**
* 共通エラーダイアログ表示
* @param errorMessage エラーメッセージ
*/
protected void showErrorDialog(int errorMessage) {
int message = PatternStringUtil.patternToInt(getApplicationContext(),
errorMessage,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
AlertDialogUtil.showAlertDialog(this, message);
}
}
......@@ -3,6 +3,7 @@ import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.FrameLayout;
......@@ -69,4 +70,82 @@ public class AlertDialogUtil {
alertDialog.setView(scrollView);
return alertDialog;
}
/**
* 共通ダイアログ表示用(Cancel表示・非表示、OKボタンコールバック)
* @param context コンテキスト
* @param title タイトル 文字列
* @param message メッセージ 文字列
* @param isCancleButtonHidden Cancelボタン表示(false)・非表示(true)
* @param okOnClick OKボタンコールバック
*/
public static void showAlertDialog(Context context, String title, String message, boolean isCancleButtonHidden, DialogInterface.OnClickListener okOnClick) {
ABookAlertDialog alertDialog = createAlertDialog(context, title, message);
if (!isCancleButtonHidden) {
alertDialog.setNegativeButton(R.string.cancel, null);
}
alertDialog.setCancelable(false);
alertDialog.setPositiveButton(R.string.ok, okOnClick);
alertDialog.show();
}
/**
* 共通ダイアログ表示用(OKボタンコールバック、CANCELボタンコールバック)
* @param context コンテキスト
* @param title タイトル
* @param message メッセージ
* @param okOnClick OKボタンコールバック
* @param okOnClick CANCELボタンコールバック
*/
public static void showAlertDialog(Context context, int title, int message, DialogInterface.OnClickListener okOnClick, DialogInterface.OnClickListener canOnClick) {
ABookAlertDialog alertDialog = createAlertDialog(context, context.getResources().getString(title), context.getResources().getString(message));
alertDialog.setNegativeButton(R.string.cancel, canOnClick);
alertDialog.setPositiveButton(R.string.ok, okOnClick);
alertDialog.setCancelable(false);
alertDialog.show();
}
/**
* 共通ダイアログ表示用(Cancel表示・非表示、OKボタンコールバック)
* @param context コンテキスト
* @param title タイトル
* @param message メッセージ
* @param isCancleButtonHidden Cancelボタン表示(false)・非表示(true)
* @param okOnClick OKボタンコールバック
*/
public static void showAlertDialog(Context context, int title, int message, boolean isCancleButtonHidden, DialogInterface.OnClickListener okOnClick) {
String dialogTitle = null;
if (title == -1) {
dialogTitle = " ";
} else {
dialogTitle = context.getResources().getString(title);
}
ABookAlertDialog alertDialog = createAlertDialog(context, dialogTitle, context.getResources().getString(message));
if (!isCancleButtonHidden) {
alertDialog.setNegativeButton(R.string.cancel, null);
}
alertDialog.setCancelable(false);
alertDialog.setPositiveButton(R.string.ok, okOnClick);
alertDialog.show();
}
/**
* 共通ダイアログを表示
* @param context コンテキスト
* @param title タイトル
* @param message メッセージ
*/
public static void showAlertDialog(Context context, int title, int message) {
showAlertDialog(context, title, message, true, null);
}
/**
* 共通ダイアログを表示
* @param context コンテキスト
* @param message メッセージ
*/
public static void showAlertDialog(Context context, int message) {
showAlertDialog(context, -1, message, true, null);
}
}
package jp.agentec.abook.abv.ui.home.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import com.google.zxing.integration.android.IntentIntegrator;
import com.journeyapps.barcodescanner.CaptureManager;
import com.journeyapps.barcodescanner.CompoundBarcodeView;
import jp.agentec.abook.abv.launcher.android.R;
/**
* QRコードリーダー画面
*/
public class CaptureQRCodeActivity extends Activity {
public static final String OPERATION_QRCODE_SCHEME = "atform.qrcode://";
public static final String QRCODE_OPERATION_ID = "id";
private static final String TAG = IntentIntegrator.class.getSimpleName();
private CaptureManager capture;
private CompoundBarcodeView barcodeView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.capture_qrcode_layout);
setFinishOnTouchOutside(false);
barcodeView = (CompoundBarcodeView)findViewById(R.id.bar_code_id);
capture = new CaptureManager(this, barcodeView);
capture.initializeFromIntent(getIntent(), savedInstanceState);
capture.decode();
}
public void onClick(View v) {
finish();
}
@Override
protected void onResume() {
super.onResume();
capture.onResume();
}
@Override
protected void onPause() {
super.onPause();
capture.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
capture.onDestroy();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
capture.onSaveInstanceState(outState);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return barcodeView.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
}
}
\ No newline at end of file
package jp.agentec.abook.abv.ui.home.activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.WindowManager;
/**
* QRコードリーダー画面(タブレット用)
*/
public class CaptureQRCodeActivityDialog extends CaptureQRCodeActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DisplayMetrics metrics = getResources().getDisplayMetrics();
int dialogWidth;
if (metrics.widthPixels > metrics.heightPixels) {
dialogWidth = (int) (metrics.heightPixels * 0.9);
} else {
dialogWidth = (int) (metrics.widthPixels * 0.9);
}
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.width = dialogWidth;
lp.height = dialogWidth;
getWindow().setAttributes(lp);
}
}
......@@ -34,6 +34,8 @@ import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshGridView;
......@@ -114,6 +116,7 @@ import jp.agentec.abook.abv.ui.home.adapter.OperationSelectAdapter;
import jp.agentec.abook.abv.ui.home.adapter.PushMessageListAdapter;
import jp.agentec.abook.abv.ui.home.adapter.HierarchyOperationGroupListAdapter;
import jp.agentec.abook.abv.ui.home.helper.ABookCheckWebViewHelper;
import jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.home.helper.HomeOperationListHelper;
import jp.agentec.abook.abv.ui.home.helper.OperationGroupMasterListHelper;
......@@ -123,6 +126,9 @@ import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.FileUtil;
import jp.agentec.adf.util.StringUtil;
import static jp.agentec.abook.abv.ui.home.activity.CaptureQRCodeActivity.OPERATION_QRCODE_SCHEME;
import static jp.agentec.abook.abv.ui.home.activity.CaptureQRCodeActivity.QRCODE_OPERATION_ID;
/**
* Created by leej on 2018/08/17
*/
......@@ -134,6 +140,7 @@ public class OperationListActivity extends OperationActivity {
private ImageButton mSearchButton; // 検索ボタン
private ImageButton mCategoryLocationButton; // カテゴリ選択ボタン
private ImageButton mOperationBatchSyncButton; // カテゴリの一括同期ボタン
private ImageButton mQrCodeButton; // QRCodeボタン
private List<OperationDto> mOperationList;
......@@ -199,6 +206,7 @@ public class OperationListActivity extends OperationActivity {
// 作業種別のサービスオプション値を保持用フラグ
private boolean mOperationGroupMasterServiceOperationFlg;
private Long mQrCodeOperationId = null;
// ビューの作成
private class ReloadHandler implements Runnable {
@Override
......@@ -230,6 +238,8 @@ public class OperationListActivity extends OperationActivity {
// 上ツールバー
mViewModeButton = (ImageButton) findViewById(R.id.btn_view_mode);
mSearchButton = (ImageButton) findViewById(R.id.btn_search);
mQrCodeButton = findViewById(R.id.btn_qrcode);
mTitleView = (TextView) findViewById(R.id.title);
// カテゴリボタン
mCategoryLocationButton = (ImageButton) findViewById(R.id.btn_category_location);
......@@ -252,6 +262,12 @@ public class OperationListActivity extends OperationActivity {
showSearchDialog();
}
});
mQrCodeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showQrCodeReaderActivity();
}
});
mTitleView.setText(PatternStringUtil.patternToString(getApplicationContext(),
R.string.operation_list,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
......@@ -401,6 +417,7 @@ public class OperationListActivity extends OperationActivity {
// TODO:アイコン差替え
mCategoryLocationButton.setEnabled(false);
}
mQrCodeButton.setEnabled(!isSearched());
}
/**
......@@ -806,6 +823,7 @@ public class OperationListActivity extends OperationActivity {
batchSyncView.showBatchSyncErrorAlert(operationDto, getString(R.string.msg_batch_sync_content_download_fail) + (StringUtil.isNullOrEmpty(errorCodeStr) ? "" : "(" + errorCodeStr + ")"));
}
closeProgressPopup();
mQrCodeOperationId = null;
}
}
}
......@@ -1364,6 +1382,52 @@ public class OperationListActivity extends OperationActivity {
}
}
}
// QRのアクティビティのリクエストコード判定する
if (IntentIntegrator.REQUEST_CODE == requestCode){
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode,resultCode,intent);
if (scanResult != null) {
String url = scanResult.getContents();
if (url == null) { //QRコードリーダー画面から「閉じる」ボタンタップ時
Logger.v(TAG, "Clicked Close Button.");
return;
}
//有効なスキームチェック
if (url != null && url.startsWith(OPERATION_QRCODE_SCHEME)){
Uri operationUrl = Uri.parse(url);
String operationIdStr = operationUrl.getQueryParameter(QRCODE_OPERATION_ID);
if (operationIdStr == null) {
showErrorDialog(R.string.msg_qrcode_operation_not_found);
return;
} else {
long operationId = Long.parseLong(operationIdStr);
OperationDto operationDto = mOperationLogic.getOperation(operationId);
if (operationDto == null) {
showErrorDialog(R.string.msg_qrcode_operation_not_found);
return;
}
if (operationDto.needSyncFlg) {
//インターネット非接続時にはアラート表示
if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
ContentDto contentDto = contentDao.getContent(operationDto.contentId);
if (contentDto == null || !contentDto.downloadedFlg || contentDto.updatedFlg) {
showErrorDialog(R.string.msg_qrcode_disconnect_content_download);
} else {
openReportView(operationDto);
}
return;
}
mQrCodeOperationId = operationId;
startSyncOperation(operationDto);
} else {
openReportView(operationDto);
}
}
} else {
showErrorDialog(R.string.msg_qrcode_not_operation_format);
}
}
}
}
private void showOperationSelectDialog() {
......@@ -1743,6 +1807,7 @@ public class OperationListActivity extends OperationActivity {
}
//新着更新中
if (contentRefresher.isRefreshing()) {
mQrCodeOperationId = null;
return;
}
// リソースパターンの適用
......@@ -2277,6 +2342,13 @@ public class OperationListActivity extends OperationActivity {
closeProgressPopup();
// エラーメッセージ表示
showSimpleAlertDialog(getString(R.string.app_name), errorMessage);
} else {
if (mQrCodeOperationId != null) {
if (mQrCodeOperationId == operationId) {
openReportView(mOperationLogic.getOperation(mQrCodeOperationId));
mQrCodeOperationId = null;
}
}
}
}
/**
......@@ -2299,4 +2371,26 @@ public class OperationListActivity extends OperationActivity {
}
return true;
}
/**
* 権限チェックし、QRコードリーダー画面を表示
*/
private void showQrCodeReaderActivity() {
//カメラパーミッションチェック
ABookPermissionHelper helper = new ABookPermissionHelper(this, Constant.ABookPermissionType.Camera, null);
if (helper.checkMultiPermissions(true)) {
IntentIntegrator integrator = new IntentIntegrator(OperationListActivity.this);
if (isNormalSize() == false) {
integrator.setCaptureActivity(CaptureQRCodeActivityDialog.class);
} else {
integrator.setCaptureActivity(CaptureQRCodeActivity.class);
}
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
integrator.setPrompt("");
integrator.setOrientationLocked(true);
integrator.initiateScan();
} else {
Logger.w(TAG,"Camera Permission false");
}
}
}
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