Recent

Author Topic: jView : how to ?  (Read 11600 times)

tintinux

  • Sr. Member
  • ****
  • Posts: 378
    • Gestinux
jView : how to ?
« on: April 26, 2016, 04:19:09 pm »
Hi

To try to show a small image on an AndroidModule, I used jView like this :

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jView1Draw(Sender: TObject; Canvas: jCanvas);
  2.  
  3. var
  4.   Bitmap : jBitmap;
  5.  
  6. begin
  7.   LogDebug('TEST2_DEBUG', 'jView1Draw BEGIN' );
  8.   Canvas.PaintColor:= colbrBlack;
  9.   Canvas.PaintStrokeWidth:= 3;
  10.   Canvas.drawLine(10,10,30,30);
  11.   // nothing visible if exit here
  12.   BitMap := jBitMap.Create(Self);
  13.   try
  14.     BitMap.LoadFromFile ('\Tablet\Download\Picture 3.png');
  15.     Canvas.drawBitmap( BitMap, 0,0, 100, 1 );
  16.   finally
  17.     BitMap.free;
  18.   end;
  19.   // nothing visible if exit here
  20.   LogDebug('TEST2_DEBUG', 'jView1Draw END' );
  21. end;  

I have added a jCanvas and linked the jView to it.
There is no error, but nothing is shown.
What am I missing ?

Something else : if I set any other color than colbrDefault, to jview1.backgroundColor  using the property editor, the application stops during jView1Draw and the log shows :
Code: [Select]
D/TEST2_DEBUG(29059): jView1Draw BEGIN

F/libc    (29059): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x550000 in tid 29059 (org.lamw.test2)

Thanks for help


PS : are they working examples of simple drawing with Android Bridges components ?
« Last Edit: May 19, 2016, 11:28:51 am by tintinux »
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2330
Re: jView : how to ?
« Reply #1 on: April 26, 2016, 07:43:45 pm »
---->>About jView and jCanvas use:

Yes, please try this "demos":

AppCameraDemo

and

AppDemo1 [see form/unit8.pas  and form/unit9.pas]


NOTE:

To use/test any demo App you will need:

1. configure the project ".lpi" to match your system... [NDK path ...]

2. configure "build.xml"  to match your system...  [SDK and target ...]
3. configure  "AndroidManifest.xml"  android:targetSdkVersion=??
   to match your  "build.xml"


4. Lazarus IDE --> Run --> "build"   [to produce the pascal jni ".so"]
5. Connect your Device-PC  via usb ...
6. Lazarus IDE --> Run --> "[Lamw] Build Android Apk and Run"



Thank you!

« Last Edit: May 04, 2016, 10:20:58 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

tintinux

  • Sr. Member
  • ****
  • Posts: 378
    • Gestinux
Re: jListView : how to ?
« Reply #2 on: April 27, 2016, 06:28:04 pm »
Hi

Thanks for your reply.

Unfortunately, the AppCameraDemo found in trunk doesn't compile.

Code: Pascal  [Select][+][-]
  1. unit1.pas(159,11) Error: identifier idents no member "Orientation"
  2.  
After I comment out the code,  it compiles...   but crashes at startup.

In logcat, I extracted 577 lines of Fatal Error... and didn't found the reason... 

Code: Pascal  [Select][+][-]
  1. F/art     (32151): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI CallIntMethod called with pending exception 'java.lang.NoSuchMethodError' thrown in void com.example.appcamerademo.Controls.pAppOnCreate(android.content.Context, android.widget.RelativeLayout):-2
  2.  
  3. F/art     (32151): art/runtime/check_jni.cc:65]     in call to CallIntMethod
  4.  
  5. F/art     (32151): art/runtime/check_jni.cc:65]     from void com.example.appcamerademo.Controls.pAppOnCreate(android.content.Context, android.widget.RelativeLayout)
  6.  
  7. F/art     (32151): art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
  8.  
  9. ....
  10.  
  11.  

And if I look into the source, event jView1Draw, I don't find any difference with my code...
Sure I'm blind....

Best regards
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2330
Re: jListView : how to ?
« Reply #3 on: April 27, 2016, 08:02:04 pm »
Hello!

About:
Quote
unit1.pas(159,11) Error: identifier idents no member "Orientation"

Sorry... the onRotate event changed the signature. Please,
empty  the   "onRotate" and  re-create it!

and put a jBitmap component on form! 

not  BitMap := jBitMap.Create(Self)  !!!


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

tintinux

  • Sr. Member
  • ****
  • Posts: 378
    • Gestinux
Re: jListView : how to ?
« Reply #4 on: April 28, 2016, 09:40:28 am »
Hi

The compilation error is in the OnJNIPrompt event procedure.

Emptying or recreating the OnRotate event procedure changes nothing, and same if emptying or re-creating OnJNIPrompt.

Best regards
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2330
Re: jListView : how to ?
« Reply #5 on: April 28, 2016, 07:07:59 pm »

Please, zip e send me your project:

unit1.pas , unit1.lfm and controls.lpr
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

tintinux

  • Sr. Member
  • ****
  • Posts: 378
    • Gestinux
Re: jListView : how to ?
« Reply #6 on: April 28, 2016, 08:14:27 pm »
Hi

As I said earlier it is AppCameraDemo found in LAMW trunk.

Regards
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2330
Re: jListView : how to ?
« Reply #7 on: April 30, 2016, 02:05:51 am »
Hello  tintinux!

OK. I am trying to fix the "AppCameraDemo"


EDITED:  Done!!!
« Last Edit: May 01, 2016, 07:16:34 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

tintinux

  • Sr. Member
  • ****
  • Posts: 378
    • Gestinux
Re: jListView : how to ?
« Reply #8 on: May 02, 2016, 09:51:06 am »
Hi

After update LAMW and reinstalling new revision of packages (including AppCameraDemo), I get this error :

Code: [Select]
Messages, Hints: 2
Note: Duplicate unit "controls" in "controls", orphaned ppu "C:\lamw\trunk\demos\Eclipse\AppCameraDemo\obj\controls\controls.o"
Note: Duplicate unit "controls" in "LCLBase 1.5", ppu="C:\lamw\laz4android\lcl\units\arm-android\controls.ppu", source="C:\lamw\laz4android\lcl\controls.pp"
Compile Project, OS: android, CPU: arm, Target: C:\lamw\trunk\demos\Eclipse\AppCameraDemo\libs\armeabi\libcontrols.so: Success, Hints: 7
unit1.pas(38,45) Hint: Parameter "Canvas" not used
unit1.pas(88,3) Note: Local variable "dir" not used
unit1.pas(32,30) Hint: Parameter "intentData" not used
unit1.pas(9,31) Hint: Unit "And_jni_Bridge" not used in unit1
unit1.pas(10,5) Hint: Unit "Laz_And_Controls_Events" not used in unit1
controls.lpr(1141,34) Hint: Parameter "reserved" not used
controls.lpr(1157,37) Hint: Parameter "reserved" not used
Building APK... : Exit code 1, Errors: 1
Buildfile: C:\lamw\trunk\demos\Eclipse\AppCameraDemo\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 24.4.1
 [checkenv] Installed at C:\lamw\android-sdk-windows

-setup:
     [echo] Project Name: AppCameraDemo
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 23.0.3
     [echo] Resolving Build Target for AppCameraDemo...
[gettarget] Project Target:   Android 4.2.2
[gettarget] API level:        17
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: C:\lamw\trunk\demos\Eclipse\AppCameraDemo\bin\res
    [mkdir] Created dir: C:\lamw\trunk\demos\Eclipse\AppCameraDemo\bin\rsObj
    [mkdir] Created dir: C:\lamw\trunk\demos\Eclipse\AppCameraDemo\bin\rsLibs
    [mkdir] Created dir: C:\lamw\trunk\demos\Eclipse\AppCameraDemo\bin\classes
    [mkdir] Created dir: C:\lamw\trunk\demos\Eclipse\AppCameraDemo\bin\dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for AppCameraDemo...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 4 source files to C:\lamw\trunk\demos\Eclipse\AppCameraDemo\bin\classes
    [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
    [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
    [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
    [javac] C:\lamw\trunk\demos\Eclipse\AppCameraDemo\src\com\example\appcamerademo\App.java:234: error: cannot find symbol
    [javac]         case KeyEvent.KEYCODE_BRIGHTNESS_DOWN:
    [javac]                      ^
    [javac]   symbol:   variable KEYCODE_BRIGHTNESS_DOWN
    [javac]   location: class KeyEvent
    [javac] C:\lamw\trunk\demos\Eclipse\AppCameraDemo\src\com\example\appcamerademo\App.java:238: error: cannot find symbol
    [javac]         case KeyEvent.KEYCODE_BRIGHTNESS_UP:
    [javac]                      ^
    [javac]   symbol:   variable KEYCODE_BRIGHTNESS_UP
    [javac]   location: class KeyEvent
    [javac] Note: C:\lamw\trunk\demos\Eclipse\AppCameraDemo\src\com\example\appcamerademo\Controls.java uses or overrides a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: C:\lamw\trunk\demos\Eclipse\AppCameraDemo\src\com\example\appcamerademo\Controls.java uses unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 2 errors
    [javac] 3 warnings

BUILD FAILED
C:\lamw\android-sdk-windows\tools\ant\build.xml:716: The following error occurred while executing this line:
C:\lamw\android-sdk-windows\tools\ant\build.xml:730: Compile failed; see the compiler error output for details.

Total time: 5 seconds
Panic: tool stopped with exit code 1. Use context menu to get more information.
Exception, Errors: 1
Fatal: [Exception] Failed: Cannot build APK!

Thanks for help !


Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2330
Re: jListView : how to ?
« Reply #9 on: May 02, 2016, 08:24:49 pm »

Hi!

the errors are here:

Quote
C:\lamw\trunk\demos\Eclipse\AppCameraDemo\src\com\example\appcamerademo\App.java:234: error: cannot find symbol

    [javac]         case KeyEvent.KEYCODE_BRIGHTNESS_DOWN:
    [javac]                      ^
    [javac]   symbol:   variable KEYCODE_BRIGHTNESS_DOWN
    [javac]   location: class KeyEvent

C:\lamw\trunk\demos\Eclipse\AppCameraDemo\src\com\example\appcamerademo\App.java:238: error: cannot find symbol

    [javac]         case KeyEvent.KEYCODE_BRIGHTNESS_UP:
    [javac]                      ^
    [javac]   symbol:   variable KEYCODE_BRIGHTNESS_UP
    [javac]   location: class KeyEvent

1. you could be compiling with an old sdk ....

2.  You can go to "App.java"  [...\src\...] and comment  these lines:

Quote
      /*
        case KeyEvent.KEYCODE_BRIGHTNESS_DOWN:
            controls.jAppOnKeyDown(c,keyCode,KeyEvent.keyCodeToString(keyCode));
            return true;
           
        case KeyEvent.KEYCODE_BRIGHTNESS_UP:
            controls.jAppOnKeyDown(c,keyCode,KeyEvent.keyCodeToString(keyCode));
            return true;
      */
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

tintinux

  • Sr. Member
  • ****
  • Posts: 378
    • Gestinux
Re: jListView : how to ?
« Reply #10 on: May 03, 2016, 10:00:02 am »
Hi

Yes, I use an old version of SDK (and other libraries), as specified in the installation wiki

If a newer works, I will upgrade, and then update the wiki : which one have you installed ?

Could you check also the other tools against your installation ?

Thanks
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2330
Re: jListView : how to ?
« Reply #11 on: May 03, 2016, 06:30:35 pm »
Hi!

Quote
    KeyEvent.KEYCODE_BRIGHTNESS_DOWN
    KeyEvent.KEYCODE_BRIGHTNESS_UP

Need android 4.3 [api 18]  ....

But go to Android 4.4 [api 19] !!!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

tintinux

  • Sr. Member
  • ****
  • Posts: 378
    • Gestinux
Re: jListView : how to ?
« Reply #12 on: May 04, 2016, 04:50:38 pm »
Hi jmpessoa !

Since you removed the java code to allow AppCameraDemo to work with API 17, I will upgrade later and save time...

In the latest svn version the button is hidden by the TextView, at least on small screens.

I have made small changes to fix this, and also to restore a good layout after 2 rotations (portrait -> landscape -> portrait). Modified sources are attached.

Best regards
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2330
Re: jView : how to ?
« Reply #13 on: May 04, 2016, 10:28:43 pm »


Ok. fixed!

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

tintinux

  • Sr. Member
  • ****
  • Posts: 378
    • Gestinux
Re: jView : how to ?
« Reply #14 on: May 19, 2016, 11:46:28 am »
Hi

I can draw on the Canvas of a JView, but I'd like to save the drawing in memory to be able to restore it partially later.

With the Windows or Linux Lazarus components (TPaintBox, TBitMap,...) I can do this easily with something like :

Code: Pascal  [Select][+][-]
  1.  // SourceBitMap and DestBitMap are 2 TBitMap instanciated and set to the same size
  2. SourceBitMap.Canvas.Draw ( 0, 0, DestBitMap );

How is this possible with LAMW jView ?

I have read about the Java technique, it requires to create a new Bitmap object and set it to the View.  This doesn't look possible with Lazarus components, or I do not find how.

Thanks for help.

PS : I found nothing in AppCameraDemo about this
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

 

TinyPortal © 2005-2018