diff --git a/WeKnowHowYouFeel.iml b/WeKnowHowYouFeel.iml
new file mode 100644
index 0000000..7091012
--- /dev/null
+++ b/WeKnowHowYouFeel.iml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bb64ece..d44ed02 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -14,6 +14,10 @@
+
+
+
+
@@ -38,6 +42,9 @@
android:theme="@style/MainActivityTheme">
+
+
+
diff --git a/app/src/main/java/com/affectiva/affdexme/DrawingView.java b/app/src/main/java/com/affectiva/affdexme/DrawingView.java
index 6049741..94a3483 100644
--- a/app/src/main/java/com/affectiva/affdexme/DrawingView.java
+++ b/app/src/main/java/com/affectiva/affdexme/DrawingView.java
@@ -497,9 +497,9 @@ public class DrawingView extends SurfaceView implements SurfaceHolder.Callback {
}
//Draw the bounding box.
- if (config.isDrawPointsEnabled) {
- drawBoundingBox(c, face, boundingRect);
- }
+// if (config.isDrawPointsEnabled) {
+// drawBoundingBox(c, face, boundingRect);
+// }
float heightOffset = findNecessaryHeightOffset(boundingRect, face);
diff --git a/app/src/main/java/com/affectiva/affdexme/MainActivity.java b/app/src/main/java/com/affectiva/affdexme/MainActivity.java
index 8cacdfd..d952ff2 100644
--- a/app/src/main/java/com/affectiva/affdexme/MainActivity.java
+++ b/app/src/main/java/com/affectiva/affdexme/MainActivity.java
@@ -6,6 +6,7 @@
package com.affectiva.affdexme;
import android.Manifest;
+import android.app.ActivityManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -16,6 +17,7 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
+import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Environment;
import android.os.SystemClock;
@@ -92,7 +94,7 @@ public class MainActivity extends AppCompatActivity
public static final int MAX_SUPPORTED_FACES = 3;
public static final boolean STORE_RAW_SCREENSHOTS = false; // setting to enable saving the raw images when taking screenshots
- public static final int NUM_METRICS_DISPLAYED = 6;
+ public static final int NUM_METRICS_DISPLAYED = 7;
private static final String LOG_TAG = "AffdexMe";
private static final int CAMERA_PERMISSIONS_REQUEST = 42; //value is arbitrary (between 0 and 255)
private static final int EXTERNAL_STORAGE_PERMISSIONS_REQUEST = 73;
@@ -117,9 +119,6 @@ public class MainActivity extends AppCompatActivity
private LinearLayout permissionsUnavailableLayout; //layout used to notify the user that not enough permissions have been granted to use the app
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;
- private ImageButton screenshotButton;
private Frame mostRecentFrame;
private boolean isMenuVisible = false;
private boolean isFPSVisible = false;
@@ -131,6 +130,8 @@ public class MainActivity extends AppCompatActivity
private boolean isBackFacingCameraDetected = true;
private boolean multiFaceModeEnabled = false;
+ private MediaPlayer mp;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -141,6 +142,8 @@ public class MainActivity extends AppCompatActivity
checkForCameraPermissions();
determineCameraAvailability();
initializeCameraDetector();
+
+ mp = MediaPlayer.create(this, R.raw.beyond_sleep_vo);
}
/**
@@ -208,7 +211,7 @@ public class MainActivity extends AppCompatActivity
requestStoragePermissions();
}
} else {
- takeScreenshot(screenshotButton);
+
}
}
@@ -269,7 +272,7 @@ public class MainActivity extends AppCompatActivity
if (storagePermissionsAvailable) {
// resume taking the screenshot
- takeScreenshot(screenshotButton);
+
}
}
@@ -357,9 +360,6 @@ public class MainActivity extends AppCompatActivity
fpsName = (TextView) findViewById(R.id.fps_name);
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);
- screenshotButton = (ImageButton) findViewById(R.id.screenshot_button);
progressBar = (ProgressBar) findViewById(R.id.progress_bar);
pleaseWaitTextView = (TextView) findViewById(R.id.please_wait_textview);
Button retryPermissionsButton = (Button) findViewById(R.id.retryPermissionsButton);
@@ -372,6 +372,7 @@ public class MainActivity extends AppCompatActivity
metricNames[3] = (TextView) findViewById(R.id.metric_name_3);
metricNames[4] = (TextView) findViewById(R.id.metric_name_4);
metricNames[5] = (TextView) findViewById(R.id.metric_name_5);
+ metricNames[6] = (TextView) findViewById(R.id.metric_name_6);
metricDisplays = new MetricDisplay[NUM_METRICS_DISPLAYED];
metricDisplays[0] = (MetricDisplay) findViewById(R.id.metric_pct_0);
metricDisplays[1] = (MetricDisplay) findViewById(R.id.metric_pct_1);
@@ -379,6 +380,7 @@ public class MainActivity extends AppCompatActivity
metricDisplays[3] = (MetricDisplay) findViewById(R.id.metric_pct_3);
metricDisplays[4] = (MetricDisplay) findViewById(R.id.metric_pct_4);
metricDisplays[5] = (MetricDisplay) findViewById(R.id.metric_pct_5);
+ metricDisplays[6] = (MetricDisplay) findViewById(R.id.metric_pct_6);
//Load Application Font and set UI Elements to use it
Typeface face = Typeface.createFromAsset(getAssets(), "fonts/Square.ttf");
@@ -456,7 +458,7 @@ public class MainActivity extends AppCompatActivity
super.onResume();
checkForCameraPermissions();
restoreApplicationSettings();
- setMenuVisible(true);
+ setMenuVisible(false);
isMenuShowingForFirstTime = true;
}
@@ -497,37 +499,28 @@ public class MainActivity extends AppCompatActivity
detector.setMaxProcessRate(detectorProcessRate);
drawingView.invalidateDimensions();
- if (sharedPreferences.getBoolean("fps", isFPSVisible)) { //restore isFPSMetricVisible
- setFPSVisible(true);
- } else {
- setFPSVisible(false);
- }
+ setFPSVisible(false);
+ setTrackPoints(true);
- if (sharedPreferences.getBoolean("track", drawingView.getDrawPointsEnabled())) { //restore isTrackingDotsVisible
- setTrackPoints(true);
- } else {
- setTrackPoints(false);
- }
+ detector.setDetectAllAppearances(false);
+ setShowAppearance(false);
- if (sharedPreferences.getBoolean("appearance", drawingView.getDrawAppearanceMarkersEnabled())) {
- detector.setDetectAllAppearances(true);
- setShowAppearance(true);
- } else {
- detector.setDetectAllAppearances(false);
- setShowAppearance(false);
- }
-
- if (sharedPreferences.getBoolean("emoji", drawingView.getDrawEmojiMarkersEnabled())) {
- detector.setDetectAllEmojis(true);
- setShowEmoji(true);
- } else {
- detector.setDetectAllEmojis(false);
- setShowEmoji(false);
- }
+ detector.setDetectAllEmojis(false);
+ setShowEmoji(false);
//populate metric displays
- for (int n = 0; n < NUM_METRICS_DISPLAYED; n++) {
- activateMetric(n, PreferencesUtils.getMetricFromPrefs(sharedPreferences, n));
+// for (int n = 0; n < NUM_METRICS_DISPLAYED; n++) {
+// activateMetric(n, PreferencesUtils.getMetricFromPrefs(sharedPreferences, n));
+// }
+
+ detector.setDetectAllEmotions(true);
+ int i=0;
+ for(MetricsManager.Emotions emotion: MetricsManager.Emotions.values()) {
+ if(emotion.equals(MetricsManager.Emotions.ENGAGEMENT) || emotion.equals(MetricsManager.Emotions.VALENCE)) {
+ continue;
+ }
+ activateMetric(i, emotion);
+ i++;
}
//if we are in multiface mode, we need to enable the detection of all emotions
@@ -542,44 +535,23 @@ public class MainActivity extends AppCompatActivity
* -enable the corresponding metric in the Detector object by calling Detector.setDetect()
* -save the Method object that will be invoked on the Face object received in onImageResults() to get the metric score
*/
- void activateMetric(int index, MetricsManager.Metrics metric) {
+ void activateMetric(int index, MetricsManager.Emotions metric) {
Method getFaceScoreMethod = null; //The method that will be used to get a metric score
try {
- switch (metric.getType()) {
- case Emotion:
- Detector.class.getMethod("setDetect" + MetricsManager.getCamelCase(metric), boolean.class).invoke(detector, true);
- metricNames[index].setText(MetricsManager.getUpperCaseName(metric));
- getFaceScoreMethod = Face.Emotions.class.getMethod("get" + MetricsManager.getCamelCase(metric));
+ metricNames[index].setText(MetricsManager.getUpperCaseName(metric));
+ getFaceScoreMethod = Face.Emotions.class.getMethod("get" + MetricsManager.getCamelCase(metric));
- //The MetricDisplay for Valence is unique; it shades it color depending on the metric value
- if (metric == MetricsManager.Emotions.VALENCE) {
- metricDisplays[index].setIsShadedMetricView(true);
- } else {
- metricDisplays[index].setIsShadedMetricView(false);
- }
- break;
- case Expression:
- Detector.class.getMethod("setDetect" + MetricsManager.getCamelCase(metric), boolean.class).invoke(detector, true);
- metricNames[index].setText(MetricsManager.getUpperCaseName(metric));
- getFaceScoreMethod = Face.Expressions.class.getMethod("get" + MetricsManager.getCamelCase(metric));
- break;
- case Emoji:
- detector.setDetectAllEmojis(true);
- MetricsManager.Emojis emoji = ((MetricsManager.Emojis) metric);
- String metricTitle = emoji.getDisplayName(); // + " " + emoji.getUnicodeForEmoji();
- metricNames[index].setText(metricTitle);
- Log.d(LOG_TAG, "Getter Method: " + "get" + MetricsManager.getCamelCase(metric));
- getFaceScoreMethod = Face.Emojis.class.getMethod("get" + MetricsManager.getCamelCase(metric));
- break;
+ //The MetricDisplay for Valence is unique; it shades it color depending on the metric value
+ if (metric == MetricsManager.Emotions.VALENCE) {
+ metricDisplays[index].setIsShadedMetricView(true);
+ } else {
+ metricDisplays[index].setIsShadedMetricView(false);
}
+
} catch (NoSuchMethodException e) {
Log.e(LOG_TAG, String.format("No such method while using reflection to generate methods for %s", metric.toString()), e);
- } catch (InvocationTargetException e) {
- Log.e(LOG_TAG, String.format("Invocation error while using reflection to generate methods for %s", metric.toString()), e);
- } catch (IllegalAccessException e) {
- Log.e(LOG_TAG, String.format("Illegal access error while using reflection to generate methods for %s", metric.toString()), e);
}
metricDisplays[index].setMetricToDisplay(metric, getFaceScoreMethod);
@@ -609,6 +581,12 @@ public class MainActivity extends AppCompatActivity
}
});
}
+
+ if(!hasFocus) {
+ // Close every kind of system dialog
+// Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+// sendBroadcast(closeDialog);
+ }
}
void mainWindowResumedTasks() {
@@ -655,6 +633,10 @@ public class MainActivity extends AppCompatActivity
rightMetricsLayout.animate().alpha(1);
resetFPSCalculations(); //Since the FPS may be different whether a face is being tracked or not, reset variables.
+
+ if(mp != null && !mp.isPlaying()) {
+ mp.start();
+ }
}
@Override
@@ -865,6 +847,12 @@ public class MainActivity extends AppCompatActivity
super.onPause();
progressBarLayout.setVisibility(View.VISIBLE);
+
+ ActivityManager activityManager = (ActivityManager) getApplicationContext()
+ .getSystemService(Context.ACTIVITY_SERVICE);
+
+ activityManager.moveTaskToFront(getTaskId(), 0);
+
performFaceDetectionStoppedTasks();
stopDetector();
@@ -890,31 +878,13 @@ public class MainActivity extends AppCompatActivity
* When the user taps the screen, hide the menu if it is visible and show it if it is hidden.
**/
void setMenuVisible(boolean b) {
- isMenuShowingForFirstTime = false;
- isMenuVisible = b;
- if (b) {
- settingsButton.setVisibility(View.VISIBLE);
- cameraButton.setVisibility(View.VISIBLE);
- screenshotButton.setVisibility(View.VISIBLE);
-
- //We display the navigation bar again
- getWindow().getDecorView().setSystemUiVisibility(
- View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
- } else {
-
- //We hide the navigation bar
- getWindow().getDecorView().setSystemUiVisibility(
- View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_FULLSCREEN);
- settingsButton.setVisibility(View.INVISIBLE);
- cameraButton.setVisibility(View.INVISIBLE);
- screenshotButton.setVisibility(View.INVISIBLE);
- }
+ //We hide the navigation bar
+ getWindow().getDecorView().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_FULLSCREEN);
}
/**
@@ -963,9 +933,6 @@ public class MainActivity extends AppCompatActivity
return false;
}
- public void settings_button_click(View view) {
- startActivity(new Intent(this, SettingsActivity.class));
- }
@SuppressWarnings("SuspiciousNameCombination")
@Override
@@ -1019,10 +986,7 @@ public class MainActivity extends AppCompatActivity
}
- public void camera_button_click(View view) {
- //Toggle the camera setting
- setCameraType(cameraType == CameraDetector.CameraType.CAMERA_FRONT ? CameraDetector.CameraType.CAMERA_BACK : CameraDetector.CameraType.CAMERA_FRONT);
- }
+
private void setCameraType(CameraDetector.CameraType type) {
SharedPreferences.Editor preferencesEditor = PreferenceManager.getDefaultSharedPreferences(this).edit();
@@ -1069,4 +1033,11 @@ public class MainActivity extends AppCompatActivity
}
});
}
+
+ @Override
+ public void onBackPressed() {
+ // nothing to do here
+ // … really
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 7d76498..5ec7eea 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -30,46 +30,10 @@
-
-
-
-
-
-
+ layout="@layout/metric_layout"
+ android:layout_height="170dp"
+ android:layout_width="match_parent"
+ android:layout_centerVertical="true" />
diff --git a/app/src/main/res/layout/metric_layout.xml b/app/src/main/res/layout/metric_layout.xml
index 98ac075..ea5d06b 100644
--- a/app/src/main/res/layout/metric_layout.xml
+++ b/app/src/main/res/layout/metric_layout.xml
@@ -2,21 +2,15 @@
+ android:layout_centerInParent="false"
+ android:layout_centerVertical="false"
+ android:layout_gravity="center_vertical">
-
+
+
+
-
-
@@ -97,5 +92,11 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/raw/beyond_sleep_vo.mp3 b/app/src/main/res/raw/beyond_sleep_vo.mp3
new file mode 100644
index 0000000..d951139
Binary files /dev/null and b/app/src/main/res/raw/beyond_sleep_vo.mp3 differ
diff --git a/build.gradle b/build.gradle
index 63ff522..2ea2e36 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.3'
+ classpath 'com.android.tools.build:gradle:2.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files