Skip to content

Commit 190ce13

Browse files
committed
推送 QPython 3C 3.5.5
1 parent 33d78af commit 190ce13

16 files changed

Lines changed: 116 additions & 81 deletions

File tree

QPython修改版说明.doc

-1 KB
Binary file not shown.

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@
55

66
Welcome to the QPython project!
77

8-
QPython is the Python engine for android. It contains some amazing features such as Python interpreter, runtime environment, editor and QPYPI and integrated SL4A. It makes it easy for you to use Python on Android. And it's FREE.
8+
QPython is the Python engine for android. It contains some amazing features such as Python interpreter, runtime environment, editor and QPYI and integrated SL4A. It makes it easy for you to use Python on Android. And it's FREE.
99

1010
Compared with other Python apps, QPython mainly solves how to use Python to drive your Android device work. Good SL4A support is our main goal, such as android's camera, sensor, sms media APIs etc.
1111

1212
QPython already has millions of users worldwide and it is also an open source project.
1313

14-
For different usage scenarios, QPython has three branches, namely QPython Ox , 3x and 3C .
14+
For different usage scenarios, QPython has two branches, namely QPython Ox and 3x.
1515

1616
QPython Ox is mainly aimed at programming learners, and it provides more friendly features for beginners.
1717
QPython 3x is mainly for experienced Python users, and it provides some advanced technical features.
18-
QPython 3C is mainly aimed at Android 7.0 to 12.0, and it provides a lot of advanced technical features .
1918

2019
## Quick start
2120

22-
This repository is the QPython 3C project repository, you can follow the below steps to run it.
21+
This repository is the QPython Ox project repository, you can follow the below steps to run it.
2322

2423
- Macos + Android studio, (Ubuntu may work too)
25-
- git clone https://github.com/buddygr/qpython-3c.git
24+
- git clone git@github.com:qpython-android/qpython.git
2625
- git submodule init
2726
- git submodule sync
2827
- git submodule update
@@ -60,11 +59,8 @@ Please tell us your phone's informatioin, android os information, QPython branch
6059

6160
## Donation
6261

63-
### Original Version
6462
- harford (Wechat)
6563
- 晨晖 (Wechat)
66-
- ### Edited (3C) Version
67-
- 乘着船 (Bilibili)
6864

6965
THANK YOU VERY MUCH FOR DONATION!
7066

qpysl4a/src/main/java/org/qpython/qsl4a/qsl4a/facade/WifiFacade.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@
2727

2828
import java.io.BufferedReader;
2929
import java.io.FileReader;
30+
import java.lang.reflect.Array;
3031
import java.lang.reflect.Field;
3132
import java.lang.reflect.Method;
33+
import java.net.InetAddress;
34+
import java.net.NetworkInterface;
35+
import java.net.SocketException;
36+
import java.util.Arrays;
37+
import java.util.Collections;
3238
import java.util.HashMap;
3339
import java.util.List;
3440
import java.util.Map;
@@ -200,6 +206,36 @@ public Map getDhcpInfo(@RpcParameter(name="ipConvertToString") @RpcDefault("true
200206
return map;
201207
}
202208

209+
@Rpc(description = "get Internet Interface Address")
210+
public Map getInternetInterfaceAddress() throws SocketException {
211+
Map map = new HashMap();
212+
for (NetworkInterface intf : Collections.list(NetworkInterface.getNetworkInterfaces())) {
213+
JSONArray array = new JSONArray();
214+
for (InetAddress addr : Collections.list(intf.getInetAddresses())) {
215+
if (!addr.isLoopbackAddress()){
216+
//map.put("addresses"+n, Arrays.toString(addr.getAddress()));
217+
//map.put("hostAddress",addr.getHostAddress());
218+
//map.put("hostName"+n,addr.getHostName());
219+
//map.put("canonicalHostName"+n,addr.getCanonicalHostName());
220+
//map.put("interface"+n,intf.toString());
221+
//map.put("interfaceName",intf.getName());
222+
//map.put("interfaceUp"+n,intf.isUp());
223+
array.put(addr.getHostAddress());
224+
}
225+
}
226+
if (array.length()>0)
227+
map.put(intf.getName(),array);
228+
}
229+
/*WifiInfo info = mWifi.getConnectionInfo();
230+
int ip = info.getIpAddress();
231+
if (ipConvertToString) {
232+
return intToIp(ip);
233+
} else {
234+
return String.valueOf(ip);
235+
}*/
236+
return map;
237+
}
238+
203239
/*@Rpc(description = "wifi set ap enabled .")
204240
public String[] wifiSetApEnabled(
205241
@RpcParameter(name = "enabled") Boolean enabled

qpython/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
defaultConfig {
1515
minSdkVersion rootProject.ext.minSdkVersion
1616
targetSdkVersion rootProject.ext.targetSdkVersion
17-
versionCode 354
18-
versionName "3.5.4"
17+
versionCode 355
18+
versionName "3.5.5"
1919
multiDexEnabled true
2020
vectorDrawables.useSupportLibrary = true
2121

121 KB
Binary file not shown.

qpython/src/main/java/org/qpython/qpy/console/ScriptExec.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public String[] getPyEnv(Context context, String path, String term, String pyPat
130130
String[] env = new String[24];
131131

132132
env[0] = "TERM=" + term;
133-
env[1] = "PATH=" + context.getFilesDir()+"/bin"+":"+path;
133+
env[1] = "PATH=" + CONF.filesDir+"/bin"+":"+path;
134134

135135
/*if (!isQPy3) {
136136
File py27so = new File(filesDir+"/lib/libpython2.7.so.1.0");
@@ -339,9 +339,7 @@ public void playCScript(Context context, final String scriptPath, String arg) {
339339
} else {
340340
args = new String[]{scriptPath, scriptPath, arg};
341341
}
342-
343342
execPyInConsole((Activity)context, args);
344-
345343
}
346344

347345
/*

qpython/src/main/java/org/qpython/qpy/console/ShellTermSession.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import org.qpython.qpy.console.compont.FileCompat;
2828
import org.qpython.qpy.console.util.TermSettings;
29+
import org.qpython.qpy.main.app.CONF;
2930

3031
import java.io.File;
3132
import java.io.FileNotFoundException;
@@ -111,7 +112,7 @@ private void initializeSession() throws IOException {
111112

112113
String[] env = ScriptExec.getInstance().getPyEnv(context, path, settings.getTermType(), pyPath);
113114

114-
File enf = new File(context.getFilesDir()+"/bin/init.sh");
115+
File enf = new File(CONF.binDir +"init.sh");
115116
//if (! enf.exists()) {
116117
String content = "#!/system/bin/sh";
117118
for (int i=0;i<env.length;i++) {

qpython/src/main/java/org/qpython/qpy/console/TermActivity.java

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public class TermActivity extends AppCompatActivity implements UpdateCallback, S
107107
public static final int REQUEST_CHOOSE_WINDOW = 1;
108108
public static final String EXTRA_WINDOW_ID = "jackpal.androidterm.window_id";
109109
public static final String ARGS = "PYTHONARGS";
110+
public static final String TYPE = "shell_type";
110111
/**
111112
* The name of the ViewFlipper in the resources.
112113
*/
@@ -259,7 +260,7 @@ public static void startActivity(Context context) {
259260

260261
public static void startShell(Context context,String shell_type) {
261262
Intent intent = new Intent(context, TermActivity.class);
262-
intent.putExtra("shell_type",shell_type);
263+
intent.putExtra(TYPE,shell_type);
263264
context.startActivity(intent);
264265
}
265266

@@ -486,17 +487,13 @@ private void populateViewFlipper() throws IOException {
486487
Log.d("TermActivity", "populateViewFlipper");
487488
if (mTermService != null) {
488489
mTermSessions = mTermService.getSessions();
489-
String[] mArgs = this.getIntent().getStringArrayExtra(ARGS);
490-
if (mArgs != null) {
490+
Intent intent = this.getIntent();
491+
String[] mArgs = intent.getStringArrayExtra(ARGS);
492+
String shell_type = intent.getStringExtra(TYPE);
493+
if (mArgs != null || shell_type != null) {
491494
mTermSessions.add(createPyTermSession(mArgs));
492-
} else {
493-
mArgs = this.getIntent().getStringArrayExtra("ARGS");
494-
if (mArgs != null) {
495-
mTermSessions.add(createPyTermSession(mArgs));
496-
497-
} else if (mTermSessions.size() == 0) {
495+
} else if (mTermSessions.size() == 0) {
498496
mTermSessions.add(createPyTermSession(null));
499-
}
500497
}
501498
//存在内存泄漏
502499
mTermSessions.addCallback(this);
@@ -1163,28 +1160,18 @@ private TermSession createPyTermSession(String[] mArgs) throws IOException {
11631160
TermSettings settings = mSettings;
11641161
TermSession session = null;
11651162
Intent intent = this.getIntent();
1166-
String shell_type = intent.getStringExtra("shell_type");
1163+
String shell_type = intent.getStringExtra(TYPE);
11671164
if (shell_type==null) {
11681165
if (mArgs!=null) shell_type = "";
1169-
else shell_type = "color";
1170-
}
1171-
switch (shell_type) {
1172-
case "color":
1173-
mArgs = new String[]{CONF.qpyccs, CONF.qpyccs};
1174-
break;
1175-
case "shell":
1176-
session = createTermSession(this, settings, "cd $HOME && cat text/" + getString(R.string.lang_flag) + "/shell", this.getFilesDir().getAbsolutePath());
1177-
break;
1178-
case "black":
1179-
shell_type = CONF.filesDir+"/bin/blackConsole.py";
1180-
mArgs = new String[]{shell_type,shell_type};
1181-
break;
1182-
/*case "tradition":
1183-
String scmd = getScmd() + " && exit";
1184-
session = createTermSession(this, settings, scmd, "");
1185-
Toast.makeText(this,getString(R.string.tradition_bug),Toast.LENGTH_LONG).show();
1186-
break;*/
1187-
}
1166+
else shell_type = "1";
1167+
}
1168+
if (shell_type.equals("1"))
1169+
mArgs = new String[]{CONF.qpyccs, CONF.qpyccs};
1170+
else if (shell_type.endsWith(".py")) {
1171+
shell_type = CONF.binDir + shell_type;
1172+
mArgs = new String[]{shell_type, shell_type};
1173+
} else
1174+
session = createTermSession(this, settings, CONF.binDir + shell_type + " && exit", CONF.filesDir);
11881175
if (mArgs != null) {
11891176
//String content = FileHelper.getFileContents(mArgs[0]);
11901177
//String cmd = settings.getInitialCommand().equals("")?scmd:settings.getInitialCommand();

qpython/src/main/java/org/qpython/qpy/main/activity/HomeMainActivity.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ public void getPyVer(boolean once) {
113113
pyVer = qpysdk.getPyVer();
114114
CONF.pyVerComplete = pyVer[1];
115115
CONF.pyVer = pyVer[0];
116-
if (!once) runShortcut(getIntent());
116+
//可以消除终端中文输入的某些bug,虽然不知道为什么
117+
if (once) startShell("init.sh");
118+
else runShortcut(getIntent());
117119
}
118120
catch (Exception e){
119121
if (once) initQPy();
@@ -136,10 +138,13 @@ protected void onNewIntent(Intent intent) {
136138
runShortcut(intent);
137139
}
138140

141+
private void startShell(String name){
142+
TermActivity.startShell(this,name);
143+
}
144+
139145
private void playPy(String name){
140-
final String bin = getFilesDir().getAbsolutePath()+"/bin/";
141146
ScriptExec.getInstance().playScript(HomeMainActivity.this,
142-
bin+name+".py", null, false);
147+
CONF.binDir+name+".py", null, false);
143148
}
144149

145150
private void initListener() {
@@ -172,17 +177,18 @@ private void initListener() {
172177
this.getString(R.string.sl4a_gui_console),
173178
this.getString(R.string.browser_console),
174179
this.getString(R.string.shell_terminal),
175-
this.getString(R.string.python_interpreter)
180+
this.getString(R.string.python_interpreter),
181+
this.getString(R.string.python_shell_terminal),
176182
};
177183
new AlertDialog.Builder(this, R.style.MyDialog)
178184
.setTitle(R.string.choose_action)
179185
.setItems(chars, (dialog, which) -> {
180186
switch (which) {
181187
case 0:
182-
playPy("colorConsole");
188+
startShell("1");
183189
break;
184190
case 1:
185-
playPy("ipython");
191+
startShell("ipython.py");
186192
break;
187193
case 2:
188194
playPy("SL4A_GUI_Console");
@@ -191,10 +197,14 @@ private void initListener() {
191197
playPy("browserConsole");
192198
break;
193199
case 4:
194-
TermActivity.startShell(HomeMainActivity.this,"shell");
200+
startShell("shell.sh");
195201
break;
196202
case 5:
197-
playPy("blackConsole");
203+
startShell("blackConsole.py");
204+
break;
205+
case 6:
206+
startShell("shell.py");
207+
break;
198208
}
199209
}).setNegativeButton(getString(R.string.close), (dialogInterface, i) -> dialogInterface.dismiss())
200210
.show();

qpython/src/main/java/org/qpython/qpy/main/app/CONF.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@ public class CONF implements QPyConstants {
2323

2424
public static final String filesDir = App.getContext().getFilesDir().getAbsolutePath();
2525

26-
public static String qpypiPath() {
27-
return filesDir +
28-
"/lib/"+pyVer/*python"+(NAction.isQPy3(App.getContext())?QPyConstants.py3Ver:"2.7")*/+"/site-packages/";
29-
}
30-
31-
public static final String pytho = filesDir + "/bin/python";
32-
public static final String qpysh = filesDir + "/bin/qpython.sh";
33-
public static final String qpyshr = filesDir + "/bin/qpython-root.sh";
34-
public static final String qpyccs = filesDir + "/bin/colorConsole.py";
26+
public static final String binDir = filesDir + "/bin/";
27+
public static final String pytho = binDir + "python";
28+
public static final String qpysh = binDir + "qpython.sh";
29+
public static final String qpyshr = binDir + "qpython-root.sh";
30+
public static final String qpyccs = binDir + "colorConsole.py";
31+
public static final String qpypiPath = filesDir + "/lib/"+pyVer+"/site-packages/";
3532

3633
}

0 commit comments

Comments
 (0)