Recent

Author Topic: LAMW OnRotate  (Read 1365 times)

jmpessoa

  • Hero Member
  • *****
  • Posts: 1477
Re: LAMW OnRotate
« Reply #15 on: June 24, 2019, 05:04:55 am »

Done!!!

Updated "AppCompatNavigationDrawerDemo1" !!!
[and other required files....]

Now we can handle "OnRotate"!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Dio Affriza

  • Jr. Member
  • **
  • Posts: 87
Re: LAMW OnRotate
« Reply #16 on: June 24, 2019, 08:59:41 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]
  1. procedure TMainControl.jsNavigationView1ClickItem(Sender: TObject;
  2.   itemId: integer; itemCaption: string);
  3. begin
  4.   case itemId of
  5.     scHome: pnMain.BringToFront();
  6.     scDataSales: DataSales.jPanel3.BringToFront();
  7.     scOrderJual: OrderJual.jPanel1.BringToFront();
  8.     scScene3: AndroidModule1.jPanel1.BringToFront();
  9.   end;
  10.   ActiveScene := ItemID;
  11.   jsDrawerLayout1.CloseDrawers();
  12. end;
  13.  
  14. procedure TMainControl.MainControlRotate(Sender: TObject; rotate: TScreenStyle);
  15. begin
  16.   case ActiveScene of
  17.     scDataSales: DataSales.DataSalesRotate(Sender, rotate);
  18.     scOrderJual: OrderJual.OrderJualRotate(Sender, rotate);
  19.     scScene3: AndroidModule1.AndroidModule1Rotate(Sender, rotate);
  20.   end;
  21. end;  
  22.  

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.
« Last Edit: June 24, 2019, 09:26:45 am by Dio Affriza »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1477
Re: LAMW OnRotate
« Reply #17 on: June 24, 2019, 07:58:31 pm »
(0)
Quote
I've deleted build folder....

I did not understand...

(1)
Quote
But, 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) 
Quote
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.

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....]
« Last Edit: June 24, 2019, 08:08:19 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Dio Affriza

  • Jr. Member
  • **
  • Posts: 87
Re: LAMW OnRotate
« Reply #18 on: June 25, 2019, 04:46:42 am »
(0)
Quote
I'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

  • Hero Member
  • *****
  • Posts: 1477
Re: LAMW OnRotate
« Reply #19 on: June 25, 2019, 05:02:45 am »
Study the demo carefully ....

Unit1.pas   [main unit.....]

note this line: AndroidModule4.jPanel1.Parent:= Self.jPanel2;

Code: Pascal  [Select]
  1.   if itemId =  104 then
  2.   begin
  3.  
  4.     //prepare scene at first launch...
  5.     //put initialize here to not "delay" the application at startup...
  6.     if AndroidModule4 = nil then
  7.     begin
  8.       gApp.CreateForm(TAndroidModule4, AndroidModule4); //property "ActiveMode = actEasel" dont "show" form
  9.       AndroidModule4.Init(gApp); //fire OnJNIPrompt ...
  10.       AndroidModule4.jPanel1.Parent:= Self.jPanel2;// <<-------- need to handle LayoutParamWidth/LayoutParamHeight "OnRotate"
  11.       AndroidModule4.jPanel1.SetViewParent(Self.jPanel2.View); //add scene 4 to Self.jPanel2
  12.     end;
  13.  
  14.     ActiveScene:= 104;
  15.     AndroidModule4.jPanel1.BringToFront();
  16.   end;
  17.  

Code: Pascal  [Select]
  1. procedure TAndroidModule1.AndroidModule1Rotate(Sender: TObject;
  2.   rotate: TScreenStyle);
  3. begin
  4.    ......................................
  5.    if ActiveScene = 104 then //just as a demonstration....
  6.    begin
  7.       AndroidModule4.AndroidModule4Rotate(Sender, rotate);
  8.    end;
  9.    -----------------------------------
  10. end;
  11.  

Unit4.pas   [your form]
Code: Pascal  [Select]
  1. procedure TAndroidModule4.AndroidModule4JNIPrompt(Sender: TObject);
  2. begin
  3.    if Self.GetScreenOrientationStyle =  ssLandscape then
  4.    begin
  5.      Self.jScrollView1.LayoutParamHeight:= lpTwoFifthOfParent;
  6.      Self.jListView1.LayoutParamHeight:= lpOneFifthOfParent;
  7.      Self.UpdateLayout;
  8.    end
  9. end;
  10.  
  11. procedure TAndroidModule4.AndroidModule4Rotate(Sender: TObject; rotate: TScreenStyle);
  12. begin
  13.    if rotate =  ssLandscape then
  14.    begin
  15.      Self.jScrollView1.LayoutParamHeight:= lpTwoFifthOfParent;
  16.      Self.jListView1.LayoutParamHeight:= lpOneFifthOfParent;
  17.    end
  18.    else
  19.    begin
  20.      Self.jScrollView1.LayoutParamHeight:= lpHalfOfParent;
  21.      Self.jListView1.LayoutParamHeight:= lpOneQuarterOfParent
  22.    end;
  23.    Self.UpdateLayout;
  24. end;
  25.  
  26.  
« Last Edit: June 25, 2019, 05:08:40 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Dio Affriza

  • Jr. Member
  • **
  • Posts: 87
Re: LAMW OnRotate
« Reply #20 on: June 25, 2019, 06:44:37 am »
TMainControl.MainControlJNIPrompt
Code: Pascal  [Select]
  1. const
  2.   scHome = 1100;
  3.   scOrderJual = 1101;
  4.   scDataSales = 1102;
  5.   scScene3 = 1199;
  6.     //...
  7.     // Don't use "show" method on actEeasel
  8.     if not Assigned(AndroidModule1) then  
  9.     begin
  10.        gApp.CreateForm(TAndroidModule1, AndroidModule1);
  11.        AndroidModule1.Init(gApp);
  12.        // This is confusing, still doesn't work
  13.        AndroidModule1.Parent := pnViewer;
  14.        // Maybe I prefered using jPanel1.ChildViewList or something to handle all child view layout automatically by parent
  15.        AndroidModule1.jPanel1.SetViewParent(pnViewer.View);
  16.     end;          
  17.  

TMainControl.jsNavigationView1ClickItem
Code: Pascal  [Select]
  1.   // like in the demonstration
  2.   case itemId of
  3.     scHome: pnMain.BringToFront();
  4.     scDataSales: DataSales.jPanel3.BringToFront();
  5.     scOrderJual: OrderJual.jPanel1.BringToFront();
  6.     scScene3: AndroidModule1.jPanel1.BringToFront();
  7.   end;
  8.   // I hope I can have jsNavigationView1.ActiveMenuItem
  9.   ActiveScene := ItemID;
  10.   jsDrawerLayout1.CloseDrawers();  
  11.  

TMainControl.MainControlRotate
Code: Pascal  [Select]
  1.   // like in the demonstration
  2.   case ActiveScene of
  3.     scDataSales: DataSales.DataSalesRotate(Sender, rotate);
  4.     scOrderJual: OrderJual.OrderJualRotate(Sender, rotate);
  5.     scScene3: AndroidModule1.AndroidModule1Rotate(Sender, rotate);
  6.   end;
  7.  

TAndroidModule1.AndroidModule1JNIPrompt
Code: Pascal  [Select]
  1.    if Self.GetScreenOrientationStyle =  ssLandscape then
  2.    begin
  3.      Self.jScrollView1.LayoutParamHeight:= lpTwoFifthOfParent;
  4.      Self.jListView1.LayoutParamHeight:= lpOneFifthOfParent;
  5.      Self.UpdateLayout;
  6.    end
  7.  

TAndroidModule1.AndroidModule1Rotate
Code: Pascal  [Select]
  1.    if rotate =  ssLandscape then
  2.    begin
  3.      Self.jScrollView1.LayoutParamHeight:= lpTwoFifthOfParent;
  4.      Self.jListView1.LayoutParamHeight:= lpOneFifthOfParent;
  5.    end
  6.    else
  7.    begin
  8.      Self.jScrollView1.LayoutParamHeight:= lpHalfOfParent;
  9.      Self.jListView1.LayoutParamHeight:= lpOneQuarterOfParent
  10.    end;
  11.    Self.UpdateLayout;
  12.    // Must be triggered here
  13.    ShowMessage('rotated');        
  14.  

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.