Kiosk mode working (power button still triggers screen, but disabling screenslock should be sufficient)
This commit is contained in:
parent
4f3b85d06b
commit
9874e8eb3b
11 changed files with 115 additions and 6 deletions
|
@ -7,11 +7,8 @@
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
<!--Kiosk Mode-->
|
<!--Kiosk Mode-->
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.GET_TASKS"/>
|
|
||||||
|
|
||||||
<service android:name=".KioskService" android:exported="false"/>
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".AppContext"
|
android:name=".AppContext"
|
||||||
|
@ -23,6 +20,8 @@
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:keepScreenOn="true"
|
android:keepScreenOn="true"
|
||||||
tools:replace="android:allowBackup,android:label">
|
tools:replace="android:allowBackup,android:label">
|
||||||
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".GamingActivity"
|
android:name=".GamingActivity"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
|
@ -40,8 +39,11 @@
|
||||||
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
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
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;
|
||||||
|
@ -94,4 +96,15 @@ public class CreditsActivity extends AppCompatActivity {
|
||||||
sendBroadcast(closeDialog);
|
sendBroadcast(closeDialog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
ActivityManager activityManager = (ActivityManager) getApplicationContext()
|
||||||
|
.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
|
|
||||||
|
activityManager.moveTaskToFront(getTaskId(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
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.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -103,4 +105,15 @@ public class EndingActivity extends AppCompatActivity {
|
||||||
sendBroadcast(closeDialog);
|
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.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;
|
||||||
|
@ -188,6 +190,11 @@ 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() {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
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;
|
||||||
|
@ -437,4 +439,15 @@ public class HighscoreActivity extends AppCompatActivity {
|
||||||
sendBroadcast(closeDialog);
|
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.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;
|
||||||
|
@ -91,7 +93,7 @@ public class IntroActivity extends AppCompatActivity {
|
||||||
public void continueToMenu() {
|
public void continueToMenu() {
|
||||||
continueHandler.removeCallbacks(continueRunnable);
|
continueHandler.removeCallbacks(continueRunnable);
|
||||||
Intent intent = new Intent(this, MirrorMenuActivity.class);
|
Intent intent = new Intent(this, MirrorMenuActivity.class);
|
||||||
finish();
|
// finish();
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
//disable distracting transition when going to menu
|
//disable distracting transition when going to menu
|
||||||
IntroActivity.this.overridePendingTransition(0, 0);
|
IntroActivity.this.overridePendingTransition(0, 0);
|
||||||
|
@ -110,4 +112,14 @@ public class IntroActivity extends AppCompatActivity {
|
||||||
sendBroadcast(closeDialog);
|
sendBroadcast(closeDialog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
ActivityManager activityManager = (ActivityManager) getApplicationContext()
|
||||||
|
.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
|
|
||||||
|
activityManager.moveTaskToFront(getTaskId(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@ 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;
|
||||||
|
@ -72,6 +74,7 @@ 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();
|
||||||
}
|
}
|
||||||
|
@ -197,6 +200,7 @@ 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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -206,6 +210,7 @@ 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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -242,6 +247,7 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
||||||
Intent intent = new Intent(MirrorMenuActivity.this, ProgressActivity.class);
|
Intent intent = new Intent(MirrorMenuActivity.this, ProgressActivity.class);
|
||||||
finish();
|
finish();
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
stopDetector();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -286,7 +292,12 @@ public class MirrorMenuActivity extends AppCompatActivity implements Detector.Im
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
stopDetector();
|
// stopDetector(); // kiosk mode should never pause ...
|
||||||
|
|
||||||
|
ActivityManager activityManager = (ActivityManager) getApplicationContext()
|
||||||
|
.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
|
|
||||||
|
activityManager.moveTaskToFront(getTaskId(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void startDetector() {
|
void startDetector() {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For kioskmode only!
|
* For kioskmode only!
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
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;
|
||||||
|
@ -189,6 +191,16 @@ 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
|
* For kioskmode
|
||||||
* @param hasFocus
|
* @param hasFocus
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
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.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -108,4 +110,14 @@ public class ReviewAchievementsActivity extends AppCompatActivity {
|
||||||
sendBroadcast(closeDialog);
|
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;
|
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;
|
||||||
|
@ -367,4 +369,15 @@ public class ReviewActivity extends AppCompatActivity {
|
||||||
sendBroadcast(closeDialog);
|
sendBroadcast(closeDialog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
ActivityManager activityManager = (ActivityManager) getApplicationContext()
|
||||||
|
.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
|
|
||||||
|
activityManager.moveTaskToFront(getTaskId(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue