Remove trailing spaces in Android source code.
authorReto Schneider <code@reto-schneider.ch>
Wed, 08 Apr 2015 12:14:36 +0200
changeset 9573cc6cba65bf36
parent 9572 6fe1936ac50b
child 9574 98c57505d74d
Remove trailing spaces in Android source code.
android-project/src/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Thu Jun 05 11:55:37 2014 -0300
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Wed Apr 08 12:14:36 2015 +0200
     1.3 @@ -54,7 +54,7 @@
     1.4  
     1.5      // This is what SDL runs in. It invokes SDL_main(), eventually
     1.6      protected static Thread mSDLThread;
     1.7 -    
     1.8 +
     1.9      // Audio
    1.10      protected static AudioTrack mAudioTrack;
    1.11  
    1.12 @@ -83,7 +83,7 @@
    1.13            System.loadLibrary(lib);
    1.14         }
    1.15      }
    1.16 -    
    1.17 +
    1.18      /**
    1.19       * This method is called by SDL before starting the native application thread.
    1.20       * It can be overridden to provide the arguments after the application name.
    1.21 @@ -93,7 +93,7 @@
    1.22      protected String[] getArguments() {
    1.23          return new String[0];
    1.24      }
    1.25 -    
    1.26 +
    1.27      public static void initialize() {
    1.28          // The static nature of the singleton and Android quirkyness force us to initialize everything here
    1.29          // Otherwise, when exiting the app and returning to it, these variables *keep* their pre exit values
    1.30 @@ -114,11 +114,11 @@
    1.31      // Setup
    1.32      @Override
    1.33      protected void onCreate(Bundle savedInstanceState) {
    1.34 -        Log.v("SDL", "Device: " + android.os.Build.DEVICE);                     
    1.35 +        Log.v("SDL", "Device: " + android.os.Build.DEVICE);
    1.36          Log.v("SDL", "Model: " + android.os.Build.MODEL);
    1.37          Log.v("SDL", "onCreate():" + mSingleton);
    1.38          super.onCreate(savedInstanceState);
    1.39 -        
    1.40 +
    1.41          SDLActivity.initialize();
    1.42          // So we can call stuff from static callbacks
    1.43          mSingleton = this;
    1.44 @@ -161,7 +161,7 @@
    1.45  
    1.46          // Set up the surface
    1.47          mSurface = new SDLSurface(getApplication());
    1.48 -        
    1.49 +
    1.50          if(Build.VERSION.SDK_INT >= 12) {
    1.51              mJoystickHandler = new SDLJoystickHandler_API12();
    1.52          }
    1.53 @@ -254,7 +254,7 @@
    1.54  
    1.55              //Log.v("SDL", "Finished waiting for SDL thread");
    1.56          }
    1.57 -            
    1.58 +
    1.59          super.onDestroy();
    1.60          // Reset everything in case the user re opens the app
    1.61          SDLActivity.initialize();
    1.62 @@ -303,7 +303,7 @@
    1.63              mSurface.handleResume();
    1.64          }
    1.65      }
    1.66 -        
    1.67 +
    1.68      /* The native thread has finished */
    1.69      public static void handleNativeExit() {
    1.70          SDLActivity.mSDLThread = null;
    1.71 @@ -409,14 +409,14 @@
    1.72      public static native void onNativeKeyboardFocusLost();
    1.73      public static native void onNativeMouse(int button, int action, float x, float y);
    1.74      public static native void onNativeTouch(int touchDevId, int pointerFingerId,
    1.75 -                                            int action, float x, 
    1.76 +                                            int action, float x,
    1.77                                              float y, float p);
    1.78      public static native void onNativeAccel(float x, float y, float z);
    1.79      public static native void onNativeSurfaceChanged();
    1.80      public static native void onNativeSurfaceDestroyed();
    1.81      public static native void nativeFlipBuffers();
    1.82 -    public static native int nativeAddJoystick(int device_id, String name, 
    1.83 -                                               int is_accelerometer, int nbuttons, 
    1.84 +    public static native int nativeAddJoystick(int device_id, String name,
    1.85 +                                               int is_accelerometer, int nbuttons,
    1.86                                                 int naxes, int nhats, int nballs);
    1.87      public static native int nativeRemoveJoystick(int device_id);
    1.88      public static native String nativeGetHint(String name);
    1.89 @@ -541,33 +541,33 @@
    1.90          int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
    1.91          int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
    1.92          int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
    1.93 -        
    1.94 +
    1.95          Log.v("SDL", "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");
    1.96 -        
    1.97 +
    1.98          // Let the user pick a larger buffer if they really want -- but ye
    1.99          // gods they probably shouldn't, the minimums are horrifyingly high
   1.100          // latency already
   1.101          desiredFrames = Math.max(desiredFrames, (AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize);
   1.102 -        
   1.103 +
   1.104          if (mAudioTrack == null) {
   1.105              mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate,
   1.106                      channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);
   1.107 -            
   1.108 +
   1.109              // Instantiating AudioTrack can "succeed" without an exception and the track may still be invalid
   1.110              // Ref: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/media/java/android/media/AudioTrack.java
   1.111              // Ref: http://developer.android.com/reference/android/media/AudioTrack.html#getState()
   1.112 -            
   1.113 +
   1.114              if (mAudioTrack.getState() != AudioTrack.STATE_INITIALIZED) {
   1.115                  Log.e("SDL", "Failed during initialization of Audio Track");
   1.116                  mAudioTrack = null;
   1.117                  return -1;
   1.118              }
   1.119 -            
   1.120 +
   1.121              mAudioTrack.play();
   1.122          }
   1.123 -       
   1.124 +
   1.125          Log.v("SDL", "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioTrack.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer");
   1.126 -        
   1.127 +
   1.128          return 0;
   1.129      }
   1.130  
   1.131 @@ -927,11 +927,11 @@
   1.132  
   1.133  /**
   1.134      SDLSurface. This is what we draw on, so we need to know when it's created
   1.135 -    in order to do anything useful. 
   1.136 +    in order to do anything useful.
   1.137  
   1.138      Because of this, that's where we set up the SDL thread
   1.139  */
   1.140 -class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, 
   1.141 +class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
   1.142      View.OnKeyListener, View.OnTouchListener, SensorEventListener  {
   1.143  
   1.144      // Sensors
   1.145 @@ -941,20 +941,20 @@
   1.146      // Keep track of the surface size to normalize touch events
   1.147      protected static float mWidth, mHeight;
   1.148  
   1.149 -    // Startup    
   1.150 +    // Startup
   1.151      public SDLSurface(Context context) {
   1.152          super(context);
   1.153 -        getHolder().addCallback(this); 
   1.154 -    
   1.155 +        getHolder().addCallback(this);
   1.156 +
   1.157          setFocusable(true);
   1.158          setFocusableInTouchMode(true);
   1.159          requestFocus();
   1.160 -        setOnKeyListener(this); 
   1.161 -        setOnTouchListener(this);   
   1.162 +        setOnKeyListener(this);
   1.163 +        setOnTouchListener(this);
   1.164  
   1.165          mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
   1.166          mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
   1.167 -        
   1.168 +
   1.169          if(Build.VERSION.SDK_INT >= 12) {
   1.170              setOnGenericMotionListener(new SDLGenericMotionListener_API12());
   1.171          }
   1.172 @@ -963,7 +963,7 @@
   1.173          mWidth = 1.0f;
   1.174          mHeight = 1.0f;
   1.175      }
   1.176 -     
   1.177 +
   1.178      public void handleResume() {
   1.179          setFocusable(true);
   1.180          setFocusableInTouchMode(true);
   1.181 @@ -972,7 +972,7 @@
   1.182          setOnTouchListener(this);
   1.183          enableSensor(Sensor.TYPE_ACCELEROMETER, true);
   1.184      }
   1.185 -    
   1.186 +
   1.187      public Surface getNativeSurface() {
   1.188          return getHolder().getSurface();
   1.189      }
   1.190 @@ -1062,7 +1062,7 @@
   1.191              final Thread sdlThread = new Thread(new SDLMain(), "SDLThread");
   1.192              enableSensor(Sensor.TYPE_ACCELEROMETER, true);
   1.193              sdlThread.start();
   1.194 -            
   1.195 +
   1.196              // Set up a listener thread to catch when the native thread ends
   1.197              SDLActivity.mSDLThread = new Thread(new Runnable(){
   1.198                  @Override
   1.199 @@ -1071,7 +1071,7 @@
   1.200                          sdlThread.join();
   1.201                      }
   1.202                      catch(Exception e){}
   1.203 -                    finally{ 
   1.204 +                    finally{
   1.205                          // Native thread has finished
   1.206                          if (! SDLActivity.mExitCalledFromJava) {
   1.207                              SDLActivity.handleNativeExit();
   1.208 @@ -1107,7 +1107,7 @@
   1.209                  }
   1.210              }
   1.211          }
   1.212 -        
   1.213 +
   1.214          if( (event.getSource() & InputDevice.SOURCE_KEYBOARD) != 0) {
   1.215              if (event.getAction() == KeyEvent.ACTION_DOWN) {
   1.216                  //Log.v("SDL", "key down: " + keyCode);
   1.217 @@ -1120,7 +1120,7 @@
   1.218                  return true;
   1.219              }
   1.220          }
   1.221 -        
   1.222 +
   1.223          return false;
   1.224      }
   1.225  
   1.226 @@ -1159,7 +1159,7 @@
   1.227                          SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
   1.228                      }
   1.229                      break;
   1.230 -                
   1.231 +
   1.232                  case MotionEvent.ACTION_UP:
   1.233                  case MotionEvent.ACTION_DOWN:
   1.234                      // Primary pointer up/down, the index is always zero
   1.235 @@ -1170,14 +1170,14 @@
   1.236                      if (i == -1) {
   1.237                          i = event.getActionIndex();
   1.238                      }
   1.239 -                    
   1.240 +
   1.241                      pointerFingerId = event.getPointerId(i);
   1.242                      x = event.getX(i) / mWidth;
   1.243                      y = event.getY(i) / mHeight;
   1.244                      p = event.getPressure(i);
   1.245                      SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
   1.246                      break;
   1.247 -                
   1.248 +
   1.249                  case MotionEvent.ACTION_CANCEL:
   1.250                      for (i = 0; i < pointerCount; i++) {
   1.251                          pointerFingerId = event.getPointerId(i);
   1.252 @@ -1194,21 +1194,21 @@
   1.253          }
   1.254  
   1.255          return true;
   1.256 -   } 
   1.257 +   }
   1.258  
   1.259      // Sensor events
   1.260      public void enableSensor(int sensortype, boolean enabled) {
   1.261          // TODO: This uses getDefaultSensor - what if we have >1 accels?
   1.262          if (enabled) {
   1.263 -            mSensorManager.registerListener(this, 
   1.264 -                            mSensorManager.getDefaultSensor(sensortype), 
   1.265 +            mSensorManager.registerListener(this,
   1.266 +                            mSensorManager.getDefaultSensor(sensortype),
   1.267                              SensorManager.SENSOR_DELAY_GAME, null);
   1.268          } else {
   1.269 -            mSensorManager.unregisterListener(this, 
   1.270 +            mSensorManager.unregisterListener(this,
   1.271                              mSensorManager.getDefaultSensor(sensortype));
   1.272          }
   1.273      }
   1.274 -    
   1.275 +
   1.276      @Override
   1.277      public void onAccuracyChanged(Sensor sensor, int accuracy) {
   1.278          // TODO
   1.279 @@ -1240,7 +1240,7 @@
   1.280                                        y / SensorManager.GRAVITY_EARTH,
   1.281                                        event.values[2] / SensorManager.GRAVITY_EARTH - 1);
   1.282          }
   1.283 -    }    
   1.284 +    }
   1.285  }
   1.286  
   1.287  /* This is a fake invisible editor view that receives the input and defines the
   1.288 @@ -1282,7 +1282,7 @@
   1.289  
   1.290          return false;
   1.291      }
   1.292 -        
   1.293 +
   1.294      //
   1.295      @Override
   1.296      public boolean onKeyPreIme (int keyCode, KeyEvent event) {
   1.297 @@ -1361,7 +1361,7 @@
   1.298      public native void nativeSetComposingText(String text, int newCursorPosition);
   1.299  
   1.300      @Override
   1.301 -    public boolean deleteSurroundingText(int beforeLength, int afterLength) {       
   1.302 +    public boolean deleteSurroundingText(int beforeLength, int afterLength) {
   1.303          // Workaround to capture backspace key. Ref: http://stackoverflow.com/questions/14560344/android-backspace-in-webview-baseinputconnection
   1.304          if (beforeLength == 1 && afterLength == 0) {
   1.305              // backspace
   1.306 @@ -1375,7 +1375,7 @@
   1.307  
   1.308  /* A null joystick handler for API level < 12 devices (the accelerometer is handled separately) */
   1.309  class SDLJoystickHandler {
   1.310 -    
   1.311 +
   1.312      /**
   1.313       * Handles given MotionEvent.
   1.314       * @param event the event to be handled.
   1.315 @@ -1407,11 +1407,11 @@
   1.316              return arg0.getAxis() - arg1.getAxis();
   1.317          }
   1.318      }
   1.319 -    
   1.320 +
   1.321      private ArrayList<SDLJoystick> mJoysticks;
   1.322 -    
   1.323 +
   1.324      public SDLJoystickHandler_API12() {
   1.325 -       
   1.326 +
   1.327          mJoysticks = new ArrayList<SDLJoystick>();
   1.328      }
   1.329  
   1.330 @@ -1422,7 +1422,7 @@
   1.331          // For example, in the case of the XBox 360 wireless dongle,
   1.332          // so the first controller seen by SDL matches what the receiver
   1.333          // considers to be the first controller
   1.334 -        
   1.335 +
   1.336          for(int i=deviceIds.length-1; i>-1; i--) {
   1.337              SDLJoystick joystick = getJoystick(deviceIds[i]);
   1.338              if (joystick == null) {
   1.339 @@ -1433,7 +1433,7 @@
   1.340                      joystick.name = joystickDevice.getName();
   1.341                      joystick.axes = new ArrayList<InputDevice.MotionRange>();
   1.342                      joystick.hats = new ArrayList<InputDevice.MotionRange>();
   1.343 -                    
   1.344 +
   1.345                      List<InputDevice.MotionRange> ranges = joystickDevice.getMotionRanges();
   1.346                      Collections.sort(ranges, new RangeComparator());
   1.347                      for (InputDevice.MotionRange range : ranges ) {
   1.348 @@ -1447,14 +1447,14 @@
   1.349                              }
   1.350                          }
   1.351                      }
   1.352 -                    
   1.353 +
   1.354                      mJoysticks.add(joystick);
   1.355 -                    SDLActivity.nativeAddJoystick(joystick.device_id, joystick.name, 0, -1, 
   1.356 +                    SDLActivity.nativeAddJoystick(joystick.device_id, joystick.name, 0, -1,
   1.357                                                    joystick.axes.size(), joystick.hats.size()/2, 0);
   1.358                  }
   1.359              }
   1.360          }
   1.361 -        
   1.362 +
   1.363          /* Check removed devices */
   1.364          ArrayList<Integer> removedDevices = new ArrayList<Integer>();
   1.365          for(int i=0; i < mJoysticks.size(); i++) {
   1.366 @@ -1467,7 +1467,7 @@
   1.367                  removedDevices.add(Integer.valueOf(device_id));
   1.368              }
   1.369          }
   1.370 -            
   1.371 +
   1.372          for(int i=0; i < removedDevices.size(); i++) {
   1.373              int device_id = removedDevices.get(i).intValue();
   1.374              SDLActivity.nativeRemoveJoystick(device_id);
   1.375 @@ -1477,9 +1477,9 @@
   1.376                      break;
   1.377                  }
   1.378              }
   1.379 -        }        
   1.380 +        }
   1.381      }
   1.382 -    
   1.383 +
   1.384      protected SDLJoystick getJoystick(int device_id) {
   1.385          for(int i=0; i < mJoysticks.size(); i++) {
   1.386              if (mJoysticks.get(i).device_id == device_id) {
   1.387 @@ -1487,9 +1487,9 @@
   1.388              }
   1.389          }
   1.390          return null;
   1.391 -    }   
   1.392 -    
   1.393 -    @Override        
   1.394 +    }
   1.395 +
   1.396 +    @Override
   1.397      public boolean handleMotionEvent(MotionEvent event) {
   1.398          if ( (event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) {
   1.399              int actionPointerIndex = event.getActionIndex();
   1.400 @@ -1503,7 +1503,7 @@
   1.401                              /* Normalize the value to -1...1 */
   1.402                              float value = ( event.getAxisValue( range.getAxis(), actionPointerIndex) - range.getMin() ) / range.getRange() * 2.0f - 1.0f;
   1.403                              SDLActivity.onNativeJoy(joystick.device_id, i, value );
   1.404 -                        }          
   1.405 +                        }
   1.406                          for (int i = 0; i < joystick.hats.size(); i+=2) {
   1.407                              int hatX = Math.round(event.getAxisValue( joystick.hats.get(i).getAxis(), actionPointerIndex ) );
   1.408                              int hatY = Math.round(event.getAxisValue( joystick.hats.get(i+1).getAxis(), actionPointerIndex ) );
   1.409 @@ -1516,7 +1516,7 @@
   1.410              }
   1.411          }
   1.412          return true;
   1.413 -    }            
   1.414 +    }
   1.415  }
   1.416  
   1.417  class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {