Compare commits
16 commits
c96c735ca4
...
4d491a411e
Author | SHA1 | Date | |
---|---|---|---|
|
4d491a411e | ||
|
9ed9bd0d58 | ||
|
25b2e09f5e | ||
|
9232c08ac6 | ||
|
4645ae4a6b | ||
|
433e09d454 | ||
|
866c6fa4ae | ||
|
3974b59919 | ||
|
cb857b501e | ||
|
123a98602a | ||
|
8dc463c388 | ||
|
90c898db82 | ||
|
741f8c83c8 | ||
|
d10662757f | ||
|
9874e8eb3b | ||
|
4f3b85d06b |
20 changed files with 528 additions and 21 deletions
|
@ -6,7 +6,7 @@ android {
|
|||
compileSdkVersion 24
|
||||
buildToolsVersion '25.0.0'
|
||||
defaultConfig {
|
||||
applicationId 'com.rubenvandeven.emotion_hero'
|
||||
applicationId 'com.rubenvandeven.emotion_hero.kiosk'
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 24
|
||||
versionCode 11
|
||||
|
@ -33,7 +33,7 @@ dependencies {
|
|||
})
|
||||
compile 'com.android.support:appcompat-v7:24.2.0'
|
||||
compile 'com.android.support:support-v4:24.2.0'
|
||||
compile 'com.affectiva.android:affdexsdk:3.1.2'
|
||||
compile 'com.affectiva.android:affdexsdk:3.2'
|
||||
compile 'com.google.code.gson:gson:2.4'
|
||||
compile 'com.android.support:design:24.2.0'
|
||||
compile 'com.loopj.android:android-async-http:1.4.9'
|
||||
|
|
|
@ -6,25 +6,31 @@
|
|||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<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
|
||||
android:name=".AppContext"
|
||||
android:allowBackup="true"
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:keepScreenOn="true"
|
||||
tools:replace="android:allowBackup,android:label">
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".GamingActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/FullscreenTheme">
|
||||
|
||||
<!-- <intent-filter> -->
|
||||
<!-- <action android:name="android.intent.action.MAIN" /> -->
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
|
||||
<!-- </intent-filter> -->
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".IntroActivity"
|
||||
|
@ -34,8 +40,11 @@
|
|||
android:theme="@style/FullscreenTheme">
|
||||
<intent-filter>
|
||||
<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" />
|
||||
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
|
@ -88,6 +97,11 @@
|
|||
<meta-data
|
||||
android:name="android.support.PARENT_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>
|
||||
|
||||
</manifest>
|
|
@ -2,7 +2,6 @@ package com.rubenvandeven.emotionhero;
|
|||
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
/**
|
||||
* Created by ruben on 10/09/16.
|
||||
|
|
|
@ -41,7 +41,7 @@ import cz.msebera.android.httpclient.entity.StringEntity;
|
|||
*/
|
||||
|
||||
public class ApiRestClient {
|
||||
private static final String BASE_URL = "https://api.emotionhero.com"; // TODO: https!
|
||||
private static final String BASE_URL = "https://api.emotionhero.com";
|
||||
|
||||
/**
|
||||
* For some reason validation of SSL certificate needs to be disabled (using true).
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
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));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package com.rubenvandeven.emotionhero;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
|
@ -39,6 +41,7 @@ public class CreditsActivity extends AppCompatActivity {
|
|||
moreInfo.setTypeface(font);
|
||||
mySite.setTypeface(font);
|
||||
|
||||
/* BLOCK FOR KIOSK-MODE
|
||||
findViewById(R.id.logoArquivo).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -84,6 +87,31 @@ public class CreditsActivity extends AppCompatActivity {
|
|||
i.setData(Uri.parse(url));
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.rubenvandeven.emotionhero;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
@ -88,4 +91,29 @@ public class EndingActivity extends AppCompatActivity {
|
|||
this.rank.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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.rubenvandeven.emotionhero;
|
|||
|
||||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -33,6 +35,8 @@ import com.affectiva.android.affdex.sdk.detector.Face;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -71,10 +75,13 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
|
|||
|
||||
protected boolean isStarted = false;
|
||||
|
||||
protected Timer timeoutTimer;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); // kiosk mode
|
||||
if(getSupportActionBar() != null) {
|
||||
getSupportActionBar().hide();
|
||||
}
|
||||
|
@ -187,6 +194,11 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
|
|||
super.onPause();
|
||||
stopDetector();
|
||||
currentScenario.pause();
|
||||
|
||||
ActivityManager activityManager = (ActivityManager) getApplicationContext()
|
||||
.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
|
||||
activityManager.moveTaskToFront(getTaskId(), 0);
|
||||
}
|
||||
|
||||
void startDetector() {
|
||||
|
@ -307,6 +319,11 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
|
|||
setText("START!");
|
||||
currentScenario.lostFace = false;
|
||||
|
||||
// in kioskmode, if no face is found for 60s return to main screen
|
||||
if(timeoutTimer != null) {
|
||||
timeoutTimer.cancel();
|
||||
}
|
||||
|
||||
if(isStarted)
|
||||
currentScenario.start();
|
||||
}
|
||||
|
@ -316,6 +333,19 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
|
|||
{
|
||||
currentScenario.pause();
|
||||
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)
|
||||
|
@ -406,4 +436,18 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
|
|||
startActivity(intent);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.rubenvandeven.emotionhero;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
|
@ -424,4 +426,28 @@ public class HighscoreActivity extends AppCompatActivity {
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.rubenvandeven.emotionhero;
|
|||
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
@ -28,6 +30,7 @@ public class IntroActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); // kiosk mode
|
||||
if(getSupportActionBar() != null) {
|
||||
getSupportActionBar().hide();
|
||||
}
|
||||
|
@ -95,4 +98,28 @@ public class IntroActivity extends AppCompatActivity {
|
|||
IntroActivity.this.overridePendingTransition(0, 0);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,9 @@ package com.rubenvandeven.emotionhero;
|
|||
import android.Manifest;
|
||||
import android.animation.ArgbEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -72,6 +74,7 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); // kiosk mode
|
||||
if(getSupportActionBar() != null) {
|
||||
getSupportActionBar().hide();
|
||||
}
|
||||
|
@ -97,6 +100,7 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
|||
highscoresButton .setTypeface(font);
|
||||
creditsButton .setTypeface(font);
|
||||
settingsButton.setTypeface(font);
|
||||
settingsButton.setVisibility(View.INVISIBLE); // kiosk mode doesn't have settings
|
||||
messageText.setTypeface(font);
|
||||
nextButton.setTypeface(font);
|
||||
readyButton.setTypeface(font);
|
||||
|
@ -111,6 +115,7 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
|||
int maxHeight = MirrorMenuActivity.this.getWindow().getDecorView().getHeight();
|
||||
int width;
|
||||
int height;
|
||||
Log.i(LOG_TAG, "Change the camera preview: " + previewWidth + " + " + measureWidth);
|
||||
if (previewHeight == 0 || previewWidth == 0) {
|
||||
width = measureWidth;
|
||||
height = measureHeight;
|
||||
|
@ -142,13 +147,13 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
|||
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);
|
||||
params.addRule(RelativeLayout.CENTER_IN_PARENT,RelativeLayout.TRUE);
|
||||
// 10% margin:
|
||||
// params.leftMargin = (int) 120;
|
||||
// params.rightMargin = params.leftMargin;
|
||||
|
||||
cameraPreview.setLayoutParams(params);
|
||||
cameraPreview.setWillNotDraw(false);
|
||||
videoContentLayout.addView(cameraPreview,0);
|
||||
|
||||
scenarioView = new ScenarioView(this, null);
|
||||
|
@ -197,6 +202,7 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
|||
public void onClick(View v) {
|
||||
Intent intent = new Intent(MirrorMenuActivity.this, ProgressActivity.class);
|
||||
startActivity(intent);
|
||||
stopDetector();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -206,6 +212,7 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
|||
public void onClick(View v) {
|
||||
Intent intent = new Intent(MirrorMenuActivity.this, CreditsActivity.class);
|
||||
startActivity(intent);
|
||||
stopDetector();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -285,7 +292,12 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
|||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
stopDetector();
|
||||
// stopDetector(); // kiosk mode should never pause ...
|
||||
|
||||
ActivityManager activityManager = (ActivityManager) getApplicationContext()
|
||||
.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
|
||||
activityManager.moveTaskToFront(getTaskId(), 0);
|
||||
}
|
||||
|
||||
void startDetector() {
|
||||
|
@ -310,7 +322,7 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
|||
// SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
|
||||
|
||||
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.setDetectAllAppearances(false);
|
||||
|
@ -364,6 +376,7 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
|||
previewHeight = height;
|
||||
previewWidth = width;
|
||||
}
|
||||
Log.i(LOG_TAG, "onCameraSize "+previewWidth +"x"+previewHeight);
|
||||
cameraPreview.requestLayout();
|
||||
}
|
||||
|
||||
|
@ -414,4 +427,26 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -64,13 +64,15 @@ public class Player {
|
|||
}
|
||||
|
||||
public boolean hasSetSnapshotConfirm() {
|
||||
SharedPreferences settings = c.getSharedPreferences(PREFS_NAME, 0);
|
||||
return settings.contains("snapshot_confirm");
|
||||
return true; // this is kioskmode, always snapshot!
|
||||
// SharedPreferences settings = c.getSharedPreferences(PREFS_NAME, 0);
|
||||
// return settings.contains("snapshot_confirm");
|
||||
}
|
||||
|
||||
public boolean allowsSnapshots() {
|
||||
SharedPreferences settings = c.getSharedPreferences(PREFS_NAME, 0);
|
||||
return settings.getBoolean("snapshot_confirm", false);
|
||||
return true; // this is kioskmode: always snapshot!
|
||||
// SharedPreferences settings = c.getSharedPreferences(PREFS_NAME, 0);
|
||||
// return settings.getBoolean("snapshot_confirm", false);
|
||||
}
|
||||
|
||||
public void setAllowsSnapshots(boolean allows) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.rubenvandeven.emotionhero;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
@ -212,4 +214,28 @@ public class ProgressActivity extends AppCompatActivity {
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.rubenvandeven.emotionhero;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.AppCompatTextView;
|
||||
|
@ -94,4 +97,27 @@ public class ReviewAchievementsActivity extends AppCompatActivity {
|
|||
achievementsLayout.addView(titleText);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.rubenvandeven.emotionhero;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Handler;
|
||||
|
@ -354,4 +356,29 @@ public class ReviewActivity extends AppCompatActivity {
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -147,6 +147,8 @@ public class ScenarioView extends SurfaceView implements SurfaceHolder.Callback
|
|||
float height = canvas.getHeight();
|
||||
float width = canvas.getWidth();
|
||||
|
||||
Log.i("ScenarioView", "onDraw "+ width+" x " +height);
|
||||
|
||||
if(_scenario != null)
|
||||
{
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<resources>
|
||||
<string name="app_name">Emotion Hero</string>
|
||||
<string name="app_name">Emotion Hero - Exhibition Edition</string>
|
||||
|
||||
<string name="dummy_button">Dummy Button</string>
|
||||
<string name="dummy_content">initialising…</string>
|
||||
|
@ -23,4 +23,6 @@
|
|||
<string name="permission_yes">Sure!</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="crash_toast_text">Sorry, Emotion Hero just crashed.</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue