Skip to content

Commit 7be0476

Browse files
committedFeb 6, 2020
Fixed QPyNotebook issue
1 parent b5e05b2 commit 7be0476

File tree

5 files changed

+18
-125
lines changed

5 files changed

+18
-125
lines changed
 

‎qpysdk/src/main/java/org/qpython/qpysdk/QPySDK.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public void extractRes(final String resource, File target, boolean force) {
276276
Log.d(TAG, "NO EXTRACT");
277277

278278
}
279-
if (resource.startsWith("private")) {
279+
if (resource.startsWith("private") || resource.startsWith("notebook")) {
280280
chmodX();
281281
}
282282
}
@@ -338,12 +338,9 @@ public void extractRes2(final String resource, File target) {
338338
}
339339
}
340340

341-
if (resource.startsWith("private"))
342-
343-
{
341+
if (resource.startsWith("private") || resource.startsWith("notebook")) {
344342
chmodX();
345343
}
346-
347344
}
348345

349346
private void chmodX () {

‎qpython/src/main/assets/notebook3.mp3

30.8 KB
Binary file not shown.

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

+3
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ private void initQPy(boolean py3) {
365365
qpysdk.extractRes(py3?"private31":"private1", HomeMainActivity.this.getFilesDir());
366366
qpysdk.extractRes(py3?"private32":"private2", HomeMainActivity.this.getFilesDir());
367367
qpysdk.extractRes(py3?"private33":"private3", HomeMainActivity.this.getFilesDir());
368+
if (py3) {
369+
qpysdk.extractRes("notebook3", HomeMainActivity.this.getFilesDir());
370+
}
368371
File externalStorage = new File(Environment.getExternalStorageDirectory(), "qpython");
369372
FileHelper.createDirIfNExists(externalStorage + "/cache");
370373
FileHelper.createDirIfNExists(externalStorage + "/log");

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

+11-119
Original file line numberDiff line numberDiff line change
@@ -254,54 +254,6 @@ private void initListener() {
254254
return false;
255255
});
256256

257-
// notebook_res.setOnPreferenceClickListener(preference -> {
258-
// Log.d(TAG, "notebook_res.setOnPreferenceClickListener");
259-
//
260-
// installNotebook();
261-
// return false;
262-
//
263-
// });
264-
265-
// if (isQPycRelease(false)) {
266-
// update_qpy3.setSummary(getString(R.string.choose_py3_inter));
267-
// } else {
268-
// update_qpy3.setSummary(getString(R.string.install_py3_first));
269-
//
270-
// }
271-
// if (isQPycRelease(true)) {
272-
// update_qpy2compatible.setSummary(getString(R.string.choose_py2compatible_inter));
273-
// } else {
274-
// update_qpy2compatible.setSummary(getString(R.string.install_py2compatible_first));
275-
// }
276-
277-
// update_qpy2compatible.setOnPreferenceClickListener(preference -> {
278-
//
279-
// new AlertDialog.Builder(getActivity(), R.style.MyDialog)
280-
// .setTitle(R.string.notice)
281-
// .setMessage(R.string.install_py2compatible_hint)
282-
// .setPositiveButton(R.string.download_it, (dialog1, which)->getQPYC(true))
283-
// .setNegativeButton(R.string.cancel, (dialog1, which) -> dialog1.dismiss())
284-
// .create()
285-
// .show();
286-
//
287-
//
288-
//
289-
// return false;
290-
// });
291-
292-
// update_qpy3.setOnPreferenceClickListener(preference -> {
293-
// Log.d(TAG, "update_qpy3.setOnPreferenceClickListener");
294-
// new AlertDialog.Builder(getActivity(), R.style.MyDialog)
295-
// .setTitle(R.string.notice)
296-
// .setMessage(R.string.install_py3_hint)
297-
// .setPositiveButton(R.string.download_it, (dialog1, which)->getQPYC(false))
298-
// .setNegativeButton(R.string.cancel, (dialog1, which) -> dialog1.dismiss())
299-
// .create()
300-
// .show();
301-
//
302-
// return false;
303-
//
304-
// });
305257
if (!NAction.isQPy3(getActivity())) {
306258
notebook_run.setSummary(getString(R.string.notebook_py3_support));
307259
notebook_run.setEnabled(false);
@@ -310,29 +262,13 @@ private void initListener() {
310262
notebook_run.setChecked(NotebookUtil.isNBSrvSet(getActivity()));
311263

312264
notebook_run.setOnPreferenceChangeListener((preference, newValue) -> {
313-
314-
if (NotebookUtil.isNotebookLibInstall(getActivity())){
315-
316-
if ((boolean)newValue) {
317-
NotebookUtil.startNotebookService2(getActivity());
318-
319-
} else {
320-
NotebookUtil.killNBSrv(getActivity());
321-
}
322-
notebook_page.setSummary(NotebookUtil.isNotebookLibInstall(getActivity())?R.string.notebook_installed : R.string.notebook_not_started);
323-
265+
if ((boolean)newValue) {
266+
NotebookUtil.startNotebookService2(getActivity());
324267

325268
} else {
326-
327-
new AlertDialog.Builder(getActivity(), R.style.MyDialog)
328-
.setTitle(R.string.notice)
329-
.setMessage(R.string.install_notebook_first)
330-
.setPositiveButton(R.string.ok, (dialog1, which) -> releaseNotebook(preference))
331-
.create()
332-
.show();
333-
notebook_run.setChecked(false);
334-
return false;
269+
NotebookUtil.killNBSrv(getActivity());
335270
}
271+
notebook_page.setSummary(NotebookUtil.isNotebookEnable(getActivity())?R.string.notebook_installed : R.string.notebook_not_started);
336272

337273
return true;
338274
});
@@ -346,41 +282,10 @@ private void initListener() {
346282
return false;
347283
});
348284

349-
// py2compatible.setOnPreferenceClickListener(preference -> {
350-
// Log.d(TAG, "py2.setOnPreferenceClickListener");
351-
// NotebookUtil.killNBSrv(getActivity());
352-
//
353-
// if (!isQPycRelease(true)) {
354-
// new AlertDialog.Builder(getActivity(), R.style.MyDialog)
355-
// .setTitle(R.string.notice)
356-
// .setMessage(R.string.install_py2compatible_first)
357-
// .setPositiveButton(R.string.ok, (dialog1, which) -> dialog1.dismiss())
358-
// .create()
359-
// .show();
360-
//
361-
// } else {
362-
// NotebookUtil.killNBSrv(getActivity());
363-
//
364-
// releasePython2Compatable(preference);
365-
// }
366-
// return false;
367-
// });
368-
369285
py3.setOnPreferenceClickListener(preference -> {
370-
// if (!isQPycRelease(false)) {
371-
//
372-
// new AlertDialog.Builder(getActivity(), R.style.MyDialog)
373-
// .setTitle(R.string.notice)
374-
// .setMessage(R.string.install_py3_first)
375-
// .setPositiveButton(R.string.ok, (dialog1, which) -> dialog1.dismiss())
376-
// .create()
377-
// .show();
378-
//
379-
// } else {
380-
NotebookUtil.killNBSrv(getActivity());
381-
382-
releasePython3(preference);
383-
// }
286+
NotebookUtil.killNBSrv(getActivity());
287+
releasePython3(preference);
288+
384289
return false;
385290
});
386291

@@ -751,9 +656,11 @@ private void releasePython3(Preference preference) {
751656
qpysdk.extractRes("private31", getActivity().getFilesDir(), true);
752657
qpysdk.extractRes("private32", getActivity().getFilesDir(), true);
753658
qpysdk.extractRes("private33", getActivity().getFilesDir(),true);
659+
qpysdk.extractRes("notebook3", getActivity().getFilesDir(), true);
660+
754661
File externalStorage = new File(Environment.getExternalStorageDirectory(), "qpython");
755662

756-
qpysdk.extractRes("public", new File(externalStorage + "/lib"));
663+
qpysdk.extractRes("publi3c", new File(externalStorage + "/lib"));
757664

758665
subscriber.onNext(true);
759666
subscriber.onCompleted();
@@ -1020,19 +927,6 @@ public void complete(String name, File installer) {
1020927
} catch (Exception e) {
1021928

1022929
}
1023-
// try {
1024-
// if (ispy2compatible) {
1025-
// update_qpy2compatible.setSummary(getString(R.string.choose_py2compatible_inter));
1026-
//
1027-
// } else {
1028-
// update_qpy3.setSummary(getString(R.string.choose_py3_inter));
1029-
// }
1030-
//
1031-
// Toast.makeText(App.getContext(), R.string.file_downloaded, Toast.LENGTH_SHORT).show();
1032-
// } catch (Exception e) {
1033-
//
1034-
// }
1035-
1036930
}
1037931

1038932
@Override
@@ -1066,9 +960,7 @@ private boolean isQPycRelease(boolean ispy2compatible) {
1066960
}
1067961
return isRelease;
1068962
}
1069-
1070-
1071-
963+
1072964
private void removeQPyc2Core() {
1073965
Log.d(TAG, "removeQPyc2Core");
1074966
String files = getActivity().getFilesDir().getAbsolutePath();

‎qpython/src/main/java/org/qpython/qpy/utils/NotebookUtil.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public static boolean isNotebookEnable(Context context) {
6363
*/
6464
public static boolean isNotebookInstall(Context context) {
6565
if (NAction.isQPy3(context)) {
66-
return new File(RELEASE_PATH, context.getString(R.string.notebook3libs_file_name)).exists();
66+
return true;
67+
//return new File(RELEASE_PATH, context.getString(R.string.notebook3libs_file_name)).exists();
6768

6869
} else {
6970
return new File(RELEASE_PATH, context.getString(R.string.notebook2libs_file_name)).exists();

0 commit comments

Comments
 (0)
Please sign in to comment.