Recent

Author Topic: Android Module Wizard  (Read 710467 times)

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #285 on: February 15, 2015, 08:38:26 pm »
@rx3,

Great and nice work!

The demo need just GUI prototype... the math can be replaced by simple "ShowMessage"... So other people can learn to model a "Lamw" application.

Thank You.


« Last Edit: February 15, 2015, 09:02:16 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

rx3.fireproof

  • New Member
  • *
  • Posts: 49
Re: Android Module Wizard
« Reply #286 on: February 15, 2015, 09:38:07 pm »
Thank you for rating.
Prepare a Demo in  near future.
How to pass?     
Can download on sourceforge.net.

With Respect

rx3.fireproof
« Last Edit: February 15, 2015, 09:48:07 pm by rx3.fireproof »

rx3.fireproof

  • New Member
  • *
  • Posts: 49
Re: Android Module Wizard
« Reply #287 on: February 16, 2015, 11:08:47 pm »
Hello Jmpessoa


Did Demo.

Upload here with full version https://yadi.sk/d/MozLnxSpeieyu
Changed  previous link.
Use is on Your discretion.

With Respect

rx3.fireproof

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #288 on: February 18, 2015, 03:06:35 pm »
Hi rx3!  [and All  :D]

I tried attend some of his suggestions! So you can improve your nice project!

ref.  https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 15 - 17 February 2015 -

   MINOR IMPROVEMENTS:

   jApp:
      LOST properties: // <<--A suggestion and request by rx3.fireproof   
         Device.PhoneNumber
         Device.ID;
   jForm:
      NEWS methods:   
         .GetDevicePhoneNumber;
         .GetDeviceID;
         .[warning] "must have" [AndroidManifest.xml]:
            <uses-permission android:name="android.permission.READ_PHONE_STATE"/>         
   jTextView:
      NEW property: // <<--- Thanks to Fatih!      
         FontFace;

   jEditText:
      NEW properties: // <<--- Thanks to Fatih!      
         TextTypeFace;
         FontFace;
         Editable; <<-A suggestion and request by rx3.fireproof
   jSpinner:
      NEW properties:   <<-A suggestion and request by rx3.fireproof
         FontSize;
          Count;
   jHttpClient:
      NEWS methods: <<-A suggestion and request by Ps   
         .SetAuthenticationUser(...);        
         .SetAuthenticationHost(...);
      NEW property:   
         AuthenticationMode [just basic... yet]

   jWebView:
      NEW property: // <<--- Thanks to Fatih!   
         ZoomControl;   
      NEW method: <<-A suggestion and request by Ps
         SetHttpAuthUsernamePassword(...);
      
   jListView: FIXs [radio group mode]
      LOST property:   
         HighLightSelectedItem;
         ::Please, no panic! When prompt "Read error" [Unknown Property] just choice "Continue Loading"

Thanks!

P.S. [rx3:]

1. jSpinner: I added 3000 Items ... no problem! :-\
2. jEditText: OnEnter [just OnExit ... OnDone ... OnGo ]
 
« Last Edit: February 18, 2015, 11:41:02 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

ps

  • Full Member
  • ***
  • Posts: 136
    • CSS
Re: Android Module Wizard
« Reply #289 on: February 18, 2015, 09:28:07 pm »
Thank's for update and thank's for SetHttpAuthUsernamePassword  ;D

jHttpClient can be really hard to implement for real world situation I'm trying work with https. And this don't work easy in Android itself. Now I'm trying do something with okHttp (http://square.github.io/okhttp/). Problem is with self signed cert or with trusted cert but not supported with google.

Please look at TextHint property I requested. In Java code this.setHint("This will be hint when edit box is empty") this is very useful for search edi box and so on ...
Small simple CSS/box model implementation: https://github.com/pst2d/csscontrols/tree/dev

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #290 on: February 19, 2015, 01:47:40 am »
OK!

   jEditText:
      NEW property:
         HintTextColor; <<-A suggestion and request by Ps

Done!

P.S. [About HttpClient]
       You can try pure FPC/FCL  library ... !
« Last Edit: February 19, 2015, 01:54:37 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

rx3.fireproof

  • New Member
  • *
  • Posts: 49
Re: Android Module Wizard
« Reply #291 on: February 19, 2015, 01:52:01 am »
Hello Jmpessoa

Thanks for the update.
I used it in the Demo. New Demo upload on the link above.

I have a spinner does not work.
I put in new demo database with large fetching of data.
Database name "rx3char.db". The base is copied to data/data/ when you first start.

Use in the AndroidModule2 is commented out in the procedure «Add_size»  and «AndroidModule2JNIPrompt» .

To test it is necessary to disable rx3.db and connect rx3char.db.

For example:
When selecting item "ГОСТ 8239-89", app works. Count items = 17.
When selecting item "ГОСТ 26020-83", app crashes count items >100
When selecting "ASTM A 6/A 6M – 12»,  app crashes also count items >200.

«rx3char.db» with strings, but in this case I think it is not important.
Added DecimalSeparator:=','  for app to work.

Please see what is wrong I am doing.

Continue to develop Your module, there are some difficulties.
1. Z order does not work in the design. If the component should be at the bottom, it should be put last.  For example background image. Change Z order cannot be.
2. In jSqliteDataAccess1.GetValueAsFloat does not work for «real» at me. :)



With Respect

rx3.fireproof

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #292 on: February 19, 2015, 02:13:43 am »
Ok I will try it!

About order:
If you need jImageView to match all background form, then put it first in the form!
But, if you need any component in bottom just configure PosRelativeToParent = [rpBottom] ... do not need anchor

Abou "real" ... change/cast to "single" ... there is not "real" compatible to android!

About  “maxtextlengh =300” .... changed! now maxtextlengh = -1 [default : no limited!!!]

« Last Edit: February 19, 2015, 05:41:25 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Stephano

  • New Member
  • *
  • Posts: 32
Re: Android Module Wizard
« Reply #293 on: February 21, 2015, 08:40:12 pm »
Question 1:

Is there an easy way to create a simple android library (.so)?

Code: [Select]
library MyLibrary;
{$mode objfpc}{$H+}

function Add(a, b: integer): integer;
begin
  Result := a + b;
end;

exports
  Add name 'Java_Adder_Add';

begin
end.

Code: [Select]
package org.test.project1;

class Adder
{
  public native int Add(int a, int b);
  static
  {
    System.loadLibrary("mylibrary");
  }
}


QUestion 2:

How can we use the library from question 1 (.so without source code) in a LazAndroidModule project?
 case A: called from java code
 case B: called from pascal code

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Android Module Wizard
« Reply #294 on: February 22, 2015, 02:25:41 pm »
How can we use the library from question 1 (.so without source code) in a LazAndroidModule project?
 case A: called from java code
 case B: called from pascal code
case A:
You've had it in Question1 actually. Put the source in src directory, under correct package directory.
case B:
Put the lib in libs/<arch: armeabi, x86, mips, etc.> directory, you can call it from Pascal code in normal way to access dynamic library.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #295 on: February 22, 2015, 07:05:46 pm »
Hi Stephano, [and All!]

I tried to answer your questions! 
[yes, the Leledumbo pointed the right and direct way!]

Please, get a new revision: 

ref.  https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 18 - 22 February 2015 -

   ::Tutorial to Stephano Questions:

      1. Create a new "Lamw" project as usual [save all to ../jni]

      2. Add to ../src the new java class code [ex. jhelloadder.java]

      3. Go to [again] IDE->Project->New Project select [again] "JNI Android Module" Project
                   and [again] Select the same project [form workspace]

      4. But, NOW double click the added java class code [jhelloadder.java]

      5. Ok

      6. Save all new project to ../jni [warning: keep the project name [jhelloadder.lpr],
         but change the unit name :: ex. "unithelloadder.pas"]


      7. Yes, the new "jhelloadder.lpr" have the "drafts" code for all native methods!

         function Add(PEnv: PJNIEnv; this: JObject; _a: JInt; _b: JInt): JInt; cdecl;
         begin
             {your code....}
             {Result:= ;}
         end;

         function StringUpperCase(PEnv: PJNIEnv; this: JObject; _str: JString): JString; cdecl;
         begin
             {your code....}
             {Result:= ;}
         end;

      8. Yes, you have a new form [datamodule]: You can put there any "pure/fcl" TComponent descendant!
         [not LCL component, not Lamw component] --->> TODO: need more test

      9. Go to [again] IDE->Tools->Android Module Wizard->New jComponent [Create]

      10. Paste the "jhelloadder.java" into Tab "java" ...

                        WARNING: after paste, remove de word "public" from class definition!
                        [TODO: need fix the parse ...]
                                           
      11. Read the content of Tab "help" ... [follow the instructions!]

         Do not forget:

         //Please, you need insert:
            public java.lang.Object jHelloAdder_jCreate(long _Self) {
                    return (java.lang.Object)(new jHelloAdder(this,_Self));
               }
         //to end of "public class Controls" in "Controls.java"

      12. Open "tfpandroidbridge_pack.lpk --> More -> Recompile Clean -> Use -> Install !!
      13. Use Case 1: Pascal call Java :: drop the new component to jForm [main app] and use it!
      14. Use case 2. Java call Java   :: declare and use it! ex.:

         jHelloAdder helloadder;
         helloadder = new jHelloAdder(controls, 1010); //controsl=reference to main "controls" object :: 1010 = dummy
         Log.i("jHelloAdder_Add","Add(7,11)="+ helloadder.Add(7,11));

      15. Please,  see the new project demo ...   
      
   NEW! Demo AppAddSingleLibraryDemo1     [Eclipse Compatible Project]   


Thank you!

PS. Yes,  I will try a more simple [solution] library [no form at all!] just pure ".so"
« Last Edit: February 22, 2015, 09:04:59 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Stephano

  • New Member
  • *
  • Posts: 32
Re: Android Module Wizard
« Reply #296 on: February 22, 2015, 09:25:47 pm »
I have read very quickly Leledumbo's and your replies, and will read them more carefully and make tests tomorrow. But I guess your suggestions rely on the fact that the source code of the 1st library is available when it is not.

To make my case clearer, let's say somebody sends me a libcontrols1.so (produced using lawm) and I want to use it either with lawm (or some other tool). My question is how to use it with lawm and have:
a- the java code make the calls to libcontrols1.so
b- the pascal code make the calls to libcontrols1.so

tuntnguyen

  • Newbie
  • Posts: 2
Re: Android Module Wizard
« Reply #297 on: February 23, 2015, 05:13:55 am »
I have downloaded the lastest revision to reinstall lazandroidwizardpack.lpk
I still get this problem:

D:\laztoapk\lazandroidmodulewizard\androidwizard_intf.pas(179,15) Error: There is no method in an ancestor class to be overridden: "TAndroidWidgetMediator.GetObjInspNodeImageIndex(TPersistent,var LongInt);"

Code: [Select]
..
public
    // needed by TAndroidWidget
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure InvalidateRect(Sender: TObject; ARect: TRect; Erase: boolean);
    property AndroidForm: jForm read FAndroidForm;
  public
    procedure GetObjInspNodeImageIndex(APersistent: TPersistent; var AIndex: integer); override;
  end; 

How to fix this?
I am using Lazarus 1.2.6 and FPC 2.6.4
« Last Edit: February 23, 2015, 05:15:53 am by tuntnguyen »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #298 on: February 23, 2015, 06:20:16 am »
Hi tuntnguyen!

you need Lazaruss >= 1.3 and fpc >=2.7.1

The pratical solution [just for Windows]:

   -TrueTom [Laz4Android Package]

         Date:2014-10-18
         FPC: 2.7.1 SVN 28863  win32/arm-android/i386-android/jvm-android
         Lazarus:1.3 trunk svn 46592
         Android NDK: r10c (arm-linux-androideabi-4.6 + x86-4.6)
         http://sourceforge.net/projects/laz4android/files/?source=navbar
         :To Install, please, read the "Laz4Android_readme.txt"

For Linux, please read UP old posts.
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

rx3.fireproof

  • New Member
  • *
  • Posts: 49
Re: Android Module Wizard
« Reply #299 on: February 24, 2015, 11:30:26 am »
Hello Jmpessoa

I updated arxdemo.

There are some problems.

1. The main problem

The demo works, but if you add in Androidmodule2 two jedittext, app crashes.

It is possible to correct by moving the procedure «add_nd» from  AndroidModule2JNIPrompt in a separate thread ( the weak point adding in spinner).
Don't want to create a thread.
I temporarily used jtimer =>> jTimer1Timer.

I'm not a programmer, but this is some kind of conflict the execution speed of the code.  %)

Probably need an event after AndroidModule2JNIPrompt, for example onShow or onActivite or afteJNIPrompt.

   
2 jmagebtn properties ImageUpIndetifier and ImageDownIndetifier not work.
For graphical buttons I used jimageview+jtimer. Looks decent, if you don't know what is it made of. ;)

   
3 jlistview.
If the property HighLightSelectedItemColor not equal colbrDefault, there may be problems with the removal of the last items. If you delete items twice  at the end of the list, the app crashes.

4 above z-order
Add a jbutton in AndroidModule2 and place it in the area jimageview3. The button cannot be pressed, the button will be under jimageview3.
You can't change the Z-order when designing forms , only to remove components and add in the correct order.



Have questions.

1. This code does not work.

stringlist:=Tstringlist.create;
……
stringlist.free;
……..
if stringlist<>nil then begin
stringlist.free;
end;

How to check whether there is object stringlist?

2. How to use code to disable speller (red line) in jedittext (Androidmodule5 arxdemo).


With Respect

rx3.fireproof
« Last Edit: February 24, 2015, 09:44:40 pm by rx3.fireproof »

 

TinyPortal © 2005-2018