commit 1db07a3b9437355334afca0541c0ed136c2afdb9 Author: Stefan Hutter Date: Sun Dec 19 10:41:13 2021 +0100 Initial Commit diff --git a/Aquarihelp.b4a b/Aquarihelp.b4a new file mode 100644 index 0000000..129bb74 --- /dev/null +++ b/Aquarihelp.b4a @@ -0,0 +1,70 @@ +Build1=Default,b4a.example +File1=Layout.bal +FileGroup1=Default Group +Group=Default Group +Library1=core +Library2=okhttputils2 +Library3=xui +Library4=javaobject +ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~~\n~)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~CreateResourceFromFile(Macro, Themes.LightTheme)~\n~'End of default text.~\n~ +Module1=Starter +NumberOfFiles=1 +NumberOfLibraries=4 +NumberOfModules=1 +Version=11 +@EndOfDesignText@ +#Region Project Attributes + #ApplicationLabel: AquariHelp + #VersionCode: 1 + #VersionName: + 'SupportedOrientations possible values: unspecified, landscape or portrait. + #SupportedOrientations: unspecified + #CanInstallToExternalStorage: False +#End Region + +#Region Activity Attributes + #FullScreen: True + #IncludeTitle: True +#End Region + +Sub Process_Globals + 'These global variables will be declared once when the application starts. + 'These variables can be accessed from all modules. + Private xui As XUI +End Sub + +Sub Globals + 'These global variables will be redeclared each time the activity is created. + Private WebView1 As WebView + Private tempPostUrl As String="https://aquarihelp.com/index_login.php" + Private tempPostString As String="mobiletest=android_apk" + Private bytesOfPOstRequest() As Byte +End Sub + +Sub Activity_Create(FirstTime As Boolean) + Activity.LoadLayout("Layout") + Activity.Title="Aquarihelp" +' WebView1.LoadUrl("https://aquarihelp.com/index_login.php") +' Dim Post As HttpJob +' Post.Initialize("Job2", Me) +' Post.PostString("https://aquarihelp.com/index_login.php", "mobiletest=android_apk") + + + + bytesOfPOstRequest=tempPostString.GetBytes("UTF8") + Private jo As JavaObject=WebView1 + jo.RunMethod("postUrl",Array As Object(tempPostUrl,bytesOfPOstRequest)) + +End Sub + +Sub Activity_Resume + +End Sub + +Sub Activity_Pause (UserClosed As Boolean) + +End Sub + +Sub Button1_Click + xui.MsgboxAsync("Hello world!", "B4X") +End Sub \ No newline at end of file diff --git a/Aquarihelp.b4a.meta b/Aquarihelp.b4a.meta new file mode 100644 index 0000000..eeab6ac --- /dev/null +++ b/Aquarihelp.b4a.meta @@ -0,0 +1,9 @@ +ModuleBookmarks0= +ModuleBookmarks1= +ModuleBreakpoints0= +ModuleBreakpoints1= +ModuleClosedNodes0= +ModuleClosedNodes1=1 +NavigationStack=Main,Activity_Pause,33,0,Main,Process_Globals,17,4,Main,Button1_Click,38,6,Main,Globals,24,0,Main,Activity_Create,28,6,Visueller Designer,Layout.bal,-100,3 +SelectedBuild=0 +VisibleModules=1 diff --git a/AutoBackups/Backup Aquarihelp 2021-11-03 21.25.zip b/AutoBackups/Backup Aquarihelp 2021-11-03 21.25.zip new file mode 100644 index 0000000..cdd3cca Binary files /dev/null and b/AutoBackups/Backup Aquarihelp 2021-11-03 21.25.zip differ diff --git a/AutoBackups/Backup Aquarihelp 2021-11-06 07.06.zip b/AutoBackups/Backup Aquarihelp 2021-11-06 07.06.zip new file mode 100644 index 0000000..a12c81a Binary files /dev/null and b/AutoBackups/Backup Aquarihelp 2021-11-06 07.06.zip differ diff --git a/AutoBackups/Backup Aquarihelp 2021-11-06 07.59.zip b/AutoBackups/Backup Aquarihelp 2021-11-06 07.59.zip new file mode 100644 index 0000000..f0d1dfd Binary files /dev/null and b/AutoBackups/Backup Aquarihelp 2021-11-06 07.59.zip differ diff --git a/Files/layout.bal b/Files/layout.bal new file mode 100644 index 0000000..a8c9431 Binary files /dev/null and b/Files/layout.bal differ diff --git a/Logos/logo.jpg b/Logos/logo.jpg new file mode 100644 index 0000000..d9ce3b9 Binary files /dev/null and b/Logos/logo.jpg differ diff --git a/Objects/AndroidManifest.xml b/Objects/AndroidManifest.xml new file mode 100644 index 0000000..2373ede --- /dev/null +++ b/Objects/AndroidManifest.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Objects/Aquarihelp.apk b/Objects/Aquarihelp.apk new file mode 100644 index 0000000..33b1b00 Binary files /dev/null and b/Objects/Aquarihelp.apk differ diff --git a/Objects/bin/classes/b4a/example/R$drawable.class b/Objects/bin/classes/b4a/example/R$drawable.class new file mode 100644 index 0000000..4938ab5 Binary files /dev/null and b/Objects/bin/classes/b4a/example/R$drawable.class differ diff --git a/Objects/bin/classes/b4a/example/R$style.class b/Objects/bin/classes/b4a/example/R$style.class new file mode 100644 index 0000000..99cc32e Binary files /dev/null and b/Objects/bin/classes/b4a/example/R$style.class differ diff --git a/Objects/bin/classes/b4a/example/R.class b/Objects/bin/classes/b4a/example/R.class new file mode 100644 index 0000000..05e5536 Binary files /dev/null and b/Objects/bin/classes/b4a/example/R.class differ diff --git a/Objects/bin/classes/b4a/example/designerscripts/LS_layout.class b/Objects/bin/classes/b4a/example/designerscripts/LS_layout.class new file mode 100644 index 0000000..558953f Binary files /dev/null and b/Objects/bin/classes/b4a/example/designerscripts/LS_layout.class differ diff --git a/Objects/bin/classes/b4a/example/httpjob$_multipartfiledata.class b/Objects/bin/classes/b4a/example/httpjob$_multipartfiledata.class new file mode 100644 index 0000000..6421e3e Binary files /dev/null and b/Objects/bin/classes/b4a/example/httpjob$_multipartfiledata.class differ diff --git a/Objects/bin/classes/b4a/example/httpjob.class b/Objects/bin/classes/b4a/example/httpjob.class new file mode 100644 index 0000000..bece660 Binary files /dev/null and b/Objects/bin/classes/b4a/example/httpjob.class differ diff --git a/Objects/bin/classes/b4a/example/httputils2service$1.class b/Objects/bin/classes/b4a/example/httputils2service$1.class new file mode 100644 index 0000000..16b6127 Binary files /dev/null and b/Objects/bin/classes/b4a/example/httputils2service$1.class differ diff --git a/Objects/bin/classes/b4a/example/httputils2service$2.class b/Objects/bin/classes/b4a/example/httputils2service$2.class new file mode 100644 index 0000000..97b01ca Binary files /dev/null and b/Objects/bin/classes/b4a/example/httputils2service$2.class differ diff --git a/Objects/bin/classes/b4a/example/httputils2service$httputils2service_BR.class b/Objects/bin/classes/b4a/example/httputils2service$httputils2service_BR.class new file mode 100644 index 0000000..e5a70ed Binary files /dev/null and b/Objects/bin/classes/b4a/example/httputils2service$httputils2service_BR.class differ diff --git a/Objects/bin/classes/b4a/example/httputils2service.class b/Objects/bin/classes/b4a/example/httputils2service.class new file mode 100644 index 0000000..8134592 Binary files /dev/null and b/Objects/bin/classes/b4a/example/httputils2service.class differ diff --git a/Objects/bin/classes/b4a/example/main$1.class b/Objects/bin/classes/b4a/example/main$1.class new file mode 100644 index 0000000..df5c4c3 Binary files /dev/null and b/Objects/bin/classes/b4a/example/main$1.class differ diff --git a/Objects/bin/classes/b4a/example/main$B4AMenuItemsClickListener.class b/Objects/bin/classes/b4a/example/main$B4AMenuItemsClickListener.class new file mode 100644 index 0000000..20bffe9 Binary files /dev/null and b/Objects/bin/classes/b4a/example/main$B4AMenuItemsClickListener.class differ diff --git a/Objects/bin/classes/b4a/example/main$HandleKeyDelayed.class b/Objects/bin/classes/b4a/example/main$HandleKeyDelayed.class new file mode 100644 index 0000000..e8aadd5 Binary files /dev/null and b/Objects/bin/classes/b4a/example/main$HandleKeyDelayed.class differ diff --git a/Objects/bin/classes/b4a/example/main$ResumeMessage.class b/Objects/bin/classes/b4a/example/main$ResumeMessage.class new file mode 100644 index 0000000..c7aa97a Binary files /dev/null and b/Objects/bin/classes/b4a/example/main$ResumeMessage.class differ diff --git a/Objects/bin/classes/b4a/example/main$WaitForLayout.class b/Objects/bin/classes/b4a/example/main$WaitForLayout.class new file mode 100644 index 0000000..3e1f5a4 Binary files /dev/null and b/Objects/bin/classes/b4a/example/main$WaitForLayout.class differ diff --git a/Objects/bin/classes/b4a/example/main.class b/Objects/bin/classes/b4a/example/main.class new file mode 100644 index 0000000..7c6d4f3 Binary files /dev/null and b/Objects/bin/classes/b4a/example/main.class differ diff --git a/Objects/bin/classes/b4a/example/starter$1.class b/Objects/bin/classes/b4a/example/starter$1.class new file mode 100644 index 0000000..8c49eb0 Binary files /dev/null and b/Objects/bin/classes/b4a/example/starter$1.class differ diff --git a/Objects/bin/classes/b4a/example/starter$2.class b/Objects/bin/classes/b4a/example/starter$2.class new file mode 100644 index 0000000..b26a3ad Binary files /dev/null and b/Objects/bin/classes/b4a/example/starter$2.class differ diff --git a/Objects/bin/classes/b4a/example/starter$starter_BR.class b/Objects/bin/classes/b4a/example/starter$starter_BR.class new file mode 100644 index 0000000..395b50c Binary files /dev/null and b/Objects/bin/classes/b4a/example/starter$starter_BR.class differ diff --git a/Objects/bin/classes/b4a/example/starter.class b/Objects/bin/classes/b4a/example/starter.class new file mode 100644 index 0000000..122b9b1 Binary files /dev/null and b/Objects/bin/classes/b4a/example/starter.class differ diff --git a/Objects/bin/extra/compiled_resources/b4a.example.zip b/Objects/bin/extra/compiled_resources/b4a.example.zip new file mode 100644 index 0000000..3c09b04 Binary files /dev/null and b/Objects/bin/extra/compiled_resources/b4a.example.zip differ diff --git a/Objects/bin/temp.ap_ b/Objects/bin/temp.ap_ new file mode 100644 index 0000000..ffd364b Binary files /dev/null and b/Objects/bin/temp.ap_ differ diff --git a/Objects/classes.dex b/Objects/classes.dex new file mode 100644 index 0000000..ddf8766 Binary files /dev/null and b/Objects/classes.dex differ diff --git a/Objects/gen/b4a/example/R.java b/Objects/gen/b4a/example/R.java new file mode 100644 index 0000000..5d123e5 --- /dev/null +++ b/Objects/gen/b4a/example/R.java @@ -0,0 +1,18 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package b4a.example; + +public final class R { + public static final class drawable { + public static final int icon=0x7f010000; + } + public static final class style { + public static final int LightTheme=0x7f020000; + public static final int LowerCaseMenu=0x7f020001; + } +} \ No newline at end of file diff --git a/Objects/res/drawable/icon.png b/Objects/res/drawable/icon.png new file mode 100644 index 0000000..6da1021 Binary files /dev/null and b/Objects/res/drawable/icon.png differ diff --git a/Objects/res/values-v14/theme.xml b/Objects/res/values-v14/theme.xml new file mode 100644 index 0000000..dce838a --- /dev/null +++ b/Objects/res/values-v14/theme.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/Objects/res/values-v20/theme.xml b/Objects/res/values-v20/theme.xml new file mode 100644 index 0000000..2d18e78 --- /dev/null +++ b/Objects/res/values-v20/theme.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/Objects/shell/bin/classes/b4a/example/httpjob.class b/Objects/shell/bin/classes/b4a/example/httpjob.class new file mode 100644 index 0000000..76372b3 Binary files /dev/null and b/Objects/shell/bin/classes/b4a/example/httpjob.class differ diff --git a/Objects/shell/bin/classes/b4a/example/httpjob_subs_0.class b/Objects/shell/bin/classes/b4a/example/httpjob_subs_0.class new file mode 100644 index 0000000..5a32bca Binary files /dev/null and b/Objects/shell/bin/classes/b4a/example/httpjob_subs_0.class differ diff --git a/Objects/shell/bin/classes/b4a/example/httputils2service.class b/Objects/shell/bin/classes/b4a/example/httputils2service.class new file mode 100644 index 0000000..66f3811 Binary files /dev/null and b/Objects/shell/bin/classes/b4a/example/httputils2service.class differ diff --git a/Objects/shell/bin/classes/b4a/example/httputils2service_subs_0.class b/Objects/shell/bin/classes/b4a/example/httputils2service_subs_0.class new file mode 100644 index 0000000..d636fc4 Binary files /dev/null and b/Objects/shell/bin/classes/b4a/example/httputils2service_subs_0.class differ diff --git a/Objects/shell/bin/classes/b4a/example/main.class b/Objects/shell/bin/classes/b4a/example/main.class new file mode 100644 index 0000000..7b8df97 Binary files /dev/null and b/Objects/shell/bin/classes/b4a/example/main.class differ diff --git a/Objects/shell/bin/classes/b4a/example/main_subs_0.class b/Objects/shell/bin/classes/b4a/example/main_subs_0.class new file mode 100644 index 0000000..14df3f5 Binary files /dev/null and b/Objects/shell/bin/classes/b4a/example/main_subs_0.class differ diff --git a/Objects/shell/bin/classes/b4a/example/starter.class b/Objects/shell/bin/classes/b4a/example/starter.class new file mode 100644 index 0000000..09be6b2 Binary files /dev/null and b/Objects/shell/bin/classes/b4a/example/starter.class differ diff --git a/Objects/shell/bin/classes/b4a/example/starter_subs_0.class b/Objects/shell/bin/classes/b4a/example/starter_subs_0.class new file mode 100644 index 0000000..2ed5c81 Binary files /dev/null and b/Objects/shell/bin/classes/b4a/example/starter_subs_0.class differ diff --git a/Objects/src/b4a/example/designerscripts/LS_layout.java b/Objects/src/b4a/example/designerscripts/LS_layout.java new file mode 100644 index 0000000..b2e1ab9 --- /dev/null +++ b/Objects/src/b4a/example/designerscripts/LS_layout.java @@ -0,0 +1,34 @@ +package b4a.example.designerscripts; +import anywheresoftware.b4a.objects.TextViewWrapper; +import anywheresoftware.b4a.objects.ImageViewWrapper; +import anywheresoftware.b4a.BA; + + +public class LS_layout{ + +public static void LS_320x480_1(java.util.LinkedHashMap views, int width, int height, float scale) { +anywheresoftware.b4a.keywords.LayoutBuilder.setScaleRate(0.3); +//BA.debugLineNum = 2;BA.debugLine="Panel1.Top=0"[Layout/320x480,scale=1] +views.get("panel1").vw.setTop((int)(0d)); +//BA.debugLineNum = 3;BA.debugLine="Panel1.Left=0"[Layout/320x480,scale=1] +views.get("panel1").vw.setLeft((int)(0d)); +//BA.debugLineNum = 4;BA.debugLine="Panel1.Height=100%y"[Layout/320x480,scale=1] +views.get("panel1").vw.setHeight((int)((100d / 100 * height))); +//BA.debugLineNum = 5;BA.debugLine="Panel1.Width=100%x"[Layout/320x480,scale=1] +views.get("panel1").vw.setWidth((int)((100d / 100 * width))); +//BA.debugLineNum = 6;BA.debugLine="WebView1.Top=Panel1.Top"[Layout/320x480,scale=1] +views.get("webview1").vw.setTop((int)((views.get("panel1").vw.getTop()))); +//BA.debugLineNum = 7;BA.debugLine="WebView1.Height=Panel1.Height"[Layout/320x480,scale=1] +views.get("webview1").vw.setHeight((int)((views.get("panel1").vw.getHeight()))); +//BA.debugLineNum = 8;BA.debugLine="WebView1.Width=Panel1.Width"[Layout/320x480,scale=1] +views.get("webview1").vw.setWidth((int)((views.get("panel1").vw.getWidth()))); +//BA.debugLineNum = 9;BA.debugLine="WebView1.Left=Panel1.Left"[Layout/320x480,scale=1] +views.get("webview1").vw.setLeft((int)((views.get("panel1").vw.getLeft()))); + +} +public static void LS_general(java.util.LinkedHashMap views, int width, int height, float scale) { +anywheresoftware.b4a.keywords.LayoutBuilder.setScaleRate(0.3); +anywheresoftware.b4a.keywords.LayoutBuilder.scaleAll(views); + +} +} \ No newline at end of file diff --git a/Objects/src/b4a/example/httpjob.java b/Objects/src/b4a/example/httpjob.java new file mode 100644 index 0000000..5c7be1f --- /dev/null +++ b/Objects/src/b4a/example/httpjob.java @@ -0,0 +1,554 @@ +package b4a.example; + + +import anywheresoftware.b4a.BA; +import anywheresoftware.b4a.B4AClass; +import anywheresoftware.b4a.BALayout; +import anywheresoftware.b4a.debug.*; + +public class httpjob extends B4AClass.ImplB4AClass implements BA.SubDelegator{ + private static java.util.HashMap htSubs; + private void innerInitialize(BA _ba) throws Exception { + if (ba == null) { + ba = new BA(_ba, this, htSubs, "b4a.example.httpjob"); + if (htSubs == null) { + ba.loadHtSubs(this.getClass()); + htSubs = ba.htSubs; + } + + } + if (BA.isShellModeRuntimeCheck(ba)) + this.getClass().getMethod("_class_globals", b4a.example.httpjob.class).invoke(this, new Object[] {null}); + else + ba.raiseEvent2(null, true, "class_globals", false); + } + + public anywheresoftware.b4a.keywords.Common __c = null; +public String _jobname = ""; +public boolean _success = false; +public String _username = ""; +public String _password = ""; +public String _errormessage = ""; +public Object _target = null; +public String _taskid = ""; +public anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest _req = null; +public anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse _response = null; +public Object _tag = null; +public String _invalidurl = ""; +public String _defaultscheme = ""; +public b4a.example.main _main = null; +public b4a.example.starter _starter = null; +public b4a.example.httputils2service _httputils2service = null; +public static class _multipartfiledata{ +public boolean IsInitialized; +public String Dir; +public String FileName; +public String KeyName; +public String ContentType; +public void Initialize() { +IsInitialized = true; +Dir = ""; +FileName = ""; +KeyName = ""; +ContentType = ""; +} +@Override + public String toString() { + return BA.TypeToString(this, false); + }} +public String _addscheme(String _link) throws Exception{ + //BA.debugLineNum = 43;BA.debugLine="Private Sub AddScheme (Link As String) As String"; + //BA.debugLineNum = 44;BA.debugLine="If DefaultScheme = \"\" Or Link.Contains(\":\") Then"; +if ((_defaultscheme).equals("") || _link.contains(":")) { +if (true) return _link;}; + //BA.debugLineNum = 45;BA.debugLine="Return DefaultScheme & \"://\" & Link"; +if (true) return _defaultscheme+"://"+_link; + //BA.debugLineNum = 46;BA.debugLine="End Sub"; +return ""; +} +public String _class_globals() throws Exception{ + //BA.debugLineNum = 2;BA.debugLine="Sub Class_Globals"; + //BA.debugLineNum = 3;BA.debugLine="Public JobName As String"; +_jobname = ""; + //BA.debugLineNum = 4;BA.debugLine="Public Success As Boolean"; +_success = false; + //BA.debugLineNum = 5;BA.debugLine="Public Username, Password As String"; +_username = ""; +_password = ""; + //BA.debugLineNum = 6;BA.debugLine="Public ErrorMessage As String"; +_errormessage = ""; + //BA.debugLineNum = 7;BA.debugLine="Private target As Object"; +_target = new Object(); + //BA.debugLineNum = 13;BA.debugLine="Private taskId As String"; +_taskid = ""; + //BA.debugLineNum = 15;BA.debugLine="Private req As OkHttpRequest"; +_req = new anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest(); + //BA.debugLineNum = 16;BA.debugLine="Public Response As OkHttpResponse"; +_response = new anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse(); + //BA.debugLineNum = 25;BA.debugLine="Public Tag As Object"; +_tag = new Object(); + //BA.debugLineNum = 26;BA.debugLine="Type MultipartFileData (Dir As String, FileName A"; +; + //BA.debugLineNum = 30;BA.debugLine="Private Const InvalidURL As String = \"https://inv"; +_invalidurl = "https://invalid-url/"; + //BA.debugLineNum = 31;BA.debugLine="Public DefaultScheme As String = \"https\""; +_defaultscheme = "https"; + //BA.debugLineNum = 32;BA.debugLine="End Sub"; +return ""; +} +public String _complete(int _id) throws Exception{ + //BA.debugLineNum = 306;BA.debugLine="Public Sub Complete (id As Int)"; + //BA.debugLineNum = 307;BA.debugLine="taskId = id"; +_taskid = BA.NumberToString(_id); + //BA.debugLineNum = 308;BA.debugLine="CallSubDelayed2(target, \"JobDone\", Me)"; +__c.CallSubDelayed2(ba,_target,"JobDone",this); + //BA.debugLineNum = 309;BA.debugLine="End Sub"; +return ""; +} +public String _delete(String _link) throws Exception{ + //BA.debugLineNum = 252;BA.debugLine="Public Sub Delete(Link As String)"; + //BA.debugLineNum = 253;BA.debugLine="Try"; +try { //BA.debugLineNum = 254;BA.debugLine="Link = AddScheme(Link)"; +_link = _addscheme(_link); + //BA.debugLineNum = 255;BA.debugLine="req.InitializeDelete(Link)"; +_req.InitializeDelete(_link); + } + catch (Exception e5) { + ba.setLastException(e5); //BA.debugLineNum = 257;BA.debugLine="Log($\"Invalid link: ${Link}\"$)"; +__c.LogImpl("92424837",("Invalid link: "+__c.SmartStringFormatter("",(Object)(_link))+""),0); + //BA.debugLineNum = 258;BA.debugLine="req.InitializeDelete(InvalidURL)"; +_req.InitializeDelete(_invalidurl); + }; + //BA.debugLineNum = 260;BA.debugLine="CallSubDelayed2(HttpUtils2Service, \"SubmitJob\", M"; +__c.CallSubDelayed2(ba,(Object)(_httputils2service.getObject()),"SubmitJob",this); + //BA.debugLineNum = 261;BA.debugLine="End Sub"; +return ""; +} +public String _delete2(String _link,String[] _parameters) throws Exception{ + //BA.debugLineNum = 263;BA.debugLine="Public Sub Delete2(Link As String, Parameters() As"; + //BA.debugLineNum = 264;BA.debugLine="Try"; +try { //BA.debugLineNum = 265;BA.debugLine="Link = AddScheme(Link)"; +_link = _addscheme(_link); + //BA.debugLineNum = 266;BA.debugLine="req.InitializeDelete(escapeLink(Link, Parameters"; +_req.InitializeDelete(_escapelink(_link,_parameters)); + } + catch (Exception e5) { + ba.setLastException(e5); //BA.debugLineNum = 268;BA.debugLine="Log($\"Invalid link: ${Link}\"$)"; +__c.LogImpl("92490373",("Invalid link: "+__c.SmartStringFormatter("",(Object)(_link))+""),0); + //BA.debugLineNum = 269;BA.debugLine="req.InitializeDelete(escapeLink(InvalidURL, Para"; +_req.InitializeDelete(_escapelink(_invalidurl,_parameters)); + }; + //BA.debugLineNum = 271;BA.debugLine="CallSubDelayed2(HttpUtils2Service, \"SubmitJob\", M"; +__c.CallSubDelayed2(ba,(Object)(_httputils2service.getObject()),"SubmitJob",this); + //BA.debugLineNum = 272;BA.debugLine="End Sub"; +return ""; +} +public String _download(String _link) throws Exception{ + //BA.debugLineNum = 210;BA.debugLine="Public Sub Download(Link As String)"; + //BA.debugLineNum = 211;BA.debugLine="Try"; +try { //BA.debugLineNum = 212;BA.debugLine="Link = AddScheme(Link)"; +_link = _addscheme(_link); + //BA.debugLineNum = 213;BA.debugLine="req.InitializeGet(Link)"; +_req.InitializeGet(_link); + } + catch (Exception e5) { + ba.setLastException(e5); //BA.debugLineNum = 215;BA.debugLine="Log($\"Invalid link: ${Link}\"$)"; +__c.LogImpl("92228229",("Invalid link: "+__c.SmartStringFormatter("",(Object)(_link))+""),0); + //BA.debugLineNum = 216;BA.debugLine="req.InitializeGet(InvalidURL)"; +_req.InitializeGet(_invalidurl); + }; + //BA.debugLineNum = 218;BA.debugLine="CallSubDelayed2(HttpUtils2Service, \"SubmitJob\", M"; +__c.CallSubDelayed2(ba,(Object)(_httputils2service.getObject()),"SubmitJob",this); + //BA.debugLineNum = 219;BA.debugLine="End Sub"; +return ""; +} +public String _download2(String _link,String[] _parameters) throws Exception{ + //BA.debugLineNum = 226;BA.debugLine="Public Sub Download2(Link As String, Parameters()"; + //BA.debugLineNum = 227;BA.debugLine="Try"; +try { //BA.debugLineNum = 228;BA.debugLine="Link = AddScheme(Link)"; +_link = _addscheme(_link); + //BA.debugLineNum = 229;BA.debugLine="req.InitializeGet(escapeLink(Link, Parameters))"; +_req.InitializeGet(_escapelink(_link,_parameters)); + } + catch (Exception e5) { + ba.setLastException(e5); //BA.debugLineNum = 231;BA.debugLine="Log($\"Invalid link: ${Link}\"$)"; +__c.LogImpl("92293765",("Invalid link: "+__c.SmartStringFormatter("",(Object)(_link))+""),0); + //BA.debugLineNum = 232;BA.debugLine="req.InitializeGet(escapeLink(InvalidURL, Paramet"; +_req.InitializeGet(_escapelink(_invalidurl,_parameters)); + }; + //BA.debugLineNum = 234;BA.debugLine="CallSubDelayed2(HttpUtils2Service, \"SubmitJob\", M"; +__c.CallSubDelayed2(ba,(Object)(_httputils2service.getObject()),"SubmitJob",this); + //BA.debugLineNum = 235;BA.debugLine="End Sub"; +return ""; +} +public String _escapelink(String _link,String[] _parameters) throws Exception{ +anywheresoftware.b4a.keywords.StringBuilderWrapper _sb = null; +anywheresoftware.b4a.objects.StringUtils _su = null; +int _i = 0; + //BA.debugLineNum = 237;BA.debugLine="Private Sub escapeLink(Link As String, Parameters("; + //BA.debugLineNum = 238;BA.debugLine="Dim sb As StringBuilder"; +_sb = new anywheresoftware.b4a.keywords.StringBuilderWrapper(); + //BA.debugLineNum = 239;BA.debugLine="sb.Initialize"; +_sb.Initialize(); + //BA.debugLineNum = 240;BA.debugLine="sb.Append(Link)"; +_sb.Append(_link); + //BA.debugLineNum = 241;BA.debugLine="If Parameters.Length > 0 Then sb.Append(\"?\")"; +if (_parameters.length>0) { +_sb.Append("?");}; + //BA.debugLineNum = 242;BA.debugLine="Dim su As StringUtils"; +_su = new anywheresoftware.b4a.objects.StringUtils(); + //BA.debugLineNum = 243;BA.debugLine="For i = 0 To Parameters.Length - 1 Step 2"; +{ +final int step6 = 2; +final int limit6 = (int) (_parameters.length-1); +_i = (int) (0) ; +for (;_i <= limit6 ;_i = _i + step6 ) { + //BA.debugLineNum = 244;BA.debugLine="If i > 0 Then sb.Append(\"&\")"; +if (_i>0) { +_sb.Append("&");}; + //BA.debugLineNum = 245;BA.debugLine="sb.Append(su.EncodeUrl(Parameters(i), \"UTF8\")).A"; +_sb.Append(_su.EncodeUrl(_parameters[_i],"UTF8")).Append("="); + //BA.debugLineNum = 246;BA.debugLine="sb.Append(su.EncodeUrl(Parameters(i + 1), \"UTF8\""; +_sb.Append(_su.EncodeUrl(_parameters[(int) (_i+1)],"UTF8")); + } +}; + //BA.debugLineNum = 248;BA.debugLine="Return sb.ToString"; +if (true) return _sb.ToString(); + //BA.debugLineNum = 249;BA.debugLine="End Sub"; +return ""; +} +public anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper _getbitmap() throws Exception{ +anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper _b = null; + //BA.debugLineNum = 321;BA.debugLine="Public Sub GetBitmap As Bitmap"; + //BA.debugLineNum = 322;BA.debugLine="Dim b As Bitmap"; +_b = new anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper(); + //BA.debugLineNum = 323;BA.debugLine="b = LoadBitmap(HttpUtils2Service.TempFolder, task"; +_b = __c.LoadBitmap(_httputils2service._tempfolder /*String*/ ,_taskid); + //BA.debugLineNum = 324;BA.debugLine="Return b"; +if (true) return _b; + //BA.debugLineNum = 325;BA.debugLine="End Sub"; +return null; +} +public anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper _getbitmapresize(int _width,int _height,boolean _keepaspectratio) throws Exception{ + //BA.debugLineNum = 332;BA.debugLine="Public Sub GetBitmapResize(Width As Int, Height As"; + //BA.debugLineNum = 333;BA.debugLine="Return LoadBitmapResize(HttpUtils2Service.TempFol"; +if (true) return __c.LoadBitmapResize(_httputils2service._tempfolder /*String*/ ,_taskid,_width,_height,_keepaspectratio); + //BA.debugLineNum = 334;BA.debugLine="End Sub"; +return null; +} +public anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper _getbitmapsample(int _width,int _height) throws Exception{ + //BA.debugLineNum = 328;BA.debugLine="Public Sub GetBitmapSample(Width As Int, Height As"; + //BA.debugLineNum = 329;BA.debugLine="Return LoadBitmapSample(HttpUtils2Service.TempFol"; +if (true) return __c.LoadBitmapSample(_httputils2service._tempfolder /*String*/ ,_taskid,_width,_height); + //BA.debugLineNum = 330;BA.debugLine="End Sub"; +return null; +} +public anywheresoftware.b4a.objects.streams.File.InputStreamWrapper _getinputstream() throws Exception{ +anywheresoftware.b4a.objects.streams.File.InputStreamWrapper _in = null; + //BA.debugLineNum = 338;BA.debugLine="Public Sub GetInputStream As InputStream"; + //BA.debugLineNum = 339;BA.debugLine="Dim In As InputStream"; +_in = new anywheresoftware.b4a.objects.streams.File.InputStreamWrapper(); + //BA.debugLineNum = 340;BA.debugLine="In = File.OpenInput(HttpUtils2Service.TempFolder,"; +_in = __c.File.OpenInput(_httputils2service._tempfolder /*String*/ ,_taskid); + //BA.debugLineNum = 341;BA.debugLine="Return In"; +if (true) return _in; + //BA.debugLineNum = 342;BA.debugLine="End Sub"; +return null; +} +public anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest _getrequest() throws Exception{ + //BA.debugLineNum = 301;BA.debugLine="Public Sub GetRequest As OkHttpRequest"; + //BA.debugLineNum = 302;BA.debugLine="Return req"; +if (true) return _req; + //BA.debugLineNum = 303;BA.debugLine="End Sub"; +return null; +} +public String _getstring() throws Exception{ + //BA.debugLineNum = 282;BA.debugLine="Public Sub GetString As String"; + //BA.debugLineNum = 283;BA.debugLine="Return GetString2(\"UTF8\")"; +if (true) return _getstring2("UTF8"); + //BA.debugLineNum = 284;BA.debugLine="End Sub"; +return ""; +} +public String _getstring2(String _encoding) throws Exception{ +anywheresoftware.b4a.objects.streams.File.TextReaderWrapper _tr = null; +String _res = ""; + //BA.debugLineNum = 287;BA.debugLine="Public Sub GetString2(Encoding As String) As Strin"; + //BA.debugLineNum = 291;BA.debugLine="Dim tr As TextReader"; +_tr = new anywheresoftware.b4a.objects.streams.File.TextReaderWrapper(); + //BA.debugLineNum = 292;BA.debugLine="tr.Initialize2(File.OpenInput(HttpUtils2Service.T"; +_tr.Initialize2((java.io.InputStream)(__c.File.OpenInput(_httputils2service._tempfolder /*String*/ ,_taskid).getObject()),_encoding); + //BA.debugLineNum = 293;BA.debugLine="Dim res As String = tr.ReadAll"; +_res = _tr.ReadAll(); + //BA.debugLineNum = 294;BA.debugLine="tr.Close"; +_tr.Close(); + //BA.debugLineNum = 295;BA.debugLine="Return res"; +if (true) return _res; + //BA.debugLineNum = 297;BA.debugLine="End Sub"; +return ""; +} +public String _head(String _link) throws Exception{ + //BA.debugLineNum = 110;BA.debugLine="Public Sub Head(Link As String)"; + //BA.debugLineNum = 111;BA.debugLine="Try"; +try { //BA.debugLineNum = 112;BA.debugLine="Link = AddScheme(Link)"; +_link = _addscheme(_link); + //BA.debugLineNum = 113;BA.debugLine="req.InitializeHead(Link)"; +_req.InitializeHead(_link); + } + catch (Exception e5) { + ba.setLastException(e5); //BA.debugLineNum = 115;BA.debugLine="Log($\"Invalid link: ${Link}\"$)"; +__c.LogImpl("91966085",("Invalid link: "+__c.SmartStringFormatter("",(Object)(_link))+""),0); + //BA.debugLineNum = 116;BA.debugLine="req.InitializeHead(InvalidURL)"; +_req.InitializeHead(_invalidurl); + }; + //BA.debugLineNum = 118;BA.debugLine="CallSubDelayed2(HttpUtils2Service, \"SubmitJob\", M"; +__c.CallSubDelayed2(ba,(Object)(_httputils2service.getObject()),"SubmitJob",this); + //BA.debugLineNum = 119;BA.debugLine="End Sub"; +return ""; +} +public String _initialize(anywheresoftware.b4a.BA _ba,String _name,Object _targetmodule) throws Exception{ +innerInitialize(_ba); + //BA.debugLineNum = 38;BA.debugLine="Public Sub Initialize (Name As String, TargetModul"; + //BA.debugLineNum = 39;BA.debugLine="JobName = Name"; +_jobname = _name; + //BA.debugLineNum = 40;BA.debugLine="target = TargetModule"; +_target = _targetmodule; + //BA.debugLineNum = 41;BA.debugLine="End Sub"; +return ""; +} +public boolean _multipartstartsection(anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper _stream,boolean _empty) throws Exception{ + //BA.debugLineNum = 170;BA.debugLine="Private Sub MultipartStartSection (stream As Outpu"; + //BA.debugLineNum = 171;BA.debugLine="If empty = False Then"; +if (_empty==__c.False) { + //BA.debugLineNum = 172;BA.debugLine="stream.WriteBytes(Array As Byte(13, 10), 0, 2)"; +_stream.WriteBytes(new byte[]{(byte) (13),(byte) (10)},(int) (0),(int) (2)); + }else { + //BA.debugLineNum = 174;BA.debugLine="empty = False"; +_empty = __c.False; + }; + //BA.debugLineNum = 176;BA.debugLine="Return empty"; +if (true) return _empty; + //BA.debugLineNum = 177;BA.debugLine="End Sub"; +return false; +} +public String _patchbytes(String _link,byte[] _data) throws Exception{ + //BA.debugLineNum = 88;BA.debugLine="Public Sub PatchBytes(Link As String, Data() As By"; + //BA.debugLineNum = 89;BA.debugLine="Link = AddScheme(Link)"; +_link = _addscheme(_link); + //BA.debugLineNum = 97;BA.debugLine="Try"; +try { //BA.debugLineNum = 98;BA.debugLine="req.InitializePatch2(Link, Data)"; +_req.InitializePatch2(_link,_data); + } + catch (Exception e5) { + ba.setLastException(e5); //BA.debugLineNum = 100;BA.debugLine="Log($\"Invalid link: ${Link}\"$)"; +__c.LogImpl("91900556",("Invalid link: "+__c.SmartStringFormatter("",(Object)(_link))+""),0); + //BA.debugLineNum = 101;BA.debugLine="req.InitializePatch2(InvalidURL, Data)"; +_req.InitializePatch2(_invalidurl,_data); + }; + //BA.debugLineNum = 105;BA.debugLine="CallSubDelayed2(HttpUtils2Service, \"SubmitJob\", M"; +__c.CallSubDelayed2(ba,(Object)(_httputils2service.getObject()),"SubmitJob",this); + //BA.debugLineNum = 106;BA.debugLine="End Sub"; +return ""; +} +public String _patchstring(String _link,String _text) throws Exception{ + //BA.debugLineNum = 83;BA.debugLine="Public Sub PatchString(Link As String, Text As Str"; + //BA.debugLineNum = 84;BA.debugLine="PatchBytes(Link, Text.GetBytes(\"UTF8\"))"; +_patchbytes(_link,_text.getBytes("UTF8")); + //BA.debugLineNum = 85;BA.debugLine="End Sub"; +return ""; +} +public String _postbytes(String _link,byte[] _data) throws Exception{ + //BA.debugLineNum = 54;BA.debugLine="Public Sub PostBytes(Link As String, Data() As Byt"; + //BA.debugLineNum = 55;BA.debugLine="Try"; +try { //BA.debugLineNum = 56;BA.debugLine="Link = AddScheme(Link)"; +_link = _addscheme(_link); + //BA.debugLineNum = 57;BA.debugLine="req.InitializePost2(Link, Data)"; +_req.InitializePost2(_link,_data); + } + catch (Exception e5) { + ba.setLastException(e5); //BA.debugLineNum = 59;BA.debugLine="Log($\"Invalid link: ${Link}\"$)"; +__c.LogImpl("91638405",("Invalid link: "+__c.SmartStringFormatter("",(Object)(_link))+""),0); + //BA.debugLineNum = 60;BA.debugLine="req.InitializePost2(InvalidURL, Data)"; +_req.InitializePost2(_invalidurl,_data); + }; + //BA.debugLineNum = 62;BA.debugLine="CallSubDelayed2(HttpUtils2Service, \"SubmitJob\", M"; +__c.CallSubDelayed2(ba,(Object)(_httputils2service.getObject()),"SubmitJob",this); + //BA.debugLineNum = 63;BA.debugLine="End Sub"; +return ""; +} +public String _postfile(String _link,String _dir,String _filename) throws Exception{ +int _length = 0; +anywheresoftware.b4a.objects.streams.File.InputStreamWrapper _in = null; +anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper _out = null; + //BA.debugLineNum = 181;BA.debugLine="Public Sub PostFile(Link As String, Dir As String,"; + //BA.debugLineNum = 182;BA.debugLine="Link = AddScheme(Link)"; +_link = _addscheme(_link); + //BA.debugLineNum = 187;BA.debugLine="Dim length As Int"; +_length = 0; + //BA.debugLineNum = 188;BA.debugLine="If Dir = File.DirAssets Then"; +if ((_dir).equals(__c.File.getDirAssets())) { + //BA.debugLineNum = 189;BA.debugLine="Log(\"Cannot send files from the assets folder.\")"; +__c.LogImpl("92162696","Cannot send files from the assets folder.",0); + //BA.debugLineNum = 190;BA.debugLine="Return"; +if (true) return ""; + }; + //BA.debugLineNum = 192;BA.debugLine="length = File.Size(Dir, FileName)"; +_length = (int) (__c.File.Size(_dir,_filename)); + //BA.debugLineNum = 193;BA.debugLine="Dim In As InputStream"; +_in = new anywheresoftware.b4a.objects.streams.File.InputStreamWrapper(); + //BA.debugLineNum = 194;BA.debugLine="In = File.OpenInput(Dir, FileName)"; +_in = __c.File.OpenInput(_dir,_filename); + //BA.debugLineNum = 195;BA.debugLine="If length < 1000000 Then '1mb"; +if (_length<1000000) { + //BA.debugLineNum = 198;BA.debugLine="Dim out As OutputStream"; +_out = new anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper(); + //BA.debugLineNum = 199;BA.debugLine="out.InitializeToBytesArray(length)"; +_out.InitializeToBytesArray(_length); + //BA.debugLineNum = 200;BA.debugLine="File.Copy2(In, out)"; +__c.File.Copy2((java.io.InputStream)(_in.getObject()),(java.io.OutputStream)(_out.getObject())); + //BA.debugLineNum = 201;BA.debugLine="PostBytes(Link, out.ToBytesArray)"; +_postbytes(_link,_out.ToBytesArray()); + }else { + //BA.debugLineNum = 203;BA.debugLine="req.InitializePost(Link, In, length)"; +_req.InitializePost(_link,(java.io.InputStream)(_in.getObject()),_length); + //BA.debugLineNum = 204;BA.debugLine="CallSubDelayed2(HttpUtils2Service, \"SubmitJob\","; +__c.CallSubDelayed2(ba,(Object)(_httputils2service.getObject()),"SubmitJob",this); + }; + //BA.debugLineNum = 207;BA.debugLine="End Sub"; +return ""; +} +public String _postmultipart(String _link,anywheresoftware.b4a.objects.collections.Map _namevalues,anywheresoftware.b4a.objects.collections.List _files) throws Exception{ +String _boundary = ""; +anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper _stream = null; +byte[] _b = null; +String _eol = ""; +boolean _empty = false; +String _key = ""; +String _value = ""; +String _s = ""; +b4a.example.httpjob._multipartfiledata _fd = null; +anywheresoftware.b4a.objects.streams.File.InputStreamWrapper _in = null; + //BA.debugLineNum = 124;BA.debugLine="Public Sub PostMultipart(Link As String, NameValue"; + //BA.debugLineNum = 125;BA.debugLine="Dim boundary As String = \"-----------------------"; +_boundary = "---------------------------1461124740692"; + //BA.debugLineNum = 126;BA.debugLine="Dim stream As OutputStream"; +_stream = new anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper(); + //BA.debugLineNum = 127;BA.debugLine="stream.InitializeToBytesArray(0)"; +_stream.InitializeToBytesArray((int) (0)); + //BA.debugLineNum = 128;BA.debugLine="Dim b() As Byte"; +_b = new byte[(int) (0)]; +; + //BA.debugLineNum = 129;BA.debugLine="Dim eol As String = Chr(13) & Chr(10)"; +_eol = BA.ObjectToString(__c.Chr((int) (13)))+BA.ObjectToString(__c.Chr((int) (10))); + //BA.debugLineNum = 130;BA.debugLine="Dim empty As Boolean = True"; +_empty = __c.True; + //BA.debugLineNum = 131;BA.debugLine="If NameValues <> Null And NameValues.IsInitialize"; +if (_namevalues!= null && _namevalues.IsInitialized()) { + //BA.debugLineNum = 132;BA.debugLine="For Each key As String In NameValues.Keys"; +{ +final anywheresoftware.b4a.BA.IterableList group8 = _namevalues.Keys(); +final int groupLen8 = group8.getSize() +;int index8 = 0; +; +for (; index8 < groupLen8;index8++){ +_key = BA.ObjectToString(group8.Get(index8)); + //BA.debugLineNum = 133;BA.debugLine="Dim value As String = NameValues.Get(key)"; +_value = BA.ObjectToString(_namevalues.Get((Object)(_key))); + //BA.debugLineNum = 134;BA.debugLine="empty = MultipartStartSection (stream, empty)"; +_empty = _multipartstartsection(_stream,_empty); + //BA.debugLineNum = 135;BA.debugLine="Dim s As String = _ $\"--${boundary} Content-Dis"; +_s = ("--"+__c.SmartStringFormatter("",(Object)(_boundary))+"\n"+"Content-Disposition: form-data; name=\""+__c.SmartStringFormatter("",(Object)(_key))+"\"\n"+"\n"+""+__c.SmartStringFormatter("",(Object)(_value))+""); + //BA.debugLineNum = 140;BA.debugLine="b = s.Replace(CRLF, eol).GetBytes(\"UTF8\")"; +_b = _s.replace(__c.CRLF,_eol).getBytes("UTF8"); + //BA.debugLineNum = 141;BA.debugLine="stream.WriteBytes(b, 0, b.Length)"; +_stream.WriteBytes(_b,(int) (0),_b.length); + } +}; + }; + //BA.debugLineNum = 144;BA.debugLine="If Files <> Null And Files.IsInitialized Then"; +if (_files!= null && _files.IsInitialized()) { + //BA.debugLineNum = 145;BA.debugLine="For Each fd As MultipartFileData In Files"; +{ +final anywheresoftware.b4a.BA.IterableList group17 = _files; +final int groupLen17 = group17.getSize() +;int index17 = 0; +; +for (; index17 < groupLen17;index17++){ +_fd = (b4a.example.httpjob._multipartfiledata)(group17.Get(index17)); + //BA.debugLineNum = 146;BA.debugLine="empty = MultipartStartSection (stream, empty)"; +_empty = _multipartstartsection(_stream,_empty); + //BA.debugLineNum = 147;BA.debugLine="Dim s As String = _ $\"--${boundary} Content-Dis"; +_s = ("--"+__c.SmartStringFormatter("",(Object)(_boundary))+"\n"+"Content-Disposition: form-data; name=\""+__c.SmartStringFormatter("",(Object)(_fd.KeyName /*String*/ ))+"\"; filename=\""+__c.SmartStringFormatter("",(Object)(_fd.FileName /*String*/ ))+"\"\n"+"Content-Type: "+__c.SmartStringFormatter("",(Object)(_fd.ContentType /*String*/ ))+"\n"+"\n"+""); + //BA.debugLineNum = 153;BA.debugLine="b = s.Replace(CRLF, eol).GetBytes(\"UTF8\")"; +_b = _s.replace(__c.CRLF,_eol).getBytes("UTF8"); + //BA.debugLineNum = 154;BA.debugLine="stream.WriteBytes(b, 0, b.Length)"; +_stream.WriteBytes(_b,(int) (0),_b.length); + //BA.debugLineNum = 155;BA.debugLine="Dim in As InputStream = File.OpenInput(fd.Dir,"; +_in = new anywheresoftware.b4a.objects.streams.File.InputStreamWrapper(); +_in = __c.File.OpenInput(_fd.Dir /*String*/ ,_fd.FileName /*String*/ ); + //BA.debugLineNum = 156;BA.debugLine="File.Copy2(in, stream)"; +__c.File.Copy2((java.io.InputStream)(_in.getObject()),(java.io.OutputStream)(_stream.getObject())); + } +}; + }; + //BA.debugLineNum = 159;BA.debugLine="empty = MultipartStartSection (stream, empty)"; +_empty = _multipartstartsection(_stream,_empty); + //BA.debugLineNum = 160;BA.debugLine="s = _ $\"--${boundary}-- \"$"; +_s = ("--"+__c.SmartStringFormatter("",(Object)(_boundary))+"--\n"+""); + //BA.debugLineNum = 163;BA.debugLine="b = s.Replace(CRLF, eol).GetBytes(\"UTF8\")"; +_b = _s.replace(__c.CRLF,_eol).getBytes("UTF8"); + //BA.debugLineNum = 164;BA.debugLine="stream.WriteBytes(b, 0, b.Length)"; +_stream.WriteBytes(_b,(int) (0),_b.length); + //BA.debugLineNum = 165;BA.debugLine="PostBytes(Link, stream.ToBytesArray)"; +_postbytes(_link,_stream.ToBytesArray()); + //BA.debugLineNum = 166;BA.debugLine="req.SetContentType(\"multipart/form-data; boundary"; +_req.SetContentType("multipart/form-data; boundary="+_boundary); + //BA.debugLineNum = 167;BA.debugLine="req.SetContentEncoding(\"UTF8\")"; +_req.SetContentEncoding("UTF8"); + //BA.debugLineNum = 168;BA.debugLine="End Sub"; +return ""; +} +public String _poststring(String _link,String _text) throws Exception{ + //BA.debugLineNum = 49;BA.debugLine="Public Sub PostString(Link As String, Text As Stri"; + //BA.debugLineNum = 50;BA.debugLine="PostBytes(Link, Text.GetBytes(\"UTF8\"))"; +_postbytes(_link,_text.getBytes("UTF8")); + //BA.debugLineNum = 51;BA.debugLine="End Sub"; +return ""; +} +public String _putbytes(String _link,byte[] _data) throws Exception{ + //BA.debugLineNum = 71;BA.debugLine="Public Sub PutBytes(Link As String, Data() As Byte"; + //BA.debugLineNum = 72;BA.debugLine="Try"; +try { //BA.debugLineNum = 73;BA.debugLine="Link = AddScheme(Link)"; +_link = _addscheme(_link); + //BA.debugLineNum = 74;BA.debugLine="req.InitializePut2(Link, Data)"; +_req.InitializePut2(_link,_data); + } + catch (Exception e5) { + ba.setLastException(e5); //BA.debugLineNum = 76;BA.debugLine="Log($\"Invalid link: ${Link}\"$)"; +__c.LogImpl("91769477",("Invalid link: "+__c.SmartStringFormatter("",(Object)(_link))+""),0); + //BA.debugLineNum = 77;BA.debugLine="req.InitializePut2(InvalidURL, Data)"; +_req.InitializePut2(_invalidurl,_data); + }; + //BA.debugLineNum = 79;BA.debugLine="CallSubDelayed2(HttpUtils2Service, \"SubmitJob\", M"; +__c.CallSubDelayed2(ba,(Object)(_httputils2service.getObject()),"SubmitJob",this); + //BA.debugLineNum = 80;BA.debugLine="End Sub"; +return ""; +} +public String _putstring(String _link,String _text) throws Exception{ + //BA.debugLineNum = 66;BA.debugLine="Public Sub PutString(Link As String, Text As Strin"; + //BA.debugLineNum = 67;BA.debugLine="PutBytes(Link, Text.GetBytes(\"UTF8\"))"; +_putbytes(_link,_text.getBytes("UTF8")); + //BA.debugLineNum = 68;BA.debugLine="End Sub"; +return ""; +} +public String _release() throws Exception{ + //BA.debugLineNum = 275;BA.debugLine="Public Sub Release"; + //BA.debugLineNum = 277;BA.debugLine="File.Delete(HttpUtils2Service.TempFolder, taskId)"; +__c.File.Delete(_httputils2service._tempfolder /*String*/ ,_taskid); + //BA.debugLineNum = 279;BA.debugLine="End Sub"; +return ""; +} +public Object callSub(String sub, Object sender, Object[] args) throws Exception { +BA.senderHolder.set(sender); +return BA.SubDelegator.SubNotFound; +} +} diff --git a/Objects/src/b4a/example/httputils2service.java b/Objects/src/b4a/example/httputils2service.java new file mode 100644 index 0000000..db0875f --- /dev/null +++ b/Objects/src/b4a/example/httputils2service.java @@ -0,0 +1,298 @@ +package b4a.example; + + +import anywheresoftware.b4a.BA; +import anywheresoftware.b4a.objects.ServiceHelper; +import anywheresoftware.b4a.debug.*; + +public class httputils2service extends android.app.Service{ + public static class httputils2service_BR extends android.content.BroadcastReceiver { + + @Override + public void onReceive(android.content.Context context, android.content.Intent intent) { + BA.LogInfo("** Receiver (httputils2service) OnReceive **"); + android.content.Intent in = new android.content.Intent(context, httputils2service.class); + if (intent != null) + in.putExtra("b4a_internal_intent", intent); + ServiceHelper.StarterHelper.startServiceFromReceiver (context, in, false, BA.class); + } + + } + static httputils2service mostCurrent; + public static BA processBA; + private ServiceHelper _service; + public static Class getObject() { + return httputils2service.class; + } + @Override + public void onCreate() { + super.onCreate(); + mostCurrent = this; + if (processBA == null) { + processBA = new BA(this, null, null, "b4a.example", "b4a.example.httputils2service"); + if (BA.isShellModeRuntimeCheck(processBA)) { + processBA.raiseEvent2(null, true, "SHELL", false); + } + try { + Class.forName(BA.applicationContext.getPackageName() + ".main").getMethod("initializeProcessGlobals").invoke(null, null); + } catch (Exception e) { + throw new RuntimeException(e); + } + processBA.loadHtSubs(this.getClass()); + ServiceHelper.init(); + } + _service = new ServiceHelper(this); + processBA.service = this; + + if (BA.isShellModeRuntimeCheck(processBA)) { + processBA.raiseEvent2(null, true, "CREATE", true, "b4a.example.httputils2service", processBA, _service, anywheresoftware.b4a.keywords.Common.Density); + } + if (!false && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, false) == false) { + + } + else { + processBA.setActivityPaused(false); + BA.LogInfo("*** Service (httputils2service) Create ***"); + processBA.raiseEvent(null, "service_create"); + } + processBA.runHook("oncreate", this, null); + if (false) { + ServiceHelper.StarterHelper.runWaitForLayouts(); + } + } + @Override + public void onStart(android.content.Intent intent, int startId) { + onStartCommand(intent, 0, 0); + } + @Override + public int onStartCommand(final android.content.Intent intent, int flags, int startId) { + if (ServiceHelper.StarterHelper.onStartCommand(processBA, new Runnable() { + public void run() { + handleStart(intent); + }})) + ; + else { + ServiceHelper.StarterHelper.addWaitForLayout (new Runnable() { + public void run() { + processBA.setActivityPaused(false); + BA.LogInfo("** Service (httputils2service) Create **"); + processBA.raiseEvent(null, "service_create"); + handleStart(intent); + ServiceHelper.StarterHelper.removeWaitForLayout(); + } + }); + } + processBA.runHook("onstartcommand", this, new Object[] {intent, flags, startId}); + return android.app.Service.START_NOT_STICKY; + } + public void onTaskRemoved(android.content.Intent rootIntent) { + super.onTaskRemoved(rootIntent); + if (false) + processBA.raiseEvent(null, "service_taskremoved"); + + } + private void handleStart(android.content.Intent intent) { + BA.LogInfo("** Service (httputils2service) Start **"); + java.lang.reflect.Method startEvent = processBA.htSubs.get("service_start"); + if (startEvent != null) { + if (startEvent.getParameterTypes().length > 0) { + anywheresoftware.b4a.objects.IntentWrapper iw = ServiceHelper.StarterHelper.handleStartIntent(intent, _service, processBA); + processBA.raiseEvent(null, "service_start", iw); + } + else { + processBA.raiseEvent(null, "service_start"); + } + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + if (false) { + BA.LogInfo("** Service (httputils2service) Destroy (ignored)**"); + } + else { + BA.LogInfo("** Service (httputils2service) Destroy **"); + processBA.raiseEvent(null, "service_destroy"); + processBA.service = null; + mostCurrent = null; + processBA.setActivityPaused(true); + processBA.runHook("ondestroy", this, null); + } + } + +@Override + public android.os.IBinder onBind(android.content.Intent intent) { + return null; + }public anywheresoftware.b4a.keywords.Common __c = null; +public static anywheresoftware.b4h.okhttp.OkHttpClientWrapper _hc = null; +public static anywheresoftware.b4a.objects.collections.Map _taskidtojob = null; +public static String _tempfolder = ""; +public static int _taskcounter = 0; +public b4a.example.main _main = null; +public b4a.example.starter _starter = null; +public static String _completejob(int _taskid,boolean _success,String _errormessage) throws Exception{ +b4a.example.httpjob _job = null; + //BA.debugLineNum = 142;BA.debugLine="Sub CompleteJob(TaskId As Int, success As Boolean,"; + //BA.debugLineNum = 146;BA.debugLine="Dim job As HttpJob = TaskIdToJob.Get(TaskId)"; +_job = (b4a.example.httpjob)(_taskidtojob.Get((Object)(_taskid))); + //BA.debugLineNum = 147;BA.debugLine="If job = Null Then"; +if (_job== null) { + //BA.debugLineNum = 148;BA.debugLine="Log(\"HttpUtils2Service: job completed multiple t"; +anywheresoftware.b4a.keywords.Common.LogImpl("71310726","HttpUtils2Service: job completed multiple times - "+BA.NumberToString(_taskid),0); + //BA.debugLineNum = 149;BA.debugLine="Return"; +if (true) return ""; + }; + //BA.debugLineNum = 151;BA.debugLine="TaskIdToJob.Remove(TaskId)"; +_taskidtojob.Remove((Object)(_taskid)); + //BA.debugLineNum = 152;BA.debugLine="job.success = success"; +_job._success /*boolean*/ = _success; + //BA.debugLineNum = 153;BA.debugLine="job.errorMessage = errorMessage"; +_job._errormessage /*String*/ = _errormessage; + //BA.debugLineNum = 155;BA.debugLine="job.Complete(TaskId)"; +_job._complete /*String*/ (_taskid); + //BA.debugLineNum = 159;BA.debugLine="End Sub"; +return ""; +} +public static String _hc_responseerror(anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse _response,String _reason,int _statuscode,int _taskid) throws Exception{ +b4a.example.httpjob _job = null; + //BA.debugLineNum = 109;BA.debugLine="Sub hc_ResponseError (Response As OkHttpResponse,"; + //BA.debugLineNum = 110;BA.debugLine="Log($\"ResponseError. Reason: ${Reason}, Response:"; +anywheresoftware.b4a.keywords.Common.LogImpl("71245185",("ResponseError. Reason: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_reason))+", Response: "+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_response.getErrorResponse()))+""),0); + //BA.debugLineNum = 111;BA.debugLine="Response.Release"; +_response.Release(); + //BA.debugLineNum = 112;BA.debugLine="Dim job As HttpJob = TaskIdToJob.Get(TaskId)"; +_job = (b4a.example.httpjob)(_taskidtojob.Get((Object)(_taskid))); + //BA.debugLineNum = 113;BA.debugLine="If job = Null Then"; +if (_job== null) { + //BA.debugLineNum = 114;BA.debugLine="Log(\"HttpUtils2Service (hc_ResponseError): job c"; +anywheresoftware.b4a.keywords.Common.LogImpl("71245189","HttpUtils2Service (hc_ResponseError): job completed multiple times - "+BA.NumberToString(_taskid),0); + //BA.debugLineNum = 115;BA.debugLine="Return"; +if (true) return ""; + }; + //BA.debugLineNum = 117;BA.debugLine="job.Response = Response"; +_job._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ = _response; + //BA.debugLineNum = 118;BA.debugLine="If Response.ErrorResponse <> \"\" Then"; +if ((_response.getErrorResponse()).equals("") == false) { + //BA.debugLineNum = 119;BA.debugLine="CompleteJob(TaskId, False, Response.ErrorRespons"; +_completejob(_taskid,anywheresoftware.b4a.keywords.Common.False,_response.getErrorResponse()); + }else { + //BA.debugLineNum = 121;BA.debugLine="CompleteJob(TaskId, False, Reason)"; +_completejob(_taskid,anywheresoftware.b4a.keywords.Common.False,_reason); + }; + //BA.debugLineNum = 123;BA.debugLine="End Sub"; +return ""; +} +public static String _hc_responsesuccess(anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse _response,int _taskid) throws Exception{ +b4a.example.httpjob _job = null; +anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper _out = null; + //BA.debugLineNum = 86;BA.debugLine="Sub hc_ResponseSuccess (Response As OkHttpResponse"; + //BA.debugLineNum = 87;BA.debugLine="Dim job As HttpJob = TaskIdToJob.Get(TaskId)"; +_job = (b4a.example.httpjob)(_taskidtojob.Get((Object)(_taskid))); + //BA.debugLineNum = 88;BA.debugLine="If job = Null Then"; +if (_job== null) { + //BA.debugLineNum = 89;BA.debugLine="Log(\"HttpUtils2Service (hc_ResponseSuccess): job"; +anywheresoftware.b4a.keywords.Common.LogImpl("71114115","HttpUtils2Service (hc_ResponseSuccess): job completed multiple times - "+BA.NumberToString(_taskid),0); + //BA.debugLineNum = 90;BA.debugLine="Return"; +if (true) return ""; + }; + //BA.debugLineNum = 92;BA.debugLine="job.Response = Response"; +_job._response /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpResponse*/ = _response; + //BA.debugLineNum = 93;BA.debugLine="Dim out As OutputStream = File.OpenOutput(TempFol"; +_out = new anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper(); +_out = anywheresoftware.b4a.keywords.Common.File.OpenOutput(_tempfolder,BA.NumberToString(_taskid),anywheresoftware.b4a.keywords.Common.False); + //BA.debugLineNum = 97;BA.debugLine="Response.GetAsynchronously(\"response\", out , _"; +_response.GetAsynchronously(processBA,"response",(java.io.OutputStream)(_out.getObject()),anywheresoftware.b4a.keywords.Common.True,_taskid); + //BA.debugLineNum = 99;BA.debugLine="End Sub"; +return ""; +} +public static String _process_globals() throws Exception{ + //BA.debugLineNum = 2;BA.debugLine="Sub Process_Globals"; + //BA.debugLineNum = 12;BA.debugLine="Private hc As OkHttpClient"; +_hc = new anywheresoftware.b4h.okhttp.OkHttpClientWrapper(); + //BA.debugLineNum = 16;BA.debugLine="Private TaskIdToJob As Map"; +_taskidtojob = new anywheresoftware.b4a.objects.collections.Map(); + //BA.debugLineNum = 19;BA.debugLine="Public TempFolder As String"; +_tempfolder = ""; + //BA.debugLineNum = 23;BA.debugLine="Private taskCounter As Int"; +_taskcounter = 0; + //BA.debugLineNum = 25;BA.debugLine="End Sub"; +return ""; +} +public static String _response_streamfinish(boolean _success,int _taskid) throws Exception{ + //BA.debugLineNum = 101;BA.debugLine="Private Sub Response_StreamFinish (Success As Bool"; + //BA.debugLineNum = 102;BA.debugLine="If Success Then"; +if (_success) { + //BA.debugLineNum = 103;BA.debugLine="CompleteJob(TaskId, Success, \"\")"; +_completejob(_taskid,_success,""); + }else { + //BA.debugLineNum = 105;BA.debugLine="CompleteJob(TaskId, Success, LastException.Messa"; +_completejob(_taskid,_success,anywheresoftware.b4a.keywords.Common.LastException(processBA).getMessage()); + }; + //BA.debugLineNum = 107;BA.debugLine="End Sub"; +return ""; +} +public static String _service_create() throws Exception{ + //BA.debugLineNum = 27;BA.debugLine="Sub Service_Create"; + //BA.debugLineNum = 29;BA.debugLine="TempFolder = File.DirInternalCache"; +_tempfolder = anywheresoftware.b4a.keywords.Common.File.getDirInternalCache(); + //BA.debugLineNum = 30;BA.debugLine="Try"; +try { //BA.debugLineNum = 31;BA.debugLine="File.WriteString(TempFolder, \"~test.test\", \"test"; +anywheresoftware.b4a.keywords.Common.File.WriteString(_tempfolder,"~test.test","test"); + //BA.debugLineNum = 32;BA.debugLine="File.Delete(TempFolder, \"~test.test\")"; +anywheresoftware.b4a.keywords.Common.File.Delete(_tempfolder,"~test.test"); + } + catch (Exception e6) { + processBA.setLastException(e6); //BA.debugLineNum = 34;BA.debugLine="Log(LastException)"; +anywheresoftware.b4a.keywords.Common.LogImpl("7851975",BA.ObjectToString(anywheresoftware.b4a.keywords.Common.LastException(processBA)),0); + //BA.debugLineNum = 35;BA.debugLine="Log(\"Switching to File.DirInternal\")"; +anywheresoftware.b4a.keywords.Common.LogImpl("7851976","Switching to File.DirInternal",0); + //BA.debugLineNum = 36;BA.debugLine="TempFolder = File.DirInternal"; +_tempfolder = anywheresoftware.b4a.keywords.Common.File.getDirInternal(); + }; + //BA.debugLineNum = 41;BA.debugLine="If hc.IsInitialized = False Then"; +if (_hc.IsInitialized()==anywheresoftware.b4a.keywords.Common.False) { + //BA.debugLineNum = 46;BA.debugLine="hc.Initialize(\"hc\")"; +_hc.Initialize("hc"); + }; + //BA.debugLineNum = 54;BA.debugLine="TaskIdToJob.Initialize"; +_taskidtojob.Initialize(); + //BA.debugLineNum = 56;BA.debugLine="End Sub"; +return ""; +} +public static String _service_destroy() throws Exception{ + //BA.debugLineNum = 62;BA.debugLine="Sub Service_Destroy"; + //BA.debugLineNum = 64;BA.debugLine="End Sub"; +return ""; +} +public static String _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{ + //BA.debugLineNum = 58;BA.debugLine="Sub Service_Start (StartingIntent As Intent)"; + //BA.debugLineNum = 59;BA.debugLine="Service.StopAutomaticForeground"; +mostCurrent._service.StopAutomaticForeground(); + //BA.debugLineNum = 60;BA.debugLine="End Sub"; +return ""; +} +public static String _submitjob(b4a.example.httpjob _job) throws Exception{ +int _taskid = 0; + //BA.debugLineNum = 68;BA.debugLine="Public Sub SubmitJob(job As HttpJob)"; + //BA.debugLineNum = 69;BA.debugLine="If TaskIdToJob.IsInitialized = False Then Service"; +if (_taskidtojob.IsInitialized()==anywheresoftware.b4a.keywords.Common.False) { +_service_create();}; + //BA.debugLineNum = 73;BA.debugLine="taskCounter = taskCounter + 1"; +_taskcounter = (int) (_taskcounter+1); + //BA.debugLineNum = 74;BA.debugLine="Dim TaskId As Int = taskCounter"; +_taskid = _taskcounter; + //BA.debugLineNum = 76;BA.debugLine="TaskIdToJob.Put(TaskId, job)"; +_taskidtojob.Put((Object)(_taskid),(Object)(_job)); + //BA.debugLineNum = 77;BA.debugLine="If job.Username <> \"\" And job.Password <> \"\" Then"; +if ((_job._username /*String*/ ).equals("") == false && (_job._password /*String*/ ).equals("") == false) { + //BA.debugLineNum = 78;BA.debugLine="hc.ExecuteCredentials(job.GetRequest, TaskId, jo"; +_hc.ExecuteCredentials(processBA,_job._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ (),_taskid,_job._username /*String*/ ,_job._password /*String*/ ); + }else { + //BA.debugLineNum = 80;BA.debugLine="hc.Execute(job.GetRequest, TaskId)"; +_hc.Execute(processBA,_job._getrequest /*anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest*/ (),_taskid); + }; + //BA.debugLineNum = 82;BA.debugLine="End Sub"; +return ""; +} +} diff --git a/Objects/src/b4a/example/main.java b/Objects/src/b4a/example/main.java new file mode 100644 index 0000000..35f03e3 --- /dev/null +++ b/Objects/src/b4a/example/main.java @@ -0,0 +1,420 @@ +package b4a.example; + + +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 menuItems; + public static final boolean fullScreen = true; + public static final boolean includeTitle = true; + public static WeakReference 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, "b4a.example", "b4a.example.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, "b4a.example", "b4a.example.main"); + + processBA.sharedProcessBA.activityBA = new java.lang.ref.WeakReference(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.example.main", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density, mostCurrent); + _activity.reinitializeForShell(activityBA, "activity"); + } + initializeProcessGlobals(); + initializeGlobals(); + + BA.LogInfo("** Activity (main) Create, isFirst = " + isFirst + " **"); + processBA.raiseEvent2(null, true, "activity_create", false, isFirst); + isFirst = false; + if (this != mostCurrent) + return; + processBA.setActivityPaused(false); + BA.LogInfo("** Activity (main) Resume **"); + processBA.raiseEvent(null, "activity_resume"); + if (android.os.Build.VERSION.SDK_INT >= 11) { + try { + android.app.Activity.class.getMethod("invalidateOptionsMenu").invoke(this,(Object[]) null); + } catch (Exception e) { + e.printStackTrace(); + } + } + + } + public void addMenuItem(B4AMenuItem item) { + if (menuItems == null) + menuItems = new java.util.ArrayList(); + 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(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; + public ResumeMessage(Activity activity) { + this.activity = new WeakReference(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 anywheresoftware.b4a.objects.B4XViewWrapper.XUI _xui = null; +public anywheresoftware.b4a.objects.WebViewWrapper _webview1 = null; +public static String _tempposturl = ""; +public static String _temppoststring = ""; +public static byte[] _bytesofpostrequest = null; +public b4a.example.starter _starter = null; +public b4a.example.httputils2service _httputils2service = null; + +public static boolean isAnyActivityVisible() { + boolean vis = false; +vis = vis | (main.mostCurrent != null); +return vis;} +public static String _activity_create(boolean _firsttime) throws Exception{ +anywheresoftware.b4j.object.JavaObject _jo = null; + //BA.debugLineNum = 29;BA.debugLine="Sub Activity_Create(FirstTime As Boolean)"; + //BA.debugLineNum = 30;BA.debugLine="Activity.LoadLayout(\"Layout\")"; +mostCurrent._activity.LoadLayout("Layout",mostCurrent.activityBA); + //BA.debugLineNum = 31;BA.debugLine="Activity.Title=\"Aquarihelp\""; +mostCurrent._activity.setTitle(BA.ObjectToCharSequence("Aquarihelp")); + //BA.debugLineNum = 39;BA.debugLine="bytesOfPOstRequest=tempPostString.GetBytes(\"UTF8\""; +_bytesofpostrequest = mostCurrent._temppoststring.getBytes("UTF8"); + //BA.debugLineNum = 40;BA.debugLine="Private jo As JavaObject=WebView1"; +_jo = new anywheresoftware.b4j.object.JavaObject(); +_jo = (anywheresoftware.b4j.object.JavaObject) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4j.object.JavaObject(), (java.lang.Object)(mostCurrent._webview1.getObject())); + //BA.debugLineNum = 41;BA.debugLine="jo.RunMethod(\"postUrl\",Array As Object(tempPostUr"; +_jo.RunMethod("postUrl",new Object[]{(Object)(mostCurrent._tempposturl),(Object)(_bytesofpostrequest)}); + //BA.debugLineNum = 43;BA.debugLine="End Sub"; +return ""; +} +public static String _activity_pause(boolean _userclosed) throws Exception{ + //BA.debugLineNum = 49;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)"; + //BA.debugLineNum = 51;BA.debugLine="End Sub"; +return ""; +} +public static String _activity_resume() throws Exception{ + //BA.debugLineNum = 45;BA.debugLine="Sub Activity_Resume"; + //BA.debugLineNum = 47;BA.debugLine="End Sub"; +return ""; +} +public static String _button1_click() throws Exception{ + //BA.debugLineNum = 53;BA.debugLine="Sub Button1_Click"; + //BA.debugLineNum = 54;BA.debugLine="xui.MsgboxAsync(\"Hello world!\", \"B4X\")"; +_xui.MsgboxAsync(processBA,BA.ObjectToCharSequence("Hello world!"),BA.ObjectToCharSequence("B4X")); + //BA.debugLineNum = 55;BA.debugLine="End Sub"; +return ""; +} +public static String _globals() throws Exception{ + //BA.debugLineNum = 21;BA.debugLine="Sub Globals"; + //BA.debugLineNum = 23;BA.debugLine="Private WebView1 As WebView"; +mostCurrent._webview1 = new anywheresoftware.b4a.objects.WebViewWrapper(); + //BA.debugLineNum = 24;BA.debugLine="Private tempPostUrl As String=\"https://aquarihelp"; +mostCurrent._tempposturl = "https://aquarihelp.com/index_login.php"; + //BA.debugLineNum = 25;BA.debugLine="Private tempPostString As String=\"mobiletest=andr"; +mostCurrent._temppoststring = "mobiletest=android_apk"; + //BA.debugLineNum = 26;BA.debugLine="Private bytesOfPOstRequest() As Byte"; +_bytesofpostrequest = new byte[(int) (0)]; +; + //BA.debugLineNum = 27;BA.debugLine="End Sub"; +return ""; +} + +public static void initializeProcessGlobals() { + + if (main.processGlobalsRun == false) { + main.processGlobalsRun = true; + try { + main._process_globals(); +starter._process_globals(); +httputils2service._process_globals(); + + } catch (Exception e) { + throw new RuntimeException(e); + } + } +}public static String _process_globals() throws Exception{ + //BA.debugLineNum = 15;BA.debugLine="Sub Process_Globals"; + //BA.debugLineNum = 18;BA.debugLine="Private xui As XUI"; +_xui = new anywheresoftware.b4a.objects.B4XViewWrapper.XUI(); + //BA.debugLineNum = 19;BA.debugLine="End Sub"; +return ""; +} +} diff --git a/Objects/src/b4a/example/starter.java b/Objects/src/b4a/example/starter.java new file mode 100644 index 0000000..3073799 --- /dev/null +++ b/Objects/src/b4a/example/starter.java @@ -0,0 +1,164 @@ +package b4a.example; + + +import anywheresoftware.b4a.BA; +import anywheresoftware.b4a.objects.ServiceHelper; +import anywheresoftware.b4a.debug.*; + +public class starter extends android.app.Service{ + public static class starter_BR extends android.content.BroadcastReceiver { + + @Override + public void onReceive(android.content.Context context, android.content.Intent intent) { + BA.LogInfo("** Receiver (starter) OnReceive **"); + android.content.Intent in = new android.content.Intent(context, starter.class); + if (intent != null) + in.putExtra("b4a_internal_intent", intent); + ServiceHelper.StarterHelper.startServiceFromReceiver (context, in, true, BA.class); + } + + } + static starter mostCurrent; + public static BA processBA; + private ServiceHelper _service; + public static Class getObject() { + return starter.class; + } + @Override + public void onCreate() { + super.onCreate(); + mostCurrent = this; + if (processBA == null) { + processBA = new BA(this, null, null, "b4a.example", "b4a.example.starter"); + if (BA.isShellModeRuntimeCheck(processBA)) { + processBA.raiseEvent2(null, true, "SHELL", false); + } + try { + Class.forName(BA.applicationContext.getPackageName() + ".main").getMethod("initializeProcessGlobals").invoke(null, null); + } catch (Exception e) { + throw new RuntimeException(e); + } + processBA.loadHtSubs(this.getClass()); + ServiceHelper.init(); + } + _service = new ServiceHelper(this); + processBA.service = this; + + if (BA.isShellModeRuntimeCheck(processBA)) { + processBA.raiseEvent2(null, true, "CREATE", true, "b4a.example.starter", processBA, _service, anywheresoftware.b4a.keywords.Common.Density); + } + if (!true && ServiceHelper.StarterHelper.startFromServiceCreate(processBA, false) == false) { + + } + else { + processBA.setActivityPaused(false); + BA.LogInfo("*** Service (starter) Create ***"); + processBA.raiseEvent(null, "service_create"); + } + processBA.runHook("oncreate", this, null); + if (true) { + ServiceHelper.StarterHelper.runWaitForLayouts(); + } + } + @Override + public void onStart(android.content.Intent intent, int startId) { + onStartCommand(intent, 0, 0); + } + @Override + public int onStartCommand(final android.content.Intent intent, int flags, int startId) { + if (ServiceHelper.StarterHelper.onStartCommand(processBA, new Runnable() { + public void run() { + handleStart(intent); + }})) + ; + else { + ServiceHelper.StarterHelper.addWaitForLayout (new Runnable() { + public void run() { + processBA.setActivityPaused(false); + BA.LogInfo("** Service (starter) Create **"); + processBA.raiseEvent(null, "service_create"); + handleStart(intent); + ServiceHelper.StarterHelper.removeWaitForLayout(); + } + }); + } + processBA.runHook("onstartcommand", this, new Object[] {intent, flags, startId}); + return android.app.Service.START_NOT_STICKY; + } + public void onTaskRemoved(android.content.Intent rootIntent) { + super.onTaskRemoved(rootIntent); + if (true) + processBA.raiseEvent(null, "service_taskremoved"); + + } + private void handleStart(android.content.Intent intent) { + BA.LogInfo("** Service (starter) Start **"); + java.lang.reflect.Method startEvent = processBA.htSubs.get("service_start"); + if (startEvent != null) { + if (startEvent.getParameterTypes().length > 0) { + anywheresoftware.b4a.objects.IntentWrapper iw = ServiceHelper.StarterHelper.handleStartIntent(intent, _service, processBA); + processBA.raiseEvent(null, "service_start", iw); + } + else { + processBA.raiseEvent(null, "service_start"); + } + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + if (true) { + BA.LogInfo("** Service (starter) Destroy (ignored)**"); + } + else { + BA.LogInfo("** Service (starter) Destroy **"); + processBA.raiseEvent(null, "service_destroy"); + processBA.service = null; + mostCurrent = null; + processBA.setActivityPaused(true); + processBA.runHook("ondestroy", this, null); + } + } + +@Override + public android.os.IBinder onBind(android.content.Intent intent) { + return null; + }public anywheresoftware.b4a.keywords.Common __c = null; +public b4a.example.main _main = null; +public b4a.example.httputils2service _httputils2service = null; +public static boolean _application_error(anywheresoftware.b4a.objects.B4AException _error,String _stacktrace) throws Exception{ + //BA.debugLineNum = 27;BA.debugLine="Sub Application_Error (Error As Exception, StackTr"; + //BA.debugLineNum = 28;BA.debugLine="Return True"; +if (true) return anywheresoftware.b4a.keywords.Common.True; + //BA.debugLineNum = 29;BA.debugLine="End Sub"; +return false; +} +public static String _process_globals() throws Exception{ + //BA.debugLineNum = 6;BA.debugLine="Sub Process_Globals"; + //BA.debugLineNum = 10;BA.debugLine="End Sub"; +return ""; +} +public static String _service_create() throws Exception{ + //BA.debugLineNum = 12;BA.debugLine="Sub Service_Create"; + //BA.debugLineNum = 16;BA.debugLine="End Sub"; +return ""; +} +public static String _service_destroy() throws Exception{ + //BA.debugLineNum = 31;BA.debugLine="Sub Service_Destroy"; + //BA.debugLineNum = 33;BA.debugLine="End Sub"; +return ""; +} +public static String _service_start(anywheresoftware.b4a.objects.IntentWrapper _startingintent) throws Exception{ + //BA.debugLineNum = 18;BA.debugLine="Sub Service_Start (StartingIntent As Intent)"; + //BA.debugLineNum = 19;BA.debugLine="Service.StopAutomaticForeground 'Starter service"; +mostCurrent._service.StopAutomaticForeground(); + //BA.debugLineNum = 20;BA.debugLine="End Sub"; +return ""; +} +public static String _service_taskremoved() throws Exception{ + //BA.debugLineNum = 22;BA.debugLine="Sub Service_TaskRemoved"; + //BA.debugLineNum = 24;BA.debugLine="End Sub"; +return ""; +} +} diff --git a/Starter.bas b/Starter.bas new file mode 100644 index 0000000..1326458 --- /dev/null +++ b/Starter.bas @@ -0,0 +1,39 @@ +B4A=true +Group=Default Group +ModulesStructureVersion=1 +Type=Service +Version=9.9 +@EndOfDesignText@ +#Region Service Attributes + #StartAtBoot: False + #ExcludeFromLibrary: True +#End Region + +Sub Process_Globals + 'These global variables will be declared once when the application starts. + 'These variables can be accessed from all modules. + +End Sub + +Sub Service_Create + 'This is the program entry point. + 'This is a good place to load resources that are not specific to a single activity. + +End Sub + +Sub Service_Start (StartingIntent As Intent) + Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases. +End Sub + +Sub Service_TaskRemoved + 'This event will be raised when the user removes the app from the recent apps list. +End Sub + +'Return true to allow the OS default exceptions handler to handle the uncaught exception. +Sub Application_Error (Error As Exception, StackTrace As String) As Boolean + Return True +End Sub + +Sub Service_Destroy + +End Sub