Commit ed09a6a5 by Kang Donghun

#73480 通信仕組み改善検証

parent 8a85b027
...@@ -91,7 +91,6 @@ public class OperationLogic extends AbstractLogic { ...@@ -91,7 +91,6 @@ public class OperationLogic extends AbstractLogic {
private TaskWorkerGroupDao mTaskWorkerGroupDao = AbstractDao.getDao(TaskWorkerGroupDao.class); private TaskWorkerGroupDao mTaskWorkerGroupDao = AbstractDao.getDao(TaskWorkerGroupDao.class);
private static final int FINISHED_STATUS = 999; private static final int FINISHED_STATUS = 999;
private final static int INTERVAL_LAST_EDIT_TIME_MS = 1800000;
public void initializeOperations() throws AcmsException, NetworkDisconnectedException { public void initializeOperations() throws AcmsException, NetworkDisconnectedException {
// 作業グループリスト取得 // 作業グループリスト取得
setWorkingGroupList(); setWorkingGroupList();
...@@ -1936,29 +1935,6 @@ public class OperationLogic extends AbstractLogic { ...@@ -1936,29 +1935,6 @@ public class OperationLogic extends AbstractLogic {
return result; return result;
} }
private Boolean isEnableTimeForAutoSync(Date lastEditDateTime) {
Date currentDateTime = DateTimeUtil.getCurrentDate();
if (lastEditDateTime == null) {
return true;
} else {
long diffInMillis = currentDateTime.getTime() - lastEditDateTime.getTime();
if (diffInMillis >= INTERVAL_LAST_EDIT_TIME_MS) {
return true;
}
}
return false;
}
public List<OperationDto> needSyncCheckArray(List<OperationDto> needSyncOperationInfoArray) {
List<OperationDto> needSyncCheckArray = new ArrayList<>();
for (OperationDto operationDto : needSyncOperationInfoArray) {
if (isEnableTimeForAutoSync(operationDto.operationLastSyncDate)) {
needSyncCheckArray.add(operationDto);
}
}
return needSyncCheckArray;
}
/** /**
* 重複作業情報を配列から除外 * 重複作業情報を配列から除外
* @param operationDtoList * @param operationDtoList
......
...@@ -68,11 +68,4 @@ ...@@ -68,11 +68,4 @@
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
...@@ -3,6 +3,7 @@ package jp.agentec.abook.abv.ui.common.activity; ...@@ -3,6 +3,7 @@ package jp.agentec.abook.abv.ui.common.activity;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.dto.OperationDto; import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic; import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic; import jp.agentec.abook.abv.bl.logic.OperationLogic;
...@@ -57,8 +58,8 @@ public class ShowPushMessageDailogActivity extends ABVUIActivity { ...@@ -57,8 +58,8 @@ public class ShowPushMessageDailogActivity extends ABVUIActivity {
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))); getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
} else { } else {
OperationListActivity operationListActivity = ActivityHandlingHelper.getInstance().getPreviousOperationListActivity(); OperationListActivity operationListActivity = ActivityHandlingHelper.getInstance().getPreviousOperationListActivity();
if (operationListActivity != null && operationListActivity.needAutoSync()) { if (operationListActivity != null && ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
operationListActivity.autoSyncOperationId(operationId); operationListActivity.autoSyncNeedSyncAndOpenOperationId(operationId);
return; return;
} }
if (operationDto.needSyncFlg) { if (operationDto.needSyncFlg) {
......
...@@ -76,7 +76,6 @@ public interface AppDefType { ...@@ -76,7 +76,6 @@ 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";
String ANDROID_13_PERMISSION_CHECK = "android13PermissionCheck"; String ANDROID_13_PERMISSION_CHECK = "android13PermissionCheck";
String ANDROID_14_PERMISSION_CHECK = "android14PermissionCheck"; String ANDROID_14_PERMISSION_CHECK = "android14PermissionCheck";
......
...@@ -95,6 +95,10 @@ public class ABookSettingFragment extends PreferenceFragment { ...@@ -95,6 +95,10 @@ public class ABookSettingFragment extends PreferenceFragment {
handler = new Handler(); handler = new Handler();
pref = PreferenceManager.getDefaultSharedPreferences(getActivity()); pref = PreferenceManager.getDefaultSharedPreferences(getActivity());
// 設定XMLから削除した CheckBox(operationAutoSync)の残キーを掃除
if (pref.contains("operationAutoSync")) {
pref.edit().remove("operationAutoSync").apply();
}
addPreferencesFromResource(R.xml.pref); addPreferencesFromResource(R.xml.pref);
// アカウント // アカウント
......
...@@ -456,6 +456,30 @@ public class DashboardActivity extends OperationActivity { ...@@ -456,6 +456,30 @@ public class DashboardActivity extends OperationActivity {
// 新着更新を止める // 新着更新を止める
contentRefresher.stopRefresh(); contentRefresher.stopRefresh();
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
// 既に作業一覧がスタック上にある場合は、画面遷移せずにそのActivityで同期処理だけ実行する
OperationListActivity operationListActivity = ActivityHandlingHelper.getInstance().getPreviousOperationListActivity();
if (operationListActivity != null) {
operationListActivity.autoSyncOperationIdFromDashboard(operationId, taskKey, taskReportId, reportStartDate);
return;
}
Intent bridge = new Intent(this, OperationListActivity.class);
bridge.putExtra(OperationListActivity.EXTRA_PENDING_DASH_SYNC_OPERATION_ID, operationId);
bridge.putExtra(OperationListActivity.EXTRA_PENDING_DASH_TASK_KEY, taskKey);
if (taskReportId != null) {
bridge.putExtra(OperationListActivity.EXTRA_PENDING_DASH_TASK_REPORT_ID, taskReportId);
}
if (reportStartDate != null) {
bridge.putExtra(OperationListActivity.EXTRA_PENDING_DASH_REPORT_START_DATE, reportStartDate);
}
bridge.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(bridge);
// 一覧画面を経由しても遷移アニメーションを無効化して、直接遷移に見せる
overridePendingTransition(0, 0);
return;
}
OperationDao operationDao = AbstractDao.getDao(OperationDao.class); OperationDao operationDao = AbstractDao.getDao(OperationDao.class);
OperationDto operationDto = operationDao.getOperation(operationId); OperationDto operationDto = operationDao.getOperation(operationId);
// t_operationテーブルにcontent_idは含まれていないので、この時点でoperationDto.contentIdはnull // t_operationテーブルにcontent_idは含まれていないので、この時点でoperationDto.contentIdはnull
......
...@@ -106,6 +106,7 @@ public class OperationActivity extends ABVUIActivity { ...@@ -106,6 +106,7 @@ public class OperationActivity extends ABVUIActivity {
private void backHome() { private void backHome() {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setClass(this, OperationListActivity.class); intent.setClass(this, OperationListActivity.class);
intent.putExtra(OperationListActivity.EXTRA_RESUME_MODE, OperationListActivity.RESUME_NEW_CONTENT_ONLY);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent); startActivity(intent);
} }
......
...@@ -137,6 +137,15 @@ import static jp.agentec.abook.abv.ui.home.activity.CaptureQRCodeActivity.QRCODE ...@@ -137,6 +137,15 @@ import static jp.agentec.abook.abv.ui.home.activity.CaptureQRCodeActivity.QRCODE
public class OperationListActivity extends OperationActivity { public class OperationListActivity extends OperationActivity {
private static final String TAG = "OperationListActivity"; private static final String TAG = "OperationListActivity";
/** 下ツールバー「ホーム」から遷移したときは新着更新のみ(作業同期は行わない) */
public static final String EXTRA_RESUME_MODE = "OperationListActivity.EXTRA_RESUME_MODE";
public static final String RESUME_NEW_CONTENT_ONLY = "resume_new_content_only";
/** ダッシュボードから作業報告へ進む前の新着+単一作業同期 */
public static final String EXTRA_PENDING_DASH_SYNC_OPERATION_ID = "OperationListActivity.EXTRA_PENDING_DASH_SYNC_OPERATION_ID";
public static final String EXTRA_PENDING_DASH_TASK_KEY = "OperationListActivity.EXTRA_PENDING_DASH_TASK_KEY";
public static final String EXTRA_PENDING_DASH_TASK_REPORT_ID = "OperationListActivity.EXTRA_PENDING_DASH_TASK_REPORT_ID";
public static final String EXTRA_PENDING_DASH_REPORT_START_DATE = "OperationListActivity.EXTRA_PENDING_DASH_REPORT_START_DATE";
private ImageButton mViewModeButton; // 左上 private ImageButton mViewModeButton; // 左上
private ImageButton mSearchButton; // 検索ボタン private ImageButton mSearchButton; // 検索ボタン
private ImageButton mCategoryLocationButton; // カテゴリ選択ボタン private ImageButton mCategoryLocationButton; // カテゴリ選択ボタン
...@@ -208,11 +217,16 @@ public class OperationListActivity extends OperationActivity { ...@@ -208,11 +217,16 @@ public class OperationListActivity extends OperationActivity {
public boolean mAutoSyncingFlg; public boolean mAutoSyncingFlg;
public Long mAutoSyncOpenOperationId = null; public Long mAutoSyncOpenOperationId = null;
public Long mAutoSyncScopeOperationId = null;
public Long mQrCodeOperationId = null; public Long mQrCodeOperationId = null;
private ListView mOperationPushMessageListView; private ListView mOperationPushMessageListView;
private Long mSyncTargetOperationId = null; private Long mSyncTargetOperationId = null;
private String mPendingDashboardTaskKey = null;
private Long mPendingDashboardTaskReportId = null;
private String mPendingDashboardReportStartDate = null;
// ビューの作成 // ビューの作成
private class ReloadHandler implements Runnable { private class ReloadHandler implements Runnable {
@Override @Override
...@@ -494,58 +508,56 @@ public class OperationListActivity extends OperationActivity { ...@@ -494,58 +508,56 @@ public class OperationListActivity extends OperationActivity {
//上部の未読プッシュメッセージ一覧リロード //上部の未読プッシュメッセージ一覧リロード
reloadOperationPushMessageListView(); reloadOperationPushMessageListView();
if (isAutoSync()) { if (mAutoSyncingFlg) {
if (mAutoSyncingFlg) { if (result) {
if (result) { // content update success
// content update success List<OperationDto> needSyncOperationList = new ArrayList<>();
List<OperationDto> needSyncOperationList = new ArrayList<>(); if (mAutoSyncScopeOperationId != null) {
if (mAutoSyncOpenOperationId != null) { OperationDto operationDto = mOperationLogic.getOperation(mAutoSyncScopeOperationId);
OperationDto operationDto = mOperationLogic.getOperation(mAutoSyncOpenOperationId); if (operationDto != null && operationDto.needSyncFlg) {
if (operationDto != null && operationDto.needSyncFlg) { needSyncOperationList.add(operationDto);
needSyncOperationList.add(operationDto);
}
} else {
needSyncOperationList.addAll(mOperationDao.getNeedSyncAllOperation());
} }
List<OperationDto> needSyncCheckArray = mOperationLogic.needSyncCheckArray(needSyncOperationList); } else {
needSyncOperationList.addAll(mOperationDao.getNeedSyncAllOperation());
}
List<OperationDto> needSyncCheckArray = needSyncOperationList;
if (mSyncTargetOperationId != null && mSyncTargetOperationId != -1) { if (mSyncTargetOperationId != null && mSyncTargetOperationId != -1) {
if (ABVDataCache.getInstance().serviceOption.isUnableIOReport()) { if (ABVDataCache.getInstance().serviceOption.isUnableIOReport()) {
List<OperationDto> categorySyncOperationList = mListHelper.getNeedSyncOperationList(); List<OperationDto> categorySyncOperationList = mListHelper.getNeedSyncOperationList();
needSyncCheckArray.addAll(categorySyncOperationList); needSyncCheckArray.addAll(categorySyncOperationList);
}
OperationDto operationDto = mOperationLogic.getOperation(mSyncTargetOperationId);
if (operationDto != null && operationDto.needSyncFlg) {
needSyncCheckArray.add(operationDto);
}
mSyncTargetOperationId = null;
needSyncCheckArray = mOperationLogic.deduplicateOperationDto(needSyncCheckArray);
} }
Logger.i("needSyncCheckArray.size() = " + needSyncCheckArray.size() + ", mSyncTargetOperationId = " + mSyncTargetOperationId); OperationDto operationDto = mOperationLogic.getOperation(mSyncTargetOperationId);
if (needSyncCheckArray.size() > 0) { if (operationDto != null && operationDto.needSyncFlg) {
categoryBatchSync(needSyncCheckArray); needSyncCheckArray.add(operationDto);
} else {
// donot need sync
autoSyncOperationDone(true);
} }
mSyncTargetOperationId = null;
needSyncCheckArray = mOperationLogic.deduplicateOperationDto(needSyncCheckArray);
}
Logger.i("needSyncCheckArray.size() = " + needSyncCheckArray.size() + ", mSyncTargetOperationId = " + mSyncTargetOperationId);
if (needSyncCheckArray.size() > 0) {
categoryBatchSync(needSyncCheckArray);
} else { } else {
// content update fail // donot need sync
autoSyncOperationDone(false); autoSyncOperationDone(true);
} }
} else {
// content update fail
autoSyncOperationDone(false);
} }
return; return;
} }
//「I/O 帳票使用」がYESのみ、新着更新処理完了後、一括同期処理を開始する。 //「I/O 帳票使用」がYESのみ、新着更新処理完了後、一括同期処理を開始する。
if (ABVDataCache.getInstance().serviceOption.isUnableIOReport()) { // if (ABVDataCache.getInstance().serviceOption.isUnableIOReport()) {
if (mAutoBatchSyncFlg) { // if (mAutoBatchSyncFlg) {
closeProgressPopup(); // closeProgressPopup();
List<OperationDto> needSyncOperationList = mListHelper.getNeedSyncOperationList(); // List<OperationDto> needSyncOperationList = mListHelper.getNeedSyncOperationList();
if (needSyncOperationList.size() != 0) { // if (needSyncOperationList.size() != 0) {
categoryBatchSync(needSyncOperationList); // categoryBatchSync(needSyncOperationList);
} // }
mAutoBatchSyncFlg = false; // mAutoBatchSyncFlg = false;
} // }
} // }
} }
} }
}); });
...@@ -560,87 +572,81 @@ public class OperationListActivity extends OperationActivity { ...@@ -560,87 +572,81 @@ public class OperationListActivity extends OperationActivity {
} }
@Override @Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
/**
* ツールバー経由「新着のみ」の指定を Intent から取り出して消費する。
*/
private boolean consumeToolbarResume(Intent intent) {
if (intent == null) {
return false;
}
String mode = intent.getStringExtra(EXTRA_RESUME_MODE);
if (RESUME_NEW_CONTENT_ONLY.equals(mode)) {
intent.removeExtra(EXTRA_RESUME_MODE);
return true;
}
return false;
}
@Override
public void onResume() { public void onResume() {
Logger.i(TAG, "onResume:start"); Logger.i(TAG, "onResume:start");
super.onResume(); super.onResume();
Intent intent = getIntent();
long pendingDashSyncOpId = intent.getLongExtra(EXTRA_PENDING_DASH_SYNC_OPERATION_ID, -1L);
if (pendingDashSyncOpId != -1L) {
mPendingDashboardTaskKey = intent.getStringExtra(EXTRA_PENDING_DASH_TASK_KEY);
long pendingTaskReportId = intent.getLongExtra(EXTRA_PENDING_DASH_TASK_REPORT_ID, -1L);
mPendingDashboardTaskReportId = pendingTaskReportId == -1L ? null : pendingTaskReportId;
mPendingDashboardReportStartDate = intent.getStringExtra(EXTRA_PENDING_DASH_REPORT_START_DATE);
intent.removeExtra(EXTRA_PENDING_DASH_SYNC_OPERATION_ID);
intent.removeExtra(EXTRA_PENDING_DASH_TASK_KEY);
intent.removeExtra(EXTRA_PENDING_DASH_TASK_REPORT_ID);
intent.removeExtra(EXTRA_PENDING_DASH_REPORT_START_DATE);
putUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L);
activityResultFlg = false;
// ダッシュボード経由時は一覧の再描画を抑止し、画面ちらつきを減らす
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
autoSyncOperationId(pendingDashSyncOpId);
}
return;
}
refreshOperationList(); refreshOperationList();
boolean toolbarResumeNewContentOnly = consumeToolbarResume(intent);
final long operationId = getUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L); final long operationId = getUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L);
// 作業指示・報告からプロジェクト一覧へ戻った時の同期処理
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) { if (toolbarResumeNewContentOnly) {
if (isAutoSync()) { putUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L);
mSyncTargetOperationId = operationId; activityResultFlg = false;
// delay for showProgressView configurationToolbarIcon();
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
handler.postDelayed(new Runnable() { handler.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
autoSyncOperation(); dataRefresh(true);
} }
}, 100); }, 100);
}
return;
}
} else { // 作業指示・報告からプロジェクト一覧へ戻った時の同期処理など
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
if (operationId != -1) { mSyncTargetOperationId = operationId;
final OperationDto operationDto = mOperationLogic.getOperation(operationId); handler.postDelayed(new Runnable() {
// リソースパターンの適用 @Override
showProgressView(PatternStringUtil.patternToString(getApplicationContext(), public void run() {
R.string.synchronizing, autoSyncOperation();
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
Logger.d(TAG, "onResume Sync operationId : " + operationId);
//報告画面からすでに同期処理を行っているため、needSyncFlgチェックは除外
if (operationDto != null) {
// 同期処理後、直列処理で新着更新を行う。
singleSyncOperation(operationId, operationDto.reportType);
//「I/O 帳票使用」がYESのみ、カテゴリ一括動機実施
if (ABVDataCache.getInstance().serviceOption.isUnableIOReport()) {
//同期中のインジケーター表示中には新着更新中のインジケーター表示できないので、チェックする。
while (progressDialogHorizontalShowing()) {
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
Logger.e(TAG, "sleep error = " + ie.getLocalizedMessage());
}
}
//新着更新後、一括同期処理を行うため、インジケーター表示
handler.post(new Runnable() {
@Override
public void run() {
showProgressPopup(PatternStringUtil.patternToString(getApplicationContext(),
R.string.updating,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
}
});
mAutoBatchSyncFlg = true;
//表示作業数が10個以上の場合、2秒待機してから新着更新を行う。10個未満は1秒待機
List<OperationDto> operationList = mListHelper.getOperationList();
int delaySeconds = 1000;
if (operationList.size() >= DELAY_2SECONDS_OPERATION_MAX_COUNT) {
delaySeconds = 2000;
}
handler.postDelayed(new Runnable() {
@Override
public void run() {
dataRefresh(true);
}
}, delaySeconds);
}
} else {
closeProgressPopup();
dataRefresh(true);
}
}
});
}
if (!activityResultFlg && operationId == -1) {
dataRefresh(true);
} }
} }, 100);
} }
putUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L); putUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L);
activityResultFlg = false; activityResultFlg = false;
...@@ -1465,7 +1471,7 @@ public class OperationListActivity extends OperationActivity { ...@@ -1465,7 +1471,7 @@ public class OperationListActivity extends OperationActivity {
return; return;
} }
//有効なスキームチェック //有効なスキームチェック
if (url != null && url.startsWith(OPERATION_QRCODE_SCHEME)){ if (url.startsWith(OPERATION_QRCODE_SCHEME)){
Uri operationUrl = Uri.parse(url); Uri operationUrl = Uri.parse(url);
String operationIdStr = operationUrl.getQueryParameter(QRCODE_OPERATION_ID); String operationIdStr = operationUrl.getQueryParameter(QRCODE_OPERATION_ID);
if (operationIdStr == null) { if (operationIdStr == null) {
...@@ -1478,26 +1484,16 @@ public class OperationListActivity extends OperationActivity { ...@@ -1478,26 +1484,16 @@ 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()) { if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
autoSyncOperationId(operationId); ContentDto contentDto = contentDao.getContent(operationDto.contentId);
return; if (contentDto == null || !contentDto.downloadedFlg || contentDto.updatedFlg) {
} showErrorDialog(R.string.msg_qrcode_disconnect_content_download);
if (operationDto.needSyncFlg) { } else {
//インターネット非接続時にはアラート表示 openReportView(operationDto);
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; return;
startSyncOperation(operationDto);
} else {
openReportView(operationDto);
} }
autoSyncNeedSyncAndOpenOperationId(operationId);
} }
} else { } else {
showErrorDialog(R.string.msg_qrcode_not_operation_format); showErrorDialog(R.string.msg_qrcode_not_operation_format);
...@@ -1853,10 +1849,6 @@ public class OperationListActivity extends OperationActivity { ...@@ -1853,10 +1849,6 @@ 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() {
...@@ -1894,10 +1886,6 @@ public class OperationListActivity extends OperationActivity { ...@@ -1894,10 +1886,6 @@ 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() {
...@@ -2399,13 +2387,6 @@ public class OperationListActivity extends OperationActivity { ...@@ -2399,13 +2387,6 @@ public class OperationListActivity extends OperationActivity {
} }
} }
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 * Run refresh data and batch sync if need
*/ */
...@@ -2431,6 +2412,27 @@ public class OperationListActivity extends OperationActivity { ...@@ -2431,6 +2412,27 @@ public class OperationListActivity extends OperationActivity {
* @param operationId * @param operationId
*/ */
public void autoSyncOperationId(Long operationId) { public void autoSyncOperationId(Long operationId) {
mAutoSyncScopeOperationId = operationId;
mAutoSyncOpenOperationId = operationId;
autoSyncOperation();
}
/**
* ダッシュボードから指定した報告入力へ進むための同期起動。
* 一覧画面を前面表示せず、必要情報だけ保持して同期を実行する。
*/
public void autoSyncOperationIdFromDashboard(Long operationId, String taskKey, Long taskReportId, String reportStartDate) {
mPendingDashboardTaskKey = taskKey;
mPendingDashboardTaskReportId = taskReportId;
mPendingDashboardReportStartDate = reportStartDate;
autoSyncOperationId(operationId);
}
/**
* QR・プッシュ等で選択した作業のみ同期し、完了後に報告へ進む。
*/
public void autoSyncNeedSyncAndOpenOperationId(Long operationId) {
mAutoSyncScopeOperationId = operationId;
mAutoSyncOpenOperationId = operationId; mAutoSyncOpenOperationId = operationId;
autoSyncOperation(); autoSyncOperation();
} }
...@@ -2446,12 +2448,58 @@ public class OperationListActivity extends OperationActivity { ...@@ -2446,12 +2448,58 @@ public class OperationListActivity extends OperationActivity {
if (mAutoSyncOpenOperationId != null) { if (mAutoSyncOpenOperationId != null) {
OperationDto operationDto = mOperationLogic.getOperation(mAutoSyncOpenOperationId); OperationDto operationDto = mOperationLogic.getOperation(mAutoSyncOpenOperationId);
if (operationDto != null && operationDto.contentId != null && operationDto.contentId != 0) { if (operationDto != null && operationDto.contentId != null && operationDto.contentId != 0) {
openReportView(operationDto); if (mPendingDashboardTaskKey != null) {
openDashboardReportView(operationDto, mPendingDashboardTaskKey, mPendingDashboardTaskReportId, mPendingDashboardReportStartDate);
} else {
openReportView(operationDto);
}
} }
} }
} }
mAutoSyncOpenOperationId = null; mAutoSyncOpenOperationId = null;
mAutoSyncScopeOperationId = null;
mSyncTargetOperationId = null; mSyncTargetOperationId = null;
mPendingDashboardTaskKey = null;
mPendingDashboardTaskReportId = null;
mPendingDashboardReportStartDate = null;
}
/**
* ダッシュボードで選択した報告入力画面へ直接遷移する。
*/
private void openDashboardReportView(OperationDto operationDto, String taskKey, Long taskReportId, String reportStartDate) {
ContentDto contentDto = contentDao.getContent(operationDto.contentId);
try {
if (contentDto == null || !contentDto.downloadedFlg) {
Logger.w(TAG, "content is not download");
return;
}
String contentPath = ABVEnvironment.getInstance().getTaskListDirName(
ContentFileExtractor.getInstance().getContentCacheDirWithExtract(contentDto.contentId));
mOperationLogic.createJsonForOperationContent(operationDto.operationId, contentPath, operationDto.reportType == ReportType.RoutineTask);
StringBuilder path = new StringBuilder();
path.append(contentPath);
path.append("/index.html?app=android");
path.append("&report_type=").append(operationDto.reportType);
path.append("&mobile_flg=").append(isNormalSize() ? "1" : "0");
path.append("&taskKey=").append(taskKey);
if (operationDto.reportType == ReportType.RoutineTask && taskReportId != null && reportStartDate != null) {
path.append("&taskReportId=").append(taskReportId);
path.append("&reportStartDate=").append(reportStartDate);
}
Intent intent = new Intent();
intent.putExtra(ABookKeys.CONTENT_ID, operationDto.contentId);
intent.putExtra(ABookKeys.OPERATION_ID, operationDto.operationId);
intent.putExtra(Constant.ABookCheck.XWALK_OPEN_TYPE, Constant.XWalkOpenType.TASK_REPORT);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
ActivityHandlingHelper.getInstance().startHTMLWebActivity(this, intent, "file://" + path, contentDto.contentId, -1, -1, -1, -1, -1);
} catch (Exception e) {
Logger.e(TAG, e);
handleErrorMessageToast(ErrorCode.E107);
}
} }
/** /**
...@@ -2472,19 +2520,17 @@ public class OperationListActivity extends OperationActivity { ...@@ -2472,19 +2520,17 @@ public class OperationListActivity extends OperationActivity {
@Override @Override
public void onMoveOperation(Long operationId) { public void onMoveOperation(Long operationId) {
Logger.d(TAG, "onMoveOperation operationId = " + operationId); Logger.d(TAG, "onMoveOperation operationId = " + operationId);
if (needAutoSync()) { if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
autoSyncOperationId(operationId);
} else {
OperationDto operationDto = mOperationLogic.getOperation(operationId); OperationDto operationDto = mOperationLogic.getOperation(operationId);
ContentDto contentDto = contentDao.getContent(operationDto.contentId); ContentDto contentDto = contentDao.getContent(operationDto.contentId);
if (contentDto == null || !contentDto.downloadedFlg || contentDto.updatedFlg) { if (contentDto == null || !contentDto.downloadedFlg || contentDto.updatedFlg) {
showErrorDialog(R.string.msg_push_message_content_not_downloaded); showErrorDialog(R.string.msg_push_message_content_not_downloaded);
} else { } else if (operationDto != null && operationDto.contentId != null && operationDto.contentId != 0) {
if (operationDto != null && operationDto.contentId != null && operationDto.contentId != 0) { openReportView(operationDto);
openReportView(operationDto);
}
} }
return;
} }
autoSyncNeedSyncAndOpenOperationId(operationId);
} }
}); });
......
...@@ -116,17 +116,8 @@ public class OperationListAdapter extends AbstractOperationAdapter { ...@@ -116,17 +116,8 @@ public class OperationListAdapter extends AbstractOperationAdapter {
holder.tvDate.setText(DateTimeUtil.toString(operationDto.operationStartDate, DateTimeFormat.yyyyMMdd_slash) + " ~ " + DateTimeUtil.toString(operationDto.operationEndDate, DateTimeFormat.yyyyMMdd_slash)); holder.tvDate.setText(DateTimeUtil.toString(operationDto.operationStartDate, DateTimeFormat.yyyyMMdd_slash) + " ~ " + DateTimeUtil.toString(operationDto.operationEndDate, DateTimeFormat.yyyyMMdd_slash));
} }
// 同期ボタン表示・非表示 // 作業別の同期ボタンは表示しない仕様
if (operationDto.contentId != null && operationDto.contentId != 0) { holder.ivSync.setVisibility(View.GONE);
if (operationDto.needSyncFlg) {
holder.ivSync.setVisibility(View.VISIBLE);
} else {
holder.ivSync.setVisibility(View.INVISIBLE);
}
} else {
// プロジェクトのコンテンツが存在しない場合は、同期ボタンを非活性化する
holder.ivSync.setVisibility(View.INVISIBLE);
}
holder.reportCountNotStarted.setText(String.valueOf(operationDto.statusNotStartedCount)); holder.reportCountNotStarted.setText(String.valueOf(operationDto.statusNotStartedCount));
holder.reportCountWorking.setText(String.valueOf(operationDto.statusWorkingCount)); holder.reportCountWorking.setText(String.valueOf(operationDto.statusWorkingCount));
...@@ -139,13 +130,6 @@ public class OperationListAdapter extends AbstractOperationAdapter { ...@@ -139,13 +130,6 @@ public class OperationListAdapter extends AbstractOperationAdapter {
listener.openReport(operationDto); listener.openReport(operationDto);
} }
}); });
// 同期ボタンのタップイベント
holder.ivSync.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onSyncOperation(operationDto);
}
});
} }
return convertView; return convertView;
......
...@@ -142,18 +142,8 @@ public class OperationPanelAdapter extends AbstractOperationAdapter { ...@@ -142,18 +142,8 @@ public class OperationPanelAdapter extends AbstractOperationAdapter {
holder.tvDate.setText(DateTimeUtil.toString(operationDto.operationStartDate, DateTimeFormat.yyyyMMdd_slash) + " ~ " + DateTimeUtil.toString(operationDto.operationEndDate, DateTimeFormat.yyyyMMdd_slash)); holder.tvDate.setText(DateTimeUtil.toString(operationDto.operationStartDate, DateTimeFormat.yyyyMMdd_slash) + " ~ " + DateTimeUtil.toString(operationDto.operationEndDate, DateTimeFormat.yyyyMMdd_slash));
} }
// 同期ボタン表示・非表示 // 作業別の同期ボタンは表示しない仕様
if (operationDto.contentId != null && operationDto.contentId != 0) { holder.ivSync.setVisibility(View.GONE);
if ((operationDto.needSyncFlg)) {
holder.ivSync.setVisibility(View.VISIBLE);
} else {
// 定期点検プロジェクトではない場合、同期ボタンを非活性化する
holder.ivSync.setVisibility(View.INVISIBLE);
}
} else {
// プロジェクトのコンテンツが存在しない場合は、同期ボタンを非活性化する
holder.ivSync.setVisibility(View.INVISIBLE);
}
holder.reportCountNotStarted.setText(String.valueOf(operationDto.statusNotStartedCount)); holder.reportCountNotStarted.setText(String.valueOf(operationDto.statusNotStartedCount));
holder.reportCountWorking.setText(String.valueOf(operationDto.statusWorkingCount)); holder.reportCountWorking.setText(String.valueOf(operationDto.statusWorkingCount));
...@@ -167,13 +157,6 @@ public class OperationPanelAdapter extends AbstractOperationAdapter { ...@@ -167,13 +157,6 @@ public class OperationPanelAdapter extends AbstractOperationAdapter {
} }
}); });
// 同期ボタンのタップイベント
holder.ivSync.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onSyncOperation(operationDto);
}
});
} }
return convertView; return convertView;
......
...@@ -12,6 +12,7 @@ import java.util.ArrayList; ...@@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException; import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.OperationDto; import jp.agentec.abook.abv.bl.dto.OperationDto;
...@@ -264,7 +265,7 @@ public abstract class OperationListHelper { ...@@ -264,7 +265,7 @@ public abstract class OperationListHelper {
abstract protected List<OperationDto> findOperationList() throws Exception; abstract protected List<OperationDto> findOperationList() throws Exception;
public void onClickReport(OperationDto operationDto) { public void onClickReport(OperationDto operationDto) {
if (mAppActivity.needAutoSync()) { if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
mAppActivity.autoSyncOperationId(operationDto.operationId); mAppActivity.autoSyncOperationId(operationDto.operationId);
return; return;
} }
......
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