package b4a.bbb;


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 setup extends Activity implements B4AActivity{
	public static setup 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 = false;
    public static WeakReference<Activity> previousOne;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        mostCurrent = this;
		if (processBA == null) {
			processBA = new anywheresoftware.b4a.ShellBA(this.getApplicationContext(), null, null, "b4a.bbb", "b4a.bbb.setup");
			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 (setup).");
				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, "b4a.bbb", "b4a.bbb.setup");
        
        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, "b4a.bbb.setup", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density, mostCurrent);
			_activity.reinitializeForShell(activityBA, "activity");
		}
        initializeProcessGlobals();		
        initializeGlobals();
        
        BA.LogInfo("** Activity (setup) Create, isFirst = " + isFirst + " **");
        processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
		isFirst = false;
		if (this != mostCurrent)
			return;
        processBA.setActivityPaused(false);
        BA.LogInfo("** Activity (setup) 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 setup.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);
        BA.LogInfo("** Activity (setup) Pause, UserClosed = " + activityBA.activity.isFinishing() + " **");
        if (mostCurrent != null)
            processBA.raiseEvent2(_activity, true, "activity_pause", false, activityBA.activity.isFinishing());		
        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() {
            setup mc = mostCurrent;
			if (mc == null || mc != activity.get())
				return;
			processBA.setActivityPaused(false);
            BA.LogInfo("** Activity (setup) 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 static void initializeProcessGlobals() {
             try {
                Class.forName(BA.applicationContext.getPackageName() + ".main").getMethod("initializeProcessGlobals").invoke(null, null);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
}
public anywheresoftware.b4a.keywords.Common __c = null;
public anywheresoftware.b4a.objects.ButtonWrapper _btn_paired = null;
public anywheresoftware.b4a.objects.ButtonWrapper _btn_scan = null;
public anywheresoftware.b4a.objects.ListViewWrapper _clvscan = null;
public anywheresoftware.b4a.objects.LabelWrapper _label1 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label2 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label4 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label6 = null;
public anywheresoftware.b4a.objects.LabelWrapper _lbl_statut_ble = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblinfo_appaired = null;
public anywheresoftware.b4a.objects.LabelWrapper _lblinfolevel = null;
public anywheresoftware.b4a.objects.PanelWrapper _panel_setup = null;
public anywheresoftware.b4a.objects.ProgressBarWrapper _pbscan = null;
public anywheresoftware.b4a.objects.EditTextWrapper _txtlocalisation = null;
public static int _idcapteur = 0;
public static String _localisation_capteur = "";
public static String[] _info_sensor = null;
public anywheresoftware.b4a.objects.IME _ime = null;
public anywheresoftware.b4a.objects.LabelWrapper _lbl_temp_consigne = null;
public anywheresoftware.b4a.objects.SeekBarWrapper _seekbar_consigne_t = null;
public static float _temp_value = 0f;
public b4a.bbb.main _main = null;
public b4a.bbb.starter _starter = null;
public b4a.bbb.param _param = null;
public b4a.bbb.cockpit _cockpit = null;
public b4a.bbb.collecte_data_sensor _collecte_data_sensor = null;
public b4a.bbb.httputils2service _httputils2service = null;
public static String  _statechanged() throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "statechanged", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "statechanged", null));}
RDebugUtils.currentLine=2359296;
 //BA.debugLineNum = 2359296;BA.debugLine="Sub StateChanged";
RDebugUtils.currentLine=2359297;
 //BA.debugLineNum = 2359297;BA.debugLine="lbl_statut_BLE.Text=Starter.currentStateText";
mostCurrent._lbl_statut_ble.setText(BA.ObjectToCharSequence(mostCurrent._starter._currentstatetext /*String*/ ));
RDebugUtils.currentLine=2359298;
 //BA.debugLineNum = 2359298;BA.debugLine="End Sub";
return "";
}
public static String  _add_list_service(String _name_service,String _id) throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "add_list_service", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "add_list_service", new Object[] {_name_service,_id}));}
RDebugUtils.currentLine=2818048;
 //BA.debugLineNum = 2818048;BA.debugLine="Sub add_list_service(name_service As String,id As";
RDebugUtils.currentLine=2818049;
 //BA.debugLineNum = 2818049;BA.debugLine="Dim Label1 As Label";
mostCurrent._label1 = new anywheresoftware.b4a.objects.LabelWrapper();
RDebugUtils.currentLine=2818050;
 //BA.debugLineNum = 2818050;BA.debugLine="clvScan.SingleLineLayout.ItemHeight = 30dip";
mostCurrent._clvscan.getSingleLineLayout().setItemHeight(anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (30)));
RDebugUtils.currentLine=2818051;
 //BA.debugLineNum = 2818051;BA.debugLine="Label1 = clvScan.SingleLineLayout.Label";
mostCurrent._label1 = mostCurrent._clvscan.getSingleLineLayout().Label;
RDebugUtils.currentLine=2818052;
 //BA.debugLineNum = 2818052;BA.debugLine="Label1.TextSize = 14";
mostCurrent._label1.setTextSize((float) (14));
RDebugUtils.currentLine=2818053;
 //BA.debugLineNum = 2818053;BA.debugLine="Label1.TextColor = Colors.black";
mostCurrent._label1.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
RDebugUtils.currentLine=2818054;
 //BA.debugLineNum = 2818054;BA.debugLine="clvScan.AddSingleLine2(name_service,id)";
mostCurrent._clvscan.AddSingleLine2(BA.ObjectToCharSequence(_name_service),(Object)(_id));
RDebugUtils.currentLine=2818057;
 //BA.debugLineNum = 2818057;BA.debugLine="End Sub";
return "";
}
public static String  _activity_create(boolean _firsttime) throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "activity_create", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "activity_create", new Object[] {_firsttime}));}
RDebugUtils.currentLine=2228224;
 //BA.debugLineNum = 2228224;BA.debugLine="Sub Activity_Create(FirstTime As Boolean)";
RDebugUtils.currentLine=2228227;
 //BA.debugLineNum = 2228227;BA.debugLine="IME.Initialize(\"IME\")";
mostCurrent._ime.Initialize("IME");
RDebugUtils.currentLine=2228228;
 //BA.debugLineNum = 2228228;BA.debugLine="IME.AddHeightChangedEvent";
mostCurrent._ime.AddHeightChangedEvent(mostCurrent.activityBA);
RDebugUtils.currentLine=2228229;
 //BA.debugLineNum = 2228229;BA.debugLine="Activity.LoadLayout(\"setup\")";
mostCurrent._activity.LoadLayout("setup",mostCurrent.activityBA);
RDebugUtils.currentLine=2228230;
 //BA.debugLineNum = 2228230;BA.debugLine="SeekBar_consigne_T.Max=300";
mostCurrent._seekbar_consigne_t.setMax((int) (300));
RDebugUtils.currentLine=2228231;
 //BA.debugLineNum = 2228231;BA.debugLine="SeekBar_consigne_T.Value=200";
mostCurrent._seekbar_consigne_t.setValue((int) (200));
RDebugUtils.currentLine=2228233;
 //BA.debugLineNum = 2228233;BA.debugLine="End Sub";
return "";
}
public static String  _activity_pause(boolean _userclosed) throws Exception{
RDebugUtils.currentModule="setup";
RDebugUtils.currentLine=2424832;
 //BA.debugLineNum = 2424832;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
RDebugUtils.currentLine=2424834;
 //BA.debugLineNum = 2424834;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "activity_resume", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "activity_resume", null));}
RDebugUtils.currentLine=2293760;
 //BA.debugLineNum = 2293760;BA.debugLine="Sub Activity_Resume";
RDebugUtils.currentLine=2293761;
 //BA.debugLineNum = 2293761;BA.debugLine="StateChanged";
_statechanged();
RDebugUtils.currentLine=2293762;
 //BA.debugLineNum = 2293762;BA.debugLine="End Sub";
return "";
}
public static void  _btn_paired_click() throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "btn_paired_click", false))
	 {Debug.delegate(mostCurrent.activityBA, "btn_paired_click", null); return;}
ResumableSub_btn_paired_Click rsub = new ResumableSub_btn_paired_Click(null);
rsub.resume(processBA, null);
}
public static class ResumableSub_btn_paired_Click extends BA.ResumableSub {
public ResumableSub_btn_paired_Click(b4a.bbb.setup parent) {
this.parent = parent;
}
b4a.bbb.setup parent;
String _permission = "";
boolean _result = false;
String _data_sensor = "";

@Override
public void resume(BA ba, Object[] result) throws Exception{
RDebugUtils.currentModule="setup";

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
RDebugUtils.currentLine=2883586;
 //BA.debugLineNum = 2883586;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);
RDebugUtils.currentLine=2883587;
 //BA.debugLineNum = 2883587;BA.debugLine="Wait For Activity_PermissionResult (Permission As";
anywheresoftware.b4a.keywords.Common.WaitFor("activity_permissionresult", processBA, new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "setup", "btn_paired_click"), null);
this.state = 11;
return;
case 11:
//C
this.state = 1;
_permission = (String) result[0];
_result = (Boolean) result[1];
;
RDebugUtils.currentLine=2883588;
 //BA.debugLineNum = 2883588;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;
;
RDebugUtils.currentLine=2883591;
 //BA.debugLineNum = 2883591;BA.debugLine="Localisation_capteur= txtLocalisation.Text";
parent.mostCurrent._localisation_capteur = parent.mostCurrent._txtlocalisation.getText();
RDebugUtils.currentLine=2883592;
 //BA.debugLineNum = 2883592;BA.debugLine="IdCapteur=IdCapteur+1";
parent._idcapteur = (int) (parent._idcapteur+1);
RDebugUtils.currentLine=2883594;
 //BA.debugLineNum = 2883594;BA.debugLine="If  Localisation_capteur.Length>0 Then";
if (true) break;

case 7:
//if
this.state = 10;
if (parent.mostCurrent._localisation_capteur.length()>0) { 
this.state = 9;
}if (true) break;

case 9:
//C
this.state = 10;
RDebugUtils.currentLine=2883595;
 //BA.debugLineNum = 2883595;BA.debugLine="Dim data_sensor As String = IdCapteur & \";\" & Lo";
_data_sensor = BA.NumberToString(parent._idcapteur)+";"+parent.mostCurrent._localisation_capteur+";"+parent.mostCurrent._info_sensor[(int) (0)]+";"+BA.NumberToString(parent._temp_value);
RDebugUtils.currentLine=2883596;
 //BA.debugLineNum = 2883596;BA.debugLine="Param.write_file_setup(data_sensor, \"setup.txt\")";
parent.mostCurrent._param._write_file_setup /*String*/ (mostCurrent.activityBA,_data_sensor,"setup.txt");
 if (true) break;

case 10:
//C
this.state = -1;
;
RDebugUtils.currentLine=2883600;
 //BA.debugLineNum = 2883600;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static void  _btn_scan_click() throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "btn_scan_click", false))
	 {Debug.delegate(mostCurrent.activityBA, "btn_scan_click", null); return;}
ResumableSub_btn_scan_Click rsub = new ResumableSub_btn_scan_Click(null);
rsub.resume(processBA, null);
}
public static class ResumableSub_btn_scan_Click extends BA.ResumableSub {
public ResumableSub_btn_scan_Click(b4a.bbb.setup parent) {
this.parent = parent;
}
b4a.bbb.setup parent;
String _permission = "";
boolean _result = false;

@Override
public void resume(BA ba, Object[] result) throws Exception{
RDebugUtils.currentModule="setup";

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
RDebugUtils.currentLine=2752513;
 //BA.debugLineNum = 2752513;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_ACCESS_COARSE_LOCATION);
RDebugUtils.currentLine=2752514;
 //BA.debugLineNum = 2752514;BA.debugLine="Wait For Activity_PermissionResult (Permission As";
anywheresoftware.b4a.keywords.Common.WaitFor("activity_permissionresult", processBA, new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "setup", "btn_scan_click"), null);
this.state = 7;
return;
case 7:
//C
this.state = 1;
_permission = (String) result[0];
_result = (Boolean) result[1];
;
RDebugUtils.currentLine=2752515;
 //BA.debugLineNum = 2752515;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 = -1;
;
RDebugUtils.currentLine=2752516;
 //BA.debugLineNum = 2752516;BA.debugLine="pbscan.Visible = True";
parent.mostCurrent._pbscan.setVisible(anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=2752517;
 //BA.debugLineNum = 2752517;BA.debugLine="clvScan.Clear";
parent.mostCurrent._clvscan.Clear();
RDebugUtils.currentLine=2752518;
 //BA.debugLineNum = 2752518;BA.debugLine="pbscan.Visible=True";
parent.mostCurrent._pbscan.setVisible(anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=2752520;
 //BA.debugLineNum = 2752520;BA.debugLine="CallSub(Starter, \"StartScan\")";
anywheresoftware.b4a.keywords.Common.CallSubDebug(processBA,(Object)(parent.mostCurrent._starter.getObject()),"StartScan");
RDebugUtils.currentLine=2752521;
 //BA.debugLineNum = 2752521;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static String  _btnquit_click() throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "btnquit_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "btnquit_click", null));}
RDebugUtils.currentLine=2949120;
 //BA.debugLineNum = 2949120;BA.debugLine="Sub btnQuit_Click";
RDebugUtils.currentLine=2949122;
 //BA.debugLineNum = 2949122;BA.debugLine="End Sub";
return "";
}
public static String  _clvscan_itemclick(int _index,Object _value) throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "clvscan_itemclick", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "clvscan_itemclick", new Object[] {_index,_value}));}
RDebugUtils.currentLine=2686976;
 //BA.debugLineNum = 2686976;BA.debugLine="Sub clvScan_ItemClick (Index As Int, Value As Obje";
RDebugUtils.currentLine=2686978;
 //BA.debugLineNum = 2686978;BA.debugLine="btn_paired.Visible=True";
mostCurrent._btn_paired.setVisible(anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=2686979;
 //BA.debugLineNum = 2686979;BA.debugLine="Starter.manager.StopScan";
mostCurrent._starter._manager /*anywheresoftware.b4a.objects.BleManager2*/ .StopScan();
RDebugUtils.currentLine=2686980;
 //BA.debugLineNum = 2686980;BA.debugLine="pbscan.Visible=False";
mostCurrent._pbscan.setVisible(anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=2686982;
 //BA.debugLineNum = 2686982;BA.debugLine="info_sensor  = Regex.Split(\";\",Value)";
mostCurrent._info_sensor = anywheresoftware.b4a.keywords.Common.Regex.Split(";",BA.ObjectToString(_value));
RDebugUtils.currentLine=2686984;
 //BA.debugLineNum = 2686984;BA.debugLine="lblinfolevel.Visible=True";
mostCurrent._lblinfolevel.setVisible(anywheresoftware.b4a.keywords.Common.True);
RDebugUtils.currentLine=2686987;
 //BA.debugLineNum = 2686987;BA.debugLine="Select True";
switch (BA.switchObjectToInt(anywheresoftware.b4a.keywords.Common.True,(double)(Double.parseDouble(mostCurrent._info_sensor[(int) (1)]))>-90,(double)(Double.parseDouble(mostCurrent._info_sensor[(int) (1)]))<-90 && (double)(Double.parseDouble(mostCurrent._info_sensor[(int) (1)]))>-100,(double)(Double.parseDouble(mostCurrent._info_sensor[(int) (1)]))<-110)) {
case 0: {
RDebugUtils.currentLine=2686989;
 //BA.debugLineNum = 2686989;BA.debugLine="lblinfolevel.Color=Colors.Green";
mostCurrent._lblinfolevel.setColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
RDebugUtils.currentLine=2686990;
 //BA.debugLineNum = 2686990;BA.debugLine="lblinfolevel.Text=\"Bon\"";
mostCurrent._lblinfolevel.setText(BA.ObjectToCharSequence("Bon"));
 break; }
case 1: {
RDebugUtils.currentLine=2686992;
 //BA.debugLineNum = 2686992;BA.debugLine="lblinfolevel.Color=Colors.Yellow";
mostCurrent._lblinfolevel.setColor(anywheresoftware.b4a.keywords.Common.Colors.Yellow);
RDebugUtils.currentLine=2686993;
 //BA.debugLineNum = 2686993;BA.debugLine="lblinfolevel.Text=\"Moyen\"";
mostCurrent._lblinfolevel.setText(BA.ObjectToCharSequence("Moyen"));
 break; }
case 2: {
RDebugUtils.currentLine=2686995;
 //BA.debugLineNum = 2686995;BA.debugLine="lblinfolevel.Color=Colors.red";
mostCurrent._lblinfolevel.setColor(anywheresoftware.b4a.keywords.Common.Colors.Red);
RDebugUtils.currentLine=2686996;
 //BA.debugLineNum = 2686996;BA.debugLine="lblinfolevel.Text=\"Faible\"";
mostCurrent._lblinfolevel.setText(BA.ObjectToCharSequence("Faible"));
 break; }
}
;
RDebugUtils.currentLine=2687003;
 //BA.debugLineNum = 2687003;BA.debugLine="End Sub";
return "";
}
public static String  _ime_heightchanged(int _newheight,int _oldheight) throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "ime_heightchanged", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "ime_heightchanged", new Object[] {_newheight,_oldheight}));}
RDebugUtils.currentLine=2555904;
 //BA.debugLineNum = 2555904;BA.debugLine="Sub IME_HeightChanged(NewHeight As Int, OldHeight";
RDebugUtils.currentLine=2555905;
 //BA.debugLineNum = 2555905;BA.debugLine="Try";
try {RDebugUtils.currentLine=2555906;
 //BA.debugLineNum = 2555906;BA.debugLine="If NewHeight < OldHeight Then";
if (_newheight<_oldheight) { 
RDebugUtils.currentLine=2555907;
 //BA.debugLineNum = 2555907;BA.debugLine="Panel_setup.Top =-900";
mostCurrent._panel_setup.setTop((int) (-900));
 }else {
RDebugUtils.currentLine=2555909;
 //BA.debugLineNum = 2555909;BA.debugLine="Panel_setup.Top =-0";
mostCurrent._panel_setup.setTop((int) (-0));
 };
 } 
       catch (Exception e8) {
			processBA.setLastException(e8);RDebugUtils.currentLine=2555913;
 //BA.debugLineNum = 2555913;BA.debugLine="Log(LastException)";
anywheresoftware.b4a.keywords.Common.LogImpl("62555913",BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(mostCurrent.activityBA)),0);
 };
RDebugUtils.currentLine=2555917;
 //BA.debugLineNum = 2555917;BA.debugLine="End Sub";
return "";
}
public static String  _seekbar_consigne_t_valuechanged(int _value,boolean _userchanged) throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "seekbar_consigne_t_valuechanged", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "seekbar_consigne_t_valuechanged", new Object[] {_value,_userchanged}));}
RDebugUtils.currentLine=9240576;
 //BA.debugLineNum = 9240576;BA.debugLine="Sub SeekBar_consigne_T_ValueChanged (Value As Int,";
RDebugUtils.currentLine=9240577;
 //BA.debugLineNum = 9240577;BA.debugLine="temp_value = SeekBar_consigne_T.Value/10";
_temp_value = (float) (mostCurrent._seekbar_consigne_t.getValue()/(double)10);
RDebugUtils.currentLine=9240578;
 //BA.debugLineNum = 9240578;BA.debugLine="Lbl_temp_consigne.Text= temp_value";
mostCurrent._lbl_temp_consigne.setText(BA.ObjectToCharSequence(_temp_value));
RDebugUtils.currentLine=9240579;
 //BA.debugLineNum = 9240579;BA.debugLine="If temp_value <7.00 Then";
if (_temp_value<7.00) { 
RDebugUtils.currentLine=9240580;
 //BA.debugLineNum = 9240580;BA.debugLine="SeekBar_consigne_T.Value=70";
mostCurrent._seekbar_consigne_t.setValue((int) (70));
 };
RDebugUtils.currentLine=9240583;
 //BA.debugLineNum = 9240583;BA.debugLine="End Sub";
return "";
}
public static String  _txtlocalisation_textchanged(String _old,String _new) throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "txtlocalisation_textchanged", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "txtlocalisation_textchanged", new Object[] {_old,_new}));}
RDebugUtils.currentLine=2621440;
 //BA.debugLineNum = 2621440;BA.debugLine="Sub txtLocalisation_TextChanged (Old As String, Ne";
RDebugUtils.currentLine=2621442;
 //BA.debugLineNum = 2621442;BA.debugLine="End Sub";
return "";
}
public static String  _txtname_capteur_textchanged(String _old,String _new) throws Exception{
RDebugUtils.currentModule="setup";
if (Debug.shouldDelegate(mostCurrent.activityBA, "txtname_capteur_textchanged", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "txtname_capteur_textchanged", new Object[] {_old,_new}));}
RDebugUtils.currentLine=2490368;
 //BA.debugLineNum = 2490368;BA.debugLine="Sub TxtName_capteur_TextChanged (Old As String, Ne";
RDebugUtils.currentLine=2490370;
 //BA.debugLineNum = 2490370;BA.debugLine="End Sub";
return "";
}
}