Jump to content

Dave Nottage

Members
  • Content Count

    1449
  • Joined

  • Last visited

  • Days Won

    34

Everything posted by Dave Nottage

  1. Dave Nottage

    MACOS "setDesktopImageURL"

    This should be: Options := TNSMutableDictionary.Create; This should be: Options.setObject(TNSColor.OCClass.whiteColor, NSObjectToID(NSWorkspaceDesktopImageFillColorKey)); Since setObject takes pointer parameters, for both. The rest should follow the same rule. Incidentally, there's loads of examples of using an NSMutableDictionary in the Delphi source (as well as in Kastri)
  2. Dave Nottage

    MACOS "setDesktopImageURL"

    I did? 🙂 This code works for me: procedure SetDesktopBackground(const ImagePath: string; const FillColor: TAlphaColor); var NSFileURL: NSURL; NSWorkspace1: NSWorkspace; MainScreen: NSScreen; LPointer: Pointer; Error: NSError; begin try // Convert Delphi file path to NSURL NSFileURL := TNSURL.Wrap(TNSURL.OCClass.fileURLWithPath(StrToNSStr(ImagePath))); NSWorkspace1 := TNSWorkspace.Wrap(TNSWorkspace.OCClass.sharedWorkspace); MainScreen := TNSScreen.Wrap(TNSScreen.OCClass.mainScreen); LPointer := nil; // Set the desktop image for the main screen if not NSWorkspace1.setDesktopImageURL(NSFileURL, MainScreen, nil, @LPointer) then begin Error := TNSError.Wrap(LPointer); ShowMessage('Failed to set desktop image: ' + NSStrToStr(Error.localizedDescription)); end; except on E: Exception do begin ShowMessage('Error setting desktop image: ' + E.Message); end; end; end; If you're having trouble creating a dictionary for the options, please show what code you attempted.
  3. Dave Nottage

    Android short time format 24h/12h

    The method name is24HourFormat, not is24hourformat, and is also a static method, so the declaration should be: JDateFormatClass = interface(JObjectClass) ['{E9A75876-EDA1-44CE-B159-46BACF1805F7}'] {class} function is24HourFormat(context: JContext): Boolean; cdecl; end; [JavaSignature('android/text/format/DateFormat')] JDateFormat = interface(JObject) ['{65E305D7-04D6-4C33-8AB0-9FE366F3F24D}'] end; TJDateFormat = class(TJavaGenericImport<JDateFormatClass, JDateFormat>) end; ..and called like this: uses Androidapi.Helpers; procedure TForm1.FormCreate(Sender: TObject); begin if TJDateFormat.JavaClass.is24HourFormat(TAndroidHelper.Context) then // is 24 hour else // is 12 hour end; Note that I have not tested the code above - I am just going by the documentation (which I linked to)
  4. Dave Nottage

    Screen Brightness in iOS

    uses iOSapi.Helpers; function GetBrightness: Single; begin Result := TiOSHelper.MainScreen.brightness; end; procedure SetBrightness(const AValue: Single); begin if (AValue >= 0) and (AValue <= 1) then TiOSHelper.MainScreen.setBrightness(AValue); end;
  5. Dave Nottage

    PasZip.pas Issue.

    If it's the one from Mormot (which it seems to be, given your info), you should file an issue here.
  6. Dave Nottage

    Buying a mini pc to install Delphi

    Since Windows ARM can run x86 code, yes. Rosetta on Mac doesn't have anything to do with the above, as far as I know - that's just for whether Intel macOS apps would be able to run in the Mac host.
  7. Dave Nottage

    Buying a mini pc to install Delphi

    Parallels allows you to run Windows ARM VMs on M-series Macs
  8. Dave Nottage

    Android aidl error when using it.

    Good to hear, but does that mean it now compiles, or that your app is working also? 🙂
  9. Dave Nottage

    Android aidl error when using it.

    Yes - you can safely remove any declarations that have a signature that ends with $ and a number (and remove the corresponding xxxClass declarations), as these are anonymous inner classes.
  10. Dave Nottage

    Android aidl error when using it.

    The file printer.jar in the SDK appears to be a cut-down version (not sure why they provide it in the first place - it might be in error) of the one you actually need to use, which is inside printer-release.aar. If you have Delphi 12.2, you can add this file to the Libraries node under Android 32-bit target in Project Manager instead of printer.jar. This library includes the required methods of SrPrinter (e.g. getInstance), so you should be able to use this function to get an instance of it: uses Androidapi.Helpers; function SrPrinter: JSrPrinter; begin Result := TJSrPrinter.JavaClass.getInstance(TAndroidHelper.Context); end; ..and call the functions like they do in the Java examples, e.g.: SrPrinter.printQRCode(StringToJString('123456'), 4, 3); However you will need to first: Rename printer-release.aar to printer-release.zip Extract the classes.jar file from the .zip file Run Java2OP on the extracted classes.jar to recreate your JavaInterfaces.pas import.
  11. You need to do it this way, for example: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, System.Messaging, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private procedure MessageResultNotificationMessageHandler(const Sender: TObject; const M: TMessage); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; var Form1: TForm1; implementation {$R *.fmx} uses Androidapi.Helpers, Androidapi.JNI.App, Androidapi.JNI.GraphicsContentViewText; const cRequestCode = 1234; // Just a random number constructor TForm1.Create(AOwner: TComponent); begin inherited; TMessageManager.DefaultManager.SubscribeToMessage(TMessageResultNotification, MessageResultNotificationMessageHandler); end; destructor TForm1.Destroy; begin TMessageManager.DefaultManager.Unsubscribe(TMessageResultNotification, MessageResultNotificationMessageHandler); inherited; end; procedure TForm1.MessageResultNotificationMessageHandler(const Sender: TObject; const M: TMessage); var LMessage: TMessageResultNotification; begin LMessage := TMessageResultNotification(M); if LMessage.RequestCode = cRequestCode then begin if LMessage.ResultCode = TJActivity.JavaClass.RESULT_OK then begin // Here, handle the Intent that is the LMessage.Value property end; end; end; procedure TForm1.Button1Click(Sender: TObject); var LIntent: JIntent; begin LIntent := TJIntent.Create; LIntent.setAction(TJIntent.JavaClass.ACTION_PICK); LIntent.setType(StringToJString('image/*')); TAndroidHelper.Activity.startActivityForResult(LIntent, cRequestCode); end; end
  12. Dave Nottage

    Android aidl error when using it.

    I do not see the recieptservice.com.recieptservice.service.PrinterService class anywhere in the .jar file you attached. Did you compile the .jar yourself? Where is this example code?
  13. Dave Nottage

    Android aidl error when using it.

    Thanks. It appears you should use TJPrinterInterface_Default, rather than TJPrinterInterface.
  14. Dave Nottage

    Android aidl error when using it.

    Possibly, but it's hard to tell without access to the .jar. You have not answered this: If it is public, where can it be obtained from?
  15. Dave Nottage

    Android aidl error when using it.

    That's because you don't need to. Possibly - the Java signatures in that file look a bit odd. Is the .jar file available publicly?
  16. Is there some reason why you haven't included here what it suggested? You can access the ContentResolver via: TAndroidHelper.Context.getContentResolver, by including the Androidapi.Helpers unit. Regardless, I expect you'll need to use a library such as smbj to access files via Windows shares, which means either finding a Delphi implementation or creating imports and writing the code yourself that uses smbj (or some other library that does the same thing).
  17. Dave Nottage

    Request "Access All Files" Permission ?

    With this: uses Androidapi.JNI.Os; LHasAccess := TJEnvironment.JavaClass.isExternalStorageManager; Note that this applies from Android 11 onwards only, so you should use TOSVersion.Check(11) to determine whether or not to manage that permission
  18. Dave Nottage

    Android and services...

    As I mentioned in my first reply, you could use the code from TNotificationCenterAndroid.CreateNativeNotification as an example. Inside that is this: function GetDefaultIconID: Integer; begin Result := TAndroidHelper.GetResourceID('drawable/ic_notification'); if Result = 0 then Result := TAndroidHelper.Context.getApplicationInfo.icon; end;
  19. Dave Nottage

    Android and services...

    You'd need to create the notification using the underlying classes, since the notification implementation in Delphi is yet to support "sticky" notifications. You could use the code in the TNotificationCenterAndroid.CreateNativeNotification method in rtl\common\System.Android.Notification.pas as a guide, and use the setOngoing method to make it "sticky". It's not exactly clear from your post what else you need solved.
  20. Dave Nottage

    Android aidl error when using it.

    That usually means you have not added the required .jar file (the one you ran Java2OP on) to the project. In Project Manager: Expand the Android 32-bit target Right-click on Libraries Click Add.. Select the .jar file Click OK Note that the .jar will be compiled in regardless of whether you compile for 32-bit or 64-bit.
  21. Dave Nottage

    App does not start anymore on macOS Sequoia (due to sandbox restrictions?)

    Yes, it should be. My Mosco app is a signed and notarized app, and has these entitlements: It starts OK for me on macOS 15.1, but is built with Delphi 12.2. Not sure whether that might be relevant?
  22. Dave Nottage

    Android. FileUriExposedException: file:///

    It's: TJcontent_FileProvider instead.
  23. A client has well established products that are based around the MDI model, and are using the concept of "desktops" by hiding/showing MDI children so that the state of the forms is maintained. The concept of hiding MDI children is actually not officially supported in Delphi, so to work around this, ShowWindow is called thus: ShowWindow(FormHandle, SW_SHOW); // or ShowWindow(FormHandle, SW_HIDE); ..where FormHandle is the handle of the MDI child being shown/hidden. This worked well, up until Delphi 12, when the message handling for forms was reimplemented, using TChildFormMessageHandler (in Vcl.Forms). The new (undesired) behaviour is that once a child form has ShowWindow called on it, then that form becomes active, the last form that was hidden becomes visible again. This can be reproduced using the attached project by using the following steps: Run the app Click File | Show Desktop 1 Click File | Show Desktop 2 Click File | Show Desktop 1 again Set focus to the visible form - the form that "belongs" to Desktop 2 becomes visible again As described above, this works OK in Delphi 11.3. At this point, reimplementing the app away from MDI is a non-option. I'm aware that whatever measures are needed will be a "hacky" workaround - it started out that way anyway. Now for the kicker: this is a package-based application, so I can't even "hack" the Vcl.Forms source. Using a "detours"-like solution might be an option. Any help with how to resolve this would be greatly appreciated. MDIIssue.zip
  24. Dave Nottage

    12.3 or 13/14 as next?

    No mention of a 12.3, however in a webinar (I think the one for 12.2) they said 13 would not be skipped.
  25. Dave Nottage

    How to solve Android Content labeling issue in FMX?

    At the moment you can safely ignore the warning. At present, there's no "out of the box" solution for it. See my comment on this SO post. For what it's worth, it appears Flutter developers have (or at least did have) the same issue.
×