Skip to content

Instantly share code, notes, and snippets.

@DelphiWorlds
DelphiWorlds / FeedDateToDateTime.pas
Last active Dec 25, 2021
Convert an RSS/Atom date to datetime
View FeedDateToDateTime.pas
uses
System.SysUtils, System.DateUtils, System.StrUtils;
// examples:
// Wed, 3 Nov 2021 18:20:21 +1030
// 21 Dec 2021 19:04:06 GMT
function FeedDateToDateTime(const AFeedDate: string): TDateTime;
var
LParts: TArray<string>;
LISO8601, LDay, LMonth: string;
@DelphiWorlds
DelphiWorlds / PendingIntentArrayListExample.pas
Created Oct 16, 2021
How to put a PendingIntent into an ArrayList
View PendingIntentArrayListExample.pas
uses
Androidapi.JNI.JavaTypes, Androidapi.JNI.App, Androidapi.JNI.GraphicsContentViewText, Androidapi.Helpers;
var
LArrayList: JArrayList;
LIntent: JIntent;
LPendingIntent: JPendingIntent
begin
LIntent := TJIntent.Create;
// *** Here, call setAction and whatever else needs to be done to initialize LIntent ***
@DelphiWorlds
DelphiWorlds / BonjourTest.pas
Created Sep 10, 2021
Example of how a Bonjour service *might* be set up on macOS. Has not been fully tested
View BonjourTest.pas
unit Unit1;
// With help from this SO post:
// https://stackoverflow.com/a/16678161/3164070
// ******* NOTE *********
// As per the comment in the Acivate method:
// This assumes you have actually created a socket that is listening on the selected port
interface
@DelphiWorlds
DelphiWorlds / NSNetServiceDelegate.pas
Created Sep 1, 2021
Import of NSNetServiceDelegate etc
View NSNetServiceDelegate.pas
uses
Macapi.Foundation;
type
NSNetService = interface;
NSNetServiceBrowser = interface;
NSNetServiceDelegate = interface;
NSNetServiceBrowserDelegate = interface;
PNSInputStream = ^NSInputStream;
@DelphiWorlds
DelphiWorlds / MapMarkerExample.pas
Created May 2, 2021
Create 2 markers, not far from each other
View MapMarkerExample.pas
type
TForm1 = class(TForm)
Map: TMapView;
private
FMarkerA: TMapMarker;
FMarkerB: TMapMarker;
procedure AddMarkers;
public
constructor Create(AOwner: TComponent); override;
end;
@DelphiWorlds
DelphiWorlds / ShowManageExternalStorageSettings.pas
Created Apr 18, 2021
Code to show the manage external storage permissions settings (Android 11)
View ShowManageExternalStorageSettings.pas
uses
Androidapi.Helpers, Androidapi.JNI.Provider, Androidapi.JNI.GraphicsContentViewText;
procedure ShowManageExternalStorageSettings;
var
LIntent: JIntent;
begin
LIntent := TJIntent.Create;
LIntent.setAction(StringToJString('android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION');
LIntent.setData(TJnet_Uri.JavaClass.parse(StringToJString('package:' + JStringtoString(TAndroidHelper.Context.getPackageName()))));
@DelphiWorlds
DelphiWorlds / TrashFile.pas
Last active Mar 16, 2021
Sending a file or directory to the trash on macOS/iOS. NOTE: *** On iOS, works only on iOS 11 or above ***
View TrashFile.pas
uses
{$IF Defined(IOS)}
Macapi.ObjectiveC,
iOSapi.Foundation,
{$ELSE}
Macapi.Foundation,
{$ENDIF}
Macapi.Helpers;
{$IF Defined(IOS)}
@DelphiWorlds
DelphiWorlds / FMX.Maps.iOS.Patch.pas
Created Jan 29, 2021
Show callout for map marker on iOS
View FMX.Maps.iOS.Patch.pas
// Note: this is just parts of the unit to show what to "patch". Please refer to the readme.md in this gist
unit FMX.Maps.iOS;
interface
{$SCOPEDENUMS ON}
procedure RegisterMapService;
implementation
@DelphiWorlds
DelphiWorlds / PutBack.pas
Created Jan 15, 2021
Put application in background on Android
View PutBack.pas
uses
Androidapi.Helpers;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
if key = vkHardwareBack then
begin
Key := 0;
TAndroidHelper.Activity.moveTaskToBack(True);
end;
@DelphiWorlds
DelphiWorlds / MigrationToolQP.md
Created Sep 6, 2020
Collection of QP reports related to Migration Tool in RADStudio
View MigrationToolQP.md

https://quality.embarcadero.com/browse/RSP-30432 (Missing Recent and Favorite projects) https://quality.embarcadero.com/browse/RSP-27078 (Missing Closed Projects) https://quality.embarcadero.com/browse/RSP-26695 (UI issue and missing environment vars) https://quality.embarcadero.com/browse/RSP-26796 (Ignores Platform SDK settings) https://quality.embarcadero.com/browse/RSP-25565 (Ignores Search\DirectoryLists) https://quality.embarcadero.com/browse/RSP-23451 (Support migrating when install is in a new path) https://quality.embarcadero.com/browse/RSP-17951 (Missing Environment vars) https://quality.embarcadero.com/browse/RSP-15354 (Migrate desktop settings - Won't fix)