Commit 9ba619f9 by NGUYEN HOANG SON

implement CMD 'saveJson'

parent 705ee87e
...@@ -101,6 +101,7 @@ public class ABookKeys { ...@@ -101,6 +101,7 @@ public class ABookKeys {
public static final String REFRESH_CONTENT = "refreshContent"; public static final String REFRESH_CONTENT = "refreshContent";
public static final String RESET_SEARCH = "resetSearch"; public static final String RESET_SEARCH = "resetSearch";
public static final String CHANGE_OPERATION_GROUP_MASTER = "changeOperationGroupMaster"; public static final String CHANGE_OPERATION_GROUP_MASTER = "changeOperationGroupMaster";
public static final String SAVE_JSON = "saveJson";
} }
...@@ -236,4 +237,8 @@ public class ABookKeys { ...@@ -236,4 +237,8 @@ public class ABookKeys {
public static final String CMD_GET_DEVICE_INFO = "getDeviceInfo"; // CMSのインターフェースのパラメータ:cmd public static final String CMD_GET_DEVICE_INFO = "getDeviceInfo"; // CMSのインターフェースのパラメータ:cmd
public static final String TASK_DEVICE_TYPE = "deviceType"; // CMSのインターフェースのパラメータ:devicetype public static final String TASK_DEVICE_TYPE = "deviceType"; // CMSのインターフェースのパラメータ:devicetype
public static final String TASK_QUESTION_ID = "qid"; // CMSのインターフェースのパラメータ:qid public static final String TASK_QUESTION_ID = "qid"; // CMSのインターフェースのパラメータ:qid
public static final String JSON_NAME = "jsonName";
public static final String JSON_DATA = "jsonData";
} }
...@@ -16,6 +16,7 @@ import android.view.Window; ...@@ -16,6 +16,7 @@ import android.view.Window;
import android.webkit.JavascriptInterface; import android.webkit.JavascriptInterface;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
...@@ -168,6 +169,17 @@ public class OperationListActivity extends ABVUIActivity { ...@@ -168,6 +169,17 @@ public class OperationListActivity extends ABVUIActivity {
mCheckWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); //オーバースクロールしない。 mCheckWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); //オーバースクロールしない。
mCheckWebView.setVerticalScrollBarEnabled(false); //スクロールバーを消す。 mCheckWebView.setVerticalScrollBarEnabled(false); //スクロールバーを消す。
mCheckWebView.addJavascriptInterface(jsInf, "android"); mCheckWebView.addJavascriptInterface(jsInf, "android");
mCheckWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//fix FileUriExposedException error when webview load url with file://
// if (Uri.parse(url).getScheme().equals("file")) {
// view.loadUrl(url);
// return true;
// }
return super.shouldOverrideUrlLoading(view, url);
}
});
if (Logger.isDebugEnabled()) { if (Logger.isDebugEnabled()) {
mCheckWebView.setWebContentsDebuggingEnabled(true); mCheckWebView.setWebContentsDebuggingEnabled(true);
} }
...@@ -391,6 +403,11 @@ public class OperationListActivity extends ABVUIActivity { ...@@ -391,6 +403,11 @@ public class OperationListActivity extends ABVUIActivity {
} }
}); });
break; break;
case ABookKeys.CMD_KEY.SAVE_JSON:
if (jsonParam.has(ABookKeys.JSON_NAME)) {
saveJson(jsonParam.getString(ABookKeys.JSON_NAME), jsonParam.getString(ABookKeys.JSON_DATA));
}
break;
} }
} }
} }
...@@ -1731,4 +1748,17 @@ public class OperationListActivity extends ABVUIActivity { ...@@ -1731,4 +1748,17 @@ public class OperationListActivity extends ABVUIActivity {
}); });
} }
} }
private void saveJson(String jsonName, String jsonData) {
if (StringUtil.isNullOrEmpty(jsonName)) {
Logger.d(TAG,"saveJson:jsonName is null or empty");
return;
}
String filePath = getCacheDir().getAbsolutePath() + "/" + jsonName;
try {
FileUtil.createFile(filePath, jsonData);
} catch (IOException 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