package com.smartboard.sdms.agent;


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, "com.smartboard.sdms.agent", "com.smartboard.sdms.agent.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, "com.smartboard.sdms.agent", "com.smartboard.sdms.agent.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, "com.smartboard.sdms.agent.main", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density, mostCurrent);
			_activity.reinitializeForShell(activityBA, "activity");
		}
        initializeProcessGlobals();		
        initializeGlobals();
        
        BA.LogInfo("** Activity (main) Create " + (isFirst ? "(first time)" : "") + " **");
        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 static String _serverurl = "";
public anywheresoftware.b4a.objects.LabelWrapper _lblstatus = null;
public anywheresoftware.b4a.objects.PanelWrapper _pnlregistration = null;
public anywheresoftware.b4a.objects.EditTextWrapper _txtdevicename = null;
public anywheresoftware.b4a.objects.ButtonWrapper _btnregister = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblregtitle = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblregprompt = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblregdeviceid = null;
public com.smartboard.sdms.agent.starter _starter = null;
public com.smartboard.sdms.agent.messageservice _messageservice = null;
public com.smartboard.sdms.agent.broadcastdisplay _broadcastdisplay = null;
public com.smartboard.sdms.agent.httputils2service _httputils2service = null;

public static boolean isAnyActivityVisible() {
    boolean vis = false;
vis = vis | (main.mostCurrent != null);
vis = vis | (broadcastdisplay.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(com.smartboard.sdms.agent.main parent,boolean _firsttime) {
this.parent = parent;
this._firsttime = _firsttime;
}
com.smartboard.sdms.agent.main parent;
boolean _firsttime;
anywheresoftware.b4a.objects.RuntimePermissions _rp = null;
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 = 41;BA.debugLine="Activity.Color = Colors.White";
parent.mostCurrent._activity.setColor(anywheresoftware.b4a.keywords.Common.Colors.White);
 //BA.debugLineNum = 44;BA.debugLine="lblStatus.Initialize(\"\")";
parent.mostCurrent._lblstatus.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 45;BA.debugLine="lblStatus.Text = \"Status: Initializing...\"";
parent.mostCurrent._lblstatus.setText(BA.ObjectToCharSequence("Status: Initializing..."));
 //BA.debugLineNum = 46;BA.debugLine="lblStatus.TextSize = 14";
parent.mostCurrent._lblstatus.setTextSize((float) (14));
 //BA.debugLineNum = 47;BA.debugLine="lblStatus.TextColor = Colors.Black";
parent.mostCurrent._lblstatus.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 48;BA.debugLine="lblStatus.Gravity = Gravity.CENTER";
parent.mostCurrent._lblstatus.setGravity(anywheresoftware.b4a.keywords.Common.Gravity.CENTER);
 //BA.debugLineNum = 49;BA.debugLine="Activity.AddView(lblStatus, 0, 0, 100%x, 50dip)";
parent.mostCurrent._activity.AddView((android.view.View)(parent.mostCurrent._lblstatus.getObject()),(int) (0),(int) (0),anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (100),mostCurrent.activityBA),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (50)));
 //BA.debugLineNum = 52;BA.debugLine="If FirstTime Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_firsttime) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 53;BA.debugLine="RequestBatteryOptimizationExemption";
_requestbatteryoptimizationexemption();
 //BA.debugLineNum = 54;BA.debugLine="PromptForAutoStart";
_promptforautostart();
 if (true) break;

case 4:
//C
this.state = 5;
;
 //BA.debugLineNum = 58;BA.debugLine="lblStatus.Text = \"Status: Checking registration..";
parent.mostCurrent._lblstatus.setText(BA.ObjectToCharSequence("Status: Checking registration..."));
 //BA.debugLineNum = 59;BA.debugLine="CheckRegistration";
_checkregistration();
 //BA.debugLineNum = 62;BA.debugLine="Dim rp As RuntimePermissions";
_rp = new anywheresoftware.b4a.objects.RuntimePermissions();
 //BA.debugLineNum = 63;BA.debugLine="rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_S";
_rp.CheckAndRequest(processBA,_rp.PERMISSION_WRITE_EXTERNAL_STORAGE);
 //BA.debugLineNum = 64;BA.debugLine="Wait For Activity_PermissionResult (Permission As";
anywheresoftware.b4a.keywords.Common.WaitFor("activity_permissionresult", processBA, this, null);
this.state = 12;
return;
case 12:
//C
this.state = 5;
_permission = (String) result[0];
_result = (Boolean) result[1];
;
 //BA.debugLineNum = 65;BA.debugLine="If Not(Result) Then";
if (true) break;

case 5:
//if
this.state = 8;
if (anywheresoftware.b4a.keywords.Common.Not(_result)) { 
this.state = 7;
}if (true) break;

case 7:
//C
this.state = 8;
 //BA.debugLineNum = 66;BA.debugLine="ToastMessageShow(\"Storage permission is required";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Storage permission is required to download content"),anywheresoftware.b4a.keywords.Common.True);
 if (true) break;
;
 //BA.debugLineNum = 70;BA.debugLine="If FirstTime Then";

case 8:
//if
this.state = 11;
if (_firsttime) { 
this.state = 10;
}if (true) break;

case 10:
//C
this.state = 11;
 //BA.debugLineNum = 71;BA.debugLine="CheckOverlayPermission";
_checkoverlaypermission();
 //BA.debugLineNum = 72;BA.debugLine="CheckAllFilesAccessPermission";
_checkallfilesaccesspermission();
 if (true) break;

case 11:
//C
this.state = -1;
;
 //BA.debugLineNum = 76;BA.debugLine="EnableScreenCapture";
_enablescreencapture();
 //BA.debugLineNum = 79;BA.debugLine="RequestMediaProjectionPermission";
_requestmediaprojectionpermission();
 //BA.debugLineNum = 80;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 = 185;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
 //BA.debugLineNum = 186;BA.debugLine="End Sub";
return "";
}
public static String  _activity_result(int _requestcode,int _resultcode,anywheresoftware.b4a.objects.IntentWrapper _data) throws Exception{
 //BA.debugLineNum = 158;BA.debugLine="Sub Activity_Result (RequestCode As Int, ResultCod";
 //BA.debugLineNum = 160;BA.debugLine="Log(\"Main: Activity_Result - RequestCode: \" & Req";
anywheresoftware.b4a.keywords.Common.LogImpl("4393218","Main: Activity_Result - RequestCode: "+BA.NumberToString(_requestcode)+", ResultCode: "+BA.NumberToString(_resultcode),0);
 //BA.debugLineNum = 162;BA.debugLine="If RequestCode = 1001 Then";
if (_requestcode==1001) { 
 //BA.debugLineNum = 163;BA.debugLine="If ResultCode = -1 Then";
if (_resultcode==-1) { 
 //BA.debugLineNum = 164;BA.debugLine="Log(\"MediaProjection permission granted!\")";
anywheresoftware.b4a.keywords.Common.LogImpl("4393222","MediaProjection permission granted!",0);
 //BA.debugLineNum = 165;BA.debugLine="Starter.ProjectionResultCode = ResultCode";
mostCurrent._starter._projectionresultcode /*int*/  = _resultcode;
 //BA.debugLineNum = 166;BA.debugLine="Starter.ProjectionData = Data";
mostCurrent._starter._projectiondata /*anywheresoftware.b4a.objects.IntentWrapper*/  = _data;
 //BA.debugLineNum = 168;BA.debugLine="ToastMessageShow(\"Screen capture authorized\", F";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Screen capture authorized"),anywheresoftware.b4a.keywords.Common.False);
 }else {
 //BA.debugLineNum = 170;BA.debugLine="Log(\"MediaProjection permission denied.\")";
anywheresoftware.b4a.keywords.Common.LogImpl("4393228","MediaProjection permission denied.",0);
 //BA.debugLineNum = 171;BA.debugLine="ToastMessageShow(\"Screen capture permission den";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Screen capture permission denied"),anywheresoftware.b4a.keywords.Common.True);
 };
 };
 //BA.debugLineNum = 174;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
 //BA.debugLineNum = 182;BA.debugLine="Sub Activity_Resume";
 //BA.debugLineNum = 183;BA.debugLine="End Sub";
return "";
}
public static String  _btnregister_click() throws Exception{
String _devicename = "";
 //BA.debugLineNum = 209;BA.debugLine="Sub btnRegister_Click";
 //BA.debugLineNum = 211;BA.debugLine="Dim deviceName As String = txtDeviceName.Text.Tri";
_devicename = mostCurrent._txtdevicename.getText().trim();
 //BA.debugLineNum = 213;BA.debugLine="If deviceName.Length < 3 Then";
if (_devicename.length()<3) { 
 //BA.debugLineNum = 214;BA.debugLine="ToastMessageShow(\"Device name must be at least 3";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Device name must be at least 3 characters"),anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 215;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 219;BA.debugLine="btnRegister.Enabled = False";
mostCurrent._btnregister.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 220;BA.debugLine="btnRegister.Text = \"Registering...\"";
mostCurrent._btnregister.setText(BA.ObjectToCharSequence("Registering..."));
 //BA.debugLineNum = 223;BA.debugLine="RegisterDevice(deviceName)";
_registerdevice(_devicename);
 //BA.debugLineNum = 224;BA.debugLine="End Sub";
return "";
}
public static void  _checkallfilesaccesspermission() throws Exception{
ResumableSub_CheckAllFilesAccessPermission rsub = new ResumableSub_CheckAllFilesAccessPermission(null);
rsub.resume(processBA, null);
}
public static class ResumableSub_CheckAllFilesAccessPermission extends BA.ResumableSub {
public ResumableSub_CheckAllFilesAccessPermission(com.smartboard.sdms.agent.main parent) {
this.parent = parent;
}
com.smartboard.sdms.agent.main parent;
anywheresoftware.b4a.phone.Phone _p = null;
anywheresoftware.b4j.object.JavaObject _jo = null;
boolean _isexternalmanager = false;
int _result = 0;
anywheresoftware.b4a.objects.IntentWrapper _i = null;
anywheresoftware.b4a.objects.RuntimePermissions _rp = null;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
try {

        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
 //BA.debugLineNum = 111;BA.debugLine="Try";
if (true) break;

case 1:
//try
this.state = 20;
this.catchState = 19;
this.state = 3;
if (true) break;

case 3:
//C
this.state = 4;
this.catchState = 19;
 //BA.debugLineNum = 112;BA.debugLine="Dim p As Phone";
_p = new anywheresoftware.b4a.phone.Phone();
 //BA.debugLineNum = 113;BA.debugLine="If p.SdkVersion >= 30 Then ' Android 11+";
if (true) break;

case 4:
//if
this.state = 17;
if (_p.getSdkVersion()>=30) { 
this.state = 6;
}if (true) break;

case 6:
//C
this.state = 7;
 //BA.debugLineNum = 114;BA.debugLine="Dim jo As JavaObject";
_jo = new anywheresoftware.b4j.object.JavaObject();
 //BA.debugLineNum = 115;BA.debugLine="jo.InitializeStatic(\"android.os.Environment\")";
_jo.InitializeStatic("android.os.Environment");
 //BA.debugLineNum = 116;BA.debugLine="Dim isExternalManager As Boolean = jo.RunMethod";
_isexternalmanager = BA.ObjectToBoolean(_jo.RunMethod("isExternalStorageManager",(Object[])(anywheresoftware.b4a.keywords.Common.Null)));
 //BA.debugLineNum = 118;BA.debugLine="If Not(isExternalManager) Then";
if (true) break;

case 7:
//if
this.state = 16;
if (anywheresoftware.b4a.keywords.Common.Not(_isexternalmanager)) { 
this.state = 9;
}else {
this.state = 15;
}if (true) break;

case 9:
//C
this.state = 10;
 //BA.debugLineNum = 119;BA.debugLine="Log(\"Main: All Files Access NOT granted. Promp";
anywheresoftware.b4a.keywords.Common.LogImpl("4262153","Main: All Files Access NOT granted. Prompting user...",0);
 //BA.debugLineNum = 120;BA.debugLine="Msgbox2Async(\"This app requires 'All Files Acc";
anywheresoftware.b4a.keywords.Common.Msgbox2Async(BA.ObjectToCharSequence("This app requires 'All Files Access' to manage content on this device. Please allow access in the next screen."),BA.ObjectToCharSequence("Storage Permission"),"Open Settings","Later","",(anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper(), (android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null)),processBA,anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 121;BA.debugLine="Wait For Msgbox_Result (Result As Int)";
anywheresoftware.b4a.keywords.Common.WaitFor("msgbox_result", processBA, this, null);
this.state = 21;
return;
case 21:
//C
this.state = 10;
_result = (Integer) result[0];
;
 //BA.debugLineNum = 122;BA.debugLine="If Result = DialogResponse.POSITIVE Then";
if (true) break;

case 10:
//if
this.state = 13;
if (_result==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
this.state = 12;
}if (true) break;

case 12:
//C
this.state = 13;
 //BA.debugLineNum = 123;BA.debugLine="Dim i As Intent";
_i = new anywheresoftware.b4a.objects.IntentWrapper();
 //BA.debugLineNum = 124;BA.debugLine="i.Initialize(\"android.settings.MANAGE_APP_ALL";
_i.Initialize("android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION","package:"+anywheresoftware.b4a.keywords.Common.Application.getPackageName());
 //BA.debugLineNum = 125;BA.debugLine="StartActivity(i)";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)(_i.getObject()));
 if (true) break;

case 13:
//C
this.state = 16;
;
 if (true) break;

case 15:
//C
this.state = 16;
 //BA.debugLineNum = 128;BA.debugLine="Log(\"Main: All Files Access already granted\")";
anywheresoftware.b4a.keywords.Common.LogImpl("4262162","Main: All Files Access already granted",0);
 if (true) break;

case 16:
//C
this.state = 17;
;
 if (true) break;

case 17:
//C
this.state = 20;
;
 if (true) break;

case 19:
//C
this.state = 20;
this.catchState = 0;
 //BA.debugLineNum = 132;BA.debugLine="Log(\"Error checking all files access: \" & LastEx";
anywheresoftware.b4a.keywords.Common.LogImpl("4262166","Error checking all files access: "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(mostCurrent.activityBA)),0);
 //BA.debugLineNum = 134;BA.debugLine="Dim rp As RuntimePermissions";
_rp = new anywheresoftware.b4a.objects.RuntimePermissions();
 //BA.debugLineNum = 135;BA.debugLine="rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_";
_rp.CheckAndRequest(processBA,_rp.PERMISSION_WRITE_EXTERNAL_STORAGE);
 if (true) break;
if (true) break;

case 20:
//C
this.state = -1;
this.catchState = 0;
;
 //BA.debugLineNum = 137;BA.debugLine="End Sub";
if (true) break;
}} 
       catch (Exception e0) {
			
if (catchState == 0)
    throw e0;
else {
    state = catchState;
processBA.setLastException(e0);}
            }
        }
    }
}
public static void  _msgbox_result(int _result) throws Exception{
}
public static void  _checkoverlaypermission() throws Exception{
ResumableSub_CheckOverlayPermission rsub = new ResumableSub_CheckOverlayPermission(null);
rsub.resume(processBA, null);
}
public static class ResumableSub_CheckOverlayPermission extends BA.ResumableSub {
public ResumableSub_CheckOverlayPermission(com.smartboard.sdms.agent.main parent) {
this.parent = parent;
}
com.smartboard.sdms.agent.main parent;
anywheresoftware.b4a.phone.Phone _p = null;
anywheresoftware.b4j.object.JavaObject _jo = null;
anywheresoftware.b4j.object.JavaObject _context = null;
boolean _candraw = false;
int _result = 0;
anywheresoftware.b4a.objects.IntentWrapper _i = null;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
try {

        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
 //BA.debugLineNum = 83;BA.debugLine="Try";
if (true) break;

case 1:
//try
this.state = 20;
this.catchState = 19;
this.state = 3;
if (true) break;

case 3:
//C
this.state = 4;
this.catchState = 19;
 //BA.debugLineNum = 84;BA.debugLine="Dim p As Phone";
_p = new anywheresoftware.b4a.phone.Phone();
 //BA.debugLineNum = 85;BA.debugLine="If p.SdkVersion >= 23 Then";
if (true) break;

case 4:
//if
this.state = 17;
if (_p.getSdkVersion()>=23) { 
this.state = 6;
}if (true) break;

case 6:
//C
this.state = 7;
 //BA.debugLineNum = 86;BA.debugLine="Dim jo As JavaObject";
_jo = new anywheresoftware.b4j.object.JavaObject();
 //BA.debugLineNum = 87;BA.debugLine="jo.InitializeStatic(\"android.provider.Settings\"";
_jo.InitializeStatic("android.provider.Settings");
 //BA.debugLineNum = 88;BA.debugLine="Dim context As JavaObject";
_context = new anywheresoftware.b4j.object.JavaObject();
 //BA.debugLineNum = 89;BA.debugLine="context.InitializeContext";
_context.InitializeContext(processBA);
 //BA.debugLineNum = 90;BA.debugLine="Dim canDraw As Boolean = jo.RunMethod(\"canDrawO";
_candraw = BA.ObjectToBoolean(_jo.RunMethod("canDrawOverlays",new Object[]{(Object)(_context.getObject())}));
 //BA.debugLineNum = 92;BA.debugLine="If Not(canDraw) Then";
if (true) break;

case 7:
//if
this.state = 16;
if (anywheresoftware.b4a.keywords.Common.Not(_candraw)) { 
this.state = 9;
}else {
this.state = 15;
}if (true) break;

case 9:
//C
this.state = 10;
 //BA.debugLineNum = 93;BA.debugLine="Log(\"Main: Overlay permission NOT granted. Pro";
anywheresoftware.b4a.keywords.Common.LogImpl("4196619","Main: Overlay permission NOT granted. Prompting user...",0);
 //BA.debugLineNum = 94;BA.debugLine="Msgbox2Async(\"This app requires 'Display over";
anywheresoftware.b4a.keywords.Common.Msgbox2Async(BA.ObjectToCharSequence("This app requires 'Display over other apps' permission to show priority broadcast messages. Please enable it in the next screen."),BA.ObjectToCharSequence("Permission Required"),"Open Settings","Later","",(anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper(), (android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null)),processBA,anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 95;BA.debugLine="Wait For Msgbox_Result (Result As Int)";
anywheresoftware.b4a.keywords.Common.WaitFor("msgbox_result", processBA, this, null);
this.state = 21;
return;
case 21:
//C
this.state = 10;
_result = (Integer) result[0];
;
 //BA.debugLineNum = 96;BA.debugLine="If Result = DialogResponse.POSITIVE Then";
if (true) break;

case 10:
//if
this.state = 13;
if (_result==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
this.state = 12;
}if (true) break;

case 12:
//C
this.state = 13;
 //BA.debugLineNum = 97;BA.debugLine="Dim i As Intent";
_i = new anywheresoftware.b4a.objects.IntentWrapper();
 //BA.debugLineNum = 98;BA.debugLine="i.Initialize(\"android.settings.action.MANAGE_";
_i.Initialize("android.settings.action.MANAGE_OVERLAY_PERMISSION","package:"+anywheresoftware.b4a.keywords.Common.Application.getPackageName());
 //BA.debugLineNum = 99;BA.debugLine="StartActivity(i)";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)(_i.getObject()));
 if (true) break;

case 13:
//C
this.state = 16;
;
 if (true) break;

case 15:
//C
this.state = 16;
 //BA.debugLineNum = 102;BA.debugLine="Log(\"Main: Overlay permission already granted\"";
anywheresoftware.b4a.keywords.Common.LogImpl("4196628","Main: Overlay permission already granted",0);
 if (true) break;

case 16:
//C
this.state = 17;
;
 if (true) break;

case 17:
//C
this.state = 20;
;
 if (true) break;

case 19:
//C
this.state = 20;
this.catchState = 0;
 //BA.debugLineNum = 106;BA.debugLine="Log(\"Error checking overlay permission: \" & Last";
anywheresoftware.b4a.keywords.Common.LogImpl("4196632","Error checking overlay permission: "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(mostCurrent.activityBA)),0);
 if (true) break;
if (true) break;

case 20:
//C
this.state = -1;
this.catchState = 0;
;
 //BA.debugLineNum = 108;BA.debugLine="End Sub";
if (true) break;
}} 
       catch (Exception e0) {
			
if (catchState == 0)
    throw e0;
else {
    state = catchState;
processBA.setLastException(e0);}
            }
        }
    }
}
public static String  _checkregistration() throws Exception{
com.smartboard.sdms.agent.httpjob _job = null;
 //BA.debugLineNum = 176;BA.debugLine="Sub CheckRegistration";
 //BA.debugLineNum = 177;BA.debugLine="Dim job As HttpJob";
_job = new com.smartboard.sdms.agent.httpjob();
 //BA.debugLineNum = 178;BA.debugLine="job.Initialize(\"check_main\", Me)";
_job._initialize /*String*/ (processBA,"check_main",main.getObject());
 //BA.debugLineNum = 179;BA.debugLine="job.Download(ServerURL & \"/devices/check?device_i";
_job._download /*String*/ (_serverurl+"/devices/check?device_id="+_getdeviceid());
 //BA.debugLineNum = 180;BA.debugLine="End Sub";
return "";
}
public static String  _disablescreencapture() throws Exception{
anywheresoftware.b4a.agraham.reflection.Reflection _r = null;
Object _act = null;
anywheresoftware.b4j.object.JavaObject _jo = null;
anywheresoftware.b4j.object.JavaObject _window = null;
 //BA.debugLineNum = 464;BA.debugLine="Sub DisableScreenCapture";
 //BA.debugLineNum = 465;BA.debugLine="Try";
try { //BA.debugLineNum = 466;BA.debugLine="Dim r As Reflector";
_r = new anywheresoftware.b4a.agraham.reflection.Reflection();
 //BA.debugLineNum = 467;BA.debugLine="Dim act As Object = r.GetActivity";
_act = (Object)(_r.GetActivity(processBA));
 //BA.debugLineNum = 468;BA.debugLine="Dim jo As JavaObject = act";
_jo = new anywheresoftware.b4j.object.JavaObject();
_jo = (anywheresoftware.b4j.object.JavaObject) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4j.object.JavaObject(), (java.lang.Object)(_act));
 //BA.debugLineNum = 469;BA.debugLine="Dim window As JavaObject = jo.RunMethod(\"getWind";
_window = new anywheresoftware.b4j.object.JavaObject();
_window = (anywheresoftware.b4j.object.JavaObject) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4j.object.JavaObject(), (java.lang.Object)(_jo.RunMethod("getWindow",(Object[])(anywheresoftware.b4a.keywords.Common.Null))));
 //BA.debugLineNum = 470;BA.debugLine="window.RunMethod(\"setFlags\", Array(0x00002000, 0";
_window.RunMethod("setFlags",new Object[]{(Object)(((int)0x00002000)),(Object)(((int)0x00002000))});
 //BA.debugLineNum = 471;BA.debugLine="Log(\"Screen capture DISABLED for this activity\")";
anywheresoftware.b4a.keywords.Common.LogImpl("41179655","Screen capture DISABLED for this activity",0);
 } 
       catch (Exception e9) {
			processBA.setLastException(e9); //BA.debugLineNum = 473;BA.debugLine="Log(\"Error disabling screen capture: \" & LastExc";
anywheresoftware.b4a.keywords.Common.LogImpl("41179657","Error disabling screen capture: "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(mostCurrent.activityBA)),0);
 };
 //BA.debugLineNum = 475;BA.debugLine="End Sub";
return "";
}
public static String  _enablescreencapture() throws Exception{
anywheresoftware.b4a.agraham.reflection.Reflection _r = null;
Object _act = null;
anywheresoftware.b4j.object.JavaObject _jo = null;
anywheresoftware.b4j.object.JavaObject _window = null;
 //BA.debugLineNum = 477;BA.debugLine="Sub EnableScreenCapture";
 //BA.debugLineNum = 478;BA.debugLine="Try";
try { //BA.debugLineNum = 479;BA.debugLine="Dim r As Reflector";
_r = new anywheresoftware.b4a.agraham.reflection.Reflection();
 //BA.debugLineNum = 480;BA.debugLine="Dim act As Object = r.GetActivity";
_act = (Object)(_r.GetActivity(processBA));
 //BA.debugLineNum = 481;BA.debugLine="Dim jo As JavaObject = act";
_jo = new anywheresoftware.b4j.object.JavaObject();
_jo = (anywheresoftware.b4j.object.JavaObject) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4j.object.JavaObject(), (java.lang.Object)(_act));
 //BA.debugLineNum = 482;BA.debugLine="Dim window As JavaObject = jo.RunMethod(\"getWind";
_window = new anywheresoftware.b4j.object.JavaObject();
_window = (anywheresoftware.b4j.object.JavaObject) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4j.object.JavaObject(), (java.lang.Object)(_jo.RunMethod("getWindow",(Object[])(anywheresoftware.b4a.keywords.Common.Null))));
 //BA.debugLineNum = 483;BA.debugLine="window.RunMethod(\"clearFlags\", Array(0x00002000)";
_window.RunMethod("clearFlags",new Object[]{(Object)(((int)0x00002000))});
 //BA.debugLineNum = 484;BA.debugLine="Log(\"Screen capture ENABLED for this activity\")";
anywheresoftware.b4a.keywords.Common.LogImpl("41245191","Screen capture ENABLED for this activity",0);
 } 
       catch (Exception e9) {
			processBA.setLastException(e9); //BA.debugLineNum = 486;BA.debugLine="Log(\"Error enabling screen capture: \" & LastExce";
anywheresoftware.b4a.keywords.Common.LogImpl("41245193","Error enabling screen capture: "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(mostCurrent.activityBA)),0);
 };
 //BA.debugLineNum = 488;BA.debugLine="End Sub";
return "";
}
public static String  _getdeviceid() throws Exception{
anywheresoftware.b4a.phone.Phone _p = null;
 //BA.debugLineNum = 457;BA.debugLine="Sub GetDeviceID As String";
 //BA.debugLineNum = 458;BA.debugLine="Dim p As Phone";
_p = new anywheresoftware.b4a.phone.Phone();
 //BA.debugLineNum = 459;BA.debugLine="Return p.GetSettings(\"android_id\")";
if (true) return _p.GetSettings("android_id");
 //BA.debugLineNum = 460;BA.debugLine="End Sub";
return "";
}
public static String  _globals() throws Exception{
 //BA.debugLineNum = 26;BA.debugLine="Sub Globals";
 //BA.debugLineNum = 28;BA.debugLine="Private lblStatus As Label";
mostCurrent._lblstatus = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 31;BA.debugLine="Private pnlRegistration As Panel";
mostCurrent._pnlregistration = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 32;BA.debugLine="Private txtDeviceName As EditText";
mostCurrent._txtdevicename = new anywheresoftware.b4a.objects.EditTextWrapper();
 //BA.debugLineNum = 33;BA.debugLine="Private btnRegister As Button";
mostCurrent._btnregister = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 34;BA.debugLine="Private lblRegTitle As Label";
mostCurrent._lblregtitle = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 35;BA.debugLine="Private lblRegPrompt As Label";
mostCurrent._lblregprompt = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 36;BA.debugLine="Private lblRegDeviceID As Label";
mostCurrent._lblregdeviceid = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 37;BA.debugLine="End Sub";
return "";
}
public static String  _jobdone(com.smartboard.sdms.agent.httpjob _job) throws Exception{
anywheresoftware.b4a.objects.collections.JSONParser _parser = null;
anywheresoftware.b4a.objects.collections.Map _root = null;
String _token = "";
anywheresoftware.b4a.objects.IntentWrapper _in = null;
 //BA.debugLineNum = 228;BA.debugLine="Sub JobDone(Job As HttpJob)";
 //BA.debugLineNum = 229;BA.debugLine="If Job.Success Then";
if (_job._success /*boolean*/ ) { 
 //BA.debugLineNum = 230;BA.debugLine="Try";
try { //BA.debugLineNum = 231;BA.debugLine="Dim parser As JSONParser";
_parser = new anywheresoftware.b4a.objects.collections.JSONParser();
 //BA.debugLineNum = 232;BA.debugLine="parser.Initialize(Job.GetString)";
_parser.Initialize(_job._getstring /*String*/ ());
 //BA.debugLineNum = 233;BA.debugLine="Dim root As Map = parser.NextObject";
_root = new anywheresoftware.b4a.objects.collections.Map();
_root = _parser.NextObject();
 //BA.debugLineNum = 235;BA.debugLine="Select Job.JobName";
switch (BA.switchObjectToInt(_job._jobname /*String*/ ,"check_main","register")) {
case 0: {
 //BA.debugLineNum = 237;BA.debugLine="If root.Get(\"registered\") = True Then";
if ((_root.Get((Object)("registered"))).equals((Object)(anywheresoftware.b4a.keywords.Common.True))) { 
 //BA.debugLineNum = 239;BA.debugLine="Dim token As String = root.Get(\"token\")";
_token = BA.ObjectToString(_root.Get((Object)("token")));
 //BA.debugLineNum = 240;BA.debugLine="File.WriteString(File.DirInternal, \"token.tx";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"token.txt",_token);
 //BA.debugLineNum = 241;BA.debugLine="File.WriteString(File.DirInternal, \"device_i";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"device_id.txt",BA.ObjectToString(_root.Get((Object)("device_id")))+"");
 //BA.debugLineNum = 243;BA.debugLine="lblStatus.Text = \"Status: Device registered\"";
mostCurrent._lblstatus.setText(BA.ObjectToCharSequence("Status: Device registered"));
 //BA.debugLineNum = 244;BA.debugLine="Log(\"Main: Device confirmed registered, star";
anywheresoftware.b4a.keywords.Common.LogImpl("4786448","Main: Device confirmed registered, starting MessageService",0);
 //BA.debugLineNum = 247;BA.debugLine="Dim in As Intent";
_in = new anywheresoftware.b4a.objects.IntentWrapper();
 //BA.debugLineNum = 248;BA.debugLine="in.Initialize(\"\", \"\")";
_in.Initialize("","");
 //BA.debugLineNum = 249;BA.debugLine="in.SetComponent(\"com.smartboard.sdms.agent/.";
_in.SetComponent("com.smartboard.sdms.agent/.messageservice");
 //BA.debugLineNum = 250;BA.debugLine="StartService(in)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(_in.getObject()));
 //BA.debugLineNum = 253;BA.debugLine="ToastMessageShow(\"SDMS Agent started in back";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("SDMS Agent started in background"),anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 254;BA.debugLine="Activity.Finish";
mostCurrent._activity.Finish();
 }else {
 //BA.debugLineNum = 257;BA.debugLine="Log(\"Main: Device not registered on server\")";
anywheresoftware.b4a.keywords.Common.LogImpl("4786461","Main: Device not registered on server",0);
 //BA.debugLineNum = 259;BA.debugLine="If File.Exists(File.DirInternal, \"token.txt\"";
if (anywheresoftware.b4a.keywords.Common.File.Exists(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"token.txt")) { 
anywheresoftware.b4a.keywords.Common.File.Delete(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"token.txt");};
 //BA.debugLineNum = 260;BA.debugLine="ShowRegistrationDialog";
_showregistrationdialog();
 };
 break; }
case 1: {
 //BA.debugLineNum = 264;BA.debugLine="If root.Get(\"success\") = True Then";
if ((_root.Get((Object)("success"))).equals((Object)(anywheresoftware.b4a.keywords.Common.True))) { 
 //BA.debugLineNum = 266;BA.debugLine="Dim token As String = root.Get(\"token\")";
_token = BA.ObjectToString(_root.Get((Object)("token")));
 //BA.debugLineNum = 267;BA.debugLine="File.WriteString(File.DirInternal, \"token.tx";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"token.txt",_token);
 //BA.debugLineNum = 268;BA.debugLine="File.WriteString(File.DirInternal, \"device_i";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"device_id.txt",BA.ObjectToString(_root.Get((Object)("device_id")))+"");
 //BA.debugLineNum = 270;BA.debugLine="lblStatus.Text = \"Status: Registered success";
mostCurrent._lblstatus.setText(BA.ObjectToCharSequence("Status: Registered successfully"));
 //BA.debugLineNum = 271;BA.debugLine="Log(\"Device registered successfully\")";
anywheresoftware.b4a.keywords.Common.LogImpl("4786475","Device registered successfully",0);
 //BA.debugLineNum = 274;BA.debugLine="If pnlRegistration.IsInitialized Then";
if (mostCurrent._pnlregistration.IsInitialized()) { 
 //BA.debugLineNum = 275;BA.debugLine="pnlRegistration.Visible = False";
mostCurrent._pnlregistration.setVisible(anywheresoftware.b4a.keywords.Common.False);
 };
 //BA.debugLineNum = 279;BA.debugLine="Dim in As Intent";
_in = new anywheresoftware.b4a.objects.IntentWrapper();
 //BA.debugLineNum = 280;BA.debugLine="in.Initialize(\"\", \"\")";
_in.Initialize("","");
 //BA.debugLineNum = 281;BA.debugLine="in.SetComponent(\"com.smartboard.sdms.agent/.";
_in.SetComponent("com.smartboard.sdms.agent/.messageservice");
 //BA.debugLineNum = 282;BA.debugLine="StartService(in)";
anywheresoftware.b4a.keywords.Common.StartService(processBA,(Object)(_in.getObject()));
 //BA.debugLineNum = 285;BA.debugLine="ToastMessageShow(\"Registration successful!\",";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Registration successful!"),anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 286;BA.debugLine="Activity.Finish";
mostCurrent._activity.Finish();
 }else {
 //BA.debugLineNum = 288;BA.debugLine="lblStatus.Text = \"Status: Registration faile";
mostCurrent._lblstatus.setText(BA.ObjectToCharSequence("Status: Registration failed - "+BA.ObjectToString(_root.Get((Object)("error")))));
 //BA.debugLineNum = 291;BA.debugLine="If btnRegister.IsInitialized Then";
if (mostCurrent._btnregister.IsInitialized()) { 
 //BA.debugLineNum = 292;BA.debugLine="btnRegister.Enabled = True";
mostCurrent._btnregister.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 293;BA.debugLine="btnRegister.Text = \"Register Device\"";
mostCurrent._btnregister.setText(BA.ObjectToCharSequence("Register Device"));
 };
 };
 break; }
}
;
 } 
       catch (Exception e50) {
			processBA.setLastException(e50); //BA.debugLineNum = 298;BA.debugLine="Log(\"JSON Parse Error: \" & LastException)";
anywheresoftware.b4a.keywords.Common.LogImpl("4786502","JSON Parse Error: "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(mostCurrent.activityBA)),0);
 //BA.debugLineNum = 299;BA.debugLine="lblStatus.Text = \"Status: Error - \" & LastExcep";
mostCurrent._lblstatus.setText(BA.ObjectToCharSequence("Status: Error - "+anywheresoftware.b4a.keywords.Common.LastException(mostCurrent.activityBA).getMessage()));
 //BA.debugLineNum = 302;BA.debugLine="If btnRegister.IsInitialized Then";
if (mostCurrent._btnregister.IsInitialized()) { 
 //BA.debugLineNum = 303;BA.debugLine="btnRegister.Enabled = True";
mostCurrent._btnregister.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 304;BA.debugLine="btnRegister.Text = \"Register Device\"";
mostCurrent._btnregister.setText(BA.ObjectToCharSequence("Register Device"));
 };
 };
 }else {
 //BA.debugLineNum = 308;BA.debugLine="Log(\"Network Error: \" & Job.ErrorMessage)";
anywheresoftware.b4a.keywords.Common.LogImpl("4786512","Network Error: "+_job._errormessage /*String*/ ,0);
 //BA.debugLineNum = 309;BA.debugLine="lblStatus.Text = \"Status: Network error - \" & Jo";
mostCurrent._lblstatus.setText(BA.ObjectToCharSequence("Status: Network error - "+_job._errormessage /*String*/ ));
 //BA.debugLineNum = 312;BA.debugLine="If btnRegister.IsInitialized Then";
if (mostCurrent._btnregister.IsInitialized()) { 
 //BA.debugLineNum = 313;BA.debugLine="btnRegister.Enabled = True";
mostCurrent._btnregister.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 314;BA.debugLine="btnRegister.Text = \"Register Device\"";
mostCurrent._btnregister.setText(BA.ObjectToCharSequence("Register Device"));
 };
 };
 //BA.debugLineNum = 317;BA.debugLine="Job.Release";
_job._release /*String*/ ();
 //BA.debugLineNum = 318;BA.debugLine="End Sub";
return "";
}
public static String  _openautostartsettings() throws Exception{
anywheresoftware.b4a.objects.IntentWrapper _i = null;
anywheresoftware.b4a.phone.Phone _pm = null;
String _manufacturer = "";
 //BA.debugLineNum = 418;BA.debugLine="Sub OpenAutoStartSettings";
 //BA.debugLineNum = 419;BA.debugLine="Try";
try { //BA.debugLineNum = 420;BA.debugLine="Dim i As Intent";
_i = new anywheresoftware.b4a.objects.IntentWrapper();
 //BA.debugLineNum = 421;BA.debugLine="Dim pm As Phone";
_pm = new anywheresoftware.b4a.phone.Phone();
 //BA.debugLineNum = 422;BA.debugLine="Dim manufacturer As String = pm.Manufacturer.ToL";
_manufacturer = _pm.getManufacturer().toLowerCase();
 //BA.debugLineNum = 424;BA.debugLine="Log(\"Attempting to open auto-start settings for:";
anywheresoftware.b4a.keywords.Common.LogImpl("41048582","Attempting to open auto-start settings for: "+_manufacturer,0);
 //BA.debugLineNum = 426;BA.debugLine="If manufacturer.Contains(\"xiaomi\") Then";
if (_manufacturer.contains("xiaomi")) { 
 //BA.debugLineNum = 427;BA.debugLine="i.Initialize(\"miui.intent.action.OP_AUTO_START\"";
_i.Initialize("miui.intent.action.OP_AUTO_START","");
 //BA.debugLineNum = 428;BA.debugLine="i.SetComponent(\"com.miui.securitycenter/com.miu";
_i.SetComponent("com.miui.securitycenter/com.miui.permcenter.autostart.AutoStartManagementActivity");
 }else if(_manufacturer.contains("oppo")) { 
 //BA.debugLineNum = 430;BA.debugLine="i.Initialize(\"\", \"\")";
_i.Initialize("","");
 //BA.debugLineNum = 431;BA.debugLine="i.SetComponent(\"com.coloros.safecenter/com.colo";
_i.SetComponent("com.coloros.safecenter/com.coloros.safecenter.permission.startup.StartupAppListActivity");
 }else if(_manufacturer.contains("vivo")) { 
 //BA.debugLineNum = 433;BA.debugLine="i.Initialize(\"\", \"\")";
_i.Initialize("","");
 //BA.debugLineNum = 434;BA.debugLine="i.SetComponent(\"com.vivo.permissionmanager/com.";
_i.SetComponent("com.vivo.permissionmanager/com.vivo.permissionmanager.activity.BgStartUpManagerActivity");
 }else if(_manufacturer.contains("huawei")) { 
 //BA.debugLineNum = 436;BA.debugLine="i.Initialize(\"\", \"\")";
_i.Initialize("","");
 //BA.debugLineNum = 437;BA.debugLine="i.SetComponent(\"com.huawei.systemmanager/com.hu";
_i.SetComponent("com.huawei.systemmanager/com.huawei.systemmanager.optimize.process.ProtectActivity");
 }else {
 //BA.debugLineNum = 440;BA.debugLine="i.Initialize(\"android.settings.APPLICATION_DETA";
_i.Initialize("android.settings.APPLICATION_DETAILS_SETTINGS","package:"+anywheresoftware.b4a.keywords.Common.Application.getPackageName());
 };
 //BA.debugLineNum = 443;BA.debugLine="StartActivity(i)";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)(_i.getObject()));
 } 
       catch (Exception e23) {
			processBA.setLastException(e23); //BA.debugLineNum = 445;BA.debugLine="Log(\"Error opening auto-start settings: \" & Last";
anywheresoftware.b4a.keywords.Common.LogImpl("41048603","Error opening auto-start settings: "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(mostCurrent.activityBA)),0);
 //BA.debugLineNum = 447;BA.debugLine="Try";
try { //BA.debugLineNum = 448;BA.debugLine="Dim i As Intent";
_i = new anywheresoftware.b4a.objects.IntentWrapper();
 //BA.debugLineNum = 449;BA.debugLine="i.Initialize(\"android.settings.SETTINGS\", \"\")";
_i.Initialize("android.settings.SETTINGS","");
 //BA.debugLineNum = 450;BA.debugLine="StartActivity(i)";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)(_i.getObject()));
 } 
       catch (Exception e29) {
			processBA.setLastException(e29); //BA.debugLineNum = 452;BA.debugLine="Log(\"Could not open any settings: \" & LastExcep";
anywheresoftware.b4a.keywords.Common.LogImpl("41048610","Could not open any settings: "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(mostCurrent.activityBA)),0);
 };
 };
 //BA.debugLineNum = 455;BA.debugLine="End Sub";
return "";
}

public static void initializeProcessGlobals() {
    
    if (main.processGlobalsRun == false) {
	    main.processGlobalsRun = true;
		try {
		        main._process_globals();
starter._process_globals();
messageservice._process_globals();
broadcastdisplay._process_globals();
httputils2service._process_globals();
		
        } catch (Exception e) {
			throw new RuntimeException(e);
		}
    }
}public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 22;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 23;BA.debugLine="Private ServerURL As String = \"https://sdms.meros";
_serverurl = "https://sdms.merosee.com/api";
 //BA.debugLineNum = 24;BA.debugLine="End Sub";
return "";
}
public static void  _promptforautostart() throws Exception{
ResumableSub_PromptForAutoStart rsub = new ResumableSub_PromptForAutoStart(null);
rsub.resume(processBA, null);
}
public static class ResumableSub_PromptForAutoStart extends BA.ResumableSub {
public ResumableSub_PromptForAutoStart(com.smartboard.sdms.agent.main parent) {
this.parent = parent;
}
com.smartboard.sdms.agent.main parent;
String _msg = "";
int _result = 0;

@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 = 410;BA.debugLine="Dim msg As String = \"To ensure this agent starts";
_msg = "To ensure this agent starts automatically after a device reboot, please make sure 'Auto-start' is enabled for this app in your system settings.";
 //BA.debugLineNum = 411;BA.debugLine="Msgbox2Async(msg, \"Auto-Start Permission\", \"Open";
anywheresoftware.b4a.keywords.Common.Msgbox2Async(BA.ObjectToCharSequence(_msg),BA.ObjectToCharSequence("Auto-Start Permission"),"Open Settings","Later","",(anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper(), (android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null)),processBA,anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 412;BA.debugLine="Wait For Msgbox_Result (Result As Int)";
anywheresoftware.b4a.keywords.Common.WaitFor("msgbox_result", processBA, this, null);
this.state = 5;
return;
case 5:
//C
this.state = 1;
_result = (Integer) result[0];
;
 //BA.debugLineNum = 413;BA.debugLine="If Result = DialogResponse.POSITIVE Then";
if (true) break;

case 1:
//if
this.state = 4;
if (_result==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 //BA.debugLineNum = 414;BA.debugLine="OpenAutoStartSettings";
_openautostartsettings();
 if (true) break;

case 4:
//C
this.state = -1;
;
 //BA.debugLineNum = 416;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static String  _registerdevice(String _devicename) throws Exception{
com.smartboard.sdms.agent.httpjob _job = null;
anywheresoftware.b4a.objects.collections.Map _data = null;
anywheresoftware.b4a.objects.collections.JSONParser.JSONGenerator _json = null;
 //BA.debugLineNum = 190;BA.debugLine="Sub RegisterDevice(deviceName As String)";
 //BA.debugLineNum = 192;BA.debugLine="If deviceName = \"\" Or deviceName.Trim = \"\" Then";
if ((_devicename).equals("") || (_devicename.trim()).equals("")) { 
 //BA.debugLineNum = 193;BA.debugLine="deviceName = \"Smartboard \" & GetDeviceID";
_devicename = "Smartboard "+_getdeviceid();
 };
 //BA.debugLineNum = 196;BA.debugLine="lblStatus.Text = \"Status: Registering...\"";
mostCurrent._lblstatus.setText(BA.ObjectToCharSequence("Status: Registering..."));
 //BA.debugLineNum = 198;BA.debugLine="Dim job As HttpJob";
_job = new com.smartboard.sdms.agent.httpjob();
 //BA.debugLineNum = 199;BA.debugLine="job.Initialize(\"register\", Me)";
_job._initialize /*String*/ (processBA,"register",main.getObject());
 //BA.debugLineNum = 200;BA.debugLine="Dim data As Map = CreateMap(\"device_id\":GetDevice";
_data = new anywheresoftware.b4a.objects.collections.Map();
_data = anywheresoftware.b4a.keywords.Common.createMap(new Object[] {(Object)("device_id"),(Object)(_getdeviceid()),(Object)("name"),(Object)(_devicename.trim()),(Object)("location"),(Object)("Unknown")});
 //BA.debugLineNum = 202;BA.debugLine="Dim json As JSONGenerator";
_json = new anywheresoftware.b4a.objects.collections.JSONParser.JSONGenerator();
 //BA.debugLineNum = 203;BA.debugLine="json.Initialize(data)";
_json.Initialize(_data);
 //BA.debugLineNum = 205;BA.debugLine="job.PostString(ServerURL & \"/devices/register\", j";
_job._poststring /*String*/ (_serverurl+"/devices/register",_json.ToString());
 //BA.debugLineNum = 206;BA.debugLine="job.GetRequest.SetContentType(\"application/json\")";
_job._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ ().SetContentType("application/json");
 //BA.debugLineNum = 207;BA.debugLine="End Sub";
return "";
}
public static String  _requestbatteryoptimizationexemption() throws Exception{
anywheresoftware.b4a.phone.Phone _p = null;
anywheresoftware.b4j.object.JavaObject _pm = null;
String _packagename = "";
boolean _isignoring = false;
anywheresoftware.b4a.objects.IntentWrapper _i = null;
 //BA.debugLineNum = 382;BA.debugLine="Sub RequestBatteryOptimizationExemption";
 //BA.debugLineNum = 384;BA.debugLine="Try";
try { //BA.debugLineNum = 385;BA.debugLine="Dim p As Phone";
_p = new anywheresoftware.b4a.phone.Phone();
 //BA.debugLineNum = 386;BA.debugLine="If p.SdkVersion >= 23 Then";
if (_p.getSdkVersion()>=23) { 
 //BA.debugLineNum = 387;BA.debugLine="Dim pm As JavaObject";
_pm = new anywheresoftware.b4j.object.JavaObject();
 //BA.debugLineNum = 388;BA.debugLine="pm.InitializeContext";
_pm.InitializeContext(processBA);
 //BA.debugLineNum = 389;BA.debugLine="pm = pm.RunMethod(\"getSystemService\", Array(\"po";
_pm = (anywheresoftware.b4j.object.JavaObject) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4j.object.JavaObject(), (java.lang.Object)(_pm.RunMethod("getSystemService",new Object[]{(Object)("power")})));
 //BA.debugLineNum = 391;BA.debugLine="Dim packageName As String = Application.Package";
_packagename = anywheresoftware.b4a.keywords.Common.Application.getPackageName();
 //BA.debugLineNum = 392;BA.debugLine="Dim isIgnoring As Boolean = pm.RunMethod(\"isIgn";
_isignoring = BA.ObjectToBoolean(_pm.RunMethod("isIgnoringBatteryOptimizations",new Object[]{(Object)(_packagename)}));
 //BA.debugLineNum = 394;BA.debugLine="If Not(isIgnoring) Then";
if (anywheresoftware.b4a.keywords.Common.Not(_isignoring)) { 
 //BA.debugLineNum = 395;BA.debugLine="Log(\"Requesting battery optimization exemption";
anywheresoftware.b4a.keywords.Common.LogImpl("4917517","Requesting battery optimization exemption...",0);
 //BA.debugLineNum = 396;BA.debugLine="Dim i As Intent";
_i = new anywheresoftware.b4a.objects.IntentWrapper();
 //BA.debugLineNum = 397;BA.debugLine="i.Initialize(\"android.settings.REQUEST_IGNORE_";
_i.Initialize("android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS","package:"+_packagename);
 //BA.debugLineNum = 398;BA.debugLine="StartActivity(i)";
anywheresoftware.b4a.keywords.Common.StartActivity(processBA,(Object)(_i.getObject()));
 //BA.debugLineNum = 399;BA.debugLine="ToastMessageShow(\"Please allow app to run in b";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Please allow app to run in background"),anywheresoftware.b4a.keywords.Common.True);
 }else {
 //BA.debugLineNum = 401;BA.debugLine="Log(\"Battery optimization already disabled\")";
anywheresoftware.b4a.keywords.Common.LogImpl("4917523","Battery optimization already disabled",0);
 };
 };
 } 
       catch (Exception e20) {
			processBA.setLastException(e20); //BA.debugLineNum = 405;BA.debugLine="Log(\"Error requesting battery optimization exemp";
anywheresoftware.b4a.keywords.Common.LogImpl("4917527","Error requesting battery optimization exemption: "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(mostCurrent.activityBA)),0);
 };
 //BA.debugLineNum = 407;BA.debugLine="End Sub";
return "";
}
public static String  _requestmediaprojectionpermission() throws Exception{
anywheresoftware.b4a.phone.Phone _p = null;
anywheresoftware.b4j.object.JavaObject _jo = null;
anywheresoftware.b4j.object.JavaObject _manager = null;
anywheresoftware.b4a.objects.IntentWrapper _startintent = null;
anywheresoftware.b4j.object.JavaObject _joactivity = null;
 //BA.debugLineNum = 139;BA.debugLine="Sub RequestMediaProjectionPermission";
 //BA.debugLineNum = 140;BA.debugLine="Try";
try { //BA.debugLineNum = 141;BA.debugLine="Dim p As Phone";
_p = new anywheresoftware.b4a.phone.Phone();
 //BA.debugLineNum = 142;BA.debugLine="If p.SdkVersion >= 21 Then";
if (_p.getSdkVersion()>=21) { 
 //BA.debugLineNum = 143;BA.debugLine="Log(\"Main: Requesting MediaProjection permissio";
anywheresoftware.b4a.keywords.Common.LogImpl("4327684","Main: Requesting MediaProjection permission...",0);
 //BA.debugLineNum = 144;BA.debugLine="Dim jo As JavaObject";
_jo = new anywheresoftware.b4j.object.JavaObject();
 //BA.debugLineNum = 145;BA.debugLine="jo.InitializeContext";
_jo.InitializeContext(processBA);
 //BA.debugLineNum = 146;BA.debugLine="Dim manager As JavaObject = jo.RunMethod(\"getSy";
_manager = new anywheresoftware.b4j.object.JavaObject();
_manager = (anywheresoftware.b4j.object.JavaObject) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4j.object.JavaObject(), (java.lang.Object)(_jo.RunMethod("getSystemService",new Object[]{(Object)("media_projection")})));
 //BA.debugLineNum = 147;BA.debugLine="Dim startIntent As Intent = manager.RunMethod(\"";
_startintent = new anywheresoftware.b4a.objects.IntentWrapper();
_startintent = (anywheresoftware.b4a.objects.IntentWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.IntentWrapper(), (android.content.Intent)(_manager.RunMethod("createScreenCaptureIntent",(Object[])(anywheresoftware.b4a.keywords.Common.Null))));
 //BA.debugLineNum = 150;BA.debugLine="Dim joActivity As JavaObject = Activity";
_joactivity = new anywheresoftware.b4j.object.JavaObject();
_joactivity = (anywheresoftware.b4j.object.JavaObject) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4j.object.JavaObject(), (java.lang.Object)(mostCurrent._activity.getObject()));
 //BA.debugLineNum = 151;BA.debugLine="joActivity.RunMethod(\"startActivityForResult\",";
_joactivity.RunMethod("startActivityForResult",new Object[]{(Object)(_startintent.getObject()),(Object)(1001)});
 };
 } 
       catch (Exception e13) {
			processBA.setLastException(e13); //BA.debugLineNum = 154;BA.debugLine="Log(\"Error requesting MediaProjection permission";
anywheresoftware.b4a.keywords.Common.LogImpl("4327695","Error requesting MediaProjection permission: "+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(mostCurrent.activityBA)),0);
 };
 //BA.debugLineNum = 156;BA.debugLine="End Sub";
return "";
}
public static String  _showregistrationdialog() throws Exception{
anywheresoftware.b4a.objects.PanelWrapper _pnldialog = null;
int _dialogwidth = 0;
int _dialogheight = 0;
int _dialogleft = 0;
int _dialogtop = 0;
anywheresoftware.b4a.agraham.reflection.Reflection _r = null;
 //BA.debugLineNum = 322;BA.debugLine="Sub ShowRegistrationDialog";
 //BA.debugLineNum = 323;BA.debugLine="lblStatus.Text = \"Status: Not registered\"";
mostCurrent._lblstatus.setText(BA.ObjectToCharSequence("Status: Not registered"));
 //BA.debugLineNum = 326;BA.debugLine="pnlRegistration.Initialize(\"\")";
mostCurrent._pnlregistration.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 327;BA.debugLine="pnlRegistration.Color = Colors.ARGB(200, 0, 0, 0)";
mostCurrent._pnlregistration.setColor(anywheresoftware.b4a.keywords.Common.Colors.ARGB((int) (200),(int) (0),(int) (0),(int) (0)));
 //BA.debugLineNum = 328;BA.debugLine="Activity.AddView(pnlRegistration, 0, 0, 100%x, 10";
mostCurrent._activity.AddView((android.view.View)(mostCurrent._pnlregistration.getObject()),(int) (0),(int) (0),anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (100),mostCurrent.activityBA),anywheresoftware.b4a.keywords.Common.PerYToCurrent((float) (100),mostCurrent.activityBA));
 //BA.debugLineNum = 331;BA.debugLine="Dim pnlDialog As Panel";
_pnldialog = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 332;BA.debugLine="pnlDialog.Initialize(\"\")";
_pnldialog.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 333;BA.debugLine="pnlDialog.Color = Colors.White";
_pnldialog.setColor(anywheresoftware.b4a.keywords.Common.Colors.White);
 //BA.debugLineNum = 334;BA.debugLine="Dim dialogWidth As Int = 80%x";
_dialogwidth = anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (80),mostCurrent.activityBA);
 //BA.debugLineNum = 335;BA.debugLine="Dim dialogHeight As Int = 300dip";
_dialogheight = anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (300));
 //BA.debugLineNum = 336;BA.debugLine="Dim dialogLeft As Int = (100%x - dialogWidth) / 2";
_dialogleft = (int) ((anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (100),mostCurrent.activityBA)-_dialogwidth)/(double)2);
 //BA.debugLineNum = 337;BA.debugLine="Dim dialogTop As Int = (100%y - dialogHeight) / 2";
_dialogtop = (int) ((anywheresoftware.b4a.keywords.Common.PerYToCurrent((float) (100),mostCurrent.activityBA)-_dialogheight)/(double)2);
 //BA.debugLineNum = 338;BA.debugLine="pnlRegistration.AddView(pnlDialog, dialogLeft, di";
mostCurrent._pnlregistration.AddView((android.view.View)(_pnldialog.getObject()),_dialogleft,_dialogtop,_dialogwidth,_dialogheight);
 //BA.debugLineNum = 341;BA.debugLine="lblRegTitle.Initialize(\"\")";
mostCurrent._lblregtitle.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 342;BA.debugLine="lblRegTitle.Text = \"SDMS Agent - Device Registrat";
mostCurrent._lblregtitle.setText(BA.ObjectToCharSequence("SDMS Agent - Device Registration"));
 //BA.debugLineNum = 343;BA.debugLine="lblRegTitle.TextSize = 20";
mostCurrent._lblregtitle.setTextSize((float) (20));
 //BA.debugLineNum = 344;BA.debugLine="lblRegTitle.TextColor = Colors.Black";
mostCurrent._lblregtitle.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 345;BA.debugLine="lblRegTitle.Gravity = Gravity.CENTER";
mostCurrent._lblregtitle.setGravity(anywheresoftware.b4a.keywords.Common.Gravity.CENTER);
 //BA.debugLineNum = 347;BA.debugLine="Dim r As Reflector";
_r = new anywheresoftware.b4a.agraham.reflection.Reflection();
 //BA.debugLineNum = 348;BA.debugLine="r.Target = lblRegTitle";
_r.Target = (Object)(mostCurrent._lblregtitle.getObject());
 //BA.debugLineNum = 349;BA.debugLine="r.RunMethod4(\"setPaintFlags\", Array(129), Array A";
_r.RunMethod4("setPaintFlags",new Object[]{(Object)(129)},new String[]{"java.lang.int"});
 //BA.debugLineNum = 350;BA.debugLine="pnlDialog.AddView(lblRegTitle, 10dip, 10dip, dial";
_pnldialog.AddView((android.view.View)(mostCurrent._lblregtitle.getObject()),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (10)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (10)),(int) (_dialogwidth-anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (20))),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (40)));
 //BA.debugLineNum = 353;BA.debugLine="lblRegPrompt.Initialize(\"\")";
mostCurrent._lblregprompt.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 354;BA.debugLine="lblRegPrompt.Text = \"Please enter a name for this";
mostCurrent._lblregprompt.setText(BA.ObjectToCharSequence("Please enter a name for this device:"));
 //BA.debugLineNum = 355;BA.debugLine="lblRegPrompt.TextSize = 14";
mostCurrent._lblregprompt.setTextSize((float) (14));
 //BA.debugLineNum = 356;BA.debugLine="lblRegPrompt.TextColor = Colors.Black";
mostCurrent._lblregprompt.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 357;BA.debugLine="pnlDialog.AddView(lblRegPrompt, 10dip, 60dip, dia";
_pnldialog.AddView((android.view.View)(mostCurrent._lblregprompt.getObject()),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (10)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (60)),(int) (_dialogwidth-anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (20))),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (30)));
 //BA.debugLineNum = 360;BA.debugLine="txtDeviceName.Initialize(\"txtDeviceName\")";
mostCurrent._txtdevicename.Initialize(mostCurrent.activityBA,"txtDeviceName");
 //BA.debugLineNum = 361;BA.debugLine="txtDeviceName.Text = \"Smartboard \" & GetDeviceID";
mostCurrent._txtdevicename.setText(BA.ObjectToCharSequence("Smartboard "+_getdeviceid()));
 //BA.debugLineNum = 362;BA.debugLine="txtDeviceName.TextSize = 16";
mostCurrent._txtdevicename.setTextSize((float) (16));
 //BA.debugLineNum = 363;BA.debugLine="txtDeviceName.Hint = \"Enter device name\"";
mostCurrent._txtdevicename.setHint("Enter device name");
 //BA.debugLineNum = 364;BA.debugLine="pnlDialog.AddView(txtDeviceName, 10dip, 100dip, d";
_pnldialog.AddView((android.view.View)(mostCurrent._txtdevicename.getObject()),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (10)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (100)),(int) (_dialogwidth-anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (20))),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (50)));
 //BA.debugLineNum = 367;BA.debugLine="lblRegDeviceID.Initialize(\"\")";
mostCurrent._lblregdeviceid.Initialize(mostCurrent.activityBA,"");
 //BA.debugLineNum = 368;BA.debugLine="lblRegDeviceID.Text = \"Device ID: \" & GetDeviceID";
mostCurrent._lblregdeviceid.setText(BA.ObjectToCharSequence("Device ID: "+_getdeviceid()));
 //BA.debugLineNum = 369;BA.debugLine="lblRegDeviceID.TextSize = 12";
mostCurrent._lblregdeviceid.setTextSize((float) (12));
 //BA.debugLineNum = 370;BA.debugLine="lblRegDeviceID.TextColor = Colors.Gray";
mostCurrent._lblregdeviceid.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Gray);
 //BA.debugLineNum = 371;BA.debugLine="pnlDialog.AddView(lblRegDeviceID, 10dip, 160dip,";
_pnldialog.AddView((android.view.View)(mostCurrent._lblregdeviceid.getObject()),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (10)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (160)),(int) (_dialogwidth-anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (20))),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (30)));
 //BA.debugLineNum = 374;BA.debugLine="btnRegister.Initialize(\"btnRegister\")";
mostCurrent._btnregister.Initialize(mostCurrent.activityBA,"btnRegister");
 //BA.debugLineNum = 375;BA.debugLine="btnRegister.Text = \"Register Device\"";
mostCurrent._btnregister.setText(BA.ObjectToCharSequence("Register Device"));
 //BA.debugLineNum = 376;BA.debugLine="btnRegister.TextSize = 16";
mostCurrent._btnregister.setTextSize((float) (16));
 //BA.debugLineNum = 377;BA.debugLine="btnRegister.Color = Colors.RGB(33, 150, 243) ' Ma";
mostCurrent._btnregister.setColor(anywheresoftware.b4a.keywords.Common.Colors.RGB((int) (33),(int) (150),(int) (243)));
 //BA.debugLineNum = 378;BA.debugLine="btnRegister.TextColor = Colors.White";
mostCurrent._btnregister.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.White);
 //BA.debugLineNum = 379;BA.debugLine="pnlDialog.AddView(btnRegister, 10dip, 200dip, dia";
_pnldialog.AddView((android.view.View)(mostCurrent._btnregister.getObject()),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (10)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (200)),(int) (_dialogwidth-anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (20))),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (50)));
 //BA.debugLineNum = 380;BA.debugLine="End Sub";
return "";
}
}
