Skip to content

Commit

Permalink
indent and normalize all java files
Browse files Browse the repository at this point in the history
  • Loading branch information
tito committed Apr 29, 2013
1 parent c7614a7 commit c1038d1
Show file tree
Hide file tree
Showing 13 changed files with 840 additions and 851 deletions.
40 changes: 20 additions & 20 deletions src/src/org/renpy/android/Action.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

public class Action {

static Context context;
static Context context;

/* Deliver some data to someone else
*/
static void send(String mimeType, String filename, String subject, String text, String chooser_title) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType(mimeType);
/** tryied with String [] emails, but hard to code the whole C/Cython part.
if (emails != null)
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emails);
**/
if (subject != null)
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
if (text != null)
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
if (filename != null)
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ filename));
if (chooser_title == null)
chooser_title = "Send mail";
context.startActivity(Intent.createChooser(emailIntent, chooser_title));
}
/* Deliver some data to someone else
*/
static void send(String mimeType, String filename, String subject, String text, String chooser_title) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType(mimeType);
/** tryied with String [] emails, but hard to code the whole C/Cython part.
if (emails != null)
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emails);
**/
if (subject != null)
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
if (text != null)
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
if (filename != null)
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+ filename));
if (chooser_title == null)
chooser_title = "Send mail";
context.startActivity(Intent.createChooser(emailIntent, chooser_title));
}
}
20 changes: 10 additions & 10 deletions src/src/org/renpy/android/AssetExtract.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ class AssetExtract {

private AssetManager mAssetManager = null;
private Activity mActivity = null;

AssetExtract(Activity act) {
mActivity = act;
mAssetManager = act.getAssets();
}

public boolean extractTar(String asset, String target) {

byte buf[] = new byte[1024 * 1024];

InputStream assetStream = null;
TarInputStream tis = null;

try {
assetStream = mAssetManager.open(asset, AssetManager.ACCESS_STREAMING);
tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new BufferedInputStream(assetStream, 8192)), 8192));
} catch (IOException e) {
Log.e("python", "opening up extract tar", e);
return false;
}

while (true) {
TarEntry entry = null;

Expand All @@ -61,7 +61,7 @@ public boolean extractTar(String asset, String target) {
}

Log.i("python", "extracting " + entry.getName());

if (entry.isDirectory()) {

try {
Expand All @@ -87,14 +87,14 @@ public boolean extractTar(String asset, String target) {
try {
while (true) {
int len = tis.read(buf);

if (len == -1) {
break;
}

out.write(buf, 0, len);
}

out.flush();
out.close();
} catch ( java.io.IOException e ) {
Expand All @@ -109,7 +109,7 @@ public boolean extractTar(String asset, String target) {
} catch (IOException e) {
// pass
}

return true;
}
}
250 changes: 125 additions & 125 deletions src/src/org/renpy/android/Audio.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/*
Simple DirectMedia Layer
Java source code (C) 2009-2011 Sergii Pylypenko
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
Simple DirectMedia Layer
Java source code (C) 2009-2011 Sergii Pylypenko
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
3. This notice may not be removed or altered from any source distribution.
*/

package org.renpy.android;

Expand All @@ -40,115 +40,115 @@ Java source code (C) 2009-2011 Sergii Pylypenko

class AudioThread {

private PythonActivity mParent;
private AudioTrack mAudio;
private byte[] mAudioBuffer;
private int mVirtualBufSize;

public AudioThread(PythonActivity parent)
{
mParent = parent;
mAudio = null;
mAudioBuffer = null;
nativeAudioInitJavaCallbacks();
}
public int fillBuffer()
{
if( mParent.isPaused() )
{
try{
Thread.sleep(200);
} catch (InterruptedException e) {}
}
else
{
//if( Globals.AudioBufferConfig == 0 ) // Gives too much spam to logcat, makes things worse
// mAudio.flush();

mAudio.write( mAudioBuffer, 0, mVirtualBufSize );
}
return 1;
}
public int initAudio(int rate, int channels, int encoding, int bufSize)
{
if( mAudio == null )
{
channels = ( channels == 1 ) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
AudioFormat.CHANNEL_CONFIGURATION_STEREO;
encoding = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
AudioFormat.ENCODING_PCM_8BIT;

mVirtualBufSize = bufSize;

if( AudioTrack.getMinBufferSize( rate, channels, encoding ) > bufSize )
bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding );

/**
if(Globals.AudioBufferConfig != 0) { // application's choice - use minimal buffer
bufSize = (int)((float)bufSize * (((float)(Globals.AudioBufferConfig - 1) * 2.5f) + 1.0f));
mVirtualBufSize = bufSize;
}
**/
mAudioBuffer = new byte[bufSize];

mAudio = new AudioTrack(AudioManager.STREAM_MUSIC,
rate,
channels,
encoding,
bufSize,
AudioTrack.MODE_STREAM );
mAudio.play();
}
return mVirtualBufSize;
}
public byte[] getBuffer()
{
return mAudioBuffer;
}
public int deinitAudio()
{
if( mAudio != null )
{
mAudio.stop();
mAudio.release();
mAudio = null;
}
mAudioBuffer = null;
return 1;
}
public int initAudioThread()
{
// Make audio thread priority higher so audio thread won't get underrun
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
return 1;
}
public int pauseAudioPlayback()
{
if( mAudio != null )
{
mAudio.pause();
return 1;
}
return 0;
}

public int resumeAudioPlayback()
{
if( mAudio != null )
{
mAudio.play();
return 1;
}
return 0;
}
private native int nativeAudioInitJavaCallbacks();
private PythonActivity mParent;
private AudioTrack mAudio;
private byte[] mAudioBuffer;
private int mVirtualBufSize;

public AudioThread(PythonActivity parent)
{
mParent = parent;
mAudio = null;
mAudioBuffer = null;
nativeAudioInitJavaCallbacks();
}

public int fillBuffer()
{
if( mParent.isPaused() )
{
try{
Thread.sleep(200);
} catch (InterruptedException e) {}
}
else
{
//if( Globals.AudioBufferConfig == 0 ) // Gives too much spam to logcat, makes things worse
// mAudio.flush();

mAudio.write( mAudioBuffer, 0, mVirtualBufSize );
}

return 1;
}

public int initAudio(int rate, int channels, int encoding, int bufSize)
{
if( mAudio == null )
{
channels = ( channels == 1 ) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
AudioFormat.CHANNEL_CONFIGURATION_STEREO;
encoding = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
AudioFormat.ENCODING_PCM_8BIT;

mVirtualBufSize = bufSize;

if( AudioTrack.getMinBufferSize( rate, channels, encoding ) > bufSize )
bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding );

/**
if(Globals.AudioBufferConfig != 0) { // application's choice - use minimal buffer
bufSize = (int)((float)bufSize * (((float)(Globals.AudioBufferConfig - 1) * 2.5f) + 1.0f));
mVirtualBufSize = bufSize;
}
**/
mAudioBuffer = new byte[bufSize];

mAudio = new AudioTrack(AudioManager.STREAM_MUSIC,
rate,
channels,
encoding,
bufSize,
AudioTrack.MODE_STREAM );
mAudio.play();
}
return mVirtualBufSize;
}

public byte[] getBuffer()
{
return mAudioBuffer;
}

public int deinitAudio()
{
if( mAudio != null )
{
mAudio.stop();
mAudio.release();
mAudio = null;
}
mAudioBuffer = null;
return 1;
}

public int initAudioThread()
{
// Make audio thread priority higher so audio thread won't get underrun
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
return 1;
}

public int pauseAudioPlayback()
{
if( mAudio != null )
{
mAudio.pause();
return 1;
}
return 0;
}

public int resumeAudioPlayback()
{
if( mAudio != null )
{
mAudio.play();
return 1;
}
return 0;
}

private native int nativeAudioInitJavaCallbacks();
}

Loading

0 comments on commit c1038d1

Please sign in to comment.