diff --git a/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java b/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java index 0a033c5da1..ac1f05e740 100755 --- a/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java +++ b/examples/androidlcl/android/src/com/pascal/lcltest/LCLActivity.java @@ -302,12 +302,12 @@ public class LCLActivity extends Activity implements SensorEventListener, Locati // input: String lcltext, int lclwidth, int lclheight // output: lclbitmap - public void LCLDoDrawText() + public void LCLDoDrawText(int ATextColor) { lclbitmap = Bitmap.createBitmap(lclwidth, lclheight, Bitmap.Config.ARGB_8888); Canvas localcanvas = new Canvas(lclbitmap); Paint localpaint = new Paint(); - localpaint.setColor(Color.BLACK); + localpaint.setColor(ATextColor); localpaint.setTextSize(lcltextsize); localpaint.setFlags(Paint.ANTI_ALIAS_FLAG); localcanvas.drawColor(Color.TRANSPARENT); // TRANSPARENT diff --git a/examples/androidlcl/mainform.lfm b/examples/androidlcl/mainform.lfm index c4f0113d04..58d230d195 100644 --- a/examples/androidlcl/mainform.lfm +++ b/examples/androidlcl/mainform.lfm @@ -83,6 +83,8 @@ object Form1: TForm1 Top = 223 Width = 43 Caption = 'Label1' + Font.Color = clBlue ParentColor = False + ParentFont = False end end diff --git a/lcl/interfaces/customdrawn/customdrawn_androidproc.pas b/lcl/interfaces/customdrawn/customdrawn_androidproc.pas index e5aae7ddc9..1f4913e995 100644 --- a/lcl/interfaces/customdrawn/customdrawn_androidproc.pas +++ b/lcl/interfaces/customdrawn/customdrawn_androidproc.pas @@ -8,13 +8,25 @@ uses // rtl+ftl Types, Classes, SysUtils, fpimage, fpcanvas, ctypes, + // Android headers + jni, // Custom Drawn Canvas IntfGraphics, lazcanvas, // - GraphType, Controls, LCLMessageGlue, WSControls, LCLType, LCLProc, + GraphType, Controls, Graphics, LCLMessageGlue, WSControls, LCLType, LCLProc, customdrawnproc; +function FPColorToAndroidColor(AValue: TFPColor): jint; + implementation +// Android color is in the format: Alpha-Red-Green-Blue +function FPColorToAndroidColor(AValue: TFPColor): jint; +begin + Result:= $FF000000 or ((AValue.Blue shr 8) and $ff) + or (AValue.Green and $ff00) + or ((AValue.Red shl 8) and $ff0000); +end; + end. diff --git a/lcl/interfaces/customdrawn/customdrawnobject_android.inc b/lcl/interfaces/customdrawn/customdrawnobject_android.inc index d167447cf3..2a607ab0ae 100644 --- a/lcl/interfaces/customdrawn/customdrawnobject_android.inc +++ b/lcl/interfaces/customdrawn/customdrawnobject_android.inc @@ -442,7 +442,7 @@ begin // Read all method IDs javaMethod_LCLDoGetTextBounds := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoGetTextBounds', '()V'); javaMethod_LCLDoGetTextPartialWidths := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoGetTextPartialWidths', '()V'); - javaMethod_LCLDoDrawText := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoDrawText', '()V'); + javaMethod_LCLDoDrawText := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoDrawText', '(I)V'); javaMethod_LCLDoShowMessageBox := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoShowMessageBox', '()V'); javaMethod_LCLDoCreateTimer := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoCreateTimer', '()V'); javaMethod_LCLDoDestroyTimer := javaEnvRef^^.GetMethodID(javaEnvRef, javaActivityClass, 'LCLDoDestroyTimer', '()V'); diff --git a/lcl/interfaces/customdrawn/customdrawnwinapi_android.inc b/lcl/interfaces/customdrawn/customdrawnwinapi_android.inc index b6fd413611..abe394a56c 100644 --- a/lcl/interfaces/customdrawn/customdrawnwinapi_android.inc +++ b/lcl/interfaces/customdrawn/customdrawnwinapi_android.inc @@ -2187,6 +2187,8 @@ var lWidth, lHeight: jint; lDestCanvas: TLazCanvas; lFontSize: Integer; + // array for the parameters + lParams: array[0..0] of JValue; begin {$ifdef VerboseCDText} DebugLn(Format(':>[WinAPI ExtTextOut] DC=%x javaEnvRef=%x Str=%s X=%d Y=%d', @@ -2217,7 +2219,8 @@ begin javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoGetTextBounds); // Call the method to draw the text - javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoDrawText); + lParams[0].i := FPColorToAndroidColor(lDestCanvas.Font.FPColor); + javaEnvRef^^.CallVoidMethodA(javaEnvRef, javaActivityObject, javaMethod_LCLDoDrawText, @lParams[0]); // Get the bitmap with the text lJavaBitmap := javaEnvRef^^.GetObjectField(javaEnvRef, javaActivityObject, javaField_lclbitmap);