diff --git a/bindings/android-sdk/android_bindings_generator.lpi b/bindings/android-sdk/android_bindings_generator.lpi index 4f87fae88..f9273fd10 100644 --- a/bindings/android-sdk/android_bindings_generator.lpi +++ b/bindings/android-sdk/android_bindings_generator.lpi @@ -39,7 +39,7 @@ - + @@ -48,7 +48,7 @@ - + @@ -61,7 +61,7 @@ - + @@ -117,12 +117,11 @@ - - - - + + + @@ -201,9 +200,9 @@ - - - + + + @@ -230,7 +229,7 @@ - + @@ -244,21 +243,22 @@ + - - - + + + - + - + @@ -269,127 +269,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + diff --git a/bindings/android-sdk/android_sdk_bindings_gen.pas b/bindings/android-sdk/android_sdk_bindings_gen.pas index 0e63df58d..7d2b82243 100644 --- a/bindings/android-sdk/android_sdk_bindings_gen.pas +++ b/bindings/android-sdk/android_sdk_bindings_gen.pas @@ -186,6 +186,7 @@ begin ADest.Add(' AbsSpinner param_self_AbsSpinner;'); ADest.Add(' ArrayAdapter param_self_ArrayAdapter_String_;'); ADest.Add(' AdapterView param_self_AdapterView;'); + ADest.Add(' AlertDialog.Builder param_self_AlertDialog_Builder;'); ADest.Add(' //'); ADest.Add(' // Params'); ADest.Add(' //'); @@ -206,6 +207,8 @@ begin ADest.Add(' boolean lResult_boolean;'); ADest.Add(' CharSequence lResult_CharSequence;'); ADest.Add(' Display lResult_Display;'); + ADest.Add(' AlertDialog.Builder lResult_AlertDialog_Builder;'); + ADest.Add(' AlertDialog lResult_AlertDialog;'); ADest.Add(''); ADest.Add(' switch (Buffer)'); ADest.Add(' {'); @@ -396,6 +399,7 @@ var lParamNum: Integer = 1; lCurWord, lParentClassName: string; lMethodReturn, lMethodReturnPas, lMethodName, lParamType, lParamTypePas, lParamName, lParamPrefix: string; + lMethodReturnJavaIdentifier: string; DeclarationBase, TmpStr, lIDString: string; FPasOutputImplCurLine: Integer; lJavaParamVar, lJavaParams, lJavaParamSelf: string; @@ -428,7 +432,7 @@ begin if not FIsGlobalObject then FPasOutputImpl.Add(' vAndroidPipesComm.SendInt(Index); // Self, Java Pointer'); - lJavaParamSelf := 'param_self_' + JavaRemoveGeneric(FClassName); + lJavaParamSelf := 'param_self_' + JavaRemoveGeneric(ConvertPointToUnderline(FClassName)); FJavaOutputMethods.Add(' // ' + ASourceLine); FJavaOutputMethods.Add(' case ' + lIDString + ':'); FJavaOutputMethods.Add(' DebugOut("' + lIDString + '");'); @@ -498,7 +502,7 @@ begin // And for Java params too lJavaParams := System.Copy(lJavaParams, 0, Length(lJavaParams)-2); - // Add the return + // Add the Pascal return if lMethodReturn = 'void' then begin TmpStr := TmpStr + ');'; @@ -530,25 +534,27 @@ begin FPasOutputImpl.Add('end;'); FPasOutputImpl.Add(''); + // Java Return FJavaOutputMethods.Add(' //'); + lMethodReturnJavaIdentifier := 'lResult_' + ConvertPointToUnderline(lMethodReturn); if AIsField then begin - FJavaOutputMethods.Add(' lResult_' + lMethodReturn + ' = ' + lJavaParamSelf + '.' + lMethodName + ';'); - FJavaOutputMethods.Add(' MyAndroidPipesComm.' + GetJavaResultFunction(lMethodReturn) + '(lResult_' + lMethodReturn + ');'); + FJavaOutputMethods.Add(Format(' %s = %s.%s;', [lMethodReturnJavaIdentifier, lJavaParamSelf, lMethodName])); + FJavaOutputMethods.Add(Format(' MyAndroidPipesComm.%s(%s);', [GetJavaResultFunction(lMethodReturn), lMethodReturnJavaIdentifier])); end else if lMethodReturn = 'void' then begin - FJavaOutputMethods.Add(' ' + lJavaParamSelf + '.' + lMethodName + '(' + lJavaParams + ');'); - FJavaOutputMethods.Add(' MyAndroidPipesComm.SendResult();'); + FJavaOutputMethods.Add(Format(' %s.%s(%s);', [lJavaParamSelf, lMethodName, lJavaParams])); + FJavaOutputMethods.Add(Format(' MyAndroidPipesComm.SendResult();', [])); end else begin - FJavaOutputMethods.Add(' lResult_' + lMethodReturn + ' = ' + lJavaParamSelf + '.' + lMethodName + '(' + lJavaParams + ');'); + FJavaOutputMethods.Add(Format(' %s = %s.%s(%s);', [lMethodReturnJavaIdentifier, lJavaParamSelf, lMethodName, lJavaParams])); if IsBasicJavaType(lMethodReturn) or (lMethodReturn = 'CharSequence') or (lMethodReturn = 'String') then - FJavaOutputMethods.Add(' MyAndroidPipesComm.' + GetJavaResultFunction(lMethodReturn) + '(lResult_' + lMethodReturn + ');') + FJavaOutputMethods.Add(Format(' MyAndroidPipesComm.%s(%s);', [GetJavaResultFunction(lMethodReturn), lMethodReturnJavaIdentifier])) else begin - FJavaOutputMethods.Add(Format(' ViewElements.add(lResult_%s);', [lMethodReturn])); + FJavaOutputMethods.Add(Format(' ViewElements.add(%s);', [lMethodReturnJavaIdentifier])); FJavaOutputMethods.Add(Format(' MyAndroidPipesComm.%s(ViewElements.size() - 1);', [GetJavaResultFunction(lMethodReturn)])) end; end; diff --git a/bindings/android-sdk/sdk_level_7/android_all.txt b/bindings/android-sdk/sdk_level_7/android_all.txt index e46d01015..3e661b31e 100644 --- a/bindings/android-sdk/sdk_level_7/android_all.txt +++ b/bindings/android-sdk/sdk_level_7/android_all.txt @@ -43,6 +43,45 @@ method void getMetrics(DisplayMetrics outMetrics) [WindowManager] TJavaObject method Display getDefaultDisplay() +[Dialog] TJavaObject + +[AlertDialog] Dialog + +[AlertDialog.Builder] TJavaObject +constructor Create(Activity) +#public AlertDialog create () +#public Context getContext () +#public AlertDialog.Builder setAdapter (ListAdapter adapter, DialogInterface.OnClickListener listener) +#public AlertDialog.Builder setCancelable (boolean cancelable) +#public AlertDialog.Builder setCursor (Cursor cursor, DialogInterface.OnClickListener listener, String labelColumn) +#public AlertDialog.Builder setCustomTitle (View customTitleView) +#public AlertDialog.Builder setIcon (Drawable icon) +#public AlertDialog.Builder setIcon (int iconId) +#public AlertDialog.Builder setIconAttribute (int attrId) +#public AlertDialog.Builder setInverseBackgroundForced (boolean useInverseBackground) +#public AlertDialog.Builder setItems (int itemsId, DialogInterface.OnClickListener listener) +#public AlertDialog.Builder setItems (CharSequence[] items, DialogInterface.OnClickListener listener) +method AlertDialog.Builder setMessage (CharSequence message) +#public AlertDialog.Builder setMessage (int messageId) +#public AlertDialog.Builder setMultiChoiceItems (CharSequence[] items, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener listener) +#public AlertDialog.Builder setMultiChoiceItems (Cursor cursor, String isCheckedColumn, String labelColumn, DialogInterface.OnMultiChoiceClickListener listener) +#public AlertDialog.Builder setNegativeButton (CharSequence text, DialogInterface.OnClickListener listener) +#public AlertDialog.Builder setNeutralButton (int textId, DialogInterface.OnClickListener listener) +#public AlertDialog.Builder setNeutralButton (CharSequence text, DialogInterface.OnClickListener listener) +#public AlertDialog.Builder setOnCancelListener (DialogInterface.OnCancelListener onCancelListener) +#public AlertDialog.Builder setOnItemSelectedListener (AdapterView.OnItemSelectedListener listener) +#public AlertDialog.Builder setOnKeyListener (DialogInterface.OnKeyListener onKeyListener) +#public AlertDialog.Builder setPositiveButton (int textId, DialogInterface.OnClickListener listener) +#public AlertDialog.Builder setPositiveButton (CharSequence text, DialogInterface.OnClickListener listener) +#public AlertDialog.Builder setSingleChoiceItems (CharSequence[] items, int checkedItem, DialogInterface.OnClickListener listener) +#public AlertDialog.Builder setSingleChoiceItems (ListAdapter adapter, int checkedItem, DialogInterface.OnClickListener listener) +#public AlertDialog.Builder setSingleChoiceItems (int itemsId, int checkedItem, DialogInterface.OnClickListener listener) +#public AlertDialog.Builder setSingleChoiceItems (Cursor cursor, int checkedItem, String labelColumn, DialogInterface.OnClickListener listener) +method AlertDialog.Builder setTitle (CharSequence title) +#public AlertDialog.Builder setTitle (int titleId) +method AlertDialog.Builder setView (View view) +method AlertDialog show () + # # android.view # diff --git a/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidAll.java b/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidAll.java index d413e23d9..531774619 100644 --- a/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidAll.java +++ b/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidAll.java @@ -49,73 +49,81 @@ public class AndroidAll static final int amkUI_TDisplay_getMetrics_0 = 0x00103000; // WindowManager static final int amkUI_TWindowManager_getDefaultDisplay_0 = 0x00104000; + // Dialog + // AlertDialog + // AlertDialog.Builder + static final int amkUI_TAlertDialog_Builder_Create_0 = 0x00107000; + static final int amkUI_TAlertDialog_Builder_setMessage_1 = 0x00107001; + static final int amkUI_TAlertDialog_Builder_setTitle_2 = 0x00107002; + static final int amkUI_TAlertDialog_Builder_setView_3 = 0x00107003; + static final int amkUI_TAlertDialog_Builder_show_4 = 0x00107004; // ViewGroup.LayoutParams - static final int amkUI_TViewGroup_LayoutParams_Create_0 = 0x00105000; + static final int amkUI_TViewGroup_LayoutParams_Create_0 = 0x00108000; // View - static final int amkUI_TView_setLayoutParams_0 = 0x00106000; - static final int amkUI_TView_setVisibility_1 = 0x00106001; + static final int amkUI_TView_setLayoutParams_0 = 0x00109000; + static final int amkUI_TView_setVisibility_1 = 0x00109001; // ViewGroup - static final int amkUI_TViewGroup_addView_0 = 0x00107000; - static final int amkUI_TViewGroup_addView_1 = 0x00107001; - static final int amkUI_TViewGroup_addView_2 = 0x00107002; - static final int amkUI_TViewGroup_addView_3 = 0x00107003; - static final int amkUI_TViewGroup_addView_4 = 0x00107004; + static final int amkUI_TViewGroup_addView_0 = 0x0010A000; + static final int amkUI_TViewGroup_addView_1 = 0x0010A001; + static final int amkUI_TViewGroup_addView_2 = 0x0010A002; + static final int amkUI_TViewGroup_addView_3 = 0x0010A003; + static final int amkUI_TViewGroup_addView_4 = 0x0010A004; // LinearLayout - static final int amkUI_TLinearLayout_Create_0 = 0x00108000; - static final int amkUI_TLinearLayout_setOrientation_1 = 0x00108001; + static final int amkUI_TLinearLayout_Create_0 = 0x0010B000; + static final int amkUI_TLinearLayout_setOrientation_1 = 0x0010B001; // AbsoluteLayout - static final int amkUI_TAbsoluteLayout_Create_0 = 0x00109000; + static final int amkUI_TAbsoluteLayout_Create_0 = 0x0010C000; // AbsoluteLayout.LayoutParams - static final int amkUI_TAbsoluteLayout_LayoutParams_Create_0 = 0x0010A000; + static final int amkUI_TAbsoluteLayout_LayoutParams_Create_0 = 0x0010D000; // TextView - static final int amkUI_TTextView_Create_0 = 0x0010B000; - static final int amkUI_TTextView_setText_1 = 0x0010B001; - static final int amkUI_TTextView_setOnClickListener_2 = 0x0010B002; - static final int amkUI_TTextView_OnClickListener_Start_3 = 0x0010B003; - static final int amkUI_TTextView_OnClickListener_Finished_4 = 0x0010B004; - static final int amkUI_TTextView_setTextSize_5 = 0x0010B005; - static final int amkUI_TTextView_getText_6 = 0x0010B006; + static final int amkUI_TTextView_Create_0 = 0x0010E000; + static final int amkUI_TTextView_setText_1 = 0x0010E001; + static final int amkUI_TTextView_setOnClickListener_2 = 0x0010E002; + static final int amkUI_TTextView_OnClickListener_Start_3 = 0x0010E003; + static final int amkUI_TTextView_OnClickListener_Finished_4 = 0x0010E004; + static final int amkUI_TTextView_setTextSize_5 = 0x0010E005; + static final int amkUI_TTextView_getText_6 = 0x0010E006; // EditText - static final int amkUI_TEditText_Create_0 = 0x0010C000; + static final int amkUI_TEditText_Create_0 = 0x0010F000; // Button - static final int amkUI_TButton_Create_0 = 0x0010D000; + static final int amkUI_TButton_Create_0 = 0x00110000; // FrameLayout // TimePicker - static final int amkUI_TTimePicker_Create_0 = 0x0010F000; - static final int amkUI_TTimePicker_getCurrentHour_1 = 0x0010F001; - static final int amkUI_TTimePicker_setCurrentHour_2 = 0x0010F002; - static final int amkUI_TTimePicker_getCurrentMinute_3 = 0x0010F003; - static final int amkUI_TTimePicker_setCurrentMinute_4 = 0x0010F004; - static final int amkUI_TTimePicker_is24HourView_5 = 0x0010F005; - static final int amkUI_TTimePicker_setIs24HourView_6 = 0x0010F006; + static final int amkUI_TTimePicker_Create_0 = 0x00112000; + static final int amkUI_TTimePicker_getCurrentHour_1 = 0x00112001; + static final int amkUI_TTimePicker_setCurrentHour_2 = 0x00112002; + static final int amkUI_TTimePicker_getCurrentMinute_3 = 0x00112003; + static final int amkUI_TTimePicker_setCurrentMinute_4 = 0x00112004; + static final int amkUI_TTimePicker_is24HourView_5 = 0x00112005; + static final int amkUI_TTimePicker_setIs24HourView_6 = 0x00112006; // ScrollView - static final int amkUI_TScrollView_Create_0 = 0x00110000; + static final int amkUI_TScrollView_Create_0 = 0x00113000; // CompoundButton - static final int amkUI_TCompoundButton_isChecked_0 = 0x00111000; - static final int amkUI_TCompoundButton_performClick_1 = 0x00111001; - static final int amkUI_TCompoundButton_setChecked_2 = 0x00111002; - static final int amkUI_TCompoundButton_toggle_3 = 0x00111003; + static final int amkUI_TCompoundButton_isChecked_0 = 0x00114000; + static final int amkUI_TCompoundButton_performClick_1 = 0x00114001; + static final int amkUI_TCompoundButton_setChecked_2 = 0x00114002; + static final int amkUI_TCompoundButton_toggle_3 = 0x00114003; // CheckBox - static final int amkUI_TCheckBox_Create_0 = 0x00112000; + static final int amkUI_TCheckBox_Create_0 = 0x00115000; // AdapterView - static final int amkUI_TAdapterView_getSelectedItemPosition_0 = 0x00113000; + static final int amkUI_TAdapterView_getSelectedItemPosition_0 = 0x00116000; // AbsSpinner - static final int amkUI_TAbsSpinner_getCount_0 = 0x00114000; - static final int amkUI_TAbsSpinner_setAdapter_1 = 0x00114001; - static final int amkUI_TAbsSpinner_setSelection_2 = 0x00114002; + static final int amkUI_TAbsSpinner_getCount_0 = 0x00117000; + static final int amkUI_TAbsSpinner_setAdapter_1 = 0x00117001; + static final int amkUI_TAbsSpinner_setSelection_2 = 0x00117002; // Spinner - static final int amkUI_TSpinner_Create_0 = 0x00115000; + static final int amkUI_TSpinner_Create_0 = 0x00118000; // Filterable // Adapter // ListAdapter // SpinnerAdapter // BaseAdapter // ArrayAdapter - static final int amkUI_TArrayAdapter_String__Create_0 = 0x0011B000; - static final int amkUI_TArrayAdapter_String__add_1 = 0x0011B001; - static final int amkUI_TArrayAdapter_String__clear_2 = 0x0011B002; - static final int amkUI_TArrayAdapter_String__insert_3 = 0x0011B003; - static final int amkUI_TArrayAdapter_String__remove_4 = 0x0011B004; + static final int amkUI_TArrayAdapter_String__Create_0 = 0x0011E000; + static final int amkUI_TArrayAdapter_String__add_1 = 0x0011E001; + static final int amkUI_TArrayAdapter_String__clear_2 = 0x0011E002; + static final int amkUI_TArrayAdapter_String__insert_3 = 0x0011E003; + static final int amkUI_TArrayAdapter_String__remove_4 = 0x0011E004; // layout public boolean ProcessCommand(int Buffer) @@ -144,6 +152,7 @@ public class AndroidAll AbsSpinner param_self_AbsSpinner; ArrayAdapter param_self_ArrayAdapter_String_; AdapterView param_self_AdapterView; + AlertDialog.Builder param_self_AlertDialog_Builder; // // Params // @@ -164,6 +173,8 @@ public class AndroidAll boolean lResult_boolean; CharSequence lResult_CharSequence; Display lResult_Display; + AlertDialog.Builder lResult_AlertDialog_Builder; + AlertDialog lResult_AlertDialog; switch (Buffer) { @@ -293,6 +304,65 @@ public class AndroidAll ViewElements.add(lResult_Display); MyAndroidPipesComm.SendIntResult(ViewElements.size() - 1); break; + case amkUI_TAlertDialog_Builder_Create_0: + DebugOut("amkUI_TAlertDialog_Builder_Create_0"); + ViewElements.add(new AlertDialog.Builder(activity)); + MyAndroidPipesComm.SendIntResult(ViewElements.size() - 1); + break; + // method AlertDialog.Builder setMessage (CharSequence message) + case amkUI_TAlertDialog_Builder_setMessage_1: + DebugOut("amkUI_TAlertDialog_Builder_setMessage_1"); + // Self + lInt = MyAndroidPipesComm.GetInt(); + param_self_AlertDialog_Builder = (AlertDialog.Builder) ViewElements.get(lInt); + // params + lInt = MyAndroidPipesComm.GetInt(); + lCharSequence_1 = (CharSequence) MyJavaLang.LangElements.get(lInt); + // + lResult_AlertDialog_Builder = param_self_AlertDialog_Builder.setMessage(lCharSequence_1); + ViewElements.add(lResult_AlertDialog_Builder); + MyAndroidPipesComm.SendIntResult(ViewElements.size() - 1); + break; + // method AlertDialog.Builder setTitle (CharSequence title) + case amkUI_TAlertDialog_Builder_setTitle_2: + DebugOut("amkUI_TAlertDialog_Builder_setTitle_2"); + // Self + lInt = MyAndroidPipesComm.GetInt(); + param_self_AlertDialog_Builder = (AlertDialog.Builder) ViewElements.get(lInt); + // params + lInt = MyAndroidPipesComm.GetInt(); + lCharSequence_1 = (CharSequence) MyJavaLang.LangElements.get(lInt); + // + lResult_AlertDialog_Builder = param_self_AlertDialog_Builder.setTitle(lCharSequence_1); + ViewElements.add(lResult_AlertDialog_Builder); + MyAndroidPipesComm.SendIntResult(ViewElements.size() - 1); + break; + // method AlertDialog.Builder setView (View view) + case amkUI_TAlertDialog_Builder_setView_3: + DebugOut("amkUI_TAlertDialog_Builder_setView_3"); + // Self + lInt = MyAndroidPipesComm.GetInt(); + param_self_AlertDialog_Builder = (AlertDialog.Builder) ViewElements.get(lInt); + // params + lInt = MyAndroidPipesComm.GetInt(); + lView_1 = (View) ViewElements.get(lInt); + // + lResult_AlertDialog_Builder = param_self_AlertDialog_Builder.setView(lView_1); + ViewElements.add(lResult_AlertDialog_Builder); + MyAndroidPipesComm.SendIntResult(ViewElements.size() - 1); + break; + // method AlertDialog show () + case amkUI_TAlertDialog_Builder_show_4: + DebugOut("amkUI_TAlertDialog_Builder_show_4"); + // Self + lInt = MyAndroidPipesComm.GetInt(); + param_self_AlertDialog_Builder = (AlertDialog.Builder) ViewElements.get(lInt); + // params + // + lResult_AlertDialog = param_self_AlertDialog_Builder.show(); + ViewElements.add(lResult_AlertDialog); + MyAndroidPipesComm.SendIntResult(ViewElements.size() - 1); + break; case amkUI_TViewGroup_LayoutParams_Create_0: DebugOut("amkUI_TViewGroup_LayoutParams_Create_0"); lint_1 = MyAndroidPipesComm.GetInt(); diff --git a/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidPipesComm.java b/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidPipesComm.java index 2aff55877..5e0b54da0 100644 --- a/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidPipesComm.java +++ b/examples/androidlcl/android/src/com/pascal/androidlcl/AndroidPipesComm.java @@ -64,15 +64,27 @@ public class AndroidPipesComm public void PrintPascalException(byte Buffer) { String PascalMessage = "" + (char) Buffer; + byte curChar; try { while (true) { - PascalMessage = PascalMessage + (char) reader.readByte(); + curChar = reader.readByte(); + // Output line by line + if (curChar == 0x10) + { + ErrorOut(PascalMessage); + PascalMessage = ""; + } + else + { + PascalMessage = PascalMessage + (char) curChar; + } } } catch (IOException e) { + ErrorOut("[PrintPascalException] Exception while obtaining the Pascal Exception, printing the rest of the buffer"); ErrorOut(PascalMessage); } } @@ -122,7 +134,7 @@ public class AndroidPipesComm else if (MyAndroidApp.ProcessCommand(lSubtype) == true) ; else { - ErrorOut("Unknown UI Command!!!" + java.lang.Integer.toHexString(lSubtype)); + ErrorOut("Unknown UI Command!!! This is normal in the end of a callback" + java.lang.Integer.toHexString(lSubtype)); }; } else if (Buffer == amkJavaLangCall) @@ -139,7 +151,7 @@ public class AndroidPipesComm // } else { - ErrorOut("Unknown Pascal message!!! " + java.lang.Integer.toHexString(Buffer)); + ErrorOut("[WaitAndProcessPascalMessage] Unknown Pascal message!!! " + java.lang.Integer.toHexString(Buffer)); // If we get an Unknown Pascal message, it might be an error printed to the console, so lets print it and quit PrintPascalException(Buffer); diff --git a/examples/androidlcl/mainform.pas b/examples/androidlcl/mainform.pas index effd3c292..da8e07cab 100644 --- a/examples/androidlcl/mainform.pas +++ b/examples/androidlcl/mainform.pas @@ -72,7 +72,13 @@ end; procedure TForm2.Button2Click(Sender: TObject); begin + {$ifdef LCLAndroid} + vAndroidPipesComm.Log('TForm2.Button2Click'); + {$endif} InputBox('Caption', 'Prompt', 'Default'); + {$ifdef LCLAndroid} + vAndroidPipesComm.Log('TForm2.Button2Click'); + {$endif} end; initialization