<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package scott.UploadAFile;


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&lt;B4AMenuItem&gt; menuItems;
	public static final boolean fullScreen = false;
	public static final boolean includeTitle = true;
    public static WeakReference&lt;Activity&gt; previousOne;
    public static boolean dontPause;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        mostCurrent = this;
		if (processBA == null) {
			processBA = new anywheresoftware.b4a.ShellBA(this.getApplicationContext(), null, null, "scott.UploadAFile", "scott.UploadAFile.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 &amp;&amp; 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, "scott.UploadAFile", "scott.UploadAFile.main");
        
        processBA.sharedProcessBA.activityBA = new java.lang.ref.WeakReference&lt;BA&gt;(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, "scott.UploadAFile.main", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density, mostCurrent);
			_activity.reinitializeForShell(activityBA, "activity");
		}
        initializeProcessGlobals();		
        initializeGlobals();
        
        BA.LogInfo("** Activity (main) Create, isFirst = " + isFirst + " **");
        processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
		isFirst = false;
		if (this != mostCurrent)
			return;
        processBA.setActivityPaused(false);
        BA.LogInfo("** Activity (main) Resume **");
        processBA.raiseEvent(null, "activity_resume");
        if (android.os.Build.VERSION.SDK_INT &gt;= 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&lt;B4AMenuItem&gt;();
		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 &gt;= 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&lt;?&gt; 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 &amp;&amp;
					android.os.Build.VERSION.SDK_INT &gt;= 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&lt;Activity&gt;(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&lt;Activity&gt; activity;
    	public ResumeMessage(Activity activity) {
    		this.activity = new WeakReference&lt;Activity&gt;(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 &lt; 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() {
    
    if (main.processGlobalsRun == false) {
	    main.processGlobalsRun = true;
		try {
		        b4a.example.dateutils._process_globals();
		
        } catch (Exception e) {
			throw new RuntimeException(e);
		}
    }
}
public static boolean isAnyActivityVisible() {
    boolean vis = false;
vis = vis | (main.mostCurrent != null);
return vis;}

private static BA killProgramHelper(BA ba) {
    if (ba == null)
        return null;
    anywheresoftware.b4a.BA.SharedProcessBA sharedProcessBA = ba.sharedProcessBA;
    if (sharedProcessBA == null || sharedProcessBA.activityBA == null)
        return null;
    return sharedProcessBA.activityBA.get();
}
public static void killProgram() {
     {
            Activity __a = null;
            if (main.previousOne != null) {
				__a = main.previousOne.get();
			}
            else {
                BA ba = killProgramHelper(main.mostCurrent == null ? null : main.mostCurrent.processBA);
                if (ba != null) __a = ba.activity;
            }
            if (__a != null)
				__a.finish();}

BA.applicationContext.stopService(new android.content.Intent(BA.applicationContext, starter.class));
BA.applicationContext.stopService(new android.content.Intent(BA.applicationContext, httputils2service.class));
}
public anywheresoftware.b4a.keywords.Common __c = null;
public static String _myfile = "";
public static anywheresoftware.b4a.objects.RuntimePermissions _rp = null;
public anywheresoftware.b4a.objects.ButtonWrapper _button1 = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonfiledialog = null;
public anywheresoftware.b4a.objects.LabelWrapper _label1 = null;
public anywheresoftware.b4a.objects.EditTextWrapper _edittext1 = null;
public anywheresoftware.b4a.objects.ButtonWrapper _button2 = null;
public b4a.example.dateutils _dateutils = null;
public scott.UploadAFile.starter _starter = null;
public scott.UploadAFile.httputils2service _httputils2service = null;
public static void  _activity_create(boolean _firsttime) throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(mostCurrent.activityBA, "activity_create", false))
	 {Debug.delegate(mostCurrent.activityBA, "activity_create", new Object[] {_firsttime}); return;}
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(scott.UploadAFile.main parent,boolean _firsttime) {
this.parent = parent;
this._firsttime = _firsttime;
}
scott.UploadAFile.main parent;
boolean _firsttime;
String _permission = "";
boolean _result = false;

@Override
public void resume(BA ba, Object[] result) throws Exception{
RDebugUtils.currentModule="main";

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
RDebugUtils.currentLine=131074;
 //BA.debugLineNum = 131074;BA.debugLine="Activity.LoadLayout(\"Layout1\")";
parent.mostCurrent._activity.LoadLayout("Layout1",mostCurrent.activityBA);
RDebugUtils.currentLine=131075;
 //BA.debugLineNum = 131075;BA.debugLine="Logit(\"Startup\")";
_logit("Startup");
RDebugUtils.currentLine=131077;
 //BA.debugLineNum = 131077;BA.debugLine="rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_S";
parent._rp.CheckAndRequest(processBA,parent._rp.PERMISSION_WRITE_EXTERNAL_STORAGE);
RDebugUtils.currentLine=131078;
 //BA.debugLineNum = 131078;BA.debugLine="Wait For Activity_PermissionResult (Permission As";
anywheresoftware.b4a.keywords.Common.WaitFor("activity_permissionresult", processBA, new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "main", "activity_create"), null);
this.state = 7;
return;
case 7:
//C
this.state = 1;
_permission = (String) result[0];
_result = (Boolean) result[1];
;
RDebugUtils.currentLine=131079;
 //BA.debugLineNum = 131079;BA.debugLine="If Result Then";
if (true) break;

case 1:
//if
this.state = 6;
if (_result) { 
this.state = 3;
}else {
this.state = 5;
}if (true) break;

case 3:
//C
this.state = 6;
RDebugUtils.currentLine=131081;
 //BA.debugLineNum = 131081;BA.debugLine="ToastMessageShow(\"Granted Access !!\",False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Granted Access !!"),anywheresoftware.b4a.keywords.Common.False);
 if (true) break;

case 5:
//C
this.state = 6;
RDebugUtils.currentLine=131084;
 //BA.debugLineNum = 131084;BA.debugLine="ToastMessageShow(\"no external storage access\",Fa";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("no external storage access"),anywheresoftware.b4a.keywords.Common.False);
 if (true) break;

case 6:
//C
this.state = -1;
;
RDebugUtils.currentLine=131087;
 //BA.debugLineNum = 131087;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static String  _logit(String _a) throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(mostCurrent.activityBA, "logit", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "logit", new Object[] {_a}));}
RDebugUtils.currentLine=262144;
 //BA.debugLineNum = 262144;BA.debugLine="Sub Logit(a As String)";
RDebugUtils.currentLine=262145;
 //BA.debugLineNum = 262145;BA.debugLine="EditText1.Text = EditText1.Text &amp; a &amp; Chr(10) &amp; C";
mostCurrent._edittext1.setText(BA.ObjectToCharSequence(mostCurrent._edittext1.getText()+_a+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.Chr((int) (10)))+BA.ObjectToString(anywheresoftware.b4a.keywords.Common.Chr((int) (13)))));
RDebugUtils.currentLine=262147;
 //BA.debugLineNum = 262147;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(mostCurrent.activityBA, "activity_resume", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "activity_resume", null));}
RDebugUtils.currentLine=196608;
 //BA.debugLineNum = 196608;BA.debugLine="Sub Activity_Resume";
RDebugUtils.currentLine=196610;
 //BA.debugLineNum = 196610;BA.debugLine="End Sub";
return "";
}
public static String  _button1_click() throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(mostCurrent.activityBA, "button1_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "button1_click", null));}
RDebugUtils.currentLine=393216;
 //BA.debugLineNum = 393216;BA.debugLine="Sub Button1_Click  'upload file now";
RDebugUtils.currentLine=393217;
 //BA.debugLineNum = 393217;BA.debugLine="upit_one";
_upit_one();
RDebugUtils.currentLine=393218;
 //BA.debugLineNum = 393218;BA.debugLine="End Sub";
return "";
}
public static void  _upit_one() throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(mostCurrent.activityBA, "upit_one", false))
	 {Debug.delegate(mostCurrent.activityBA, "upit_one", null); return;}
ResumableSub_upit_one rsub = new ResumableSub_upit_one(null);
rsub.resume(processBA, null);
}
public static class ResumableSub_upit_one extends BA.ResumableSub {
public ResumableSub_upit_one(scott.UploadAFile.main parent) {
this.parent = parent;
}
scott.UploadAFile.main parent;
boolean _tryremote = false;
scott.UploadAFile.httpjob _h = null;
scott.UploadAFile.httpjob._multipartfiledata _mfd = null;
scott.UploadAFile.httpjob _j = null;
String _reponse = "";

@Override
public void resume(BA ba, Object[] result) throws Exception{
RDebugUtils.currentModule="main";

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
RDebugUtils.currentLine=327683;
 //BA.debugLineNum = 327683;BA.debugLine="Dim TryRemote As Boolean";
_tryremote = false;
RDebugUtils.currentLine=327684;
 //BA.debugLineNum = 327684;BA.debugLine="Dim H As HttpJob";
_h = new scott.UploadAFile.httpjob();
RDebugUtils.currentLine=327685;
 //BA.debugLineNum = 327685;BA.debugLine="H.Initialize(\"\",Me)";
_h._initialize /*String*/ (null,processBA,"",main.getObject());
RDebugUtils.currentLine=327687;
 //BA.debugLineNum = 327687;BA.debugLine="Dim MFD As MultipartFileData";
_mfd = new scott.UploadAFile.httpjob._multipartfiledata();
RDebugUtils.currentLine=327688;
 //BA.debugLineNum = 327688;BA.debugLine="MFD.Initialize";
_mfd.Initialize();
RDebugUtils.currentLine=327689;
 //BA.debugLineNum = 327689;BA.debugLine="MFD.Dir = File.DirDefaultExternal";
_mfd.Dir /*String*/  = anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal();
RDebugUtils.currentLine=327690;
 //BA.debugLineNum = 327690;BA.debugLine="MFD.FileName = MyFile";
_mfd.FileName /*String*/  = parent._myfile;
RDebugUtils.currentLine=327691;
 //BA.debugLineNum = 327691;BA.debugLine="MFD.KeyName = \"userfile\"";
_mfd.KeyName /*String*/  = "userfile";
RDebugUtils.currentLine=327692;
 //BA.debugLineNum = 327692;BA.debugLine="MFD.ContentType = \"application/octet-stream\"";
_mfd.ContentType /*String*/  = "application/octet-stream";
RDebugUtils.currentLine=327694;
 //BA.debugLineNum = 327694;BA.debugLine="Logit(\"Attempting to upload file now..\")";
_logit("Attempting to upload file now..");
RDebugUtils.currentLine=327695;
 //BA.debugLineNum = 327695;BA.debugLine="H.PostMultipart(\"https://homeyhome.fr/Sensor_File";
_h._postmultipart /*String*/ (null,"https://homeyhome.fr/Sensor_FileUpLoaded.php",(anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (anywheresoftware.b4a.objects.collections.Map.MyMap)(anywheresoftware.b4a.keywords.Common.Null)),anywheresoftware.b4a.keywords.Common.ArrayToList(new Object[]{(Object)(_mfd)}));
RDebugUtils.currentLine=327696;
 //BA.debugLineNum = 327696;BA.debugLine="Wait For (h) JobDone(j As HttpJob)";
anywheresoftware.b4a.keywords.Common.WaitFor("jobdone", processBA, new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "main", "upit_one"), (Object)(_h));
this.state = 16;
return;
case 16:
//C
this.state = 1;
_j = (scott.UploadAFile.httpjob) result[0];
;
RDebugUtils.currentLine=327699;
 //BA.debugLineNum = 327699;BA.debugLine="TryRemote = False";
_tryremote = anywheresoftware.b4a.keywords.Common.False;
RDebugUtils.currentLine=327701;
 //BA.debugLineNum = 327701;BA.debugLine="If j.Success Then";
if (true) break;

case 1:
//if
this.state = 6;
if (_j._success /*boolean*/ ) { 
this.state = 3;
}else {
this.state = 5;
}if (true) break;

case 3:
//C
this.state = 6;
RDebugUtils.currentLine=327702;
 //BA.debugLineNum = 327702;BA.debugLine="Logit(\"sucessful upload to Server on Lan\")";
_logit("sucessful upload to Server on Lan");
RDebugUtils.currentLine=327703;
 //BA.debugLineNum = 327703;BA.debugLine="Dim reponse As String= H.GetString";
_reponse = _h._getstring /*String*/ (null);
RDebugUtils.currentLine=327704;
 //BA.debugLineNum = 327704;BA.debugLine="Log(reponse)";
anywheresoftware.b4a.keywords.Common.LogImpl("1327704",_reponse,0);
RDebugUtils.currentLine=327705;
 //BA.debugLineNum = 327705;BA.debugLine="TryRemote =False";
_tryremote = anywheresoftware.b4a.keywords.Common.False;
 if (true) break;

case 5:
//C
this.state = 6;
RDebugUtils.currentLine=327707;
 //BA.debugLineNum = 327707;BA.debugLine="Logit(\"Failed to upload to Server on Lan:\")";
_logit("Failed to upload to Server on Lan:");
RDebugUtils.currentLine=327708;
 //BA.debugLineNum = 327708;BA.debugLine="TryRemote = True";
_tryremote = anywheresoftware.b4a.keywords.Common.True;
 if (true) break;
;
RDebugUtils.currentLine=327712;
 //BA.debugLineNum = 327712;BA.debugLine="If TryRemote=True Then";

case 6:
//if
this.state = 15;
if (_tryremote==anywheresoftware.b4a.keywords.Common.True) { 
this.state = 8;
}if (true) break;

case 8:
//C
this.state = 9;
RDebugUtils.currentLine=327713;
 //BA.debugLineNum = 327713;BA.debugLine="H.PostMultipart(\"https://homeyhome.fr/Sensor_Fil";
_h._postmultipart /*String*/ (null,"https://homeyhome.fr/Sensor_FileUpLoaded.php",(anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (anywheresoftware.b4a.objects.collections.Map.MyMap)(anywheresoftware.b4a.keywords.Common.Null)),anywheresoftware.b4a.keywords.Common.ArrayToList(new Object[]{(Object)(_mfd)}));
RDebugUtils.currentLine=327714;
 //BA.debugLineNum = 327714;BA.debugLine="Wait For (h) JobDone(j As HttpJob)";
anywheresoftware.b4a.keywords.Common.WaitFor("jobdone", processBA, new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "main", "upit_one"), (Object)(_h));
this.state = 17;
return;
case 17:
//C
this.state = 9;
_j = (scott.UploadAFile.httpjob) result[0];
;
RDebugUtils.currentLine=327716;
 //BA.debugLineNum = 327716;BA.debugLine="If j.Success Then";
if (true) break;

case 9:
//if
this.state = 14;
if (_j._success /*boolean*/ ) { 
this.state = 11;
}else {
this.state = 13;
}if (true) break;

case 11:
//C
this.state = 14;
RDebugUtils.currentLine=327717;
 //BA.debugLineNum = 327717;BA.debugLine="Logit(\"sucessful upload to Server on Internet\")";
_logit("sucessful upload to Server on Internet");
 if (true) break;

case 13:
//C
this.state = 14;
RDebugUtils.currentLine=327719;
 //BA.debugLineNum = 327719;BA.debugLine="Logit(\"Failed to upload to Server on Internet:";
_logit("Failed to upload to Server on Internet: ");
 if (true) break;

case 14:
//C
this.state = 15;
;
 if (true) break;

case 15:
//C
this.state = -1;
;
RDebugUtils.currentLine=327729;
 //BA.debugLineNum = 327729;BA.debugLine="j.release";
_j._release /*String*/ (null);
RDebugUtils.currentLine=327730;
 //BA.debugLineNum = 327730;BA.debugLine="Logit(\"DONE\")";
_logit("DONE");
RDebugUtils.currentLine=327731;
 //BA.debugLineNum = 327731;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static String  _button2_click() throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(mostCurrent.activityBA, "button2_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "button2_click", null));}
RDebugUtils.currentLine=4194304;
 //BA.debugLineNum = 4194304;BA.debugLine="Sub Button2_Click";
RDebugUtils.currentLine=4194305;
 //BA.debugLineNum = 4194305;BA.debugLine="read_infoFile";
_read_infofile();
RDebugUtils.currentLine=4194306;
 //BA.debugLineNum = 4194306;BA.debugLine="End Sub";
return "";
}
public static void  _read_infofile() throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(mostCurrent.activityBA, "read_infofile", false))
	 {Debug.delegate(mostCurrent.activityBA, "read_infofile", null); return;}
ResumableSub_read_infoFile rsub = new ResumableSub_read_infoFile(null);
rsub.resume(processBA, null);
}
public static class ResumableSub_read_infoFile extends BA.ResumableSub {
public ResumableSub_read_infoFile(scott.UploadAFile.main parent) {
this.parent = parent;
}
scott.UploadAFile.main parent;
boolean _tryremote = false;
scott.UploadAFile.httpjob _h = null;
String _https_login = "";
String _https_pwd = "";
String _res = "";
anywheresoftware.b4a.objects.collections.JSONParser _parser = null;
anywheresoftware.b4a.objects.collections.List _listofattributes = null;
String _filename = "";
long _filedate = 0L;
long _filetime = 0L;
int _i = 0;
anywheresoftware.b4a.objects.collections.Map _myfiles = null;
long _unixtime = 0L;
long _targetdate = 0L;
int step21;
int limit21;

@Override
public void resume(BA ba, Object[] result) throws Exception{
RDebugUtils.currentModule="main";

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
RDebugUtils.currentLine=4128773;
 //BA.debugLineNum = 4128773;BA.debugLine="Dim TryRemote As Boolean";
_tryremote = false;
RDebugUtils.currentLine=4128774;
 //BA.debugLineNum = 4128774;BA.debugLine="Dim H As HttpJob";
_h = new scott.UploadAFile.httpjob();
RDebugUtils.currentLine=4128775;
 //BA.debugLineNum = 4128775;BA.debugLine="H.Initialize(\"\",Me)";
_h._initialize /*String*/ (null,processBA,"",main.getObject());
RDebugUtils.currentLine=4128776;
 //BA.debugLineNum = 4128776;BA.debugLine="Dim HTTPS_Login As String = \"homeyhomld-FHEBERT\"";
_https_login = "homeyhomld-FHEBERT";
RDebugUtils.currentLine=4128777;
 //BA.debugLineNum = 4128777;BA.debugLine="Dim HTTPS_Pwd As String = \"bdHg47oyTz93Ajq80pPm\"";
_https_pwd = "bdHg47oyTz93Ajq80pPm";
RDebugUtils.currentLine=4128779;
 //BA.debugLineNum = 4128779;BA.debugLine="H.Username=HTTPS_Login";
_h._username /*String*/  = _https_login;
RDebugUtils.currentLine=4128780;
 //BA.debugLineNum = 4128780;BA.debugLine="H.Password=HTTPS_Pwd";
_h._password /*String*/  = _https_pwd;
RDebugUtils.currentLine=4128790;
 //BA.debugLineNum = 4128790;BA.debugLine="H.Download(\"https://homeyhome.fr/Data_Sensor/Info";
_h._download /*String*/ (null,"https://homeyhome.fr/Data_Sensor/InfoFile.php");
RDebugUtils.currentLine=4128791;
 //BA.debugLineNum = 4128791;BA.debugLine="Wait For (h) JobDone h";
anywheresoftware.b4a.keywords.Common.WaitFor("jobdone", processBA, new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "main", "read_infofile"), (Object)(_h));
this.state = 9;
return;
case 9:
//C
this.state = 1;
;
RDebugUtils.currentLine=4128793;
 //BA.debugLineNum = 4128793;BA.debugLine="If h.Success Then";
if (true) break;

case 1:
//if
this.state = 8;
if (_h._success /*boolean*/ ) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
RDebugUtils.currentLine=4128794;
 //BA.debugLineNum = 4128794;BA.debugLine="Logit(\"sucessful upload to Server on Lan\")";
_logit("sucessful upload to Server on Lan");
RDebugUtils.currentLine=4128795;
 //BA.debugLineNum = 4128795;BA.debugLine="Dim res As String= H.GetString";
_res = _h._getstring /*String*/ (null);
RDebugUtils.currentLine=4128796;
 //BA.debugLineNum = 4128796;BA.debugLine="Log(res)";
anywheresoftware.b4a.keywords.Common.LogImpl("14128796",_res,0);
RDebugUtils.currentLine=4128799;
 //BA.debugLineNum = 4128799;BA.debugLine="Dim parser As JSONParser";
_parser = new anywheresoftware.b4a.objects.collections.JSONParser();
RDebugUtils.currentLine=4128800;
 //BA.debugLineNum = 4128800;BA.debugLine="parser.Initialize(res)";
_parser.Initialize(_res);
RDebugUtils.currentLine=4128803;
 //BA.debugLineNum = 4128803;BA.debugLine="Dim ListOfAttributes As List";
_listofattributes = new anywheresoftware.b4a.objects.collections.List();
RDebugUtils.currentLine=4128804;
 //BA.debugLineNum = 4128804;BA.debugLine="Dim FileName As String";
_filename = "";
RDebugUtils.currentLine=4128805;
 //BA.debugLineNum = 4128805;BA.debugLine="Dim FileDate As Long";
_filedate = 0L;
RDebugUtils.currentLine=4128806;
 //BA.debugLineNum = 4128806;BA.debugLine="Dim FileTime As Long";
_filetime = 0L;
RDebugUtils.currentLine=4128808;
 //BA.debugLineNum = 4128808;BA.debugLine="ListOfAttributes = parser.NextArray 'returns a l";
_listofattributes = _parser.NextArray();
RDebugUtils.currentLine=4128810;
 //BA.debugLineNum = 4128810;BA.debugLine="For i = 0 To 2";
if (true) break;

case 4:
//for
this.state = 7;
step21 = 1;
limit21 = (int) (2);
_i = (int) (0) ;
this.state = 10;
if (true) break;

case 10:
//C
this.state = 7;
if ((step21 &gt; 0 &amp;&amp; _i &lt;= limit21) || (step21 &lt; 0 &amp;&amp; _i &gt;= limit21)) this.state = 6;
if (true) break;

case 11:
//C
this.state = 10;
_i = ((int)(0 + _i + step21)) ;
if (true) break;

case 6:
//C
this.state = 11;
RDebugUtils.currentLine=4128811;
 //BA.debugLineNum = 4128811;BA.debugLine="Dim MyFiles As Map";
_myfiles = new anywheresoftware.b4a.objects.collections.Map();
RDebugUtils.currentLine=4128812;
 //BA.debugLineNum = 4128812;BA.debugLine="MyFiles = ListOfAttributes.Get(i)";
_myfiles = (anywheresoftware.b4a.objects.collections.Map) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.objects.collections.Map(), (anywheresoftware.b4a.objects.collections.Map.MyMap)(_listofattributes.Get(_i)));
RDebugUtils.currentLine=4128814;
 //BA.debugLineNum = 4128814;BA.debugLine="FileName = MyFiles.Get(\"filename\")";
_filename = BA.ObjectToString(_myfiles.Get((Object)("filename")));
RDebugUtils.currentLine=4128815;
 //BA.debugLineNum = 4128815;BA.debugLine="FileDate = MyFiles.Get(\"mtime\")";
_filedate = BA.ObjectToLongNumber(_myfiles.Get((Object)("mtime")));
RDebugUtils.currentLine=4128817;
 //BA.debugLineNum = 4128817;BA.debugLine="Dim unixtime As Long = FileDate ' 1395744770 '";
_unixtime = _filedate;
RDebugUtils.currentLine=4128818;
 //BA.debugLineNum = 4128818;BA.debugLine="Dim targetDate As Long = DateUtils.UnixTimeToTi";
_targetdate = parent.mostCurrent._dateutils._unixtimetoticks(mostCurrent.activityBA,_unixtime);
RDebugUtils.currentLine=4128819;
 //BA.debugLineNum = 4128819;BA.debugLine="DateTime.DateFormat = \"dd.MM.yyyy\"";
anywheresoftware.b4a.keywords.Common.DateTime.setDateFormat("dd.MM.yyyy");
RDebugUtils.currentLine=4128820;
 //BA.debugLineNum = 4128820;BA.debugLine="DateTime.TimeFormat = \"HH:mm:ss\"";
anywheresoftware.b4a.keywords.Common.DateTime.setTimeFormat("HH:mm:ss");
RDebugUtils.currentLine=4128821;
 //BA.debugLineNum = 4128821;BA.debugLine="DateTime.SetTimeZone(0)";
anywheresoftware.b4a.keywords.Common.DateTime.SetTimeZone(0);
RDebugUtils.currentLine=4128826;
 //BA.debugLineNum = 4128826;BA.debugLine="Log(FileName &amp; \" - \" &amp; \" - \" &amp; DateTime.Date(ta";
anywheresoftware.b4a.keywords.Common.LogImpl("14128826",_filename+" - "+" - "+anywheresoftware.b4a.keywords.Common.DateTime.Date(_targetdate)+" "+anywheresoftware.b4a.keywords.Common.DateTime.Time(_targetdate),0);
 if (true) break;
if (true) break;

case 7:
//C
this.state = 8;
;
 if (true) break;

case 8:
//C
this.state = -1;
;
RDebugUtils.currentLine=4128832;
 //BA.debugLineNum = 4128832;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
public static void  _buttonfiledialog_click() throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(mostCurrent.activityBA, "buttonfiledialog_click", false))
	 {Debug.delegate(mostCurrent.activityBA, "buttonfiledialog_click", null); return;}
ResumableSub_ButtonFileDialog_Click rsub = new ResumableSub_ButtonFileDialog_Click(null);
rsub.resume(processBA, null);
}
public static class ResumableSub_ButtonFileDialog_Click extends BA.ResumableSub {
public ResumableSub_ButtonFileDialog_Click(scott.UploadAFile.main parent) {
this.parent = parent;
}
scott.UploadAFile.main parent;
anywheresoftware.b4a.agraham.dialogs.InputDialog.FileDialog _fd = null;
Object _sf = null;
int _result = 0;

@Override
public void resume(BA ba, Object[] result) throws Exception{
RDebugUtils.currentModule="main";

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
RDebugUtils.currentLine=458753;
 //BA.debugLineNum = 458753;BA.debugLine="Dim fd As FileDialog";
_fd = new anywheresoftware.b4a.agraham.dialogs.InputDialog.FileDialog();
RDebugUtils.currentLine=458754;
 //BA.debugLineNum = 458754;BA.debugLine="fd.FilePath = File.DirRootExternal 'rp.GetSafeDir";
_fd.setFilePath(anywheresoftware.b4a.keywords.Common.File.getDirRootExternal());
RDebugUtils.currentLine=458755;
 //BA.debugLineNum = 458755;BA.debugLine="Dim sf As Object = fd.ShowAsync(\"Select file\", \"Y";
_sf = _fd.ShowAsync(BA.ObjectToCharSequence("Select file"),"Yes","Cancel","No",mostCurrent.activityBA,(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null),anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=458756;
 //BA.debugLineNum = 458756;BA.debugLine="Wait For (sf) Dialog_Result(Result As Int)";
anywheresoftware.b4a.keywords.Common.WaitFor("dialog_result", processBA, new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "main", "buttonfiledialog_click"), _sf);
this.state = 5;
return;
case 5:
//C
this.state = 1;
_result = (Integer) result[0];
;
RDebugUtils.currentLine=458757;
 //BA.debugLineNum = 458757;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;
RDebugUtils.currentLine=458758;
 //BA.debugLineNum = 458758;BA.debugLine="Log(\"File path: \" &amp; fd.FilePath)";
anywheresoftware.b4a.keywords.Common.LogImpl("1458758","File path: "+_fd.getFilePath(),0);
RDebugUtils.currentLine=458759;
 //BA.debugLineNum = 458759;BA.debugLine="Log(\"File name: \" &amp; fd.ChosenName)";
anywheresoftware.b4a.keywords.Common.LogImpl("1458759","File name: "+_fd.getChosenName(),0);
 if (true) break;

case 4:
//C
this.state = -1;
;
RDebugUtils.currentLine=458762;
 //BA.debugLineNum = 458762;BA.debugLine="MyFile = fd.ChosenName";
parent._myfile = _fd.getChosenName();
RDebugUtils.currentLine=458763;
 //BA.debugLineNum = 458763;BA.debugLine="Label1.Text = MyFile";
parent.mostCurrent._label1.setText(BA.ObjectToCharSequence(parent._myfile));
RDebugUtils.currentLine=458765;
 //BA.debugLineNum = 458765;BA.debugLine="File.Copy(fd.FilePath,MyFile,File.DirDefaultExter";
anywheresoftware.b4a.keywords.Common.File.Copy(_fd.getFilePath(),parent._myfile,anywheresoftware.b4a.keywords.Common.File.getDirDefaultExternal(),parent._myfile);
RDebugUtils.currentLine=458766;
 //BA.debugLineNum = 458766;BA.debugLine="Sleep(2000)";
anywheresoftware.b4a.keywords.Common.Sleep(mostCurrent.activityBA,new anywheresoftware.b4a.shell.DebugResumableSub.DelegatableResumableSub(this, "main", "buttonfiledialog_click"),(int) (2000));
this.state = 6;
return;
case 6:
//C
this.state = -1;
;
RDebugUtils.currentLine=458768;
 //BA.debugLineNum = 458768;BA.debugLine="End Sub";
if (true) break;

            }
        }
    }
}
}</pre></body></html>