|
@@ -43,6 +43,13 @@ import android.text.ClipboardManager; |
|
|
import android.text.InputType;
|
|
|
import android.text.InputType;
|
|
|
import android.util.DisplayMetrics;
|
|
|
import android.util.DisplayMetrics;
|
|
|
import android.util.Log;
|
|
|
import android.util.Log;
|
|
|
|
|
|
import java.lang.Runnable;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
|
import java.util.Hashtable;
|
|
|
|
|
|
import java.util.TimerTask;
|
|
|
import java.io.*;
|
|
|
import java.io.*;
|
|
|
import java.net.URL;
|
|
|
import java.net.URL;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.HttpURLConnection;
|
|
@@ -143,6 +150,7 @@ public class JuceAppActivity extends Activity |
|
|
//==============================================================================
|
|
|
//==============================================================================
|
|
|
private ViewHolder viewHolder;
|
|
|
private ViewHolder viewHolder;
|
|
|
private boolean isScreenSaverEnabled;
|
|
|
private boolean isScreenSaverEnabled;
|
|
|
|
|
|
private java.util.Timer keepAliveTimer;
|
|
|
|
|
|
|
|
|
public final ComponentPeerView createNewView (boolean opaque, long host)
|
|
|
public final ComponentPeerView createNewView (boolean opaque, long host)
|
|
|
{
|
|
|
{
|
|
@@ -230,14 +238,46 @@ public class JuceAppActivity extends Activity |
|
|
if (isScreenSaverEnabled != enabled)
|
|
|
if (isScreenSaverEnabled != enabled)
|
|
|
{
|
|
|
{
|
|
|
isScreenSaverEnabled = enabled;
|
|
|
isScreenSaverEnabled = enabled;
|
|
|
|
|
|
|
|
|
|
|
|
if (keepAliveTimer != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
keepAliveTimer.cancel();
|
|
|
|
|
|
keepAliveTimer = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
if (enabled)
|
|
|
if (enabled)
|
|
|
|
|
|
{
|
|
|
getWindow().clearFlags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
getWindow().clearFlags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
else
|
|
|
|
|
|
{
|
|
|
getWindow().addFlags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
getWindow().addFlags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
|
|
|
|
|
|
|
|
|
// If no user input is received after about 3 seconds, the OS will lower the
|
|
|
|
|
|
// task's priority, so this timer forces it to be kept active.
|
|
|
|
|
|
keepAliveTimer = new java.util.Timer();
|
|
|
|
|
|
|
|
|
|
|
|
keepAliveTimer.scheduleAtFixedRate (new TimerTask()
|
|
|
|
|
|
{
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void run()
|
|
|
|
|
|
{
|
|
|
|
|
|
android.app.Instrumentation instrumentation = new android.app.Instrumentation();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
instrumentation.sendKeyDownUpSync (KeyEvent.KEYCODE_BREAK);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 2000, 2000);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public final boolean getScreenSaver ()
|
|
|
|
|
|
|
|
|
public final boolean getScreenSaver()
|
|
|
{
|
|
|
{
|
|
|
return isScreenSaverEnabled;
|
|
|
return isScreenSaverEnabled;
|
|
|
}
|
|
|
}
|
|
|