Skip to content

Commit 13c10f1

Browse files
committed
Add androidhelper APIs documentation (some parts)
1 parent bff00da commit 13c10f1

29 files changed

+3091
-155
lines changed

docs/_sources/en/guide_androidhelpers.txt

Lines changed: 704 additions & 0 deletions
Large diffs are not rendered by default.

docs/_sources/en/guide_extend.txt

Lines changed: 87 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,59 @@
1-
How to call QPython script in your application?
1+
QPython Open API
22
=====================================================
3-
You could call QPython to run some script or python code in your app
3+
QPython has an open activity which allow you run qpython from outside.
4+
5+
The MPyAPI's definition seems like the following:
46

57
::
68

9+
<activity
10+
android:name="org.qpython.qpylib.MPyApi"
11+
android:label="@string/qpy_run_with_share"
12+
android:screenOrientation="user"
13+
android:configChanges="orientation|keyboardHidden"
14+
android:exported="true">
15+
<intent-filter>
16+
<action android:name="org.qpython.qpylib.action.MPyApi" />
17+
<category android:name="android.intent.category.DEFAULT" />
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
<intent-filter>
21+
<action android:name="android.intent.action.VIEW" />
22+
<category android:name="android.intent.category.DEFAULT" />
23+
<category android:name="android.intent.category.BROWSABLE" />
24+
<data android:scheme="http" />
25+
<data android:scheme="https" />
26+
</intent-filter>
27+
<intent-filter>
28+
<action android:name="android.intent.action.SEND"/>
29+
<category android:name="android.intent.category.DEFAULT"/>
30+
<data android:mimeType="text/plain"/>
31+
</intent-filter>
32+
<intent-filter>
33+
<action android:name="android.intent.action.SEND"/>
34+
<category android:name="android.intent.category.DEFAULT"/>
35+
<data android:mimeType="image/*"/>
36+
</intent-filter>
37+
</activity>
38+
39+
40+
**So, with it's help, you could:**
41+
42+
Share some content to QPython's scripts
43+
---------------------------------------------
44+
You could choose some content in some app, and share to qpython's script, then you could handle the content with the **sys.argv[2]**
45+
46+
`Watch the demo video on YouTube <https://www.youtube.com/watch?v=2Y50Yir8TWg>`_
47+
48+
49+
Run QPython's script from your own application
50+
------------------------------------------------------
51+
52+
You can call QPython to run some script or python code in your application by call this activity, like the following sample:
53+
54+
::
55+
56+
// code sample shows how to call qpython API
757
String extPlgPlusName = "org.qpython.qpy"; // QPython package name
858
Intent intent = new Intent();
959
intent.setClassName(extPlgPlusName, "org.qpython.qpylib.MPyApi");
@@ -12,33 +62,26 @@ You could call QPython to run some script or python code in your app
1262
Bundle mBundle = new Bundle();
1363
mBundle.putString("app", "myappid");
1464
mBundle.putString("act", "onPyApi");
15-
mBundle.putString("flag", "onQPyExec"); // any String flag you may use in your context
16-
mBundle.putString("param", ""); // param String param you may use in your context
65+
mBundle.putString("flag", "onQPyExec"); // any String flag you may use in your context
66+
mBundle.putString("param", ""); // param String param you may use in your context
1767

1868
/*
19-
* The String Python code, you can put your py file in res or raw or intenet, so that you can get it the same way, which can make it scalable
69+
* The Python code we will run
2070
*/
21-
String code = "#qpy:console\n" +
22-
"try:\n" +
23-
" import androidhelper\n" +
24-
"\n" +
25-
" droid = androidhelper.Android()\n" +
26-
" line = droid.dialogGetInput()\n" +
27-
" s = 'Hello %s' % line.result\n" +
28-
" droid.makeToast(s)\n" +
29-
"except:\n" +
30-
" print(\"Hello, Please update to newest QPython version from (http://play.qpython.com/qrcode-python.html) to use this feature\")\n");
31-
71+
String code = "import androidhelper\n" +
72+
"droid = androidhelper.Android()\n" +
73+
"line = droid.dialogGetInput()\n" +
74+
"s = 'Hello %s' % line.result\n" +
75+
"droid.makeToast(s)\n"
3276

3377
mBundle.putString("pycode", code);
3478
intent.putExtras(mBundle);
35-
3679
startActivityForResult(intent, SCRIPT_EXEC_PY);
37-
3880
...
3981

4082

41-
// Deal with the result callback by qpython
83+
84+
// And you can handle the qpython callabck result in onActivityResult
4285
@Override
4386
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
4487
if (requestCode == SCRIPT_EXEC_PY) {
@@ -56,16 +99,33 @@ You could call QPython to run some script or python code in your app
5699
}
57100

58101

102+
`Checkout the full project from github <https://github.com/qpython-android/app-call-qpython-api>`_
103+
104+
And there is `a production application - QPython Plugin for Tasker <https://play.google.com/store/apps/details?id=com.qpython.tasker2>`_
59105

60-
Sample of running QPython script in other application
61-
-------------------------------------------------------
62-
* `You can see this sample project in github <https://github.com/qpython-android/app-call-qpython-api>`_
106+
QPython Online Service
107+
=====================================================
63108

64-
* `Another Application which have published in google play - QPython Plugin for Tasker <https://play.google.com/store/apps/details?id=com.qpython.tasker2>`_
109+
Now the QPython online service only open for QPython, not QPython3.
65110

66-
.. image:: ../_static/taskerplugin-for-qpython.png
67111

68-
How to build an independt APK from QPython scripts?
69-
=====================================================
70-
http://qpy.io
112+
QPypi
113+
---------------------------------------------------------
114+
Can I install some packages which required pre-compiled ?
115+
Sure, you could install some pre-compiled packages from QPypi, you could find it through "Libraries" on dashboard.
116+
117+
118+
.. image:: ../_static/guide_extend_pic2.png
119+
120+
If you couldn't found the package here, you could send email to river@qpython.org .
121+
122+
QPY.IO
123+
---------------------------------------------------
124+
Can I build an independent APK from QPython script?
125+
126+
Sure you can. now the service is **in BETA**, it's a challenging thing. We will publish it as a online service, for we want to let the development process is simple, you don't need to own the development environment set up when you want to build a application.
127+
128+
129+
.. image:: ../_static/guide_extend_pic1.png
71130

131+
If you want to try it out or have some business proposal, please contact with us by sending email to river@qpython.org .

docs/_sources/en/guide_ide.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ QEditor is the QPython's built-in editor, which supports Python / HTML syntax hi
2222
You could run the QPython script directly when you develop from QEditor, so when you are moving it's the most convient way for QPython develop.
2323

2424

25-
Develop from your PC/Laptop's browser
25+
Develop from browser
2626
--------------------------------------
2727
QPython has a built-in script which is **qedit4web.py**, you could see it when you click the start button and choose "Run local script".
2828
After run it, you could see the result.
@@ -44,3 +44,6 @@ Then, you could access the url from your PC/Laptop's browser for developing, jus
4444
With it's help, you could write from browser and run from your android phone. It is very convenient.
4545

4646

47+
Develop from your computer
48+
--------------------------
49+
Besides the above ways, you could develop the script with your way, then upload to your phone and run with QPython also.

docs/_sources/en/guide_libraries.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ QPython built-in Libraries
22
==========================
33
QPython is using the Python 2.7.2 and it support most Python stardard libraries. And you could see their documentation through Python documentation.
44

5-
QPython dynload libraries (python built-in .so libraries)
5+
QPython dynload libraries
66
--------------------------------------------------------------
7+
Just like Python, QPython contains python built-in .so libraries.
8+
79
Usually, you don't need to import them manually, they were used in stardard libraries, and could be imported automatically.
810

911
* _codecs_cn.so

docs/_sources/en/guide_program.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
What can QPython do?
1+
QPython's main features
22
====================================
33

4+
**With QPython, you could build android applications with android application and script language now.**
5+
46

57
Why should I choose QPython
68
------------------------

docs/en/guide.html

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
</ul>
3838
</li>
3939
<li class="toctree-l1"><a class="reference internal" href="#programming-guide">Programming Guide</a><ul>
40-
<li class="toctree-l2"><a class="reference internal" href="guide_program.html">What can QPython do?</a></li>
40+
<li class="toctree-l2"><a class="reference internal" href="guide_program.html">QPython&#8217;s main features</a></li>
4141
<li class="toctree-l2"><a class="reference internal" href="guide_ide.html">Use the best way for developing</a></li>
4242
<li class="toctree-l2"><a class="reference internal" href="guide_libraries.html">QPython built-in Libraries</a></li>
4343
<li class="toctree-l2"><a class="reference internal" href="guide_libraries.html#python-3rd-libraries">Python 3rd Libraries</a></li>
4444
<li class="toctree-l2"><a class="reference internal" href="guide_libraries.html#androidhelper-apis">Androidhelper APIs</a></li>
45-
<li class="toctree-l2"><a class="reference internal" href="guide_extend.html">How to call QPython script in your application?</a></li>
46-
<li class="toctree-l2"><a class="reference internal" href="guide_extend.html#how-to-build-an-independt-apk-from-qpython-scripts">How to build an independt APK from QPython scripts?</a></li>
45+
<li class="toctree-l2"><a class="reference internal" href="guide_extend.html">QPython Open API</a></li>
46+
<li class="toctree-l2"><a class="reference internal" href="guide_extend.html#qpython-online-service">QPython Online Service</a></li>
4747
</ul>
4848
</li>
4949
<li class="toctree-l1"><a class="reference internal" href="#qpython-hackers-guide">QPython Hackers&#8217; Guide</a></li>
@@ -104,18 +104,19 @@ <h1>Programming Guide<a class="headerlink" href="#programming-guide" title="Perm
104104
<p>If you you want to know more about how to program through qpython, just follow these steps:</p>
105105
<div class="toctree-wrapper compound">
106106
<ul>
107-
<li class="toctree-l1"><a class="reference internal" href="guide_program.html">What can QPython do?</a><ul>
107+
<li class="toctree-l1"><a class="reference internal" href="guide_program.html">QPython&#8217;s main features</a><ul>
108108
<li class="toctree-l2"><a class="reference internal" href="guide_program.html#why-should-i-choose-qpython">Why should I choose QPython</a></li>
109-
<li class="toctree-l2"><a class="reference internal" href="guide_program.html#qpython-s-main-features">QPython&#8217;s main features</a></li>
109+
<li class="toctree-l2"><a class="reference internal" href="guide_program.html#id1">QPython&#8217;s main features</a></li>
110110
</ul>
111111
</li>
112112
<li class="toctree-l1"><a class="reference internal" href="guide_ide.html">Use the best way for developing</a><ul>
113113
<li class="toctree-l2"><a class="reference internal" href="guide_ide.html#develop-from-qeditor">Develop from QEditor</a></li>
114-
<li class="toctree-l2"><a class="reference internal" href="guide_ide.html#develop-from-your-pc-laptop-s-browser">Develop from your PC/Laptop&#8217;s browser</a></li>
114+
<li class="toctree-l2"><a class="reference internal" href="guide_ide.html#develop-from-browser">Develop from browser</a></li>
115+
<li class="toctree-l2"><a class="reference internal" href="guide_ide.html#develop-from-your-computer">Develop from your computer</a></li>
115116
</ul>
116117
</li>
117118
<li class="toctree-l1"><a class="reference internal" href="guide_libraries.html">QPython built-in Libraries</a><ul>
118-
<li class="toctree-l2"><a class="reference internal" href="guide_libraries.html#qpython-dynload-libraries-python-built-in-so-libraries">QPython dynload libraries (python built-in .so libraries)</a></li>
119+
<li class="toctree-l2"><a class="reference internal" href="guide_libraries.html#qpython-dynload-libraries">QPython dynload libraries</a></li>
119120
<li class="toctree-l2"><a class="reference internal" href="guide_libraries.html#qpython-stardard-libraries">QPython stardard libraries</a></li>
120121
</ul>
121122
</li>
@@ -150,11 +151,16 @@ <h1>Programming Guide<a class="headerlink" href="#programming-guide" title="Perm
150151
<li class="toctree-l2"><a class="reference internal" href="guide_androidhelpers.html#uifacade">UiFacade</a></li>
151152
</ul>
152153
</li>
153-
<li class="toctree-l1"><a class="reference internal" href="guide_extend.html">How to call QPython script in your application?</a><ul>
154-
<li class="toctree-l2"><a class="reference internal" href="guide_extend.html#sample-of-running-qpython-script-in-other-application">Sample of running QPython script in other application</a></li>
154+
<li class="toctree-l1"><a class="reference internal" href="guide_extend.html">QPython Open API</a><ul>
155+
<li class="toctree-l2"><a class="reference internal" href="guide_extend.html#share-some-content-to-qpython-s-scripts">Share some content to QPython&#8217;s scripts</a></li>
156+
<li class="toctree-l2"><a class="reference internal" href="guide_extend.html#run-qpython-s-script-from-your-own-application">Run QPython&#8217;s script from your own application</a></li>
157+
</ul>
158+
</li>
159+
<li class="toctree-l1"><a class="reference internal" href="guide_extend.html#qpython-online-service">QPython Online Service</a><ul>
160+
<li class="toctree-l2"><a class="reference internal" href="guide_extend.html#qpypi">QPypi</a></li>
161+
<li class="toctree-l2"><a class="reference internal" href="guide_extend.html#qpy-io">QPY.IO</a></li>
155162
</ul>
156163
</li>
157-
<li class="toctree-l1"><a class="reference internal" href="guide_extend.html#how-to-build-an-independt-apk-from-qpython-scripts">How to build an independt APK from QPython scripts?</a></li>
158164
</ul>
159165
</div>
160166
</div>

0 commit comments

Comments
 (0)