Skip to content

Commit 8af6862

Browse files
committed
推送 QPython 3C 3.5.6
1 parent 1524c4b commit 8af6862

File tree

11 files changed

+74
-57
lines changed

11 files changed

+74
-57
lines changed

QPython修改版说明.doc

1 KB
Binary file not shown.

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.qpython.qsl4a.qsl4a.facade;
22

33
import android.app.Service;
4+
import android.content.Context;
45
import android.content.SharedPreferences;
56
import android.content.SharedPreferences.Editor;
67
import android.preference.PreferenceManager;
@@ -34,10 +35,15 @@
3435
public class PreferencesFacade extends RpcReceiver {
3536

3637
private Service mService;
38+
private final AndroidFacade mAndroidFacade;
39+
private final Context context;
3740

3841
public PreferencesFacade(FacadeManager manager) {
3942
super(manager);
43+
mAndroidFacade = manager.getReceiver(AndroidFacade.class);
44+
context = mAndroidFacade.context;
4045
mService = manager.getService();
46+
4147
}
4248

4349
@Rpc(description = "Read a value from shared preferences")
@@ -52,12 +58,12 @@ public Object prefGetValue(
5258
public void prefPutValue(
5359
@RpcParameter(name = "key") String key,
5460
@RpcParameter(name = "value") Object value,
55-
@RpcParameter(name = "filename", description = "Desired preferences file. If not defined, uses the default Shared Preferences.") @RpcOptional String filename)
56-
throws IOException {
61+
@RpcParameter(name = "filename", description = "Desired preferences file. If not defined, uses the default Shared Preferences.") @RpcOptional String filename) {
62+
SharedPreferences p;
5763
if (filename == null || filename.equals("")) {
58-
throw new IOException("Can't write to default preferences.");
59-
}
60-
SharedPreferences p = getPref(filename);
64+
//throw new IOException("Can't write to default preferences.");
65+
p = PreferenceManager.getDefaultSharedPreferences(context);
66+
} else p = getPref(filename);
6167
Editor e = p.edit();
6268
if (value instanceof Boolean) {
6369
e.putBoolean(key, (Boolean) value);
@@ -72,7 +78,7 @@ public void prefPutValue(
7278
} else {
7379
e.putString(key, value.toString());
7480
}
75-
e.commit();
81+
e.apply();
7682
}
7783

7884
@Rpc(description = "Get list of Shared Preference Values", returns = "Map of key,value")

qpython/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apply plugin: 'com.jakewharton.butterknife'
33
apply plugin: 'realm-android'
44

55
//获取系统时间
6-
def releaseTime() {
6+
static def releaseTime() {
77
return new Date().format("yyyyMMdd-HHmmss")
88
}
99

@@ -14,8 +14,8 @@ android {
1414
defaultConfig {
1515
minSdkVersion rootProject.ext.minSdkVersion
1616
targetSdkVersion rootProject.ext.targetSdkVersion
17-
versionCode 355
18-
versionName "3.5.5"
17+
versionCode 356
18+
versionName "3.5.6"
1919
multiDexEnabled true
2020
vectorDrawables.useSupportLibrary = true
2121

809 KB
Binary file not shown.

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,14 +1163,16 @@ private TermSession createPyTermSession(String[] mArgs) throws IOException {
11631163
String shell_type = intent.getStringExtra(TYPE);
11641164
if (shell_type==null) {
11651165
if (mArgs!=null) shell_type = "";
1166-
else shell_type = "1";
1166+
else shell_type = "color";
11671167
}
1168-
if (shell_type.equals("1"))
1168+
if (shell_type.equals("color"))
11691169
mArgs = new String[]{CONF.qpyccs, CONF.qpyccs};
11701170
else if (shell_type.endsWith(".py")) {
11711171
shell_type = CONF.binDir + shell_type;
11721172
mArgs = new String[]{shell_type, shell_type};
1173-
} else
1173+
} else if (shell_type.equals("shell"))
1174+
session = createTermSession(this, settings, "cd && cat text/" + getString(R.string.lang_flag) + "/shell", CONF.filesDir);
1175+
else
11741176
session = createTermSession(this, settings, CONF.binDir + shell_type + " && exit", CONF.filesDir);
11751177
if (mArgs != null) {
11761178
//String content = FileHelper.getFileContents(mArgs[0]);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private void initListener() {
185185
.setItems(chars, (dialog, which) -> {
186186
switch (which) {
187187
case 0:
188-
startShell("1");
188+
startShell("color");
189189
break;
190190
case 1:
191191
startShell("ipython.py");
@@ -197,10 +197,10 @@ private void initListener() {
197197
playPy("browserConsole");
198198
break;
199199
case 4:
200-
startShell("shell.sh");
200+
startShell("shell");
201201
break;
202202
case 5:
203-
startShell("blackConsole.py");
203+
startShell("qpython.sh");
204204
break;
205205
case 6:
206206
startShell("shell.py");

qpython/src/main/java/org/qpython/qpy/main/fragment/SettingFragment.java

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class SettingFragment extends PreferenceFragment {
5959

6060
private SharedPreferences settings;
6161
private Resources resources;
62-
private Preference mPassWordPref, username_pref, portnum_pref, chroot_pref, lastlog;
62+
private Preference mPassWordPref, username_pref, portnum_pref, chroot_pref, lastlog, ipaddress;
6363
private CheckBoxPreference sl4a, running_state, root, display_pwd, qpy_protect;//, notebook_run;
6464

6565
//private PreferenceScreen py_inter,notebook_page;
@@ -75,17 +75,21 @@ private void viewWebSite(int resId) {
7575
@Override
7676
public void onReceive(Context context, Intent intent) {
7777
Log.v(TAG, "FTPServerService action received: " + intent.getAction());
78-
if (intent.getAction().equals(FTPServerService.ACTION_STARTED)) {
79-
running_state.setChecked(true);
80-
// Fill in the FTP server address
81-
setFtpAddress();
82-
} else if (intent.getAction().equals(FTPServerService.ACTION_STOPPED)) {
83-
running_state.setChecked(false);
84-
running_state.setSummary(org.swiftp.R.string.running_summary_stopped);
85-
} else if (intent.getAction().equals(FTPServerService.ACTION_FAILEDTOSTART)) {
86-
running_state.setChecked(false);
87-
running_state.setSummary(org.swiftp.R.string.running_summary_failed);
88-
Toast.makeText(getActivity(),R.string.ip_address_need_wifi_or_ap,Toast.LENGTH_LONG).show();
78+
switch (intent.getAction()) {
79+
case FTPServerService.ACTION_STARTED:
80+
running_state.setChecked(true);
81+
// Fill in the FTP server address
82+
setFtpAddress();
83+
break;
84+
case FTPServerService.ACTION_STOPPED:
85+
running_state.setChecked(false);
86+
running_state.setSummary(org.swiftp.R.string.running_summary_stopped);
87+
break;
88+
case FTPServerService.ACTION_FAILEDTOSTART:
89+
running_state.setChecked(false);
90+
running_state.setSummary(org.swiftp.R.string.running_summary_failed);
91+
Toast.makeText(getActivity(), R.string.ip_address_need_wifi_or_ap, Toast.LENGTH_LONG).show();
92+
break;
8993
}
9094
}
9195
};
@@ -128,8 +132,7 @@ public void onResume() {
128132
super.onResume();
129133
}
130134

131-
private void initSettings() {
132-
Preference ipaddress = findPreference("ipaddress");
135+
private boolean showIpAddress(){
133136
InetAddress ip;
134137
try {
135138
ip = FTPServerService.getWifiAndApIp();
@@ -139,10 +142,18 @@ private void initSettings() {
139142
}
140143
if (ip!=null) {
141144
ipaddress.setSummary(ip.getHostAddress());
145+
return true;
142146
} else {
143147
ipaddress.setSummary(R.string.ip_address_need_wifi_or_ap);
148+
return false;
144149
}
145-
lastlog = (Preference) findPreference("lastlog");
150+
}
151+
152+
private void initSettings() {
153+
ipaddress = findPreference("ipaddress");
154+
showIpAddress();
155+
156+
lastlog = findPreference("lastlog");
146157
//py_inter = (PreferenceScreen) findPreference(getString(R.string.key_py_inter));
147158
/*notebook_page = (PreferenceScreen) findPreference(getString(R.string.key_notebook_page));
148159
notebook_page.setTitle(MessageFormat.format(getString(R.string.notebook_for_py), NAction.getPyVer(getActivity())));
@@ -225,7 +236,7 @@ private void setFtpAddress() {
225236
if (address == null) {
226237
Log.v(TAG, "Unable to retreive wifi ip address");
227238
running_state.setSummary(org.swiftp.R.string.cant_get_url);
228-
Toast.makeText(getActivity(),R.string.ip_address_need_wifi_or_ap,Toast.LENGTH_LONG).show();
239+
Toast.makeText(getActivity(),"FTP: "+getString(R.string.ip_address_need_wifi_or_ap),Toast.LENGTH_LONG).show();
229240
} else {
230241
String iptext = "ftp://" + address.getHostAddress() + ":"
231242
+ FTPServerService.getPort() + "/";
@@ -264,6 +275,8 @@ private void initListener() {
264275
return false;
265276
});
266277

278+
ipaddress.setOnPreferenceClickListener(preference -> showIpAddress());
279+
267280
/*if (!NAction.isQPy3(getActivity())) {
268281
notebook_run.setSummary(getString(R.string.notebook_py3_support));
269282
notebook_run.setEnabled(false);

qpython/src/main/res/values-zh-rCN/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
<string name="add">添加</string>
136136
<string name="sl4a_running">SL4A服务运行中</string>
137137
<string name="service_toggle">服务开关</string>
138-
<string name="qpy_description">QPython 3C是安卓设备Python小程序引擎,支持PyVer、新版SL4A、FileProvider、 DocumentFile、加解密、GUI、音视频播放。</string>
138+
<string name="qpy_description">QPython 3C是安卓设备Python小程序引擎,支持PyVer、新版SL4A、打开文件、写外置卡、加解密、图形界面、音视频播放。</string>
139139
<string name="warning">警告</string>
140140
<string name="reset_warning">将重置所有设置并删除已下载的库,确定重置吗?</string>
141141
<string name="downloading">库文件</string>
@@ -448,7 +448,7 @@
448448
<string name="use_py3">使用 Python 3</string>
449449
<string name="welcome">欢迎使用QPython 3C,享受您的手机编程之旅吧。</string>
450450
<string name="notice">提示</string>
451-
<string name="python_interpreter">黑白Python解释器</string>
451+
<string name="python_interpreter">传统Python解释器</string>
452452
<string name="shell_terminal">传统 Shell 终端</string>
453453
<string name="package_name_title">软件包名</string>
454454
<string name="bili_web_tip">教程/下载/检查更新:</string>

qpython/src/main/res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
<string name="sl4a_running">SL4A server is running</string>
232232
<string name="sl4a_un_running">SL4A server is not running</string>
233233
<string name="service_toggle">Server taggle</string>
234-
<string name="qpy_description">QPython 3C is the Python applet engine for Android devices. It supports PyVer, new SL4A, FileProvider, DocumentFile, encryption and decryption, GUI, audio and video play.</string>
234+
<string name="qpy_description">QPython 3C is the Python applet engine for Android devices. It supports PyVer, new SL4A, Open File, Write External Sdcard, Encryption and Decryption, GUI, Audio and Video Play.</string>
235235
<string name="warning">Warning</string>
236236
<string name="reset_warning">Reset storage will lost all setting and downloaded libs, are you sure you want to reset?</string>
237237
<string name="downloading">Library</string>
@@ -656,7 +656,7 @@
656656
<string name="key_update_qpy3" translatable="false">update_py3</string>
657657
<string name="key_update_qpy2compatible" translatable="false">update_py2compatible</string>
658658

659-
<string name="python_interpreter">BlackWhite Python Interpreter</string>
659+
<string name="python_interpreter">Traditional Python Interpreter</string>
660660
<string name="action_notebook">Notebook</string>
661661

662662
<string name="shell_terminal">Traditional Shell Terminal</string>

termemulator/src/main/java/jackpal/androidterm/emulatorview/EmulatorView.java

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@
1616

1717
package jackpal.androidterm.emulatorview;
1818

19-
import jackpal.androidterm.emulatorview.compat.ClipboardManagerCompat;
20-
import jackpal.androidterm.emulatorview.compat.ClipboardManagerCompatFactory;
21-
import jackpal.androidterm.emulatorview.compat.KeycodeConstants;
22-
import jackpal.androidterm.emulatorview.compat.Patterns;
23-
24-
import java.io.IOException;
25-
import java.util.Arrays;
26-
import java.util.Hashtable;
27-
import java.util.LinkedList;
28-
import java.util.List;
29-
3019
import android.content.Context;
3120
import android.graphics.Canvas;
3221
import android.graphics.Paint;
@@ -55,11 +44,17 @@
5544
import android.view.inputmethod.InputConnection;
5645
import android.widget.Scroller;
5746

58-
import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
59-
import static android.view.inputmethod.EditorInfo.IME_ACTION_NEXT;
60-
import static android.view.inputmethod.EditorInfo.IME_ACTION_NONE;
47+
import java.io.IOException;
48+
import java.util.Arrays;
49+
import java.util.Hashtable;
50+
import java.util.LinkedList;
51+
52+
import jackpal.androidterm.emulatorview.compat.ClipboardManagerCompat;
53+
import jackpal.androidterm.emulatorview.compat.ClipboardManagerCompatFactory;
54+
import jackpal.androidterm.emulatorview.compat.KeycodeConstants;
55+
import jackpal.androidterm.emulatorview.compat.Patterns;
56+
6157
import static android.view.inputmethod.EditorInfo.IME_ACTION_UNSPECIFIED;
62-
import static android.view.inputmethod.EditorInfo.IME_MASK_ACTION;
6358

6459
/**
6560
* A view on a {@link TermSession}. Displays the terminal emulator's screen,
@@ -308,7 +303,7 @@ private int createLinks(int row) {
308303
for (lineLen = 0; line[lineLen] != 0; ++lineLen) ;
309304
}
310305

311-
SpannableStringBuilder textToLinkify = new SpannableStringBuilder(new String(line, 0, lineLen));
306+
SpannableStringBuilder textToLinkify = new SpannableStringBuilder(new String(line, 0, lineLen - 1));//去空格
312307

313308
boolean lineWrap = transcriptScreen.getScriptLineWrap(row);
314309

@@ -333,7 +328,7 @@ private int createLinks(int row) {
333328
for (lineLen = 0; line[lineLen] != 0; ++lineLen) ;
334329
}
335330

336-
textToLinkify.append(new String(line, 0, lineLen));
331+
textToLinkify.append(new String(line, 0, lineLen-1));//去空格
337332

338333
//Check if line after next is wrapped
339334
lineWrap = transcriptScreen.getScriptLineWrap(nextRow);
@@ -657,7 +652,7 @@ public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
657652
private int mSelectedTextEnd;
658653

659654
private void sendText(CharSequence text) {
660-
Log.d(TAG, "sendText:"+text);
655+
//writeToFile("sendText",text.toString());
661656
int n = text.length();
662657
char c;
663658
try {
@@ -1347,7 +1342,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
13471342
} else if (handleFnKey(keyCode, true)) {
13481343
return true;
13491344
} else if (isSystemKey(keyCode, event)) {
1350-
if (!isInterceptedSystemKey(keyCode)) {
1345+
if (allowSystemKey(keyCode)) {
13511346
// Don't intercept the system keys
13521347
return super.onKeyDown(keyCode, event);
13531348
}
@@ -1377,8 +1372,8 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
13771372
/**
13781373
* Do we want to intercept this system key?
13791374
*/
1380-
private boolean isInterceptedSystemKey(int keyCode) {
1381-
return keyCode == KeyEvent.KEYCODE_BACK && mBackKeySendsCharacter;
1375+
private boolean allowSystemKey(int keyCode) {
1376+
return keyCode != KeyEvent.KEYCODE_BACK || !mBackKeySendsCharacter;
13821377
}
13831378

13841379
/**
@@ -1399,7 +1394,7 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
13991394
return true;
14001395
} else if (isSystemKey(keyCode, event)) {
14011396
// Don't intercept the system keys
1402-
if (!isInterceptedSystemKey(keyCode)) {
1397+
if (allowSystemKey(keyCode)) {
14031398
return super.onKeyUp(keyCode, event);
14041399
}
14051400
}

0 commit comments

Comments
 (0)