Skip to content

Commit 9ce733f

Browse files
committed
Build sdlplugin
1 parent 5f9ba7b commit 9ce733f

File tree

4,744 files changed

+203
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,744 files changed

+203
-228
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/pdaxrom/editor/CodeEditorInterface.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

sdlplugin/AndroidManifest.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.duy.c.cpp.compiler.sdlplugin"
5+
android:installLocation="auto">
6+
7+
<uses-permission android:name="android.permission.INTERNET" />
8+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10+
11+
<application
12+
android:allowBackup="false"
13+
android:fullBackupContent="false"
14+
android:icon="@drawable/ic_launcher"
15+
android:label="@string/app_name"
16+
android:theme="@style/Theme.AppCompat.Light"
17+
tools:ignore="GoogleAppIndexingWarning">
18+
19+
<activity
20+
android:name="com.duy.c.cpp.compiler.sdlplugin.sdlpluginActivity"
21+
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
22+
android:label="@string/app_name">
23+
24+
<intent-filter>
25+
<action android:name="android.intent.action.MAIN" />
26+
<category android:name="android.intent.category.LAUNCHER" />
27+
</intent-filter>
28+
</activity>
29+
</application>
30+
</manifest>

sdlplugin/README.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

sdlplugin/assets/examples.zip

434 KB
Binary file not shown.

sdlplugin/assets/headers.zip

261 KB
Binary file not shown.

sdlplugin/build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ android {
3333
}
3434
}
3535

36+
sourceSets {
37+
main {
38+
manifest.srcFile 'AndroidManifest.xml'
39+
res.srcDir 'res'
40+
assets.srcDir 'assets'
41+
jni.srcDir 'jni'
42+
java.srcDir 'java'
43+
}
44+
}
3645
buildTypes {
3746
release {
3847
minifyEnabled true
@@ -48,7 +57,7 @@ android {
4857

4958
externalNativeBuild {
5059
ndkBuild {
51-
path 'src/main/jni/Android.mk'
60+
path 'jni/Android.mk'
5261
}
5362
}
5463
}
File renamed without changes.
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
package com.duy.c.cpp.compiler.sdlplugin;
2+
3+
import android.annotation.SuppressLint;
4+
import android.app.AlertDialog;
5+
import android.app.ProgressDialog;
6+
import android.content.DialogInterface;
7+
import android.content.DialogInterface.OnCancelListener;
8+
import android.content.pm.PackageManager.NameNotFoundException;
9+
import android.os.AsyncTask;
10+
import android.os.Build;
11+
import android.os.Bundle;
12+
import android.os.Environment;
13+
import android.text.method.LinkMovementMethod;
14+
import android.text.util.Linkify;
15+
import android.util.Log;
16+
import android.widget.TextView;
17+
18+
import org.libsdl.app.SDLActivity;
19+
20+
import java.io.File;
21+
import java.io.IOException;
22+
import java.io.InputStream;
23+
24+
public class sdlpluginActivity extends SDLActivity {
25+
private static final String TAG = "sdlpluginActivity";
26+
27+
private static final String CCTOOLS_GOOGLE_URL = "https://play.google.com/store/apps/details?id=com.pdaxrom.cctools";
28+
29+
private static final String CCTOOLS_URL = "http://cctools.info";
30+
31+
private static String sdCardDir;
32+
33+
private ProgressDialog pd;
34+
35+
@Override
36+
protected void onCreate(Bundle savedInstanceState) {
37+
Log.v(TAG, "onCreate()");
38+
super.onCreate(savedInstanceState);
39+
40+
sdCardDir = Environment.getExternalStorageDirectory().getPath() + "/CCTools";
41+
42+
if (!super.mIsPaused && getIntent().getExtras() == null) {
43+
if (new File(sdCardDir).exists() && new File(sdCardDir).isDirectory()) {
44+
if (!new File(sdCardDir + "/SDL/include").exists() ||
45+
!new File(sdCardDir + "/SDL/lib").exists()) {
46+
Log.i(TAG, "Install dev files");
47+
new InstallDevFiles().execute();
48+
} else {
49+
aboutDialog(1);
50+
}
51+
} else {
52+
aboutDialog(0);
53+
}
54+
}
55+
}
56+
57+
private void aboutDialog(int type) {
58+
String versionName;
59+
try {
60+
versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
61+
} catch (NameNotFoundException e) {
62+
versionName = "1.0";
63+
}
64+
final TextView textView = new TextView(this);
65+
textView.setAutoLinkMask(Linkify.WEB_URLS);
66+
textView.setLinksClickable(true);
67+
if (type == 0) {
68+
textView.setText(getString(R.string.about_dialog_text) +
69+
" " +
70+
versionName +
71+
"\n" +
72+
getString(R.string.about_dialog_text1) +
73+
"\n" + CCTOOLS_GOOGLE_URL + "\n" +
74+
getString(R.string.about_dialog_text2));
75+
} else {
76+
textView.setText(getString(R.string.about_dialog_text) +
77+
" " + versionName + "\n" +
78+
getString(R.string.sdl_version) + " " + Utils.getSDLVersion(Utils.Lib_SDL) + "\n" +
79+
getString(R.string.sdl_image_version) + " " + Utils.getSDLVersion(Utils.Lib_SDL_image) + "\n" +
80+
getString(R.string.sdl_mixer_version) + " " + Utils.getSDLVersion(Utils.Lib_SDL_mixer) + "\n" +
81+
getString(R.string.sdl_net_version) + " " + Utils.getSDLVersion(Utils.Lib_SDL_net) + "\n" +
82+
getString(R.string.sdl_ttf_version) + " " + Utils.getSDLVersion(Utils.Lib_SDL_ttf) + "\n\n" +
83+
getString(R.string.about_dialog_text3) + "\n" +
84+
CCTOOLS_URL + "\n"
85+
);
86+
}
87+
textView.setMovementMethod(LinkMovementMethod.getInstance());
88+
new AlertDialog.Builder(this)
89+
.setTitle(getString(R.string.about_dialog))
90+
.setView(textView)
91+
.setOnCancelListener(new OnCancelListener() {
92+
@Override
93+
public void onCancel(DialogInterface dialog) {
94+
System.exit(RESULT_OK);
95+
}
96+
})
97+
.show();
98+
}
99+
100+
@SuppressLint("StaticFieldLeak")
101+
private class InstallDevFiles extends AsyncTask<Void, String, Void> {
102+
@Override
103+
protected void onPreExecute() {
104+
super.onPreExecute();
105+
pd = ProgressDialog.show(getContext(), getString(R.string.app_name),
106+
getString(R.string.update_checking), true);
107+
}
108+
109+
@Override
110+
protected void onProgressUpdate(String... values) {
111+
super.onProgressUpdate(values);
112+
pd.setMessage(values[0]);
113+
}
114+
115+
@Override
116+
protected Void doInBackground(Void... params) {
117+
try {
118+
if (!(new File(sdCardDir + "/SDL/lib").exists())) {
119+
new File(sdCardDir + "/SDL/lib").mkdirs();
120+
Utils.copyDirectory(new File(getCacheDir().getParentFile().getAbsolutePath() + "/lib"),
121+
new File(sdCardDir + "/SDL/lib"));
122+
new File(sdCardDir + "/SDL/lib/libmain.so").delete();
123+
new File(sdCardDir + "/SDL/lib/libccsdlplugin.so").delete();
124+
String arch = Build.CPU_ABI;
125+
if (arch.startsWith("mips")) {
126+
arch = "mips";
127+
}
128+
publishProgress(getString(R.string.update_install_libs));
129+
InputStream is = getAssets().open("sdlmain-" + arch + ".zip");
130+
Utils.unpackZip(is, sdCardDir + "/SDL/lib");
131+
is.close();
132+
}
133+
if (!(new File(sdCardDir + "/SDL/include").exists())) {
134+
publishProgress(getString(R.string.update_install_headers));
135+
InputStream is = getAssets().open("headers.zip");
136+
Utils.unpackZip(is, sdCardDir + "/SDL");
137+
is.close();
138+
}
139+
if (!(new File(sdCardDir + "/Examples/SDL").exists())) {
140+
publishProgress(getString(R.string.update_install_examples));
141+
InputStream is = getAssets().open("examples.zip");
142+
Utils.unpackZip(is, sdCardDir);
143+
is.close();
144+
}
145+
} catch (IOException e) {
146+
Log.e(TAG, "Error installing dev files " + e);
147+
}
148+
return null;
149+
}
150+
151+
@Override
152+
protected void onPostExecute(Void result) {
153+
super.onPostExecute(result);
154+
pd.dismiss();
155+
aboutDialog(1);
156+
}
157+
}
158+
159+
}

0 commit comments

Comments
 (0)