You've already forked lazarus-ccr
androidlcl: Advances to implementing reading text values
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1818 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -67,6 +67,7 @@ public class AndroidAll
|
|||||||
static final int amkUI_TTextView_OnClickListener_Start = 0x0010A003;
|
static final int amkUI_TTextView_OnClickListener_Start = 0x0010A003;
|
||||||
static final int amkUI_TTextView_OnClickListener_Finished = 0x0010A004;
|
static final int amkUI_TTextView_OnClickListener_Finished = 0x0010A004;
|
||||||
static final int amkUI_TTextView_setTextSize = 0x0010A005;
|
static final int amkUI_TTextView_setTextSize = 0x0010A005;
|
||||||
|
static final int amkUI_TTextView_getText = 0x0010A006;
|
||||||
// EditText
|
// EditText
|
||||||
static final int amkUI_TEditText_Create = 0x0010B000;
|
static final int amkUI_TEditText_Create = 0x0010B000;
|
||||||
static final int amkUI_TEditText_setText = 0x0010B001;
|
static final int amkUI_TEditText_setText = 0x0010B001;
|
||||||
@ -145,6 +146,7 @@ public class AndroidAll
|
|||||||
float lResult_float;
|
float lResult_float;
|
||||||
int lResult_int;
|
int lResult_int;
|
||||||
boolean lResult_boolean;
|
boolean lResult_boolean;
|
||||||
|
CharSequence lResult_CharSequence;
|
||||||
Display lResult_Display;
|
Display lResult_Display;
|
||||||
|
|
||||||
switch (Buffer)
|
switch (Buffer)
|
||||||
@ -396,6 +398,17 @@ public class AndroidAll
|
|||||||
param_self_TextView.setTextSize(lint_1, lfloat_2);
|
param_self_TextView.setTextSize(lint_1, lfloat_2);
|
||||||
MyAndroidPipesComm.SendResult();
|
MyAndroidPipesComm.SendResult();
|
||||||
break;
|
break;
|
||||||
|
// method CharSequence getText()
|
||||||
|
case amkUI_TTextView_getText:
|
||||||
|
DebugOut("amkUI_TTextView_getText");
|
||||||
|
// Self
|
||||||
|
lInt = MyAndroidPipesComm.GetInt();
|
||||||
|
param_self_TextView = (TextView) ViewElements.get(lInt);
|
||||||
|
// params
|
||||||
|
//
|
||||||
|
lResult_CharSequence = param_self_TextView.getText();
|
||||||
|
MyAndroidPipesComm.SendStringResult(lResult_CharSequence);
|
||||||
|
break;
|
||||||
case amkUI_TEditText_Create:
|
case amkUI_TEditText_Create:
|
||||||
DebugOut("amkUI_TEditText_Create");
|
DebugOut("amkUI_TEditText_Create");
|
||||||
ViewElements.add(new EditText(activity));
|
ViewElements.add(new EditText(activity));
|
||||||
@ -598,7 +611,6 @@ public class AndroidAll
|
|||||||
DebugOut("amkUI_TArrayAdapter_String__Create");
|
DebugOut("amkUI_TArrayAdapter_String__Create");
|
||||||
lint_1 = MyAndroidPipesComm.GetInt();
|
lint_1 = MyAndroidPipesComm.GetInt();
|
||||||
ViewElements.add(new ArrayAdapter<String>(activity, lint_1));
|
ViewElements.add(new ArrayAdapter<String>(activity, lint_1));
|
||||||
DebugOut("Result = " + (ViewElements.size() - 1));
|
|
||||||
MyAndroidPipesComm.SendIntResult(ViewElements.size() - 1);
|
MyAndroidPipesComm.SendIntResult(ViewElements.size() - 1);
|
||||||
break;
|
break;
|
||||||
// method void add(String aobject)
|
// method void add(String aobject)
|
||||||
@ -619,7 +631,6 @@ public class AndroidAll
|
|||||||
DebugOut("amkUI_TArrayAdapter_String__clear");
|
DebugOut("amkUI_TArrayAdapter_String__clear");
|
||||||
// Self
|
// Self
|
||||||
lInt = MyAndroidPipesComm.GetInt();
|
lInt = MyAndroidPipesComm.GetInt();
|
||||||
DebugOut("lInt = " + lInt);
|
|
||||||
param_self_ArrayAdapter_String_ = (ArrayAdapter<String>) ViewElements.get(lInt);
|
param_self_ArrayAdapter_String_ = (ArrayAdapter<String>) ViewElements.get(lInt);
|
||||||
// params
|
// params
|
||||||
//
|
//
|
||||||
@ -631,7 +642,6 @@ public class AndroidAll
|
|||||||
DebugOut("amkUI_TArrayAdapter_String__insert");
|
DebugOut("amkUI_TArrayAdapter_String__insert");
|
||||||
// Self
|
// Self
|
||||||
lInt = MyAndroidPipesComm.GetInt();
|
lInt = MyAndroidPipesComm.GetInt();
|
||||||
DebugOut("lInt = " + lInt);
|
|
||||||
param_self_ArrayAdapter_String_ = (ArrayAdapter<String>) ViewElements.get(lInt);
|
param_self_ArrayAdapter_String_ = (ArrayAdapter<String>) ViewElements.get(lInt);
|
||||||
// params
|
// params
|
||||||
lInt = MyAndroidPipesComm.GetInt();
|
lInt = MyAndroidPipesComm.GetInt();
|
||||||
|
@ -23,9 +23,10 @@ public class AndroidPipesComm
|
|||||||
int lSubtype = 0;
|
int lSubtype = 0;
|
||||||
|
|
||||||
// Android Message Kind
|
// Android Message Kind
|
||||||
static byte amkFloatResult = 103;
|
static byte amkStringResult = 14;
|
||||||
static byte amkIntResult = 102;
|
static byte amkFloatResult = 13;
|
||||||
static byte amkResult = 101;
|
static byte amkIntResult = 12;
|
||||||
|
static byte amkResult = 11;
|
||||||
static byte amkActivityCallback = 0;
|
static byte amkActivityCallback = 0;
|
||||||
static byte amkLog = 1;
|
static byte amkLog = 1;
|
||||||
static byte amkUICommand = 2;
|
static byte amkUICommand = 2;
|
||||||
@ -110,12 +111,7 @@ public class AndroidPipesComm
|
|||||||
else if (Buffer == amkLog)
|
else if (Buffer == amkLog)
|
||||||
{
|
{
|
||||||
DebugOut("amkLog");
|
DebugOut("amkLog");
|
||||||
int lInt = GetInt(); // Length
|
char[] lChars = GetString();
|
||||||
char[] lChars = new char[lInt];
|
|
||||||
for (int i = 0; i < lInt; i++)
|
|
||||||
{
|
|
||||||
lChars[i] = (char) GetByte();
|
|
||||||
}
|
|
||||||
DebugOut(new String(lChars));
|
DebugOut(new String(lChars));
|
||||||
}
|
}
|
||||||
else if (Buffer == amkUICommand)
|
else if (Buffer == amkUICommand)
|
||||||
@ -217,6 +213,26 @@ public class AndroidPipesComm
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public char[] GetString()
|
||||||
|
{
|
||||||
|
char[] lChars;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int lInt = reader.readInt(); // Length
|
||||||
|
lChars = new char[lInt];
|
||||||
|
for (int i = 0; i < lInt; i++)
|
||||||
|
{
|
||||||
|
lChars[i] = (char) reader.readByte();
|
||||||
|
}
|
||||||
|
return lChars;
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
ErrorOut("[GetString] IOException=" + e.getMessage());
|
||||||
|
}
|
||||||
|
return new char[0];
|
||||||
|
}
|
||||||
|
|
||||||
// Sending results
|
// Sending results
|
||||||
|
|
||||||
public void SendResult()
|
public void SendResult()
|
||||||
@ -258,6 +274,24 @@ public class AndroidPipesComm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendStringResult(CharSequence Result)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
writer.writeByte(amkStringResult);
|
||||||
|
int lInt = Result.length();
|
||||||
|
writer.writeInt(lInt); // Length
|
||||||
|
for (int i = 0; i < lInt; i++)
|
||||||
|
{
|
||||||
|
writer.writeByte(Result.charAt(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
ErrorOut("[SendStringResult] IOException=" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Sending data
|
// Sending data
|
||||||
|
|
||||||
// Convenience routine, uses SendIntResult
|
// Convenience routine, uses SendIntResult
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<MacroValues Count="1">
|
<MacroValues Count="1">
|
||||||
<Macro1 Name="LCLWidgetType" Value="android"/>
|
<Macro1 Name="LCLWidgetType" Value="android"/>
|
||||||
</MacroValues>
|
</MacroValues>
|
||||||
<BuildModes Count="3">
|
<BuildModes Count="4">
|
||||||
<Item1 Name="Android" Default="True"/>
|
<Item1 Name="Android" Default="True"/>
|
||||||
<Item2 Name="Desktop">
|
<Item2 Name="Desktop">
|
||||||
<MacroValues Count="1">
|
<MacroValues Count="1">
|
||||||
@ -75,6 +75,42 @@
|
|||||||
</Other>
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
</Item3>
|
</Item3>
|
||||||
|
<Item4 Name="Android-Debug">
|
||||||
|
<MacroValues Count="1">
|
||||||
|
<Macro1 Name="LCLWidgetType" Value="android"/>
|
||||||
|
</MacroValues>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="10"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="android/libs/armeabi/libandroidlcltest.so"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<CodeGeneration>
|
||||||
|
<TargetCPU Value="arm"/>
|
||||||
|
<TargetOS Value="linux"/>
|
||||||
|
</CodeGeneration>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<GenerateDebugInfo Value="True"/>
|
||||||
|
<GenerateDwarf Value="True"/>
|
||||||
|
</Debugging>
|
||||||
|
<Options>
|
||||||
|
<Win32>
|
||||||
|
<GraphicApplication Value="True"/>
|
||||||
|
</Win32>
|
||||||
|
</Options>
|
||||||
|
</Linking>
|
||||||
|
<Other>
|
||||||
|
<CompilerMessages>
|
||||||
|
<UseMsgFile Value="True"/>
|
||||||
|
</CompilerMessages>
|
||||||
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
|
</Other>
|
||||||
|
</CompilerOptions>
|
||||||
|
</Item4>
|
||||||
</BuildModes>
|
</BuildModes>
|
||||||
<PublishOptions>
|
<PublishOptions>
|
||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
|
@ -13,6 +13,7 @@ object Form2: TForm2
|
|||||||
Top = 35
|
Top = 35
|
||||||
Width = 87
|
Width = 87
|
||||||
Caption = 'Button1'
|
Caption = 'Button1'
|
||||||
|
OnClick = Button1Click
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object CheckBox1: TCheckBox
|
object CheckBox1: TCheckBox
|
||||||
@ -53,4 +54,12 @@ object Form2: TForm2
|
|||||||
TabOrder = 4
|
TabOrder = 4
|
||||||
Text = 'ComboBox1'
|
Text = 'ComboBox1'
|
||||||
end
|
end
|
||||||
|
object Edit2: TEdit
|
||||||
|
Left = 147
|
||||||
|
Height = 25
|
||||||
|
Top = 144
|
||||||
|
Width = 80
|
||||||
|
TabOrder = 5
|
||||||
|
Text = 'Edit2'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,9 @@ type
|
|||||||
CheckBox1: TCheckBox;
|
CheckBox1: TCheckBox;
|
||||||
ComboBox1: TComboBox;
|
ComboBox1: TComboBox;
|
||||||
Edit1: TEdit;
|
Edit1: TEdit;
|
||||||
|
Edit2: TEdit;
|
||||||
StaticText1: TStaticText;
|
StaticText1: TStaticText;
|
||||||
|
procedure Button1Click(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
public
|
public
|
||||||
@ -29,6 +31,35 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$ifdef LCLAndroid}
|
||||||
|
uses androidpipescomm;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
{ TForm2 }
|
||||||
|
|
||||||
|
procedure TForm2.Button1Click(Sender: TObject);
|
||||||
|
var
|
||||||
|
lChecked, lEdit1Text: String;
|
||||||
|
lComboBox: String;
|
||||||
|
begin
|
||||||
|
if CheckBox1.Checked then lChecked := 'True'
|
||||||
|
else lChecked := 'False';
|
||||||
|
|
||||||
|
vAndroidPipesComm.Log('3');
|
||||||
|
lEdit1Text := Edit1.Text;
|
||||||
|
|
||||||
|
vAndroidPipesComm.Log('4');
|
||||||
|
lComboBox := IntToStr(ComboBox1.ItemIndex);
|
||||||
|
|
||||||
|
vAndroidPipesComm.Log('5');
|
||||||
|
|
||||||
|
Edit2.Text :=
|
||||||
|
'Edit1.Text='+lEdit1Text+LineEnding+
|
||||||
|
'Caption='+Caption+LineEnding+
|
||||||
|
'Checked?='+lChecked+LineEnding+
|
||||||
|
'ComboBox='+lComboBox;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
{$I mainform.lrs}
|
{$I mainform.lrs}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user