Recent

Author Topic: Android Module Wizard  (Read 705608 times)

renabor

  • Jr. Member
  • **
  • Posts: 73
Re: Android Module Wizard
« Reply #690 on: November 09, 2015, 05:21:03 pm »
Hi jmpessoa, i am developing an english study app, but it has a problem with jactionbartab

When I press on image button , tabs will be created and show, but if i want back home page, tabs  still be there ( on the top of screen)

I tried to use both command

self.RemoveAllTabsActionBar();
jactionbartab1.RemoveAllTabs();   

but they can't solve this
You can see image below to understand more

Hello m4u_hoahoctro!

I use this method in order to remove tabs:

Code: [Select]
  jMenu1.Clear();
  self.RemoveAllTabsActionBar();
  jMenu1.InvalidateOptionsMenu();

be sure that in your controls.java the method RemoveAllTabsActionBar is updated:

Code: [Select]
public void RemoveAllTabsActionBar() {
ActionBar actionBar = this.controls.activity.getActionBar();
actionBar.removeAllTabs();
        this.controls.activity.invalidateOptionsMenu();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); //API 11 renabor
}


« Last Edit: November 09, 2015, 05:41:49 pm by renabor »
FPC 3.2.2 | Lazarus 2.2.3 | Kubuntu 22.04 64bit

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #691 on: November 13, 2015, 02:54:01 pm »
May be i was wrong when i decided to update lamw and laz4android
I updated:
lamw's lastest version
laz4android 1.4
android ndk 10e

I confirgured paths setting, and when I choose Update Code menu ( rebuild .so lib): This error shows: Priviledged instruction ( below image )

and so I choosed Cancel to reopen laz4, and I tried to open my project ( created by older version of lamw and laz4 ( 1.3) )
but I still got more errors ( Can see  by images I sent below )

http://i.imgur.com/3iBUa1p.png

http://i.imgur.com/lc36CtX.png


after some hours, I used backup version of my project and reopen it
everything is ok until I choose Run and build apk file menu
As this image, I choosed Yes to all because i updated ndk to r10e
http://i.imgur.com/wtXyjbI.png

then a dialog appears, and i dont know which  should be chosen
 :o
http://i.imgur.com/LvTGDdO.png

I need a solution from others, thanks  %) %) %)
« Last Edit: November 13, 2015, 03:08:45 pm by m4u_hoahoctro »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: Android Module Wizard
« Reply #692 on: November 13, 2015, 03:46:22 pm »
Hello M4u

1.

 You need download ndk10e


2.

Go to "C:\laz4android\config"

and change  "JNIAndroidProject.ini"  lines:

PathToAndroidNDK=your "ndk10e" path
NDK=3


3.

For old projects open "*.lpi" and change NDK path and replace "4.6" to "4.9"

 
« Last Edit: November 13, 2015, 03:48:03 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #693 on: November 14, 2015, 06:03:08 am »
Hello M4u

2.

Go to "C:\laz4android\config"

and change  "JNIAndroidProject.ini"  lines:

PathToAndroidNDK=your "ndk10e" path
NDK=3


I set up laz4android in D drive, but I dont find any file whose name JNIAndroidProject.ini in config folder ( below image )
http://i.imgur.com/KBa7phs.png

 

« Last Edit: November 14, 2015, 06:13:28 am by m4u_hoahoctro »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Android Module Wizard
« Reply #694 on: November 14, 2015, 08:05:37 am »
I set up laz4android in D drive, but I dont find any file whose name JNIAndroidProject.ini in config folder ( below image )
http://i.imgur.com/KBa7phs.png
JNIAndroidProject.ini is located in lazarus configuration directory, not your app (it's global for all of your LAMW projects).

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: Android Module Wizard
« Reply #695 on: November 14, 2015, 10:41:19 am »
Yes,

Go to "..\laz4android\config"     // << -----------------

and change  "JNIAndroidProject.ini"  lines:

PathToAndroidNDK=your "ndk10e" path
NDK=3


Well, if  you not have "JNIAndroidProject.ini"  in  your new laz4android install, then
you can copy from the old install [and fix it]

or:

go to Lazarus IDE menu  ---> Tools ---> [Lamw] ---> Paths Settings
« Last Edit: November 14, 2015, 11:23:49 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #696 on: November 14, 2015, 11:54:46 am »
problem was solved. thanks to all  :) :)

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #697 on: December 07, 2015, 12:43:38 pm »
after updating lamw, i am having a new problem
I tried making an app loading image from internet
I used code as I did before, but the app will be closed ( crash )

asynctask do in background

Code: Pascal  [Select][+][-]
  1. if actiontype=8 then
  2.  begin
  3.  FImageBitmap:=jImageFileManager1.LoadFromURL('http://miftyisbored.com/wp-content/uploads/2013/07/nature-sound-spa-app.png');
  4.  FImageBitmap:=Get_jObjGlobalRef(FImageBitmap);
  5.  end;              
  6.  

post excute:

Code: Pascal  [Select][+][-]
  1. if actiontype=8 then
  2.  begin
  3.  if FImageBitmap<>nil then
  4.   begin
  5.   jImageview11.SetImageBitmap(FImageBitmap);
  6.   Delete_jGlobalRef(FImageBitmap);
  7.   FImageBitmap:=nil;
  8.   end;
  9.  end;        

and the button runs that codes

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jImageView12Click(Sender: TObject);
  2. begin
  3.   jtextview1.text:=suggestion;
  4.   actiontype:=8;
  5.   if not jasynctask1.Running=true then
  6.   begin
  7.   jdialogprogress1.Start;
  8.   jasynctask1.Execute;
  9.   end;
  10.    ttime:=30;
  11.    jtimer1.enabled:=true;
  12.  
  13. end;          

i tested many times, and errors always appears if I use code:
Code: Pascal  [Select][+][-]
  1. FImageBitmap:=jImageFileManager1.LoadFromURL('http://miftyisbored.com/wp-content/uploads/2013/07/nature-sound-spa-app.png');
  2.  FImageBitmap:=Get_jObjGlobalRef(FImageBitmap);          

( many it caused all problem )

I dont know what should do next or fix it  %)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Android Module Wizard
« Reply #698 on: December 08, 2015, 06:19:10 pm »
Hello guys , there is a demo or an example to generate an Graph Lines with LAMW

Like this:

http://blog.andreaventuri.it/wp-content/uploads/2010/03/linegraph.jpg
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: Android Module Wizard
« Reply #699 on: December 09, 2015, 04:02:52 pm »
@m4u_hoahoctro

Please, put here your "unit1.pas" ...

@xinyiman

I have a multi-platform graphics toolkit here:

https://github.com/jmpessoa/tfpdxfwritebridge   [install first]
https://github.com/jmpessoa/tfpnoguigraphicsbridge

You can get  "AppTFPNoGUIGraphicsBridgeDemo1" in "...\demos\Eclipse"

I will try to do a new android demo to mimic your example...

See the windows preview [attachment]... the windows code is here:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, FPNoGUIGraphicsBridge, ViewPort, Forms, Controls,
  9.   Graphics, Dialogs, ExtCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     FPNoGUIGraphicsBridge1: TFPNoGUIGraphicsBridge;
  17.     PaintBox1: TPaintBox;
  18.     Panel1: TPanel;
  19.     Panel2: TPanel;
  20.     ViewPort1: TViewPort;
  21.     procedure FormCreate(Sender: TObject);
  22.     procedure PaintBox1Paint(Sender: TObject);
  23.   private
  24.     { private declarations }
  25.   public
  26.     { public declarations }
  27.   end;
  28.  
  29. var
  30.   Form1: TForm1;
  31.  
  32. implementation
  33.  
  34. {$R *.lfm}
  35.  
  36. uses
  37.   GeometryUtilsBridge, fpcolorbridge;
  38.  
  39. { TForm1 }
  40.  
  41. procedure TForm1.FormCreate(Sender: TObject);
  42. begin
  43.    ViewPort1.Height:= PaintBox1.Height;
  44.    ViewPort1.Width:= PaintBox1.Width;
  45.  
  46.    ViewPort1.SetScaleXY(0 {minx}, 15 {maxx}, -5 {miny}, 15 {maxy});
  47.  
  48.    FPNoGUIGraphicsBridge1.PathToFontFile:= 'C:\Windows\Fonts\LUCON.TTF';
  49.    FPNoGUIGraphicsBridge1.SetSurfaceSize(PaintBox1.Width,PaintBox1.Height);
  50.  
  51.    //FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort1; //or in design time
  52.    FPNoGUIGraphicsBridge1.PaintViewPort;
  53.    FPNoGUIGraphicsBridge1.PaintGrid(True);
  54.  
  55.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(4,10),ToRealPoint(5,11) ],'','');
  56.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(4,10),ToRealPoint(4+0.1,10) ],'','');
  57.  
  58.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(5,11),ToRealPoint(6,11) ],'','');
  59.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(5,11),ToRealPoint(5+0.1,11) ],'','');
  60.  
  61.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(6,11),ToRealPoint(7,12) ],'','');
  62.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(6,11),ToRealPoint(6+0.1,11) ],'','');
  63.  
  64.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(7,12),ToRealPoint(8,12) ],'','');
  65.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(7,12),ToRealPoint(7+0.1,12) ],'','');
  66.  
  67.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(8,12),ToRealPoint(10,13) ],'','');
  68.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(8,12),ToRealPoint(8+0.1,12) ],'','');
  69.  
  70.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(10,13),ToRealPoint(11,14) ],'','');
  71.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(10,13),ToRealPoint(10+0.1,13) ],'','');
  72.  
  73.    FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(11,14),ToRealPoint(12,15) ],'','');
  74.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(11,14),ToRealPoint(11+0.1,14) ],'','');
  75.    FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(12,15),ToRealPoint(12+0.1,15) ],'','');
  76.  
  77.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(4,-5),ToRealPoint(5,0) ],'','');
  78.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(4,-5),ToRealPoint(4+0.1,-5) ],'','');
  79.  
  80.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(5,0),ToRealPoint(6,7) ],'','');
  81.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(5,0),ToRealPoint(5+0.1,0) ],'','');
  82.  
  83.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(6,7),ToRealPoint(7,10) ],'','');
  84.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(6,7),ToRealPoint(6+0.1,7) ],'','');
  85.  
  86.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(7,10),ToRealPoint(8,10) ],'','');
  87.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(7,10),ToRealPoint(7+0.1,10) ],'','');
  88.  
  89.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(8,10),ToRealPoint(10,11) ],'','');
  90.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(8,10),ToRealPoint(8+0.1,10) ],'','');
  91.  
  92.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(10,11),ToRealPoint(11,12) ],'','');
  93.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(10,11),ToRealPoint(10+0.1,11) ],'','');
  94.  
  95.    FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(11,12),ToRealPoint(12,14) ],'','');
  96.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(11,12),ToRealPoint(11+0.1,12) ],'','');
  97.    FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(12,14),ToRealPoint(12+0.1,14) ],'','');
  98.  
  99.    //ViewPort1.PenColor:= colbrRed;  //default
  100.    FPNoGUIGraphicsBridge1.DrawEntities('red');
  101.  
  102.    ViewPort1.PenColor:= colbrBlue;
  103.    FPNoGUIGraphicsBridge1.DrawEntities('blue');
  104.  
  105.    PaintBox1.Invalidate;
  106. end;
  107.  
  108. procedure TForm1.PaintBox1Paint(Sender: TObject);
  109. begin
  110.   FPNoGUIGraphicsBridge1.CopyToCanvas(PaintBox1.Canvas);
  111. end;
  112.  
  113. end.
  114.  
  115.  
« Last Edit: December 10, 2015, 01:41:14 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: Android Module Wizard
« Reply #700 on: December 10, 2015, 05:44:58 am »
Hello xinyiman!

The android demo to mimic your example was added to github repository....

You can get  "AppTFPNoGUIGraphicsBridgeDemo2" in "...\demos\Eclipse"
[please, read the "readme.txt" in "..\jni"]

note:  you need the graphics toolkit from here:

https://github.com/jmpessoa/tfpdxfwritebridge  [install first]
https://github.com/jmpessoa/tfpnoguigraphicsbridge
                 

the android preview [attachment]... the android code is here:

Code: Pascal  [Select][+][-]
  1. {Hint: save all files to location: C:\adt32\eclipse\workspace\AppTFPNoGUIGraphicsBridgeDemo2\jni }
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
  10.     Laz_And_Controls_Events, AndroidWidget, FPNoGUIGraphicsBridge, ViewPort;
  11.  
  12. type
  13.  
  14.   { TAndroidModule1 }
  15.  
  16.   TAndroidModule1 = class(jForm)
  17.     FPNoGUIGraphicsBridge1: TFPNoGUIGraphicsBridge;
  18.     jBitmap1: jBitmap;
  19.     jButton1: jButton;
  20.     jImageView1: jImageView;
  21.     jPanel1: jPanel;
  22.     jPanel2: jPanel;
  23.     jTextView1: jTextView;
  24.     ViewPort1: TViewPort;
  25.     procedure jButton1Click(Sender: TObject);
  26.   private
  27.     {private declarations}
  28.   public
  29.     {public declarations}
  30.   end;
  31.  
  32. var
  33.   AndroidModule1: TAndroidModule1;
  34.   PGlobalDirectImagePixel: PJByte;
  35.  
  36. implementation
  37.  
  38. {$R *.lfm}
  39.  
  40. uses
  41.   FPColorBridge, GeometryUtilsBridge;
  42.  
  43. { TAndroidModule1 }
  44.  
  45. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  46. var
  47.   jGraphicsBuffer: jObject;
  48.   w, h: integer;
  49. begin
  50.   w:= jPanel2.Width;
  51.   h:= jPanel2.Height;
  52.  
  53.   ViewPort1.Height:= h;
  54.   ViewPort1.Width:= w;
  55.  
  56.   ViewPort1.SetScaleXY(0 {minx}, 15 {maxx}, -5 {miny}, 15 {maxy});
  57.  
  58.   FPNoGUIGraphicsBridge1.SetSurfaceSize(w,h);
  59.   FPNoGUIGraphicsBridge1.PathToFontFile:= '/system/fonts/Roboto-Regular.ttf'; //or DroidSerif-Bold.ttf
  60.  
  61.   //FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort1; //or in design time
  62.   FPNoGUIGraphicsBridge1.PaintViewPort;
  63.   FPNoGUIGraphicsBridge1.PaintGrid(True);
  64.  
  65.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(4,10),ToRealPoint(5,11) ],'','');
  66.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(4,10),ToRealPoint(4+0.1,10) ],'','');
  67.  
  68.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(5,11),ToRealPoint(6,11) ],'','');
  69.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(5,11),ToRealPoint(5+0.1,11) ],'','');
  70.  
  71.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(6,11),ToRealPoint(7,12) ],'','');
  72.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(6,11),ToRealPoint(6+0.1,11) ],'','');
  73.  
  74.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(7,12),ToRealPoint(8,12) ],'','');
  75.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(7,12),ToRealPoint(7+0.1,12) ],'','');
  76.  
  77.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(8,12),ToRealPoint(10,13) ],'','');
  78.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(8,12),ToRealPoint(8+0.1,12) ],'','');
  79.  
  80.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(10,13),ToRealPoint(11,14) ],'','');
  81.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(10,13),ToRealPoint(10+0.1,13) ],'','');
  82.  
  83.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(11,14),ToRealPoint(12,15) ],'','');
  84.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(11,14),ToRealPoint(11+0.1,14) ],'','');
  85.   FPNoGUIGraphicsBridge1.AddEntity('red','Circle',[ToRealPoint(12,15),ToRealPoint(12+0.1,15) ],'','');
  86.  
  87.   //legend
  88.   FPNoGUIGraphicsBridge1.AddEntity('red','Line',[ToRealPoint(14,5),ToRealPoint(15,5) ],'','');
  89.   FPNoGUIGraphicsBridge1.AddEntity('red','Text',[ToRealPoint(15,5)],'Feb','');
  90.  
  91.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(4,-5),ToRealPoint(5,0) ],'','');
  92.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(4,-5),ToRealPoint(4+0.1,-5) ],'','');
  93.  
  94.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(5,0),ToRealPoint(6,7) ],'','');
  95.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(5,0),ToRealPoint(5+0.1,0) ],'','');
  96.  
  97.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(6,7),ToRealPoint(7,10) ],'','');
  98.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(6,7),ToRealPoint(6+0.1,7) ],'','');
  99.  
  100.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(7,10),ToRealPoint(8,10) ],'','');
  101.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(7,10),ToRealPoint(7+0.1,10) ],'','');
  102.  
  103.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(8,10),ToRealPoint(10,11) ],'','');
  104.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(8,10),ToRealPoint(8+0.1,10) ],'','');
  105.  
  106.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(10,11),ToRealPoint(11,12) ],'','');
  107.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(10,11),ToRealPoint(10+0.1,11) ],'','');
  108.  
  109.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(11,12),ToRealPoint(12,14) ],'','');
  110.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(11,12),ToRealPoint(11+0.1,12) ],'','');
  111.   FPNoGUIGraphicsBridge1.AddEntity('blue','Circle',[ToRealPoint(12,14),ToRealPoint(12+0.1,14) ],'','');
  112.  
  113.   //legend
  114.   FPNoGUIGraphicsBridge1.AddEntity('blue','Line',[ToRealPoint(14,4),ToRealPoint(15,4) ],'','');
  115.   FPNoGUIGraphicsBridge1.AddEntity('blue','Text',[ToRealPoint(15,4)],'Jan','');
  116.  
  117.   //ViewPort1.PenColor:= colbrRed;  //default: design time
  118.   FPNoGUIGraphicsBridge1.DrawEntities('red');
  119.  
  120.   ViewPort1.PenColor:= colbrBlue;
  121.   FPNoGUIGraphicsBridge1.DrawEntities('blue');
  122.  
  123. (*
  124.    //or simply
  125.    ViewPort1.PenColor:= colbrGreen;
  126.    FPNoGUIGraphicsBridge1.DrawPath([ToRealPoint(3,3), ToRealPoint(4,4), ToRealPoint(5,5),ToRealPoint(6,6), ToRealPoint(7,7), ToRealPoint(8,8)]);
  127.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(3,3){center},ToRealPoint(3+0.1,3) {rX}]);
  128.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(4,4){center},ToRealPoint(4+0.1,4) {rX}]);
  129.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(5,5){center},ToRealPoint(5+0.1,5) {rX}]);
  130.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(6,6){center},ToRealPoint(6+0.1,6) {rX}]);
  131.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(7,7){center},ToRealPoint(7+0.1,7) {rX}]);
  132.    FPNoGUIGraphicsBridge1.DrawFillCircle([ToRealPoint(8,8){center},ToRealPoint(8+0.1,8) {rX}]);
  133.    FPNoGUIGraphicsBridge1.DrawFillRectangle([ToRealPoint(9.5,8.0),ToRealPoint(10,7)]); {left-top, right-bottom}
  134.    FPNoGUIGraphicsBridge1.TextOut(ToRealPoint(10.2,7), 'Mar', 22, colbrGreen);
  135. *)
  136.  
  137.   jGraphicsBuffer:= jBitmap1.GetByteBuffer(w,h);
  138.  
  139.   PGlobalDirectImagePixel:= jBitmap1.GetDirectBufferAddress(jGraphicsBuffer);
  140.  
  141.   FPNoGUIGraphicsBridge1.Surface.GetRGBAGraphics(PGlobalDirectImagePixel);
  142.  
  143.   jImageView1.SetImageBitmap(jBitmap1.GetBitmapFromByteBuffer(jGraphicsBuffer, w, h));
  144. end;
  145.  
  146. end.
  147.  

« Last Edit: December 12, 2015, 03:36:28 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Android Module Wizard
« Reply #701 on: December 17, 2015, 08:46:12 pm »
Hello, I would have a couple of questions. How do I ensure that a jtextbox accept only numbers?

How do I use the JTIMER?

Are there examples?

Then I wanted to know, there is a guide that explains clearly the best methods to manage the look and feel of an application made with  Android (LAMW)?

Thank you
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

truetom

  • Jr. Member
  • **
  • Posts: 73
    • http://sourceforge.net/projects/laz4android/
Re: Android Module Wizard
« Reply #702 on: December 18, 2015, 02:03:49 am »
Hello, I would have a couple of questions. How do I ensure that a jtextbox accept only numbers?

How do I use the JTIMER?

Are there examples?

Then I wanted to know, there is a guide that explains clearly the best methods to manage the look and feel of an application made with  Android (LAMW)?

Thank you

Hello,

try  to answer your question.

1. set Property InputTypeEx:= itxNumber;
2. When jFrom create , set jTimer enabled to true, jTimer1.enabled:=true;

Thanks and best regard!
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: Android Module Wizard
« Reply #703 on: December 18, 2015, 02:33:49 am »

Quote
...there is a guide that explains clearly the best methods to manage the look and feel of an application made with  Android (LAMW)?

LAMW now support  android "themes"...  so you can get the android  "look and feel" by Just

selecting a theme [create new project]:

   DeviceDefault
   Holo.Light.DarkActionBar 
   Holo.Light 
   Holo
   Material.Light.DarkActionBar
   Material.Light
   Material
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: Android Module Wizard
« Reply #704 on: December 22, 2015, 05:20:28 pm »

Hi!

Following the suggestion and request by xinyiman, 

There are news "Lamw" demos for "chart" [https://github.com/jmpessoa/lazandroidmodulewizard]:

AppTFPNoGUIGraphicsBridgeDemo4 [DataPieSlices and DataLines graphics]  <<--- picture attachment!
AppTFPNoGUIGraphicsBridgeDemo5  [DataBars and DataHistogram graphics]

warning 1: read the "readme.txt" in  project  "...\jni" folder

warning 2. install the "NoGUIGraphicsBridge" package from here :

https://github.com/jmpessoa/tfpnoguigraphicsbridge   
[a native pascal multi-platform graphics toolkit wrapper over Free Pascal "fcl-image" + freetype]


AppTFPNoGUIGraphicsBridgeDemo4  "unit1.pas" code "look and feel" is here:

Code: Pascal  [Select][+][-]
  1. {Hint: save all files to location: C:\adt32\eclipse\workspace\AppTFPNoGUIGraphicsBridgeDemo4\jni }
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
  10.     Laz_And_Controls_Events, AndroidWidget, FPNoGUIGraphicsBridge, ViewPort;
  11.  
  12. type
  13.  
  14.   { TAndroidModule1 }
  15.  
  16.   TAndroidModule1 = class(jForm)
  17.     FPNoGUIGraphicsBridge1: TFPNoGUIGraphicsBridge;
  18.     jBitmap1: jBitmap;
  19.     jButton1: jButton;
  20.     jImageView1: jImageView;
  21.     jPanel1: jPanel;
  22.     jPanel2: jPanel;
  23.     jTextView1: jTextView;
  24.     ViewPort1: TViewPort;
  25.     ViewPort2: TViewPort;
  26.     procedure jButton1Click(Sender: TObject);
  27.   private
  28.     {private declarations}
  29.   public
  30.     {public declarations}
  31.   end;
  32.  
  33. var
  34.   AndroidModule1: TAndroidModule1;
  35.   PGlobalDirectImagePixel: PJByte;
  36.  
  37. implementation
  38.  
  39. {$R *.lfm}
  40.  
  41. uses
  42.   FPColorBridge, GeometryUtilsBridge;
  43.  
  44. { TAndroidModule1 }
  45.  
  46. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  47. var
  48.   jGraphicsBuffer: jObject;
  49.   w, h: integer;
  50. begin
  51.   w:= jPanel2.Width;
  52.   h:= jPanel2.Height;
  53.  
  54.   ViewPort1.XLeft:= 0;
  55.   ViewPort1.YTop:= 0;
  56.   ViewPort1.Height:= Trunc(h/2);
  57.   ViewPort1.Width:= w;
  58.  
  59.   ViewPort1.SetScaleXY(0 {minx}, 10 {maxx}, 0 {miny}, 10 {maxy});
  60.  
  61.   FPNoGUIGraphicsBridge1.SetSurfaceSize(w,h);
  62.   FPNoGUIGraphicsBridge1.PathToFontFile:= '/system/fonts/Roboto-Regular.ttf'; //or DroidSerif-Bold.ttf
  63.  
  64.   FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort1; //or in design time
  65.   FPNoGUIGraphicsBridge1.PaintViewPort;
  66.   FPNoGUIGraphicsBridge1.PaintGrid(True);
  67.  
  68.   FPNoGUIGraphicsBridge1.DrawDataPieSlices([ToRealPoint(1,8),ToRealPoint(7,2)],
  69.                                            [ToSlice(45,'Jan', colbrLightGray),
  70.                                             ToSlice(15,'Fev', colbrYellow),
  71.                                             ToSlice(40,'Mar', colbrMoccasin),
  72.                                             ToSlice(40,'Abr', colbrLightBlue),
  73.                                             ToSlice(40,'Mai', colbrLime),
  74.                                             ToSlice(45,'Jun', colbrLightSalmon)], False);
  75.   ViewPort2.XLeft:= 0;
  76.   ViewPort2.YTop:= Trunc(h/2);
  77.   ViewPort2.Height:= Trunc(h/2);
  78.   ViewPort2.Width:= w;
  79.   ViewPort2.SetScaleXY(0 {minx}, 14 {maxx}, -5 {miny}, 15 {maxy});
  80.  
  81.   FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort2;
  82.   FPNoGUIGraphicsBridge1.PaintViewPort;
  83.   FPNoGUIGraphicsBridge1.PaintGrid(True);
  84.  
  85.   //
  86.   FPNoGUIGraphicsBridge1.DrawDataLine([ToRealPoint(4,10),
  87.                                    ToRealPoint(5,11),
  88.                                    ToRealPoint(6,11),
  89.                                    ToRealPoint(7,12),
  90.                                    ToRealPoint(8,12),
  91.                                    ToRealPoint(10,13),
  92.                                    ToRealPoint(11,14),
  93.                                    ToRealPoint(12,15)],
  94.                                    ToLegend('Jan', colbrBlue, 14.1,9));
  95.  
  96.   FPNoGUIGraphicsBridge1.DrawDataLine([ToRealPoint(4,-5),
  97.                                    ToRealPoint(5,0),
  98.                                    ToRealPoint(6,7),
  99.                                    ToRealPoint(7,10),
  100.                                    ToRealPoint(8,10),
  101.                                    ToRealPoint(10,11),
  102.                                    ToRealPoint(11,12),
  103.                                    ToRealPoint(12,14)],
  104.                                    ToLegend('Fev', colbrSalmon, 14.1,7));
  105.  
  106.   FPNoGUIGraphicsBridge1.DrawDataLine([ToRealPoint(4,0),
  107.                                    ToRealPoint(5,6),
  108.                                    ToRealPoint(6,9),
  109.                                    ToRealPoint(7,11),
  110.                                    ToRealPoint(8,11),
  111.                                    ToRealPoint(10,12),
  112.                                    ToRealPoint(11,13),
  113.                                    ToRealPoint(12,13)],
  114.                                    ToLegend('Mar', colbrIndigo, 14.1,5));
  115.  
  116.   jGraphicsBuffer:= jBitmap1.GetByteBuffer(w,h);
  117.  
  118.   PGlobalDirectImagePixel:= jBitmap1.GetDirectBufferAddress(jGraphicsBuffer);
  119.  
  120.   FPNoGUIGraphicsBridge1.Surface.GetRGBAGraphics(PGlobalDirectImagePixel);
  121.  
  122.   jImageView1.SetImageBitmap(jBitmap1.GetBitmapFromByteBuffer(jGraphicsBuffer, w, h));
  123. end;
  124.  
  125. end.
  126.  


AppTFPNoGUIGraphicsBridgeDemo5  "unit1.pas" code  "look and feel" is here:
Code: Pascal  [Select][+][-]
  1. {Hint: save all files to location: C:\adt32\eclipse\workspace\AppTFPNoGUIGraphicsBridgeDemo5\jni }
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, And_jni, And_jni_Bridge, Laz_And_Controls,
  10.     Laz_And_Controls_Events, AndroidWidget, FPNoGUIGraphicsBridge, ViewPort;
  11.  
  12. type
  13.  
  14.   { TAndroidModule1 }
  15.  
  16.   TAndroidModule1 = class(jForm)
  17.     FPNoGUIGraphicsBridge1: TFPNoGUIGraphicsBridge;
  18.     jBitmap1: jBitmap;
  19.     jButton1: jButton;
  20.     jImageView1: jImageView;
  21.     jPanel1: jPanel;
  22.     jPanel2: jPanel;
  23.     jTextView1: jTextView;
  24.     ViewPort1: TViewPort;
  25.     ViewPort2: TViewPort;
  26.     procedure jButton1Click(Sender: TObject);
  27.   private
  28.     {private declarations}
  29.   public
  30.     {public declarations}
  31.   end;
  32.  
  33. var
  34.   AndroidModule1: TAndroidModule1;
  35.   PGlobalDirectImagePixel: PJByte;
  36.  
  37. implementation
  38.  
  39. {$R *.lfm}
  40.  
  41. uses
  42.   GeometryUtilsBridge, fpcolorbridge;
  43.  
  44. { TAndroidModule1 }
  45.  
  46. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  47. var
  48.   jGraphicsBuffer: jObject;
  49.   w, h: integer;
  50. begin
  51.   w:= jPanel2.Width;
  52.   h:= jPanel2.Height;
  53.  
  54.   ViewPort1.Height:= Trunc(h/2);
  55.   ViewPort1.Width:= w;
  56.   ViewPort1.SetScaleXY(0 {minx}, 23 {maxx}, 0 {miny}, 100 {maxy});
  57.  
  58.   ViewPort2.YTop:= Trunc(h/2);
  59.   ViewPort2.Height:= Trunc(h/2);
  60.   ViewPort2.Width:= w;
  61.   ViewPort2.SetScaleXY(0 {minx}, 2.5*6 {maxx = range*6}, 0 {miny}, 100 {maxy});
  62.  
  63.   FPNoGUIGraphicsBridge1.SetSurfaceSize(w,h);
  64.   FPNoGUIGraphicsBridge1.PathToFontFile:= '/system/fonts/Roboto-Regular.ttf'; //or DroidSerif-Bold.ttf
  65.  
  66.   FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort1; //or in design time
  67.   FPNoGUIGraphicsBridge1.PaintViewPort;
  68.   FPNoGUIGraphicsBridge1.PaintGrid(True);
  69.  
  70.   FPNoGUIGraphicsBridge1.DrawDataBars([ToBar(15,'Jan', colbrBlue),
  71.                                            ToBar(30,'Fev', colbrYellow),
  72.                                            ToBar(70,'Mar', colbrRed),
  73.                                            ToBar(25,'Abr', colbrLightBlue),
  74.                                            ToBar(40,'Mai', colbrLime),
  75.                                            ToBar(60,'Jun', colbrLightSalmon),
  76.                                            ToBar(15,'Jul', colbrGold),
  77.                                            ToBar(30,'Ago', colbrMagenta),
  78.                                            ToBar(70,'Set', colbrGreen),
  79.                                            ToBar(25,'Out', colbrLightSlateBlue),
  80.                                            ToBar(40,'Nov', colbrOrange),
  81.                                            ToBar(60,'Dez', colbrSalmon)]);
  82.  
  83.   FPNoGUIGraphicsBridge1.ActiveViewPort:= ViewPort2;
  84.   FPNoGUIGraphicsBridge1.PaintViewPort;
  85.   FPNoGUIGraphicsBridge1.PaintGrid(True);
  86.  
  87.   FPNoGUIGraphicsBridge1.DrawDataHistograms(
  88.                                               [ToHistogram(30, colbrGreen),
  89.                                               ToHistogram(45, colbrGold),
  90.                                               ToHistogram(65, colbrTomato),
  91.                                               ToHistogram(25, colbrLightSlateBlue),
  92.                                               ToHistogram(40, colbrRed),
  93.                                               ToHistogram(50, colbrBlue)],  2.5 {range});
  94.  
  95.  
  96.   jGraphicsBuffer:= jBitmap1.GetByteBuffer(w,h);
  97.  
  98.   PGlobalDirectImagePixel:= jBitmap1.GetDirectBufferAddress(jGraphicsBuffer);
  99.  
  100.   FPNoGUIGraphicsBridge1.Surface.GetRGBAGraphics(PGlobalDirectImagePixel);
  101.  
  102.   jImageView1.SetImageBitmap(jBitmap1.GetBitmapFromByteBuffer(jGraphicsBuffer, w, h));
  103. end;
  104.  
  105. end.
  106.  
Thanks to All!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

 

TinyPortal © 2005-2018