Jump to content

Chester Wilson

Members
  • Content Count

    30
  • Joined

  • Last visited

Community Reputation

5 Neutral

Technical Information

  • Delphi-Version
    Delphi 10.2 Tokyo

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Chester Wilson

    Scaley drawings

    Thanks, Sherlock. It works fine on windows with the scale set to 1 (the default), and I have no problem with that. It is with bloody android! I have put your code in, thanks - but I need to know what to include in the USES. I have found FMX.BehaviourManager, but cannot find where AService is defined (for DeviceBehavior), or how to define DisplayMetrics. Please would you mind filling in the gaps?
  2. Chester Wilson

    Scaley drawings

    I have a problem with image scale being different under android and under windows. I have tried to simplify this for Delphi Praxis. It started with trying to draw a black box around tEdit components on Android, so you can actually see them! On windows, the image.scale is left to the default (1,1). On android (at least on my phone), it has to be set to (0.31, 0.31) or the results are weird / awful. To duplicate it, make a new FMX project in a simple window. On the form place a tImage and 2 x tEdit (with some text in each). Use the code below, and put Resize into the Form.Resize in the object inspector. Run it on android and on windows and you should see the oddity. I do not know whether there may be something about using / not using high DPI on the android: ClientWidth x ClientHeight shows as 338 x 660, whereas the Samsung S22 is supposed to have a screen of 1080 x 2340, but I do not know how to access this. I will be interested in your ideas and findings please. unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.Edit, FMX.Memo.Types, FMX.ScrollBox, FMX.Memo, FMX.Objects; type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Image1: TImage; procedure FormResize(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: tForm1; implementation {$R *.fmx} procedure tForm1.FormResize(Sender: TObject); var Rect, e1Rect, e2Rect : tRectf; begin Image1.Position.X := 20; Image1.Position.Y := 30; Edit1.Position.X := 40; Edit1.Position.Y := 60; Edit2.Position.X := ClientWidth - Edit2.Width - 60; Edit2.Position.Y := 60; //Create rectangle positions for edit boxes with respect to the image. e1Rect := tRectf.Create( Edit1.Position.X - Image1.Position.X, Edit1.Position.Y - Image1.Position.Y, Edit1.Position.X - Image1.Position.X + Edit1.Width, Edit1.Position.Y - Image1.Position.Y + Edit1.Height); e2Rect := tRectf.Create( Edit2.Position.X - Image1.Position.X, Edit2.Position.Y - Image1.Position.Y, Edit2.Position.X - Image1.Position.X + Edit2.Width, Edit2.Position.Y - Image1.Position.Y + Edit2.Height); // --------------- Problem Area ------------------- //Need this for Android: Image1.Scale.X := 0.31; Image1.Scale.Y := 0.31; Image1.Height := 200 * 3; Image1.Width := 3 * (ClientWidth - 40); Image1.Bitmap.SetSize(round(Image1.Width), round(Image1.Height)); //Need this for Windows { Image1.Height := 200; Image1.Width := (ClientWidth - 40); Image1.Bitmap.SetSize(round(Image1.Width), round(Image1.Height)); } // ------------------------------------------------- Image1.Bitmap.Canvas.Stroke.Kind := tBrushKind.Solid; Image1.Bitmap.Canvas.Stroke.Color := tAlphaColorRec.Black; Image1.Bitmap.Canvas.Stroke.Thickness := 2; Image1.Bitmap.Canvas.BeginScene; //Colour the whole image first Image1.Bitmap.Canvas.Clear(tAlphaColorRec.Lightsalmon); //Now white out the bits where we want to place the edit boxes //Left one: Rect.Left := e1Rect.Left - 1; Rect.Right := e1Rect.Left + Edit1.Width + 1; Rect.Top := e1Rect.Top; Rect.Bottom := e1Rect.Top + Edit1.Height + 1; Image1.Bitmap.Canvas.ClearRect(Rect, tAlphaColorRec.Yellow); //Right one: Rect.Left := e2Rect.Left - 1; Rect.Right := e2Rect.Left + Edit2.Width + 1; Rect.Top := e2Rect.Top; Rect.Bottom := e2Rect.Top + Edit2.Height + 1; Image1.Bitmap.Canvas.ClearRect(Rect, tAlphaColorRec.Yellow); //Now draw the rectangles Rect.Left := e1Rect.Left - 1; Rect.Right := e1Rect.Left + Edit1.Width + 1; Rect.Top := e1Rect.Top - 1; Rect.Bottom := e1Rect.Top + Edit1.Height + 1; Image1.Bitmap.Canvas.DrawRect(Rect, 1); Rect.Left := e2Rect.Left - 1; Rect.Right := e2Rect.Left + Edit2.Width + 1; Rect.Top := e2Rect.Top - 1; Rect.Bottom := e2Rect.Top + Edit2.Height + 1; Image1.Bitmap.Canvas.DrawRect(Rect, 1); Image1.Bitmap.Canvas.EndScene; end; end.
  3. Chester Wilson

    Samsung S22 not showing in RAD 11

    Anyone else have problems getting a Samsung S22 to talk to Delphi 11? I have just put RAD 11 on, and got new samsung s22 phones, and can now do nothing! - Windows 11 - Developer mode - USB defaults to file transfer / android auto - Set for USB debugging when device plugged in to computer . . . and it worked initially (well, it was there, but I got a wedge of horrible bugs about looping or non-extant .dex files!) but now no matter what I do, the S22 fails to show up as an Android device target in Delphi. I have looked at every developer option, and can find nothing which makes it work. It is interesting that Delphi 10.3 and 10.4 bring up the S22 as a target, but not Delphi 11. Do I need some special drivers for Rad !!? I have installed Samsung-USB-Driver-v1.7.48.0.exe, to no avail.
  4. Chester Wilson

    android camera problem

    Found! On the Kastri page, you have to click on "Code" before you can Download. (Beats me, but it rhymes.) NOW I can start to get some understanding.
  5. Chester Wilson

    android camera problem

    Dear Everyone, More from the struggling department! Click on that Camera | Android Developers reference and you get taken to a deprecated page. I have looked at the Java Camera2 page - which is fine if you want to write in Java! Not so helpful if you can't get the Delphi basics sorted out (but yes, it would be very helpful after that.) I have tried to get the files from Github. It does not give me an option to download. I can look at each of the files in turn, select all the text, copy then paste into notepad then save with the correct filename. Messy - but there must be a better way (which I have not found yet). Any ideas please? In Androidapi.JNI.Hardware Delphi pseudo-interfaces are created, with what should ideally be class methods, but for syntactic reasons they are just methods. Unfortunately when you type something to reference one of these methods it will not let you. (If you write one yourself, does the UUID have to match something deep in the bowels of Java, or can you just generate your own UUID?) For example, trying to get the number of cameras available to decide which to open: i := JCameraClass.getNumberOfCameras; - can't find any getNumberOfCameras function. In fact, typing JCameraClass. gives none of the "Class" functions which should be available. What syntax should be used to get this to work please?
  6. Chester Wilson

    android camera problem

    All I want to do is take a bloody piccie! Here is the next episode - trying to use the definitions in Androidapi.JNI.Hardware. It crashed most effectively with non-explanatory error messages in both 10.3 and 10.4. It needs 2 buttons (ButtonPiccie and ButtonExit) and an Image. (Not sure if this is easier than trying to send the files, or more of a nuisance - please tell me!) unit TryCamera3MainUnit; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Memo.Types, FMX.Objects, FMX.StdCtrls, FMX.Controls.Presentation, FMX.ScrollBox, System.Permissions, FMX.Memo, Androidapi.JNI.JavaTypes, Androidapi.JNIBridge, Androidapi.JNI.Hardware, Androidapi.Helpers; type TForm1 = class(TForm) ButtonPiccie: TButton; Memo1: TMemo; ButtonExit: TButton; procedure FormCreate(Sender: TObject); procedure FormActivate(Sender: TObject); procedure ButtonPiccieClick(Sender: TObject); procedure RequestPermissionsResultProc( const aPermissions : System.TArray<string>; const aGrantResults : System.TArray<tPermissionStatus>); procedure ButtonExitClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; aPermissions : System.TArray<string>; aGrantResults : System.TArray<tPermissionStatus>; implementation {$R *.fmx} procedure TForm1.FormCreate(Sender: TObject); begin Memo1.Lines.Clear; end; procedure TForm1.FormActivate(Sender: TObject); begin aPermissions := ['android.permission.CAMERA']; PermissionsService.RequestPermissions( aPermissions, RequestPermissionsResultProc); end; procedure TForm1.ButtonExitClick(Sender: TObject); begin Application.Terminate; end; procedure tForm1.ButtonPiccieClick(Sender : tObject); var Cam : JCamera; h, w : integer; begin Cam := TJCamera.Create; //Crashes here Memo1.Lines.Add(JstringToString(Cam.toString)); Application.ProcessMessages; Cam.startPreview; //Originally crashed here h := Cam.getParameters.getPictureSize.height; w := Cam.getParameters.getPictureSize.width; Memo1.Lines.Clear; Memo1.Lines.Add('Height: ' + inttostr(h)); Memo1.Lines.Add('Width: ' + inttostr(w)); end; procedure tForm1.RequestPermissionsResultProc( const aPermissions : System.TArray<string>; const aGrantResults : System.TArray<tPermissionStatus>); var s : string; begin s := 'Unknown'; case aGrantResults[0] of tPermissionStatus.Granted: s := 'Granted'; tPermissionStatus.Denied: s := 'Denied'; tPermissionStatus.PermanentlyDenied: s := 'Permanently Denied'; end; Memo1.Lines.Add(aPermissions[0]); Memo1.Lines.Add(s); end; end.
  7. Chester Wilson

    android camera problem

    Thanks for your warnings, emaiilx45! No, I am not going to take my phone back to a7 - and nor would the other users of the programme. It is interesting that Dave Nottage, to whom I sent the latest version of the programme, had no trouble running it under 10.3.3. I tried it with 10.3.3 on m computer and still got the same error message. My android seems to be 25.2.5. Could that be a problem? Otherwise my option seems to be getting / writing a java wrapper for camera2 - which looks pretty daunting!
  8. Chester Wilson

    android camera problem

    Thanks for your response, emailx45! I was trying to simplify it down to a minimalist programme to hone in on where the error may be coming from. I do not need to send any rationale to the user. The system box requesting permission is quite, quite enough! The RequestPermissions is sending me the correct information - ie that the programme has been granted CAMERA permission, and it works without any problems. The problem is in the next bit, where I try to access the camera. The error message comes after either the TakePhoto() or the TakePhotoFromCameraAction1.Execute Dave Nottage suggested that I had to get camera permissions first. I have done that successfully (well, the RequestPermissions returned .Granted, so I assume that means all is well), but the same error message persists, and I would love to be able to get rid of it. My apologies if my pascal reads like programming by a Fortran programmer! As I have nobody else for 1000km whom I know of to interact Delphi programming with, I am stuck with my background.
  9. Chester Wilson

    android camera problem

    Well, fellas, thanks for your ideas. I can request required permissions now, and get some of them! (Why it won't give me WAKE_LOCK I know not. Reasonable not to give me ELEPHANT though!) The location one still comes up with the annoyance of "only while active". I am not sure that the argument about a tracking predator is good enough to bugger it up for everyone, especially as a tracking predator would have to get hold of the victim's phone and set it all up. However, it really buggers up my job of tracking small furry mammals in the middle of Australia! I could not find anything explanatory in the suggested reading on certificates, how to use them, where to get them, and what they may be capable of doing for this problem. Unfortunately, I have had no luck with the camera stuff. I have taken your ideas, and other ideas from the net, and put together two means of accessing the camera. Neither of them works, and they still prang with the extremely unhelpful message of : "java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager,java.lang.String)' on a null object reference." The sample files are attached in a single .zip. I would greatly appreciate any ideas, as the various delphi help facilities and the net have been no help at all! Permissions.zip
  10. Chester Wilson

    android camera problem

    Sorry, EmailX45! I will accept the "hug" at the bottom of your email as a friendly "man hug" and call you by your preferred name! The problem is that the later versions of android will only allow you in the "Settings" for a programme to have location as either deniet or "Only while app is in use"! It seems to be part of their idea that some permissions are regarded as "dangerous", and therefore are limited in their availability. Unfortunately I need to be able to continue tracking (small furry animals in remote areas of Australia) without interruption - and I cannot find out how to get android to cooperate!!!! i go to another app briefly, and the GPS gets turned off my tracking programme! This is a real problem, and I would like to get a useful answer to it. Any idea whom I should ask?
  11. Chester Wilson

    android camera problem

    Have you any idea how to get location permission not only for when the programme is the primary one on the screen, but always? In earlier androids I could continue tracking, go off an do something else briefly, then return to the tracking programme. In recent androids this turns off the location to the tracking programme, really messing up the data collection! (Why they think location is a dangerous privilege I do not know. The only time I can see it being dangerous is if I am going somewhere where my wife does not want me to go, and she finds out about it!)
  12. Chester Wilson

    android camera problem

    Thanks, hug! I will tackle it over the next few days. Even if the permissions for a programme have been set in "Settings" on an android device, and set up in the programme (project/options etc), is it still necessary to go through all the code for the permissions in the programme as well? Or is that so that the user can get an error message telling him which permissions have not been set?
  13. Chester Wilson

    android camera problem

    I am having great difficulty getting a firemonkey programme to take piccies on an android device. This is the simplest programme I have managed to put together for this. It keeps blowing up no matter what I try! (I have put 3 full days work into it, with no success, and now seek help!) I am using Delphi in Embarcadero® RAD Studio 10.4 Version 27.0.37889.9797 (it will be a month before I can get home to download Sydney). The phone I am working on is a Huawei P20 Pro with android 10 (can I have android 7 back please?????) I got Marco's GitHub main form for a camera, and got the same error from it. I wondered if it were a Delphi bug, and sent it off to Quality.Embarcadero. Dave Nottage kindly replied, telling me to set the permissions. However, if the permissions are not set, the error message is different, and setting the permissions did not help. I sent back that Dave's considered response did not help any, but have heard nothing since. It is necessary to run it once, then go and set up the android settings permissions since android have become cripplingly paranoid from V10. The error message is: Project TryCamera1.spk raised exception class EJNIException with message 'java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData (android.content.pm.PackageManager, java.lang.String)' on a null object reference'. The crash comes on ExecuteTarget in FMX.MediaLibrary.Action where it is called with FCameraService.TakePhoto TryCamera1.dpr TryCamera1.dproj TryCamera1.dproj.local TryCamera1.identcache TryCamera1.res TryCameraMainUnit.fmx TryCameraMainUnit.pas TryCameraMainUnit1.fmx TryCameraMainUnit1.pas
  14. Chester Wilson

    Present status of Indy

    Thanks, Remy. Tim Frost has kindly found Indy Help under Delphi/Help/Third Party Help. I had finally found a 2012 PDF Delphi in Depth, but the new one on the system is very nice - many thanks, Tim!
  15. Chester Wilson

    GDB server problems in 10.4

    Love your bug! The problem fixed itself after a couple of days, and has not recurred.
×