Skip to content

Commit d412cdd

Browse files
committed
add java bootstrap, template.
1 parent 4442705 commit d412cdd

30 files changed

+3506
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ src/obj
66
src/local.properties
77
src/default.properties
88
dist
9+
*.pyc
10+
testsuite

src/res/drawable/icon.png

16.1 KB
Loading

src/res/drawable/presplash.jpg

12.4 KB
Loading

src/res/layout/chooser_item.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:orientation="horizontal"
5+
android:gravity="center"
6+
>
7+
8+
<ImageView
9+
android:id="@+id/icon"
10+
android:layout_width="64sp"
11+
android:layout_height="64sp"
12+
android:scaleType="fitCenter"
13+
android:padding="2sp"
14+
/>
15+
16+
<LinearLayout
17+
android:orientation="vertical"
18+
android:layout_width="fill_parent"
19+
android:layout_height="wrap_content"
20+
>
21+
22+
<TextView
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
25+
android:id="@+id/title"
26+
android:textSize="18sp"
27+
android:textColor="#fff"
28+
android:singleLine="true"
29+
/>
30+
31+
<TextView
32+
android:layout_width="wrap_content"
33+
android:layout_height="wrap_content"
34+
android:singleLine="true"
35+
android:id="@+id/author"
36+
/>
37+
38+
</LinearLayout>
39+
</LinearLayout>

src/res/layout/main.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical"
4+
android:layout_width="fill_parent"
5+
android:layout_height="fill_parent"
6+
>
7+
</LinearLayout>
8+

src/res/layout/project_chooser.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<LinearLayout
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
android:orientation="vertical"
6+
>
7+
8+
<TextView
9+
android:text="Please choose a project:"
10+
android:layout_width="fill_parent"
11+
android:layout_height="wrap_content"
12+
android:padding="4sp"
13+
/>
14+
15+
<ListView
16+
android:id="@+id/projectList"
17+
android:layout_width="fill_parent"
18+
android:layout_height="fill_parent"
19+
/>
20+
21+
22+
</LinearLayout>

src/res/layout/project_empty.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<LinearLayout
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
android:orientation="vertical"
6+
>
7+
8+
<TextView
9+
android:id="@+id/emptyText"
10+
android:layout_width="fill_parent"
11+
android:layout_height="wrap_content"
12+
android:padding="4sp"
13+
/>
14+
15+
</LinearLayout>

src/res/values/strings.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="appName">Kivy Launcher</string>
4+
<string name="iconName">Kivy Launcher</string>
5+
6+
<string name="private_version">1323531558.3</string>
7+
8+
9+
<string name="urlScheme">kivy</string>
10+
</resources>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// This string is autogenerated by ChangeAppSettings.sh, do not change
2+
// spaces amount
3+
package org.renpy.android;
4+
5+
import java.io.*;
6+
7+
import android.app.Activity;
8+
import android.util.Log;
9+
10+
import java.io.BufferedInputStream;
11+
import java.io.BufferedOutputStream;
12+
import java.io.IOException;
13+
import java.io.InputStream;
14+
import java.io.FileInputStream;
15+
import java.io.FileOutputStream;
16+
import java.io.File;
17+
18+
import java.util.zip.GZIPInputStream;
19+
20+
import android.content.res.AssetManager;
21+
22+
import org.xeustechnologies.jtar.*;
23+
24+
class AssetExtract {
25+
26+
private AssetManager mAssetManager = null;
27+
private Activity mActivity = null;
28+
29+
AssetExtract(Activity act) {
30+
mActivity = act;
31+
mAssetManager = act.getAssets();
32+
}
33+
34+
public boolean extractTar(String asset, String target) {
35+
36+
byte buf[] = new byte[1024 * 1024];
37+
38+
InputStream assetStream = null;
39+
TarInputStream tis = null;
40+
41+
try {
42+
assetStream = mAssetManager.open(asset, AssetManager.ACCESS_STREAMING);
43+
tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new BufferedInputStream(assetStream, 8192)), 8192));
44+
} catch (IOException e) {
45+
Log.e("python", "opening up extract tar", e);
46+
return false;
47+
}
48+
49+
while (true) {
50+
TarEntry entry = null;
51+
52+
try {
53+
entry = tis.getNextEntry();
54+
} catch ( java.io.IOException e ) {
55+
Log.e("python", "extracting tar", e);
56+
return false;
57+
}
58+
59+
if ( entry == null ) {
60+
break;
61+
}
62+
63+
Log.i("python", "extracting " + entry.getName());
64+
65+
if (entry.isDirectory()) {
66+
67+
try {
68+
new File(target +"/" + entry.getName()).mkdirs();
69+
} catch ( SecurityException e ) { };
70+
71+
continue;
72+
}
73+
74+
OutputStream out = null;
75+
String path = target + "/" + entry.getName();
76+
77+
try {
78+
out = new BufferedOutputStream(new FileOutputStream(path), 8192);
79+
} catch ( FileNotFoundException e ) {
80+
} catch ( SecurityException e ) { };
81+
82+
if ( out == null ) {
83+
Log.e("python", "could not open " + path);
84+
return false;
85+
}
86+
87+
try {
88+
while (true) {
89+
int len = tis.read(buf);
90+
91+
if (len == -1) {
92+
break;
93+
}
94+
95+
out.write(buf, 0, len);
96+
}
97+
98+
out.flush();
99+
out.close();
100+
} catch ( java.io.IOException e ) {
101+
Log.e("python", "extracting zip", e);
102+
return false;
103+
}
104+
}
105+
106+
try {
107+
tis.close();
108+
assetStream.close();
109+
} catch (IOException e) {
110+
// pass
111+
}
112+
113+
return true;
114+
}
115+
}

src/src/org/renpy/android/Audio.java

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/*
2+
Simple DirectMedia Layer
3+
Java source code (C) 2009-2011 Sergii Pylypenko
4+
5+
This software is provided 'as-is', without any express or implied
6+
warranty. In no event will the authors be held liable for any damages
7+
arising from the use of this software.
8+
9+
Permission is granted to anyone to use this software for any purpose,
10+
including commercial applications, and to alter it and redistribute it
11+
freely, subject to the following restrictions:
12+
13+
1. The origin of this software must not be misrepresented; you must not
14+
claim that you wrote the original software. If you use this software
15+
in a product, an acknowledgment in the product documentation would be
16+
appreciated but is not required.
17+
2. Altered source versions must be plainly marked as such, and must not be
18+
misrepresented as being the original software.
19+
3. This notice may not be removed or altered from any source distribution.
20+
*/
21+
22+
package org.renpy.android;
23+
24+
25+
import android.app.Activity;
26+
import android.content.Context;
27+
import android.os.Bundle;
28+
import android.view.MotionEvent;
29+
import android.view.KeyEvent;
30+
import android.view.Window;
31+
import android.view.WindowManager;
32+
import android.media.AudioTrack;
33+
import android.media.AudioManager;
34+
import android.media.AudioFormat;
35+
import java.io.*;
36+
import java.nio.ByteBuffer;
37+
import android.util.Log;
38+
import java.lang.Thread;
39+
40+
41+
class AudioThread {
42+
43+
private PythonActivity mParent;
44+
private AudioTrack mAudio;
45+
private byte[] mAudioBuffer;
46+
private int mVirtualBufSize;
47+
48+
public AudioThread(PythonActivity parent)
49+
{
50+
mParent = parent;
51+
mAudio = null;
52+
mAudioBuffer = null;
53+
nativeAudioInitJavaCallbacks();
54+
}
55+
56+
public int fillBuffer()
57+
{
58+
if( mParent.isPaused() )
59+
{
60+
try{
61+
Thread.sleep(200);
62+
} catch (InterruptedException e) {}
63+
}
64+
else
65+
{
66+
//if( Globals.AudioBufferConfig == 0 ) // Gives too much spam to logcat, makes things worse
67+
// mAudio.flush();
68+
69+
mAudio.write( mAudioBuffer, 0, mVirtualBufSize );
70+
}
71+
72+
return 1;
73+
}
74+
75+
public int initAudio(int rate, int channels, int encoding, int bufSize)
76+
{
77+
if( mAudio == null )
78+
{
79+
channels = ( channels == 1 ) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
80+
AudioFormat.CHANNEL_CONFIGURATION_STEREO;
81+
encoding = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
82+
AudioFormat.ENCODING_PCM_8BIT;
83+
84+
mVirtualBufSize = bufSize;
85+
86+
if( AudioTrack.getMinBufferSize( rate, channels, encoding ) > bufSize )
87+
bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding );
88+
89+
/**
90+
if(Globals.AudioBufferConfig != 0) { // application's choice - use minimal buffer
91+
bufSize = (int)((float)bufSize * (((float)(Globals.AudioBufferConfig - 1) * 2.5f) + 1.0f));
92+
mVirtualBufSize = bufSize;
93+
}
94+
**/
95+
mAudioBuffer = new byte[bufSize];
96+
97+
mAudio = new AudioTrack(AudioManager.STREAM_MUSIC,
98+
rate,
99+
channels,
100+
encoding,
101+
bufSize,
102+
AudioTrack.MODE_STREAM );
103+
mAudio.play();
104+
}
105+
return mVirtualBufSize;
106+
}
107+
108+
public byte[] getBuffer()
109+
{
110+
return mAudioBuffer;
111+
}
112+
113+
public int deinitAudio()
114+
{
115+
if( mAudio != null )
116+
{
117+
mAudio.stop();
118+
mAudio.release();
119+
mAudio = null;
120+
}
121+
mAudioBuffer = null;
122+
return 1;
123+
}
124+
125+
public int initAudioThread()
126+
{
127+
// Make audio thread priority higher so audio thread won't get underrun
128+
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
129+
return 1;
130+
}
131+
132+
public int pauseAudioPlayback()
133+
{
134+
if( mAudio != null )
135+
{
136+
mAudio.pause();
137+
return 1;
138+
}
139+
return 0;
140+
}
141+
142+
public int resumeAudioPlayback()
143+
{
144+
if( mAudio != null )
145+
{
146+
mAudio.play();
147+
return 1;
148+
}
149+
return 0;
150+
}
151+
152+
private native int nativeAudioInitJavaCallbacks();
153+
}
154+

0 commit comments

Comments
 (0)