Jump to content

vfbb

Members
  • Content Count

    72
  • Joined

  • Last visited

  • Days Won

    7

vfbb last won the day on June 6

vfbb had the most liked content!

Community Reputation

39 Excellent

Technical Information

  • Delphi-Version
    Delphi 10.3 Rio

Recent Profile Visitors

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

  1. vfbb

    Your RAD Studio 10.4 Sydney issues

    One more issue: memory leak using inline variables (just arc types, like strings, arrays and interfaces) + anonymous method. Ex: procedure TForm1.FormCreate(Sender: TObject); begin var S: string := 'Test leak'; TThread.Queue(nil, procedure() begin Showmessage(S); end); end; The report:
  2. vfbb

    10.3/10.4 Debug iOS?

    It may not be your problem but I have to inform there is a very common bug with the iOS in 10.3 (not sure in 10.4), that the break points marked is pointing to an wrong line (usually 4~5 lines before or after) from the break point marked by you. It is very common for me to mark within the scope of a method but internally delphi marked on another line that is outside the scope of the method, and when you compile your breakpoint is marked as invalid. In this case I put several breakpoints in sequence, close to the method I want.
  3. vfbb

    ZXing Delphi for 10.4

    @MikeMon I forgot that in Delphi Rio there was a bug in the android permissions and I noticed that it is still in Delphi Sydney. You have to fix the FMX.Platform.Android.pas procedure TFMXNativeActivityListener.onRequestPermissionsResult(ARequestCode: Integer; APermissions: TJavaObjectArray<JString>; AGrantResults: TJavaArray<Integer>); // ----------------------------------------------------------------------------- // [iPub - github.com/viniciusfbb] - 28/05/2020 - Delphi 10.4 // The delphi messages system isn't thread-safe and this request result can be // called in background threads {$IFDEF DELPHI_FIXES} // ------------------------------------------------------- begin TThread.Queue(nil, procedure() var MsgData: TPermissionsRequestResultData; Msg: TPermissionsRequestResultMessage; begin MsgData.RequestCode := ARequestCode; MsgData.Permissions := APermissions; MsgData.GrantResults := AGrantResults; Msg := TPermissionsRequestResultMessage.Create(MsgData); TMessageManager.DefaultManager.SendMessage(nil, Msg); end); {$ELSE} // --------------------------------------------------------------------- var MsgData: TPermissionsRequestResultData; Msg: TPermissionsRequestResultMessage; begin MsgData.RequestCode := ARequestCode; MsgData.Permissions := APermissions; MsgData.GrantResults := AGrantResults; Msg := TPermissionsRequestResultMessage.Create(MsgData); TMessageManager.DefaultManager.SendMessage(nil, Msg); {$ENDIF} // -------------------------------------------------------------------- end;
  4. The Apple will remove the apps without storyboard or will not allow new updates without storyboard?
  5. vfbb

    ZXing Delphi for 10.4

    @MikeMon Today I don't have an android device to check it, but first I would check 2 things in andoird: 1) the Porject Options > Uses Permission > Camera = true. 2) Test if the "TFormMain.AccessCameraPermissionRequestResult" is executing in the main thread with LIsMainThread := TThread.Current.ThreadID = MainThreadID; About Delphi 10.3.3 I do not use anymore and the code of iOS that I posted will work only in 10.4 because the iOSapi.AVFoundation.pas of the 10.3.3 not have the apis of media permission.
  6. vfbb

    Chatbots on whatsapp. Freeware.

    The most common component of the city Recife-Brazil in the internet. @Mike Lustosa Would be better if you create a second readme in english
  7. vfbb

    ZXing Delphi for 10.4

    Mike, the "PermissionsService .RequestPermissions" works only in Android, in others platforms it have not been implemented, will simple skip. The code I gave you will work perfectly, but I think you are having trouble adapting it. So I simplified things for you: {$IFDEF iOS} type TipPermissionStatusProc = reference to procedure(AStatus: TPermissionStatus); { TipiOSUtils } TipiOSUtils = class private type { IipRequestCameraPermissionDelegate } IipRequestCameraPermissionDelegate = interface(IipInterface) procedure RequestAccessResult(AAuthorized: Boolean); end; { TipRequestCameraPermissionDelegate } TipRequestCameraPermissionDelegate = class(TipInterfacedObject, IipRequestCameraPermissionDelegate) private FStatusProc: TipPermissionStatusProc; public constructor Create(AStatusProc: TipPermissionStatusProc); procedure RequestAccessResult(AAuthorized: Boolean); end; end; uses System.Classes, FMX.Dialogs, iOSapi.AVFoundation; { TipiOSUtils.TipRequestCameraPermissionDelegate } constructor TipiOSUtils.TipRequestCameraPermissionDelegate.Create( AStatusProc: TipPermissionStatusProc); begin inherited Create; FStatusProc := AStatusProc; end; procedure TipiOSUtils.TipRequestCameraPermissionDelegate.requestAccessResult( AAuthorized: Boolean); begin if AAuthorized then FStatusProc(TPermissionStatus.Granted) else FStatusProc(TPermissionStatus.Denied); end; { TipiOSUtils } class procedure TipiOSUtils.RequestAccessResult(AAuthorized: Boolean); begin TThread.Queue(nil, procedure() var LRequestCameraPermissionDelegate: IipRequestCameraPermissionDelegate; begin LRequestCameraPermissionDelegate := FRequestCameraPermissionDelegate; FRequestCameraPermissionDelegate := nil; if Assigned(LRequestCameraPermissionDelegate) then LRequestCameraPermissionDelegate.RequestAccessResult(AAuthorized); end); end; procedure TipiOSUtils.RequestCameraPermission(AStatusProc: TipPermissionStatusProc); begin case TAVCaptureDevice.OCClass.authorizationStatusForMediaType(AVMediaTypeVideo) of AVAuthorizationStatusNotDetermined: begin FRequestCameraPermissionDelegate := TipRequestCameraPermissionDelegate.Create(AStatusProc); TAVCaptureDevice.OCClass.requestAccessForMediaType(AVMediaTypeVideo, RequestAccessResult); end; AVAuthorizationStatusDenied: AStatusProc(TPermissionStatus.Denied); AVAuthorizationStatusAuthorized: AStatusProc(TPermissionStatus.Granted); AVAuthorizationStatusRestricted: AStatusProc(TPermissionStatus.PermanentlyDenied); else AStatusProc(TPermissionStatus.Denied); end; end; {$ENDIF} And to use, replace your TFormMain.FormActivate by this: {$IFDEF iOS} var LiOSUtils: TipiOSUtils.Create; {$ENDIF} procedure TFormMain.FormActivate(Sender: TObject); begin {$IFDEF ANDROID} FPermissionCamera := JStringToString(TJManifest_permission.JavaClass.CAMERA); PermissionsService.RequestPermissions([FPermissionCamera], AccessCameraPermissionRequestResult, DisplayRationale); {$ELSEIF defined(iOS)} LiOSUtils: TipiOSUtils.Create; LiOSUtils.RequestCameraPermission( procedure(AStatus: TPermissionStatus) begin if AStatus = TPermissionStatus.Granted then CreateCamera() else Showmessage('You need to enable the Camera permission in system Settings. Please go to the Settings > MyApp > enable Camera.'); end); {$ENDIF} end; Note: To test the permission you need to unistall your app before compile.
  8. vfbb

    ZXing Delphi for 10.4

    What I doing? If the status is not determined (first time) I request the access (you can request just if the status is not determined). If is denied I simple show a message informing to go to the Settings and enable the permission manually (all aps do this, example: Telegram).
  9. vfbb

    ZXing Delphi for 10.4

    Mike, but the ZXing don't ask the permission. You need to do this by your self. I don't know why it is working for you in 10.3, probably the TCamera did it internally. I can't send you my entire code, but you will understand how it works by seeing part of the code: TipiOSUtils = class(TipFMXUtils, IipiOSUtils) private type { IipRequestCameraPermissionDelegate } IipRequestCameraPermissionDelegate = interface(IipInterface) procedure RequestAccessResult(AAuthorized: Boolean); end; { TipRequestCameraPermissionDelegate } TipRequestCameraPermissionDelegate = class(TipInterfacedObject, IipRequestCameraPermissionDelegate) private FStatusProc: TipPermissionStatusProc; public constructor Create(AStatusProc: TipPermissionStatusProc); procedure RequestAccessResult(AAuthorized: Boolean); end; {$IFDEF DELPHI_FIXES} private class var FCurrentAlert: UIAlertController; FRequestCameraPermissionDelegate: IipRequestCameraPermissionDelegate; class procedure AlertCancel(AAction: UIAlertAction); class procedure AlertSettings(AAction: UIAlertAction); class procedure RequestAccessResult(AAuthorized: Boolean); {$ENDIF} // .... {$IFDEF DELPHI_FIXES} class procedure TipiOSUtils.AlertCancel(AAction: UIAlertAction); var LRequestCameraPermissionDelegate: IipRequestCameraPermissionDelegate; begin LRequestCameraPermissionDelegate := FRequestCameraPermissionDelegate; FRequestCameraPermissionDelegate := nil; if Assigned(LRequestCameraPermissionDelegate) then LRequestCameraPermissionDelegate.RequestAccessResult(False); end; class procedure TipiOSUtils.AlertSettings(AAction: UIAlertAction); var LRequestCameraPermissionDelegate: IipRequestCameraPermissionDelegate; begin GiOSUtils.OpenAppSettings; LRequestCameraPermissionDelegate := FRequestCameraPermissionDelegate; FRequestCameraPermissionDelegate := nil; if Assigned(LRequestCameraPermissionDelegate) then LRequestCameraPermissionDelegate.RequestAccessResult(False); end; {$ENDIF} {$IFDEF DELPHI_FIXES} class procedure TipiOSUtils.RequestAccessResult(AAuthorized: Boolean); begin TipTask.Queue( procedure() var LRequestCameraPermissionDelegate: IipRequestCameraPermissionDelegate; begin LRequestCameraPermissionDelegate := FRequestCameraPermissionDelegate; FRequestCameraPermissionDelegate := nil; if Assigned(LRequestCameraPermissionDelegate) then LRequestCameraPermissionDelegate.RequestAccessResult(AAuthorized); end); end; {$ENDIF} procedure TipiOSUtils.RequestCameraPermission(const ADescription: string; AStatusProc: TipPermissionStatusProc); {$IFDEF DELPHI_FIXES} var LCancelAction: UIAlertAction; LWindow: UIWindow; {$ENDIF} begin if not Assigned(AStatusProc) then Exit; {$IFDEF DELPHI_FIXES} case TAVCaptureDevice.OCClass.authorizationStatusForMediaType(AVMediaTypeVideo) of AVAuthorizationStatusNotDetermined: begin FRequestCameraPermissionDelegate := TipRequestCameraPermissionDelegate.Create(AStatusProc); TAVCaptureDevice.OCClass.requestAccessForMediaType(AVMediaTypeVideo, RequestAccessResult); end; AVAuthorizationStatusDenied: begin LWindow := TiOSHelper.SharedApplication.keyWindow; if (LWindow = nil) or (LWindow.rootViewController = nil) then begin AStatusProc(TPermissionStatus.Denied); Exit; end; FRequestCameraPermissionDelegate := TipRequestCameraPermissionDelegate.Create(AStatusProc); FCurrentAlert := TUIAlertController.Wrap(TUIAlertController.OCClass.alertControllerWithTitle( StrToNSStr(FMXLanguage.GetPermissionTitle), StrToNSStr(ADescription + #13#10 + FMXLanguage.GetiOSPermissionMessageText), UIAlertControllerStyleAlert )); FCurrentAlert.addAction(TUIAlertAction.Wrap(TUIAlertAction.OCClass.actionWithTitle(StrToNSStr(FMXLanguage.GetPermissionSettingsButtonText), UIAlertActionStyleDefault, AlertSettings))); LCancelAction := TUIAlertAction.Wrap(TUIAlertAction.OCClass.actionWithTitle(StrToNSStr(FMXLanguage.GetPermissionCancelButtonText), UIAlertActionStyleCancel, AlertCancel)); FCurrentAlert.addAction(LCancelAction); FCurrentAlert.setPreferredAction(LCancelAction); LWindow.rootViewController.presentViewController(FCurrentAlert, True, nil); end; AVAuthorizationStatusAuthorized: AStatusProc(TPermissionStatus.Granted); AVAuthorizationStatusRestricted: AStatusProc(TPermissionStatus.PermanentlyDenied); else AStatusProc(TPermissionStatus.Denied); end; {$ELSE} AStatusProc(TPermissionStatus.Denied); {$ENDIF} end;
  10. vfbb

    ZXing Delphi for 10.4

    Ok, but the permission will be show just at first time. If your user negate the permission once, he will need to give the permission manually at the Settings of the iOS. In iOS go to the Settings > Your App > enable Camera, and try again
  11. vfbb

    ZXing Delphi for 10.4

    Mike, if your notebook/desktop have a webcam test in windows. Your problem on mobile can be related to the permission to have access to the camera and not in relation to the ZXing code. Here I use it only in windows, and with Delphi 10.4 is working fine.
  12. vfbb

    Your RAD Studio 10.4 Sydney issues

    I found the workaround! Add the WebKit framework to your iOS SDK and update the local file cache. After, in the unit source\rtl\ios\iOSapi.WebKit.pas in the line: var WebKitModule: THandle; {$ENDIF} Change to var WebKitModule: THandle; {$ELSE} {$IF NOT DECLARED(_PU)} const {$IFDEF UNDERSCOREIMPORTNAME} _PU = '_'; {$ELSE} _PU = ''; {$ENDIF} {$EXTERNALSYM _PU} {$ENDIF} procedure EmbedFramework; cdecl; external libWebKit name _PU + 'OBJC_CLASS$_WKWebView'; {$ENDIF}
  13. vfbb

    Your RAD Studio 10.4 Sydney issues

    The TWebBrowser.Create is crashing in the iOS. To test just add a TWebBrowser to the form and compile. The exception is raising in the FMX.WebBrowser.Delegate.iOS.pas in TNativeWebViewHelper.CreateAndInitWebView. Did anyone get a workaround?
  14. vfbb

    StoryBoard launch screen - Delphi 10.4

    No, it is correct. The name in that file is not the name your image in your computer, but the name of the image in the remote device. As I told you, just delete your app, restart your phone, open a blank project, change it by options and compile and you will see that is working.
  15. vfbb

    StoryBoard launch screen - Delphi 10.4

    The options of the delphi 10.4 is working perfectly for this, you don't have to add it manually to the deploy project and you don't need to change the storyboard files either. You can test with a new project.
×