Compare commits

..

No commits in common. "4d491a411e250da15bccfd2c993ab05c26a31963" and "c96c735ca4a3d2c17125cfe4ad853cf9a1c8f614" have entirely different histories.

20 changed files with 21 additions and 528 deletions

View file

@ -6,7 +6,7 @@ android {
compileSdkVersion 24 compileSdkVersion 24
buildToolsVersion '25.0.0' buildToolsVersion '25.0.0'
defaultConfig { defaultConfig {
applicationId 'com.rubenvandeven.emotion_hero.kiosk' applicationId 'com.rubenvandeven.emotion_hero'
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 24 targetSdkVersion 24
versionCode 11 versionCode 11
@ -33,7 +33,7 @@ dependencies {
}) })
compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:support-v4:24.2.0' compile 'com.android.support:support-v4:24.2.0'
compile 'com.affectiva.android:affdexsdk:3.2' compile 'com.affectiva.android:affdexsdk:3.1.2'
compile 'com.google.code.gson:gson:2.4' compile 'com.google.code.gson:gson:2.4'
compile 'com.android.support:design:24.2.0' compile 'com.android.support:design:24.2.0'
compile 'com.loopj.android:android-async-http:1.4.9' compile 'com.loopj.android:android-async-http:1.4.9'

View file

@ -6,31 +6,25 @@
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<!--Kiosk Mode-->
<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application <application
android:name=".AppContext"
android:allowBackup="true" android:allowBackup="true"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:keepScreenOn="true"
tools:replace="android:allowBackup,android:label"> tools:replace="android:allowBackup,android:label">
<activity <activity
android:name=".GamingActivity" android:name=".GamingActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize" android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/FullscreenTheme"> android:theme="@style/FullscreenTheme">
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity> </activity>
<activity <activity
android:name=".IntroActivity" android:name=".IntroActivity"
@ -40,11 +34,8 @@
android:theme="@style/FullscreenTheme"> android:theme="@style/FullscreenTheme">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
@ -97,11 +88,6 @@
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value="com.rubenvandeven.emotionhero.ProgressActivity" /></activity> android:value="com.rubenvandeven.emotionhero.ProgressActivity" /></activity>
<receiver android:name=".BootReceiver">
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application> </application>
</manifest> </manifest>

View file

@ -2,6 +2,7 @@ package com.rubenvandeven.emotionhero;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout;
/** /**
* Created by ruben on 10/09/16. * Created by ruben on 10/09/16.

View file

@ -41,7 +41,7 @@ import cz.msebera.android.httpclient.entity.StringEntity;
*/ */
public class ApiRestClient { public class ApiRestClient {
private static final String BASE_URL = "https://api.emotionhero.com"; private static final String BASE_URL = "https://api.emotionhero.com"; // TODO: https!
/** /**
* For some reason validation of SSL certificate needs to be disabled (using true). * For some reason validation of SSL certificate needs to be disabled (using true).

View file

@ -1,61 +0,0 @@
package com.rubenvandeven.emotionhero;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.PowerManager;
/**
* For kioskmode only!
* See http://www.andreas-schrade.de/2015/02/16/android-tutorial-how-to-create-a-kiosk-mode-in-android/
*/
@ReportsCrashes(
buildConfigClass=BuildConfig.class,
formUri="http://crashes.rubenvandeven.com/api",
formUriBasicAuthLogin="com.rubenvandeven.emotion_hero.kiosk",
formUriBasicAuthPassword="4fkpp89Q+VKdbVj3VIbBFKTT",
mode=ReportingInteractionMode.TOAST,
resToastText=R.string.crash_toast_text)
public class AppContext extends Application {
private AppContext instance;
private PowerManager.WakeLock wakeLock;
private OnScreenOffReceiver onScreenOffReceiver;
@Override
public void onCreate() {
super.onCreate();
instance = this;
if (!ACRA.isACRASenderServiceProcess()) {
registerKioskModeScreenOffReceiver();
startKioskService();
}
}
private void registerKioskModeScreenOffReceiver() {
// register screen off receiver
final IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
onScreenOffReceiver = new OnScreenOffReceiver();
registerReceiver(onScreenOffReceiver, filter);
}
protected void attachBaseContext(Context paramContext)
{
super.attachBaseContext(paramContext);
ACRA.init(this, new ConfigurationBuilder(this).setReportField(ReportField.USER_COMMENT, false), true);
}
public PowerManager.WakeLock getWakeLock() {
if(wakeLock == null) {
// lazy loading: first call, create wakeLock via PowerManager.
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "wakeup");
}
return wakeLock;
}
private void startKioskService() {
startService(new Intent(this, KioskService.class));
}
}

View file

@ -1,18 +0,0 @@
package com.rubenvandeven.emotionhero;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* For kioskmode only!
* See http://www.andreas-schrade.de/2015/02/16/android-tutorial-how-to-create-a-kiosk-mode-in-android/
*/
public class BootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent myIntent = new Intent(context, IntroActivity.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);
}
}

View file

@ -1,7 +1,5 @@
package com.rubenvandeven.emotionhero; package com.rubenvandeven.emotionhero;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.net.Uri; import android.net.Uri;
@ -41,7 +39,6 @@ public class CreditsActivity extends AppCompatActivity {
moreInfo.setTypeface(font); moreInfo.setTypeface(font);
mySite.setTypeface(font); mySite.setTypeface(font);
/* BLOCK FOR KIOSK-MODE
findViewById(R.id.logoArquivo).setOnClickListener(new View.OnClickListener() { findViewById(R.id.logoArquivo).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -87,31 +84,6 @@ public class CreditsActivity extends AppCompatActivity {
i.setData(Uri.parse(url)); i.setData(Uri.parse(url));
startActivity(i); startActivity(i);
} }
});*/ });
} }
/**
* For kioskmode
* @param hasFocus
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(!hasFocus) {
// Close every kind of system dialog
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
@Override
protected void onPause() {
super.onPause();
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
}
} }

View file

@ -1,8 +1,5 @@
package com.rubenvandeven.emotionhero; package com.rubenvandeven.emotionhero;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
@ -91,29 +88,4 @@ public class EndingActivity extends AppCompatActivity {
this.rank.setVisibility(View.VISIBLE); this.rank.setVisibility(View.VISIBLE);
this.textRank.setVisibility(View.VISIBLE); this.textRank.setVisibility(View.VISIBLE);
} }
/**
* For kioskmode
* @param hasFocus
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(!hasFocus) {
// Close every kind of system dialog
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
@Override
protected void onPause() {
super.onPause();
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
}
} }

View file

@ -2,9 +2,7 @@ package com.rubenvandeven.emotionhero;
import android.Manifest; import android.Manifest;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -35,8 +33,6 @@ import com.affectiva.android.affdex.sdk.detector.Face;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
/** /**
@ -75,13 +71,10 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
protected boolean isStarted = false; protected boolean isStarted = false;
protected Timer timeoutTimer;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); // kiosk mode
if(getSupportActionBar() != null) { if(getSupportActionBar() != null) {
getSupportActionBar().hide(); getSupportActionBar().hide();
} }
@ -194,11 +187,6 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
super.onPause(); super.onPause();
stopDetector(); stopDetector();
currentScenario.pause(); currentScenario.pause();
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
} }
void startDetector() { void startDetector() {
@ -319,11 +307,6 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
setText("START!"); setText("START!");
currentScenario.lostFace = false; currentScenario.lostFace = false;
// in kioskmode, if no face is found for 60s return to main screen
if(timeoutTimer != null) {
timeoutTimer.cancel();
}
if(isStarted) if(isStarted)
currentScenario.start(); currentScenario.start();
} }
@ -333,19 +316,6 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
{ {
currentScenario.pause(); currentScenario.pause();
currentScenario.lostFace = true; currentScenario.lostFace = true;
// in kioskmode, if no face is found for 60s return to main screen
timeoutTimer = new Timer();
TimerTask timeoutTimerTask = new TimerTask() {
@Override
public void run() {
Intent intent = new Intent(GamingActivity.this, MirrorMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
}
};
timeoutTimer.schedule(timeoutTimerTask, 60*1000);
} }
public void setText(String text) public void setText(String text)
@ -436,18 +406,4 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
startActivity(intent); startActivity(intent);
finish(); finish();
} }
/**
* For kioskmode
* @param hasFocus
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(!hasFocus) {
// Close every kind of system dialog
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
} }

View file

@ -1,8 +1,6 @@
package com.rubenvandeven.emotionhero; package com.rubenvandeven.emotionhero;
import android.app.ActivityManager;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
@ -426,28 +424,4 @@ public class HighscoreActivity extends AppCompatActivity {
return mViewPager; return mViewPager;
} }
/**
* For kioskmode
* @param hasFocus
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(!hasFocus) {
// Close every kind of system dialog
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
@Override
protected void onPause() {
super.onPause();
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
}
} }

View file

@ -2,8 +2,6 @@ package com.rubenvandeven.emotionhero;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Handler; import android.os.Handler;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
@ -30,7 +28,6 @@ public class IntroActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); // kiosk mode
if(getSupportActionBar() != null) { if(getSupportActionBar() != null) {
getSupportActionBar().hide(); getSupportActionBar().hide();
} }
@ -98,28 +95,4 @@ public class IntroActivity extends AppCompatActivity {
IntroActivity.this.overridePendingTransition(0, 0); IntroActivity.this.overridePendingTransition(0, 0);
finish(); finish();
} }
/**
* For kioskmode
* @param hasFocus
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(!hasFocus) {
// Close every kind of system dialog
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
@Override
protected void onPause() {
super.onPause();
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
}
} }

View file

@ -1,95 +0,0 @@
package com.rubenvandeven.emotionhero;
import android.app.ActivityManager;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* Created by ruben on 05/10/16.
*/
public class KioskService extends Service {
private static final long INTERVAL = TimeUnit.SECONDS.toMillis(2); // periodic interval to check in seconds -> 2 seconds
private static final String TAG = KioskService.class.getSimpleName();
private static final String PREF_KIOSK_MODE = "pref_kiosk_mode";
private Thread t = null;
private Context ctx = null;
private boolean running = false;
@Override
public void onDestroy() {
Log.i(TAG, "Stopping service 'KioskService'");
running =false;
super.onDestroy();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG, "Starting service 'KioskService'");
running = true;
ctx = this;
// start a thread that periodically checks if your app is in the foreground
t = new Thread(new Runnable() {
@Override
public void run() {
do {
handleKioskMode();
try {
Thread.sleep(INTERVAL);
} catch (InterruptedException e) {
Log.i(TAG, "Thread interrupted: 'KioskService'");
}
}while(running);
stopSelf();
}
});
t.start();
return Service.START_NOT_STICKY;
}
private void handleKioskMode() {
// is Kiosk Mode active?
if(true) {
// is App in background?
if(isInBackground()) {
restoreApp(); // restore!
}
}
}
private boolean isInBackground() {
ActivityManager am = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
ComponentName componentInfo = taskInfo.get(0).topActivity;
return (!ctx.getApplicationContext().getPackageName().equals(componentInfo.getPackageName()));
}
private void restoreApp() {
// Restart activity
Intent i = new Intent(ctx, IntroActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(i);
}
public boolean isKioskModeActive(final Context context) {
return true;
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(PREF_KIOSK_MODE, false);
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
}

View file

@ -3,9 +3,7 @@ package com.rubenvandeven.emotionhero;
import android.Manifest; import android.Manifest;
import android.animation.ArgbEvaluator; import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.app.ActivityManager;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Bitmap; import android.graphics.Bitmap;
@ -74,7 +72,6 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); // kiosk mode
if(getSupportActionBar() != null) { if(getSupportActionBar() != null) {
getSupportActionBar().hide(); getSupportActionBar().hide();
} }
@ -100,7 +97,6 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
highscoresButton .setTypeface(font); highscoresButton .setTypeface(font);
creditsButton .setTypeface(font); creditsButton .setTypeface(font);
settingsButton.setTypeface(font); settingsButton.setTypeface(font);
settingsButton.setVisibility(View.INVISIBLE); // kiosk mode doesn't have settings
messageText.setTypeface(font); messageText.setTypeface(font);
nextButton.setTypeface(font); nextButton.setTypeface(font);
readyButton.setTypeface(font); readyButton.setTypeface(font);
@ -115,7 +111,6 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
int maxHeight = MirrorMenuActivity.this.getWindow().getDecorView().getHeight(); int maxHeight = MirrorMenuActivity.this.getWindow().getDecorView().getHeight();
int width; int width;
int height; int height;
Log.i(LOG_TAG, "Change the camera preview: " + previewWidth + " + " + measureWidth);
if (previewHeight == 0 || previewWidth == 0) { if (previewHeight == 0 || previewWidth == 0) {
width = measureWidth; width = measureWidth;
height = measureHeight; height = measureHeight;
@ -147,13 +142,13 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
setMeasuredDimension(width,height); setMeasuredDimension(width,height);
} }
}; };
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
// RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(1,1); // RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(1,1);
params.addRule(RelativeLayout.CENTER_IN_PARENT,RelativeLayout.TRUE); params.addRule(RelativeLayout.CENTER_IN_PARENT,RelativeLayout.TRUE);
// 10% margin:
// params.leftMargin = (int) 120;
// params.rightMargin = params.leftMargin;
cameraPreview.setLayoutParams(params); cameraPreview.setLayoutParams(params);
cameraPreview.setWillNotDraw(false);
videoContentLayout.addView(cameraPreview,0); videoContentLayout.addView(cameraPreview,0);
scenarioView = new ScenarioView(this, null); scenarioView = new ScenarioView(this, null);
@ -202,7 +197,6 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(MirrorMenuActivity.this, ProgressActivity.class); Intent intent = new Intent(MirrorMenuActivity.this, ProgressActivity.class);
startActivity(intent); startActivity(intent);
stopDetector();
} }
}); });
} }
@ -212,7 +206,6 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(MirrorMenuActivity.this, CreditsActivity.class); Intent intent = new Intent(MirrorMenuActivity.this, CreditsActivity.class);
startActivity(intent); startActivity(intent);
stopDetector();
} }
}); });
@ -292,12 +285,7 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
// stopDetector(); // kiosk mode should never pause ... stopDetector();
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
} }
void startDetector() { void startDetector() {
@ -322,7 +310,7 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
// SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView); // SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
detector = new CameraDetector(this, CameraDetector.CameraType.CAMERA_FRONT, cameraPreview, 1, Detector.FaceDetectorMode.LARGE_FACES); detector = new CameraDetector(this, CameraDetector.CameraType.CAMERA_FRONT, cameraPreview, 1, Detector.FaceDetectorMode.LARGE_FACES);
// detector.setLicensePath("emotionhero_dev.license"); detector.setLicensePath("emotionhero_dev.license");
detector.setDetectAllEmotions(true); detector.setDetectAllEmotions(true);
detector.setDetectAllAppearances(false); detector.setDetectAllAppearances(false);
@ -376,7 +364,6 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
previewHeight = height; previewHeight = height;
previewWidth = width; previewWidth = width;
} }
Log.i(LOG_TAG, "onCameraSize "+previewWidth +"x"+previewHeight);
cameraPreview.requestLayout(); cameraPreview.requestLayout();
} }
@ -427,26 +414,4 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
messageText.setVisibility(View.GONE); messageText.setVisibility(View.GONE);
} }
/**
* For kiosk mode only
*/
@Override
public void onBackPressed() {
// nothing to do here
// really
}
/**
* For kioskmode
* @param hasFocus
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(!hasFocus) {
// Close every kind of system dialog
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
} }

View file

@ -1,47 +0,0 @@
package com.rubenvandeven.emotionhero;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.util.Log;
/**
* For kioskmode only!
* See http://www.andreas-schrade.de/2015/02/16/android-tutorial-how-to-create-a-kiosk-mode-in-android/
*/
public class OnScreenOffReceiver extends BroadcastReceiver {
private static final String PREF_KIOSK_MODE = "pref_kiosk_mode";
@Override
public void onReceive(Context context, Intent intent) {
if(Intent.ACTION_SCREEN_OFF.equals(intent.getAction())){
AppContext ctx = (AppContext) context.getApplicationContext();
// is Kiosk Mode active?
if(isKioskModeActive(ctx)) {
wakeUpDevice(ctx);
}
}
}
private void wakeUpDevice(AppContext context) {
PowerManager.WakeLock wakeLock = context.getWakeLock(); // get WakeLock reference via AppContext
if (wakeLock.isHeld()) {
wakeLock.release(); // release old wake lock
}
// create a new wake lock...
wakeLock.acquire();
// ... and release again
wakeLock.release();
}
private boolean isKioskModeActive(final Context context) {
return true;
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(PREF_KIOSK_MODE, false);
}
}

View file

@ -64,15 +64,13 @@ public class Player {
} }
public boolean hasSetSnapshotConfirm() { public boolean hasSetSnapshotConfirm() {
return true; // this is kioskmode, always snapshot! SharedPreferences settings = c.getSharedPreferences(PREFS_NAME, 0);
// SharedPreferences settings = c.getSharedPreferences(PREFS_NAME, 0); return settings.contains("snapshot_confirm");
// return settings.contains("snapshot_confirm");
} }
public boolean allowsSnapshots() { public boolean allowsSnapshots() {
return true; // this is kioskmode: always snapshot! SharedPreferences settings = c.getSharedPreferences(PREFS_NAME, 0);
// SharedPreferences settings = c.getSharedPreferences(PREFS_NAME, 0); return settings.getBoolean("snapshot_confirm", false);
// return settings.getBoolean("snapshot_confirm", false);
} }
public void setAllowsSnapshots(boolean allows) { public void setAllowsSnapshots(boolean allows) {

View file

@ -1,8 +1,6 @@
package com.rubenvandeven.emotionhero; package com.rubenvandeven.emotionhero;
import android.app.ActivityManager;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
@ -214,28 +212,4 @@ public class ProgressActivity extends AppCompatActivity {
levelsLayout.addView(outroText); levelsLayout.addView(outroText);
} }
@Override
protected void onPause() {
super.onPause();
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
}
/**
* For kioskmode
* @param hasFocus
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(!hasFocus) {
// Close every kind of system dialog
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
} }

View file

@ -1,8 +1,5 @@
package com.rubenvandeven.emotionhero; package com.rubenvandeven.emotionhero;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.AppCompatTextView; import android.support.v7.widget.AppCompatTextView;
@ -97,27 +94,4 @@ public class ReviewAchievementsActivity extends AppCompatActivity {
achievementsLayout.addView(titleText); achievementsLayout.addView(titleText);
achievementsLayout.addView(descriptionLayout); achievementsLayout.addView(descriptionLayout);
} }
/**
* For kioskmode
* @param hasFocus
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(!hasFocus) {
// Close every kind of system dialog
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
@Override
protected void onPause() {
super.onPause();
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
}
} }

View file

@ -1,8 +1,6 @@
package com.rubenvandeven.emotionhero; package com.rubenvandeven.emotionhero;
import android.app.ActivityManager;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Handler; import android.os.Handler;
@ -356,29 +354,4 @@ public class ReviewActivity extends AppCompatActivity {
return super.onOptionsItemSelected(menuItem); return super.onOptionsItemSelected(menuItem);
} }
} }
/**
* For kioskmode
* @param hasFocus
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(!hasFocus) {
// Close every kind of system dialog
Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
}
@Override
protected void onPause() {
super.onPause();
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
}
} }

View file

@ -147,8 +147,6 @@ public class ScenarioView extends SurfaceView implements SurfaceHolder.Callback
float height = canvas.getHeight(); float height = canvas.getHeight();
float width = canvas.getWidth(); float width = canvas.getWidth();
Log.i("ScenarioView", "onDraw "+ width+" x " +height);
if(_scenario != null) if(_scenario != null)
{ {

View file

@ -1,5 +1,5 @@
<resources> <resources>
<string name="app_name">Emotion Hero - Exhibition Edition</string> <string name="app_name">Emotion Hero</string>
<string name="dummy_button">Dummy Button</string> <string name="dummy_button">Dummy Button</string>
<string name="dummy_content">initialising&#8230;</string> <string name="dummy_content">initialising&#8230;</string>
@ -23,6 +23,4 @@
<string name="permission_yes">Sure!</string> <string name="permission_yes">Sure!</string>
<string name="ending_winner">You are the one and only <i>Emotion Hero</i>!</string> <string name="ending_winner">You are the one and only <i>Emotion Hero</i>!</string>
<string name="ending_loser">You have finished all steps in the training, and many peers have done the same. It is too bad that many scored better than you. Try smiling better next time!</string> <string name="ending_loser">You have finished all steps in the training, and many peers have done the same. It is too bad that many scored better than you. Try smiling better next time!</string>
<string name="crash_toast_text">Sorry, Emotion Hero just crashed.</string>
</resources> </resources>