diff --git a/project/java/Accelerometer.java b/project/java/Accelerometer.java index 0e054aecf..978020850 100644 --- a/project/java/Accelerometer.java +++ b/project/java/Accelerometer.java @@ -33,7 +33,7 @@ import android.hardware.SensorManager; import android.hardware.SensorEventListener; import android.hardware.Sensor; import android.hardware.SensorEvent; - +import android.util.Log; import android.widget.TextView; @@ -53,7 +53,7 @@ class AccelerometerReader implements SensorEventListener { if( _manager != null ) { - System.out.println("libSDL: stopping accelerometer/gyroscope"); + Log.i("SDL", "libSDL: stopping accelerometer/gyroscope"); _manager.unregisterListener(this); _manager.unregisterListener(gyro); } @@ -64,12 +64,12 @@ class AccelerometerReader implements SensorEventListener if( (Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) && _manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null ) { - System.out.println("libSDL: starting accelerometer"); + Log.i("SDL", "libSDL: starting accelerometer"); _manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME); } if( Globals.AppUsesGyroscope && _manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null ) { - System.out.println("libSDL: starting gyroscope"); + Log.i("SDL", "libSDL: starting gyroscope"); _manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME); } } diff --git a/project/java/Audio.java b/project/java/Audio.java index e14b215b8..94ae6f427 100644 --- a/project/java/Audio.java +++ b/project/java/Audio.java @@ -173,7 +173,7 @@ class AudioThread } if( !mRecordThread.isStopped() ) { - System.out.println("SDL: error: application already opened audio recording device"); + Log.i("SDL", "SDL: error: application already opened audio recording device"); return null; } @@ -186,7 +186,7 @@ class AudioThread int minBufDevice = AudioRecord.getMinBufferSize(rate, channelConfig, encodingConfig); int minBufferSize = Math.max(bufsize * 8, minBufDevice + (bufsize - (minBufDevice % bufsize))); - System.out.println("SDL: app opened recording device, rate " + rate + " channels " + channels + " sample size " + (encoding+1) + " bufsize " + bufsize + " internal bufsize " + minBufferSize); + Log.i("SDL", "SDL: app opened recording device, rate " + rate + " channels " + channels + " sample size " + (encoding+1) + " bufsize " + bufsize + " internal bufsize " + minBufferSize); if( mRecorder == null || mRecorder.getSampleRate() != rate || mRecorder.getChannelCount() != channels || mRecorder.getAudioFormat() != encodingConfig || @@ -199,13 +199,13 @@ class AudioThread mRecorder = new AudioRecord(AudioSource.DEFAULT, rate, channelConfig, encodingConfig, minBufferSize); mRecorderBufferSize = minBufferSize; } catch (IllegalArgumentException e) { - System.out.println("SDL: error: failed to open recording device!"); + Log.i("SDL", "SDL: error: failed to open recording device!"); return null; } } else { - System.out.println("SDL: reusing old recording device"); + Log.i("SDL", "SDL: reusing old recording device"); } mRecordThread.startRecording(); return mRecordThread.mRecordBuffer; @@ -215,11 +215,11 @@ class AudioThread { if( mRecordThread == null || mRecordThread.isStopped() ) { - System.out.println("SDL: error: application already closed audio recording device"); + Log.i("SDL", "SDL: error: application already closed audio recording device"); return; } mRecordThread.stopRecording(); - System.out.println("SDL: app closed recording device"); + Log.i("SDL", "SDL: app closed recording device"); } private class RecordingThread extends Thread @@ -261,9 +261,9 @@ class AudioThread } else { - //System.out.println("SDL: nativeAudioRecordCallback with len " + mRecordBuffer.length); + //Log.i("SDL", "SDL: nativeAudioRecordCallback with len " + mRecordBuffer.length); nativeAudioRecordCallback(); - //System.out.println("SDL: nativeAudioRecordCallback returned"); + //Log.i("SDL", "SDL: nativeAudioRecordCallback returned"); } } diff --git a/project/java/DataDownloader.java b/project/java/DataDownloader.java index e5ddf398f..5d6bd5ff1 100644 --- a/project/java/DataDownloader.java +++ b/project/java/DataDownloader.java @@ -228,7 +228,7 @@ class DataDownloader extends Thread String [] downloadUrls = DataDownloadUrl.split("[|]"); if( downloadUrls.length < 2 ) { - System.out.println("Error: download string invalid: '" + DataDownloadUrl + "', your AndroidAppSettigns.cfg is broken"); + Log.i("SDL", "Error: download string invalid: '" + DataDownloadUrl + "', your AndroidAppSettigns.cfg is broken"); Status.setText( res.getString(R.string.error_dl_from, DataDownloadUrl) ); return false; } @@ -249,14 +249,14 @@ class DataDownloader extends Thread if( readed > 0 ) compare = new String( b, 0, readed, "UTF-8" ); boolean matched = false; - //System.out.println("Read URL: '" + compare + "'"); + //Log.i("SDL", "Read URL: '" + compare + "'"); for( int i = 1; i < downloadUrls.length; i++ ) { - //System.out.println("Comparing: '" + downloadUrls[i] + "'"); + //Log.i("SDL", "Comparing: '" + downloadUrls[i] + "'"); if( compare.compareTo(downloadUrls[i]) == 0 ) matched = true; } - //System.out.println("Matched: " + String.valueOf(matched)); + //Log.i("SDL", "Matched: " + String.valueOf(matched)); if( ! matched ) throw new IOException(); Status.setText( res.getString(R.string.download_unneeded) ); @@ -269,7 +269,7 @@ class DataDownloader extends Thread checkFile = null; // Create output directory (not necessary for phone storage) - System.out.println("Downloading data to: '" + outFilesDir + "'"); + Log.i("SDL", "Downloading data to: '" + outFilesDir + "'"); try { File outDir = new File( outFilesDir ); if( !(outDir.exists() && outDir.isDirectory()) ) @@ -295,7 +295,7 @@ class DataDownloader extends Thread int downloadUrlIndex = 1; while( downloadUrlIndex < downloadUrls.length ) { - System.out.println("Processing download " + downloadUrls[downloadUrlIndex]); + Log.i("SDL", "Processing download " + downloadUrls[downloadUrlIndex]); url = new String(downloadUrls[downloadUrlIndex]); DoNotUnzip = false; if(url.indexOf(":") == 0) @@ -320,18 +320,18 @@ class DataDownloader extends Thread stream1 = Parent.getAssets().open(url + "00"); stream1.close(); } catch( Exception ee ) { - System.out.println("Failed to open file in assets: " + url); + Log.i("SDL", "Failed to open file in assets: " + url); downloadUrlIndex++; continue; } } FileInAssets = true; - System.out.println("Fetching file from assets: " + url); + Log.i("SDL", "Fetching file from assets: " + url); break; } else { - System.out.println("Connecting to: " + url); + Log.i("SDL", "Connecting to: " + url); request = new HttpGet(url); request.addHeader("Accept", "*/*"); if( partialDownloadLen > 0 ) @@ -341,14 +341,14 @@ class DataDownloader extends Thread client.getParams().setBooleanParameter("http.protocol.handle-redirects", true); response = client.execute(request); } catch (IOException e) { - System.out.println("Failed to connect to " + url); + Log.i("SDL", "Failed to connect to " + url); downloadUrlIndex++; }; if( response != null ) { if( response.getStatusLine().getStatusCode() != 200 && response.getStatusLine().getStatusCode() != 206 ) { - System.out.println("Failed to connect to " + url + " with error " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase()); + Log.i("SDL", "Failed to connect to " + url + " with error " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase()); responseError = response; response = null; downloadUrlIndex++; @@ -376,7 +376,7 @@ class DataDownloader extends Thread multipart = s; else multipart = new SequenceInputStream(multipart, s); - System.out.println("Multipart archive found: " + url1); + Log.i("SDL", "Multipart archive found: " + url1); } catch( IOException e ) { break; } @@ -393,7 +393,7 @@ class DataDownloader extends Thread stream.close(); stream = new CountingInputStream(Parent.getAssets().open(url), 8192); } catch( IOException e ) { - System.out.println("Unpacking from assets '" + url + "' - error: " + e.toString()); + Log.i("SDL", "Unpacking from assets '" + url + "' - error: " + e.toString()); Status.setText( res.getString(R.string.error_dl_from, url) ); return false; } @@ -403,7 +403,7 @@ class DataDownloader extends Thread { if( response == null ) { - System.out.println("Error connecting to " + url); + Log.i("SDL", "Error connecting to " + url); Status.setText( res.getString(R.string.failed_connecting_to, url) + (responseError == null ? "" : ": " + responseError.getStatusLine().getStatusCode() + " " + responseError.getStatusLine().getReasonPhrase()) ); return false; } @@ -420,7 +420,7 @@ class DataDownloader extends Thread if(DoNotUnzip) { - System.out.println("Saving file '" + path + "'"); + Log.i("SDL", "Saving file '" + path + "'"); OutputStream out = null; try { try { @@ -435,12 +435,12 @@ class DataDownloader extends Thread Header[] range = response.getHeaders("Content-Range"); if( range.length > 0 && range[0].getValue().indexOf("bytes") == 0 ) { - //System.out.println("Resuming download of file '" + path + "': Content-Range: " + range[0].getValue()); + //Log.i("SDL", "Resuming download of file '" + path + "': Content-Range: " + range[0].getValue()); String[] skippedBytes = range[0].getValue().split("/")[0].split("-")[0].split(" "); if( skippedBytes.length >= 2 && Long.parseLong(skippedBytes[1]) == partialDownloadLen ) { out = new FileOutputStream( path, true ); - System.out.println("Resuming download of file '" + path + "' at pos " + partialDownloadLen); + Log.i("SDL", "Resuming download of file '" + path + "' at pos " + partialDownloadLen); } } } catch (Exception e) { } @@ -451,14 +451,14 @@ class DataDownloader extends Thread partialDownloadLen = 0; } } catch( FileNotFoundException e ) { - System.out.println("Saving file '" + path + "' - error creating output file: " + e.toString()); + Log.i("SDL", "Saving file '" + path + "' - error creating output file: " + e.toString()); } catch( SecurityException e ) { - System.out.println("Saving file '" + path + "' - error creating output file: " + e.toString()); + Log.i("SDL", "Saving file '" + path + "' - error creating output file: " + e.toString()); }; if( out == null ) { Status.setText( res.getString(R.string.error_write, path) ); - System.out.println("Saving file '" + path + "' - error creating output file"); + Log.i("SDL", "Saving file '" + path + "' - error creating output file"); return false; } @@ -480,14 +480,14 @@ class DataDownloader extends Thread out = null; } catch( java.io.IOException e ) { Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() ); - System.out.println("Saving file '" + path + "' - error writing: " + e.toString()); + Log.i("SDL", "Saving file '" + path + "' - error writing: " + e.toString()); return false; } - System.out.println("Saving file '" + path + "' done"); + Log.i("SDL", "Saving file '" + path + "' done"); } else { - System.out.println("Reading from zip file '" + url + "'"); + Log.i("SDL", "Reading from zip file '" + url + "'"); ZipInputStream zip = new ZipInputStream(stream); while(true) @@ -496,20 +496,20 @@ class DataDownloader extends Thread try { entry = zip.getNextEntry(); if( entry != null ) - System.out.println("Reading from zip file '" + url + "' entry '" + entry.getName() + "'"); + Log.i("SDL", "Reading from zip file '" + url + "' entry '" + entry.getName() + "'"); } catch( java.io.IOException e ) { Status.setText( res.getString(R.string.error_dl_from, url) ); - System.out.println("Error reading from zip file '" + url + "': " + e.toString()); + Log.i("SDL", "Error reading from zip file '" + url + "': " + e.toString()); return false; } if( entry == null ) { - System.out.println("Reading from zip file '" + url + "' finished"); + Log.i("SDL", "Reading from zip file '" + url + "' finished"); break; } if( entry.isDirectory() ) { - System.out.println("Creating dir '" + getOutFilePath(entry.getName()) + "'"); + Log.i("SDL", "Creating dir '" + getOutFilePath(entry.getName()) + "'"); try { File outDir = new File( getOutFilePath(entry.getName()) ); if( !(outDir.exists() && outDir.isDirectory()) ) @@ -522,7 +522,7 @@ class DataDownloader extends Thread path = getOutFilePath(entry.getName()); float percent = 0.0f; - System.out.println("Saving file '" + path + "'"); + Log.i("SDL", "Saving file '" + path + "'"); try { File outDir = new File( path.substring(0, path.lastIndexOf("/") )); @@ -540,7 +540,7 @@ class DataDownloader extends Thread ff.delete(); throw new Exception(); } - System.out.println("File '" + path + "' exists and passed CRC check - not overwriting it"); + Log.i("SDL", "File '" + path + "' exists and passed CRC check - not overwriting it"); if( totalLen > 0 ) percent = stream.getBytesRead() * 100.0f / totalLen; Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) ); @@ -550,14 +550,14 @@ class DataDownloader extends Thread try { out = new FileOutputStream( path ); } catch( FileNotFoundException e ) { - System.out.println("Saving file '" + path + "' - cannot create file: " + e.toString()); + Log.i("SDL", "Saving file '" + path + "' - cannot create file: " + e.toString()); } catch( SecurityException e ) { - System.out.println("Saving file '" + path + "' - cannot create file: " + e.toString()); + Log.i("SDL", "Saving file '" + path + "' - cannot create file: " + e.toString()); }; if( out == null ) { Status.setText( res.getString(R.string.error_write, path) ); - System.out.println("Saving file '" + path + "' - cannot create file"); + Log.i("SDL", "Saving file '" + path + "' - cannot create file"); return false; } @@ -583,7 +583,7 @@ class DataDownloader extends Thread out = null; } catch( java.io.IOException e ) { Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() ); - System.out.println("Saving file '" + path + "' - error writing or downloading: " + e.toString()); + Log.i("SDL", "Saving file '" + path + "' - error writing or downloading: " + e.toString()); return false; } @@ -600,7 +600,7 @@ class DataDownloader extends Thread { File ff = new File(path); ff.delete(); - System.out.println("Saving file '" + path + "' - CRC check failed, ZIP: " + + Log.i("SDL", "Saving file '" + path + "' - CRC check failed, ZIP: " + String.format("%x", entry.getCrc()) + " actual file: " + String.format("%x", check.getChecksum().getValue()) + " file size in ZIP: " + entry.getSize() + " actual size " + count ); throw new Exception(); @@ -609,7 +609,7 @@ class DataDownloader extends Thread Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() ); return false; } - System.out.println("Saving file '" + path + "' done"); + Log.i("SDL", "Saving file '" + path + "' done"); } }; diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java index 8c4cdc476..4c2ddd28a 100644 --- a/project/java/MainActivity.java +++ b/project/java/MainActivity.java @@ -74,6 +74,7 @@ import java.util.concurrent.Semaphore; import android.content.pm.ActivityInfo; import android.view.Display; import android.text.InputType; +import android.util.Log; public class MainActivity extends Activity { @@ -93,7 +94,7 @@ public class MainActivity extends Activity getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - System.out.println("libSDL: Creating startup screen"); + Log.i("SDL", "libSDL: Creating startup screen"); _layout = new LinearLayout(this); _layout.setOrientation(LinearLayout.VERTICAL); _layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); @@ -114,7 +115,7 @@ public class MainActivity extends Activity public void onClick(View v) { setUpStatusLabel(); - System.out.println("libSDL: User clicked change phone config button"); + Log.i("SDL", "libSDL: User clicked change phone config button"); loadedLibraries.acquireUninterruptibly(); Settings.showConfig(p, false); } @@ -164,10 +165,10 @@ public class MainActivity extends Activity if(p.mAudioThread == null) { - System.out.println("libSDL: Loading libraries"); + Log.i("SDL", "libSDL: Loading libraries"); p.LoadLibraries(); p.mAudioThread = new AudioThread(p); - System.out.println("libSDL: Loading settings"); + Log.i("SDL", "libSDL: Loading settings"); final Semaphore loaded = new Semaphore(0); class Callback2 implements Runnable { @@ -191,14 +192,14 @@ public class MainActivity extends Activity { if( Globals.StartupMenuButtonTimeout > 0 ) { - System.out.println("libSDL: " + String.valueOf(Globals.StartupMenuButtonTimeout) + "-msec timeout in startup screen"); + Log.i("SDL", "libSDL: " + String.valueOf(Globals.StartupMenuButtonTimeout) + "-msec timeout in startup screen"); try { Thread.sleep(Globals.StartupMenuButtonTimeout); } catch( InterruptedException e ) {}; } if( Settings.settingsChanged ) return; - System.out.println("libSDL: Timeout reached in startup screen, process with downloader"); + Log.i("SDL", "libSDL: Timeout reached in startup screen, process with downloader"); p.startDownloader(); } } @@ -225,14 +226,14 @@ public class MainActivity extends Activity public void startDownloader() { - System.out.println("libSDL: Starting data downloader"); + Log.i("SDL", "libSDL: Starting data downloader"); class Callback implements Runnable { public MainActivity Parent; public void run() { setUpStatusLabel(); - System.out.println("libSDL: Starting downloader"); + Log.i("SDL", "libSDL: Starting downloader"); if( Parent.downloader == null ) Parent.downloader = new DataDownloader(Parent, Parent._tv); } @@ -251,7 +252,7 @@ public class MainActivity extends Activity //int tries = 30; while( isCurrentOrientationHorizontal() != Globals.HorizontalOrientation ) { - System.out.println("libSDL: Waiting for screen orientation to change - the device is probably in the lockscreen mode"); + Log.i("SDL", "libSDL: Waiting for screen orientation to change - the device is probably in the lockscreen mode"); try { Thread.sleep(500); } catch( Exception e ) {} @@ -259,13 +260,13 @@ public class MainActivity extends Activity tries--; if( tries <= 0 ) { - System.out.println("libSDL: Giving up waiting for screen orientation change"); + Log.i("SDL", "libSDL: Giving up waiting for screen orientation change"); break; } */ if( _isPaused ) { - System.out.println("libSDL: Application paused, cancelling SDL initialization until it will be brought to foreground"); + Log.i("SDL", "libSDL: Application paused, cancelling SDL initialization until it will be brought to foreground"); return; } } @@ -284,7 +285,7 @@ public class MainActivity extends Activity { if(sdlInited) return; - System.out.println("libSDL: Initializing video and SDL application"); + Log.i("SDL", "libSDL: Initializing video and SDL application"); sdlInited = true; if(Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) @@ -363,7 +364,7 @@ public class MainActivity extends Activity @Override public void onWindowFocusChanged (boolean hasFocus) { super.onWindowFocusChanged(hasFocus); - System.out.println("libSDL: onWindowFocusChanged: " + hasFocus + " - sending onPause/onResume"); + Log.i("SDL", "libSDL: onWindowFocusChanged: " + hasFocus + " - sending onPause/onResume"); if (hasFocus == false) onPause(); else @@ -454,7 +455,7 @@ public class MainActivity extends Activity return true; } } - //System.out.println("Key " + keyCode + " flags " + event.getFlags() + " action " + event.getAction()); + //Log.i("SDL", "Key " + keyCode + " flags " + event.getFlags() + " action " + event.getAction()); return false; } }; @@ -514,7 +515,7 @@ public class MainActivity extends Activity public void setScreenKeyboardHintMessage(String s) { _screenKeyboardHintMessage = s; - //System.out.println("setScreenKeyboardHintMessage: " + (_screenKeyboardHintMessage != null ? _screenKeyboardHintMessage : getString(R.string.text_edit_click_here))); + //Log.i("SDL", "setScreenKeyboardHintMessage: " + (_screenKeyboardHintMessage != null ? _screenKeyboardHintMessage : getString(R.string.text_edit_click_here))); runOnUiThread(new Runnable() { public void run() @@ -667,7 +668,7 @@ public class MainActivity extends Activity @Override public boolean dispatchTouchEvent(final MotionEvent ev) { - //System.out.println("dispatchTouchEvent: " + ev.getAction() + " coords " + ev.getX() + ":" + ev.getY() ); + //Log.i("SDL", "dispatchTouchEvent: " + ev.getAction() + " coords " + ev.getX() + ":" + ev.getY() ); if(_screenKeyboard != null) _screenKeyboard.dispatchTouchEvent(ev); else @@ -694,7 +695,7 @@ public class MainActivity extends Activity @Override public boolean dispatchGenericMotionEvent (MotionEvent ev) { - //System.out.println("dispatchGenericMotionEvent: " + ev.getAction() + " coords " + ev.getX() + ":" + ev.getY() ); + //Log.i("SDL", "dispatchGenericMotionEvent: " + ev.getAction() + " coords " + ev.getX() + ":" + ev.getY() ); // This code fails to run for Android 1.6, so there will be no generic motion event for Andorid screen keyboard /* if(_screenKeyboard != null) @@ -760,11 +761,11 @@ public class MainActivity extends Activity { if(Globals.NeedGles2) System.loadLibrary("GLESv2"); - System.out.println("libSDL: loaded GLESv2 lib"); + Log.i("SDL", "libSDL: loaded GLESv2 lib"); } catch ( UnsatisfiedLinkError e ) { - System.out.println("libSDL: Cannot load GLESv2 lib"); + Log.i("SDL", "libSDL: Cannot load GLESv2 lib"); } // ----- VCMI hack ----- @@ -772,7 +773,7 @@ public class MainActivity extends Activity for(String binaryZip: binaryZipNames) { try { - System.out.println("libSDL: Trying to extract binaries from assets " + binaryZip); + Log.i("SDL", "libSDL: Trying to extract binaries from assets " + binaryZip); InputStream in = null; try @@ -813,11 +814,11 @@ public class MainActivity extends Activity entry = zip.getNextEntry(); /* if( entry != null ) - System.out.println("Extracting lib " + entry.getName()); + Log.i("SDL", "Extracting lib " + entry.getName()); */ if( entry == null ) { - System.out.println("Extracting binaries finished"); + Log.i("SDL", "Extracting binaries finished"); break; } if( entry.isDirectory() ) @@ -846,11 +847,11 @@ public class MainActivity extends Activity ff.delete(); throw new Exception(); } - System.out.println("File '" + path + "' exists and passed CRC check - not overwriting it"); + Log.i("SDL", "File '" + path + "' exists and passed CRC check - not overwriting it"); continue; } catch( Exception eeeeee ) { } - System.out.println("Saving to file '" + path + "'"); + Log.i("SDL", "Saving to file '" + path + "'"); out = new FileOutputStream( path ); int len = zip.read(buf); @@ -868,7 +869,7 @@ public class MainActivity extends Activity } catch ( Exception eee ) { - //System.out.println("libSDL: Error: " + eee.toString()); + //Log.i("SDL", "libSDL: Error: " + eee.toString()); } } // ----- VCMI hack ----- @@ -882,22 +883,22 @@ public class MainActivity extends Activity { String libname = System.mapLibraryName(l); File libpath = new File(getFilesDir().getAbsolutePath() + "/../lib/" + libname); - System.out.println("libSDL: loading lib " + libpath.getAbsolutePath()); + Log.i("SDL", "libSDL: loading lib " + libpath.getAbsolutePath()); System.load(libpath.getPath()); } catch( UnsatisfiedLinkError e ) { - System.out.println("libSDL: error loading lib " + l + ": " + e.toString()); + Log.i("SDL", "libSDL: error loading lib " + l + ": " + e.toString()); try { String libname = System.mapLibraryName(l); File libpath = new File(getFilesDir().getAbsolutePath() + "/" + libname); - System.out.println("libSDL: loading lib " + libpath.getAbsolutePath()); + Log.i("SDL", "libSDL: loading lib " + libpath.getAbsolutePath()); System.load(libpath.getPath()); } catch( UnsatisfiedLinkError ee ) { - System.out.println("libSDL: error loading lib " + l + ": " + ee.toString()); + Log.i("SDL", "libSDL: error loading lib " + l + ": " + ee.toString()); System.loadLibrary(l); } } @@ -906,7 +907,7 @@ public class MainActivity extends Activity catch ( UnsatisfiedLinkError e ) { try { - System.out.println("libSDL: Extracting APP2SD-ed libs"); + Log.i("SDL", "libSDL: Extracting APP2SD-ed libs"); InputStream in = null; try @@ -939,11 +940,11 @@ public class MainActivity extends Activity entry = zip.getNextEntry(); /* if( entry != null ) - System.out.println("Extracting lib " + entry.getName()); + Log.i("SDL", "Extracting lib " + entry.getName()); */ if( entry == null ) { - System.out.println("Extracting libs finished"); + Log.i("SDL", "Extracting libs finished"); break; } if( entry.isDirectory() ) @@ -962,7 +963,7 @@ public class MainActivity extends Activity outDir.mkdirs(); } catch( SecurityException eeeee ) { }; - System.out.println("Saving to file '" + path + "'"); + Log.i("SDL", "Saving to file '" + path + "'"); out = new FileOutputStream( path ); int len = zip.read(buf); @@ -981,14 +982,14 @@ public class MainActivity extends Activity { String libname = System.mapLibraryName(l); File libpath = new File(libDir, libname); - System.out.println("libSDL: loading lib " + libpath.getPath()); + Log.i("SDL", "libSDL: loading lib " + libpath.getPath()); System.load(libpath.getPath()); libpath.delete(); } } catch ( Exception ee ) { - System.out.println("libSDL: Error: " + ee.toString()); + Log.i("SDL", "libSDL: Error: " + ee.toString()); } } @@ -1007,21 +1008,21 @@ public class MainActivity extends Activity } catch ( UnsatisfiedLinkError e ) { - System.out.println("libSDL: error loading lib: " + e.toString()); + Log.i("SDL", "libSDL: error loading lib: " + e.toString()); try { for(String l : libs) { String libname = System.mapLibraryName(l); File libpath = new File(context.getFilesDir(), libname); - System.out.println("libSDL: loading lib " + libpath.getPath()); + Log.i("SDL", "libSDL: loading lib " + libpath.getPath()); System.load(libpath.getPath()); libpath.delete(); } } catch ( UnsatisfiedLinkError ee ) { - System.out.println("libSDL: error loading lib: " + ee.toString()); + Log.i("SDL", "libSDL: error loading lib: " + ee.toString()); } } } @@ -1032,7 +1033,7 @@ public class MainActivity extends Activity PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0); return packageInfo.versionCode; } catch (PackageManager.NameNotFoundException e) { - System.out.println("libSDL: Cannot get the version of our own package: " + e); + Log.i("SDL", "libSDL: Cannot get the version of our own package: " + e); } return 0; } diff --git a/project/java/Settings.java b/project/java/Settings.java index a2d3710d7..95c26d529 100644 --- a/project/java/Settings.java +++ b/project/java/Settings.java @@ -183,7 +183,7 @@ class Settings { return; } - System.out.println("libSDL: Settings.Load(): enter"); + Log.i("SDL", "libSDL: Settings.Load(): enter"); nativeInitKeymap(); for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ ) { @@ -239,7 +239,7 @@ class Settings Globals.ScreenKbControlsLayout[i][3] = Globals.ScreenKbControlsLayout[i][1] + wh; } - System.out.println("android.os.Build.MODEL: " + android.os.Build.MODEL); + Log.i("SDL", "android.os.Build.MODEL: " + android.os.Build.MODEL); if( (android.os.Build.MODEL.equals("GT-N7000") || android.os.Build.MODEL.equals("SGH-I717")) && android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.GINGERBREAD_MR1 ) { @@ -346,16 +346,16 @@ class Settings settingsLoaded = true; - System.out.println("libSDL: Settings.Load(): loaded settings successfully"); + Log.i("SDL", "libSDL: Settings.Load(): loaded settings successfully"); settingsFile.close(); - System.out.println("libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion()); + Log.i("SDL", "libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion()); if( cfgVersion != p.getApplicationVersion() ) { DeleteFilesOnUpgrade(); if( Globals.ResetSdlConfigForThisVersion ) { - System.out.println("libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion() + " and we need to clean up config file"); + Log.i("SDL", "libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion() + " and we need to clean up config file"); // Delete settings file, and restart the application DeleteSdlConfigOnUpgradeAndRestart(p); } @@ -370,7 +370,7 @@ class Settings DeleteFilesOnUpgrade(); if( Globals.ResetSdlConfigForThisVersion ) { - System.out.println("libSDL: old cfg version unknown or too old, our version " + p.getApplicationVersion() + " and we need to clean up config file"); + Log.i("SDL", "libSDL: old cfg version unknown or too old, our version " + p.getApplicationVersion() + " and we need to clean up config file"); DeleteSdlConfigOnUpgradeAndRestart(p); } }; @@ -379,7 +379,7 @@ class Settings { if( !Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) ) { - System.out.println("libSDL: SD card or external storage is not mounted (state " + Environment.getExternalStorageState() + "), switching to the internal storage."); + Log.i("SDL", "libSDL: SD card or external storage is not mounted (state " + Environment.getExternalStorageState() + "), switching to the internal storage."); Globals.DownloadToSdcard = false; } Globals.DataDir = Globals.DownloadToSdcard ? @@ -396,7 +396,7 @@ class Settings } } - System.out.println("libSDL: Settings.Load(): loading settings failed, running config dialog"); + Log.i("SDL", "libSDL: Settings.Load(): loading settings failed, running config dialog"); p.setUpStatusLabel(); if( checkRamSize(p) ) showConfig(p, true); @@ -1617,7 +1617,7 @@ class Settings p.touchListener = null; Globals.ClickScreenPressure = getAverageForce(); Globals.ClickScreenTouchspotSize = getAverageRadius(); - System.out.println("SDL: measured average force " + Globals.ClickScreenPressure + " radius " + Globals.ClickScreenTouchspotSize); + Log.i("SDL", "SDL: measured average force " + Globals.ClickScreenPressure + " radius " + Globals.ClickScreenTouchspotSize); goBack(p); } } @@ -2097,7 +2097,7 @@ class Settings continue; if( currentButton == -1 ) currentButton = i; - System.out.println("Screen kb button " + i + " coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] ); + Log.i("SDL", "Screen kb button " + i + " coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] ); // Check if the button is off screen edge or shrunk to zero if( Globals.ScreenKbControlsLayout[i][0] > Globals.ScreenKbControlsLayout[i][2] - displayY/12 ) Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY/12; @@ -2127,7 +2127,7 @@ class Settings Globals.ScreenKbControlsLayout[i][1] -= Globals.ScreenKbControlsLayout[i][3] - displayY; Globals.ScreenKbControlsLayout[i][3] = displayY; } - System.out.println("After bounds check coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] ); + Log.i("SDL", "After bounds check coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] ); imgs[i] = new ImageView(p); imgs[i].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); @@ -2714,7 +2714,7 @@ class Settings String lang = new String(Locale.getDefault().getLanguage()); if( Locale.getDefault().getCountry().length() > 0 ) lang = lang + "_" + Locale.getDefault().getCountry(); - System.out.println( "libSDL: setting envvar LANGUAGE to '" + lang + "'"); + Log.i("SDL", "libSDL: setting envvar LANGUAGE to '" + lang + "'"); nativeSetEnv( "LANG", lang ); nativeSetEnv( "LANGUAGE", lang ); // TODO: get current user name and set envvar USER, the API is not availalbe on Android 1.6 so I don't bother with this @@ -2849,7 +2849,7 @@ class Settings { String[] fields = line.split("[ \t]+"); Long size = Long.parseLong(fields[1]); - System.out.println("Device RAM size: " + size / 1024 + " Mb, required minimum RAM: " + Globals.AppMinimumRAM + " Mb" ); + Log.i("SDL", "Device RAM size: " + size / 1024 + " Mb, required minimum RAM: " + Globals.AppMinimumRAM + " Mb" ); if( size / 1024 < Globals.AppMinimumRAM ) { settingsChanged = true; @@ -2888,7 +2888,7 @@ class Settings } } } catch ( Exception e ) { - System.out.println("Error: cannot parse /proc/meminfo: " + e.toString()); + Log.i("SDL", "Error: cannot parse /proc/meminfo: " + e.toString()); } return true; } diff --git a/project/java/Video.java b/project/java/Video.java index 3425f4c2c..600515056 100644 --- a/project/java/Video.java +++ b/project/java/Video.java @@ -47,6 +47,7 @@ import android.graphics.drawable.BitmapDrawable; import android.content.res.Resources; import android.content.res.AssetManager; import android.widget.Toast; +import android.util.Log; import android.widget.TextView; import java.lang.Thread; @@ -108,7 +109,7 @@ abstract class DifferentTouchInput multiTouchAvailable2 = true; } try { - System.out.println("Device model: " + android.os.Build.MODEL); + Log.i("SDL", "Device model: " + android.os.Build.MODEL); if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH ) { return IcsTouchInput.Holder.sInstance; @@ -191,7 +192,7 @@ abstract class DifferentTouchInput { int action = -1; - //System.out.println("Got motion event, type " + (int)(event.getAction()) + " X " + (int)event.getX() + " Y " + (int)event.getY()); + //Log.i("SDL", "Got motion event, type " + (int)(event.getAction()) + " X " + (int)event.getX() + " Y " + (int)event.getY()); if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP || (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_CANCEL ) { @@ -231,7 +232,7 @@ abstract class DifferentTouchInput { s += " p" + event.getPointerId(i) + "=" + (int)event.getX(i) + ":" + (int)event.getY(i); } - System.out.println(s); + Log.i("SDL", s); */ int pointerReleased = -1; if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP ) @@ -332,7 +333,7 @@ abstract class DifferentTouchInput private int buttonState = 0; public void process(final MotionEvent event) { - //System.out.println("Got motion event, type " + (int)(event.getAction()) + " X " + (int)event.getX() + " Y " + (int)event.getY() + " buttons " + buttonState + " source " + event.getSource()); + //Log.i("SDL", "Got motion event, type " + (int)(event.getAction()) + " X " + (int)event.getX() + " Y " + (int)event.getY() + " buttons " + buttonState + " source " + event.getSource()); int buttonStateNew = event.getButtonState(); if( buttonStateNew != buttonState ) { @@ -379,7 +380,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer } public void onSurfaceCreated(GL10 gl, EGLConfig config) { - System.out.println("libSDL: DemoRenderer.onSurfaceCreated(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart ); + Log.i("SDL", "libSDL: DemoRenderer.onSurfaceCreated(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart ); mGlSurfaceCreated = true; mGl = gl; if( ! mPaused && ! mFirstTimeStart ) @@ -388,7 +389,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer } public void onSurfaceChanged(GL10 gl, int w, int h) { - System.out.println("libSDL: DemoRenderer.onSurfaceChanged(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart ); + Log.i("SDL", "libSDL: DemoRenderer.onSurfaceChanged(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart ); mWidth = w; mHeight = h; mGl = gl; @@ -396,7 +397,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer } public void onSurfaceDestroyed() { - System.out.println("libSDL: DemoRenderer.onSurfaceDestroyed(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart ); + Log.i("SDL", "libSDL: DemoRenderer.onSurfaceDestroyed(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart ); mGlSurfaceCreated = false; mGlContextLost = true; nativeGlContextLost(); @@ -723,7 +724,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL { return; mRenderer.mPaused = false; super.onResume(); - System.out.println("libSDL: DemoGLSurfaceView.onResume(): mRenderer.mGlSurfaceCreated " + mRenderer.mGlSurfaceCreated + " mRenderer.mPaused " + mRenderer.mPaused); + Log.i("SDL", "libSDL: DemoGLSurfaceView.onResume(): mRenderer.mGlSurfaceCreated " + mRenderer.mGlSurfaceCreated + " mRenderer.mPaused " + mRenderer.mPaused); if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused || Globals.NonBlockingSwapBuffers ) mRenderer.nativeGlContextRecreated(); if( mRenderer.accelerometer != null && mRenderer.accelerometer.openedBySDL ) // For some reason it crashes here often - are we getting this event before initialization? @@ -733,7 +734,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL { // This seems like redundant code - it handled in MainActivity.java @Override public boolean onKeyDown(int keyCode, final KeyEvent event) { - //System.out.println("Got key down event, id " + keyCode + " meta " + event.getMetaState() + " event " + event.toString()); + //Log.i("SDL", "Got key down event, id " + keyCode + " meta " + event.getMetaState() + " event " + event.toString()); if( nativeKey( keyCode, 1 ) == 0 ) return super.onKeyDown(keyCode, event); return true; @@ -741,7 +742,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL { @Override public boolean onKeyUp(int keyCode, final KeyEvent event) { - //System.out.println("Got key up event, id " + keyCode + " meta " + event.getMetaState()); + //Log.i("SDL", "Got key up event, id " + keyCode + " meta " + event.getMetaState()); if( nativeKey( keyCode, 0 ) == 0 ) return super.onKeyUp(keyCode, event); return true;