Recent

Author Topic: Android Module Wizard  (Read 710498 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Android Module Wizard
« Reply #495 on: June 19, 2015, 09:58:55 am »
@jmpessoa, I get the attached image (that "read error" dialog) everytime I close lazarus with lazandroidmodulewizard project opened. It's not a problem (I'm closing the IDE after all), but it's annoying.

This is what the log says:
Code: [Select]
NOTE: Window with stalled focus found!, faking focus-out event
[TJITComponentList.DestroyJITComponent] ERROR destroying component Error: Access violation
  Stack trace:
  $0000000001307E5D line 4539 of androidwidget.pas
  $00000000012FDEB8 line 2154 of androidwidget.pas
  $0000000000432022
  $0000000000A722FF line 753 of ../designer/jitforms.pp
  $0000000000A9DB7F line 584 of customformeditor.pp
  $0000000000A8974C line 668 of ../designer/designer.pp
  $0000000000D6C757 line 6719 of sourcefilemanager.pas
  $0000000000D54A19 line 2273 of sourcefilemanager.pas
  $0000000000D5CA3D line 3748 of sourcefilemanager.pas
  $00000000004BFCA8 line 6183 of main.pp
  $00000000004A5FEB line 1993 of main.pp
  $0000000000477B19 line 2171 of include/customform.inc
  $0000000000477851 line 2081 of include/customform.inc
  $0000000000477C8D line 2179 of include/customform.inc
  $0000000000432549
  $00000000006BC130 line 5342 of include/wincontrol.inc
  $0000000000474D33 line 1444 of include/customform.inc
TCustomFormEditor.JITListException List.CurReadStreamClass=nil nil
« Last Edit: June 19, 2015, 10:19:48 am by Leledumbo »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #496 on: June 19, 2015, 06:08:54 pm »

Yes,  you're right!  I also noticed that here in my system [Win] ... I'll try find fix this error...

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Android Module Wizard
« Reply #497 on: June 19, 2015, 07:48:42 pm »
One more thing, Lazarus freezes when I use Run->[Lamw] Build apk and run. It freezes when running adb with no emulator/real device running, my guess is that the external tool is not executed asynchronously. Tools that I add to Configure External Tools seem to execute asynchronously, though. Very weird.

A.S.

  • Jr. Member
  • **
  • Posts: 76
Re: Android Module Wizard
« Reply #498 on: June 19, 2015, 09:05:53 pm »
Leledumbo, Run->[Lamw] Build apk and run uses external tools for building/installing/running purposes. But it also determines connected devices, and this check is not asynchronous.

A.S.

  • Jr. Member
  • **
  • Posts: 76
Re: Android Module Wizard
« Reply #499 on: June 19, 2015, 09:20:32 pm »

Yes,  you're right!  I also noticed that here in my system [Win] ... I'll try find fix this error...

Thank you!

Please check. It seems, I fixed it.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #500 on: June 19, 2015, 11:03:36 pm »

@ A.S.

Quote
Please check. It seems, I fixed it.

Yes, now it's  ok!

Thank You!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

renabor

  • Jr. Member
  • **
  • Posts: 73
Re: Android Module Wizard
« Reply #501 on: June 21, 2015, 10:32:17 am »
......

And now some suggestions, requests and bugs:
  • Add the OnBack Event In jCustomDialog
  • The function JNIPrompt is not fired when a form is reactivated trough a Back in a second form, solution could be to add an OnComingBack event to jForm, or firing JNIPrompt event on coming back. At this time data displayed cannot be refreshed in automatic on coming back to first form
  • The jContextMenu cannot open a form
  • When a jContextMenu is linked to a jListView would very helpful that the Caption of the Item clicked where accessible or passed. My need is to edit or delete the record associated with the item clicked
  • jListView is lacking in configurability in order to display many columns of data. What do you think about adding Columns or  something like Tab to jListView?
  • Add an onClick event to jEditText, to make it possible, i.e., to open in automatic a jDatePickerDialog
  • Add an itxCurrency mask for jEditText that admits dot and comma with numbers together, or add dot and comma to itxNumber

Last request is partially resolved modifying in Controls.java (line 1436) :
Code: [Select]
        if(str.equals("NUMBER")) {
            this.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
        }
with
        if(str.equals("NUMBER")) {
            this.setInputType(InputType.TYPE_CLASS_NUMBER| InputType.TYPE_NUMBER_FLAG_DECIMAL|
                     InputType.TYPE_NUMBER_FLAG_SIGNED);
       }

that permits input of numbers [0..9], a minus sign prepended and a singular punctuation sign (only point, not comma)

Best regards
FPC 3.2.2 | Lazarus 2.2.3 | Kubuntu 22.04 64bit

renabor

  • Jr. Member
  • **
  • Posts: 73
Re: Android Module Wizard
« Reply #502 on: June 23, 2015, 12:17:08 pm »
@jmpessoa
For my purpose I need the Id of last inserted row, but my effort are unsuccessful.

I tried to add this method in Controls.java, related to class jSqliteCursor:
Code: [Select]
public long GetLastId() {
                if (this.cursor != null) {
                        int index = 0;
                        index = this.cursor.getColumnIndex("ROWID");
                        this.MoveToLast();
                        return this.GetValueAsLong(index);
        }
        else{
                return -1;
        }
}

this in Laz_and_controls:
Code: [Select]
function jSqliteCursor.GetLastId: integer;
begin
   if not FInitialized  then Exit;
   Result:= integer(jSqliteCursor_GetLastId(FjEnv, FjObject ));
end;     

and this in And_jni_Bridge:
Code: [Select]
Function jSqliteCursor_GetLastId(env:PJNIEnv;  SqliteCursor: jObject): integer;
var
 _jMethod : jMethodID = nil;
 cls: jClass;
begin
 cls := env^.GetObjectClass(env, SqliteCursor);
  _jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()I');
 Result := integer(env^.CallLongMethod(env,SqliteCursor,_jMethod));
 env^.DeleteLocalRef(env, cls);
end;

and the log report:

I/dalvikvm( 4112): java.lang.NoSuchMethodError: no method with name='GetLastId' signature='()I' in class Lcom/suevoz/borsa/jSqliteCursor;

so, where is the error? Can you help me?

thank you!

FPC 3.2.2 | Lazarus 2.2.3 | Kubuntu 22.04 64bit

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #503 on: June 23, 2015, 05:49:45 pm »
@renabor

OK, java/JNI 'long' signature is "J", then

Code: [Select]
_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()I');

change to:

Code: [Select]
_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()J');

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

renabor

  • Jr. Member
  • **
  • Posts: 73
Re: Android Module Wizard
« Reply #504 on: June 23, 2015, 06:38:37 pm »
@renabor

OK, java/JNI 'long' signature is "J", then

Code: [Select]
_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()I');

change to:

Code: [Select]
_jMethod:= env^.GetMethodID(env, cls, 'GetLastId', '()J');

Now the error is:

JNI WARNING: expected return type 'I'

 %)

FPC 3.2.2 | Lazarus 2.2.3 | Kubuntu 22.04 64bit

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #505 on: June 23, 2015, 06:46:42 pm »


Ok,  change all your pascal function result "integer" to int64 ....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #506 on: June 30, 2015, 09:57:25 pm »
Hi All!

There is a new  "Lamw" revision:
 
ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 31 - 30 June 2015 -

   NEW! jContactManager component [Partial support] // <<--- @renabor's request and suggestion!
      
      warning [need]:
      <uses-permission android:name="android.permission.READ_CONTACTS"/>
      <uses-permission android:name="android.permission.WRITE_CONTACTS"/>

   NEW! AppContactManagerDemo1
   NEW! AppContactManagerDemo2

   IMPROVEMENTS!   

          jCustomDialog component:         
         New! OnBackKeyPressed property event// <<--- @renabor's request and suggestion!

         UPDATED: Demo AppCustomDialogDemo1

          jEditText component:         
         New! OnClick property event // <<--- @renabor's request and suggestion!
         New! itxCurrency mask // <<--- @renabor's request and suggestion!

         UPDATED: AppEditTextDemo1
         
      jForm
         New! OnJNIPrompt event now fires when a form is reactivated trough a Backkeypressed!
         // <<--- @renabor's request and suggestion!    

         Fixed! jForms stack behaviour

         UPDATED: Demo AppTest1

   HINT 1: Old Projects: upgrade your projects code templates !
      Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!


Thanks to All and special thanks to @renabor !!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

m4u_hoahoctro

  • Full Member
  • ***
  • Posts: 160
Re: Android Module Wizard
« Reply #507 on: July 03, 2015, 05:15:20 pm »
@jmpessoa

How to create an applicaiton that can connect to a database on free hosting, read datas in database and save from tstringlist ? (theory all them is text only). Seems your demos doesn't mention about this.
thanks

renabor

  • Jr. Member
  • **
  • Posts: 73
Re: Android Module Wizard
« Reply #508 on: July 03, 2015, 06:46:25 pm »
@jmpessoa

Hi All!

There is a new  "Lamw" revision:
 
ref. https://github.com/jmpessoa/lazandroidmodulewizard

Version 0.6 - rev. 31 - 30 June 2015 -

   NEW! jContactManager component [Partial support] // <<--- @renabor's request and suggestion!
      
      warning [need]:
      <uses-permission android:name="android.permission.READ_CONTACTS"/>
      <uses-permission android:name="android.permission.WRITE_CONTACTS"/>

   NEW! AppContactManagerDemo1
   NEW! AppContactManagerDemo2

   IMPROVEMENTS!   

          jCustomDialog component:         
         New! OnBackKeyPressed property event// <<--- @renabor's request and suggestion!

         UPDATED: Demo AppCustomDialogDemo1

          jEditText component:         
         New! OnClick property event // <<--- @renabor's request and suggestion!
         New! itxCurrency mask // <<--- @renabor's request and suggestion!

         UPDATED: AppEditTextDemo1
         
      jForm
         New! OnJNIPrompt event now fires when a form is reactivated trough a Backkeypressed!
         // <<--- @renabor's request and suggestion!    

         Fixed! jForms stack behaviour

         UPDATED: Demo AppTest1

   HINT 1: Old Projects: upgrade your projects code templates !
      Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java]

   HINT 2:   When prompt "Read error" [Unknown Property] just choice "Continue Loading"!


Thanks to All and special thanks to @renabor !!

Thank you very much for all!

I've tried improvements and are all precious!
jContactManager is a must, although I have not tried it so much, I'm working on another project now.

the OnBackKeyPressed in CustomDialog property is great, but break the propagation of Event for soft backkey and del key, here an amended version that handle both soft and hard backkey press:
Code: [Select]
line ~ 10069 in Controls.java

mDialog.setOnKeyListener(new Dialog.OnKeyListener() {
@Override
  public  boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) {
     if (event.getAction() == KeyEvent.ACTION_UP) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
             controls.pOnCustomDialogBackKeyPressed(pascalObj, mTitle);
             if (mDialog != null) mDialog.dismiss();
             return false;
        } else if (keyCode == KeyEvent.KEYCODE_ENTER) {
            InputMethodManager imm = (InputMethodManager) controls.activity.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getWindowToken(), 0);
            controls.pOnEnter(pascalObj);
            return true;
        }
     }
     return false;
   }
});

Finally I've found a solution for my problem in obtaining the item index clicked out of jListView, here the code that add a listener to OnItemLongClick Event and add the property ItemIndex to jListView:
Code: [Select]
----- in  Laz_And_Controls.pas
line 1040
    function GetItemIndex: integer;
line 1083
    property ItemIndex: integer read GetItemIndex;
line 5120
    function jListView.GetItemIndex: integer;
    begin
      Result:= Self.Items.Count;
      if FInitialized then
        Result:= jListView_GetItemIndex(FjEnv, FjObject );
    end;

----- in  And_jni_Bridge.pas
line 485
  function jListView_GetItemIndex(env:PJNIEnv; ListView : jObject): integer;
line 3915
  function jListView_GetItemIndex(env:PJNIEnv;  ListView : jObject): integer;
  var
    _jMethod : jMethodID = nil;
    cls: jClass;
  begin
    cls := env^.GetObjectClass(env, ListView);
    _jMethod:= env^.GetMethodID(env, cls, 'GetItemIndex', '()I');
    Result:= env^.CallIntMethod(env,ListView,_jMethod);
    env^.DeleteLocalRef(env, cls);
  end;

------- in Controls.java
line 2785
  int itemIndex = -1;
line ~ 2887 
  itemIndex = position;
line ~ 2892
  onItemLongClickListener = new OnItemLongClickListener() {
    public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) {
      itemIndex = position;
      return false;
    }
  };
setOnItemLongClickListener(onItemLongClickListener);
line 2949
  public int GetItemIndex() {
    return itemIndex;
  }

Now I'm in trouble with jListView adapter, I'm trying to adapt this example

http://www.codelearn.org/android-tutorial/android-listview

any idea is really appreciated
FPC 3.2.2 | Lazarus 2.2.3 | Kubuntu 22.04 64bit

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: Android Module Wizard
« Reply #509 on: July 04, 2015, 12:12:58 am »
@renabor,

Quote
....I'm trying to adapt this example http://www.codelearn.org/android-tutorial/android-listview

The  jListView already support this possibility!

try this properties: widgetItem, widgetText, imageItem, ItemLayout,
 textDecoreted and textSizeDecoreted ...

Thank You!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

 

TinyPortal © 2005-2018