Skip to content

Instantly share code, notes, and snippets.

@DelphiWorlds
DelphiWorlds / MigrationToolQP.md
Created September 6, 2020 22:12
Collection of QP reports related to Migration Tool in RADStudio

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)

@DelphiWorlds
DelphiWorlds / AndroidCheckDarkMode.pas
Created July 23, 2020 13:46
Check Android for dark mode (untested)
uses
Androidapi.JNI.GraphicsContentViewText, Androidapi.Helpers;
function IsDarkMode: Boolean;
var
LMode: Integer;
begin
LMode := TAndroidHelper.Context.getResources.getConfiguration.uiMode and TJConfiguration.JavaClass.UI_MODE_NIGHT_MASK;
Result := LMode = TJConfiguration.JavaClass.UI_MODE_NIGHT_YES;
end;
@DelphiWorlds
DelphiWorlds / ExtractEXIFAndroid.pas
Created June 23, 2020 02:11
Extracting EXIF data on Android
uses
Androidapi.JNI.Media, Androidapi.JNIBridge;
var
LEXIF: JExifInterface;
LLatLong: TJavaArray<Single>;
LOrientation: Integer;
LLatitude, LLongitude: Single;
LDateTaken, LCameraMake, LCameraModel: string;
begin
uses
Androidapi.JNI.WebKit;
procedure TForm1.Button1Click(Sender: TObject);
var
LWebView: JWebView;
begin
if Supports(WebBrowser1, JWebView, LWebView) then
LWebView.clearHistory;
end;
uses
Androidapi.JNI.App, Androidapi.Helpers, Androidapi.JNI.GraphicsContentViewText;
// Available memory in MB
function GetMemory: Int64;
var
LMemoryInfo: JActivityManager_MemoryInfo;
LActivityManager: JActivityManager;
begin
LActivityManager := TJActivityManager.Wrap(JObjectToID(TAndroidHelper.Context.getSystemService(TJActivity.JavaClass.ACTIVITY_SERVICE)));
uses
System.Permissions;
procedure TForm1.RequestCallPhonePermission;
begin
PermissionsService.RequestPermissions(['android.permission.CALL_PHONE'],
procedure(const APermissions: TArray<string>; const AGrantResults: TArray<TPermissionStatus>)
begin
if AGrantResults[0] = TPermissionStatus.Granted then
// Permission has been granted
@DelphiWorlds
DelphiWorlds / FormHelperInterface.pas
Created January 21, 2020 22:28
Implementing an interface via a helper
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.StdCtrls;
type
ITest = interface(IInterface)
uses
Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Os, Androidapi.JNI.JavaTypes, Androidapi.Helpers;
procedure SendBroadcast(const AIntent: JIntent);
var
LResolveInfoList: JList;
LResolveInfo: JResolveInfo;
LComponentName: JComponentName;
LExplicitIntent: JIntent;
I: Integer;
@DelphiWorlds
DelphiWorlds / AddingStrings.pas
Last active August 9, 2024 13:36
StringList value type alternative
type
StringList = TArray<string>;
StringListHelper = record helper for StringList
public
procedure Add(const AValue: string);
end;
{ StringListHelper }
@DelphiWorlds
DelphiWorlds / EnumNetPrinters.pas
Last active January 21, 2019 03:40
Enumerating network printers in Windows
type
TNetResourceArray = TArray<TNetResource>;
function EnumerateContainedPrinters(const AContainer: TNetResource): TNetResourceArray;
var
LResult, LBufferSize: DWORD;
LEnumHandle: THandle;
LNetResources: TNetResourceArray;
I: Integer;
LEntries : Longint;