jView : how to ? lazarus / 43-Android ---------------------------------------------------------------------- tintinux · 2016-04-26 14:19 Hi To try to show a small image on an AndroidModule, I used jView like this : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.jView1Draw(Sender: TObject; Canvas: jCanvas); var  Bitmap : jBitmap; begin  LogDebug('TEST2_DEBUG', 'jView1Draw BEGIN' );  Canvas.PaintColor:= colbrBlack;  Canvas.PaintStrokeWidth:= 3;  Canvas.drawLine(10,10,30,30);  // nothing visible if exit here  BitMap := jBitMap.Create(Self);  try    BitMap.LoadFromFile ('\Tablet\Download\Picture 3.png');    Canvas.drawBitmap( BitMap, 0,0, 100, 1 );  finally    BitMap.free;  end;  // nothing visible if exit here  LogDebug('TEST2_DEBUG', 'jView1Draw END' );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 ? ---------------------------------------------------------------------- jmpessoa · 2016-04-26 17:43 ---->>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! ---------------------------------------------------------------------- tintinux · 2016-04-27 16:28 Hi Thanks for your reply. Unfortunately, the AppCameraDemo found in trunk doesn't compile. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit1.pas(159,11) Error: identifier idents no member "Orientation" 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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 F/art     (32151): art/runtime/check_jni.cc:65]     in call to CallIntMethod F/art     (32151): art/runtime/check_jni.cc:65]     from void com.example.appcam erademo.Controls.pAppOnCreate(android.content.Context, android.widget.RelativeLayout) F/art     (32151): art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable ....   And if I look into the source, event jView1Draw, I don't find any difference with my code... Sure I'm blind.... Best regards ---------------------------------------------------------------------- jmpessoa · 2016-04-27 18:02 Hello! About: Quoteunit1.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)  !!! ---------------------------------------------------------------------- tintinux · 2016-04-28 07:40 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 ---------------------------------------------------------------------- jmpessoa · 2016-04-28 17:07 Please, zip e send me your project: unit1.pas , unit1.lfm and controls.lpr ---------------------------------------------------------------------- tintinux · 2016-04-28 18:14 Hi As I said earlier it is AppCameraDemo found in LAMW trunk. Regards ---------------------------------------------------------------------- jmpessoa · 2016-04-30 00:05 Hello  tintinux! OK. I am trying to fix the "AppCameraDemo" EDITED:  Done!!! ---------------------------------------------------------------------- tintinux · 2016-05-02 07:51 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\ex ample\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\ex ample\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 ! ---------------------------------------------------------------------- jmpessoa · 2016-05-02 18:24 Hi! the errors are here: QuoteC:\lamw\trunk\demos\Eclipse\AppCameraDemo\src\com\example\appcame rademo\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\appcameradem o\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;       */ ---------------------------------------------------------------------- tintinux · 2016-05-03 08:00 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 ---------------------------------------------------------------------- jmpessoa · 2016-05-03 16:30 Hi! Quote    KeyEvent.KEYCODE_BRIGHTNESS_DOWN     KeyEvent.KEYCODE_BRIGHTNESS_UP Need android 4.3 [api 18]  .... But go to Android 4.4 [api 19] !!! ---------------------------------------------------------------------- tintinux · 2016-05-04 14:50 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 ---------------------------------------------------------------------- jmpessoa · 2016-05-04 20:28 Ok. fixed! Thank you! ---------------------------------------------------------------------- tintinux · 2016-05-19 09:46 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  // SourceBitMap and DestBitMap are 2 TBitMap instanciated and set to the same sizeSourceBitMap.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 ---------------------------------------------------------------------- jmpessoa · 2016-05-19 20:41 Hi tintinux! Quote... but I'd like to save the drawing in memory to be able to restore it partially later. Please, wait. I wil do some improvement in jView even today... Thank you! ---------------------------------------------------------------------- tintinux · 2016-05-20 13:34 Ok, I'm waiting  I have another question with jView : When I call jView.Invalidate  the OnDraw event is not called, except the first time. I found this hint but I don't find how to call the method Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i setWillNotDraw(false) from my code.  Maybe a public property should be made available (and it could be probably TRUE by default). Best regards ---------------------------------------------------------------------- jmpessoa · 2016-05-20 17:55 Hi tintinux! Quotein...validate  the OnDraw event is not called, except the first time. Ok. I will take care of it too ... and others [pm] issues.... Thank you! ---------------------------------------------------------------------- tintinux · 2016-05-27 15:42 Hi The new jDrawingView is simpler to use, and I can now obtain what I want ! I have however some questions and remarks : 1) Why is Canvas a parameter of the OnDraw event ? Nothing happens when we draw on this Canvas, we have to draw on the View only. It could sometimes be useful to have the Canvas of the View, but it could be obtained by something like : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TjDrawingView(Sender).Canvas  if the property Canvas was existing. I think there is no need for a parameter, which will give most times a "unused parameter" Hint. 2) The method JDrawingView.Invalidate exists, but it seems it does nothing. Refresh does the job. You could call Refresh from Invalidate, because it works like this, I believe, in LCL. Or else make Invalidate private or deprecated. Best regards