Skip to content

Commit

Permalink
Reorganized code, removed OpenGL/Picarus/AudioOnOff, Reformatted code
Browse files Browse the repository at this point in the history
Signed-off-by: Brandyn A. White <bwhite@dappervision.com>
  • Loading branch information
Brandyn A. White committed Mar 9, 2014
1 parent 209bf2f commit 7edf251
Show file tree
Hide file tree
Showing 92 changed files with 392 additions and 1,127 deletions.
5 changes: 3 additions & 2 deletions WearScript/Default.html
@@ -1,7 +1,7 @@
<html style="width:100%; height:100%; overflow:hidden">
<head>
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>-->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>-->
</head>
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<canvas id="canvas" width="640" height="360" style="display:block"></canvas>
Expand Down Expand Up @@ -33,6 +33,7 @@
WS.serverConnect('{{WSUrl}}', 'server');
}
window.onload = main;

</script>
</body>
</html>
2 changes: 1 addition & 1 deletion WearScript/build.gradle
Expand Up @@ -3,7 +3,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
Expand Down
37 changes: 17 additions & 20 deletions WearScript/src/main/AndroidManifest.xml
Expand Up @@ -37,46 +37,43 @@
android:targetSdkVersion="19" />

<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:anyDensity="true"
android:largeScreens="true"
android:anyDensity="true" />
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true" />

<application
android:allowBackup="true"
android:icon="@drawable/launcher"
android:label="@string/app_name">
<activity
android:name=".ui.ScriptActivity"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
android:configChanges="orientation|screenSize|keyboardHidden"
android:exported="true">
</activity>
android:exported="true"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"></activity>
<activity
android:name=".ui.QRActivity"
android:label="WearScript QR"
android:configChanges="keyboardHidden"></activity>
android:configChanges="keyboardHidden"
android:label="WearScript QR"></activity>
<activity
android:name=".ui.SetupActivity"
android:clearTaskOnLaunch="true"
android:label="@string/setup"
android:configChanges="keyboardHidden"
android:exported="true"
android:configChanges="keyboardHidden">
</activity>
android:label="@string/setup"></activity>
<activity
android:name=".ui.StopActivity"
android:clearTaskOnLaunch="true"
android:configChanges="keyboardHidden"
android:icon="@drawable/ic_stop"
android:launchMode="singleInstance"
android:label="@string/stop"
android:configChanges="keyboardHidden">
</activity>
android:launchMode="singleInstance"></activity>
<activity
android:name=".ui.MainActivity"
android:launchMode="singleInstance"
android:name=".launcher.MainActivity"
android:configChanges="keyboardHidden"
android:label="@string/app_name"
android:configChanges="keyboardHidden">
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -88,9 +85,9 @@
</activity>
<activity
android:name=".ui.MenuActivity"
android:enabled="true"
android:label="@string/app_name"
android:theme="@style/MenuTheme"
android:enabled="true"></activity>
android:theme="@style/MenuTheme"></activity>

<service android:name="com.dappervision.wearscript.BackgroundService" />
</application>
Expand Down

This file was deleted.

This file was deleted.

Expand Up @@ -20,27 +20,24 @@

import com.dappervision.wearscript.dataproviders.BatteryDataProvider;
import com.dappervision.wearscript.dataproviders.DataPoint;
import com.dappervision.wearscript.events.ActivityEvent;
import com.dappervision.wearscript.events.CameraEvents;
import com.dappervision.wearscript.events.DataLogEvent;
import com.dappervision.wearscript.events.JsCall;
import com.dappervision.wearscript.events.LambdaEvent;
import com.dappervision.wearscript.events.SayEvent;
import com.dappervision.wearscript.events.ScreenEvent;
import com.dappervision.wearscript.events.ScriptEvent;
import com.dappervision.wearscript.events.SendEvent;
import com.dappervision.wearscript.events.ShutdownEvent;
import com.dappervision.wearscript.jsevents.ActivityEvent;
import com.dappervision.wearscript.jsevents.CameraEvents;
import com.dappervision.wearscript.jsevents.DataLogEvent;
import com.dappervision.wearscript.jsevents.PicarusEvent;
import com.dappervision.wearscript.jsevents.SayEvent;
import com.dappervision.wearscript.jsevents.ScreenEvent;
import com.dappervision.wearscript.jsevents.WifiScanResultsEvent;
import com.dappervision.wearscript.events.WifiScanResultsEvent;
import com.dappervision.wearscript.managers.CameraManager;
import com.dappervision.wearscript.managers.CardTreeManager;
import com.dappervision.wearscript.managers.ConnectionManager;
import com.dappervision.wearscript.managers.DataManager;
import com.dappervision.wearscript.managers.GestureManager;
import com.dappervision.wearscript.managers.Manager;
import com.dappervision.wearscript.managers.ManagerManager;
import com.dappervision.wearscript.managers.OpenGLManager;
import com.dappervision.wearscript.managers.PicarusManager;
import com.dappervision.wearscript.managers.WarpManager;
import com.dappervision.wearscript.managers.WifiManager;
import com.dappervision.wearscript.ui.ScriptActivity;
Expand All @@ -58,16 +55,16 @@ public class BackgroundService extends Service implements AudioRecord.OnRecordPo
protected static String TAG = "WearScript";
private final IBinder mBinder = new LocalBinder();
private final Object lock = new Object(); // All calls to webview client must acquire lock
protected TextToSpeech tts;
protected ScreenBroadcastReceiver broadcastReceiver;
protected String glassID;
protected CardScrollView cardScroller;
private ScriptActivity activity;
private boolean dataRemote, dataLocal, dataWifi;
private double lastSensorSaveTime, sensorDelay;
private ScriptView webview;
private TreeMap<String, ArrayList<Value>> sensorBuffer;
private TreeMap<String, Integer> sensorTypes;
protected TextToSpeech tts;
protected ScreenBroadcastReceiver broadcastReceiver;
protected String glassID;
protected CardScrollView cardScroller;
private MessagePack msgpack = new MessagePack();
private View activityView;
private ActivityEvent.Mode activityMode;
Expand All @@ -82,6 +79,11 @@ static public String getDefaultUrl() {
return (new String(wsUrlArray)).trim();
}

static String convertStreamToString(java.io.InputStream is) {
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}

public void updateActivityView(final ActivityEvent.Mode mode) {
if (activity == null)
return;
Expand All @@ -91,8 +93,6 @@ public void run() {
activityMode = mode;
if (mode == ActivityEvent.Mode.WEBVIEW && webview != null) {
activityView = webview;
} else if (mode == ActivityEvent.Mode.OPENGL) {
activityView = ((OpenGLManager) getManager(OpenGLManager.class)).getView();
} else if (mode == ActivityEvent.Mode.WARP) {
activityView = ((WarpManager) getManager(WarpManager.class)).getView();
} else if (mode == ActivityEvent.Mode.CARD_TREE) {
Expand Down Expand Up @@ -122,7 +122,6 @@ public ActivityEvent.Mode getActivityMode() {
return activityMode;
}


public void loadUrl(String url) {
synchronized (lock) {
if (webview != null && url != null) {
Expand Down Expand Up @@ -279,7 +278,7 @@ public void reset() {
}

public void startDefaultScript() {
byte[] data = "<body style='width:640px; height:480px; overflow:hidden; margin:0' bgcolor='black'><center><h1 style='font-size:70px;color:#FAFAFA;font-family:monospace'>WearScript</h1><h1 style='font-size:40px;color:#FAFAFA;font-family:monospace'>When connected use playground to control<br><br>Docs @ wearscript.com</h1></center><script>function s() {WSRAW.say('Connected')};window.onload=function () {WSRAW.serverConnect('{{WSUrl}}', 's')}</script></body>" .getBytes();
byte[] data = "<body style='width:640px; height:480px; overflow:hidden; margin:0' bgcolor='black'><center><h1 style='font-size:70px;color:#FAFAFA;font-family:monospace'>WearScript</h1><h1 style='font-size:40px;color:#FAFAFA;font-family:monospace'>When connected use playground to control<br><br>Docs @ wearscript.com</h1></center><script>function s() {WSRAW.say('Connected')};window.onload=function () {WSRAW.serverConnect('{{WSUrl}}', 's')}</script></body>".getBytes();
String path = Utils.SaveData(data, "scripting/", false, "glass.html");
Utils.eventBusPost(new ScriptEvent(path));
}
Expand Down Expand Up @@ -330,11 +329,6 @@ public IBinder onBind(Intent intent) {
return mBinder;
}

static String convertStreamToString(java.io.InputStream is) {
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}

@Override
public void onCreate() {
Log.i(TAG, "Lifecycle: Service onCreate");
Expand Down Expand Up @@ -364,7 +358,7 @@ public void setMainActivity(ScriptActivity a) {
activity.finish();
}
this.activity = a;
if(ManagerManager.hasManager(CardTreeManager.class))
if (ManagerManager.hasManager(CardTreeManager.class))
((CardTreeManager) getManager(CardTreeManager.class)).setMainActivity(a);
}

Expand All @@ -383,7 +377,7 @@ public void onDestroy() {

public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if(hasWebView())
if (hasWebView())
webview.onConfigurationChanged(newConfig);
}

Expand Down Expand Up @@ -415,11 +409,6 @@ public void onEvent(DataLogEvent e) {
sensorDelay = e.getSensorDelay() * 1000000000L;
}

public void onEvent(PicarusEvent e) {
// TODO(brandyn): Needs to be fixed
ManagerManager.get().add(new PicarusManager(this));
}

public void onEvent(ScreenEvent e) {
wake();
}
Expand Down
18 changes: 9 additions & 9 deletions WearScript/src/main/java/com/dappervision/wearscript/Log.java
Expand Up @@ -42,10 +42,10 @@ static private void logRaven(final String tag, final String message, final Sentr
activity.runOnUiThread(new Thread() {
public void run() {
Sentry.captureEvent(new Sentry.SentryEventBuilder()
.setMessage(message)
.setLevel(level)
.setCulprit(tag)
.setTimestamp(System.currentTimeMillis())
.setMessage(message)
.setLevel(level)
.setCulprit(tag)
.setTimestamp(System.currentTimeMillis())
);
}
});
Expand All @@ -58,11 +58,11 @@ static private void logRaven(final String tag, final String message, final Sentr
activity.runOnUiThread(new Thread() {
public void run() {
Sentry.captureEvent(new Sentry.SentryEventBuilder()
.setMessage(message)
.setLevel(level)
.setCulprit(tag)
.setException(tr)
.setTimestamp(System.currentTimeMillis())
.setMessage(message)
.setLevel(level)
.setCulprit(tag)
.setException(tr)
.setTimestamp(System.currentTimeMillis())
);
}
});
Expand Down
Expand Up @@ -11,8 +11,8 @@
import android.webkit.WebChromeClient;
import android.webkit.WebView;

import com.dappervision.wearscript.events.LiveCardEvent;
import com.dappervision.wearscript.events.SendEvent;
import com.dappervision.wearscript.jsevents.LiveCardEvent;
import com.dappervision.wearscript.ui.MenuActivity;
import com.google.android.glass.timeline.DirectRenderingCallback;
import com.google.android.glass.timeline.LiveCard;
Expand All @@ -21,9 +21,9 @@
public class ScriptView extends WebView implements SurfaceHolder.Callback, DirectRenderingCallback {
private static final String TAG = "ScriptView";
private final BackgroundService context;
private final Handler handler;
private LiveCard liveCard;
private SurfaceHolder holder;
private final Handler handler;
private long drawFrequency;
private boolean paused;

Expand Down

0 comments on commit 7edf251

Please sign in to comment.