@@ -56,10 +56,10 @@ public class PythonActivity extends Activity implements Runnable {
56
56
private File mPath = null ;
57
57
private File mScript ;
58
58
59
- boolean _isPaused = false ;
60
-
59
+ boolean _isPaused = false ;
60
+
61
61
private static final String DB_INITIALIZED = "db_initialized" ;
62
-
62
+
63
63
boolean isMain = false ;
64
64
65
65
public final static int PY_NOTI_FLAG = 123400 ;
@@ -115,19 +115,19 @@ protected void onCreate(Bundle savedInstanceState) {
115
115
// Otherwise, we use the public data, if we have it, or the
116
116
// private data if we do not.
117
117
String act = getIntent ().getStringExtra (EXTRA_CONTENT_URL1 );
118
-
118
+
119
119
boolean fullscreen = false ;
120
120
if (act !=null && act .equals ("execute" )) {
121
121
mPath = new File (getIntent ().getStringExtra (EXTRA_CONTENT_URL2 ));
122
-
122
+
123
123
File f = new File (mPath , "main.py" );
124
124
if (f .exists ()) {
125
125
if (FileHelper .getFileContents (f .toString ()).contains ("#qpy:fullscreen" )) {
126
126
fullscreen = true ;
127
127
}
128
128
}
129
-
130
-
129
+
130
+
131
131
Project p = Project .scanDirectory (mPath );
132
132
133
133
if (p != null ) {
@@ -136,7 +136,7 @@ protected void onCreate(Bundle savedInstanceState) {
136
136
} else {
137
137
setRequestedOrientation (ActivityInfo .SCREEN_ORIENTATION_PORTRAIT );
138
138
}
139
-
139
+
140
140
if ( p .fullscreen ) {
141
141
fullscreen = true ;
142
142
}
@@ -146,7 +146,7 @@ protected void onCreate(Bundle savedInstanceState) {
146
146
String fn = getIntent ().getStringExtra (EXTRA_CONTENT_URL2 );
147
147
if (fn == null ) {
148
148
isMain = true ;
149
-
149
+
150
150
fn = "/sdcard/qpython/launcher.py" ;
151
151
}
152
152
mScript = new File (fn );
@@ -156,13 +156,13 @@ protected void onCreate(Bundle savedInstanceState) {
156
156
157
157
}
158
158
mPath = mScript .getParentFile ();
159
-
159
+
160
160
if (FileHelper .getFileContents (mScript .toString ()).contains ("#qpy:fullscreen" )) {
161
161
fullscreen = true ;
162
162
}
163
163
//Log.d(TAG, "mscript:"+mScript+"-mPath"+mPath);
164
164
}
165
-
165
+
166
166
//
167
167
if (fullscreen ) {
168
168
getWindow ().setFlags (WindowManager .LayoutParams .FLAG_FULLSCREEN ,
@@ -178,14 +178,14 @@ protected void onCreate(Bundle savedInstanceState) {
178
178
// pass
179
179
}
180
180
181
-
181
+
182
182
updateNotification (mPath .toString ());
183
183
184
184
//Log.d("PythonActivity", "mPath:"+mPath.toString());
185
185
// go to fullscreen mode
186
186
requestWindowFeature (Window .FEATURE_NO_TITLE );
187
187
String full = getIntent ().getStringExtra (EXTRA_CONTENT_URL3 );
188
-
188
+
189
189
File logFile = new File (mPath , ".run.log" );
190
190
if (logFile .exists ()) {
191
191
logFile .delete ();
@@ -207,7 +207,7 @@ protected void onCreate(Bundle savedInstanceState) {
207
207
}
208
208
}
209
209
}
210
-
210
+
211
211
/*try {
212
212
this.mInfo = this.getPackageManager().getApplicationInfo(
213
213
this.getPackageName(), PackageManager.GET_META_DATA);
@@ -217,42 +217,42 @@ protected void onCreate(Bundle savedInstanceState) {
217
217
WindowManager.LayoutParams.FLAG_FULLSCREEN);
218
218
}
219
219
} catch (PackageManager.NameNotFoundException e) {
220
-
220
+
221
221
}*/
222
222
//
223
-
223
+
224
224
// if (isMain) { //
225
225
// Intent intent = new Intent();
226
226
// intent.setClassName(PythonActivity.this, "com.hipipal.sl4alib.PyScriptService");
227
227
// this.bindService(intent, connection, BIND_AUTO_CREATE);
228
228
// }
229
-
230
-
229
+
230
+
231
231
Log .d (TAG , "[RUN param:" +externalStorage .getAbsolutePath ().toString ()+"-" +mPath .getAbsolutePath ().toString ()+"-" +s +"]" );
232
232
mView = new SDLSurfaceView (
233
233
this ,
234
234
mPath .getAbsolutePath ().toString (),
235
235
s ,
236
236
externalStorage .getAbsolutePath ().toString ()
237
237
);
238
-
238
+
239
239
IntentFilter filter = new IntentFilter (".PythonActivity" );
240
240
registerReceiver (mReceiver , filter );
241
241
242
242
startPyScreen ();
243
243
}
244
-
244
+
245
245
private ServiceConnection connection = new ServiceConnection () {
246
246
@ Override
247
- public void onServiceConnected (ComponentName name , IBinder service ) {
248
- //if (!CONF.DEBUG)
247
+ public void onServiceConnected (ComponentName name , IBinder service ) {
248
+ //if (!CONF.DEBUG)
249
249
Log .d (TAG , "onServiceConnected" );
250
250
//binded = true;
251
251
}
252
252
253
253
@ Override
254
254
public void onServiceDisconnected (ComponentName name ) {
255
- //if (!CONF.DEBUG)
255
+ //if (!CONF.DEBUG)
256
256
Log .d (TAG , "onServiceDisconnected" );
257
257
//binded = false;
258
258
}
@@ -264,15 +264,15 @@ public void startPyScreen() {
264
264
// Start showing an SDLSurfaceView.
265
265
Hardware .view = mView ;
266
266
setContentView (mView );
267
-
267
+
268
268
// Force the background window color if asked
269
269
/*if ( this.mInfo.metaData.containsKey("android.background_color") ) {
270
270
getWindow().getDecorView().setBackgroundColor(
271
271
this.mInfo.metaData.getInt("android.background_color"));
272
272
}*/
273
273
274
274
}
275
-
275
+
276
276
/**
277
277
* Show an error using a toast. (Only makes sense from non-UI
278
278
* threads.)
@@ -310,7 +310,7 @@ public void recursiveDelete(File f) {
310
310
* the .apk is necessary. If it is, the zip file is unpacked.
311
311
*/
312
312
public void unpackDataInPyAct (final String resource , File target ) {
313
-
313
+
314
314
// The version of data in memory and on disk.
315
315
String data_version = resourceManager .getString (resource + "_version" );
316
316
String disk_version = "0" ;
@@ -378,7 +378,7 @@ public void unpackDataInPyAct(final String resource, File target) {
378
378
Log .d (TAG , "NO MEDIA EXTRACTED" );
379
379
}
380
380
}
381
-
381
+
382
382
public static void loadLibrary (File libPath ) {
383
383
System .loadLibrary ("sdl" );
384
384
System .loadLibrary ("sdl_image" );
@@ -410,7 +410,7 @@ public static void loadLibrary(File libPath) {
410
410
} catch (UnsatisfiedLinkError e ) {
411
411
Log .d ("PythonActivity" , "Exception occured when loading python modules:" +e .getLocalizedMessage ());
412
412
}
413
-
413
+
414
414
try {
415
415
System .load (libPath + "/lib/python2.7/lib-dynload/_imaging.so" );
416
416
System .load (libPath + "/lib/python2.7/lib-dynload/_imagingft.so" );
@@ -447,7 +447,7 @@ protected void onPause() {
447
447
mView .onPause ();
448
448
}
449
449
}
450
-
450
+
451
451
@ Override
452
452
protected void onResume () {
453
453
super .onResume ();
@@ -511,7 +511,7 @@ public void onDestroy() {
511
511
mView = null ;
512
512
}
513
513
//Log.i(TAG, "on destroy (exit1)");
514
-
514
+
515
515
//this.finish();
516
516
// 发送通知给对应的activity
517
517
String code ;
@@ -526,23 +526,23 @@ public void onDestroy() {
526
526
if (!noexit .exists () && !code .contains ("#qpy:noend" )) {
527
527
Intent intent1 = new Intent (".MIndexAct" );
528
528
sendBroadcast (intent1 );
529
-
529
+
530
530
Intent intent2 = new Intent (".UProfileAct" );
531
531
sendBroadcast (intent2 );
532
-
532
+
533
533
updateNotification (mPath .toString ());
534
534
535
535
} else {
536
536
updateNotification (mPath .toString ());
537
537
}
538
-
538
+
539
539
try {
540
540
super .onDestroy ();
541
541
} catch (Exception e ) {
542
-
542
+
543
543
}
544
544
}
545
-
545
+
546
546
public static void start_service (String serviceTitle , String serviceDescription ,
547
547
String pythonServiceArgument ) {
548
548
Intent serviceIntent = new Intent (PythonActivity .mActivity , PythonService .class );
@@ -556,7 +556,7 @@ public static void start_service(String serviceTitle, String serviceDescription,
556
556
serviceIntent .putExtra ("serviceDescription" , serviceDescription );
557
557
serviceIntent .putExtra ("pythonServiceArgument" , pythonServiceArgument );
558
558
PythonActivity .mActivity .startService (serviceIntent );
559
- }
559
+ }
560
560
public static void stop_service () {
561
561
Intent serviceIntent = new Intent (PythonActivity .mActivity , PythonService .class );
562
562
PythonActivity .mActivity .stopService (serviceIntent );
@@ -634,16 +634,16 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
634
634
}
635
635
636
636
637
- ////////////////
637
+ ////////////////
638
638
protected final BroadcastReceiver mReceiver = new BroadcastReceiver () {
639
639
@ Override
640
640
public void onReceive (Context context , Intent intent ) {
641
641
Log .d (TAG , "mReceiver" );
642
642
startPyScreen ();
643
643
}
644
644
};
645
-
646
-
645
+
646
+
647
647
protected void updateNotification (String scriptFile ) {
648
648
String script = scriptFile .substring (scriptFile .lastIndexOf ("/" )+1 );
649
649
String logFile = scriptFile +"/.run.log" ;
0 commit comments