package Box.Control;


import anywheresoftware.b4a.B4AMenuItem;
import android.app.Activity;
import android.os.Bundle;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.B4AActivity;
import anywheresoftware.b4a.ObjectWrapper;
import anywheresoftware.b4a.objects.ActivityWrapper;
import java.lang.reflect.InvocationTargetException;
import anywheresoftware.b4a.B4AUncaughtException;
import anywheresoftware.b4a.debug.*;
import java.lang.ref.WeakReference;

public class main extends Activity implements B4AActivity{
	public static main mostCurrent;
	static boolean afterFirstLayout;
	static boolean isFirst = true;
    private static boolean processGlobalsRun = false;
	BALayout layout;
	public static BA processBA;
	BA activityBA;
    ActivityWrapper _activity;
    java.util.ArrayList<B4AMenuItem> menuItems;
	public static final boolean fullScreen = false;
	public static final boolean includeTitle = true;
    public static WeakReference<Activity> previousOne;
    public static boolean dontPause;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        mostCurrent = this;
		if (processBA == null) {
			processBA = new BA(this.getApplicationContext(), null, null, "Box.Control", "Box.Control.main");
			processBA.loadHtSubs(this.getClass());
	        float deviceScale = getApplicationContext().getResources().getDisplayMetrics().density;
	        BALayout.setDeviceScale(deviceScale);
            
		}
		else if (previousOne != null) {
			Activity p = previousOne.get();
			if (p != null && p != this) {
                BA.LogInfo("Killing previous instance (main).");
				p.finish();
			}
		}
        processBA.setActivityPaused(true);
        processBA.runHook("oncreate", this, null);
		if (!includeTitle) {
        	this.getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE);
        }
        if (fullScreen) {
        	getWindow().setFlags(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN,   
        			android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
		
        processBA.sharedProcessBA.activityBA = null;
		layout = new BALayout(this);
		setContentView(layout);
		afterFirstLayout = false;
        WaitForLayout wl = new WaitForLayout();
        if (anywheresoftware.b4a.objects.ServiceHelper.StarterHelper.startFromActivity(this, processBA, wl, false))
		    BA.handler.postDelayed(wl, 5);

	}
	static class WaitForLayout implements Runnable {
		public void run() {
			if (afterFirstLayout)
				return;
			if (mostCurrent == null)
				return;
            
			if (mostCurrent.layout.getWidth() == 0) {
				BA.handler.postDelayed(this, 5);
				return;
			}
			mostCurrent.layout.getLayoutParams().height = mostCurrent.layout.getHeight();
			mostCurrent.layout.getLayoutParams().width = mostCurrent.layout.getWidth();
			afterFirstLayout = true;
			mostCurrent.afterFirstLayout();
		}
	}
	private void afterFirstLayout() {
        if (this != mostCurrent)
			return;
		activityBA = new BA(this, layout, processBA, "Box.Control", "Box.Control.main");
        
        processBA.sharedProcessBA.activityBA = new java.lang.ref.WeakReference<BA>(activityBA);
        anywheresoftware.b4a.objects.ViewWrapper.lastId = 0;
        _activity = new ActivityWrapper(activityBA, "activity");
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        if (BA.isShellModeRuntimeCheck(processBA)) {
			if (isFirst)
				processBA.raiseEvent2(null, true, "SHELL", false);
			processBA.raiseEvent2(null, true, "CREATE", true, "Box.Control.main", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density, mostCurrent);
			_activity.reinitializeForShell(activityBA, "activity");
		}
        initializeProcessGlobals();		
        initializeGlobals();
        
        BA.LogInfo("** Activity (main) Create, isFirst = " + isFirst + " **");
        processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
		isFirst = false;
		if (this != mostCurrent)
			return;
        processBA.setActivityPaused(false);
        BA.LogInfo("** Activity (main) Resume **");
        processBA.raiseEvent(null, "activity_resume");
        if (android.os.Build.VERSION.SDK_INT >= 11) {
			try {
				android.app.Activity.class.getMethod("invalidateOptionsMenu").invoke(this,(Object[]) null);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}
	public void addMenuItem(B4AMenuItem item) {
		if (menuItems == null)
			menuItems = new java.util.ArrayList<B4AMenuItem>();
		menuItems.add(item);
	}
	@Override
	public boolean onCreateOptionsMenu(android.view.Menu menu) {
		super.onCreateOptionsMenu(menu);
        try {
            if (processBA.subExists("activity_actionbarhomeclick")) {
                Class.forName("android.app.ActionBar").getMethod("setHomeButtonEnabled", boolean.class).invoke(
                    getClass().getMethod("getActionBar").invoke(this), true);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (processBA.runHook("oncreateoptionsmenu", this, new Object[] {menu}))
            return true;
		if (menuItems == null)
			return false;
		for (B4AMenuItem bmi : menuItems) {
			android.view.MenuItem mi = menu.add(bmi.title);
			if (bmi.drawable != null)
				mi.setIcon(bmi.drawable);
            if (android.os.Build.VERSION.SDK_INT >= 11) {
				try {
                    if (bmi.addToBar) {
				        android.view.MenuItem.class.getMethod("setShowAsAction", int.class).invoke(mi, 1);
                    }
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			mi.setOnMenuItemClickListener(new B4AMenuItemsClickListener(bmi.eventName.toLowerCase(BA.cul)));
		}
        
		return true;
	}   
 @Override
 public boolean onOptionsItemSelected(android.view.MenuItem item) {
    if (item.getItemId() == 16908332) {
        processBA.raiseEvent(null, "activity_actionbarhomeclick");
        return true;
    }
    else
        return super.onOptionsItemSelected(item); 
}
@Override
 public boolean onPrepareOptionsMenu(android.view.Menu menu) {
    super.onPrepareOptionsMenu(menu);
    processBA.runHook("onprepareoptionsmenu", this, new Object[] {menu});
    return true;
    
 }
 protected void onStart() {
    super.onStart();
    processBA.runHook("onstart", this, null);
}
 protected void onStop() {
    super.onStop();
    processBA.runHook("onstop", this, null);
}
    public void onWindowFocusChanged(boolean hasFocus) {
       super.onWindowFocusChanged(hasFocus);
       if (processBA.subExists("activity_windowfocuschanged"))
           processBA.raiseEvent2(null, true, "activity_windowfocuschanged", false, hasFocus);
    }
	private class B4AMenuItemsClickListener implements android.view.MenuItem.OnMenuItemClickListener {
		private final String eventName;
		public B4AMenuItemsClickListener(String eventName) {
			this.eventName = eventName;
		}
		public boolean onMenuItemClick(android.view.MenuItem item) {
			processBA.raiseEventFromUI(item.getTitle(), eventName + "_click");
			return true;
		}
	}
    public static Class<?> getObject() {
		return main.class;
	}
    private Boolean onKeySubExist = null;
    private Boolean onKeyUpSubExist = null;
	@Override
	public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
        if (processBA.runHook("onkeydown", this, new Object[] {keyCode, event}))
            return true;
		if (onKeySubExist == null)
			onKeySubExist = processBA.subExists("activity_keypress");
		if (onKeySubExist) {
			if (keyCode == anywheresoftware.b4a.keywords.constants.KeyCodes.KEYCODE_BACK &&
					android.os.Build.VERSION.SDK_INT >= 18) {
				HandleKeyDelayed hk = new HandleKeyDelayed();
				hk.kc = keyCode;
				BA.handler.post(hk);
				return true;
			}
			else {
				boolean res = new HandleKeyDelayed().runDirectly(keyCode);
				if (res)
					return true;
			}
		}
		return super.onKeyDown(keyCode, event);
	}
	private class HandleKeyDelayed implements Runnable {
		int kc;
		public void run() {
			runDirectly(kc);
		}
		public boolean runDirectly(int keyCode) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keypress", false, keyCode);
			if (res == null || res == true) {
                return true;
            }
            else if (keyCode == anywheresoftware.b4a.keywords.constants.KeyCodes.KEYCODE_BACK) {
				finish();
				return true;
			}
            return false;
		}
		
	}
    @Override
	public boolean onKeyUp(int keyCode, android.view.KeyEvent event) {
        if (processBA.runHook("onkeyup", this, new Object[] {keyCode, event}))
            return true;
		if (onKeyUpSubExist == null)
			onKeyUpSubExist = processBA.subExists("activity_keyup");
		if (onKeyUpSubExist) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keyup", false, keyCode);
			if (res == null || res == true)
				return true;
		}
		return super.onKeyUp(keyCode, event);
	}
	@Override
	public void onNewIntent(android.content.Intent intent) {
        super.onNewIntent(intent);
		this.setIntent(intent);
        processBA.runHook("onnewintent", this, new Object[] {intent});
	}
    @Override 
	public void onPause() {
		super.onPause();
        if (_activity == null)
            return;
        if (this != mostCurrent)
			return;
		anywheresoftware.b4a.Msgbox.dismiss(true);
        if (!dontPause)
            BA.LogInfo("** Activity (main) Pause, UserClosed = " + activityBA.activity.isFinishing() + " **");
        else
            BA.LogInfo("** Activity (main) Pause event (activity is not paused). **");
        if (mostCurrent != null)
            processBA.raiseEvent2(_activity, true, "activity_pause", false, activityBA.activity.isFinishing());		
        if (!dontPause) {
            processBA.setActivityPaused(true);
            mostCurrent = null;
        }

        if (!activityBA.activity.isFinishing())
			previousOne = new WeakReference<Activity>(this);
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        processBA.runHook("onpause", this, null);
	}

	@Override
	public void onDestroy() {
        super.onDestroy();
		previousOne = null;
        processBA.runHook("ondestroy", this, null);
	}
    @Override 
	public void onResume() {
		super.onResume();
        mostCurrent = this;
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        if (activityBA != null) { //will be null during activity create (which waits for AfterLayout).
        	ResumeMessage rm = new ResumeMessage(mostCurrent);
        	BA.handler.post(rm);
        }
        processBA.runHook("onresume", this, null);
	}
    private static class ResumeMessage implements Runnable {
    	private final WeakReference<Activity> activity;
    	public ResumeMessage(Activity activity) {
    		this.activity = new WeakReference<Activity>(activity);
    	}
		public void run() {
            main mc = mostCurrent;
			if (mc == null || mc != activity.get())
				return;
			processBA.setActivityPaused(false);
            BA.LogInfo("** Activity (main) Resume **");
            if (mc != mostCurrent)
                return;
		    processBA.raiseEvent(mc._activity, "activity_resume", (Object[])null);
		}
    }
	@Override
	protected void onActivityResult(int requestCode, int resultCode,
	      android.content.Intent data) {
		processBA.onActivityResult(requestCode, resultCode, data);
        processBA.runHook("onactivityresult", this, new Object[] {requestCode, resultCode});
	}
	private static void initializeGlobals() {
		processBA.raiseEvent2(null, true, "globals", false, (Object[])null);
	}
    public void onRequestPermissionsResult(int requestCode,
        String permissions[], int[] grantResults) {
        for (int i = 0;i < permissions.length;i++) {
            Object[] o = new Object[] {permissions[i], grantResults[i] == 0};
            processBA.raiseEventFromDifferentThread(null,null, 0, "activity_permissionresult", true, o);
        }
            
    }

public anywheresoftware.b4a.keywords.Common __c = null;
public anywheresoftware.b4a.objects.B4XViewWrapper _btn_start = null;
public anywheresoftware.b4a.objects.collections.JSONParser.JSONGenerator _jg = null;
public anywheresoftware.b4a.objects.collections.JSONParser _json = null;
public static long _start_date = 0L;
public static long _stop_date = 0L;
public static long _start_time = 0L;
public static long _stop_time = 0L;
public static String _first_name = "";
public static String _last_name = "";
public static String _email = "";
public static String _phone = "";
public static String _city = "";
public static String _door_code = "";
public static String _rentalid = "";
public static String _phone1 = "";
public static String _phone2 = "";
public static String _admin_code = "";
public static String _admin_message1 = "";
public static String _admin_message2 = "";
public static String _localisation = "";
public static String _welcome_message1 = "";
public static String _welcome_message2 = "";
public static String _welcome_message3 = "";
public static String _battery_level = "";
public static boolean _wifi_enable = false;
public static boolean _ble_enable = false;
public static boolean _activephone1 = false;
public static boolean _activephone2 = false;
public anywheresoftware.b4a.objects.B4XViewWrapper _btn_setup = null;
public anywheresoftware.b4a.objects.B4XViewWrapper.XUI _ui = null;
public anywheresoftware.b4a.objects.B4XViewWrapper _btn_read_setup = null;
public Box.Control.starter _starter = null;
public Box.Control.agent _agent = null;
public Box.Control.param _param = null;
public Box.Control.s1 _s1 = null;

public static boolean isAnyActivityVisible() {
    boolean vis = false;
vis = vis | (main.mostCurrent != null);
return vis;}
public static void  _activity_create(boolean _firsttime) throws Exception{
ResumableSub_Activity_Create rsub = new ResumableSub_Activity_Create(null,_firsttime);
rsub.resume(processBA, null);
}
public static class ResumableSub_Activity_Create extends BA.ResumableSub {
public ResumableSub_Activity_Create(Box.Control.main parent,boolean _firsttime) {
this.parent = parent;
this._firsttime = _firsttime;
}
Box.Control.main parent;
boolean _firsttime;
String _permission = "";
boolean _result = false;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
 //BA.debugLineNum = 43;BA.debugLine="Activity.LoadLayout(\"Audiostream\")";
parent.mostCurrent._activity.LoadLayout("Audiostream",mostCurrent.activityBA);
 //BA.debugLineNum = 48;BA.debugLine="Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_";
parent.mostCurrent._starter._rp /*anywheresoftware.b4a.objects.RuntimePermissions*/ .CheckAndRequest(processBA,parent.mostCurrent._starter._rp /*anywheresoftware.b4a.objects.RuntimePermissions*/ .PERMISSION_SEND_SMS);
 //BA.debugLineNum = 49;BA.debugLine="Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_";
parent.mostCurrent._starter._rp /*anywheresoftware.b4a.objects.RuntimePermissions*/ .CheckAndRequest(processBA,parent.mostCurrent._starter._rp /*anywheresoftware.b4a.objects.RuntimePermissions*/ .PERMISSION_READ_EXTERNAL_STORAGE);
 //BA.debugLineNum = 50;BA.debugLine="Wait For Activity_PermissionResult (Permission As";
anywheresoftware.b4a.keywords.Common.WaitFor("activity_permissionresult", processBA, this, null);
this.state = 11;
return;
case 11:
//C
this.state = 1;
_permission = (String) result[0];
_result = (Boolean) result[1];
;
 //BA.debugLineNum = 51;BA.debugLine="If Result = False Then Return";
if (true) break;

case 1:
//if
this.state = 6;
if (_result==anywheresoftware.b4a.keywords.Common.False) { 
this.state = 3;
;}if (true) break;

case 3:
//C
this.state = 6;
if (true) return ;
if (true) break;

case 6:
//C
this.state = 7;
;
 //BA.debugLineNum = 53;BA.debugLine="If File.Exists(File.DirDefaultExternal,\"Setup.jso";
if (true) break;

case 7:
//if
this.state = 10;
if (anywheresoftware.b4a.keywords.Common.File.Exists(anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal(),"Setup.json")==anywheresoftware.b4a.keywords.Common.False) { 
this.state = 9;
}if (true) break;

case 9:
//C
this.state = 10;
 //BA.debugLineNum = 54;BA.debugLine="Ui.MsgboxAsync(\"Vous devez configurer le Setup\",";
parent.mostCurrent._ui.MsgboxAsync(processBA,BA.ObjectToCharSequence("Vous devez configurer le Setup"),BA.ObjectToCharSequence("Warning"));
 if (true) break;

case 10:
//C
this.state = -1;
;
 //BA.debugLineNum = 71;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static void  _activity_permissionresult(String _permission,boolean _result) throws Exception{
}
public static String  _activity_pause(boolean _userclosed) throws Exception{
 //BA.debugLineNum = 78;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
 //BA.debugLineNum = 80;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
 //BA.debugLineNum = 73;BA.debugLine="Sub Activity_Resume";
 //BA.debugLineNum = 75;BA.debugLine="End Sub";
return "";
}
public static String  _btn_read_setup_click() throws Exception{
anywheresoftware.b4a.objects.collections.Map _generaladmin = null;
anywheresoftware.b4a.objects.collections.Map _generaladmin_data = null;
 //BA.debugLineNum = 199;BA.debugLine="Sub Btn_read_setup_Click";
 //BA.debugLineNum = 201;BA.debugLine="Dim GeneralAdmin As Map";
_generaladmin = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 202;BA.debugLine="Dim GeneralAdmin_Data As Map";
_generaladmin_data = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 203;BA.debugLine="JSON.Initialize(File.ReadString(File.DirDefaultEx";
mostCurrent._json.Initialize(anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal(),"Setup.json"));
 //BA.debugLineNum = 204;BA.debugLine="GeneralAdmin.Initialize";
_generaladmin.Initialize();
 //BA.debugLineNum = 205;BA.debugLine="GeneralAdmin = JSON.NextObject";
_generaladmin = mostCurrent._json.NextObject();
 //BA.debugLineNum = 207;BA.debugLine="GeneralAdmin_Data=GeneralAdmin.Get(\"GeneralAdmin\"";
_generaladmin_data = (anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (anywheresoftware.b4a.objects.collections.Map.MyMap)(_generaladmin.Get((Object)("GeneralAdmin"))));
 //BA.debugLineNum = 209;BA.debugLine="Phone1=GeneralAdmin_Data.Get(\"Phone1\")";
mostCurrent._phone1 = BA.ObjectToString(_generaladmin_data.Get((Object)("Phone1")));
 //BA.debugLineNum = 210;BA.debugLine="Phone2=GeneralAdmin_Data.Get(\"Phone2\")";
mostCurrent._phone2 = BA.ObjectToString(_generaladmin_data.Get((Object)("Phone2")));
 //BA.debugLineNum = 211;BA.debugLine="Admin_Code=GeneralAdmin_Data.Get(\"Admin_Code\")";
mostCurrent._admin_code = BA.ObjectToString(_generaladmin_data.Get((Object)("Admin_Code")));
 //BA.debugLineNum = 212;BA.debugLine="Admin_Message1=GeneralAdmin_Data.Get(\"Admin_Messa";
mostCurrent._admin_message1 = BA.ObjectToString(_generaladmin_data.Get((Object)("Admin_Message1")));
 //BA.debugLineNum = 213;BA.debugLine="Admin_Message2=GeneralAdmin_Data.Get(\"Admin_Messa";
mostCurrent._admin_message2 = BA.ObjectToString(_generaladmin_data.Get((Object)("Admin_Message2")));
 //BA.debugLineNum = 214;BA.debugLine="Localisation=GeneralAdmin_Data.Get(\"Localisation\"";
mostCurrent._localisation = BA.ObjectToString(_generaladmin_data.Get((Object)("Localisation")));
 //BA.debugLineNum = 215;BA.debugLine="Welcome_Message1=GeneralAdmin_Data.Get(\"Welcome_M";
mostCurrent._welcome_message1 = BA.ObjectToString(_generaladmin_data.Get((Object)("Welcome_Message1")));
 //BA.debugLineNum = 216;BA.debugLine="Welcome_Message2=GeneralAdmin_Data.Get(\"Welcome_M";
mostCurrent._welcome_message2 = BA.ObjectToString(_generaladmin_data.Get((Object)("Welcome_Message2")));
 //BA.debugLineNum = 217;BA.debugLine="Welcome_Message3=GeneralAdmin_Data.Get(\"Welcome_M";
mostCurrent._welcome_message3 = BA.ObjectToString(_generaladmin_data.Get((Object)("Welcome_Message3")));
 //BA.debugLineNum = 218;BA.debugLine="ActivePhone1=GeneralAdmin_Data.Get(\"ActivePhone1\"";
_activephone1 = BA.ObjectToBoolean(_generaladmin_data.Get((Object)("ActivePhone1")));
 //BA.debugLineNum = 219;BA.debugLine="ActivePhone2=GeneralAdmin_Data.Get(\"ActivePhone2\"";
_activephone2 = BA.ObjectToBoolean(_generaladmin_data.Get((Object)("ActivePhone2")));
 //BA.debugLineNum = 221;BA.debugLine="End Sub";
return "";
}
public static String  _btn_setup_click() throws Exception{
 //BA.debugLineNum = 179;BA.debugLine="Sub Btn_setup_Click";
 //BA.debugLineNum = 182;BA.debugLine="Phone1=\"0623682403\"";
mostCurrent._phone1 = "0623682403";
 //BA.debugLineNum = 183;BA.debugLine="Phone2=\"0612484116\"";
mostCurrent._phone2 = "0612484116";
 //BA.debugLineNum = 184;BA.debugLine="Admin_Code=\"123456\"";
mostCurrent._admin_code = "123456";
 //BA.debugLineNum = 185;BA.debugLine="Admin_Message1=\"La porte a été déverouillée par \"";
mostCurrent._admin_message1 = "La porte a été déverouillée par ";
 //BA.debugLineNum = 186;BA.debugLine="Admin_Message2=\"\"";
mostCurrent._admin_message2 = "";
 //BA.debugLineNum = 187;BA.debugLine="Localisation=\"Caudebec\"";
mostCurrent._localisation = "Caudebec";
 //BA.debugLineNum = 188;BA.debugLine="Welcome_Message1=\"Le portail va se déverrouiller";
mostCurrent._welcome_message1 = "Le portail va se déverrouiller à 3 reprises. Géraldine et Francois vous souhaitent un excellent séjour.";
 //BA.debugLineNum = 189;BA.debugLine="Welcome_Message2=\"\"";
mostCurrent._welcome_message2 = "";
 //BA.debugLineNum = 190;BA.debugLine="Welcome_Message3=\"\"";
mostCurrent._welcome_message3 = "";
 //BA.debugLineNum = 191;BA.debugLine="ActivePhone1=True";
_activephone1 = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 192;BA.debugLine="ActivePhone2=False";
_activephone2 = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 193;BA.debugLine="Wifi_Enable=False";
_wifi_enable = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 194;BA.debugLine="BLE_Enable=False";
_ble_enable = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 196;BA.debugLine="create_Setup_JsonFile";
_create_setup_jsonfile();
 //BA.debugLineNum = 197;BA.debugLine="End Sub";
return "";
}
public static String  _btn_start_click() throws Exception{
 //BA.debugLineNum = 175;BA.debugLine="Sub Btn_start_Click";
 //BA.debugLineNum = 176;BA.debugLine="CallSub3(Starter, \"Beep\", 5000, 1000)";
anywheresoftware.b4a.keywords.Common.CallSubNew3(processBA,(Object)(mostCurrent._starter.getObject()),"Beep",(Object)(5000),(Object)(1000));
 //BA.debugLineNum = 177;BA.debugLine="End Sub";
return "";
}
public static String  _create_host_jsonfile() throws Exception{
anywheresoftware.b4a.objects.collections.Map _map1 = null;
anywheresoftware.b4a.objects.collections.Map _m = null;
anywheresoftware.b4a.objects.collections.Map _ident_loc = null;
 //BA.debugLineNum = 82;BA.debugLine="Sub create_Host_JsonFile";
 //BA.debugLineNum = 85;BA.debugLine="Dim Map1 As Map";
_map1 = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 87;BA.debugLine="Dim m As Map";
_m = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 88;BA.debugLine="Dim Ident_Loc As Map";
_ident_loc = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 90;BA.debugLine="m.Initialize";
_m.Initialize();
 //BA.debugLineNum = 91;BA.debugLine="m.Put(\"StartDate\", Start_Date)";
_m.Put((Object)("StartDate"),(Object)(_start_date));
 //BA.debugLineNum = 92;BA.debugLine="m.Put(\"StopDate\", Stop_Date)";
_m.Put((Object)("StopDate"),(Object)(_stop_date));
 //BA.debugLineNum = 93;BA.debugLine="m.Put(\"StartTime\", Start_Time)";
_m.Put((Object)("StartTime"),(Object)(_start_time));
 //BA.debugLineNum = 94;BA.debugLine="m.Put(\"stopTime\", Stop_Time)";
_m.Put((Object)("stopTime"),(Object)(_stop_time));
 //BA.debugLineNum = 96;BA.debugLine="RentalId=Rnd(100000,999999)";
mostCurrent._rentalid = BA.NumberToString(anywheresoftware.b4a.keywords.Common.Rnd((int) (100000),(int) (999999)));
 //BA.debugLineNum = 98;BA.debugLine="Ident_Loc.Initialize";
_ident_loc.Initialize();
 //BA.debugLineNum = 99;BA.debugLine="Ident_Loc.Put(\"FirstName\",First_Name)";
_ident_loc.Put((Object)("FirstName"),(Object)(mostCurrent._first_name));
 //BA.debugLineNum = 100;BA.debugLine="Ident_Loc.Put(\"LastName\",Last_Name)";
_ident_loc.Put((Object)("LastName"),(Object)(mostCurrent._last_name));
 //BA.debugLineNum = 101;BA.debugLine="Ident_Loc.Put(\"Email\",Email)";
_ident_loc.Put((Object)("Email"),(Object)(mostCurrent._email));
 //BA.debugLineNum = 102;BA.debugLine="Ident_Loc.Put(\"Phone\",Phone)";
_ident_loc.Put((Object)("Phone"),(Object)(mostCurrent._phone));
 //BA.debugLineNum = 103;BA.debugLine="Ident_Loc.Put(\"City\",City)";
_ident_loc.Put((Object)("City"),(Object)(mostCurrent._city));
 //BA.debugLineNum = 104;BA.debugLine="Ident_Loc.Put(\"DoorCode\",Door_Code)";
_ident_loc.Put((Object)("DoorCode"),(Object)(mostCurrent._door_code));
 //BA.debugLineNum = 105;BA.debugLine="Ident_Loc.Put(\"Reserved\",m)";
_ident_loc.Put((Object)("Reserved"),(Object)(_m.getObject()));
 //BA.debugLineNum = 109;BA.debugLine="jg.Initialize(CreateMap( RentalId :Ident_Loc))";
mostCurrent._jg.Initialize(anywheresoftware.b4a.keywords.Common.createMap(new Object[] {(Object)(mostCurrent._rentalid),(Object)(_ident_loc.getObject())}));
 //BA.debugLineNum = 111;BA.debugLine="Log(jg.ToPrettyString(4))";
anywheresoftware.b4a.keywords.Common.LogImpl("11048605",mostCurrent._jg.ToPrettyString((int) (4)),0);
 //BA.debugLineNum = 113;BA.debugLine="File.WriteString(File.DirDefaultExternal,\"Base.js";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal(),"Base.json",mostCurrent._jg.ToPrettyString((int) (4)));
 //BA.debugLineNum = 114;BA.debugLine="JSON.Initialize(File.ReadString(File.DirDefaultEx";
mostCurrent._json.Initialize(anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal(),"Base.json"));
 //BA.debugLineNum = 115;BA.debugLine="Map1.Initialize";
_map1.Initialize();
 //BA.debugLineNum = 116;BA.debugLine="Map1 = JSON.NextObject";
_map1 = mostCurrent._json.NextObject();
 //BA.debugLineNum = 120;BA.debugLine="End Sub";
return "";
}
public static String  _create_setup_jsonfile() throws Exception{
anywheresoftware.b4a.objects.collections.Map _map1 = null;
anywheresoftware.b4a.objects.collections.Map _host = null;
anywheresoftware.b4a.objects.collections.Map _g_admin = null;
anywheresoftware.b4a.objects.collections.Map _android_admin = null;
 //BA.debugLineNum = 122;BA.debugLine="Sub create_Setup_JsonFile";
 //BA.debugLineNum = 139;BA.debugLine="Dim Map1 As Map";
_map1 = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 141;BA.debugLine="Dim Host As Map";
_host = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 142;BA.debugLine="Dim G_Admin As Map";
_g_admin = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 143;BA.debugLine="Dim Android_Admin As Map";
_android_admin = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 145;BA.debugLine="Host.Initialize";
_host.Initialize();
 //BA.debugLineNum = 146;BA.debugLine="Host.Put(\"Welcome_Message1\", Welcome_Message1)";
_host.Put((Object)("Welcome_Message1"),(Object)(mostCurrent._welcome_message1));
 //BA.debugLineNum = 147;BA.debugLine="Host.Put(\"Welcome_Message2\", Welcome_Message2)";
_host.Put((Object)("Welcome_Message2"),(Object)(mostCurrent._welcome_message2));
 //BA.debugLineNum = 148;BA.debugLine="Host.Put(\"Welcome_Message3\", Welcome_Message3)";
_host.Put((Object)("Welcome_Message3"),(Object)(mostCurrent._welcome_message3));
 //BA.debugLineNum = 150;BA.debugLine="G_Admin.Initialize";
_g_admin.Initialize();
 //BA.debugLineNum = 151;BA.debugLine="G_Admin.Put(\"Phone1\",Phone1)";
_g_admin.Put((Object)("Phone1"),(Object)(mostCurrent._phone1));
 //BA.debugLineNum = 152;BA.debugLine="G_Admin.Put(\"ActivePhone1\",ActivePhone1)";
_g_admin.Put((Object)("ActivePhone1"),(Object)(_activephone1));
 //BA.debugLineNum = 153;BA.debugLine="G_Admin.Put(\"Phone2\",Phone2)";
_g_admin.Put((Object)("Phone2"),(Object)(mostCurrent._phone2));
 //BA.debugLineNum = 154;BA.debugLine="G_Admin.Put(\"ActivePhone2\",ActivePhone2)";
_g_admin.Put((Object)("ActivePhone2"),(Object)(_activephone2));
 //BA.debugLineNum = 155;BA.debugLine="G_Admin.Put(\"Admin_Code\",Admin_Code)";
_g_admin.Put((Object)("Admin_Code"),(Object)(mostCurrent._admin_code));
 //BA.debugLineNum = 156;BA.debugLine="G_Admin.Put(\"Admin_Message1\",Admin_Message1)";
_g_admin.Put((Object)("Admin_Message1"),(Object)(mostCurrent._admin_message1));
 //BA.debugLineNum = 157;BA.debugLine="G_Admin.Put(\"Admin_Message2\",Admin_Message2)";
_g_admin.Put((Object)("Admin_Message2"),(Object)(mostCurrent._admin_message2));
 //BA.debugLineNum = 158;BA.debugLine="G_Admin.Put(\"Localisation\",Localisation)";
_g_admin.Put((Object)("Localisation"),(Object)(mostCurrent._localisation));
 //BA.debugLineNum = 160;BA.debugLine="Android_Admin.Initialize";
_android_admin.Initialize();
 //BA.debugLineNum = 161;BA.debugLine="Android_Admin.Put(\"Wifi\",Wifi_Enable)";
_android_admin.Put((Object)("Wifi"),(Object)(_wifi_enable));
 //BA.debugLineNum = 162;BA.debugLine="Android_Admin.Put(\"BLE\",BLE_Enable)";
_android_admin.Put((Object)("BLE"),(Object)(_ble_enable));
 //BA.debugLineNum = 163;BA.debugLine="Android_Admin.Put(\"BatteryLevel\",Battery_Level)";
_android_admin.Put((Object)("BatteryLevel"),(Object)(mostCurrent._battery_level));
 //BA.debugLineNum = 165;BA.debugLine="jg.Initialize(CreateMap( \"GeneralAdmin\" :G_Admin,";
mostCurrent._jg.Initialize(anywheresoftware.b4a.keywords.Common.createMap(new Object[] {(Object)("GeneralAdmin"),(Object)(_g_admin.getObject()),(Object)("HostService"),(Object)(_host.getObject()),(Object)("AndroidAdmin"),(Object)(_android_admin.getObject())}));
 //BA.debugLineNum = 167;BA.debugLine="Log(jg.ToPrettyString(4))";
anywheresoftware.b4a.keywords.Common.LogImpl("11114157",mostCurrent._jg.ToPrettyString((int) (4)),0);
 //BA.debugLineNum = 169;BA.debugLine="File.WriteString(File.DirDefaultExternal,\"Setup.j";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal(),"Setup.json",mostCurrent._jg.ToPrettyString((int) (4)));
 //BA.debugLineNum = 172;BA.debugLine="End Sub";
return "";
}
public static String  _globals() throws Exception{
 //BA.debugLineNum = 22;BA.debugLine="Sub Globals";
 //BA.debugLineNum = 26;BA.debugLine="Private Btn_start As B4XView";
mostCurrent._btn_start = new anywheresoftware.b4a.objects.B4XViewWrapper();
 //BA.debugLineNum = 27;BA.debugLine="Dim jg As JSONGenerator";
mostCurrent._jg = new anywheresoftware.b4a.objects.collections.JSONParser.JSONGenerator();
 //BA.debugLineNum = 28;BA.debugLine="Dim JSON As JSONParser";
mostCurrent._json = new anywheresoftware.b4a.objects.collections.JSONParser();
 //BA.debugLineNum = 29;BA.debugLine="Dim Start_Date, Stop_Date, Start_Time, Stop_Time";
_start_date = 0L;
_stop_date = 0L;
_start_time = 0L;
_stop_time = 0L;
 //BA.debugLineNum = 30;BA.debugLine="Dim First_Name, Last_Name, Email, Phone, City, Do";
mostCurrent._first_name = "";
mostCurrent._last_name = "";
mostCurrent._email = "";
mostCurrent._phone = "";
mostCurrent._city = "";
mostCurrent._door_code = "";
 //BA.debugLineNum = 31;BA.debugLine="Dim RentalId As String";
mostCurrent._rentalid = "";
 //BA.debugLineNum = 32;BA.debugLine="Dim Phone1,Phone2,Admin_Code,Admin_Message1,Admin";
mostCurrent._phone1 = "";
mostCurrent._phone2 = "";
mostCurrent._admin_code = "";
mostCurrent._admin_message1 = "";
mostCurrent._admin_message2 = "";
mostCurrent._localisation = "";
mostCurrent._welcome_message1 = "";
mostCurrent._welcome_message2 = "";
mostCurrent._welcome_message3 = "";
mostCurrent._battery_level = "";
 //BA.debugLineNum = 33;BA.debugLine="Dim Wifi_Enable, BLE_Enable As Boolean";
_wifi_enable = false;
_ble_enable = false;
 //BA.debugLineNum = 34;BA.debugLine="Dim ActivePhone1,ActivePhone2 As Boolean=False";
_activephone1 = false;
_activephone2 = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 35;BA.debugLine="Private Btn_setup As B4XView";
mostCurrent._btn_setup = new anywheresoftware.b4a.objects.B4XViewWrapper();
 //BA.debugLineNum = 36;BA.debugLine="Dim Ui As XUI";
mostCurrent._ui = new anywheresoftware.b4a.objects.B4XViewWrapper.XUI();
 //BA.debugLineNum = 37;BA.debugLine="Private Btn_read_setup As B4XView";
mostCurrent._btn_read_setup = new anywheresoftware.b4a.objects.B4XViewWrapper();
 //BA.debugLineNum = 38;BA.debugLine="End Sub";
return "";
}

public static void initializeProcessGlobals() {
    
    if (main.processGlobalsRun == false) {
	    main.processGlobalsRun = true;
		try {
		        main._process_globals();
starter._process_globals();
agent._process_globals();
param._process_globals();
s1._process_globals();
		
        } catch (Exception e) {
			throw new RuntimeException(e);
		}
    }
}public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 17;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 20;BA.debugLine="End Sub";
return "";
}
}
