diff --git a/AffdexMe/app/src/main/AndroidManifest.xml b/AffdexMe/app/src/main/AndroidManifest.xml index fc7cb0e..5d6165a 100644 --- a/AffdexMe/app/src/main/AndroidManifest.xml +++ b/AffdexMe/app/src/main/AndroidManifest.xml @@ -14,7 +14,6 @@ - - - - - - - diff --git a/AffdexMe/app/src/main/java/com/affectiva/affdexme/DrawingView.java b/AffdexMe/app/src/main/java/com/affectiva/affdexme/DrawingView.java index 7ac5175..1fc8f50 100644 --- a/AffdexMe/app/src/main/java/com/affectiva/affdexme/DrawingView.java +++ b/AffdexMe/app/src/main/java/com/affectiva/affdexme/DrawingView.java @@ -25,17 +25,13 @@ import com.affectiva.android.affdex.sdk.detector.Face; */ public class DrawingView extends SurfaceView implements SurfaceHolder.Callback { - class PointFArraySharer { - PointF[] nextPointsToDraw = null; - } - //Inner Thread class class DrawingThread extends Thread{ private SurfaceHolder mSurfaceHolder; private Paint circlePaint; private Paint boxPaint; - private volatile boolean stopFlag = false; //boolean to indicate when thread has been told to stop - private final PointFArraySharer sharer; + private boolean stopFlag = false; //boolean to indicate when thread has been told to stop + private PointF[] nextPointsToDraw = null; //holds a reference to the most recent set of points returned by CameraDetector, passed in by main thread private DrawingViewConfig config; private final long drawPeriod = 33; //draw at 30 fps @@ -56,7 +52,6 @@ public class DrawingView extends SurfaceView implements SurfaceHolder.Callback { boxPaint.setStyle(Paint.Style.STROKE); config = con; - sharer = new PointFArraySharer(); setThickness(config.drawThickness); } @@ -89,9 +84,7 @@ public class DrawingView extends SurfaceView implements SurfaceHolder.Callback { //Updates thread with latest points returned by the onImageResults() event. public void updatePoints(PointF[] pointList) { - synchronized (sharer) { - sharer.nextPointsToDraw = pointList; - } + nextPointsToDraw = pointList; } void setThickness(int thickness) { @@ -100,9 +93,7 @@ public class DrawingView extends SurfaceView implements SurfaceHolder.Callback { //Inform thread face detection has stopped, so array of points is no longer valid. public void invalidatePoints() { - synchronized (sharer) { - sharer.nextPointsToDraw = null; - } + nextPointsToDraw = null; } @Override @@ -110,6 +101,7 @@ public class DrawingView extends SurfaceView implements SurfaceHolder.Callback { android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); while(!stopFlag) { + long startTime = SystemClock.elapsedRealtime(); //get time at the start of thread loop /** * We use SurfaceHolder.lockCanvas() to get the canvas that draws to the SurfaceView. @@ -122,7 +114,9 @@ public class DrawingView extends SurfaceView implements SurfaceHolder.Callback { if (c!= null) { synchronized (mSurfaceHolder) { c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); //clear previous dots - draw(c); + if ((nextPointsToDraw != null) ) { + draw(c); + } } } } @@ -132,18 +126,23 @@ public class DrawingView extends SurfaceView implements SurfaceHolder.Callback { } } + //send thread to sleep so we don't draw faster than the requested 'drawPeriod'. + long sleepTime = drawPeriod - (SystemClock.elapsedRealtime() - startTime); + try { + if(sleepTime>0){ + this.sleep(sleepTime); + } + } catch (InterruptedException ex) { + Log.e(LOG_TAG,ex.getMessage()); + } } config = null; //nullify object to avoid memory leak } void draw(Canvas c) { - PointF[] points; - synchronized (sharer) { - if (sharer.nextPointsToDraw == null) - return; - points = sharer.nextPointsToDraw; - } + //Save our own reference to the list of points, in case the previous reference is overwritten by the main thread. + PointF[] points = nextPointsToDraw; //Coordinates around which to draw bounding box. float leftBx = config.surfaceViewWidth; @@ -219,9 +218,10 @@ public class DrawingView extends SurfaceView implements SurfaceHolder.Callback { private int surfaceViewHeight = 0; private float screenToImageRatio = 0; private int drawThickness = 0; + private boolean isImageDimensionsNeeded = true; + private boolean isSurfaceViewDimensionsNeeded = true; private boolean isDrawPointsEnabled = true; //by default, have the drawing thread draw tracking dots private boolean isDrawMeasurementsEnabled = false; - private boolean isDimensionsNeeded = true; private Paint textPaint; private int textSize; @@ -235,16 +235,32 @@ public class DrawingView extends SurfaceView implements SurfaceHolder.Callback { this.upperTextSpacing = upperTextSpacing; } - public void updateViewDimensions(int surfaceViewWidth, int surfaceViewHeight, int imageWidth, int imageHeight) { - if (surfaceViewWidth <= 0 || surfaceViewHeight <= 0 || imageWidth <= 0 || imageHeight <= 0) { - throw new IllegalArgumentException("All dimensions submitted to updateViewDimensions() must be positive"); + public void updateImageDimensions(int w, int h) { + + if ( (w <= 0) || (h <= 0)) { + throw new IllegalArgumentException("Image Dimensions must be positive."); } - this.imageWidth = imageWidth; - this.imageHeight = imageHeight; - this.surfaceViewWidth = surfaceViewWidth; - this.surfaceViewHeight = surfaceViewHeight; - screenToImageRatio = (float)surfaceViewWidth / imageWidth; - isDimensionsNeeded = false; + + imageWidth = w; + imageHeight = h; + if (!isSurfaceViewDimensionsNeeded) { + screenToImageRatio = (float)surfaceViewWidth / (float)imageWidth; + } + isImageDimensionsNeeded = false; + } + + public void updateSurfaceViewDimensions(int w, int h) { + + if ( (w <= 0) || (h <= 0)) { + throw new IllegalArgumentException("SurfaceView Dimensions must be positive."); + } + + surfaceViewWidth = w; + surfaceViewHeight = h; + if (!isImageDimensionsNeeded) { + screenToImageRatio = (float)surfaceViewWidth / (float)imageWidth; + } + isSurfaceViewDimensionsNeeded = false; } public void setDrawThickness(int t) { @@ -349,17 +365,29 @@ public class DrawingView extends SurfaceView implements SurfaceHolder.Callback { } } - public boolean isDimensionsNeeded() { - return drawingViewConfig.isDimensionsNeeded; + public boolean isImageDimensionsNeeded() { + return drawingViewConfig.isImageDimensionsNeeded; } - public void invalidateDimensions() { - drawingViewConfig.isDimensionsNeeded = true; + public boolean isSurfaceDimensionsNeeded() { + return drawingViewConfig.isSurfaceViewDimensionsNeeded; } - public void updateViewDimensions(int surfaceViewWidth, int surfaceViewHeight, int imageWidth, int imageHeight) { + public void invalidateImageDimensions() { + drawingViewConfig.isImageDimensionsNeeded = true; + } + + public void updateImageDimensions(int w, int h) { try { - drawingViewConfig.updateViewDimensions(surfaceViewWidth,surfaceViewHeight,imageWidth,imageHeight); + drawingViewConfig.updateImageDimensions(w, h); + } catch (Exception e) { + Log.e(LOG_TAG,e.getMessage()); + } + } + + public void updateSurfaceViewDimensions(int w, int h) { + try { + drawingViewConfig.updateSurfaceViewDimensions(w, h); } catch (Exception e) { Log.e(LOG_TAG,e.getMessage()); } diff --git a/AffdexMe/app/src/main/java/com/affectiva/affdexme/MainActivity.java b/AffdexMe/app/src/main/java/com/affectiva/affdexme/MainActivity.java index 7178f62..7449d88 100644 --- a/AffdexMe/app/src/main/java/com/affectiva/affdexme/MainActivity.java +++ b/AffdexMe/app/src/main/java/com/affectiva/affdexme/MainActivity.java @@ -67,15 +67,13 @@ import com.affectiva.android.affdex.sdk.detector.Face; */ public class MainActivity extends Activity - implements Detector.FaceListener, Detector.ImageListener, View.OnTouchListener, CameraDetector.OnCameraEventListener { + implements Detector.FaceListener, Detector.ImageListener, View.OnTouchListener, CameraDetector.CameraSurfaceViewListener { private static final String LOG_TAG = "Affectiva"; public static final int NUM_METRICS_DISPLAYED = 6; //Affectiva SDK Object private CameraDetector detector = null; - //TODO: License file in byte form. Should NOT be included in released sample code. - private byte[] licenseBytes = {123,34,116,111,107,101,110,34,58,32,34,102,98,51,51,101,102,57,98,102,98,49,57,53,100,97,99,55,97,53,99,48,98,50,56,54,54,51,51,48,56,52,100,102,56,48,57,55,52,101,99,99,57,98,51,54,97,97,101,51,57,99,97,51,98,97,53,54,57,50,49,102,56,49,53,34,44,34,108,105,99,101,110,115,111,114,34,58,32,34,65,102,102,101,99,116,105,118,97,32,73,110,99,46,34,44,34,101,120,112,105,114,101,115,34,58,32,34,50,48,57,57,45,48,49,45,48,49,34,44,34,100,101,118,101,108,111,112,101,114,73,100,34,58,32,34,65,102,102,101,99,116,105,118,97,45,105,110,116,101,114,110,97,108,34,44,34,115,111,102,116,119,97,114,101,34,58,32,34,65,102,102,100,101,120,32,83,68,75,34,125}; //MetricsManager View UI Objects private RelativeLayout metricViewLayout; @@ -95,7 +93,6 @@ public class MainActivity extends Activity private SurfaceView cameraView; //SurfaceView used to display camera images private DrawingView drawingView; //SurfaceView containing its own thread, used to draw facial tracking dots private ImageButton settingsButton; - private ImageButton cameraButton; //Application settings variables private int detectorProcessRate; @@ -108,12 +105,7 @@ public class MainActivity extends Activity private float numberOfFrames = 0; private long timeToUpdate = 0; - //Camera-related variables private boolean isFrontFacingCameraDetected = true; - private boolean isBackFacingCameraDetected = true; - int cameraPreviewWidth = 0; - int cameraPreviewHeight = 0; - CameraDetector.CameraType cameraType; @Override protected void onCreate(Bundle savedInstanceState) { @@ -123,33 +115,20 @@ public class MainActivity extends Activity initializeUI(); - determineCameraAvailability(); - - initializeCameraDetector(); - } - - /** - * We check to make sure the device has a front-facing camera. - * If it does not, we obscure the app with a notice informing the user they cannot - * use the app. - */ - void determineCameraAvailability() { - PackageManager manager = getPackageManager(); - isFrontFacingCameraDetected = manager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT); - isBackFacingCameraDetected = manager.hasSystemFeature(PackageManager.FEATURE_CAMERA); - - if (!isFrontFacingCameraDetected && !isBackFacingCameraDetected) { + /** + * We check to make sure the device has a front-facing camera. + * If it does not, we obscure the app with a notice informing the user they cannot + * use the app. + */ + if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) { + isFrontFacingCameraDetected = false; progressBar.setVisibility(View.INVISIBLE); pleaseWaitTextView.setVisibility(View.INVISIBLE); TextView notFoundTextView = (TextView) findViewById(R.id.not_found_textview); notFoundTextView.setVisibility(View.VISIBLE); } - //TODO: change this to be taken from settings - if (isBackFacingCameraDetected) - cameraType = CameraDetector.CameraType.CAMERA_BACK; - if (isFrontFacingCameraDetected) - cameraType = CameraDetector.CameraType.CAMERA_FRONT; + initializeCameraDetector(); } void initializeUI() { @@ -166,7 +145,6 @@ public class MainActivity extends Activity cameraView = (SurfaceView) findViewById(R.id.camera_preview); drawingView = (DrawingView) findViewById(R.id.drawing_view); settingsButton = (ImageButton) findViewById(R.id.settings_button); - cameraButton = (ImageButton) findViewById(R.id.camera_button); progressBar = (ProgressBar) findViewById(R.id.progress_bar); pleaseWaitTextView = (TextView) findViewById(R.id.please_wait_textview); @@ -238,14 +216,12 @@ public class MainActivity extends Activity * the camera. If a SurfaceView is passed in as the last argument to the constructor, * that view will be painted with what the camera sees. */ - detector = new CameraDetector(this, cameraType, cameraView); - //TODO: this method SHOULD NOT be included in sample code release (customer should enter their own license file). - detector.setLicenseStream(new BufferedReader(new InputStreamReader(new ByteArrayInputStream(licenseBytes)))); + detector = new CameraDetector(this, CameraDetector.CameraType.CAMERA_FRONT, cameraView); // NOTE: uncomment the line below and replace "YourLicenseFile" with your license file, which should be stored in /assets/Affdex/ //detector.setLicensePath("YourLicenseFile"); detector.setImageListener(this); detector.setFaceListener(this); - detector.setOnCameraEventListener(this); + detector.setCameraDetectorDimensionsListener(this); } /* @@ -353,10 +329,8 @@ public class MainActivity extends Activity } void mainWindowResumedTasks() { - - startDetector(); - - if (!drawingView.isDimensionsNeeded()) { + startCamera(); + if (!drawingView.isSurfaceDimensionsNeeded()) { progressBarLayout.setVisibility(View.GONE); } resetFPSCalculations(); @@ -367,14 +341,14 @@ public class MainActivity extends Activity setMenuVisible(false); } } - }, 5000); + },5000); } - void startDetector() { - if (!isBackFacingCameraDetected && !isFrontFacingCameraDetected) - return; //without any cameras detected, we cannot proceed + void startCamera() { + + //this app will always detect valence (it will also always detect measurements, but measurement don't need to be enabled) + detector.setDetectValence(true); - detector.setDetectValence(true); //this app will always detect valence if (!detector.isRunning()) { try { detector.start(); @@ -382,10 +356,9 @@ public class MainActivity extends Activity Log.e(LOG_TAG, e.getMessage()); } } + } - - @Override public void onFaceDetectionStarted() { leftMetricsLayout.animate().alpha(1); //make left and right metrics appear @@ -402,7 +375,8 @@ public class MainActivity extends Activity void performFaceDetectionStoppedTasks() { leftMetricsLayout.animate().alpha(0); //make left and right metrics disappear rightMetricsLayout.animate().alpha(0); - drawingView.updatePoints(null); + + drawingView.invalidatePoints(); //inform the drawing thread that the latest facial tracking points are now invalid resetFPSCalculations(); //Since the FPS may be different whether a face is being tracked or not, reset variables. } @@ -411,6 +385,14 @@ public class MainActivity extends Activity */ @Override public void onImageResults(List faces, Frame image, float timeStamp) { + /** + * If the flag indicating that we still need to know the size of the camera frames, call calculateImageDimensions(). + * The flag is a boolean stored in our drawingView object, retrieved through DrawingView.isImageDimensionsNeeded(). + */ + if (drawingView.isImageDimensionsNeeded() ) { + calculateImageDimensions(image); + } + //If the faces object is null, we received an unprocessed frame if (faces == null) { return; @@ -421,7 +403,6 @@ public class MainActivity extends Activity //If faces.size() is 0, we received a frame in which no face was detected if (faces.size() == 0) { - drawingView.updatePoints(null); //the drawingView takes null points to mean it doesn't have to draw anything return; } @@ -467,6 +448,54 @@ public class MainActivity extends Activity metricDisplay.setScore(score); } + /** + * In this method, we inform our drawingView of the size of the incoming camera images. + * We also set the thickness (which controls the size of the dots and bounding box) based on a reference thickness, which + * should be the same whether the device is landscape or portrait. + */ + void calculateImageDimensions(Frame image){ + ///referenceDimension will be used to determine the size of the facial tracking dots + float referenceDimension = activityLayout.getHeight(); + + //get size of frames being passed by camera + int imageWidth = image.getWidth(); + int imageHeight = image.getHeight(); + + /** + * If device is rotated vertically, reverse the width and height returned by the Frame object, + * and switch the dimension we consider to be the reference dimension. + */ + if ((ROTATE.BY_90_CW == image.getTargetRotation()) || (ROTATE.BY_90_CCW == image.getTargetRotation())) { + int temp = imageWidth; + imageWidth = imageHeight; + imageHeight = temp; + + referenceDimension = activityLayout.getWidth(); + } + + drawingView.updateImageDimensions(imageWidth, imageHeight); + drawingView.setThickness((int) (referenceDimension / 160f)); + } + + + /** + * This method is called when the SDK has corrected the aspect ratio of the SurfaceView. We use this information to resize + * our mainLayout ViewGroup so the UI fits snugly around the SurfaceView. We also update our drawingView object, so the tracking dots + * are drawn in the correct coordinates. + */ + @Override + public void onSurfaceViewAspectRatioChanged(int width, int height) { + drawingView.updateSurfaceViewDimensions(width,height); + + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mainLayout.getLayoutParams(); + params.height = height; + params.width = width; + mainLayout.setLayoutParams(params); + + //Now that our main layout has been resized, we can remove the progress bar that was obscuring the screen (its purpose was to obscure the resizing of the SurfaceView) + progressBarLayout.setVisibility(View.GONE); + } + /** * FPS measurement simply uses SystemClock to measure how many frames were processed since * the FPS variables were last reset. @@ -493,25 +522,21 @@ public class MainActivity extends Activity public void onPause() { super.onPause(); progressBarLayout.setVisibility(View.VISIBLE); - - performFaceDetectionStoppedTasks(); - - stopDetector(); + stopCamera(); } - void stopDetector() { - if (detector.isRunning()) { - try { - detector.stop(); - } catch (Exception e) { - Log.e(LOG_TAG,e.getMessage()); - } - } + private void stopCamera() { + performFaceDetectionStoppedTasks(); detector.setDetectAllEmotions(false); detector.setDetectAllExpressions(false); - } + try { + detector.stop(); + } catch (Exception e) { + Log.e(LOG_TAG, e.getMessage()); + } + } /** @@ -522,7 +547,6 @@ public class MainActivity extends Activity isMenuVisible = b; if (b) { settingsButton.setVisibility(View.VISIBLE); - cameraButton.setVisibility(View.VISIBLE); //We display the navigation bar again getWindow().getDecorView().setSystemUiVisibility( @@ -543,7 +567,6 @@ public class MainActivity extends Activity settingsButton.setVisibility(View.INVISIBLE); - cameraButton.setVisibility(View.INVISIBLE); } } @@ -591,86 +614,6 @@ public class MainActivity extends Activity public void settings_button_click(View view) { startActivity(new Intent(this,SettingsActivity.class)); } - - @Override - public void onCameraStarted(boolean b, Throwable throwable) { - if (throwable != null) { - Toast.makeText(this,"Failed to start camera.",Toast.LENGTH_LONG).show(); - } - } - - @Override - public void onCameraSizeSelected(int cameraWidth, int cameraHeight, ROTATE rotation) { - if (rotation == ROTATE.BY_90_CCW || rotation == ROTATE.BY_90_CW) { - cameraPreviewWidth = cameraHeight; - cameraPreviewHeight = cameraWidth; - } else { - cameraPreviewWidth = cameraWidth; - cameraPreviewHeight = cameraHeight; - } - drawingView.setThickness((int)(cameraWidth/100f)); - - mainLayout.post(new Runnable() { - @Override - public void run() { - int layoutWidth = mainLayout.getWidth(); - int layoutHeight = mainLayout.getHeight(); - - if (cameraPreviewWidth == 0 || cameraPreviewHeight == 0 || layoutWidth == 0 || layoutHeight == 0) - return; - - float layoutAspectRatio = (float)layoutWidth/layoutHeight; - float cameraPreviewAspectRatio = (float)cameraPreviewWidth/cameraPreviewHeight; - - int newWidth; - int newHeight; - - if (cameraPreviewAspectRatio > layoutAspectRatio) { - newWidth = layoutWidth; - newHeight =(int) (layoutWidth / cameraPreviewAspectRatio); - } else { - newWidth = (int) (layoutHeight * cameraPreviewAspectRatio); - newHeight = layoutHeight; - } - - drawingView.updateViewDimensions(newWidth,newHeight,cameraPreviewWidth,cameraPreviewHeight); - - ViewGroup.LayoutParams params = mainLayout.getLayoutParams(); - params.height = newHeight; - params.width = newWidth; - mainLayout.setLayoutParams(params); - - //Now that our main layout has been resized, we can remove the progress bar that was obscuring the screen (its purpose was to obscure the resizing of the SurfaceView) - progressBarLayout.setVisibility(View.GONE); - } - }); - - } - - - public void camera_button_click(View view) { - if (cameraType == CameraDetector.CameraType.CAMERA_FRONT) { - if (isBackFacingCameraDetected) { - cameraType = CameraDetector.CameraType.CAMERA_BACK; - } else { - Toast.makeText(this,"No back-facing camera found",Toast.LENGTH_LONG).show(); - } - } else if (cameraType == CameraDetector.CameraType.CAMERA_BACK) { - if (isFrontFacingCameraDetected) { - cameraType = CameraDetector.CameraType.CAMERA_FRONT; - } else { - Toast.makeText(this,"No front-facing camera found",Toast.LENGTH_LONG).show(); - } - } - - performFaceDetectionStoppedTasks(); - - try { - detector.setCameraType(cameraType); - } catch (Exception e) { - Log.e(LOG_TAG,e.getMessage()); - } - } } diff --git a/AffdexMe/app/src/main/java/com/affectiva/errorreporting/CustomApplication.java b/AffdexMe/app/src/main/java/com/affectiva/errorreporting/CustomApplication.java deleted file mode 100644 index d1ae05d..0000000 --- a/AffdexMe/app/src/main/java/com/affectiva/errorreporting/CustomApplication.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.affectiva.errorreporting; - -import android.app.Application; -import android.content.Intent; - -/** - * Created by Alan on 8/21/2015. - */ -public class CustomApplication extends Application { - - static volatile boolean wasErrorActivityStarted = false; - static final boolean enableCustomErrorMessage = false; - Thread.UncaughtExceptionHandler exceptionHandler; - - @Override - public void onCreate () - { - super.onCreate(); - exceptionHandler = Thread.getDefaultUncaughtExceptionHandler(); - // Setup handler for uncaught exceptions. - Thread.setDefaultUncaughtExceptionHandler (new Thread.UncaughtExceptionHandler() - { - @Override - public void uncaughtException (Thread thread, Throwable e) - { - handleUncaughtException (thread, e); - } - }); - } - - public void handleUncaughtException (Thread thread, Throwable e) - { - if (!wasErrorActivityStarted && enableCustomErrorMessage) { - Intent intent = new Intent(); - intent.setAction("com.affectiva.REPORT_ERROR"); // see step 5. - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // required when starting from Application - intent.putExtra("affdexme_error", e); - startActivity(intent); - wasErrorActivityStarted = true; - } - - exceptionHandler.uncaughtException(thread,e); - } -} diff --git a/AffdexMe/app/src/main/java/com/affectiva/errorreporting/ErrorReporter.java b/AffdexMe/app/src/main/java/com/affectiva/errorreporting/ErrorReporter.java deleted file mode 100644 index 87e39ec..0000000 --- a/AffdexMe/app/src/main/java/com/affectiva/errorreporting/ErrorReporter.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.affectiva.errorreporting; - -import android.app.Activity; -import android.content.DialogInterface; -import android.content.Intent; -import android.os.Bundle; -import android.view.View; -import android.view.Window; -import android.widget.Button; - -import com.affectiva.affdexme.R; - -import java.text.DateFormat; -import java.util.Date; - -/** - * Created by Alan on 8/21/2015. - */ -public class ErrorReporter extends Activity implements View.OnClickListener { - - String errorMessage; - Button sendButton; - - - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - requestWindowFeature(Window.FEATURE_NO_TITLE); // make a dialog without a titlebar - setContentView(R.layout.error_reporter); - - Throwable error = (Throwable) getIntent().getSerializableExtra("affdexme_error"); - if (error != null) { - - StringBuilder builder = new StringBuilder(); - builder.append("AffdexMe Error Report:"); - builder.append(DateFormat.getDateTimeInstance().format(new Date())); - builder.append("\n"); - builder.append(error.getMessage()); - builder.append(("\n")); - - StackTraceElement[] stackTraceElements = error.getStackTrace(); - for (StackTraceElement element : stackTraceElements) { - builder.append("\n"); - builder.append(element.toString()); - } - errorMessage = builder.toString(); - } else { - errorMessage = "Failed to catch error."; - } - - sendButton = (Button) findViewById(R.id.send_button); - sendButton.setOnClickListener(this); - } - - @Override - public void onClick(View v) { - Intent intent = new Intent (Intent.ACTION_SEND); - intent.setType("plain/text"); - intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"sdk@affectiva.com"}); - intent.putExtra(Intent.EXTRA_SUBJECT, "AffdexMe Crash Report"); - intent.putExtra(Intent.EXTRA_TEXT, errorMessage); // do this so some email clients don't complain about empty body. - startActivity(intent); - finish(); - } -} diff --git a/AffdexMe/app/src/main/res/drawable-hdpi/ic_more_vert_black_48dp.png b/AffdexMe/app/src/main/res/drawable-hdpi/ic_more_vert_black_48dp.png deleted file mode 100644 index 94d5ab9..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-hdpi/ic_more_vert_black_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-hdpi/ic_more_vert_white_48dp.png b/AffdexMe/app/src/main/res/drawable-hdpi/ic_more_vert_white_48dp.png deleted file mode 100644 index d322813..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-hdpi/ic_more_vert_white_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-hdpi/ic_switch_camera_black_48dp.png b/AffdexMe/app/src/main/res/drawable-hdpi/ic_switch_camera_black_48dp.png deleted file mode 100644 index 1f6be43..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-hdpi/ic_switch_camera_black_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-hdpi/ic_switch_camera_white_48dp.png b/AffdexMe/app/src/main/res/drawable-hdpi/ic_switch_camera_white_48dp.png deleted file mode 100644 index bee95a1..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-hdpi/ic_switch_camera_white_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-hdpi/settings_button_pressed_1.png b/AffdexMe/app/src/main/res/drawable-hdpi/settings_button_pressed.png similarity index 100% rename from AffdexMe/app/src/main/res/drawable-hdpi/settings_button_pressed_1.png rename to AffdexMe/app/src/main/res/drawable-hdpi/settings_button_pressed.png diff --git a/AffdexMe/app/src/main/res/drawable-mdpi/ic_more_vert_black_48dp.png b/AffdexMe/app/src/main/res/drawable-mdpi/ic_more_vert_black_48dp.png deleted file mode 100644 index 9f10aa2..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-mdpi/ic_more_vert_black_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-mdpi/ic_more_vert_white_48dp.png b/AffdexMe/app/src/main/res/drawable-mdpi/ic_more_vert_white_48dp.png deleted file mode 100644 index efab8a7..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-mdpi/ic_more_vert_white_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-mdpi/ic_switch_camera_black_48dp.png b/AffdexMe/app/src/main/res/drawable-mdpi/ic_switch_camera_black_48dp.png deleted file mode 100644 index 3dfc224..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-mdpi/ic_switch_camera_black_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-mdpi/ic_switch_camera_white_48dp.png b/AffdexMe/app/src/main/res/drawable-mdpi/ic_switch_camera_white_48dp.png deleted file mode 100644 index 9a5c966..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-mdpi/ic_switch_camera_white_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-mdpi/settings_button_pressed_1.png b/AffdexMe/app/src/main/res/drawable-mdpi/settings_button_pressed.png similarity index 100% rename from AffdexMe/app/src/main/res/drawable-mdpi/settings_button_pressed_1.png rename to AffdexMe/app/src/main/res/drawable-mdpi/settings_button_pressed.png diff --git a/AffdexMe/app/src/main/res/drawable-nodpi/disgust.jpg b/AffdexMe/app/src/main/res/drawable-nodpi/disgust.jpg index 4a6d097..3604459 100644 Binary files a/AffdexMe/app/src/main/res/drawable-nodpi/disgust.jpg and b/AffdexMe/app/src/main/res/drawable-nodpi/disgust.jpg differ diff --git a/AffdexMe/app/src/main/res/drawable-xhdpi/ic_more_vert_black_48dp.png b/AffdexMe/app/src/main/res/drawable-xhdpi/ic_more_vert_black_48dp.png deleted file mode 100644 index 4642a3b..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-xhdpi/ic_more_vert_black_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-xhdpi/ic_more_vert_white_48dp.png b/AffdexMe/app/src/main/res/drawable-xhdpi/ic_more_vert_white_48dp.png deleted file mode 100644 index 2f2cb3d..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-xhdpi/ic_more_vert_white_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-xhdpi/ic_switch_camera_black_48dp.png b/AffdexMe/app/src/main/res/drawable-xhdpi/ic_switch_camera_black_48dp.png deleted file mode 100644 index e88bbea..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-xhdpi/ic_switch_camera_black_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-xhdpi/ic_switch_camera_white_48dp.png b/AffdexMe/app/src/main/res/drawable-xhdpi/ic_switch_camera_white_48dp.png deleted file mode 100644 index 1b679f1..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-xhdpi/ic_switch_camera_white_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-xhdpi/settings_button_pressed_1.png b/AffdexMe/app/src/main/res/drawable-xhdpi/settings_button_pressed.png similarity index 100% rename from AffdexMe/app/src/main/res/drawable-xhdpi/settings_button_pressed_1.png rename to AffdexMe/app/src/main/res/drawable-xhdpi/settings_button_pressed.png diff --git a/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_more_vert_black_48dp.png b/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_more_vert_black_48dp.png deleted file mode 100644 index cf0f8f3..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_more_vert_black_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_48dp.png b/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_48dp.png deleted file mode 100644 index b37b96f..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_switch_camera_black_48dp.png b/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_switch_camera_black_48dp.png deleted file mode 100644 index 016ba6d..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_switch_camera_black_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_switch_camera_white_48dp.png b/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_switch_camera_white_48dp.png deleted file mode 100644 index 8cbb600..0000000 Binary files a/AffdexMe/app/src/main/res/drawable-xxhdpi/ic_switch_camera_white_48dp.png and /dev/null differ diff --git a/AffdexMe/app/src/main/res/drawable-xxhdpi/settings_button_pressed_1.png b/AffdexMe/app/src/main/res/drawable-xxhdpi/settings_button_pressed.png similarity index 100% rename from AffdexMe/app/src/main/res/drawable-xxhdpi/settings_button_pressed_1.png rename to AffdexMe/app/src/main/res/drawable-xxhdpi/settings_button_pressed.png diff --git a/AffdexMe/app/src/main/res/drawable/camera_button_not_pressed.xml b/AffdexMe/app/src/main/res/drawable/camera_button_not_pressed.xml deleted file mode 100644 index ad2ebaa..0000000 --- a/AffdexMe/app/src/main/res/drawable/camera_button_not_pressed.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/AffdexMe/app/src/main/res/drawable/camera_button_pressed.xml b/AffdexMe/app/src/main/res/drawable/camera_button_pressed.xml deleted file mode 100644 index 883b6aa..0000000 --- a/AffdexMe/app/src/main/res/drawable/camera_button_pressed.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/AffdexMe/app/src/main/res/drawable/camera_button_selector.xml b/AffdexMe/app/src/main/res/drawable/camera_button_selector.xml deleted file mode 100644 index 669fc9e..0000000 --- a/AffdexMe/app/src/main/res/drawable/camera_button_selector.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/AffdexMe/app/src/main/res/drawable/settings_button_not_pressed.xml b/AffdexMe/app/src/main/res/drawable/settings_button_not_pressed.xml deleted file mode 100644 index 739dcec..0000000 --- a/AffdexMe/app/src/main/res/drawable/settings_button_not_pressed.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/AffdexMe/app/src/main/res/drawable/settings_button_pressed_1.png b/AffdexMe/app/src/main/res/drawable/settings_button_pressed.png similarity index 100% rename from AffdexMe/app/src/main/res/drawable/settings_button_pressed_1.png rename to AffdexMe/app/src/main/res/drawable/settings_button_pressed.png diff --git a/AffdexMe/app/src/main/res/drawable/settings_button_pressed.xml b/AffdexMe/app/src/main/res/drawable/settings_button_pressed.xml deleted file mode 100644 index a1922a5..0000000 --- a/AffdexMe/app/src/main/res/drawable/settings_button_pressed.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/AffdexMe/app/src/main/res/drawable/settings_button_selector.xml b/AffdexMe/app/src/main/res/drawable/settings_button_selector.xml index f30d2af..f6f77f6 100644 --- a/AffdexMe/app/src/main/res/drawable/settings_button_selector.xml +++ b/AffdexMe/app/src/main/res/drawable/settings_button_selector.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/AffdexMe/app/src/main/res/drawable/transluscent_circle.xml b/AffdexMe/app/src/main/res/drawable/transluscent_circle.xml deleted file mode 100644 index 11a1121..0000000 --- a/AffdexMe/app/src/main/res/drawable/transluscent_circle.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/AffdexMe/app/src/main/res/layout/activity_main.xml b/AffdexMe/app/src/main/res/layout/activity_main.xml index 8378a3a..45b3524 100644 --- a/AffdexMe/app/src/main/res/layout/activity_main.xml +++ b/AffdexMe/app/src/main/res/layout/activity_main.xml @@ -1,9 +1,7 @@ - - - - + + + + + - -