Jump to content

ToddFrankson

Members
  • Content Count

    31
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ToddFrankson

  1. ToddFrankson

    MACOS "setDesktopImageURL"

    So I have the ability to set the MACOS wallpaper on the current screen using this code (I believe Dave Nottage posted it). procedure SetDesktopBackground(const ImagePath: string; const FillColor: TAlphaColor); var NSFileURL: NSURL; NSWorkspace1: NSWorkspace; MainScreen: NSScreen; 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); // Set the desktop image for the main screen if not NSWorkspace1.setDesktopImageURL(NSFileURL, MainScreen, nil, @Error) then begin 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; My problem has been the 3rd parameter in SetDesktopImageURL..... Evidently it takes an NSDictionary. I have spent 3 days attempting to get this part to work with various attempts at translating ObjectiveC and swift code, using my brain and even several AI coding websites. Nothing I seem to do actually builds the dictionary. Can anyone lend me a hand? I have managed to find the following constants (Not defined in Delphi BTW): const NSImageScaleNone = 0; NSImageScaleAxesIndependently = 1; NSImageScaleProportionallyUpOrDown = 2; NSImageScaleProportionallyDown = 3; Here's the Dictionary documentation : https://developer.apple.com/documentation/foundation/nsdictionary?language=objc And the Documentation on the keys in the dictionary(Defined in the constants above): https://developer.apple.com/documentation/appkit/nsworkspace/desktopimageoptionkey?language=objc Thanks If someone could help me understand this, so I can get past it, I'd appreciate it.
  2. ToddFrankson

    MACOS "setDesktopImageURL"

    I think you posted it....I may be mistaken. Here is 1 variation: procedure SetDesktopBackground(const ImagePath: string; const FillColor: TAlphaColor); var Err: NSError; Options: NSMutableDictionary; ImageURL: NSURL; FillColorObj: NSColor; begin // Convert the image file path to NSURL ImageURL := TNSURL.Wrap(TNSURL.OCClass.fileURLWithPath(NSStr(ImagePath))); if ImageURL = nil then begin Showmessage('Failed to create NSURL for the image file.'); Exit; end; // Create a dictionary for desktop image options Options := TNSMutableDictionary.Wrap(TNSMutableDictionary.OCClass.dictionary); // Set the desktop image fill color FillColorObj := TNSColor.Wrap(TNSColor.OCClass.colorWithCalibratedRed( TAlphaColorRec(FillColor).R / 255, TAlphaColorRec(FillColor).G / 255, TAlphaColorRec(FillColor).B / 255, TAlphaColorRec(FillColor).A / 255)); Options.setObject(FillColorObj, NSWorkspaceDesktopImageFillColorKey); // Set the desktop image scaling to none Options.setObject(TNSNumber.Wrap(TNSNumber.OCClass.numberWithInt(NSImageScaleProportionallyUpOrDown)), NSWorkspaceDesktopImageScalingKey); // Set the desktop image for the main screen if not TNSWorkspace.Wrap(TNSWorkspace.OCClass.sharedWorkspace).setDesktopImageURL(ImageURL, TNSScreen.Wrap(TNSScreen.OCClass.mainScreen), Options, @Err) then begin if Err <> nil then Writeln(Format('Error setting desktop background: %s', [NSStrToStr(Err.localizedDescription)])); end; end; It hangs here: Options.setObject(FillColorObj, NSWorkspaceDesktopImageFillColorKey); Here is another: procedure SetDesktopColor(const Color: TAlphaColor); var Err: NSError; Options: NSMutableDictionary; URL: NSURL; TempFile: string; begin // Create a temporary file path for the color image TempFile := TPath.Combine(TPath.GetTempPath, 'SolidColorDesktop.png'); // Create a solid color image CreateSolidColorImage(Color, TempFile); // Load the image as an NSURL URL := TNSURL.Wrap(TNSURL.OCClass.fileURLWithPath(NSStr(TempFile))); if URL = nil then begin Showmessage('Failed to create NSURL for the temporary file.'); Exit; end; // Create a mutable dictionary for desktop image options Options := TNSMutableDictionary.Wrap(TNSMutableDictionary.OCClass.dictionary); // Set the desktop image fill color (not used in this case) Options.setObject(TNSColor.Wrap(TNSColor.OCClass.whiteColor), NSWorkspaceDesktopImageFillColorKey); // Set the desktop image scaling Options.setObject(TNSNumber.Wrap(TNSNumber.OCClass.numberWithInt(NSImageScaleNone)), NSWorkspaceDesktopImageScalingKey); // Set the desktop image for the main screen if not TNSWorkspace.Wrap(TNSWorkspace.OCClass.sharedWorkspace).setDesktopImageURL(URL, TNSScreen.Wrap(TNSScreen.OCClass.mainScreen), Options, @Err) then begin if Err <> nil then Showmessage(Format('Error setting desktop color: %s', [NSStrToStr(Err.localizedDescription)])); end; end; I have tried using NSDictionary in place of NSMutableDictionary, and used the SetValue method. That gives me an Exception in the onButtonUp event deep in FMX code. I tried this to get the current settings: function GetCurrentDesktopImageOptions: TDictionary<string, string>; var Options: NSDictionary; KeyEnumerator: NSEnumerator; Key: Pointer; OptionKey: string; OptionValue: string; ResultDict: TDictionary<string, string>; begin ResultDict := TDictionary<string, string>.Create; try Options := TNSWorkspace.Wrap(TNSWorkspace.OCClass.sharedWorkspace) .desktopImageOptionsForScreen(TNSScreen.Wrap(TNSScreen.OCClass.mainScreen)); if Options <> nil then begin KeyEnumerator := Options.keyEnumerator; while True do begin Key := KeyEnumerator.nextObject; if Key = nil then Break; OptionKey := NSStrToStr(TNSString.Wrap(Key)); OptionValue := NSStrToStr(TNSString.Wrap(Options.objectForKey(Key))); ResultDict.Add(OptionKey, OptionValue); end; end; Result := ResultDict; except ResultDict.Free; raise; end; end; This returns absolutely nothing. What am I doing wrong? I'd love to pass the dictionary with the Scaled image, and background color in the dictionary. Apple documentation gives me a headache. I'm surprised I got this far.....
  3. ToddFrankson

    Looking for a certain component

    Explain how else you display a sum to the user, without displaying the data in a control This will be good to learn.
  4. ToddFrankson

    TRestRequest and IOS...

    Are there any Issues with TRestRequest and IOS? The following Code runs on Android, Windows 32bit & 64bit, and MacOS fine, but on IOS I get nothing in the TRestResponse contents: procedure TForm1.Button1Click(Sender: TObject); begin Memo1.lines.clear; TTask.run(Procedure Begin RestRequest1.execute; End).Start; end; And the RestRequest Handler- procedure TForm1.RESTRequest1AfterExecute(Sender: TCustomRESTRequest); begin Try Begin Accesstoken:=restresponse1.JSONValue.GetValue<string>('access_token'); Memo1.lines.add(Accesstoken); TDialogservice.showmessage('Access Token: ' + AccessToken); End; Except on E:Exception do TDialogservice.showmessage(E.message); End; end; Everytime I hit Accesstoken:=restresponse1.JSONValue.GetValue<string>('access_token'); the restresponse content is ''. But only on IOS. Anyone have ideas where to look? Maybe a property I need to set? I can post the form code if needed.
  5. ToddFrankson

    TRestRequest and IOS...

    And just like that, Response code of 0 with ZERO code changes. Even the Postman App on IOS fails following the instructions from the website. There's something fishy with REST and IOS
  6. ToddFrankson

    TRestRequest and IOS...

    Got it. It seems IOS had to have a slightly different URL............ The API provider needs better documentation. All is good in the universe again. Thanks for helping me brainstorm
  7. ToddFrankson

    TRestRequest and IOS...

    1-It should be, bu tit is not. Content=''.- Works on all platforms but IOS-I used the REST Debugger to generate the objects. 2-On all other platforms it is, but not on IOS 3- the response code is 0- i have been digging into the HTTPClient in the rest Request. It seems on IOS it's doing a handoff to the OS with a callback. Line 517-522 of System.Net.HTTPClient.mac is where it fails on IOS Emulator (So I can step through the code) LResponse.FDone := False; FDataTasks.AddTask(LRequest.FDataTask, LResponse); try LRequest.FDataTask.resume; while not LResponse.FDone do InternalWaitMessage(0.01); --> This procedure Located at 330-338: procedure InternalWaitMessage(AInterval: Single); var TimeoutDate: NSDate; begin TimeoutDate := TNSDate.Wrap(TNSDate.OCClass.dateWithTimeIntervalSinceNow(AInterval)); TNSRunLoop.Wrap(TNSRunLoop.OCClass.currentRunLoop).runMode(NSDefaultRunLoopMode, TimeoutDate); if TThread.CurrentThread.ThreadID <> MainThreadID then Sleep(Trunc(AInterval * 1000)); end; Lines 1309-on in System.Net.HTTPCLient is where the LResponse.Cancelled is set to true: if LRequest.FCancelled then----->Cancelled is false; Exit; LExecResult := DoExecuteRequest(LRequest, LResponse, AContentStream); if LRequest.FCancelled then--------------Cancelled is true Exit; case LExecResult of TExecutionResult.Success: ------>Status is success, but the exit above spits us out begin if not SameText(LRequest.FMethodString, sHTTPMethodHead) and (LResponse.FStream <> nil) then LResponse.DoReadData(LResponse.FStream); if LRequest.FCancelled then Exit; Status := LResponse.GetStatusCode;------------Status code is 200 but Cancelled set to true means we've exited case Status of 200: begin Break; end; 401: ...... And today I get an SSL error at line 529 of System.Net.HTTPClient.mac: else if LResponse.FError <> nil then-------------------------> raise ENetHTTPClientException.CreateResFmt(@SNetHttpClientErrorAccessing, [LResponse.FError.code, LRequest.FURL.ToString, NSStrToStr(LResponse.FError.localizedDescription)]) End;
  8. ToddFrankson

    How to generate aab file

    https://docwiki.embarcadero.com/RADStudio/Athens/en/Submitting_Your_Android_App_to_Google_Play#Android_App_Bundle_Support
  9. ToddFrankson

    TRestRequest and IOS...

    Same issue. That was where this started. procedure TForm1.Button1Click(Sender: TObject); begin RESTRequest1.AcceptEncoding := 'gzip, deflate, br'; Memo1.lines.clear; RestRequest1.ExecuteAsync(MyHandler,true,true,nil); end; procedure TForm1.myHandler; begin Try Accesstoken:=restresponse1.JSONValue.GetValue<string>('access_token'); Memo1.lines.add(Accesstoken); showmessage('Access Token: ' + AccessToken); Except on E:Exception do showmessage(E.message); End; When I tap button1 to fire RestRequest1.ExecuteAsync(MyHandler,true,true,nil); almost immediately I go right to Accesstoken:=restresponse1.JSONValue.GetValue<string>('access_token'); Then it hits the Exception, where Accesstoken is '', and never shows the error message.
  10. ToddFrankson

    TRestRequest and IOS...

    I tried that too, It works on all platforms except IOS. Thats what lead me to try this. It's like the RESTRequest1AfterExecute comes back before the request is completed
  11. ToddFrankson

    Android and services...

    I need some help in figuring out services.... I will be writing an app that needs to stay running, and every certain interval of time (at least 15 minutes or more-user configurable), open a file(in the apps folder) read it and then close the file(there's more to it but that is basics). I believe a foreground service is best, with it sticky, and start on boot.... I have those pieces. So the questions I have are the following: Like a weather app, I'd like it to stay in the Notification Panel at the top. How does that work? anyone have sample code? See the image.....How do I make my App stay like that in the notification panel, and then when the panel is "closed" it displays the current temperature. Has anyone done that in Delphi? I also will have the interface allowing to see the contents of the file the service opens, I believe I have some samples for that, but if it helps it will be a few configuration text items, and the UI will also open the same file, blocking the Service from doing so when the UI is launched. I believe I have that covered as well....
  12. ToddFrankson

    Android and services...

    Not necessarily solved. Just trying to understand the process.......... I've read that foreground services have some specific permissions that need to be requested, along with specific reasons why. I think I have a grasp on that now... As for the notifications, I can get that working by modifying your Kastri Demo Actually.....I used the JNotification_Builder and JNotificationManager to create the first Notification. For updates, I used the JNotificationCompat_Builder Still having issues getting the App Icon Using the following: var MainAppContext: JContext; AppIcon: Integer; Begin // Get the main application context by package name MainAppContext := TAndroidHelper.Context.getApplicationContext; // Fetch the application icon from the main application context AppIcon := MainAppContext.getPackageManager.getApplicationInfo( MainAppContext.getPackageName, 0).icon; ...... //other code related to building either the Notification_Builder or JNotificationCompat_Builder. .... End; The Icon is always a white box.
  13. So out of the box, the demo doesn't work for me. The first problem was the Read and Write External Storage permissions are deprecated. So, I changed the permissions to use the media files..... changed the line in the service from : LFileName := TPath.Combine(TPath.GetSharedDownloadsPath, LFileName); to LFileName := TPath.Combine(TPath.GetDocumentsPath, LFileName); in hopes it would work. Still nothing. This is my first pass at services, so I don't know diddly...... 1-Can I debug a service? I have tried but can't seem to make it happen. 2- Does the service and the App reside in the same "directory" on android, and have access to the same folders? I'm at a point where the app runs fine, but no notification comes from the server indicating the file downloaded, and the app never loads it....... Any one have 2 cents??
  14. Disregard.....Needed the Post notification permission
  15. ToddFrankson

    What new features would you like to see in Delphi 13?

    Dave, it would be best to have a private conversation regarding why. I actually have been thinking of reaching out to you.... I'll PM you.
  16. ToddFrankson

    What new features would you like to see in Delphi 13?

    While that is awesome, it should have been provided, and in the future, should be provided by the producer of the software. No one there ever thought, "I bet people will love installing 200+ addons one at a time, instead of a select a group and install...."
  17. ToddFrankson

    What new features would you like to see in Delphi 13?

    Android Auto built in Apple CarPlay Built In IOS Debugging (not on emulator) Ability to select multiple Getit Packages and install at once instead of having to select and install each one
  18. For some reason, the Android Service Demos don't work for me. I follow the instructions, and deploy fine, but the service never starts. Is there a "fix" or something I need to do? Embarcadero® Delphi 12 Version 29.0.51961.7529 12.1 patch
  19. ToddFrankson

    Mobile Zoom & Pan

    I have been looking into Zoom and Pan on mobile.... Almost every example I find involves zooming and panning an Image... Anyone have an example using a TVertScrollBox and the components on it?
  20. ToddFrankson

    Weird new IOS Issue-

    So, I have been working on a multi platform project, that has worked fine on Windows Android and IOS. IOS just updated to 17.5.1 The code works fine Prior to the update, but not after. I use TNetHttpClient to do a get of a web page. Prior to the Get, a Head returns just fine, to ensure internet access. I made a simple sample of the code. tap a button to initiate the Get and load the same page in a Twebbrowser. Can anyone text the attached code and tell me why the Get doesn't "get"? And why it works fine Prior to 17.5.1, and on all other platforms?? When the button is clicked, the Webbrowser browses the page, and the memo never gets filled. AndroidManifest.template.xml Entitlement.TemplateiOS.xml info.plist.TemplateiOS.xml Project1.deployproj Project1.dpr Project1.dproj Project1.dproj.local Project1.dsk Project1.identcache Project1.res Unit1.fmx Unit1.pas
  21. ToddFrankson

    Weird new IOS Issue-

    Yes, several files. Everytime I get a cannot write..... user doesn't have sufficient rights error, only displaying when I specifically show the error in a message. When I remove the try except, the file doesn't exist to open. I just spent the day on the main project, using message dialogs to find this out. I am now using temppath.
  22. ToddFrankson

    Weird new IOS Issue-

    Ios 17.5.1? 17.5 sdk?
  23. ToddFrankson

    Weird new IOS Issue-

    The failure Occurs in the code i posted with the Stringlist.SavetoFile. No ERROR PRESENTED. I had to wrap almost everything with message Dialogs to find the failure. I tried Assign /reset just on a whim . I have attached a new unit.pas. On line 92 & 93 put a URL you know you can get too. Unit1.pas
  24. ToddFrankson

    Weird new IOS Issue-

    So, I have figured out my problem. Please alter the code with a web page you can hit. It seems that IOS No longer likes Getdocumentspath....A Stringlist failed to write to it, using Assign and reset failed to open or read the file.... All in development mode. Can anyone check this?
  25. ToddFrankson

    Weird new IOS Issue-

    Can Anyone else get to this website https://gis.cravencountync.gov/images/activebookings.html ?
×