added a simple android test application (using xamarin)

This commit is contained in:
Alexander Eckart committed 2013-05-05 17:03:12 +02:00
1 parent eb9e17d2e6
commit 0a4d1ebe61
11 files changed
+597

No files matched your search

+6
View File
@@ -46,3 +46,9 @@ Output/Songs
/ClientServerLib/ClientServerLib/bin/ClientServerLib.dll
ClientTest.exe
*.vshost.*
*.userprefs
AndroidRemote.dll.mdb
/ClientServerLib/AndroidRemote/bin/Newtonsoft.Json.MonoDroid.dll
/ClientServerLib/ClientServerLib/bin/Newtonsoft.Json.dll
/ClientServerLib/AndroidRemote/bin/AndroidRemote.dll
/ClientServerLib/ClientTest/bin/Debug/Newtonsoft.Json.dll
+20
View File
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroidRemote", "AndroidRemote\AndroidRemote.csproj", "{D97EF6F3-7C3F-439F-B022-647948E206D2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D97EF6F3-7C3F-439F-B022-647948E206D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D97EF6F3-7C3F-439F-B022-647948E206D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D97EF6F3-7C3F-439F-B022-647948E206D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D97EF6F3-7C3F-439F-B022-647948E206D2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = AndroidRemote.csproj
EndGlobalSection
EndGlobal
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D97EF6F3-7C3F-439F-B022-647948E206D2}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>AndroidRemote</RootNamespace>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AssemblyName>AndroidRemote</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;MONO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AndroidLinkMode>None</AndroidLinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<ConsolePause>false</ConsolePause>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<DefineConstants>MONO</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Mono.Android" />
<Reference Include="Newtonsoft.Json.MonoDroid">
<HintPath>Newtonsoft.Json.MonoDroid.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="..\ClientServerLib\CClient.cs">
<Link>ClientServerLib\CClient.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\CConnection.cs">
<Link>ClientServerLib\CConnection.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\Structs.cs">
<Link>ClientServerLib\Structs.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\BigInt.cs">
<Link>ClientServerLib\DeffieHellman\BigInt.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\DeffieHellman.cs">
<Link>ClientServerLib\DeffieHellman\DeffieHellman.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\DeffieHellman\StrongNumberProvider.cs">
<Link>ClientServerLib\DeffieHellman\StrongNumberProvider.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\Vocaluxe\CCommands.cs">
<Link>ClientServerLib\Vocaluxe\CCommands.cs</Link>
</Compile>
<Compile Include="..\ClientServerLib\Vocaluxe\VocaluxeStructs.cs">
<Link>ClientServerLib\Vocaluxe\VocaluxeStructs.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
<None Include="Assets\AboutAssets.txt" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\Main.axml" />
<AndroidResource Include="Resources\values\Strings.xml" />
<AndroidResource Include="Resources\drawable\Icon.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<ItemGroup>
<Folder Include="ClientServerLib\" />
</ItemGroup>
</Project>
@@ -0,0 +1,143 @@
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using ClientServerLib;
using Vocaluxe.Base.Server;
namespace AndroidRemote
{
[Activity (Label = "Vocaluxe Remote", MainLauncher = true)]
public class Activity1 : Activity
{
CClient client = new CClient();
Button bConnect;
Button bLogin;
Button bUp;
Button bDown;
bool loggedIn;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
loggedIn = false;
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
bConnect = FindViewById<Button> (Resource.Id.btConnect);
bConnect.Click += delegate { Connect(); };
bLogin = FindViewById<Button> (Resource.Id.btLogin);
bLogin.Click += delegate { Login(); };
bUp = FindViewById<Button> (Resource.Id.btUp);
bUp.Click += delegate {
client.SendMessage (CCommands.CreateCommandWithoutParams (CCommands.CommandSendKeyUp), OnResponse);
};
bDown = FindViewById<Button> (Resource.Id.btDown);
bDown.Click += delegate {
client.SendMessage (CCommands.CreateCommandWithoutParams (CCommands.CommandSendKeyDown), OnResponse);
};
}
protected override void OnStop ()
{
base.OnStop();
client.Close();
}
private void Connect()
{
if (!client.Connected)
client.Connect("192.168.178.57", 3000, OnConnectionChanged);
else
client.Disconnect();
}
private void Login()
{
if (!loggedIn)
client.SendMessage (CCommands.CreateCommandLogin("vocaluxe"), OnResponse);
else
client.Disconnect();
}
private void OnConnectionChanged(bool Connected)
{
RunOnUiThread (() => UpdateConnectionStatus(Connected));
}
private void OnResponse(byte[] Message)
{
if (Message == null)
return;
if (Message.Length < 4)
return;
int command = BitConverter.ToInt32(Message, 0);
switch (command)
{
case CCommands.ResponseLoginFailed:
RunOnUiThread (() => Toast.MakeText(this, "Login Failed", ToastLength.Short).Show());
break;
case CCommands.ResponseLoginWrongPassword:
RunOnUiThread (() => Toast.MakeText(this, "Wrong Password", ToastLength.Short).Show());
break;
case CCommands.ResponseLoginOK:
RunOnUiThread (() => UpdateLoginStatus(true));
break;
default:
break;
}
}
private void UpdateConnectionStatus(bool Connected)
{
if (Connected)
{
bLogin.Enabled = true;
bConnect.Text = Resources.GetString(Resource.String.button_disconnect);
Toast.MakeText(this, Resource.String.message_connected, ToastLength.Short).Show();
}
else
{
client.Disconnect();
bLogin.Enabled = false;
bLogin.Text = Resources.GetString(Resource.String.button_login);
bConnect.Text = Resources.GetString(Resource.String.button_connect);
bUp.Enabled = false;
bDown.Enabled = false;
Toast.MakeText(this, Resources.GetString(Resource.String.message_disconnected), ToastLength.Short).Show();
}
}
private void UpdateLoginStatus(bool LoggedIn)
{
loggedIn = LoggedIn;
if (LoggedIn)
{
bUp.Enabled = LoggedIn;
bDown.Enabled = LoggedIn;
bLogin.Text = Resources.GetString(Resource.String.button_logout);
Toast.MakeText(this, "Logged In", ToastLength.Short).Show();
}
else
Toast.MakeText(this, "Not Logged In", ToastLength.Short).Show();
}
}
}
@@ -0,0 +1,28 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using Android.App;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("AndroidRemote")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Alex")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
@@ -0,0 +1,44 @@
Images, layout descriptions, binary blobs and string dictionaries can be included
in your application as resource files. Various Android APIs are designed to
operate on the resource IDs instead of dealing with images, strings or binary blobs
directly.
For example, a sample Android app that contains a user interface layout (main.axml),
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
would keep its resources in the "Resources" directory of the application:
Resources/
drawable/
icon.png
layout/
main.axml
values/
strings.xml
In order to get the build system to recognize Android resources, set the build action to
"AndroidResource". The native Android APIs do not operate directly with filenames, but
instead operate on resource IDs. When you compile an Android application that uses resources,
the build system will package the resources for distribution and generate a class called "R"
(this is an Android convention) that contains the tokens for each one of the resources
included. For example, for the above Resources layout, this is what the R class would expose:
public class R {
public class drawable {
public const int icon = 0x123;
}
public class layout {
public const int main = 0x456;
}
public class strings {
public const int first_string = 0xabc;
public const int second_string = 0xbcd;
}
}
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
to reference the layout/main.axml file, or R.strings.first_string to reference the first
string in the dictionary file values/strings.xml.
@@ -0,0 +1,194 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.18034
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: global::Android.Runtime.ResourceDesignerAttribute("AndroidRemote.Resource", IsApplication=true)]
namespace AndroidRemote
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource
{
static Resource()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
public static void UpdateIdValues()
{
}
public partial class Attribute
{
static Attribute()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Attribute()
{
}
}
public partial class Drawable
{
// aapt resource value: 0x7f020000
public const int Icon = 2130837504;
// aapt resource value: 0x7f020001
public const int monoandroidsplash = 2130837505;
static Drawable()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Drawable()
{
}
}
public partial class Id
{
// aapt resource value: 0x7f060002
public const int btConnect = 2131099650;
// aapt resource value: 0x7f060007
public const int btDown = 2131099655;
// aapt resource value: 0x7f060005
public const int btLogin = 2131099653;
// aapt resource value: 0x7f060006
public const int btUp = 2131099654;
// aapt resource value: 0x7f060001
public const int tbIP = 2131099649;
// aapt resource value: 0x7f060004
public const int tbPassword = 2131099652;
// aapt resource value: 0x7f060000
public const int textView1 = 2131099648;
// aapt resource value: 0x7f060003
public const int textView2 = 2131099651;
static Id()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Id()
{
}
}
public partial class Layout
{
// aapt resource value: 0x7f030000
public const int Main = 2130903040;
// aapt resource value: 0x7f030001
public const int monoandroidsplash = 2130903041;
static Layout()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Layout()
{
}
}
public partial class String
{
// aapt resource value: 0x7f040000
public const int app_name = 2130968576;
// aapt resource value: 0x7f040001
public const int button_connect = 2130968577;
// aapt resource value: 0x7f040002
public const int button_disconnect = 2130968578;
// aapt resource value: 0x7f040006
public const int button_down = 2130968582;
// aapt resource value: 0x7f040003
public const int button_login = 2130968579;
// aapt resource value: 0x7f040004
public const int button_logout = 2130968580;
// aapt resource value: 0x7f040005
public const int button_up = 2130968581;
// aapt resource value: 0x7f04000d
public const int ip_address = 2130968589;
// aapt resource value: 0x7f040007
public const int message_connected = 2130968583;
// aapt resource value: 0x7f040008
public const int message_disconnected = 2130968584;
// aapt resource value: 0x7f040009
public const int message_logged_in = 2130968585;
// aapt resource value: 0x7f04000a
public const int message_logged_out = 2130968586;
// aapt resource value: 0x7f04000e
public const int password = 2130968590;
// aapt resource value: 0x7f04000b
public const int text_ip_address = 2130968587;
// aapt resource value: 0x7f04000c
public const int text_password = 2130968588;
static String()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private String()
{
}
}
public partial class Style
{
// aapt resource value: 0x7f050000
public const int Mono_Android_Theme_Splash = 2131034112;
static Style()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Style()
{
}
}
}
}
#pragma warning restore 1591
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text="@string/text_ip_address"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:linksClickable="false" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tbIP"
android:text="@string/ip_address" />
<Button
android:text="@string/button_connect"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btConnect" />
<TextView
android:text="@string/text_password"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/textView2" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/tbPassword"
android:text="@string/password" />
<Button
android:text="@string/button_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btLogin"
android:enabled="false" />
<Button
android:text="@string/button_up"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btUp"
android:enabled="false" />
<Button
android:text="@string/button_down"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btDown"
android:enabled="false" />
</LinearLayout>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">AndroidRemote</string>
<string name="button_connect">Connect</string>
<string name="button_disconnect">Disconnect</string>
<string name="button_login">Login</string>
<string name="button_logout">Logout</string>
<string name="button_up">Up</string>
<string name="button_down">Down</string>
<string name="message_connected">Connected</string>
<string name="message_disconnected">Disconnected</string>
<string name="message_logged_in">Logged in</string>
<string name="message_logged_out">Logged out</string>
<string name="text_ip_address">IP Address of Vocaluxe Server:</string>
<string name="text_password">Password:</string>
<string name="ip_address">192.168.178.57</string>
<string name="password">vocaluxe</string>
</resources>