Skip to content

Commit 0ae04e2

Browse files
committed
Improve the program icon
1 parent c92657c commit 0ae04e2

File tree

6 files changed

+73
-57
lines changed

6 files changed

+73
-57
lines changed

qpysdk/src/main/java/org/renpy/android/PythonActivity.java

+39-39
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public class PythonActivity extends Activity implements Runnable {
5656
private File mPath = null;
5757
private File mScript;
5858

59-
boolean _isPaused = false;
60-
59+
boolean _isPaused = false;
60+
6161
private static final String DB_INITIALIZED = "db_initialized";
62-
62+
6363
boolean isMain = false;
6464

6565
public final static int PY_NOTI_FLAG = 123400;
@@ -115,19 +115,19 @@ protected void onCreate(Bundle savedInstanceState) {
115115
// Otherwise, we use the public data, if we have it, or the
116116
// private data if we do not.
117117
String act = getIntent().getStringExtra(EXTRA_CONTENT_URL1);
118-
118+
119119
boolean fullscreen = false;
120120
if (act!=null && act.equals("execute")) {
121121
mPath = new File(getIntent().getStringExtra(EXTRA_CONTENT_URL2));
122-
122+
123123
File f = new File(mPath, "main.py");
124124
if (f.exists()) {
125125
if (FileHelper.getFileContents(f.toString()).contains("#qpy:fullscreen")) {
126126
fullscreen = true;
127127
}
128128
}
129-
130-
129+
130+
131131
Project p = Project.scanDirectory(mPath);
132132

133133
if (p != null) {
@@ -136,7 +136,7 @@ protected void onCreate(Bundle savedInstanceState) {
136136
} else {
137137
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
138138
}
139-
139+
140140
if ( p.fullscreen ) {
141141
fullscreen = true;
142142
}
@@ -146,7 +146,7 @@ protected void onCreate(Bundle savedInstanceState) {
146146
String fn = getIntent().getStringExtra(EXTRA_CONTENT_URL2);
147147
if (fn == null) {
148148
isMain = true;
149-
149+
150150
fn = "/sdcard/qpython/launcher.py";
151151
}
152152
mScript = new File(fn);
@@ -156,13 +156,13 @@ protected void onCreate(Bundle savedInstanceState) {
156156

157157
}
158158
mPath = mScript.getParentFile();
159-
159+
160160
if (FileHelper.getFileContents(mScript.toString()).contains("#qpy:fullscreen")) {
161161
fullscreen = true;
162162
}
163163
//Log.d(TAG, "mscript:"+mScript+"-mPath"+mPath);
164164
}
165-
165+
166166
//
167167
if (fullscreen) {
168168
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
@@ -178,14 +178,14 @@ protected void onCreate(Bundle savedInstanceState) {
178178
// pass
179179
}
180180

181-
181+
182182
updateNotification(mPath.toString());
183183

184184
//Log.d("PythonActivity", "mPath:"+mPath.toString());
185185
// go to fullscreen mode
186186
requestWindowFeature(Window.FEATURE_NO_TITLE);
187187
String full = getIntent().getStringExtra(EXTRA_CONTENT_URL3);
188-
188+
189189
File logFile = new File(mPath, ".run.log");
190190
if (logFile.exists()) {
191191
logFile.delete();
@@ -207,7 +207,7 @@ protected void onCreate(Bundle savedInstanceState) {
207207
}
208208
}
209209
}
210-
210+
211211
/*try {
212212
this.mInfo = this.getPackageManager().getApplicationInfo(
213213
this.getPackageName(), PackageManager.GET_META_DATA);
@@ -217,42 +217,42 @@ protected void onCreate(Bundle savedInstanceState) {
217217
WindowManager.LayoutParams.FLAG_FULLSCREEN);
218218
}
219219
} catch (PackageManager.NameNotFoundException e) {
220-
220+
221221
}*/
222222
//
223-
223+
224224
// if (isMain) { //
225225
// Intent intent = new Intent();
226226
// intent.setClassName(PythonActivity.this, "com.hipipal.sl4alib.PyScriptService");
227227
// this.bindService(intent, connection, BIND_AUTO_CREATE);
228228
// }
229-
230-
229+
230+
231231
Log.d(TAG, "[RUN param:"+externalStorage.getAbsolutePath().toString()+"-"+mPath.getAbsolutePath().toString()+"-"+s+"]");
232232
mView = new SDLSurfaceView(
233233
this,
234234
mPath.getAbsolutePath().toString(),
235235
s,
236236
externalStorage.getAbsolutePath().toString()
237237
);
238-
238+
239239
IntentFilter filter = new IntentFilter(".PythonActivity");
240240
registerReceiver(mReceiver, filter);
241241

242242
startPyScreen();
243243
}
244-
244+
245245
private ServiceConnection connection = new ServiceConnection() {
246246
@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)
249249
Log.d(TAG, "onServiceConnected");
250250
//binded = true;
251251
}
252252

253253
@Override
254254
public void onServiceDisconnected(ComponentName name) {
255-
//if (!CONF.DEBUG)
255+
//if (!CONF.DEBUG)
256256
Log.d(TAG, "onServiceDisconnected");
257257
//binded = false;
258258
}
@@ -264,15 +264,15 @@ public void startPyScreen() {
264264
// Start showing an SDLSurfaceView.
265265
Hardware.view = mView;
266266
setContentView(mView);
267-
267+
268268
// Force the background window color if asked
269269
/*if ( this.mInfo.metaData.containsKey("android.background_color") ) {
270270
getWindow().getDecorView().setBackgroundColor(
271271
this.mInfo.metaData.getInt("android.background_color"));
272272
}*/
273273

274274
}
275-
275+
276276
/**
277277
* Show an error using a toast. (Only makes sense from non-UI
278278
* threads.)
@@ -310,7 +310,7 @@ public void recursiveDelete(File f) {
310310
* the .apk is necessary. If it is, the zip file is unpacked.
311311
*/
312312
public void unpackDataInPyAct(final String resource, File target) {
313-
313+
314314
// The version of data in memory and on disk.
315315
String data_version = resourceManager.getString(resource + "_version");
316316
String disk_version = "0";
@@ -378,7 +378,7 @@ public void unpackDataInPyAct(final String resource, File target) {
378378
Log.d(TAG, "NO MEDIA EXTRACTED");
379379
}
380380
}
381-
381+
382382
public static void loadLibrary(File libPath) {
383383
System.loadLibrary("sdl");
384384
System.loadLibrary("sdl_image");
@@ -410,7 +410,7 @@ public static void loadLibrary(File libPath) {
410410
} catch(UnsatisfiedLinkError e) {
411411
Log.d("PythonActivity", "Exception occured when loading python modules:"+e.getLocalizedMessage());
412412
}
413-
413+
414414
try {
415415
System.load(libPath + "/lib/python2.7/lib-dynload/_imaging.so");
416416
System.load(libPath + "/lib/python2.7/lib-dynload/_imagingft.so");
@@ -447,7 +447,7 @@ protected void onPause() {
447447
mView.onPause();
448448
}
449449
}
450-
450+
451451
@Override
452452
protected void onResume() {
453453
super.onResume();
@@ -511,7 +511,7 @@ public void onDestroy() {
511511
mView = null;
512512
}
513513
//Log.i(TAG, "on destroy (exit1)");
514-
514+
515515
//this.finish();
516516
// 发送通知给对应的activity
517517
String code;
@@ -526,23 +526,23 @@ public void onDestroy() {
526526
if (!noexit.exists() && !code.contains("#qpy:noend")) {
527527
Intent intent1 = new Intent(".MIndexAct");
528528
sendBroadcast(intent1);
529-
529+
530530
Intent intent2 = new Intent(".UProfileAct");
531531
sendBroadcast(intent2);
532-
532+
533533
updateNotification(mPath.toString());
534534

535535
} else {
536536
updateNotification(mPath.toString());
537537
}
538-
538+
539539
try{
540540
super.onDestroy();
541541
} catch (Exception e) {
542-
542+
543543
}
544544
}
545-
545+
546546
public static void start_service(String serviceTitle, String serviceDescription,
547547
String pythonServiceArgument) {
548548
Intent serviceIntent = new Intent(PythonActivity.mActivity, PythonService.class);
@@ -556,7 +556,7 @@ public static void start_service(String serviceTitle, String serviceDescription,
556556
serviceIntent.putExtra("serviceDescription", serviceDescription);
557557
serviceIntent.putExtra("pythonServiceArgument", pythonServiceArgument);
558558
PythonActivity.mActivity.startService(serviceIntent);
559-
}
559+
}
560560
public static void stop_service() {
561561
Intent serviceIntent = new Intent(PythonActivity.mActivity, PythonService.class);
562562
PythonActivity.mActivity.stopService(serviceIntent);
@@ -634,16 +634,16 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
634634
}
635635

636636

637-
////////////////
637+
////////////////
638638
protected final BroadcastReceiver mReceiver = new BroadcastReceiver() {
639639
@Override
640640
public void onReceive(Context context, Intent intent) {
641641
Log.d(TAG, "mReceiver");
642642
startPyScreen();
643643
}
644644
};
645-
646-
645+
646+
647647
protected void updateNotification(String scriptFile) {
648648
String script = scriptFile.substring(scriptFile.lastIndexOf("/")+1);
649649
String logFile = scriptFile+"/.run.log";

qpysdk/src/main/java/org/renpy/android/SDLSurfaceView.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public interface OnInterceptTouchListener {
357357
String mArgument = null;
358358
String mScript = null;
359359
String mDirectory = null;
360-
360+
361361

362362
// The resource manager we use.
363363
ResourceManager mResourceManager;
@@ -380,9 +380,9 @@ public static void updateTextFromCursor(String bef, String aft){
380380

381381
public SDLSurfaceView(PythonActivity act, String argument, String script, String directory) {
382382
super(act);
383-
383+
384384
mScript = script;
385-
385+
386386
SDLSurfaceView.instance = this;
387387

388388
mActivity = act;
@@ -394,7 +394,7 @@ public SDLSurfaceView(PythonActivity act, String argument, String script, String
394394

395395
mFilesDirectory = mActivity.getFilesDir().getAbsolutePath();
396396
mDirectory = directory;
397-
397+
398398
mArgument = argument;
399399

400400
PowerManager pm = (PowerManager) act.getSystemService(Context.POWER_SERVICE);
@@ -768,7 +768,7 @@ public void run() {
768768

769769
//Log.i(TAG, "End of native init, stop everything (exit0)");
770770
mActivity.finish();
771-
771+
772772
//System.exit(0);
773773
}
774774

@@ -1228,10 +1228,10 @@ public void onGlobalLayout() {
12281228
//send control sequence start /x04 == kayboard layout changed
12291229
nativeKey(45, 1, 4);
12301230
nativeKey(45, 0, 4);
1231-
}
1231+
}
12321232
kHeight = heightDiff;
1233-
}
1234-
});
1233+
}
1234+
});
12351235
return new BaseInputConnection(this, false){
12361236

12371237
private void deleteLastText(){

qpython/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
android:name="org.qpython.qpy.main.app.App"
3535
android:allowBackup="true"
3636
android:hardwareAccelerated="true"
37-
android:icon="@mipmap/ic_launcher"
37+
android:icon="@drawable/micon"
3838
android:label="@string/app_name"
3939
android:largeHeap="true"
4040
android:supportsRtl="true"

qpython/src/main/java/org/qpython/qpy/main/dialog/RunProgramDialog.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.qpython.qpy.plugin.SpaceItemDecoration;
2020

2121
import java.io.File;
22+
import java.lang.reflect.Array;
2223
import java.util.ArrayList;
2324
import java.util.Arrays;
2425
import java.util.List;
@@ -59,18 +60,32 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
5960
super.onViewCreated(view, savedInstanceState);
6061
type = getArguments().getInt(PROGRAM_TYPE);
6162
File dir = null;
63+
ArrayList<File> v = new ArrayList();
64+
6265
if (type == TYPE_SCRIPT) {
6366
mBinding.tvTitle.setText(R.string.dialog_title_script);
6467
dir = new File(App.getScriptPath());
68+
File[] xx = dir.listFiles();
69+
for (int i=0;i<xx.length;i++) {
70+
if (xx[i].getAbsolutePath().endsWith(".py")) {
71+
v.add(xx[i]);
72+
}
73+
}
6574
}
6675
if (type == TYPE_PROJECT) {
6776
mBinding.tvTitle.setText(R.string.dialog_title_project);
6877
dir = new File(App.getProjectPath());
78+
File[] xx = dir.listFiles();
79+
for (int i=0;i<xx.length;i++) {
80+
if (xx[i].isDirectory()) {
81+
v.add(xx[i]);
82+
}
83+
}
6984
}
7085
if (!dir.exists()) {
7186
dir.mkdirs();
7287
}
73-
mAdapter.setData(Arrays.asList(dir.listFiles()));
88+
mAdapter.setData(v);
7489
}
7590

7691
public class Adapter extends RecyclerView.Adapter<Holder> {

0 commit comments

Comments
 (0)