Translate files related to plugin-development
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/commit/bb374344 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/tree/bb374344 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/diff/bb374344 Branch: refs/heads/master Commit: bb374344014be817a1981fe54fe4a17479dff8bb Parents: edb0813 Author: Keiko Oda <keiko...@gmail.com> Authored: Thu Aug 2 00:15:13 2012 -0700 Committer: Keiko Oda <keiko...@gmail.com> Committed: Thu Aug 2 00:27:47 2012 -0700 ---------------------------------------------------------------------- .../guide/plugin-development/android/index.md | 154 ++++++++++++++ .../2.0.0/guide/plugin-development/bada/index.md | 74 +++++++ .../guide/plugin-development/blackberry/index.md | 138 +++++++++++++ docs/jp/2.0.0/guide/plugin-development/index.md | 111 ++++++++++ .../jp/2.0.0/guide/plugin-development/ios/index.md | 157 +++++++++++++++ .../2.0.0/guide/plugin-development/webos/index.md | 23 ++ .../plugin-development/windows-phone/index.md | 23 ++ 7 files changed, 680 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/bb374344/docs/jp/2.0.0/guide/plugin-development/android/index.md ---------------------------------------------------------------------- diff --git a/docs/jp/2.0.0/guide/plugin-development/android/index.md b/docs/jp/2.0.0/guide/plugin-development/android/index.md new file mode 100644 index 0000000..910c54e --- /dev/null +++ b/docs/jp/2.0.0/guide/plugin-development/android/index.md @@ -0,0 +1,154 @@ +--- +license: Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--- + +# Developing a Plugin on Android + +ãã©ã°ã¤ã³ã®éçºã«ã¯ã Cordova-Android ã®ã¢ã¼ããã¯ãã£ã®çè§£ãå¿ è¦ã§ãã +Cordova-Android 㯠Android WebView ã¨ããã«ä»å±ããã³ã¼ã«ããã¯ããæ§æããã¾ãã +ãããã®ãã©ã°ã¤ã³ã¯ config.xml ãã¡ã¤ã«å ã«ã¯ã©ã¹ãããã³ã°ã¨ãã¦è¡¨ããã¦ãã¾ãã + +ãã©ã°ã¤ã³ã¯ `Pluguin` ã¯ã©ã¹ãç¶æ¿ããå°ãªãã¨ã1ã¤ã® Java ã¯ã©ã¹ã«ãã£ã¦æ§æããã¾ãã +ãã©ã°ã¤ã³ã¯ `PluginResult` ãªãã¸ã§ã¯ããè¿ã `execute` ã¡ã½ããã **å¿ ã **å®è£ ããªããã°ãªãã¾ããã +å ãã¦ããã©ã°ã¤ã³ä½æã®ãã¹ããã©ã¯ãã£ã¹ã¨ãã¦ããã©ã°ã¤ã³ã¯ pause 㨠resume ã¤ãã³ãããµãã¼ãããã¾ããã©ã°ã¤ã³éã®ã¡ãã»ã¼ã¸ã®ããã¨ãããµãã¼ããã¦ããã¹ãã§ãã + +## ãã©ã°ã¤ã³ã¯ã©ã¹ã®ãããã³ã° + +ãã©ã°ã¤ã³ã® JavaScript é¨åã¯å¸¸ã« `cordova.exec` ã¡ã½ããã以ä¸ã®ããã«ä½¿ãã¾ã: + + exec(<successFunction>, <failFunction>, <service>, <action>, [<args>]); + +ãã㯠WebView ãã Android ãã¤ãã£ãå´ã¸ã®ãªã¯ã¨ã¹ããæ´çãã +ããããè¦ç´ãã㨠`service` ã¯ã©ã¹ã§ `action` ã¡ã½ãããã +`args` é åã§æ¸¡ããã弿°ã¨ä¸ç·ã«å¼ã³åºãã¨ãããã¨ã«ãªãã¾ãã + +ãã©ã°ã¤ã³ã Java ãã¡ã¤ã«ã§æä¾ãããã JAR ã§ããã«ããããã©ã°ã¤ã³ã¯å¿ ã Cordova-Anroid ã¢ããªã±ã¼ã·ã§ã³ã® `res/xml` ãã©ã«ãã¼ã«ãã `config.xml` ãã¡ã¤ã«ã«è¿½å ããã¦ããªããã°ãªãã¾ããã + + <plugin name="<service_name>" value="<full_name_including_namespace>"/> + +ãµã¼ãã¹å (name) 㯠JavaScript ã® `exec` ã®ä¸ã§å®ç¾©ãããã®ã¨ä¸è´ãã¦ããå¿ è¦ããããå¤ (value) 㯠Java ã¯ã©ã¹ã¸ã®ãã¼ã ã¹ãã¼ã¹ãå«ãã ãã«ãã¹ã«ãªãã¾ããããããªãã¨ããã©ã°ã¤ã³ã¯ã³ã³ãã¤ã«ã¯ããã¾ããã +Cordova ããã¢ã¯ã»ã¹ã§ããªãç¶æ ã¨ãªãã¾ãã + +## Android Java ãã©ã°ã¤ã³ã®ä½æ + +ç§ãã¡ã¯ãã©ã°ã¤ã³ãªã¯ã¨ã¹ãããã¤ãã£ãå´ã«éã JavaScript ã使ãã¾ããã +ã¾ããæ£ãã `config.xml` ãã¡ã¤ã«ã§ãããã³ã°ããã Android Java ãã©ã°ã¤ã³ãããã¾ãã +ã§ã¯ãæçµçã« Android Java ãã©ã°ã¤ã³ã®ã¯ã©ã¹ãã©ã®ããã«ãªãã®ãè¦ã¦ããã¾ãããã + +JavaScript ã® `exec` 颿°ã«ãã£ã¦ãã©ã°ã¤ã³ã«å²ãå½ã¦ããããã®ã¯ã +ãã©ã°ã¤ã³ã®ã¯ã©ã¹ã® `execute` ã¡ã½ããã«æ¸¡ããã¾ãã大åã® `execute` +ã®å®è£ ã¯ä»¥ä¸ã®ããã«ãªãã¾ã: + + public PluginResult execute(String action, JSONArray args, String callbackId) { + PluginResult.Status status = PluginResult.Status.OK; + String result = ""; + + try { + if (action.equals("beep")) { + this.beep(args.getLong(0)); + } + return new PluginResult(status, result); + } catch (JSONException e) { + return new PluginResult(PluginResult.Status.JSON_EXCEPTION); + } + } + +åºæ¬çã« `action` ãã©ã¡ã¼ã¿ã¼ã®å¤ãè¦ã¦ãã¯ã©ã¹å ã® +(ãã©ã¤ãã¼ã) ã¡ã½ããã«å²ãæ¯ã£ã¦ããã¾ãã +ã¾ããä»»æã§ããã¤ãã®ãã©ã¡ã¼ã¿ã¼ããã®ã¡ã½ããã«æ¸¡ãã¾ãã + +ä¾å¤ããã£ãããã¨ã©ã¼ãè¿ãã¨ãã JavaScript ã¸è¿ãã¨ã©ã¼ã Java ã§çºçããä¾å¤ã«å¯è½ãªãããè¿ã¥ãããã¨ã¯ãæçãã®ããã«ãéè¦ã§ãã + +### Android ãã©ã°ã¤ã³ã® Echo ãã©ã°ã¤ã³ + +次ã config.xml ã«è¿½å ãã¾ã: + + <plugin name="Echo" value="org.apache.cordova.plugin.Echo" /> + +ããã¦ã次ã Cordova-Android ã¢ããªã±ã¼ã·ã§ã³ã®ä¸ã® +`src/org/apache/cordova/plugin/Echo.java` ã«è¿½å ãã¾ã: + + + package org.apache.cordova.plugin; + + import org.apache.cordova.api.Plugin; + import org.apache.cordova.api.PluginResult; + import org.json.JSONArray; + import org.json.JSONException; + import org.json.JSONObject; + + /** + * ãã®ã¯ã©ã¹ã¯ JavaScript ããå¼ã³åºãããæååãecho ãã¾ãã + */ + public class App extends Plugin { + + /** + * ãªã¯ã¨ã¹ããå®è¡ãã PluginResult ãè¿ãã¾ãã + * + * @param action å®è¡ããã¢ã¯ã·ã§ã³åã§ãã + * @param args ãã©ã°ã¤ã³ã¸ã®å¼æ°ã® JSONArry ã§ãã + * @param callbackId JavaScript ã¸ã³ã¼ã«ããã¯ããã¨ãã«ä½¿ãã³ã¼ã«ãã㯠id ã§ãã + * @return ã¹ãã¼ã¿ã¹ã¨ã¡ãã»ã¼ã¸ãä¼´ã£ã PluginResult ãªãã¸ã§ã¯ãã§ãã + */ + public PluginResult execute(String action, JSONArray args, String callbackId) { + try { + if (action.equals("echo")) { + String echo = args.getString(0); + if (echo != null && echo.length() > 0) { + return new PluginResult(PluginResult.Status.OK, echo); + } else { + return new PluginResult(PluginResult.Status.ERROR); + } + } else { + return new PluginResult(PluginResult.Status.INVALID_ACTION); + } + } catch (JSONException e) { + return new PluginResult(PluginResult.Status.JSON_EXCEPTION); + } + } + } + +ã³ã¼ããè¦ã¦ããã¾ããããä¸çªä¸ã«ã¯ãå¿ è¦ãªãã¹ã¦ã® Cordova ã«é¢ãã +`import` æã並ãã§ãã¾ããã¯ã©ã¹ã¯ `Plugin` ãç¶æ¿ãã¦ãã¾ã - ããã¯ã¨ã¦ã +éè¦ã§ãã `Plugin` ã¤ã³ã¿ã¼ãã§ã¼ã¹ã¯ `execute` ã¡ã½ãããå®è£ ããå¿ è¦ã +ããã¾ããã¡ã½ããã¯ãæåã« `action` ãè¦ã¦ããã¾ãããã®ãã©ã°ã¤ã³ã¯1㤠+ã®ã¢ã¯ã·ã§ã³ `echo` ã®ã¿ããµãã¼ããã¦ãã¾ããã»ãã®ã¢ã¯ã·ã§ã³ã¯ãã¹ãã¼ã¿ã¹ +ã `INVALID_ACTION` ã¨ãªã£ã `PluginResult` ãè¿ããã¾ã - ãã㯠JavaScript +å´ã§ã¨ã©ã¼ã³ã¼ã«ããã¯ã¸ã®å¼ã³åºãã«å¤æããã¾ããæ¬¡ã«ã `args` ã«å¯¾ã㦠+`getString` ã¡ã½ããã使ãããã©ã¡ã¼ã¿ã¼é åãã0çªç®ã®ãã©ã¡ã¼ã¿ã¼ãåå¾ +ãããã¨ã«ããã echo ããæååãåãåºãã¾ããããã§ãå°ããã©ã¡ã¼ã¿ã¼ã« +対ãã¦ãã§ãã¯ãè¡ãã¾ã: `null` ãã§ãã¯ãæååã®é·ãã0ã§ãªããã©ãããªã© +ã§ããããããã§ãã£ãå ´åã¯ãã¹ãã¼ã¿ã¹ã `ERROR` ã® `PluginResult` ã +è¿ãã¾ã (ããã¯ãããåç¥ã®éã JavaScript å´ã§ã¨ã©ã¼ã³ã¼ã«ããã¯ã +å¼ã³åºãã¾ã)ããããããã®ãã§ãã¯ããã¹ããããã¹ãã¼ã¿ã¹ã `OK` ã® +`PluginResult` ãè¿ãããã©ã¡ã¼ã¿ã¼ã¨ãã¦åãåã£ã `echo` æååã +渡ãã¾ãããããã JavaScript å´ã§æåã³ã¼ã«ããã¯é¢æ°ã«å¤æããã¾ãã +ã¾ãã `echo` ãã©ã¡ã¼ã¿ã¼ã JavaScript ã®æåã³ã¼ã«ããã¯é¢æ°ã« +ãã©ã¡ã¼ã¿ã¼ã¨ãã¦æ¸¡ãã¾ãã + +## ãã©ã°ã¤ã³ã®ãããã° + +Eclipse 㯠Android ããã¸ã§ã¯ãã®ãããã°ã«ä½¿ç¨ã§ãã Java ã®ã½ã¼ã¹ãã¡ã¤ã«ãããã¸ã§ã¯ãã«å«ã¾ãã¦ããå ´åã¯ããã©ã°ã¤ã³ããããã°ã§ãã¾ããææ°ãã¼ã¸ã§ã³ã® Android Dev Tools ã®ã¿ JAR ã«ã½ã¼ã¹ã³ã¼ããä»ä¸ã§ããããã¯ä»åã¯ãã«ã§ãµãã¼ãããã¦ãã¾ããã + +## ããããè½ã¨ãç©´ + +* ãã©ã°ã¤ã³ã¯ `CordovaInterface` ãªãã¸ã§ã¯ãã¸ã®ã¢ã¯ã»ã¹æ¨©ãæã£ã¦ãã¾ãããã®ãªãã¸ã§ã¯ãã¯ã¢ããªã±ã¼ã·ã§ã³ã§èµ°ã£ã¦ãã Android ã® `Activity` ã¸ã®ã¢ã¯ã»ã¹æ¨©ãæã£ã¦ãã¾ãããã® `Activity` ã¯æ°ãã Android `Intent` ãèµ·åããããã«å¿ è¦ãª `Context` ã§ãã +`CordovaInterface` ã¯ãçµæã¨ã㦠`Activity` ãéå§ãããã¨ãã¾ã `Intent` ãã¢ããªã±ã¼ã·ã§ã³ã«æ»ã£ã¦ããã¨ãã«ã³ã¼ã«ããã¯ãã»ãããããã¨ããã©ã°ã¤ã³ã«è¨±å¯ãã¾ãã +`Intent` ã·ã¹ãã 㯠Android ã®ããã»ã¹éã®é£æºã«ä½¿ããããããããã¯é常ã«éè¦ã§ãã +* ãã©ã°ã¤ã³ã¯ `Context` ã¸ã®ç´æ¥ã¢ã¯ã»ã¹æ¨©ã以åã®ããã«æã£ã¦ãã¾ããã以åã® `ctx` ã¯ãã廿¢ããã 2.0 ãªãªã¼ã¹ã®6ã¶æå¾ã«åé¤ããã¾ãã `Context` ã«ãã£ã `ctx` ãåå¨ãããã¹ã¦ã®ã¡ã½ããã `getContext()` 㨠`getActivity()` ã¯å¿ è¦ãªæ£ãããªãã¸ã§ã¯ããè¿ããã¨ãå¯è½ã§ãã +* `webView.loadUrl()` ã使ã£ã¦ JavaScript ãå¼ã³åºããã¨ã¯é¿ãã¦ãã ãããã³ã¼ã«ããã¯ãµã¼ãã¼ãããçç±ã¯ã JavaScript ãã¹ã¬ããã»ã¼ãã§å®è¡ãããããã§ãã `loadUrl` ã¯æç¢ºã« UI ã¹ã¬ããã«å²ãè¾¼ã¿ããã©ã°ã¤ã³ã®ã¦ã¼ã¶ããªãã£ã¼ã«å½±é¿ãã¾ãã http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/bb374344/docs/jp/2.0.0/guide/plugin-development/bada/index.md ---------------------------------------------------------------------- diff --git a/docs/jp/2.0.0/guide/plugin-development/bada/index.md b/docs/jp/2.0.0/guide/plugin-development/bada/index.md new file mode 100644 index 0000000..2732582 --- /dev/null +++ b/docs/jp/2.0.0/guide/plugin-development/bada/index.md @@ -0,0 +1,74 @@ +--- +license: Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--- + +Developing a Plugin on Bada +=========================== + +ãã©ã°ã¤ã³ã¯ Bada 2.0 以ä¸ã®ã¿ãµãã¼ããã¦ãã¾ãã Bada 1.2 ã¯ãµãã¼ããã¦ãã¾ããã + +Bada ã®å®è£ ã¯ãã¹ã¦ JavaScript ã®å®è£ ã§ãããã®ãããã«ã¹ã¿ã ãã©ã°ã¤ã³ã追å ãããã¨ã¯ããã©ã°ã¤ã³ã³ã¼ãã«ãã£ã¦ CordovaJS ãæ´æ°ãããã¨ã«ãªãã¾ãã以ä¸ã¯ãã·ã³ãã«ãª _Hello World_ ãã©ã°ã¤ã³ã追å ããã¹ãããã§ã: + +1. CordovaJS ãªãã¸ããªã¼ã clone ãã¾ã + + git clone https://git-wip-us.apache.org/repos/asf/incubuator-cordova-js.git + +2. __lib/bada/plugin/bada/__ 以ä¸ã«æ°ãã JavaScript ãã¡ã¤ã«ã使ãã _HelloWorld.js_ ã¨ååãã¤ãã¾ãã以ä¸ã®å 容ã追å ãã¾ã: + + function HelloWorld() { + } + + HelloWorld.prototype.printHello = function(success, fail, arg) { + alert(Osp.Core.StringHelper('Hello %1', arg[0])); + } + + module.exports = new HelloWorld(); + +3. __lib/bada/platform.js__ ã® objects ããããã£ã¼ã®ä¸ã«ãæ°ããä½ã£ããã©ã°ã¤ã³ã¸ã®ãªã³ã¯ã追å ãã¾ã: + + objects: { + ... + HelloWorld: { + 'cordova/plugin/bada/HelloWorld' + }, + ... + } + ... +4. __lib/bada/exec.js__ ã®ãã©ã°ã¤ã³ãªã¹ãããä½ã£ããã©ã°ã¤ã³ãå«ãããã«æ´æ°ãã¾ã + + var plugins = { + ... + "HelloWorld": require('cordova/plugin/bada/HelloWorld') + }; +5. ããã§ã好ããªããã«ã¦ã¼ã¶ã¼åãã® JavaScript ãæ¸ããã¨ãã§ãã¾ãããããããã©ã°ã¤ã³ãå®è¡ããããã«ã¯ã以ä¸ã®ã¡ã½ãããå¼ã³åºãå¿ è¦ããããã¨ãå¿ããªãã§ä¸ãã + + exec(succes, fail, 'HelloWorld', 'printHello', ['Jackson!']); + + success ã¯ãã©ã°ã¤ã³ãæ£å¸¸ã«çµäºããã¨ãã«å®è¡ãããæåã³ã¼ã«ããã¯é¢æ°ã§ã + fail ã¯ãã©ã°ã¤ã³ãæ£å¸¸ã«çµäºããªãã£ãã¨ãã«å®è¡ãããã¨ã©ã¼ã³ã¼ã«ããã¯é¢æ°ã§ã + 'HelloWorld' ã¯ããªãã®ãã©ã°ã¤ã³ã®ååã§ã + 'printHello' ã¯ããªãã®ãã©ã°ã¤ã³ã®ã¢ã¯ã·ã§ã³åã§ã + æå¾ã®ãã©ã¡ã¼ã¿ã¼ã¯ããã©ã°ã¤ã³ã¸ã®å¼æ°ã§ã + +6. 以ä¸ã®ã³ãã³ããå®è¡ããæ°ããå ±é JavaScript ãçæãã¾ã (npm ã¢ã¸ã¥ã¼ã«ã® jake ãã¤ã³ã¹ãã¼ã«ããã¦ãããã¨ã確èªãã¦ä¸ãã) + + jake + +7. æ°ããçæããã __pkg/cordova.bada.js__ ãã Bada ããã¸ã§ã¯ãã® __Res/js__ 以ä¸ã«ã³ãã¼ãã¾ã + +6. 以ä¸ã§ãï¼ããã§ãããªãã¯æ°ãã Bada ãã©ã°ã¤ã³ã追å ãããã¨ãã§ããç¾å¨ã¯ Cordova Bada ã§ãµãã¼ãããã¦ããªãããããã®æ©è½ãå®è£ ã§ããããã«ãªãã¾ããã http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/bb374344/docs/jp/2.0.0/guide/plugin-development/blackberry/index.md ---------------------------------------------------------------------- diff --git a/docs/jp/2.0.0/guide/plugin-development/blackberry/index.md b/docs/jp/2.0.0/guide/plugin-development/blackberry/index.md new file mode 100644 index 0000000..d92c90c --- /dev/null +++ b/docs/jp/2.0.0/guide/plugin-development/blackberry/index.md @@ -0,0 +1,138 @@ +--- +license: Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--- + +Developing a Plugin on BlackBerry +================================= + +## Blackberry ã§ã® Echo ãã©ã°ã¤ã³ã®ä½ãæ¹ + +ãã®ã¬ã¤ãã§ã¯ã BlackBerry ã§ã® Echo ãã©ã°ã¤ã³ã®ä½ãæ¹ã«ã¤ãã¦èª¬æãã¾ãã +ããä¸ä½ã®ã¬ã¤ãã§ãã JavaScript ãã¼ãã®ãã©ã°ã¤ã³ã«ã¤ãã¦ã®ã¬ã¤ããèªãã§ããªãå ´åã¯ããããæåã«èªããã¨ããããããã¾ãã +å ãã¦ã [Cordova Blackberry repo](https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-blackberry-webworks.git;a=summary) ããã¦ã³ãã¼ããã¦ãã ããã + +Cordova-BlackBerry ããã¸ã§ã¯ã㯠Torch, Bold, Playbook ã¨ãã£ã BlackBerry ããã¤ã¹ã¸ã®ãããã¤ãå¯è½ã«ãã¾ãã +éå¸¸ã®æºå¸¯ç«¯æ«ã¿ã¤ãã® BlackBerry (ä¾, Torch 㨠Bold) ã¨ã¿ãã¬ããã¿ã¤ãã® Playbook ã®éã«ã¯ããããã¤æ¹æ³ã«å·®ãããã¾ãã +ãã®2ã¤ã®ã³ã¼ãã¯ãã¼ã¹ãéãããã1ã¤ãéçºãã¦ããã¨ãã¯ããã1ã¤ã®ããã«ã³ã¼ããè¤è£½ãã¦ãããå¿ è¦ãããã¾ãã +ãã®ããããã®ã¬ã¤ãã§ã¯æºå¸¯ç«¯æ«ã«ãã©ã¼ã«ã¹ããã¿ãã¬ããã«ã¯ãã©ã¼ã«ã¹ãã¾ããã +å°æ¥çã«ã¯ã両æ¹ã®ãã©ãããã©ã¼ã ãã«ãã¼ããäºå®ã§ãã + + +åã®ã¬ã¤ãããã®ç¶ãã§ã Echo ãã©ã°ã¤ã³ã¯åºæ¬çã«ã¦ã¼ã¶ã¼ã `window.echo` +颿°ã§ä¸ããã¡ãã»ã¼ã¸ãè¿ãã¾ãã + +Echo 颿°: + + window.echo = function(str, callback) { + cordova.exec(callback, function(err) { + callback('Nothing to echo.'); + }, "Echo", "echo", [str]); + }; + +## plugins.xml ã®ä¿®æ£ + +ãã®ãã¡ã¤ã«ã¯ããã¸ã§ã¯ãã®ä¸ã® www ãã©ã«ãã¼ã«ããã Cordova ããã¸ã§ã¯ãã使ç¨ãã¦ãããã¹ã¦ã®ãã©ã°ã¤ã³ã¸ã®åç §ãå«ã¿ã¾ãã +æ°ããåç §ã追å ãã¦ã cordova.exec ãå¼ã°ããã¨ãã«ã Cordova ã `cordova.exec` ã® "Echo" 弿°ã +ããããæ¸ããã¤ãã£ãã³ã¼ãã® Echo ã¯ã©ã¹ã«ãããã³ã°ãããã¨ãåããããã«ãã¾ãã + + <plugins> + ... + <plugin name="Echo" value="org.apache.cordova.echo.Echo"/> + ... + </plugins> + +## Echo.java ã®è¿½å + +ãã value 屿§ã®æ§é ã«ãæ°ã¥ããªãã Echo ãã©ã°ã¤ã³ã¸ã®å®ç¾©ããããã¹ãè¦ããã§ãããã +Cordova BlackBerry Webworks ã®ãªãã¸ããªã¼ã®ã«ã¼ããã©ã«ãã¼ã§ã framework ã¨å¼ã°ãããã©ã«ãã¼ãæ¢ãã¦ãã ããã +ãã®ãã©ã«ãã¼ã¯ BlackBerry ä¸ã§åããã¹ã¦ã®ã½ã¼ã¹ã³ã¼ããå«ãã§ãã¾ãã +ãã®ãã©ã«ãã¼ä»¥ä¸ã® `framework/ext/src/org/apache/cordova` ã«ãã©ã«ãã¼ã«è¾¿ãã¤ãã¾ã§ cd ãç¶ãã¾ãã +ãã®æãã¹ã¦ã®ãã©ã°ã¤ã³ãã©ã«ãã¼ãè¦ããã§ããããã¾ããããããã®ãã©ã«ãã¼ã®ä¸èº«ã¯ãã©ã°ã¤ã³ã®ã½ã¼ã¹ã³ã¼ãã¨ãªã£ã¦ãã¾ãã +ããã§ããã©ã«ãã¼ echo ã `framework/ext/src/org/apache/cordova/echo` ã«ä½æãã +`Echo.java` ããã®ä¸ã® `framework/ext/src/org/apache/cordova/echo/Echo.java` ã®ä½ç½®ã«æ°è¦è¿½å ãã¾ãã + +## Echo.java ã®å®è£ + +ãã©ã°ã¤ã³ã®å®è£ ã®åºæ¬çãªã¢ã¤ãã¢ã¯ã Plugin ã¯ã©ã¹ãç¶æ¿ããã¯ã©ã¹ã使ãã +PluginResult ã¯ã©ã¹ãè¿ã execute ã¨å¼ã°ããã¡ã½ããã使ãããã¨ã§ãã +cordova.exec ã¸ã®ãã¹ã¦ã®å¼ã³åºãã¯ãã¯ã©ã¹å ã§å®è¡ãããã¢ã¯ã·ã§ã³ã¨å¼æ°ã渡ãã¾ãã +ãã®å ´åã "echo" ãã¯ã©ã¹ "Echo" å ã§å®è¡ãããã¢ã¯ã·ã§ã³ã§ã [str] ãæ¸¡ãã¦ãã弿°ã§ãã + + package org.apache.cordova.echo; + + import org.apache.cordova.api.Plugin; + import org.apache.cordova.api.PluginResult; + import org.apache.cordova.json4j.JSONArray; + import org.apache.cordova.json4j.JSONException; + import org.apache.cordova.json4j.JSONObject; + import org.apache.cordova.util.Logger; + /** + * BlackBerry ã§ã®ãã©ã°ã¤ã³ã®ä½ãæ¹ãã¢ã®ããã®ã·ã³ãã«ãªãã©ã°ã¤ã³ + * ã¦ã¼ã¶ã¼ããã©ã°ã¤ã³ãå¼ã³åºããã¨ãã®ã¡ãã»ã¼ã¸ããã®ã¾ã¾è¿ãã¾ã + */ + public final class Echo extends Plugin { + + public static final String echo = "echo"; + + public PluginResult execute(String action, JSONArray args, String callbackId) { + PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION, "Echo: Invalid action:" + action); + if(action.equals(echo)){ + try { + JSONObject echoObj = new JSONObject(); + String theMsg = args.getString(0); + if(theMsg.length()>0){ + result = new PluginResult(PluginResult.Status.OK, theMsg); + }else{ + result = new PluginResult(PluginResult.Status.ERROR, theMsg); + } + } catch (JSONException e) { + result = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage()); + } + } + + return result; + } + + } + +ä¸ã®ã³ã¼ããè¦ã¦ã¿ãã¨ã execute ã¡ã½ããã®ä¸ã§ãæåã«ã©ããªã¢ã¯ã·ã§ã³ãæ¥ããã調ã¹ã¦ããã®ãåããã¾ãã +ãã® Echo ãã©ã°ã¤ã³ã¯1ã¤ã®ã¢ã¯ã·ã§ã³ "echo" ã®ã¿ãæã¤ã®ã§ãããã®ã¿ããã§ãã¯ãã¾ãã +ãããã©ã°ã¤ã³ã«è¤æ°ã®ã¢ã¯ã·ã§ã³ããã£ãå ´åã¯ã if æã追å ãã¦ããããããããã§ãã¯ãã¦ããã¾ãã + + +次ã«ã args ãã©ã¡ã¼ã¿ã¼ã«ãã£ã¦ä¸ãããã弿°ããã¡ãã»ã¼ã¸ãåå¾ãã¾ãã +`String theMsg = args.getString(0);` ã¨ãããã¨ã§ãã·ã³ãã«ã«ä¸çªæåã®å¼æ°ãåå¾ãããã¨ãã§ãã¾ãã + +ããã¤ãã®ã¨ã©ã¼ãã§ãã¯ãããããã¡ãã»ã¼ã¸ã大ä¸å¤«ãããªãã ok ã¹ãã¼ã¿ã¹ (PluginResult.Status.OK) ã¨ã¡ãã»ã¼ã¸ (theMsg) ãæã¤ +æ°ãã PluginResult ã¤ã³ã¹ã¿ã³ã¹ãä½ãã¾ãã +ãã®å¾ã JavaScript ã«æ¸¡ããæåã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºã result ãè¿ãã¾ãã +ããä½ãã¨ã©ã¼ãèµ·ããå ´åã PluginResult.Status.ERROR, PluginResult.Status.JSON_EXCEPTION, PluginResult.Status.INVALID_ACTION ã¨ãã£ããããªä½ç¨®é¡ãã®ã¹ãã¼ã¿ã¹ä¾å¤ãè¿ããã¨ãåºæ¥ã¾ãã +ãããã®ã¿ã¤ãã®ä¾å¤ãè¿ãããã¨ãã JavaScript å´ã§ã¯ã¨ã©ã¼ã³ã¼ã«ããã¯ã +å¼ã³åºããã¾ãã + +## www ãã©ã«ãã¼ã® .jar ã®æ´æ° + +ããªãã®ããã¸ã§ã¯ãå ã§ Echo.java ã®è¿½å åãæ´æ°ãããå¿ è¦ãããã¾ãã .jar ãã¡ã¤ã«ããã«ãããããã«ã¯ã BlackBerry Webworks ãªãã¸ããªã¼ã®ã«ã¼ããã£ã¬ã¯ããªã« cd ãã¾ãã +次㮠ant ã³ãã³ãã使ç¨ãã¾ã: + + ant update -Dproject.path="~/path_to_my_project" + +ãã㯠build/ext ãã©ã«ãã¼ã®ä¸ã®æ°ãã .jar ãã¡ã¤ã«ããã«ããã¾ãã +`build/ext/cordova.jar` ãã¡ã¤ã«ã ããã¸ã§ã¯ãã® www/ext ãã©ã«ãã¼ã«ã³ãã¼ãã¾ãã + +ãããã¹ã¦ã䏿ããã£ããã BlackBerry ã§ Echo ãã©ã°ã¤ã³ã使ç¨ã§ããããã«ãªã£ã¦ããã¯ãã§ãã http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/bb374344/docs/jp/2.0.0/guide/plugin-development/index.md ---------------------------------------------------------------------- diff --git a/docs/jp/2.0.0/guide/plugin-development/index.md b/docs/jp/2.0.0/guide/plugin-development/index.md new file mode 100644 index 0000000..1538786 --- /dev/null +++ b/docs/jp/2.0.0/guide/plugin-development/index.md @@ -0,0 +1,111 @@ +--- +license: Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--- + +# ãã©ã°ã¤ã³éçºã¬ã¤ã + +Cordava ãã©ã°ã¤ã³ã¯ Cordova ã¢ããªã±ã¼ã·ã§ã³ Webview 㨠Cordava +ã¢ããªã±ã¼ã·ã§ã³ãèµ°ã£ã¦ãããã¤ãã£ããã©ãããã©ã¼ã ã®æ©è½ç㪠+æ©æ¸¡ãããã¾ãããã©ã°ã¤ã³ã¯ãã¹ã¦ã®ãã©ãããã©ã¼ã ã§ä½¿ããã +1ã¤ã® JavaScript ã¤ã³ã¿ã¼ãã§ã¼ã¹ã«éç´ããããã®ãã©ã°ã¤ã³ +ã¤ã³ã¿ã¼ãã§ã¼ã¹ã«å¾ã£ããã©ãããã©ã¼ã ç¬èªã®ãã¤ãã£ãå®è£ ã +ãããããªããã¾ãããã¹ã¦ã®ã³ã¢ Cordova API ã¯ãã®ã¢ã¼ããã¯ã㣠+ãç¨ãã¦å®è£ ããã¦ãã¾ãã + +ãã®ã¬ã¤ãã¯ã·ã³ãã«ãª Echo ãã©ã°ã¤ã³ãæ¸ãããã«å¿ è¦ãªã¹ãããã +ç´¹ä»ãã¦ããã¾ãã Echo ãã©ã°ã¤ã³ã¯ JavaScript ããæååãåãåãã +ããããµãã¼ãããã¦ãããã©ãããã©ã¼ã ã®ãã¤ãã£ãç°å¢ã«æ¸¡ãã¾ãã +ãã®ãã¤ãã£ãã³ã¼ãã¯åãæååãããã©ã°ã¤ã³ã® JavaScript ã® +ã³ã¼ã«ããã¯ã«å«ãã§è¿ãã¾ãã + +ãã®ã¬ã¤ããããããè¤éãªãã©ã°ã¤ã³ãæ¸ãããã«å¿ è¦ãªæ¦è¦³ã詳細ã +å¾ãããã¯ãã§ãã + +## JavaScript + +ãã¹ã¦ã®ãã©ã°ã¤ã³ã®æåã®ä¸æ©ã¯ JavaScript ã§ããéçºè ã Cordova ã +使ãçç±ã¯ã Objective-C ã§ã Java ã§ã C# ã§ããªãã JavaScript ã使ã£ã¦ +ã³ã¼ããæ¸ããããã§ãããã©ã°ã¤ã³ã«ã¨ã£ã¦ JavaScript ã¤ã³ã¿ã¼ãã§ã¼ã¹ã¯ +ã¾ãããé¡ã§ããããã£ã¨ãéè¦ãªé¨åã§ããã¨è¨ããã§ãããã + +ããªãã¯ãã©ã°ã¤ã³ã® JavaScript ã好ããªããã«æ§æã§ãã¾ãããã ä¸ã¤ã +Cordova JavaScript ã¨ãã¤ãã£ãç°å¢ã¨ã®éã®ã³ãã¥ãã±ã¼ã·ã§ã³ã®ããã« +`cordova.exec` 颿°ã _使ãå¿ è¦ãããã¾ã_ ã以ä¸ãä¾ã§ã: + + cordova.exec(function(winParam) {}, function(error) {}, "service", + "action", ["firstArgument", "secondArgument", 42, + false]); + +以ä¸ããã©ã¡ã¼ã¿ã¼ã®è©³ç´°èª¬æã§ã: + +1. `function(winParam) {}` - æåã³ã¼ã«ããã¯é¢æ°ã§ãã `exec` ã®å®è¡ã + æ£å¸¸ã«å®äºããã¨ãããã®é¢æ°ãå¼ã³åºããã¾ã + (ä»»æã§è¿ããããã©ã¡ã¼ã¿ã¼ã¨ä¸ç·ã«å¼ã³åºããã¾ã) +2. `function(error) {}` - ã¨ã©ã¼ã³ã¼ã«ããã¯é¢æ°ã§ããããæä½ãæ£å¸¸ã« + å®äºããªãã£ãã¨ãããã®é¢æ°ãå¼ã³åºããã¾ã + (ä»»æã§è¿ããããã©ã¡ã¼ã¿ã¼ã¨ä¸ç·ã«å¼ã³åºããã¾ã) +3. `"service"` - ãã¤ãã£ãå´ã§å¼ã³åºããããµã¼ãã¹åã§ãããã㯠+ ãã¤ãã£ãã¯ã©ã¹ã«ãããã³ã°ããã¾ãã詳ããã¯ã以ä¸ã®ãã¤ãã£ã + ã¬ã¤ãã§èª¬æãã¦ãã¾ã +4. `"action"` - å¼ã³åºãããã¢ã¯ã·ã§ã³åã§ãã `exec` ããã®å¼ã³åºãã + åãããã¤ãã£ãã¯ã©ã¹ã§åãåºããããã©ãããã©ã¼ã ã«ä¾åãã¦ã + ã¯ã©ã¹ã®ã¡ã½ããã«ãããã³ã°ããã¾ãã詳ããã¯ã以ä¸ã®ãã¤ãã£ã + ã¬ã¤ãã§èª¬æãã¦ãã¾ã +5. `[/* arguments */]` - ãã¤ãã£ãç°å¢ã«æ¸¡ããã弿°ã§ã + + +### Echo ãã©ã°ã¤ã³ JavaScript ã®ä¾ + + window.echo = function(str, callback) { + cordova.exec(callback, function(err) { + callback('Nothing to echo.'); + }, "Echo", "echo", [str]); + }; + +詳ããè¦ã¦ããã¾ãããããã©ã°ã¤ã³ã `window` ã« `echo` 颿°ã¨ã㦠+ä»ä¸ãã¦ãã¾ãããã©ã°ã¤ã³ã®ã¦ã¼ã¶ã¼ã¯ä»¥ä¸ã®ããã«ä½¿ç¨ãã¾ã: + + + window.echo("echome", function(echoValue) { + alert(echoValue == "echome"); // should alert true. + }); + +ã¯ããã«ã `exec` 颿°ã®å¾ã3ã¤ã®å¼æ°ã«ã¤ãã¦è¦ã¦ããã¾ãããã +ç§ãã¡ã¯ã `Echo` "ãµã¼ãã¹" ãå¼ã³åºãã `echo` "ã¢ã¯ã·ã§ã³" ã +ãªã¯ã¨ã¹ããããã㦠`window.echo` 颿°ã®æåã®ãã©ã¡ã¼ã¿ã¼ã§ãã +æååãå«ãã é åã弿°ã¨ãã¦æ¸¡ãã¦ãã¾ãã + +`exec` ã«æ¸¡ãããæåã³ã¼ã«ããã¯é¢æ°ã¯ `window.echo` ãååã +ã³ã¼ã«ããã¯é¢æ°ãåç´ã«åç §ãã¦ãã¾ããã¨ã©ã¼ã³ã¼ã«ããã¯ã«ã¤ãã¦ã¯ +ããå°ãæãå ãã¦ãã¾ã: ãããã¤ãã£ãå´ã§ã¨ã©ã¼ã³ã¼ã«ããã¯ãå¼ã³åºãã +å ´åã¯ãåç´ã«æåã³ã¼ã«ããã¯ãå¼ã³åºãã "ããã©ã«ã" æååãæ¸¡ãã¾ãã + +## ãã¤ãã£ã + +ãã©ã°ã¤ã³ã® JavaScript ã®å®ç¾©ãçµãã£ãããããã«å°ãªãã¨ã1ã¤ã® +ãã¤ãã£ãå®è£ ãä»ãå ããå¿ è¦ãããã¾ãã以ä¸ã¯ Cordova ããµãã¼ã +ãã¦ããããããã®ãã©ãããã©ã¼ã ã«ç¹åããã¬ã¤ãã«ãªãã¾ãã +以ä¸ã®ã¬ã¤ãã§ã¯å¼ãç¶ãããã®ã¬ã¤ãã§ä½ãå§ãã Echo ãã©ã°ã¤ã³ã +使ãã¦ããã¾ãã + +- Developing a Plugin on Android +- Developing a Plugin on Bada +- Developing a Plugin on BlackBerry +- Developing a Plugin on iOS +- Developing a Plugin on webOS +- Developing a Plugin on Windows Phone http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/bb374344/docs/jp/2.0.0/guide/plugin-development/ios/index.md ---------------------------------------------------------------------- diff --git a/docs/jp/2.0.0/guide/plugin-development/ios/index.md b/docs/jp/2.0.0/guide/plugin-development/ios/index.md new file mode 100644 index 0000000..322e8b6 --- /dev/null +++ b/docs/jp/2.0.0/guide/plugin-development/ios/index.md @@ -0,0 +1,157 @@ +--- +license: Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--- + +# Developing a Plugin on iOS + +ãã©ã°ã¤ã³ã®éçºã«ã¯ã Cordova-iOS ã®ã¢ã¼ããã¯ãã£ã®çè§£ãå¿ è¦ã§ãã Conrdova-iOS 㯠UIWebView ããæ§æããã¦ãã¾ããã¤ã³ã¿ã¼ã»ããå½ä»¤ã¯ã URL ã®å¤åã«å¿ã㦠UIWebView ã«æ¸¡ããã¾ãããããã®ãã©ã°ã¤ã³ã¯ .plist ãã¡ã¤ã«ã® Plugins ãã¼ã«ã¯ã©ã¹ãããã³ã°ã¨ãã¦è¡¨ããã¦ãã¾ãã + +ãã©ã°ã¤ã³ã¯ `CDVPlugin` ã¯ã©ã¹ãç¶æ¿ãã Objective-C ã®ã¯ã©ã¹ã§ãã + +## ãã©ã°ã¤ã³ã¯ã©ã¹ã®ãããã³ã° + +ãã©ã°ã¤ã³ã® JavaScript é¨åã¯å¸¸ã« `cordova.exec` ã¡ã½ããã以ä¸ã®ããã«ä½¿ãã¾ã: + + exec(<successFunction>, <failFunction>, <service>, <action>, [<args>]); + +ãã㯠UIWebView ãã iOS ãã¤ãã£ãå´ã¸ã®ãªã¯ã¨ã¹ããæ´çããããããè¦ç´ãã㨠`service` ã¯ã©ã¹ã§ `action` ã¡ã½ãããã `args` é åã§æ¸¡ããã弿°ã¨ä¸ç·ã«å¼ã³åºãã¨ãããã¨ã«ãªãã¾ãã + +Objective-C ãã©ã°ã¤ã³ã¡ã½ããã® `options` ãã©ã¡ã¼ã¿ã¼ã¯éæ¨å¥¨ã§ããã使ãããã¹ãã§ã¯ããã¾ãããã¬ã¬ã·ã¼çãªçç±ã§ã `args` é åã®æå¾ã® JavaScript ãªãã¸ã§ã¯ãè¦ç´ ã¯ã Objective-C å´ã¡ã½ããã® `options` è¾æ¸ã«æ¸¡ããã¾ããã©ã㪠JavaScript ãªãã¸ã§ã¯ãã§ã `args` é åã®æå¾ã®è¦ç´ ã¨ãã¦æ¸¡ãããã¹ãã§ãããããé åã®éä¸ã®è¦ç´ ã« JavaScript ãªãã¸ã§ã¯ããããã¨ããã以éã® Objective-C å´ã®é åã®ã¤ã³ããã¯ã¹ãã§ãããã«ãªããã¨ã«ååæ³¨æãã¦ãã ããã options è¾æ¸ã¯ãã 1ã¤ã® JavaScript ãªãã¸ã§ã¯ãã®ã¿ããµãã¼ããã¦ãããã¾ãé åã®ä¸çªæå¾ã®è¦ç´ ã®ã¿ãã¤ãã£ãã¡ã½ããã«æ¸¡ããã¾ãããã®ããã«ã¨ã©ã¼ãèµ·ãããããã®ã§ã `options` ã¯éæ¨å¥¨ã¨ãªã£ã¦ãã¾ãã + +ãã®ãã©ã°ã¤ã³ã¯ã Cordova-iOS ã¢ããªã±ã¼ã·ã§ã³ã®ããã¸ã§ã¯ããã©ã«ãã¼ã®ä¸ã® `Cordova.plist` ãã¡ã¤ã«ã® `Plugins` ãã¼ (è¾æ¸) ã«è¿½å ãããå¿ è¦ãããã¾ãã + + <key>service_name</key> + <string>PluginClassName</string> + +`service_name` ã®ãã¼ã¯ JavaScript ã® `exec` ã®ä¸ã§ä½¿ç¨ãã¦ãããã®ã¨ä¸è´ãã¦ããå¿ è¦ããããå¤ã¯ãã©ã°ã¤ã³ã® Objective-C ã¯ã©ã¹ã®ååã«ãªãã¾ããããããªãã¨ããã©ã°ã¤ã³ã¯ã³ã³ãã¤ã«ããã¾ããã Cordova ããã¢ã¯ã»ã¹ã§ããªãç¶æ ã¨ãªãã¾ãã + +## iOS Cordova Plugin ã®ä½æ + +ç§ãã¡ã¯ãã©ã°ã¤ã³ãªã¯ã¨ã¹ãããã¤ãã£ãå´ã«éã JavaScript ã使ãã¾ãããã¾ããæ£ãã `Cordova.plist` ãã¡ã¤ã«ã§ãããã³ã°ããã iOS Objective-C ãã©ã°ã¤ã³ãããã¾ããã§ã¯ãæçµçã« iOS Objective-C ãã©ã°ã¤ã³ã®ã¯ã©ã¹ãã©ã®ããã«ãªãã®ãè¦ã¦ããã¾ãããã + +JavaScript ã® `exec` 颿°ã«ãã£ã¦ãã©ã°ã¤ã³ã«å²ãå½ã¦ããããã®ã¯ããã©ã°ã¤ã³ã¯ã©ã¹ã®å¯¾å¿ãã `action` ã¡ã½ããã«æ¸¡ããã¾ãã大åã®ã¡ã½ããã®å®è£ ã¯ä»¥ä¸ã®ããã«ãªãã¾ã: + + - (void) myMethod:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options + { + NSString* callbackId = [arguments objectAtIndex:0]; + + CDVPluginResult* pluginResult = nil; + NSString* javaScript = nil; + + @try { + NSString* myarg = [arguments objectAtIndex:1]; + + if (myarg != nil) { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + javaScript = [pluginResult toSuccessCallbackString:callbackId]; + } + } @catch (id exception) { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_JSON_EXCEPTION messageAsString:[exception reason]]; + javaScript = [pluginResult toErrorCallbackString:callbackId]; + } + + [self writeJavascript:javaScript]; + } + + +### iOS ãã©ã°ã¤ã³ã® Echo ãã©ã°ã¤ã³ + +`Cordova.plist` ãã¡ã¤ã«ã® `Plugins` ãã¼ (è¾æ¸) ã«ä»¥ä¸ã追å ãã¾ã: + + <key>Echo</key> + <string>Echo</string> + +次ã®ãã¡ã¤ã« (`Echo.h` 㨠`Echo.m`) ã Cordova-iOS ã¢ããªã±ã¼ã·ã§ã³ãã©ã«ãã¼ã®ä¸ã® +ãã©ã°ã¤ã³ãã©ã«ãã¼ã«è¿½å ãã¾ã: + + /********* Echo.h Cordova Plugin Header *******/ + + #import <Cordova/CDVPlugin.h> + + @interface Echo : CDVPlugin + + - (void) echo:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; + + @end + + /********* Echo.m Cordova Plugin Implementation *******/ + + #import "Echo.h" + #import <Cordova/CDVPluginResult.h> + + @implementation Echo + + - (void) echo:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options + { + NSString* callbackId = [arguments objectAtIndex:0]; + + CDVPluginResult* pluginResult = nil; + NSString* javaScript = nil; + + @try { + NSString* echo = [arguments objectAtIndex:1]; + + if (echo != nil && [echo length] > 0) { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:echo]; + javaScript = [pluginResult toSuccessCallbackString:callbackId]; + } else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; + javaScript = [pluginResult toErrorCallbackString:callbackId]; + } + } @catch (NSException* exception) { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_JSON_EXCEPTION messageAsString:[exception reason]]; + javaScript = [pluginResult toErrorCallbackString:callbackId]; + } + + [self writeJavascript:javaScript]; + } + + @end + + +ã³ã¼ããè¦ã¦ããã¾ããããä¸çªä¸ã«ã¯ãå¿ è¦ãªãã¹ã¦ã® Cordova ã«é¢ãã import æã並ãã§ãã¾ããã¯ã©ã¹ã¯ `CDVPlugin` ãç¶æ¿ãã¦ãã¾ã - ããã¯ã¨ã¦ãéè¦ã§ãã + +ãã®ãã©ã°ã¤ã³ã¯1ã¤ã®ã¢ã¯ã·ã§ã³ `echo` ã®ã¿ããµãã¼ããã¦ãã¾ããæåã«ã弿°é åã®0çªç®ã®è¦ç´ ã§ãã `callbackId` ãã©ã¡ã¼ã¿ã¼ãåå¾ãã¾ããæ¬¡ã«ã `objectAtIndex` ã¡ã½ããã使ã£ã¦ã弿°é åã®1çªç®ã®è¦ç´ ã§ãã echo ç¨æååãåå¾ãã¾ããããã§ãå°ããã©ã¡ã¼ã¿ã¼ã«å¯¾ãã¦ãã§ãã¯ãè¡ãã¾ã: `nil` ãã§ãã¯ãæååã®é·ãã0ã§ãªããã©ãããªã©ã§ãã + +ããããã§ãã£ãå ´åã¯ãã¹ãã¼ã¿ã¹ã `ERROR` ã® `PluginResult` ãè¿ãã¾ãããããããã®ãã§ãã¯ããã¹ããããã¹ãã¼ã¿ã¹ã `OK` ã® `PluginResult` ãè¿ãããã©ã¡ã¼ã¿ã¼ã¨ãã¦åãåã£ã `echo` æååãæ¸¡ãã¾ããããã¦ãããæ£å¸¸ãªå ´å㯠`toSuccessCallbackString` ã¡ã½ãããã¨ã©ã¼ã®å ´å㯠`toErrorCallbackString` ã¡ã½ãããå¼ã³ã ã㦠`PluginResult` ã JavaScript ã«å¤æãã¾ãã + +æå¾ã«ã JavaScript å´ã§æåã¾ãã¯ã¨ã©ã¼ã³ã¼ã«ããã¯é¢æ°ãå®è¡ãããã㪠JavaScript ãæ¸ãåºãã¾ããããæåã³ã¼ã«ããã¯ãå¼ã°ããå ´åã¯ã `echo` ãã©ã¡ã¼ã¿ã¼ããã©ã¡ã¼ã¿ã¼ã¨ãã¦æ¸¡ãã¾ãã + +## 䏿©é²ãã ãã©ã°ã¤ã³ã®æ©è½ + +ä»ã«ãããªã¼ãã¼ã©ã¤ãåºæ¥ãã¡ã½ããã«ã¤ãã¦ã¯ä»¥ä¸ãåç §ãã¦ãã ãã: + +1. [CDVPlugin.h](https://github.com/apache/incubator-cordova-ios/blob/master/CordovaLib/Classes/CDVPlugin.h) +2. [CDVPlugin.m](https://github.com/apache/incubator-cordova-ios/blob/master/CordovaLib/Classes/CDVPlugin.m) + +ä¾ãã°ã pausa, resume, app terminate, handleOpenURL events ã¨ãã£ããããªæ©è½ãå®è£ ã§ãã¾ãã + +## ãã©ã°ã¤ã³ã®ãããã° + +Objective-C å´ã§ãããã°ããã«ã¯ã Xcode ã®ãã«ãã¤ã³ã®ãããã¬ã¼ã使ç¨ãã¾ãã JavaScript å´ã§ã¯ã [Apache Cordova Project ã® Weinre](https://github.com/apache/incubator-cordova-weinre) ã¾ã㯠[ãµã¼ããã¼ãã£è£½ã® iWebInspector](http://www.iwebinspector.com/) ã使ç¨ã§ãã¾ãã + +## ããããè½ã¨ãç©´ + +* Cordova.plist ã«ãã©ã°ã¤ã³ãããã³ã°ã追å ãããã¨ãå¿ããªãã§ãã ãã - ããå¿ãã¦ããå ´åã¯ã Xcode ã®ã³ã³ã½ã¼ã«ãã°ã«ã¨ã©ã¼ã表示ããã¾ã +* æ¥ç¶ãããã¹ã¦ã®ãã¹ãã [ãã¯ã¤ããªã¹ã](guide_whitelist_index.md.html#Domain%20Whitelist%20Guide) ã«è¿½å ãããã¨ãå¿ããªãã§ä¸ãã - ããå¿ãã¦ããå ´åã¯ã Xcode ã®ã³ã³ã½ã¼ã«ãã°ã«ã¨ã©ã¼ã表示ããã¾ã +* ããã¢ããªã復帰ããã¨ãã® onResume() ã¤ãã³ãå ã§ãã¢ã©ã¼ãã¨ãã£ããããªãã¤ãã£ã颿°ãå®è¡ããã¨ãã¢ããªã±ã¼ã·ã§ã³ã忢ãã¦ãã¾ãã¾ããå®å ¨ã®ããã JavaScript å¼ã³åºããã¿ã¤ã ã¢ã¦ãå¤0ã® setTimeout ã§ã©ãããã¦ãã ãã: + + setTimeout(function() { + // ä»»æã®ã³ã¼ã + }, 0); + http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/bb374344/docs/jp/2.0.0/guide/plugin-development/webos/index.md ---------------------------------------------------------------------- diff --git a/docs/jp/2.0.0/guide/plugin-development/webos/index.md b/docs/jp/2.0.0/guide/plugin-development/webos/index.md new file mode 100644 index 0000000..e341f4f --- /dev/null +++ b/docs/jp/2.0.0/guide/plugin-development/webos/index.md @@ -0,0 +1,23 @@ +--- +license: Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--- + +Developing a Plugin on webOS +============================ + +ãã©ã°ã¤ã³ã¯ webOS ãã©ãããã©ã¼ã ã§ã¯ç¾å¨ãµãã¼ãããã¦ãã¾ããã http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/bb374344/docs/jp/2.0.0/guide/plugin-development/windows-phone/index.md ---------------------------------------------------------------------- diff --git a/docs/jp/2.0.0/guide/plugin-development/windows-phone/index.md b/docs/jp/2.0.0/guide/plugin-development/windows-phone/index.md new file mode 100644 index 0000000..35c3cbb --- /dev/null +++ b/docs/jp/2.0.0/guide/plugin-development/windows-phone/index.md @@ -0,0 +1,23 @@ +--- +license: Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--- + +Developing a Plugin on Windows Phone +==================================== + +æºåä¸ã§ã...