LAMW OnRotate lazarus / 43-Android ---------------------------------------------------------------------- AFFRIZA 亜風実 · 2019-06-17 07:38 Hello, I have a problem with jEditText and jListView, when the screen is rotated, the width is the same as the previous layout width, I have used OnRotate and UpdateLayout, but it doesn't do anything. So, if the screen started with Landscape then on the Portrait layout will become ugly, and if the screen started with Portrait then on then Landscape layout will be broken. Any ideas? ---------------------------------------------------------------------- jmpessoa · 2019-06-17 17:33 Can you put your ".pas" and  ".lfm"  files?  [or send me your project....] ---------------------------------------------------------------------- AFFRIZA 亜風実 · 2019-06-18 02:46 Quote from: jmpessoa on June 17, 2019, 07:33:52 pm Can you put your ".pas" and  ".lfm"  files?  [or send me your project....] Thank you for the reply  , here the form files (.pas and .lfm). ---------------------------------------------------------------------- ADiV · 2019-06-20 07:05 Quote from: Dio Affriza on June 18, 2019, 04:46:23 amQuote from: jmpessoa on June 17, 2019, 07:33:52 pm Can you put your ".pas" and  ".lfm"  files?  [or send me your project....] Thank you for the reply  , here the form files (.pas and .lfm). Hello, I've tried your code and the bug that I see that the "jForm" uses "ActivityMode = actEasel" when you should use "ActivityMode = actRecyclable" and thus works correctly. ---------------------------------------------------------------------- AFFRIZA 亜風実 · 2019-06-20 11:35 Quote from: TR3E on June 20, 2019, 09:05:49 amQuote from: Dio Affriza on June 18, 2019, 04:46:23 amQuote from: jmpessoa on June 17, 2019, 07:33:52 pm Can you put your ".pas" and  ".lfm"  files?  [or send me your project....] Thank you for the reply  , here the form files (.pas and .lfm). Hello, I've tried your code and the bug that I see that the "jForm" uses "ActivityMode = actEasel" when you should use "ActivityMode = actRecyclable" and thus works correctly. It makes my app freeze at startup because I am used it as a jPanel's child, the correct option is actEasel, not the actRecycleable. ---------------------------------------------------------------------- jmpessoa · 2019-06-21 03:27 Ok.  In the  attachments,  there is a demo project and some pictures.... note1: avoid using multiple panels ... this causes an unbelievable screen process delay.... note2: you can use "margins" properties to improve the layout.... note3: tested in Galaxy S3 [4.3]  S4 [5.0.1] and S5 [6.0.1] ---------------------------------------------------------------------- AFFRIZA 亜風実 · 2019-06-21 05:29 Quote from: jmpessoa on June 21, 2019, 05:27:10 amOk.  In the  attachments,  there is a demo project and some pictures.... note1: avoid using multiple panels ... this causes an unbelievable screen process delay.... note2: you can use "margins" properties to improve the layout.... note3: tested in Galaxy S3 [4.3]  S4 [5.0.1] and S5 [6.0.1] I have a problem opening the project, should I need to update LAMW? ---------------------------------------------------------------------- jmpessoa · 2019-06-21 05:38 Yes! LAMW is always evolving! ---------------------------------------------------------------------- AFFRIZA 亜風実 · 2019-06-21 06:10 Ah, yeah, I forgot to mention that. Can you check the demo "AppCompatNavigationDrawerDemo1", I'm replicate that thing to make the form, that's why I'm using a lot of panels previously. As the previous reply, the alignment problem may only affect atEeasel jForm. I want to send my project files, but there are many SQL things. Can I send the file via email or private message maybe? ---------------------------------------------------------------------- jmpessoa · 2019-06-21 23:41 Yes, you can use jPanel as in demo "AppCompatNavigationDrawerDemo1".... that is  a good  technique! But, the massive use  of jPanel is bad.... [you can see: the "actEasel" forms use only one jPanel to encapsulates all the layout!] A revised  "AppLayoutingDemo1" demo is here: https://od.lk/f/Ml8xNzA2NTE2ODdf               [opendrive.com] Now there is an external jPanel wrapping all the layout... so you can use it as  an "actEasel" form... And there is, too,  some code to handling the "Landscape" and  "Portrait"  screen  state/style.... P.S About "Easel" meaning ....                      http://paintingproperly.com/best-easel-reviews/ ---------------------------------------------------------------------- AFFRIZA 亜風実 · 2019-06-22 04:32 Quote from: jmpessoa on June 22, 2019, 01:41:08 amYes, you can use jPanel as in demo "AppCompatNavigationDrawerDemo1".... that is  a good  technique! But, the massive use  of jPanel is bad.... [you can see: the "actEasel" forms use only one jPanel to encapsulates all the layout!] A revised  "AppLayoutingDemo1" demo is here: https://od.lk/f/Ml8xNzA2NTE2ODdf               [opendrive.com] Now there is an external jPanel wrapping all the layout... so you can use it as  an "actEasel" form... And there is, too,  some code to handling the "Landscape" and  "Portrait"  screen  state/style.... P.S About "Easel" meaning ....                      http://paintingproperly.com/best-easel-reviews/ The form in that demo still doesn't work after I inserted into my project as an Easel (layout still broken), but yeah it's work as a recycler, but I can't embed it to the main form as a child of the panel. I'm not sure why.  Maybe I will disable the form rotate for now.  Btw, thank you for the replies and tips! I appreciate that. ---------------------------------------------------------------------- jmpessoa · 2019-06-22 07:04 Yes. We have some issues here.... 1) I Fixed the file "amw_ide_menu_items.pas"   [LAMW folder "..../ide- tools"] [Now the "Import LAMW Stuff..."  works,  again!] 2) About " layout still broken" in  "Easel"  model.... I will try some solution... ---------------------------------------------------------------------- AFFRIZA 亜風実 · 2019-06-22 07:05 Quote from: jmpessoa on June 22, 2019, 09:04:01 am Yes. We have some issues here.... 1) I Fixed the file "amw_ide_menu_items.pas"   [LAMW folder "..../ide- tools"] [Now the "Import LAMW Stuff..."  works,  again!] 2) About " layout still broken" in  "Easel"  model.... I will try some solution... Btw, there's some fun stuff here. jCustomDialog works fine in easel form. It still requires a timer to update, but yeah, it's better than crowding a single form with many components, that's why I like the Easel idea. It's only broken in jPanel, even I tried with a timer it doesn't work like jCustomDialog. EDIT There's what I've experienced until now. 1) I realized in jCustomDialog I'm using 2 edits (right and left, jEdit combined with jEdit), but the left side looks a bit bigger (at least it much looks better). Then I changed the right edit to a button (jEdit combined with jButton), it starts broken as the previous case. 2) If the button or edit I set to MatchParent, it will work completely normal. Like ThreeQuarter or NineTenth, it will be broken, except for MatchParent. 3) jPanel and ListView shared similar behavior when I tested in the jCustomDialog, it's only working with MatchToParent. For jPanel it will collapse until invisible when there's no component inside the jPanel (it's like the component is forcing the layout into WrapContent), even I set the weight HalfOfParent, ThreeQuarter, or anything except MatchParent. For jListView, it same as jPanel even there's contains items, it still collapsed, until I set into MatchParent. Sorry for my bad English, I edited it so much. ---------------------------------------------------------------------- jmpessoa · 2019-06-23 06:47 QuoteThere's what I've experienced until now..... Yes, we need some more code to handle HalfOfParent, ThreeQuarter.... etc... But, but I already know! I will notify here  after some tests.... [Now I need to sleep....  ] ---------------------------------------------------------------------- AFFRIZA 亜風実 · 2019-06-24 02:51 Quote from: jmpessoa on June 23, 2019, 08:47:25 amI will notify here  after some tests.... [Now I need to sleep....  ] Thank you! I will wait for it. ---------------------------------------------------------------------- jmpessoa · 2019-06-24 03:04 Done!!! Updated "AppCompatNavigationDrawerDemo1" !!! [and other required files....] Now we can handle "OnRotate"! ---------------------------------------------------------------------- AFFRIZA 亜風実 · 2019-06-24 06:59 Quote from: jmpessoa on June 24, 2019, 05:04:55 am Done!!! Updated "AppCompatNavigationDrawerDemo1" !!! [and other required files....] Now we can handle "OnRotate"! The demo works wonderfully! But, when I use the form in my project it's doesn't work. I've deleted build folder, but it still the same. May I missed something? I've added this too: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMainControl.jsNavigationView1ClickItem(Sender: TObject;  itemId: integer; itemCaption: string);begin  case itemId of    scHome: pnMain.BringToFront();    scDataSales: DataSales.jPanel3.BringToFront();    scOrderJual: OrderJual.jPanel1.BringToFront();    scScene3: AndroidModule1.jPanel1.BringToFront();  end;  ActiveScene := ItemID;  jsDrawerLayout1.CloseDrawers();end; procedure TMainControl.MainControlRotate(Sender: TObject; rotate: TScreenStyle);begin  case ActiveScene of    scDataSales: DataSales.DataSalesRotate(Sender, rotate);    scOrderJual: OrderJual.OrderJualRotate(Sender, rotate);    scScene3: AndroidModule1.AndroidModule1Rotate(Sender, rotate);  end;end; Also, I have one more bug. The main form changed every I create a new jForm, so it requires me to edit the .LPI file manually. ---------------------------------------------------------------------- jmpessoa · 2019-06-24 17:58 (0) QuoteI've deleted build folder.... I did not understand... (1) QuoteBut, when I use the form in my project it's doesn't work. You cant copy and paste a "unit" to your project... You need "Use/Import LAMW Stuff..." from menu "Tools" --->"[LAMW] ....." how does it work? The [dummy] unit[form] selected will be replaced by the the imported unit[form]! (2)  QuoteAlso, I have one more bug. The main form changed every I create a new jForm, so it requires me to edit the .LPI file manually. The error (1)  can cause the error (2)!!! But, to create new form you need use "File" -->  "New..."  -->  "LAMW [GUI] Android jForm" [the default will be "Recyclable", so change to "Easel" if you need....] ---------------------------------------------------------------------- AFFRIZA 亜風実 · 2019-06-25 02:46 Quote from: jmpessoa on June 24, 2019, 07:58:31 pm(0) QuoteI've deleted build folder.... I did not understand... I mean the layout still is broken, but only in my project, not in the demo. I thought the Java template files generated in "build" folder that caused the problem, which contains: "generated", "intermediates", "output", etc. So, I following all in the demo. Like I changed the API into 28.0.2, still the same. ---------------------------------------------------------------------- jmpessoa · 2019-06-25 03:02 Study the demo carefully .... Unit1.pas   [main unit.....] note this line: AndroidModule4.jPanel1.Parent:= Self.jPanel2; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if itemId =  104 then  begin     //prepare scene at first launch...    //put initialize here to not "delay" the application at startup...    if AndroidModule4 = nil then    begin      gApp.CreateForm(TAndroidModule4, AndroidModule4); //property "ActiveMode = actEasel" dont "show" form      AndroidModule4.Init(gApp); //fire OnJNIPrompt ...      AndroidModule4.jPanel1.Parent:= Self.jPanel2;// <<-------- need to handle LayoutParamWidth/LayoutParamHeight "OnRotate"      AndroidModule4.jPanel1.SetViewParent(Self.jPanel2.View); //add scene 4 to Self.jPanel2    end;     ActiveScene:= 104;    AndroidModule4.jPanel1.BringToFront();  end;  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.AndroidModule1Rotate(Sender: TObject;  rotate: TScreenStyle);begin   ......................................   if ActiveScene = 104 then //just as a demonstration....   begin      AndroidModule4.AndroidModule4Rotate(Sender, rotate);   end;   -----------------------------------end;  Unit4.pas   [your form] Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule4.AndroidModule4JNIPrompt(Sender: TObject);begin   if Self.GetScreenOrientationStyle =  ssLandscape then   begin     Self.jScrollView1.LayoutParamHeight:= lpTwoFifthOfParent;     Self.jListView1.LayoutParamHeight:= lpOneFifthOfParent;     Self.UpdateLayout;   endend; procedure TAndroidModule4.AndroidModule4Rotate(Sender: TObject; rotate: TScreenStyle);begin   if rotate =  ssLandscape then   begin     Self.jScrollView1.LayoutParamHeight:= lpTwoFifthOfParent;     Self.jListView1.LayoutParamHeight:= lpOneFifthOfParent;   end   else   begin     Self.jScrollView1.LayoutParamHeight:= lpHalfOfParent;     Self.jListView1.LayoutParamHeight:= lpOneQuarterOfParent   end;   Self.UpdateLayout;end; ---------------------------------------------------------------------- AFFRIZA 亜風実 · 2019-06-25 04:44 TMainControl.MainControlJNIPrompt Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  scHome = 1100;  scOrderJual = 1101;  scDataSales = 1102;  scScene3 = 1199;    //...    // Don't use "show" method on actEeasel    if not Assigned(AndroidModule1) then      begin       gApp.CreateForm(TAndroidModule1, AndroidModule1);       AndroidModule1.Init(gApp);       // This is confusing, still doesn't work       AndroidModule1.Parent := pnViewer;       // Maybe I prefered using jPanel1.ChildViewList or something to handle all child view layout automatically by parent       AndroidModule1.jPanel1.SetViewParent(pnViewer.View);    end;         TMainControl.jsNavigationView1ClickItem Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   // like in the demonstration  case itemId of    scHome: pnMain.BringToFront();    scDataSales: DataSales.jPanel3.BringToFront();    scOrderJual: OrderJual.jPanel1.BringToFront();    scScene3: AndroidModule1.jPanel1.BringToFront();  end;  // I hope I can have jsNavigationView1.ActiveMenuItem  ActiveScene := ItemID;  jsDrawerLayout1.CloseDrawers();   TMainControl.MainControlRotate Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   // like in the demonstration  case ActiveScene of    scDataSales: DataSales.DataSalesRotate(Sender, rotate);    scOrderJual: OrderJual.OrderJualRotate(Sender, rotate);    scScene3: AndroidModule1.AndroidModule1Rotate(Sender, rotate);  end; TAndroidModule1.AndroidModule1JNIPrompt Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    if Self.GetScreenOrientationStyle =  ssLandscape then   begin     Self.jScrollView1.LayoutParamHeight:= lpTwoFifthOfParent;     Self.jListView1.LayoutParamHeight:= lpOneFifthOfParent;     Self.UpdateLayout;   end TAndroidModule1.AndroidModule1Rotate Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    if rotate =  ssLandscape then   begin     Self.jScrollView1.LayoutParamHeight:= lpTwoFifthOfParent;     Self.jListView1.LayoutParamHeight:= lpOneFifthOfParent;   end   else   begin     Self.jScrollView1.LayoutParamHeight:= lpHalfOfParent;     Self.jListView1.LayoutParamHeight:= lpOneQuarterOfParent   end;   Self.UpdateLayout;    // Must be triggered here   ShowMessage('rotated');         Yeah, I already read that. Maybe my project is broken, corrupted or something. I'll try to create a new project from the start later.