LCL-CustomDrawn-Android: Changes the hardcoded package name to a variable which user software can change

git-svn-id: trunk@37099 -
This commit is contained in:
sekelsenmat 2012-04-30 08:36:08 +00:00
parent 15b8f2e5c3
commit 125a10ca75
7 changed files with 10 additions and 6 deletions

View File

@ -28,7 +28,7 @@ REM Resource compilation
call aapt p -v -f -M AndroidManifest.xml -F bin\%APP_NAME%.ap_ -I %APK_SDK_PLATFORM%\android.jar -S res -m -J gen raw
REM Java compiler
call javac -verbose -classpath %APK_SDK_PLATFORM%\android.jar -d bin\classes src\com\pascal\lcltest\LCLActivity.java
call javac -verbose -encoding UTF8 -classpath %APK_SDK_PLATFORM%\android.jar -d bin\classes src\com\pascal\lcltest\LCLActivity.java
REM DX to convert the java bytecode to dalvik bytecode
call dx --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes

View File

@ -312,7 +312,7 @@ public class LCLActivity extends Activity implements SensorEventListener, Locati
// -------------------------------------------
public native int LCLDrawToBitmap(int width, int height, Bitmap bitmap);
public native int LCLOnTouch(float x, float y, int action);
public native int LCLOnCreate(LCLActivity lclactivity);
public native int LCLOnCreate(Activity lclactivity);
public native int LCLOnMessageBoxFinished(int Result, int DialogType);
public native int LCLOnKey(int kind, int keyCode, KeyEvent event, int AChar);
public native int LCLOnTimer(Runnable timerid);

View File

@ -31,6 +31,7 @@ begin
end;
begin
CDWidgetset.ActivityClassName := 'com/pascal/lcltest/LCLActivity';
CDWidgetset.ActivityOnCreate := @MyActivityOnCreate;
end.

View File

@ -268,6 +268,7 @@ type
// Android Activity callbacks
ActivityOnCreate: TProcedure;
ActivityClassName: string;
constructor Create; override;
destructor Destroy; override;

View File

@ -313,7 +313,7 @@ begin
{$endif}
// Very strangely in the emulator it crashes if we don't refresh the Activity class here
javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef,'com/pascal/lcltest/LCLActivity');
javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef, PChar(CDWidgetset.ActivityClassName));
// ad.setSingleChoiceItems( adapter, -1, MyOnClickListener);
// DialogInterface.OnClickListener lclselectitemcallback;

View File

@ -127,6 +127,8 @@ begin
FTerminating := False;
DefaultFontSize := 10;
ActivityClassName := 'com/pascal/lcltest/LCLActivity';
FClipBoardFormats := TStringList.Create;
FClipBoardFormats.Add('foo'); // 0 is reserved

View File

@ -350,7 +350,7 @@ begin
Result := 0;
// Very strangely in the emulator it crashes if we don't refresh the Activity class here
javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef,'com/pascal/lcltest/LCLActivity');
javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef, PChar(CDWidgetset.ActivityClassName));
//{$ifdef VerboseCDEvents}
DebugLn(Format('LCLOnMenuAction called kind=%d itemIndex=%d', [kind, itemIndex]));
@ -441,7 +441,7 @@ const NativeMethods: array[0..8] of JNINativeMethod=
signature:'(FFI)I';
fnPtr:@Java_com_pascal_lclproject_LCLActivity_LCLOnTouch;),
(name:'LCLOnCreate';
signature:'(Lcom/pascal/lcltest/LCLActivity;)I'; //android/app/Activity;
signature:'(Landroid/app/Activity;)I'; // Don't use a name which includes the package name like com/pascal/lcltest/LCLActivity;
fnPtr:@Java_com_pascal_lclproject_LCLActivity_LCLOnCreate;),
(name:'LCLOnMessageBoxFinished';
signature:'(II)I';
@ -484,7 +484,7 @@ begin
// Find our activity class
__android_log_write(ANDROID_LOG_INFO,'lclapp','Reading our Activity Class');
javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef,'com/pascal/lcltest/LCLActivity');
javaActivityClass := javaEnvRef^^.FindClass(javaEnvRef, PChar(CDWidgetset.ActivityClassName));
if not assigned(javaActivityClass) then
begin
__android_log_write(ANDROID_LOG_FATAL, 'lclapp', 'javaEnvRef^.FindClass failed');