Commit 82568d82 by Kim Jinsung

Merge branch 'contract/sato/1.0.500_son' into 'contract/sato/1.0.500'

implement operation auto sync

See merge request !320
parents e46de6fd 0c39bacd
...@@ -606,4 +606,8 @@ public class OperationDao extends AbstractDao { ...@@ -606,4 +606,8 @@ public class OperationDao extends AbstractDao {
Logger.e(TAG, e); Logger.e(TAG, e);
} }
} }
public List<OperationDto> getNeedSyncAllOperation() {
return rawQueryGetDtoList("select tp.*, rpc.content_id from t_operation AS tp left outer join r_operation_content AS rpc on tp.operation_id = rpc.operation_id where tp.need_sync_flg = 1", null, OperationDto.class);
}
} }
...@@ -1468,4 +1468,9 @@ ...@@ -1468,4 +1468,9 @@
<string name="msg_qrcode_not_operation_format">作業QRコードではありません。</string> <string name="msg_qrcode_not_operation_format">作業QRコードではありません。</string>
<string name="msg_qrcode_operation_not_found">作業が存在しません。</string> <string name="msg_qrcode_operation_not_found">作業が存在しません。</string>
<string name="msg_qrcode_disconnect_content_download">インターネットに接続されてないので同期できません。インターネットに接続してください。</string> <string name="msg_qrcode_disconnect_content_download">インターネットに接続されてないので同期できません。インターネットに接続してください。</string>
<string name="auto_sync">自動同期</string>
<string name="auto_sync_setting_title">自動同期する</string>
<string name="auto_sync_setting_subtitle">作業一覧で作業の自動同期を可能にします。</string>
</resources> </resources>
...@@ -1482,4 +1482,8 @@ ...@@ -1482,4 +1482,8 @@
<string name="msg_qrcode_operation_not_found">Working does not exist.</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> <string name="msg_qrcode_disconnect_content_download">Synchronization process was failed because there are not connected to the internet. Please connect the internet.</string>
<string name="auto_sync">Auto Sync</string>
<string name="auto_sync_setting_title">Automatically sync</string>
<string name="auto_sync_setting_subtitle">Enables automatic synchronization of operations in the operation list.</string>
</resources> </resources>
\ No newline at end of file
...@@ -68,4 +68,11 @@ ...@@ -68,4 +68,11 @@
android:title="@string/spp_machine" > android:title="@string/spp_machine" >
</PreferenceScreen> </PreferenceScreen>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/auto_sync" android:key="auto_sync">
<CheckBoxPreference
android:defaultValue="false"
android:key="operationAutoSync"
android:title="@string/auto_sync_setting_title"
android:summary="@string/auto_sync_setting_subtitle"/>
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
\ No newline at end of file
...@@ -55,14 +55,18 @@ public class ShowPushMessageDailogActivity extends ABVUIActivity { ...@@ -55,14 +55,18 @@ public class ShowPushMessageDailogActivity extends ABVUIActivity {
ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(), ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_routineTask_report_disable_no_operation, R.string.msg_routineTask_report_disable_no_operation,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))); getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
} else if (operationDto.needSyncFlg) { } else {
OperationListActivity operationListActivity = ActivityHandlingHelper.getInstance().getPreviousOperationListActivity();
if (operationListActivity != null && operationListActivity.needAutoSync()) {
operationListActivity.autoSyncOperationId(operationId);
return;
}
if (operationDto.needSyncFlg) {
// リソースパターンの適用 // リソースパターンの適用
ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(), ErrorMessage.showErrorMessageToast(ShowPushMessageDailogActivity.this, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_routineTask_report_disable_not_updated, R.string.msg_routineTask_report_disable_not_updated,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))); getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
} else { } else {
OperationListActivity operationListActivity = ActivityHandlingHelper.getInstance().getPreviousOperationListActivity();
if (operationListActivity != null) { if (operationListActivity != null) {
operationListActivity.startTaskDirectionOrReportView(operationDto); operationListActivity.startTaskDirectionOrReportView(operationDto);
} else { } else {
...@@ -73,6 +77,7 @@ public class ShowPushMessageDailogActivity extends ABVUIActivity { ...@@ -73,6 +77,7 @@ public class ShowPushMessageDailogActivity extends ABVUIActivity {
} }
} }
} }
}
dialog.dismiss(); dialog.dismiss();
} }
}); });
......
...@@ -76,6 +76,7 @@ public interface AppDefType { ...@@ -76,6 +76,7 @@ public interface AppDefType {
String OPERATION_GROUP_MASERT_MODE = "operation_group_master"; // 通常・作業種別モード(画面) String OPERATION_GROUP_MASERT_MODE = "operation_group_master"; // 通常・作業種別モード(画面)
String OPERATION_GROUP_MASERT_ID = "operation_group_master_id"; // 作業種別のID String OPERATION_GROUP_MASERT_ID = "operation_group_master_id"; // 作業種別のID
String OPERATION_SORT_CONDITION = "operation_sort_condition"; // 作業のソート String OPERATION_SORT_CONDITION = "operation_sort_condition"; // 作業のソート
String OPERATION_AUTO_SYNC = "operationAutoSync";
} }
/** /**
......
...@@ -82,6 +82,9 @@ public class ABVBatchSyncView extends ProgressDialog { ...@@ -82,6 +82,9 @@ public class ABVBatchSyncView extends ProgressDialog {
// Activity破棄フラグがtrue、またはスタックが存在しなければ、全て完了と見做す // Activity破棄フラグがtrue、またはスタックが存在しなければ、全て完了と見做す
closeProgressDialog(); closeProgressDialog();
Logger.d(TAG, "---batchSync is end"); Logger.d(TAG, "---batchSync is end");
if (mOperationListActivity != null && mOperationListActivity.mAutoSyncingFlg) {
mOperationListActivity.autoSyncOperationDone(true);
}
return; return;
} }
// ベース資料のダウンロードチェック // ベース資料のダウンロードチェック
...@@ -97,6 +100,9 @@ public class ABVBatchSyncView extends ProgressDialog { ...@@ -97,6 +100,9 @@ public class ABVBatchSyncView extends ProgressDialog {
// error // error
showBatchSyncErrorAlert(peekOperationDto, mOperationListActivity.getString(R.string.msg_batch_sync_content_download_fail)); showBatchSyncErrorAlert(peekOperationDto, mOperationListActivity.getString(R.string.msg_batch_sync_content_download_fail));
} }
if (mOperationListActivity != null && mOperationListActivity.mAutoSyncingFlg) {
mOperationListActivity.autoSyncOperationDone(false);
}
return; return;
} }
// 同期処理 // 同期処理
......
...@@ -206,6 +206,9 @@ public class OperationListActivity extends OperationActivity { ...@@ -206,6 +206,9 @@ public class OperationListActivity extends OperationActivity {
// 作業種別のサービスオプション値を保持用フラグ // 作業種別のサービスオプション値を保持用フラグ
private boolean mOperationGroupMasterServiceOperationFlg; private boolean mOperationGroupMasterServiceOperationFlg;
public boolean mAutoSyncingFlg;
public Long mAutoSyncOpenOperationId = null;
public Long mQrCodeOperationId = null; public Long mQrCodeOperationId = null;
// ビューの作成 // ビューの作成
private class ReloadHandler implements Runnable { private class ReloadHandler implements Runnable {
...@@ -478,6 +481,32 @@ public class OperationListActivity extends OperationActivity { ...@@ -478,6 +481,32 @@ public class OperationListActivity extends OperationActivity {
// ビューを作り直す // ビューを作り直す
setOperationListView(); setOperationListView();
} }
if (isAutoSync()) {
if (mAutoSyncingFlg) {
if (result) {
// content update success
List<OperationDto> needSyncOperationList = new ArrayList<>();
if (mAutoSyncOpenOperationId != null) {
OperationDto operationDto = mOperationLogic.getOperation(mAutoSyncOpenOperationId);
if (operationDto.needSyncFlg) {
needSyncOperationList.add(operationDto);
}
} else {
needSyncOperationList.addAll(mOperationDao.getNeedSyncAllOperation());
}
if (needSyncOperationList.size() > 0) {
categoryBatchSync(needSyncOperationList);
} else {
// donot need sync
autoSyncOperationDone(true);
}
} else {
// content update fail
autoSyncOperationDone(false);
}
}
return;
}
//「I/O 帳票使用」がYESのみ、新着更新処理完了後、一括同期処理を開始する。 //「I/O 帳票使用」がYESのみ、新着更新処理完了後、一括同期処理を開始する。
if (ABVDataCache.getInstance().serviceOption.isUnableIOReport()) { if (ABVDataCache.getInstance().serviceOption.isUnableIOReport()) {
if (mAutoBatchSyncFlg) { if (mAutoBatchSyncFlg) {
...@@ -509,6 +538,16 @@ public class OperationListActivity extends OperationActivity { ...@@ -509,6 +538,16 @@ public class OperationListActivity extends OperationActivity {
refreshOperationList(); refreshOperationList();
// 作業指示・報告からプロジェクト一覧へ戻った時の同期処理 // 作業指示・報告からプロジェクト一覧へ戻った時の同期処理
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) { if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
if (isAutoSync()) {
// delay for showProgressView
handler.postDelayed(new Runnable() {
@Override
public void run() {
autoSyncOperation();
}
}, 100);
} else {
final long operationId = getUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L); final long operationId = getUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L);
if (operationId != -1) { if (operationId != -1) {
final OperationDto operationDto = mOperationLogic.getOperation(operationId); final OperationDto operationDto = mOperationLogic.getOperation(operationId);
...@@ -570,7 +609,7 @@ public class OperationListActivity extends OperationActivity { ...@@ -570,7 +609,7 @@ public class OperationListActivity extends OperationActivity {
dataRefresh(true); dataRefresh(true);
} }
} }
}
putUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L); putUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L);
activityResultFlg = false; activityResultFlg = false;
...@@ -1406,6 +1445,10 @@ public class OperationListActivity extends OperationActivity { ...@@ -1406,6 +1445,10 @@ public class OperationListActivity extends OperationActivity {
showErrorDialog(R.string.msg_qrcode_operation_not_found); showErrorDialog(R.string.msg_qrcode_operation_not_found);
return; return;
} }
if (needAutoSync()) {
autoSyncOperationId(operationId);
return;
}
if (operationDto.needSyncFlg) { if (operationDto.needSyncFlg) {
//インターネット非接続時にはアラート表示 //インターネット非接続時にはアラート表示
if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) { if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
...@@ -1855,6 +1898,10 @@ public class OperationListActivity extends OperationActivity { ...@@ -1855,6 +1898,10 @@ public class OperationListActivity extends OperationActivity {
refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(lastUpdateTimeLabel); refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(lastUpdateTimeLabel);
} }
} }
if (needAutoSync()) {
autoSyncOperation();
return;
}
CommonExecutor.execute(new Runnable() { CommonExecutor.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -1892,7 +1939,10 @@ public class OperationListActivity extends OperationActivity { ...@@ -1892,7 +1939,10 @@ public class OperationListActivity extends OperationActivity {
refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(lastUpdateTimeLabel); refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(lastUpdateTimeLabel);
} }
} }
if (needAutoSync()) {
autoSyncOperation();
return;
}
CommonExecutor.execute(new Runnable() { CommonExecutor.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -2393,4 +2443,58 @@ public class OperationListActivity extends OperationActivity { ...@@ -2393,4 +2443,58 @@ public class OperationListActivity extends OperationActivity {
Logger.w(TAG,"Camera Permission false"); Logger.w(TAG,"Camera Permission false");
} }
} }
private boolean isAutoSync() {
return PreferenceUtil.get(getApplicationContext(), AppDefType.UserPrefKey.OPERATION_AUTO_SYNC, false);
}
public boolean needAutoSync() {
return (isAutoSync() && ABVEnvironment.getInstance().networkAdapter.isNetworkConnected());
}
/**
* Run refresh data and batch sync if need
*/
public void autoSyncOperation() {
if (mAutoSyncingFlg) {
return;
}
mAutoSyncingFlg = true;
showProgressPopup(getResources().getString(R.string.synchronizing));
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
dataRefresh(true);
if (!contentRefresher.isRefreshing()) {
autoSyncOperationDone(false);
}
}
});
}
/**
* Auto sync and open operation if success
* @param operationId
*/
public void autoSyncOperationId(Long operationId) {
mAutoSyncOpenOperationId = operationId;
autoSyncOperation();
}
/**
* Auto sync done
* @param isSuccess
*/
public void autoSyncOperationDone(boolean isSuccess) {
mAutoSyncingFlg = false;
closeProgressPopup();
if (isSuccess) {
if (mAutoSyncOpenOperationId != null) {
OperationDto operationDto = mOperationLogic.getOperation(mAutoSyncOpenOperationId);
if (!operationDto.needSyncFlg) {
openReportView(operationDto);
}
}
}
mAutoSyncOpenOperationId = null;
}
} }
...@@ -148,18 +148,7 @@ public abstract class OperationListHelper { ...@@ -148,18 +148,7 @@ public abstract class OperationListHelper {
adapter.setAdapterListener(new AbstractOperationAdapter.AbstractOperationListAdapterListener() { adapter.setAdapterListener(new AbstractOperationAdapter.AbstractOperationListAdapterListener() {
@Override @Override
public void openReport(OperationDto operationDto) { public void openReport(OperationDto operationDto) {
if (operationDto.contentId != null && operationDto.contentId != 0) { onClickReport(operationDto);
// 作業画面
mAppActivity.openReportView(operationDto);
} else {
if (operationDto.operationType == PANO) {
// パノラマ登録画面
mAppActivity.showPanoEntryDialog(operationDto);
} else {
// 何もしない
Logger.e("not open target");
}
}
} }
@Override @Override
...@@ -211,18 +200,7 @@ public abstract class OperationListHelper { ...@@ -211,18 +200,7 @@ public abstract class OperationListHelper {
adapter.setAdapterListener(new AbstractOperationAdapter.AbstractOperationListAdapterListener() { adapter.setAdapterListener(new AbstractOperationAdapter.AbstractOperationListAdapterListener() {
@Override @Override
public void openReport(OperationDto operationDto) { public void openReport(OperationDto operationDto) {
if (operationDto.contentId != null && operationDto.contentId != 0) { onClickReport(operationDto);
// 作業画面
mAppActivity.openReportView(operationDto);
} else {
if (operationDto.operationType == PANO) {
// パノラマ登録画面
mAppActivity.showPanoEntryDialog(operationDto);
} else {
// 何もしない
Logger.e("not open target");
}
}
} }
@Override @Override
...@@ -285,4 +263,23 @@ public abstract class OperationListHelper { ...@@ -285,4 +263,23 @@ public abstract class OperationListHelper {
*/ */
abstract protected List<OperationDto> findOperationList() throws Exception; abstract protected List<OperationDto> findOperationList() throws Exception;
public void onClickReport(OperationDto operationDto) {
if (mAppActivity.needAutoSync()) {
mAppActivity.autoSyncOperationId(operationDto.operationId);
return;
}
if (operationDto.contentId != null && operationDto.contentId != 0) {
// 作業画面
mAppActivity.openReportView(operationDto);
} else {
if (operationDto.operationType == PANO) {
// パノラマ登録画面
mAppActivity.showPanoEntryDialog(operationDto);
} else {
// 何もしない
Logger.e("not open target");
}
}
}
} }
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