@@ -74,8 +74,8 @@ public class SettingFragment extends PreferenceFragment {
74
74
private CheckBoxPreference sl4a , running_state , root , display_pwd , notebook_run ;
75
75
76
76
private PreferenceScreen py_inter ,notebook_page ;
77
- private Preference py3 ,py2 , py2compatible , notebook_res ;
78
- private Preference update_qpy3 ,update_qpy2compatible ;
77
+ private Preference py3 ,py2 ; //notebook_res, py2compatible
78
+ // private Preference update_qpy3,update_qpy2compatible;
79
79
80
80
private SwitchPreference log , app ;
81
81
private BroadcastReceiver ftpServerReceiver = new BroadcastReceiver () {
@@ -149,16 +149,22 @@ private void initSettings() {
149
149
py_inter = (PreferenceScreen ) findPreference (getString (R .string .key_py_inter ));
150
150
notebook_page = (PreferenceScreen ) findPreference (getString (R .string .key_notebook_page ));
151
151
notebook_page .setTitle (MessageFormat .format (getString (R .string .notebook_for_py ), NAction .getPyVer (getActivity ())));
152
- notebook_page .setSummary (NotebookUtil .isNotebookLibInstall (getActivity ())?R .string .notebook_installed : R .string .notebook_not_install );
152
+ if (NAction .isQPy3 (getActivity ())) {
153
+ notebook_page .setSummary (NotebookUtil .isNotebookLibInstall (getActivity ()) ? R .string .notebook_installed : R .string .notebook_not_started );
153
154
154
- notebook_res = (Preference ) findPreference (getString (R .string .key_notebook ));
155
- notebook_res .setSummary ((NotebookUtil .isNotebookLibInstall (getActivity ())||NotebookUtil .isNotebookInstall (getActivity ()))?R .string .choose_notebook_inter :R .string .install_notebook_first );
155
+ } else {
156
+ notebook_page .setSummary ( R .string .notebook_py3_support );
157
+
158
+ }
159
+
160
+ //notebook_res = (Preference) findPreference(getString(R.string.key_notebook));
161
+ //notebook_res.setSummary((NotebookUtil.isNotebookLibInstall(getActivity())||NotebookUtil.isNotebookInstall(getActivity()))?R.string.choose_notebook_inter:R.string.install_notebook_first);
156
162
notebook_run = (CheckBoxPreference ) findPreference (getString (R .string .key_notebook_run ));
157
163
158
- update_qpy3 = (Preference )findPreference (getString (R .string .key_update_qpy3 ));
159
- update_qpy2compatible = (Preference )findPreference (getString (R .string .key_update_qpy2compatible ));
164
+ // update_qpy3 = (Preference)findPreference(getString(R.string.key_update_qpy3));
165
+ // update_qpy2compatible = (Preference)findPreference(getString(R.string.key_update_qpy2compatible));
160
166
py2 = (Preference ) findPreference (getString (R .string .key_py2 ));
161
- py2compatible = (Preference ) findPreference (getString (R .string .key_py2compatible ));
167
+ // py2compatible = (Preference) findPreference(getString(R.string.key_py2compatible));
162
168
py3 = (Preference ) findPreference (getString (R .string .key_py3 ));
163
169
164
170
@@ -248,93 +254,100 @@ private void initListener() {
248
254
return false ;
249
255
});
250
256
251
- notebook_res .setOnPreferenceClickListener (preference -> {
252
- Log .d (TAG , "notebook_res.setOnPreferenceClickListener" );
253
-
254
- installNotebook ();
255
- return false ;
256
-
257
- });
257
+ // notebook_res.setOnPreferenceClickListener(preference -> {
258
+ // Log.d(TAG, "notebook_res.setOnPreferenceClickListener");
259
+ //
260
+ // installNotebook();
261
+ // return false;
262
+ //
263
+ // });
258
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
+ // });
305
+ if (!NAction .isQPy3 (getActivity ())) {
306
+ notebook_run .setSummary (getString (R .string .notebook_py3_support ));
307
+ notebook_run .setEnabled (false );
259
308
260
- if (isQPycRelease (false )) {
261
- update_qpy3 .setSummary (getString (R .string .choose_py3_inter ));
262
309
} else {
263
- update_qpy3 . setSummary ( getString ( R . string . install_py3_first ));
310
+ notebook_run . setChecked ( NotebookUtil . isNBSrvSet ( getActivity () ));
264
311
265
- }
266
- if (isQPycRelease (true )) {
267
- update_qpy2compatible .setSummary (getString (R .string .choose_py2compatible_inter ));
268
- } else {
269
- update_qpy2compatible .setSummary (getString (R .string .install_py2compatible_first ));
270
- }
312
+ notebook_run .setOnPreferenceChangeListener ((preference , newValue ) -> {
271
313
272
- update_qpy2compatible . setOnPreferenceClickListener ( preference -> {
314
+ if ( NotebookUtil . isNotebookInstall ( getActivity ()) && ! NotebookUtil . isNotebookLibInstall ( getActivity ())) {
273
315
274
- new AlertDialog .Builder (getActivity (), R .style .MyDialog )
275
- .setTitle (R .string .notice )
276
- .setMessage (R .string .install_py2compatible_hint )
277
- .setPositiveButton (R .string .download_it , (dialog1 , which )->getQPYC (true ))
278
- .setNegativeButton (R .string .cancel , (dialog1 , which ) -> dialog1 .dismiss ())
279
- .create ()
280
- .show ();
281
-
282
-
283
-
284
- return false ;
285
- });
286
-
287
- update_qpy3 .setOnPreferenceClickListener (preference -> {
288
- Log .d (TAG , "update_qpy3.setOnPreferenceClickListener" );
289
- new AlertDialog .Builder (getActivity (), R .style .MyDialog )
290
- .setTitle (R .string .notice )
291
- .setMessage (R .string .install_py3_hint )
292
- .setPositiveButton (R .string .download_it , (dialog1 , which )->getQPYC (false ))
293
- .setNegativeButton (R .string .cancel , (dialog1 , which ) -> dialog1 .dismiss ())
294
- .create ()
295
- .show ();
296
-
297
- return false ;
298
-
299
- });
300
-
301
- notebook_run .setChecked (NotebookUtil .isNBSrvSet (getActivity ()));
316
+ releaseNotebook (preference );
317
+ /*new AlertDialog.Builder(getActivity(), R.style.MyDialog)
318
+ .setTitle(R.string.notice)
319
+ .setMessage(R.string.notebook_first)
320
+ .setPositiveButton(R.string.ok, (dialog1, which) -> )
321
+ .create()
322
+ .show();*/
302
323
303
- notebook_run .setOnPreferenceChangeListener ((preference , newValue ) -> {
304
324
305
- if (NotebookUtil .isNotebookInstall ( getActivity ()) && ! NotebookUtil . isNotebookLibInstall (getActivity ())) {
325
+ } else if (NotebookUtil .isNotebookLibInstall (getActivity ())){
306
326
307
- releaseNotebook (preference );
308
- /*new AlertDialog.Builder(getActivity(), R.style.MyDialog)
309
- .setTitle(R.string.notice)
310
- .setMessage(R.string.notebook_first)
311
- .setPositiveButton(R.string.ok, (dialog1, which) -> )
312
- .create()
313
- .show();*/
327
+ if ((boolean )newValue ) {
328
+ NotebookUtil .startNotebookService2 (getActivity ());
314
329
330
+ } else {
331
+ NotebookUtil .killNBSrv (getActivity ());
332
+ }
333
+ notebook_page .setSummary (NotebookUtil .isNotebookLibInstall (getActivity ())?R .string .notebook_installed : R .string .notebook_not_started );
315
334
316
- } else if (NotebookUtil .isNotebookLibInstall (getActivity ())){
317
335
318
- if ((boolean )newValue ) {
319
- NotebookUtil .startNotebookService2 (getActivity ());
320
336
} else {
321
- NotebookUtil .killNBSrv (getActivity ());
322
- }
323
-
324
- } else {
325
337
326
- new AlertDialog .Builder (getActivity (), R .style .MyDialog )
327
- .setTitle (R .string .notice )
328
- .setMessage (R .string .install_notebook_first )
329
- .setPositiveButton (R .string .ok , (dialog1 , which ) -> dialog1 .dismiss ())
330
- .create ()
331
- .show ();
332
- notebook_run .setChecked (false );
333
- return false ;
334
- }
338
+ new AlertDialog .Builder (getActivity (), R .style .MyDialog )
339
+ .setTitle (R .string .notice )
340
+ .setMessage (R .string .install_notebook_first )
341
+ .setPositiveButton (R .string .ok , (dialog1 , which ) -> dialog1 .dismiss ())
342
+ .create ()
343
+ .show ();
344
+ notebook_run .setChecked (false );
345
+ return false ;
346
+ }
335
347
336
- return true ;
337
- });
348
+ return true ;
349
+ });
350
+ }
338
351
339
352
py2 .setOnPreferenceClickListener (preference -> {
340
353
Log .d (TAG , "py2.setOnPreferenceClickListener" );
@@ -344,25 +357,25 @@ private void initListener() {
344
357
return false ;
345
358
});
346
359
347
- py2compatible .setOnPreferenceClickListener (preference -> {
348
- Log .d (TAG , "py2.setOnPreferenceClickListener" );
349
- NotebookUtil .killNBSrv (getActivity ());
350
-
351
- if (!isQPycRelease (true )) {
352
- new AlertDialog .Builder (getActivity (), R .style .MyDialog )
353
- .setTitle (R .string .notice )
354
- .setMessage (R .string .install_py2compatible_first )
355
- .setPositiveButton (R .string .ok , (dialog1 , which ) -> dialog1 .dismiss ())
356
- .create ()
357
- .show ();
358
-
359
- } else {
360
- NotebookUtil .killNBSrv (getActivity ());
361
-
362
- releasePython2Compatable (preference );
363
- }
364
- return false ;
365
- });
360
+ // py2compatible.setOnPreferenceClickListener(preference -> {
361
+ // Log.d(TAG, "py2.setOnPreferenceClickListener");
362
+ // NotebookUtil.killNBSrv(getActivity());
363
+ //
364
+ // if (!isQPycRelease(true)) {
365
+ // new AlertDialog.Builder(getActivity(), R.style.MyDialog)
366
+ // .setTitle(R.string.notice)
367
+ // .setMessage(R.string.install_py2compatible_first)
368
+ // .setPositiveButton(R.string.ok, (dialog1, which) -> dialog1.dismiss())
369
+ // .create()
370
+ // .show();
371
+ //
372
+ // } else {
373
+ // NotebookUtil.killNBSrv(getActivity());
374
+ //
375
+ // releasePython2Compatable(preference);
376
+ // }
377
+ // return false;
378
+ // });
366
379
367
380
py3 .setOnPreferenceClickListener (preference -> {
368
381
// if (!isQPycRelease(false)) {
@@ -605,21 +618,27 @@ public void onError(Throwable e) {
605
618
@ Override
606
619
public void onNext (Boolean aBoolean ) {
607
620
Log .d (TAG , "onNext" );
608
-
621
+
609
622
NotebookUtil .startNotebookService2 (getActivity ());
623
+ notebook_page .setSummary (NotebookUtil .isNotebookLibInstall (getActivity ())?R .string .notebook_installed : R .string .notebook_not_started );
624
+
610
625
611
626
}
612
627
});
613
628
}
614
629
615
630
private void installNotebook () {
616
- new AlertDialog .Builder (getActivity (), R .style .MyDialog )
617
- .setTitle (R .string .notice )
618
- .setMessage (R .string .install_notebook_hint )
619
- .setPositiveButton (R .string .download_it , (dialog1 , which )->getNotebook ())
620
- .setNegativeButton (R .string .cancel , (dialog1 , which ) -> dialog1 .dismiss ())
621
- .create ()
622
- .show ();
631
+ new Thread (() -> {
632
+ QPySDK qpySDK = new QPySDK (App .getContext (), getActivity ());
633
+ qpySDK .extractRes ("notebook" + (NAction .isQPy3 (getActivity ()) ? "3" : "2" ), new File (NotebookUtil .RELEASE_PATH ));
634
+ }).run ();
635
+ // new AlertDialog.Builder(getActivity(), R.style.MyDialog)
636
+ // .setTitle(R.string.notice)
637
+ // .setMessage(R.string.install_notebook_hint)
638
+ // .setPositiveButton(R.string.download_it, (dialog1, which)->getNotebook())
639
+ // .setNegativeButton(R.string.cancel, (dialog1, which) -> dialog1.dismiss())
640
+ // .create()
641
+ // .show();
623
642
}
624
643
625
644
@@ -652,7 +671,7 @@ private void releaseQPycRes(String path) {
652
671
private void releasePython2Standard (Preference preference ) {
653
672
Observable .create ((Observable .OnSubscribe <Boolean >) subscriber -> {
654
673
try {
655
- removeQPyc2Core ();
674
+ // removeQPyc2Core();
656
675
QPySDK qpysdk = new QPySDK (getActivity (), getActivity ());
657
676
qpysdk .extractRes ("private1" , getActivity ().getFilesDir (), true );
658
677
qpysdk .extractRes ("private2" , getActivity ().getFilesDir (), true );
@@ -695,7 +714,7 @@ private void releasePython2Compatable(Preference preference) {
695
714
Observable .create ((Observable .OnSubscribe <Boolean >) subscriber -> {
696
715
try {
697
716
698
- removeQPyc2Core ();
717
+ // removeQPyc2Core();
699
718
700
719
extractQPyCore (true );
701
720
@@ -1012,18 +1031,18 @@ public void complete(String name, File installer) {
1012
1031
} catch (Exception e ) {
1013
1032
1014
1033
}
1015
- try {
1016
- if (ispy2compatible ) {
1017
- update_qpy2compatible .setSummary (getString (R .string .choose_py2compatible_inter ));
1018
-
1019
- } else {
1020
- update_qpy3 .setSummary (getString (R .string .choose_py3_inter ));
1021
- }
1022
-
1023
- Toast .makeText (App .getContext (), R .string .file_downloaded , Toast .LENGTH_SHORT ).show ();
1024
- } catch (Exception e ) {
1025
-
1026
- }
1034
+ // try {
1035
+ // if (ispy2compatible) {
1036
+ // update_qpy2compatible.setSummary(getString(R.string.choose_py2compatible_inter));
1037
+ //
1038
+ // } else {
1039
+ // update_qpy3.setSummary(getString(R.string.choose_py3_inter));
1040
+ // }
1041
+ //
1042
+ // Toast.makeText(App.getContext(), R.string.file_downloaded, Toast.LENGTH_SHORT).show();
1043
+ // } catch (Exception e) {
1044
+ //
1045
+ // }
1027
1046
1028
1047
}
1029
1048
0 commit comments