Skip to content

Commit

Permalink
android gui.Cyrus->NetMash
Browse files Browse the repository at this point in the history
  • Loading branch information
DuncanCragg committed Apr 17, 2014
1 parent cb749f3 commit cd2fbbc
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 51 deletions.
4 changes: 2 additions & 2 deletions makefile
Expand Up @@ -260,10 +260,10 @@ usestaticdb:
cp src/server/vm1/static.db src/server/vm1/cyrus.db

setremmapkey:
sed -i"" -e "s:03Hoq1TEN3zaDOQmSJNHwHM5fRQ3dajOdQYZGbw:03Hoq1TEN3zbEGUSHYbrBqYgXhph-qRQ7g8s3UA:" src/android/cyrus/gui/Cyrus.java
sed -i"" -e "s:03Hoq1TEN3zaDOQmSJNHwHM5fRQ3dajOdQYZGbw:03Hoq1TEN3zbEGUSHYbrBqYgXhph-qRQ7g8s3UA:" src/android/cyrus/gui/NetMash.java

setemumapkey:
sed -i"" -e "s:03Hoq1TEN3zbEGUSHYbrBqYgXhph-qRQ7g8s3UA:03Hoq1TEN3zaDOQmSJNHwHM5fRQ3dajOdQYZGbw:" src/android/cyrus/gui/Cyrus.java
sed -i"" -e "s:03Hoq1TEN3zbEGUSHYbrBqYgXhph-qRQ7g8s3UA:03Hoq1TEN3zaDOQmSJNHwHM5fRQ3dajOdQYZGbw:" src/android/cyrus/gui/NetMash.java

setappemuconfig:
sed -i"" -e "s:the-cyrus.net:10.0.2.2:g" res/raw/cyrusconfig.db
Expand Down
12 changes: 6 additions & 6 deletions src/android/cyrus/BLELinks.java
Expand Up @@ -9,13 +9,13 @@

import cyrus.platform.Kernel;
import cyrus.forest.*;
import cyrus.gui.Cyrus;
import cyrus.gui.NetMash;

import static cyrus.lib.Utils.*;

public class BLELinks extends WebObject implements BluetoothAdapter.LeScanCallback {

public BLELinks(){ Cyrus.user.linksaround=this; }
public BLELinks(){ NetMash.user.linksaround=this; }

public BLELinks(String s){ super(s,true); }

Expand All @@ -24,13 +24,13 @@ public class BLELinks extends WebObject implements BluetoothAdapter.LeScanCallba
private final static int REQUEST_ENABLE_BT = 1;

public void evaluate(){
if(!Cyrus.top.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) return;
if(!NetMash.top.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) return;
if(!running) runBLEScan();
}

private void runBLEScan(){
running=true;
BluetoothManager bm=(BluetoothManager)Cyrus.top.getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothManager bm=(BluetoothManager)NetMash.top.getSystemService(Context.BLUETOOTH_SERVICE);
bluetoothAdapter=bm.getAdapter(); if(bluetoothAdapter==null) return;
new Thread(){ public void run(){
while(running){
Expand All @@ -50,11 +50,11 @@ synchronized private void checkOnScanning(){
scanning=false;
if(!notifiedEnableBT){
notifiedEnableBT=true;
Cyrus.top.toast("Enable Bluetooth to detect local objects", false);
NetMash.top.toast("Enable Bluetooth to detect local objects", false);
}
return;
// Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
// Cyrus.top.startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
// NetMash.top.startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
if(scanning) return;
scanning=true;
Expand Down
4 changes: 2 additions & 2 deletions src/android/cyrus/CurrentLocation.java
Expand Up @@ -17,7 +17,7 @@
import static android.content.Context.*;
import static android.location.LocationManager.*;

import cyrus.gui.Cyrus;
import cyrus.gui.NetMash;

import cyrus.lib.JSON;
import cyrus.forest.*;
Expand All @@ -36,7 +36,7 @@ public class CurrentLocation implements LocationListener {

CurrentLocation(User user){
this.user=user;
locationManager=(LocationManager)Cyrus.top.getSystemService(LOCATION_SERVICE);
locationManager=(LocationManager)NetMash.top.getSystemService(LOCATION_SERVICE);
}

public void getLocationUpdates(){
Expand Down
10 changes: 5 additions & 5 deletions src/android/cyrus/Cyrus2GUI.java
Expand Up @@ -24,7 +24,7 @@

import static cyrus.lib.Utils.*;

import cyrus.gui.Cyrus;
import cyrus.gui.NetMash;
import cyrus.gui.Mesh;

/** Convertors from std Cyrus JSON to common GUI JSON.
Expand Down Expand Up @@ -542,8 +542,8 @@ public LinkedHashMap guifyHash(String uid, LinkedHashMap<String,Object> hm, bool
if(address==null || address.equals("")) return null;
LinkedHashMap<String,Double> loc=geoCodeCache.get(address);
if(loc!=null){ log("cached result="+loc); return loc; }
if(Cyrus.top==null){ log("No Activity to geoCode from"); return null; }
Geocoder geocoder = new Geocoder(Cyrus.top.getApplicationContext(), Locale.getDefault());
if(NetMash.top==null){ log("No Activity to geoCode from"); return null; }
Geocoder geocoder = new Geocoder(NetMash.top.getApplicationContext(), Locale.getDefault());
try{
List<Address> geos = geocoder.getFromLocationName(address, 1);
if(!geos.isEmpty()){
Expand Down Expand Up @@ -790,8 +790,8 @@ private String text2Bitmap(String title, LinkedList text){
if(bitmap!=null) return key;
bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_4444);
Canvas canvas = new Canvas(bitmap);
if(Cyrus.top!=null){
Drawable background = Cyrus.top.getPlaceHolderDrawable();
if(NetMash.top!=null){
Drawable background = NetMash.top.getPlaceHolderDrawable();
background.setBounds(0, 0, 256, 256);
background.draw(canvas);
}
Expand Down
4 changes: 2 additions & 2 deletions src/android/cyrus/Sensors.java
Expand Up @@ -6,7 +6,7 @@
import android.content.*;
import static android.content.Context.*;

import cyrus.gui.Cyrus;
import cyrus.gui.NetMash;
import static cyrus.lib.Utils.*;

public class Sensors implements SensorEventListener {
Expand All @@ -16,7 +16,7 @@ public class Sensors implements SensorEventListener {

public Sensors(User user){
this.user=user;
sensorManager=(SensorManager)Cyrus.top.getSystemService(Context.SENSOR_SERVICE);
sensorManager=(SensorManager)NetMash.top.getSystemService(Context.SENSOR_SERVICE);
}

public void startWatchingSensors(){
Expand Down
40 changes: 20 additions & 20 deletions src/android/cyrus/User.java
Expand Up @@ -22,7 +22,7 @@
import static android.content.Context.*;
import static android.location.LocationManager.*;

import cyrus.gui.Cyrus;
import cyrus.gui.NetMash;
import cyrus.gui.Mesh;
import cyrus.lib.*;
import cyrus.forest.*;
Expand Down Expand Up @@ -84,7 +84,7 @@ static public void createUserAndDevice(){
currentUser.funcobs.cacheSaveAndEvaluate(currentUser, true);

if(homeusers!=null) currentUser.notifying(list(homeusers));
Cyrus.top.onUserReady(currentUser);
NetMash.top.onUserReady(currentUser);
}

public User(String jsonstring){ super(jsonstring); }
Expand Down Expand Up @@ -117,7 +117,7 @@ public User(String homeusers, String contactuid, String linksuid, String linksar
"}");
}

public User(){ if(currentUser==null){ currentUser=this; if(Cyrus.top!=null) Cyrus.top.onUserReady(currentUser); } }
public User(){ if(currentUser==null){ currentUser=this; if(NetMash.top!=null) NetMash.top.onUserReady(currentUser); } }

static User newForm(String guiuid, String useruid){
return new User("{ \"is\": \"form\",\n"+
Expand Down Expand Up @@ -208,7 +208,7 @@ void onNewLocation(final Location location){
}

void onNewOrientation(float azimuth, float pitch, float roll){
if(trackingAround) Cyrus.top.onNewOrientation(azimuth,pitch,roll);
if(trackingAround) NetMash.top.onNewOrientation(azimuth,pitch,roll);
}

// ---------------------------------------------------------
Expand All @@ -230,7 +230,7 @@ public void onObjectTouched(LinkedList touchInfo, final boolean down, final int
new Evaluator(this){ public void evaluate(){
if(firstTouchQuadrant==1){
content("holding",objectuid);
Cyrus.top.toast("Holding "+contentStringOr("holding:title","object"), false);
NetMash.top.toast("Holding "+contentStringOr("holding:title","object"), false);
}
else
if(firstTouchQuadrant==2){
Expand Down Expand Up @@ -407,19 +407,19 @@ private void setViewingAndAs(String uid, String as){
public boolean menuItem(final int itemid){
new Evaluator(this){ public void evaluate(){
switch(itemid){
case Cyrus.MENU_ITEM_ARD:
case NetMash.MENU_ITEM_ARD:
jumpToEnvironment();
break;
case Cyrus.MENU_ITEM_LNX:
case NetMash.MENU_ITEM_LNX:
jumpToHereAndShow(content("private:links"), "gui", false);
break;
case Cyrus.MENU_ITEM_GUI:
case NetMash.MENU_ITEM_GUI:
jumpToHereAndShow(content("private:viewing"), "gui", false);
break;
case Cyrus.MENU_ITEM_MAP:
case NetMash.MENU_ITEM_MAP:
jumpToHereAndShow(content("private:viewing"), "map", false);
break;
case Cyrus.MENU_ITEM_RAW:
case NetMash.MENU_ITEM_RAW:
jumpToHereAndShow(content("private:viewing"), "raw", false);
break;
}
Expand Down Expand Up @@ -507,7 +507,7 @@ public void evaluate(){
val[0]=contentIs("private:responses:rsvp:"+UID.toUID(guiuid)+":"+dehash(tag),"yes");
}
else if(contentIsOrListContains("private:viewing:is", "gui")){
val[0]=contentBool("private:responses:form:"+UID.toUID(guiuid)+":form:"+dehash(tag));
val[0]=contentBoolean("private:responses:form:"+UID.toUID(guiuid)+":form:"+dehash(tag));
}
else val[0]=null;
}
Expand Down Expand Up @@ -604,10 +604,10 @@ else new Evaluator(this){ public void evaluate(){
if(contentListContainsAll("is", list("editable", "rule"))){
LinkedHashMap rule=null;
try{
JSON json=new JSON(Cyrus.top.getRawSource(),true);
JSON json=new JSON(NetMash.top.getRawSource(),true);
json.setPathAdd("is", "editable");
rule=makeEditRule("",contentInt("editable:Version"),json);
}catch(JSON.Syntax js){ Cyrus.top.toast(js.toString().split("\n")[1], true); }
}catch(JSON.Syntax js){ NetMash.top.toast(js.toString().split("\n")[1], true); }
if(rule!=null) contentMerge(rule);
}
else
Expand Down Expand Up @@ -793,11 +793,11 @@ private void setUpdateValOnObjectUpdating(String guiuid, String tag, String val)
else
new Evaluator(o){ public void evaluate(){
if(!self.contentIsOrListContains("is", "editable")) return;
if(Cyrus.top==null) return;
String source=spawnUIDNew(Cyrus.top.getRawSource());
if(NetMash.top==null) return;
String source=spawnUIDNew(NetMash.top.getRawSource());
try{
self.contentReplace(new JSON(source,true));
}catch(JSON.Syntax js){ Cyrus.top.toast(js.toString().split("\n")[1], true); }
}catch(JSON.Syntax js){ NetMash.top.toast(js.toString().split("\n")[1], true); }
self.contentSetAdd("is", "editable");
self.evaluate();
}};
Expand Down Expand Up @@ -940,7 +940,7 @@ void updateUserPosition(){
if(targetpos==null) return;
float dx=getFloatFromList(targetpos, 0, 0)-getFloatFromList(currenpos, 0, 0);
float dz=getFloatFromList(targetpos, 2, 0)-getFloatFromList(currenpos, 2, 0);
if(dx*dx+dz*dz>5) Cyrus.top.onNewMovement(dx/20,dz/20);
if(dx*dx+dz*dz>5) NetMash.top.onNewMovement(dx/20,dz/20);
}};
}

Expand Down Expand Up @@ -1081,7 +1081,7 @@ private void showWhatIAmViewingAsGUI(){
}
uiJSON=new JSON(meshhash);
}
if(Cyrus.top!=null && uiJSON!=null) Cyrus.top.drawJSON(uiJSON, content("private:viewing"));
if(NetMash.top!=null && uiJSON!=null) NetMash.top.drawJSON(uiJSON, content("private:viewing"));
}
}

Expand Down Expand Up @@ -1115,7 +1115,7 @@ private void showWhatIAmViewingOnMap(){
JSON uiJSON=new JSON("{ \"is\": \"gui\" }");
uiJSON.stringPath("title", title);
uiJSON.listPath("view", viewlist);
if(Cyrus.top!=null) Cyrus.top.drawJSON(uiJSON, content("private:viewing"));
if(NetMash.top!=null) NetMash.top.drawJSON(uiJSON, content("private:viewing"));
}
}
}
Expand All @@ -1130,7 +1130,7 @@ private void showWhatIAmViewingAsRawJSON(){
JSON uiJSON=new JSON("{ \"is\": \"gui\" }");
uiJSON.stringPath("title", title);
uiJSON.hashPath("view", viewhash);
if(Cyrus.top!=null) Cyrus.top.drawJSON(uiJSON, content("private:viewing"));
if(NetMash.top!=null) NetMash.top.drawJSON(uiJSON, content("private:viewing"));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/android/cyrus/UserContacts.java
Expand Up @@ -23,14 +23,14 @@
import cyrus.forest.*;
import cyrus.platform.Kernel;

import cyrus.gui.Cyrus;
import cyrus.gui.NetMash;

/** Access to User's contacts list.
*/
public class UserContacts {

static String getUsersFullName(){
AccountManager acctmgr = AccountManager.get(Cyrus.top);
AccountManager acctmgr = AccountManager.get(NetMash.top);
Account[] accounts = acctmgr.getAccountsByType("com.google");
for(Account account: accounts){
String name=account.name;
Expand All @@ -55,8 +55,8 @@ static public String toFullNameFromEmail(String emailname){

static public LinkedList populateContacts(User user){
LinkedList contactslist = new LinkedList();
if(Cyrus.top==null) return null;
Context context = Cyrus.top.getApplicationContext();
if(NetMash.top==null) return null;
Context context = NetMash.top.getApplicationContext();
ContentResolver cr=context.getContentResolver();
Cursor concur = cr.query(Contacts.CONTENT_URI, null, null, null, null);
int idcol = concur.getColumnIndex(Contacts._ID);
Expand Down
4 changes: 2 additions & 2 deletions src/android/cyrus/gui/CyrusMapOverlay.java
Expand Up @@ -32,9 +32,9 @@ public Item(GeoPoint point, String label, String sublabel, String jumpUID){
}

private ArrayList<Item> overlayitems = new ArrayList<Item>();
private Cyrus cyrus;
private NetMash cyrus;

public CyrusMapOverlay(Drawable defaultMarker, Cyrus cyrus, String mapUID){
public CyrusMapOverlay(Drawable defaultMarker, NetMash cyrus, String mapUID){
super(boundCenterBottom(defaultMarker));
populate();
this.cyrus = cyrus;
Expand Down
Expand Up @@ -36,11 +36,11 @@

import cyrus.User;

/** Cyrus main.
/** NetMash main.
*/
public class Cyrus extends MapActivity {
public class NetMash extends MapActivity {

static public Cyrus top=null;
static public NetMash top=null;
static public User user=null;

public GLSurfaceView onemeshview=null;
Expand Down Expand Up @@ -291,8 +291,8 @@ public void onNewMovement(float dx, float dz){
boolean newObject=!uiUID.equals(viewUID);
viewUID=uiUID;
String title =uiJSON.stringPathN("title");
if(title==null) setTitle( "Cyrus");
else setTitle(title+"|Cyrus");
if(title==null) setTitle( "NetMash");
else setTitle(title+"|NetMash");
if("gui".equals(uiJSON.stringPathN("is"))){
Object o=uiJSON.hashPathN("view");
if(o==null) o=uiJSON.listPathN("view");
Expand Down Expand Up @@ -1156,7 +1156,7 @@ private int parseFirstInt(String s){
//---------------------------------------------------------

public void toast(final String s, final boolean longer){
final Cyrus self=this;
final NetMash self=this;
guiHandler.post(new Runnable(){ public void run(){ Toast.makeText(self, s, longer? Toast.LENGTH_LONG: Toast.LENGTH_SHORT).show(); }});
}

Expand Down
4 changes: 2 additions & 2 deletions src/android/cyrus/gui/Renderer.java
Expand Up @@ -23,7 +23,7 @@ public class Renderer implements GLSurfaceView.Renderer {

private boolean debugGL;

private Cyrus cyrus;
private NetMash cyrus;
private Mesh mesh;

private int texture0Loc;
Expand Down Expand Up @@ -84,7 +84,7 @@ public class Renderer implements GLSurfaceView.Renderer {
static String lightVertexShaderSource = "uniform mat4 mvpm; attribute vec4 pos; attribute vec2 tex; varying vec2 texturePt; void main(){ texturePt = tex; gl_Position = mvpm*pos; }";
static String lightFragmentShaderSource = "precision mediump float; uniform vec3 lightCol; uniform sampler2D texture0; varying vec2 texturePt; void main(){ gl_FragColor=vec4(lightCol,1.0)*texture2D(texture0,texturePt); }";

public Renderer(Cyrus cyrus, LinkedHashMap hm) {
public Renderer(NetMash cyrus, LinkedHashMap hm) {
debugGL=Kernel.config.boolPathN("gl:log"); if(debugGL) log("** GL Debugging on! May be slower..");
this.cyrus=cyrus;
this.mesh=new Mesh(hm,cyrus.user);
Expand Down

0 comments on commit cd2fbbc

Please sign in to comment.