Commit f87bac92 by Kazuyuki Hida

ダッシュボードの件数表示と一覧表示の不具合を修正

parent f6eef977
Subproject commit 8f1954b9979d4a4f494c8f6a04ab454732e7208b Subproject commit 39a8f243e91a4a70143ef6cfe7ba33807de9cdfb
...@@ -2,7 +2,6 @@ package jp.agentec.abook.abv.ui.home.activity; ...@@ -2,7 +2,6 @@ package jp.agentec.abook.abv.ui.home.activity;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
...@@ -19,11 +18,12 @@ import android.widget.ProgressBar; ...@@ -19,11 +18,12 @@ import android.widget.ProgressBar;
import org.json.adf.JSONArray; import org.json.adf.JSONArray;
import org.json.adf.JSONObject; import org.json.adf.JSONObject;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import jp.agentec.abook.abv.bl.acms.type.OperationType; import jp.agentec.abook.abv.bl.acms.type.OperationType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment; import jp.agentec.abook.abv.bl.common.ABVEnvironment;
...@@ -74,11 +74,10 @@ import static jp.agentec.abook.abv.bl.common.constant.ABookKeys.CMD_UNLOCK_REPOR ...@@ -74,11 +74,10 @@ import static jp.agentec.abook.abv.bl.common.constant.ABookKeys.CMD_UNLOCK_REPOR
public class DashboardActivity extends OperationActivity { public class DashboardActivity extends OperationActivity {
private static final String TAG = "DashboardActivity"; private static final String TAG = "DashboardActivity";
private static final String DASHBOARD_URL = "file:///android_asset/dashboard/app/index.html"; private static final String DASHBOARD_URL = "file:///android_asset/dashboard/app/index.html?app=android";
private WebView webView; private WebView webView;
private ProgressBar progress; private ProgressBar progress;
private boolean countInitialized = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -106,6 +105,16 @@ public class DashboardActivity extends OperationActivity { ...@@ -106,6 +105,16 @@ public class DashboardActivity extends OperationActivity {
} }
@Override @Override
protected void onResume() {
super.onResume();
try {
getReportStatusCount();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
if (webView != null) { if (webView != null) {
...@@ -145,6 +154,8 @@ public class DashboardActivity extends OperationActivity { ...@@ -145,6 +154,8 @@ public class DashboardActivity extends OperationActivity {
webView.setWebViewClient(new ViewClient()); webView.setWebViewClient(new ViewClient());
webView.addJavascriptInterface(new JsInf(), "android"); webView.addJavascriptInterface(new JsInf(), "android");
webView.getSettings().setJavaScriptEnabled(true); // JavaScriptを有効にする
Logger.d(TAG, "loadUrl: " + DASHBOARD_URL); Logger.d(TAG, "loadUrl: " + DASHBOARD_URL);
} }
...@@ -155,7 +166,7 @@ public class DashboardActivity extends OperationActivity { ...@@ -155,7 +166,7 @@ public class DashboardActivity extends OperationActivity {
settings.setLoadsImagesAutomatically(true); // イメージを自動的にロードする settings.setLoadsImagesAutomatically(true); // イメージを自動的にロードする
settings.setBuiltInZoomControls(true); // ズーム機能を有効にする settings.setBuiltInZoomControls(true); // ズーム機能を有効にする
settings.setSupportZoom(true); // ズーム機能を有効にする settings.setSupportZoom(true); // ズーム機能を有効にする
settings.setJavaScriptEnabled(true); // JavaScriptを有効にする //settings.setJavaScriptEnabled(true); // JavaScriptを有効にする
settings.setLoadWithOverviewMode(true); // 画面の横幅にページの横幅を合わせる settings.setLoadWithOverviewMode(true); // 画面の横幅にページの横幅を合わせる
settings.setUseWideViewPort(true); // 画面の横幅にページの横幅を合わせる settings.setUseWideViewPort(true); // 画面の横幅にページの横幅を合わせる
//noinspection deprecation(API18から非推奨になった。無視) //noinspection deprecation(API18から非推奨になった。無視)
...@@ -218,12 +229,28 @@ public class DashboardActivity extends OperationActivity { ...@@ -218,12 +229,28 @@ public class DashboardActivity extends OperationActivity {
} }
@JavascriptInterface @JavascriptInterface
public void getAttachedDataUrl(String taskKey, String data) { public String getCachePath() {
//commonAttachedDataUrl(taskKey, data); return getCacheDir().getAbsolutePath();
} }
@JavascriptInterface
public void sendParam(String param) {
Logger.i(TAG, "sendParam: %s", param);
final JSONObject json = new JSONObject(param);
runOnUiThread(new Runnable() {
@Override
public void run() {
checkApiLoading(json);
}
});
} }
private class ViewClient extends WebViewClient { @JavascriptInterface
public void getAttachedDataUrl(String taskKey, String data) {}
}
private static class ViewClient extends WebViewClient {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
...@@ -234,86 +261,60 @@ public class DashboardActivity extends OperationActivity { ...@@ -234,86 +261,60 @@ public class DashboardActivity extends OperationActivity {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
Logger.v(TAG, "shouldOverrideUrlLoading: %s", url); Logger.v(TAG, "shouldOverrideUrlLoading: %s", url);
if (url.startsWith("abook")) {
final Uri uri = Uri.parse(url);
// AndroidOSが5以下のPANO_SERVER処理のため、置き換える必要がある。
url = "/" + url;
if (url.contains(ABookKeys.ABOOK_CHECK_API)) {
return checkApiLoding(uri);
}
return true;
}
return false; return false;
} }
} }
private boolean checkApiLoding(Uri uri) { private void checkApiLoading(JSONObject json) {
Map<String, String> param = new HashMap<>();
for (String key : uri.getQueryParameterNames()) {
param.put(key, uri.getQueryParameter(key));
}
String cmd = param.get(ABookKeys.CMD); String cmd = json.getString(ABookKeys.CMD);
if (cmd == null) { if (cmd == null) {
return false; return;
} }
try { try {
switch (cmd) { switch (cmd) {
case CMD_GET_REPORT_STATUS_COUNT: { case CMD_GET_REPORT_STATUS_COUNT: {
countInitialized = true;
return getReportStatusCount();
}
case CMD_GET_REPORT_LIST: {
if (! countInitialized) {
countInitialized = true;
getReportStatusCount(); getReportStatusCount();
break;
} }
String reportStatusId = param.get(ReportStatusId); case CMD_GET_REPORT_LIST: {
if (reportStatusId != null) { int reportStatusId = json.getInt(ReportStatusId);
return getReportList(Integer.parseInt(reportStatusId)); getReportList(reportStatusId);
} else { break;
return false;
}
} }
case CMD_GO_REPORT_DETAIL: { case CMD_GO_REPORT_DETAIL: {
Long operationId = getLongOrNull(param.get(OperationId)); long operationId = json.getLong(OperationId);
if (operationId == null) { goReportDetail(operationId);
return true; break;
} else {
return goReportDetail(operationId);
}
} }
case CMD_LOCK_REPORT: { case CMD_LOCK_REPORT: {
String taskKey = param.get(TaskKey); String taskKey = json.getString(TaskKey);
Long taskReportId = getLongOrNull(param.get(TaskReportId)); long taskReportId = json.getLong(TaskReportId);
Date reportStartDate = getDateOrNull(param.get(ReportStartDate)); Date reportStartDate = getDateOrNull(json.getString(ReportStartDate));
return lockReport(taskKey, taskReportId, reportStartDate); lockReport(taskKey, taskReportId, reportStartDate);
break;
} }
case CMD_UNLOCK_REPORT: { case CMD_UNLOCK_REPORT: {
String taskKey = param.get(TaskKey); String taskKey = json.getString(TaskKey);
Long taskReportId = getLongOrNull(param.get(TaskReportId)); long taskReportId = json.getLong(TaskReportId);
Date reportStartDate = getDateOrNull(param.get(ReportStartDate)); Date reportStartDate = getDateOrNull(json.getString(ReportStartDate));
return unlockReport(taskKey, taskReportId, reportStartDate); unlockReport(taskKey, taskReportId, reportStartDate);
break;
} }
} }
} catch (Throwable e) { } catch (Throwable e) {
Logger.e(TAG, e.getLocalizedMessage()); Logger.e(TAG, e);
return false;
} }
return false;
} }
private boolean getReportStatusCount() { private void getReportStatusCount() throws IOException {
ReportStatusDao dao = AbstractDao.getDao(ReportStatusDao.class); ReportStatusDao dao = AbstractDao.getDao(ReportStatusDao.class);
JSONObject extParam = dao.getReportStatusCountJson(); JSONObject extParam = dao.getReportStatusCountJson();
afterABookCheckApi(CMD_GET_REPORT_STATUS_COUNT, "", 0,"", extParam.toString()); saveCounts(extParam);
return true;
} }
private boolean getReportList(int reportStatusId) { private void getReportList(int reportStatusId) {
ReportStatusDao dao = AbstractDao.getDao(ReportStatusDao.class); ReportStatusDao dao = AbstractDao.getDao(ReportStatusDao.class);
List<ReportStatusDto> reports = null; List<ReportStatusDto> reports = null;
switch (reportStatusId) { switch (reportStatusId) {
...@@ -353,9 +354,6 @@ public class DashboardActivity extends OperationActivity { ...@@ -353,9 +354,6 @@ public class DashboardActivity extends OperationActivity {
JSONObject param = makeReportTree(reportStatusId, reports); JSONObject param = makeReportTree(reportStatusId, reports);
String script = "javascript:CHK_Dashboard.reportListCallback(" + reportStatusId + "," + param.toString() + ")"; String script = "javascript:CHK_Dashboard.reportListCallback(" + reportStatusId + "," + param.toString() + ")";
webView.loadUrl(script); webView.loadUrl(script);
return true;
} else {
return false;
} }
} }
...@@ -395,9 +393,9 @@ public class DashboardActivity extends OperationActivity { ...@@ -395,9 +393,9 @@ public class DashboardActivity extends OperationActivity {
return tree; return tree;
} }
private boolean goReportDetail(long operationId) { private void goReportDetail(long operationId) {
if (ActivityHandlingHelper.getInstance().isMeetingConnected()) { if (ActivityHandlingHelper.getInstance().isMeetingConnected()) {
return true; return;
} }
// 新着更新を止める // 新着更新を止める
contentRefresher.stopRefresh(); contentRefresher.stopRefresh();
...@@ -442,7 +440,6 @@ public class DashboardActivity extends OperationActivity { ...@@ -442,7 +440,6 @@ public class DashboardActivity extends OperationActivity {
intent.setClass(this, HTMLXWalkWebViewActivity.class); intent.setClass(this, HTMLXWalkWebViewActivity.class);
ActivityHandlingHelper.getInstance().startHTMLXWalkWebActivity(this, intent, "file://" + path, contentDto.contentId, -1, -1, -1, -1, -1); ActivityHandlingHelper.getInstance().startHTMLXWalkWebActivity(this, intent, "file://" + path, contentDto.contentId, -1, -1, -1, -1, -1);
} }
return true;
} else { } else {
Logger.w(TAG, "content is not download"); Logger.w(TAG, "content is not download");
} }
...@@ -450,11 +447,9 @@ public class DashboardActivity extends OperationActivity { ...@@ -450,11 +447,9 @@ public class DashboardActivity extends OperationActivity {
Logger.e(TAG, e); Logger.e(TAG, e);
handleErrorMessageToast(ErrorCode.E107); handleErrorMessageToast(ErrorCode.E107);
} }
return false;
} }
private boolean lockReport(String taskKey, Long taskReportId, Date reportStartDate) { private void lockReport(String taskKey, Long taskReportId, Date reportStartDate) {
try { try {
LockReportLogic.Result r = LockReportLogic.newInstance().lock(taskKey, taskReportId, reportStartDate); LockReportLogic.Result r = LockReportLogic.newInstance().lock(taskKey, taskReportId, reportStartDate);
// JSコールバック // JSコールバック
...@@ -465,14 +460,12 @@ public class DashboardActivity extends OperationActivity { ...@@ -465,14 +460,12 @@ public class DashboardActivity extends OperationActivity {
r.getMessage(), r.getMessage(),
r.getExtParam().json() r.getExtParam().json()
); );
return true;
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
return false;
} }
} }
private boolean unlockReport(String taskKey, Long taskReportId, Date reportStartDate) { private void unlockReport(String taskKey, Long taskReportId, Date reportStartDate) {
try { try {
UnlockReportLogic.Result r = UnlockReportLogic.newInstance().unlock(taskKey, taskReportId, reportStartDate); UnlockReportLogic.Result r = UnlockReportLogic.newInstance().unlock(taskKey, taskReportId, reportStartDate);
// JSコールバック // JSコールバック
...@@ -483,10 +476,8 @@ public class DashboardActivity extends OperationActivity { ...@@ -483,10 +476,8 @@ public class DashboardActivity extends OperationActivity {
r.getMessage(), r.getMessage(),
r.getExtParam().json() r.getExtParam().json()
); );
return true;
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
return false;
} }
} }
...@@ -502,21 +493,28 @@ public class DashboardActivity extends OperationActivity { ...@@ -502,21 +493,28 @@ public class DashboardActivity extends OperationActivity {
}); });
} }
private Long getLongOrNull(String s) { private Date getDateOrNull(String s) {
try { try {
return Long.parseLong(s); return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMddHHmmss_hyphen);
} catch (Exception e) { } catch (Exception e) {
Logger.e(TAG, e.getLocalizedMessage()); Logger.e(TAG, e.getLocalizedMessage());
return null; return null;
} }
} }
private Date getDateOrNull(String s) { public String getCachePath() {
try { return getCacheDir().getAbsolutePath();
return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMddHHmmss_hyphen); }
} catch (Exception e) {
Logger.e(TAG, e.getLocalizedMessage()); private void saveCounts(JSONObject counts) throws IOException {
return null; File dir = new File(getCachePath());
File file = new File(dir, "getReportStatusCount.json");
try(FileWriter writer = new FileWriter(file)) {
writer.write(counts.toString());
} catch (Throwable e) {
Logger.e(TAG, e);
throw e;
} }
} }
} }
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