*/
package org.ocera.orte.shape_android;
-import java.util.regex.Pattern;
-
import org.ocera.orte.DomainApp;
import org.ocera.orte.Manager;
import org.ocera.orte.types.NtpTime;
import android.net.wifi.WifiManager.WifiLock;
import android.os.Bundle;
import android.os.Handler;
+import android.os.PowerManager;
+import android.os.PowerManager.WakeLock;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
private static final int MINSEPARATION_MAX = 5;
private static final int RESULT_SETTINGS = 1;
+ public static int SHAPE_WIDTH = 0;
+ public static int SHAPE_HEIGHT = 0;
+
+ private PowerManager powerManager;
+ private WakeLock wakeLock;
+
private WifiManager wifiManager;
private WifiLock wifiLock;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_publisher);
+ // count default shape size
+ SHAPE_WIDTH = (int) (this.getWindowManager().getDefaultDisplay().getWidth() * 25 / BoxType.DESTINATION_WIDTH);
+ SHAPE_HEIGHT = (int) (this.getWindowManager().getDefaultDisplay().getHeight() * 45 / BoxType.DESTINATION_HEIGHT);
+
// From Robot_Demo project.
wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifiLock = (WifiLock) wifiManager.createWifiLock((
? WifiManager.WIFI_MODE_FULL_HIGH_PERF
: WifiManager.WIFI_MODE_FULL
), getClass().getName());
-
+
+ powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ wakeLock = (WakeLock) powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, getClass().getName() + " Dim");
+
sp = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
// Start ORTE.
}
/**
- * When pause activity, release WiFi lock.
+ * When pause activity, release WiFi lock and Wake lock.
*
* @since 1.0
*/
super.onPause();
wifiLock.release();
+ wakeLock.release();
}
/**
- * When resume activity, acquire WiFi lock.
+ * When resume activity, acquire WiFi lock and Wake lock.
*
* @since 1.0
*/
super.onResume();
wifiLock.acquire();
+ wakeLock.acquire();
}
/**
public void onDestroy()
{
super.onDestroy();
-
+
+ handler.removeCallbacks(redraw);
+
+ for (PublisherShape shape : publisherView.shapes)
+ shape.killMe();
+
+ for (SubscriberElement element : subscriberView.elements)
+ element.killMe();
+
if (appDomain != null) {
appDomain.destroy();
appDomain = null;
{
super.onConfigurationChanged(newConfig);
+ // count default shape size
+ SHAPE_WIDTH = (int) (this.getWindowManager().getDefaultDisplay().getWidth() * 25 / BoxType.DESTINATION_WIDTH);
+ SHAPE_HEIGHT = (int) (this.getWindowManager().getDefaultDisplay().getHeight() * 45 / BoxType.DESTINATION_HEIGHT);
+
for (PublisherShape s : this.publisherView.shapes) {
s.setScale(this.getWindowManager().getDefaultDisplay().getWidth(), this.getWindowManager().getDefaultDisplay().getHeight());
}
e.setScale(this.getWindowManager().getDefaultDisplay().getWidth(), this.getWindowManager().getDefaultDisplay().getHeight());
}
- //TODO When change rotation in Subscriber view,
+ //TODO When change rotation in Subscriber view,
// there is no change in Publisher view, which
// leads to misbehavior. For example, there
// is Publisher of Black color in Publisher view,
orteManager = new Manager(sp.getString("prefManagers", ""));
break;
+ default:
}
}