From 5910c711d888c51400518f21b40c3395d5e9617f Mon Sep 17 00:00:00 2001 From: Miguel Astor Date: Thu, 28 Nov 2013 15:48:17 -0430 Subject: [PATCH 01/16] CameraImageMonitor now follows the Producer/Consumer model. Other assorted minor changes. --- res/values-es/strings.xml | 4 +- res/values/strings.xml | 2 +- src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java | 29 ++++++++----- src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java | 9 +--- .../ccg/nxtcam/camera/CameraImageMonitor.java | 43 +++++++++++-------- 5 files changed, 50 insertions(+), 37 deletions(-) diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 31826e1..1558306 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -10,7 +10,7 @@ Comenzar streaming de video CamActivity Dirección IP de NxtAR - La dirección IP no es válida + No se encontró un servidor válido Rellene el campo de dirección IP Esta app requiere WiFi ¿Encender el WiFi? @@ -18,7 +18,7 @@ Encender El radio del WiFi está encendido Esta app no puede funcionar sin wifi, cerrando. - Este dispositivo no soporta Bluetooth + Este dispositivo no soporta Bluetooth Esta app no puede funcionar sin Bluetooth, cerrando Ícono de lente Conectar con el robot diff --git a/res/values/strings.xml b/res/values/strings.xml index deb1f95..4e72cee 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -10,7 +10,7 @@ Connect with NxtAR Start video streaming NxtAR IP Address - Invalid IP address + No proper server found Fill out the IP address field This app requires WiFi Turn on the WiFi? diff --git a/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java b/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java index 47369bc..ea18169 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java @@ -2,6 +2,7 @@ package ve.ucv.ciens.ccg.nxtcam; import ve.ucv.ciens.ccg.nxtcam.camera.CameraPreview; import ve.ucv.ciens.ccg.nxtcam.network.ImageTransferThread; +import ve.ucv.ciens.ccg.nxtcam.network.LCPThread; import ve.ucv.ciens.ccg.nxtcam.utils.Logger; import android.app.Activity; import android.content.Intent; @@ -16,12 +17,13 @@ import android.widget.Toast; public class CamActivity extends Activity{ private final String TAG = "NXTCAM_CAM"; - private final String CLASS_NAME = MainActivity.class.getSimpleName(); - + private final String CLASS_NAME = CamActivity.class.getSimpleName(); + private Camera hwCamera; private CameraPreview cPreview; private CameraSetupTask camSetupTask; private ImageTransferThread imThread; + private LCPThread botThread; private String serverIp; /******************* @@ -31,12 +33,13 @@ public class CamActivity extends Activity{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - + cPreview = new CameraPreview(this, hwCamera); setContentView(cPreview); - + Intent intent = getIntent(); serverIp = intent.getStringExtra("address"); + imThread = new ImageTransferThread(serverIp); } @Override @@ -69,21 +72,27 @@ public class CamActivity extends Activity{ camSetupTask = new CameraSetupTask(); camSetupTask.execute(); - - imThread = new ImageTransferThread(serverIp); - imThread.start(); + + // imThread.start(); } @Override public void onPause(){ super.onPause(); - // TODO: Disconnect and destroy the imThread object. - + // TODO: pause the imThread and botThread objects. + cPreview.removePreviewCallback(); cPreview.setCamera(null); releaseCamera(); } + + @Override + public void onDestroy(){ + super.onDestroy(); + // TODO: Destroy the network threads. + imThread = null; + } /****************** * My own methods * @@ -121,7 +130,7 @@ public class CamActivity extends Activity{ @Override protected void onPostExecute(Camera result) { super.onPostExecute(result); - + hwCamera = result; if(result != null){ Logger.log_d(TAG, CLASS_NAME + ".onPostExecute() :: Camera successfully opened"); diff --git a/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java b/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java index 80a6dbb..3d57f54 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java @@ -334,11 +334,6 @@ public class MainActivity extends Activity implements WifiOnDialogListener, Conn Logger.log_d(TAG, CLASS_NAME + ".doInBackground() :: Packet payload is\n" + received); if(received.compareTo("NxtAR server here!") == 0) done = true; - Socket client1, client2; - client1 = new Socket(packet.getAddress(), ProjectConstants.SERVER_TCP_PORT_1); - client1.close(); - client2 = new Socket(packet.getAddress(), ProjectConstants.SERVER_TCP_PORT_2); - client2.close(); } result = true; }catch(IOException io){ @@ -367,10 +362,10 @@ public class MainActivity extends Activity implements WifiOnDialogListener, Conn if(packet != null){ showToast(R.string.serv_connected, Toast.LENGTH_SHORT); - // startCamActivity(result, packet.getAddress().getHostAddress()); + startCamActivity(result, packet.getAddress().getHostAddress()); }else{ showToast(R.string.serv_fail, Toast.LENGTH_SHORT); - // startCamActivity(false, null); + startCamActivity(false, null); } } } diff --git a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java index 4637344..51a094a 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java @@ -7,10 +7,12 @@ public class CameraImageMonitor{ private final String CLASS_NAME = CameraImageMonitor.class.getSimpleName(); private byte[] image; - private boolean imgChanged; + private boolean imgProduced; + private boolean imgConsumed; private CameraImageMonitor(){ - imgChanged = false; + imgProduced = false; + imgConsumed = false; } private static class SingletonHolder{ @@ -22,33 +24,40 @@ public class CameraImageMonitor{ } public void setImageData(byte[] image){ - Logger.log_d(TAG, CLASS_NAME + ".setImageData() :: Copying new image."); - synchronized(image){ - this.image = new byte[image.length]; - System.arraycopy(image, 0, this.image, 0, image.length); - imgChanged = true; - image.notifyAll(); + if(imgConsumed){ + Logger.log_d(TAG, CLASS_NAME + ".setImageData() :: Copying new image."); + synchronized(this.image){ + //this.image = new byte[image.length]; + //System.arraycopy(image, 0, this.image, 0, image.length); + this.image = image; + imgProduced = true; + imgConsumed = false; + this.image.notifyAll(); + } + Logger.log_d(TAG, CLASS_NAME + ".setImageData() :: Data copy finished."); + }else{ + Logger.log_d(TAG, CLASS_NAME + ".setImageData() :: Old image still valid, ignoring new image."); } - Logger.log_d(TAG, CLASS_NAME + ".setImageData() :: Data copy finished."); } public byte[] getImageData(){ byte[] returnImg; Logger.log_d(TAG, CLASS_NAME + ".getImageData() :: Entry point."); synchronized(image){ - while(!imgChanged){ - Logger.log_d(TAG, CLASS_NAME + ".getImageData() :: Waiting for new data."); - try{ image.wait(); }catch(InterruptedException ie){} + while(!imgProduced){ + Logger.log_d(TAG, CLASS_NAME + ".getImageData() :: Waiting for new image."); + try{ image.wait(); }catch(InterruptedException ie){ } } - Logger.log_d(TAG, CLASS_NAME + ".getImageData() :: Retrieving new data."); - returnImg = image.clone(); - imgChanged = false; + Logger.log_d(TAG, CLASS_NAME + ".getImageData() :: Retrieving new image."); + returnImg = image; + imgProduced = false; + imgConsumed = true; } - Logger.log_d(TAG, CLASS_NAME + ".getImageData() :: New data retreived."); + Logger.log_d(TAG, CLASS_NAME + ".getImageData() :: New image retrieved."); return returnImg; } public synchronized boolean hasChanged(){ - return imgChanged; + return imgProduced; } } From 770f6b247663646af43a9d0a7d1b5d9002307d55 Mon Sep 17 00:00:00 2001 From: Miguel Astor Date: Thu, 28 Nov 2013 16:04:18 -0430 Subject: [PATCH 02/16] Assorted refactorings on CamActivity. --- .../ccg/nxtcam/camera/CameraPreview.java | 93 +++++++++---------- 1 file changed, 45 insertions(+), 48 deletions(-) diff --git a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java index 93fb5cb..b257a1d 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java @@ -22,32 +22,32 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, private final String TAG = "SURFVIEW"; private final String CLASS_NAME = CameraPreview.class.getSimpleName(); - private Size mPreviewSize; - private List mSupportedPreviewSizes; - private CameraImageMonitor camMonitor; + private Size previewSize; + private List supportedPreviewSizes; + private CameraImageMonitor imgMonitor; private Activity parentActivity; - private SurfaceView mSurfaceView; - private SurfaceHolder mHolder; - private Camera mCamera; + private SurfaceView surfaceView; + private SurfaceHolder holder; + private Camera camera; @SuppressWarnings("deprecation") public CameraPreview(Context context, Camera camera){ super(context); parentActivity = (Activity)context; - mSurfaceView = new SurfaceView(context); - mHolder = mSurfaceView.getHolder(); - mHolder.addCallback(this); + surfaceView = new SurfaceView(context); + holder = surfaceView.getHolder(); + holder.addCallback(this); if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) - mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); + holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } public void setCamera(Camera camera){ - mCamera = camera; - if(mCamera != null){ - camMonitor = CameraImageMonitor.getInstance(); - mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes(); + this.camera = camera; + if(this.camera != null){ + imgMonitor = CameraImageMonitor.getInstance(); + supportedPreviewSizes = this.camera.getParameters().getSupportedPreviewSizes(); requestLayout(); } } @@ -55,43 +55,42 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, public void surfaceCreated(SurfaceHolder holder){ // The Surface has been created, now tell the camera where to draw the preview. try { - if(mCamera != null){ - mCamera.setPreviewDisplay(holder); - } + if(camera != null) + camera.setPreviewDisplay(holder); } catch (IOException e) { Logger.log_d(TAG, "Error setting camera preview: " + e.getMessage()); } } public void surfaceDestroyed(SurfaceHolder holder){ - if(mCamera != null){ - mCamera.stopPreview(); - } + if(camera != null) + camera.stopPreview(); } - public void surfaceChanged(SurfaceHolder holder, int format, int w, int h){ - if(mHolder.getSurface() == null){ - return; - } + public void surfaceChanged(SurfaceHolder tmpHolder, int format, int w, int h){ + int result; + int rotation; + int degrees = 0; + Camera.Parameters camParams; - try{ - mCamera.stopPreview(); - }catch (Exception e){ } + if(this.holder.getSurface() == null || camera == null) + return; + + try{ camera.stopPreview(); }catch (Exception e){ } requestLayout(); - Camera.Parameters camParams = mCamera.getParameters(); + camParams = camera.getParameters(); /*Size optimal = getOptimalPreviewSize(camParams.getSupportedPreviewSizes(), w, h); if(ProjectConstants.DEBUG) Log.d(TAG, CLASS_NAME + ".surfaceChanged() :: Preview size set at (" + optimal.width + ", " + optimal.height + ")");*/ - camParams.setPreviewSize(mPreviewSize.width, mPreviewSize.height); - mCamera.setParameters(camParams); + camParams.setPreviewSize(previewSize.width, previewSize.height); + camera.setParameters(camParams); android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(0, info); - int rotation = parentActivity.getWindowManager().getDefaultDisplay().getRotation(); + rotation = parentActivity.getWindowManager().getDefaultDisplay().getRotation(); - int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0; break; case Surface.ROTATION_90: degrees = 90; break; @@ -99,21 +98,18 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, case Surface.ROTATION_270: degrees = 270; break; } - int result; if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { result = (info.orientation + degrees) % 360; result = (360 - result) % 360; // compensate the mirror } else { // back-facing result = (info.orientation - degrees + 360) % 360; } - mCamera.setDisplayOrientation(result); - - mCamera.setPreviewCallback(this); + camera.setDisplayOrientation(result); + camera.setPreviewCallback(this); try { - mCamera.setPreviewDisplay(mHolder); - mCamera.startPreview(); - + camera.setPreviewDisplay(this.holder); + camera.startPreview(); }catch (Exception e){ Logger.log_d(TAG, CLASS_NAME + ".surfaceChanged() :: Error starting camera preview: " + e.getMessage()); } @@ -122,13 +118,14 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, @Override public void onPreviewFrame(byte[] data, Camera camera){ Logger.log_d(TAG, CLASS_NAME + ".onPreviewFrame() :: Preview received"); - Logger.log_d(TAG, CLASS_NAME + ".onPreviewFrame() :: Frame has" + (camMonitor.hasChanged() ? "" : " not") + " changed."); - if(!camMonitor.hasChanged()) - camMonitor.setImageData(data); + Logger.log_d(TAG, CLASS_NAME + ".onPreviewFrame() :: Frame has" + (imgMonitor.hasChanged() ? "" : " not") + " changed."); + if(!imgMonitor.hasChanged()) + imgMonitor.setImageData(data); } public void removePreviewCallback(){ - mCamera.setPreviewCallback(null); + if(camera != null) + camera.setPreviewCallback(null); } private Size getOptimalPreviewSize(List sizes, int w, int h) { @@ -174,9 +171,9 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, int previewWidth = width; int previewHeight = height; - if (mPreviewSize != null) { - previewWidth = mPreviewSize.width; - previewHeight = mPreviewSize.height; + if (previewSize != null) { + previewWidth = previewSize.width; + previewHeight = previewSize.height; } // Center the child SurfaceView within the parent. @@ -198,8 +195,8 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, final int height = resolveSize(getSuggestedMinimumHeight(), heightMeasureSpec); setMeasuredDimension(width, height); - if (mSupportedPreviewSizes != null) { - mPreviewSize = getOptimalPreviewSize(mSupportedPreviewSizes, width, height); + if (supportedPreviewSizes != null) { + previewSize = getOptimalPreviewSize(supportedPreviewSizes, width, height); } } } From 5340d3b3830261154d9c81efeff94bca7801dfae Mon Sep 17 00:00:00 2001 From: Miguel Astor Date: Thu, 28 Nov 2013 16:19:37 -0430 Subject: [PATCH 03/16] Testing the camera preview. --- src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java index b257a1d..064eeab 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java @@ -58,7 +58,7 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, if(camera != null) camera.setPreviewDisplay(holder); } catch (IOException e) { - Logger.log_d(TAG, "Error setting camera preview: " + e.getMessage()); + Logger.log_e(TAG, CLASS_NAME + ".surfaceCreated() :: Error setting camera preview: " + e.getMessage()); } } @@ -73,8 +73,11 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, int degrees = 0; Camera.Parameters camParams; - if(this.holder.getSurface() == null || camera == null) + Logger.log_d(TAG, CLASS_NAME + ".surfaceChanged() :: Method started."); + if(this.holder.getSurface() == null || camera == null){ + Logger.log_d(TAG, CLASS_NAME + ".surfaceChanged() :: Holder and/or camera are null."); return; + } try{ camera.stopPreview(); }catch (Exception e){ } @@ -111,7 +114,7 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, camera.setPreviewDisplay(this.holder); camera.startPreview(); }catch (Exception e){ - Logger.log_d(TAG, CLASS_NAME + ".surfaceChanged() :: Error starting camera preview: " + e.getMessage()); + Logger.log_e(TAG, CLASS_NAME + ".surfaceChanged() :: Error starting camera preview: " + e.getMessage()); } } From 10d0f3601338da72466a560e6d33e8c7e631b35a Mon Sep 17 00:00:00 2001 From: Miguel Astor Date: Tue, 3 Dec 2013 15:31:59 -0430 Subject: [PATCH 04/16] Camera preview displays with correct aspect ratio. --- res/layout/activity_cam.xml | 9 ++- src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java | 18 +++-- .../ccg/nxtcam/camera/CameraPreview.java | 68 ++++--------------- 3 files changed, 35 insertions(+), 60 deletions(-) diff --git a/res/layout/activity_cam.xml b/res/layout/activity_cam.xml index 3c9f70f..7aad758 100644 --- a/res/layout/activity_cam.xml +++ b/res/layout/activity_cam.xml @@ -10,4 +10,11 @@ android:paddingTop="@dimen/activity_vertical_margin" tools:context=".CamActivity" > - + + + + \ No newline at end of file diff --git a/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java b/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java index ea18169..3e47c80 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java @@ -13,6 +13,7 @@ import android.support.v4.app.NavUtils; import android.view.Menu; import android.view.MenuItem; import android.view.WindowManager; +import android.widget.FrameLayout; import android.widget.Toast; public class CamActivity extends Activity{ @@ -33,9 +34,7 @@ public class CamActivity extends Activity{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - - cPreview = new CameraPreview(this, hwCamera); - setContentView(cPreview); + setContentView(R.layout.activity_cam); Intent intent = getIntent(); serverIp = intent.getStringExtra("address"); @@ -82,9 +81,11 @@ public class CamActivity extends Activity{ // TODO: pause the imThread and botThread objects. - cPreview.removePreviewCallback(); - cPreview.setCamera(null); - releaseCamera(); + if(cPreview != null){ + cPreview.removePreviewCallback(); + cPreview.setCamera(null); + releaseCamera(); + } } @Override @@ -99,7 +100,11 @@ public class CamActivity extends Activity{ ******************/ public void startCameraPreview(){ if(hwCamera != null){ + Logger.log_d(TAG, CLASS_NAME + ".startCameraPreview() :: Setting camera."); + cPreview = new CameraPreview(this, hwCamera); cPreview.setCamera(hwCamera); + ((FrameLayout)findViewById(R.id.previewLayout)).addView(cPreview); + Logger.log_d(TAG, CLASS_NAME + ".startCameraPreview() :: Camera and content view set."); }else{ Logger.log_wtf(TAG, CLASS_NAME + ".startCameraPreview() :: CAMERA IS NULL!"); System.exit(1); @@ -119,6 +124,7 @@ public class CamActivity extends Activity{ @Override protected Camera doInBackground(Void... params) { Camera cam = null; + Logger.log_d(TAG, CLASS_NAME + ".doInBackground() :: Opening the camera."); try{ cam = Camera.open(0); }catch(Exception e){ diff --git a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java index 064eeab..a97ccd3 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java @@ -13,20 +13,15 @@ import android.os.Build; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; -import android.view.View; -import android.view.ViewGroup; /** A basic Camera preview class */ @SuppressLint("ViewConstructor") -public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, Camera.PreviewCallback { +public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback, Camera.PreviewCallback { private final String TAG = "SURFVIEW"; private final String CLASS_NAME = CameraPreview.class.getSimpleName(); - private Size previewSize; - private List supportedPreviewSizes; private CameraImageMonitor imgMonitor; private Activity parentActivity; - private SurfaceView surfaceView; private SurfaceHolder holder; private Camera camera; @@ -35,8 +30,8 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, super(context); parentActivity = (Activity)context; - surfaceView = new SurfaceView(context); - holder = surfaceView.getHolder(); + // surfaceView = new SurfaceView(context); + holder = getHolder(); holder.addCallback(this); if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) @@ -46,19 +41,21 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, public void setCamera(Camera camera){ this.camera = camera; if(this.camera != null){ + Logger.log_d(TAG, CLASS_NAME + ".setCamera() :: Setting camera."); imgMonitor = CameraImageMonitor.getInstance(); - supportedPreviewSizes = this.camera.getParameters().getSupportedPreviewSizes(); requestLayout(); + Logger.log_d(TAG, CLASS_NAME + ".setCamera() :: Camera set."); } } public void surfaceCreated(SurfaceHolder holder){ // The Surface has been created, now tell the camera where to draw the preview. + Logger.log_d(TAG, CLASS_NAME + ".surfaceCreated() :: Creating surface view."); try { if(camera != null) camera.setPreviewDisplay(holder); } catch (IOException e) { - Logger.log_e(TAG, CLASS_NAME + ".surfaceCreated() :: Error setting camera preview: " + e.getMessage()); + Logger.log_e(TAG, CLASS_NAME + ".surfaceCreated() :: Error creating camera: " + e.getMessage()); } } @@ -84,10 +81,9 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, requestLayout(); camParams = camera.getParameters(); - /*Size optimal = getOptimalPreviewSize(camParams.getSupportedPreviewSizes(), w, h); - if(ProjectConstants.DEBUG) - Log.d(TAG, CLASS_NAME + ".surfaceChanged() :: Preview size set at (" + optimal.width + ", " + optimal.height + ")");*/ - camParams.setPreviewSize(previewSize.width, previewSize.height); + Size optimal = getOptimalPreviewSize(camParams.getSupportedPreviewSizes(), w, h); + Logger.log_d(TAG, CLASS_NAME + ".surfaceChanged() :: Preview size set at (" + optimal.width + ", " + optimal.height + ")"); + camParams.setPreviewSize(optimal.width, optimal.height); camera.setParameters(camParams); android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); @@ -134,6 +130,8 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, private Size getOptimalPreviewSize(List sizes, int w, int h) { final double ASPECT_TOLERANCE = 0.1; double targetRatio = (double) w / h; + + Logger.log_d(TAG, CLASS_NAME + ".getOptimalPreviewSize() :: Method started."); if (sizes == null) return null; Size optimalSize = null; @@ -161,45 +159,9 @@ public class CameraPreview extends ViewGroup implements SurfaceHolder.Callback, } } } + Logger.log_d(TAG, CLASS_NAME + ".getOptimalPreviewSize() :: Method ended."); + Logger.log_d(TAG, CLASS_NAME + ".getOptimalPreviewSize() :: Optimal size is: (" + Integer.toString(optimalSize.width) + + ", " + Integer.toString(optimalSize.height) + ")"); return optimalSize; } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - if (changed && getChildCount() > 0) { - final View child = getChildAt(0); - - final int width = r - l; - final int height = b - t; - - int previewWidth = width; - int previewHeight = height; - if (previewSize != null) { - previewWidth = previewSize.width; - previewHeight = previewSize.height; - } - - // Center the child SurfaceView within the parent. - if (width * previewHeight > height * previewWidth) { - final int scaledChildWidth = previewWidth * height / previewHeight; - child.layout((width - scaledChildWidth) / 2, 0, - (width + scaledChildWidth) / 2, height); - } else { - final int scaledChildHeight = previewHeight * width / previewWidth; - child.layout(0, (height - scaledChildHeight) / 2, - width, (height + scaledChildHeight) / 2); - } - } - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - final int width = resolveSize(getSuggestedMinimumWidth(), widthMeasureSpec); - final int height = resolveSize(getSuggestedMinimumHeight(), heightMeasureSpec); - setMeasuredDimension(width, height); - - if (supportedPreviewSizes != null) { - previewSize = getOptimalPreviewSize(supportedPreviewSizes, width, height); - } - } } From ebbacf4febc04b908ece9b85a48981e3acc6b687 Mon Sep 17 00:00:00 2001 From: Miguel Astor Date: Tue, 3 Dec 2013 16:24:59 -0430 Subject: [PATCH 05/16] Fixed some bugs on the image monitor class. --- .../ccg/nxtcam/camera/CameraImageMonitor.java | 14 ++++++++------ .../ucv/ciens/ccg/nxtcam/camera/CameraPreview.java | 5 ++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java index 51a094a..1d76a52 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java @@ -6,13 +6,15 @@ public class CameraImageMonitor{ private final String TAG = "CAM_MONITOR"; private final String CLASS_NAME = CameraImageMonitor.class.getSimpleName(); + private Object imageMonitor; private byte[] image; private boolean imgProduced; private boolean imgConsumed; private CameraImageMonitor(){ imgProduced = false; - imgConsumed = false; + imgConsumed = true; + imageMonitor = new Object(); } private static class SingletonHolder{ @@ -26,13 +28,13 @@ public class CameraImageMonitor{ public void setImageData(byte[] image){ if(imgConsumed){ Logger.log_d(TAG, CLASS_NAME + ".setImageData() :: Copying new image."); - synchronized(this.image){ + synchronized(this.imageMonitor){ //this.image = new byte[image.length]; //System.arraycopy(image, 0, this.image, 0, image.length); this.image = image; imgProduced = true; imgConsumed = false; - this.image.notifyAll(); + this.imageMonitor.notifyAll(); } Logger.log_d(TAG, CLASS_NAME + ".setImageData() :: Data copy finished."); }else{ @@ -43,10 +45,10 @@ public class CameraImageMonitor{ public byte[] getImageData(){ byte[] returnImg; Logger.log_d(TAG, CLASS_NAME + ".getImageData() :: Entry point."); - synchronized(image){ + synchronized(imageMonitor){ while(!imgProduced){ Logger.log_d(TAG, CLASS_NAME + ".getImageData() :: Waiting for new image."); - try{ image.wait(); }catch(InterruptedException ie){ } + try{ imageMonitor.wait(); }catch(InterruptedException ie){ } } Logger.log_d(TAG, CLASS_NAME + ".getImageData() :: Retrieving new image."); returnImg = image; @@ -58,6 +60,6 @@ public class CameraImageMonitor{ } public synchronized boolean hasChanged(){ - return imgProduced; + return imgConsumed; } } diff --git a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java index a97ccd3..049cd0f 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java @@ -117,9 +117,8 @@ public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback @Override public void onPreviewFrame(byte[] data, Camera camera){ Logger.log_d(TAG, CLASS_NAME + ".onPreviewFrame() :: Preview received"); - Logger.log_d(TAG, CLASS_NAME + ".onPreviewFrame() :: Frame has" + (imgMonitor.hasChanged() ? "" : " not") + " changed."); - if(!imgMonitor.hasChanged()) - imgMonitor.setImageData(data); + Logger.log_d(TAG, CLASS_NAME + ".onPreviewFrame() :: Frame has" + (imgMonitor.hasChanged() ? "" : " not") + " been consumed."); + imgMonitor.setImageData(data); } public void removePreviewCallback(){ From 9c2b67395e0ff9b3c5867cc4c8174575a5b2dbdd Mon Sep 17 00:00:00 2001 From: Miguel Astor Date: Tue, 3 Dec 2013 16:33:50 -0430 Subject: [PATCH 06/16] Removed some useless commented out lines. --- src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java index 1d76a52..eb30ca6 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java @@ -29,8 +29,6 @@ public class CameraImageMonitor{ if(imgConsumed){ Logger.log_d(TAG, CLASS_NAME + ".setImageData() :: Copying new image."); synchronized(this.imageMonitor){ - //this.image = new byte[image.length]; - //System.arraycopy(image, 0, this.image, 0, image.length); this.image = image; imgProduced = true; imgConsumed = false; From a7d0cabba38c7ca5f9f6afa2727abf6d650ab7c8 Mon Sep 17 00:00:00 2001 From: Miguel Astor Date: Fri, 13 Dec 2013 09:19:49 -0430 Subject: [PATCH 07/16] Slapped the Apache License version 2 to the project. --- LICENSE.txt | 202 ++++++++++++++++++ src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java | 15 ++ src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java | 15 ++ .../ccg/nxtcam/camera/CameraImageMonitor.java | 15 ++ .../ccg/nxtcam/camera/CameraPreview.java | 19 ++ .../nxtcam/dialogs/ConnectRobotDialog.java | 15 ++ .../ccg/nxtcam/dialogs/WifiOnDialog.java | 15 ++ .../ccg/nxtcam/network/BTCommunicator.java | 15 ++ .../ccg/nxtcam/network/BluetoothManager.java | 15 ++ .../nxtcam/network/ImageTransferThread.java | 15 ++ .../ciens/ccg/nxtcam/network/LCPThread.java | 15 ++ .../protocols/ImageTransferProtocol.java | 16 +- .../protocols/LegoCommunicationProtocol.java | 15 ++ src/ve/ucv/ciens/ccg/nxtcam/utils/Logger.java | 15 ++ .../ccg/nxtcam/utils/ProjectConstants.java | 15 ++ 15 files changed, 416 insertions(+), 1 deletion(-) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java b/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java index 3e47c80..e22bf01 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/CamActivity.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam; import ve.ucv.ciens.ccg.nxtcam.camera.CameraPreview; diff --git a/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java b/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java index 3d57f54..bda3060 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/MainActivity.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam; import java.io.IOException; diff --git a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java index eb30ca6..84998a8 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraImageMonitor.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam.camera; import ve.ucv.ciens.ccg.nxtcam.utils.Logger; diff --git a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java index 049cd0f..759fcc1 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * The getOptimalPreviewSize() function is copied and slightly modified from + * the Android Open Source Project ApiDemos camera preview code which is + * Copyright (C) 2007 The Android Open Source Project. + */ package ve.ucv.ciens.ccg.nxtcam.camera; import java.io.IOException; diff --git a/src/ve/ucv/ciens/ccg/nxtcam/dialogs/ConnectRobotDialog.java b/src/ve/ucv/ciens/ccg/nxtcam/dialogs/ConnectRobotDialog.java index ef03188..dc8173f 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/dialogs/ConnectRobotDialog.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/dialogs/ConnectRobotDialog.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam.dialogs; import java.util.ArrayList; diff --git a/src/ve/ucv/ciens/ccg/nxtcam/dialogs/WifiOnDialog.java b/src/ve/ucv/ciens/ccg/nxtcam/dialogs/WifiOnDialog.java index af21fad..c74d59a 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/dialogs/WifiOnDialog.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/dialogs/WifiOnDialog.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam.dialogs; import ve.ucv.ciens.ccg.nxtcam.R; diff --git a/src/ve/ucv/ciens/ccg/nxtcam/network/BTCommunicator.java b/src/ve/ucv/ciens/ccg/nxtcam/network/BTCommunicator.java index 1c05b85..6f6eedb 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/network/BTCommunicator.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/network/BTCommunicator.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam.network; import java.io.IOException; diff --git a/src/ve/ucv/ciens/ccg/nxtcam/network/BluetoothManager.java b/src/ve/ucv/ciens/ccg/nxtcam/network/BluetoothManager.java index c50ddcf..b330f8e 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/network/BluetoothManager.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/network/BluetoothManager.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam.network; import java.io.IOException; diff --git a/src/ve/ucv/ciens/ccg/nxtcam/network/ImageTransferThread.java b/src/ve/ucv/ciens/ccg/nxtcam/network/ImageTransferThread.java index ef3173b..58ea2e8 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/network/ImageTransferThread.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/network/ImageTransferThread.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam.network; import java.io.BufferedReader; diff --git a/src/ve/ucv/ciens/ccg/nxtcam/network/LCPThread.java b/src/ve/ucv/ciens/ccg/nxtcam/network/LCPThread.java index ad19a00..335f553 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/network/LCPThread.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/network/LCPThread.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam.network; public class LCPThread extends Thread{ diff --git a/src/ve/ucv/ciens/ccg/nxtcam/network/protocols/ImageTransferProtocol.java b/src/ve/ucv/ciens/ccg/nxtcam/network/protocols/ImageTransferProtocol.java index d3ce9bf..0461bfb 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/network/protocols/ImageTransferProtocol.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/network/protocols/ImageTransferProtocol.java @@ -1,6 +1,20 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam.network.protocols; - public abstract class ImageTransferProtocol{ public static enum ProtocolState{ SALUTE, IMG_FOLLOWS, SEND_DATA, PAUSED, WAITING, GOODBYE diff --git a/src/ve/ucv/ciens/ccg/nxtcam/network/protocols/LegoCommunicationProtocol.java b/src/ve/ucv/ciens/ccg/nxtcam/network/protocols/LegoCommunicationProtocol.java index aa89a57..404c63a 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/network/protocols/LegoCommunicationProtocol.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/network/protocols/LegoCommunicationProtocol.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam.network.protocols; import java.security.InvalidParameterException; diff --git a/src/ve/ucv/ciens/ccg/nxtcam/utils/Logger.java b/src/ve/ucv/ciens/ccg/nxtcam/utils/Logger.java index 26be9c0..7545181 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/utils/Logger.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/utils/Logger.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam.utils; import android.util.Log; diff --git a/src/ve/ucv/ciens/ccg/nxtcam/utils/ProjectConstants.java b/src/ve/ucv/ciens/ccg/nxtcam/utils/ProjectConstants.java index 24ca455..658a20c 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/utils/ProjectConstants.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/utils/ProjectConstants.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2013 Miguel Angel Astor Romero + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ve.ucv.ciens.ccg.nxtcam.utils; import java.util.UUID; From e7b42528b357fa3014c896a94eaad86b235b64d1 Mon Sep 17 00:00:00 2001 From: Miguel Astor Date: Fri, 13 Dec 2013 10:44:13 -0430 Subject: [PATCH 08/16] Fixed the Android Open Source Project copyright notice. --- src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java index 759fcc1..9348f43 100644 --- a/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java +++ b/src/ve/ucv/ciens/ccg/nxtcam/camera/CameraPreview.java @@ -13,9 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. * + * NOTE: * The getOptimalPreviewSize() function is copied and slightly modified from - * the Android Open Source Project ApiDemos camera preview code which is - * Copyright (C) 2007 The Android Open Source Project. + * the Android Open Source Project ApiDemos camera preview code available at + * the following url http://goo.gl/thP1e4 from http://android.googlesource.com . + * The ApiDemos code is Copyright (C) 2007 The Android Open Source Project also + * avilable under the Apache License Version 2.0. */ package ve.ucv.ciens.ccg.nxtcam.camera; From 1b88c67ec1e03a58d0362f467b3952a7b79113a0 Mon Sep 17 00:00:00 2001 From: Miguel Astor Date: Fri, 13 Dec 2013 10:50:21 -0430 Subject: [PATCH 09/16] More licensing crap. --- AndroidManifest.xml | 16 ++++++++++++++++ res/layout/activity_cam.xml | 16 ++++++++++++++++ res/layout/activity_main.xml | 16 ++++++++++++++++ res/menu/cam.xml | 16 ++++++++++++++++ res/menu/main.xml | 16 ++++++++++++++++ res/values-es/strings.xml | 16 ++++++++++++++++ res/values-sw600dp/dimens.xml | 16 ++++++++++++++++ res/values-sw720dp-land/dimens.xml | 16 ++++++++++++++++ res/values-v11/styles.xml | 16 ++++++++++++++++ res/values-v14/styles.xml | 16 ++++++++++++++++ res/values/dimens.xml | 16 ++++++++++++++++ res/values/strings.xml | 16 ++++++++++++++++ res/values/styles.xml | 16 ++++++++++++++++ 13 files changed, 208 insertions(+) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 1ed4e8a..cb91dd7 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,4 +1,20 @@ + + + + + + + + NxtCAM diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml index 44f01db..1dd7e41 100644 --- a/res/values-sw600dp/dimens.xml +++ b/res/values-sw600dp/dimens.xml @@ -1,3 +1,19 @@ + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 4e72cee..c789648 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,4 +1,20 @@ + + NxtCAM diff --git a/res/values/styles.xml b/res/values/styles.xml index 6ce89c7..eea644b 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -1,3 +1,19 @@ + +