added SendProfile to the android test app, fixed some bugs

This commit is contained in:
Alexander Eckart committed 2013-05-09 23:58:48 +02:00
1 parent 1a68c26e9f
commit 2f1795d9a3
6 files changed
+108 -69

No files matched your search

+46 -22
View File
@@ -16,15 +16,14 @@ using Vocaluxe.Base.Server;
namespace AndroidRemote namespace AndroidRemote
{ {
[Activity (Label = "Vocaluxe Remote", MainLauncher = true)] [Activity (Label = "Vocaluxe Remote", MainLauncher = true, ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation)]
public class Activity1 : Activity public class Activity1 : Activity
{ {
CClient client = new CClient(); CClient client = new CClient();
Button bConnect; Button bConnect;
Button bLogin; Button bLogin;
Button bUp;
Button bDown;
Button bSendAvatar; Button bSendAvatar;
Button bSendProfile;
bool loggedIn; bool loggedIn;
byte[] fileBytes; byte[] fileBytes;
@@ -33,6 +32,8 @@ namespace AndroidRemote
Java.IO.File dir; Java.IO.File dir;
System.IO.FileStream fs; System.IO.FileStream fs;
bool sendProfile;
protected override void OnCreate (Bundle bundle) protected override void OnCreate (Bundle bundle)
{ {
base.OnCreate (bundle); base.OnCreate (bundle);
@@ -48,20 +49,13 @@ namespace AndroidRemote
bLogin = FindViewById<Button> (Resource.Id.btLogin); bLogin = FindViewById<Button> (Resource.Id.btLogin);
bLogin.Click += delegate { Login(); }; 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);
};
imageView = FindViewById<ImageView>(Resource.Id.imageView1);
bSendAvatar = FindViewById<Button> (Resource.Id.btSendAvatar); bSendAvatar = FindViewById<Button> (Resource.Id.btSendAvatar);
bSendAvatar.Click += SendAvatar; bSendAvatar.Click += SendAvatar;
bSendProfile = FindViewById<Button> (Resource.Id.btSendProfile);
bSendProfile.Click += SendProfile;
sendProfile = false;
} }
protected override void OnStop () protected override void OnStop ()
@@ -92,7 +86,19 @@ namespace AndroidRemote
fs.Flush(); fs.Flush();
fs.Close(); fs.Close();
client.SendMessage (CCommands.CreateCommandSendAvatarPictureJpg(fileBytes), OnResponse);
if (sendProfile)
{
sendProfile = false;
TextView tv = FindViewById<TextView>(Resource.Id.tbPlayerName);
if (tv.Text == String.Empty)
return;
client.SendMessage (CCommands.CreateCommandSendProfile(fileBytes, tv.Text, 0), OnResponse);
}
else
client.SendMessage (CCommands.CreateCommandSendAvatarPictureJpg(fileBytes), OnResponse);
} }
private bool IsThereAnAppToTakePictures() private bool IsThereAnAppToTakePictures()
@@ -119,6 +125,12 @@ namespace AndroidRemote
StartActivityForResult(intent, 0); StartActivityForResult(intent, 0);
} }
private void SendProfile(object sender, EventArgs eventArgs)
{
sendProfile = true;
SendAvatar(sender, eventArgs);
}
private void Connect() private void Connect()
{ {
if (!client.Connected) if (!client.Connected)
@@ -152,17 +164,25 @@ namespace AndroidRemote
switch (command) switch (command)
{ {
case CCommands.ResponseLoginFailed: case CCommands.ResponseLoginFailed:
RunOnUiThread (() => Toast.MakeText(this, "Login Failed", ToastLength.Short).Show()); RunOnUiThread (() => Toast.MakeText(this, Resources.GetString(Resource.String.message_login_failed), ToastLength.Short).Show());
break; break;
case CCommands.ResponseLoginWrongPassword: case CCommands.ResponseLoginWrongPassword:
RunOnUiThread (() => Toast.MakeText(this, "Wrong Password", ToastLength.Short).Show()); RunOnUiThread (() => Toast.MakeText(this, Resources.GetString(Resource.String.message_wrong_password), ToastLength.Short).Show());
break; break;
case CCommands.ResponseLoginOK: case CCommands.ResponseLoginOK:
RunOnUiThread (() => UpdateLoginStatus(true)); RunOnUiThread (() => UpdateLoginStatus(true));
break; break;
case CCommands.ResponseOK:
RunOnUiThread (() => Toast.MakeText(this, Resources.GetString(Resource.String.message_ok), ToastLength.Short).Show());
break;
case CCommands.ResponseNOK:
RunOnUiThread (() => Toast.MakeText(this, Resources.GetString(Resource.String.message_nok), ToastLength.Short).Show());
break;
default: default:
break; break;
} }
@@ -182,8 +202,8 @@ namespace AndroidRemote
bLogin.Enabled = false; bLogin.Enabled = false;
bLogin.Text = Resources.GetString(Resource.String.button_login); bLogin.Text = Resources.GetString(Resource.String.button_login);
bConnect.Text = Resources.GetString(Resource.String.button_connect); bConnect.Text = Resources.GetString(Resource.String.button_connect);
bUp.Enabled = false; bSendAvatar.Enabled = false;
bDown.Enabled = false; bSendProfile.Enabled = false;
Toast.MakeText(this, Resources.GetString(Resource.String.message_disconnected), ToastLength.Short).Show(); Toast.MakeText(this, Resources.GetString(Resource.String.message_disconnected), ToastLength.Short).Show();
} }
} }
@@ -194,13 +214,17 @@ namespace AndroidRemote
if (LoggedIn) if (LoggedIn)
{ {
bUp.Enabled = LoggedIn;
bDown.Enabled = LoggedIn;
bLogin.Text = Resources.GetString(Resource.String.button_logout); bLogin.Text = Resources.GetString(Resource.String.button_logout);
Toast.MakeText(this, "Logged In", ToastLength.Short).Show(); Toast.MakeText(this, "Logged In", ToastLength.Short).Show();
bSendAvatar.Enabled = true;
bSendProfile.Enabled = true;
} }
else else
{
Toast.MakeText(this, "Not Logged In", ToastLength.Short).Show(); Toast.MakeText(this, "Not Logged In", ToastLength.Short).Show();
bSendAvatar.Enabled = false;
bSendProfile.Enabled = false;
}
} }
} }
+39 -27
View File
@@ -66,20 +66,14 @@ namespace AndroidRemote
// aapt resource value: 0x7f060002 // aapt resource value: 0x7f060002
public const int btConnect = 2131099650; public const int btConnect = 2131099650;
// aapt resource value: 0x7f060007
public const int btDown = 2131099655;
// aapt resource value: 0x7f060005 // aapt resource value: 0x7f060005
public const int btLogin = 2131099653; public const int btLogin = 2131099653;
// aapt resource value: 0x7f060008
public const int btSendAvatar = 2131099656;
// aapt resource value: 0x7f060006 // aapt resource value: 0x7f060006
public const int btUp = 2131099654; public const int btSendAvatar = 2131099654;
// aapt resource value: 0x7f060009 // aapt resource value: 0x7f060009
public const int imageView1 = 2131099657; public const int btSendProfile = 2131099657;
// aapt resource value: 0x7f060001 // aapt resource value: 0x7f060001
public const int tbIP = 2131099649; public const int tbIP = 2131099649;
@@ -87,12 +81,18 @@ namespace AndroidRemote
// aapt resource value: 0x7f060004 // aapt resource value: 0x7f060004
public const int tbPassword = 2131099652; public const int tbPassword = 2131099652;
// aapt resource value: 0x7f060008
public const int tbPlayerName = 2131099656;
// aapt resource value: 0x7f060000 // aapt resource value: 0x7f060000
public const int textView1 = 2131099648; public const int textView1 = 2131099648;
// aapt resource value: 0x7f060003 // aapt resource value: 0x7f060003
public const int textView2 = 2131099651; public const int textView2 = 2131099651;
// aapt resource value: 0x7f060007
public const int textView3 = 2131099655;
static Id() static Id()
{ {
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); global::Android.Runtime.ResourceIdManager.UpdateIdValues();
@@ -134,44 +134,56 @@ namespace AndroidRemote
// aapt resource value: 0x7f040002 // aapt resource value: 0x7f040002
public const int button_disconnect = 2130968578; public const int button_disconnect = 2130968578;
// aapt resource value: 0x7f040006
public const int button_down = 2130968582;
// aapt resource value: 0x7f040003 // aapt resource value: 0x7f040003
public const int button_login = 2130968579; public const int button_login = 2130968579;
// aapt resource value: 0x7f040004 // aapt resource value: 0x7f040004
public const int button_logout = 2130968580; public const int button_logout = 2130968580;
// aapt resource value: 0x7f040007
public const int button_send_avatar = 2130968583;
// aapt resource value: 0x7f040005 // aapt resource value: 0x7f040005
public const int button_up = 2130968581; public const int button_send_avatar = 2130968581;
// aapt resource value: 0x7f04000e // aapt resource value: 0x7f040006
public const int ip_address = 2130968590; public const int button_send_profile = 2130968582;
// aapt resource value: 0x7f040012
public const int ip_address = 2130968594;
// aapt resource value: 0x7f040007
public const int message_connected = 2130968583;
// aapt resource value: 0x7f040008 // aapt resource value: 0x7f040008
public const int message_connected = 2130968584; public const int message_disconnected = 2130968584;
// aapt resource value: 0x7f040009 // aapt resource value: 0x7f040009
public const int message_disconnected = 2130968585; public const int message_logged_in = 2130968585;
// aapt resource value: 0x7f04000a // aapt resource value: 0x7f04000a
public const int message_logged_in = 2130968586; public const int message_logged_out = 2130968586;
// aapt resource value: 0x7f04000b // aapt resource value: 0x7f04000b
public const int message_logged_out = 2130968587; public const int message_login_failed = 2130968587;
// aapt resource value: 0x7f04000f // aapt resource value: 0x7f04000e
public const int password = 2130968591; public const int message_nok = 2130968590;
// aapt resource value: 0x7f04000c
public const int text_ip_address = 2130968588;
// aapt resource value: 0x7f04000d // aapt resource value: 0x7f04000d
public const int text_password = 2130968589; public const int message_ok = 2130968589;
// aapt resource value: 0x7f04000c
public const int message_wrong_password = 2130968588;
// aapt resource value: 0x7f040013
public const int password = 2130968595;
// aapt resource value: 0x7f04000f
public const int text_ip_address = 2130968591;
// aapt resource value: 0x7f040010
public const int text_password = 2130968592;
// aapt resource value: 0x7f040011
public const int text_player_name = 2130968593;
static String() static String()
{ {
@@ -37,27 +37,26 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/btLogin" android:id="@+id/btLogin"
android:enabled="false" /> 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" />
<Button <Button
android:text="@string/button_send_avatar" android:text="@string/button_send_avatar"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/btSendAvatar" android:id="@+id/btSendAvatar"
android:enabled="true" /> android:enabled="false" />
<ImageView <TextView
android:src="@android:drawable/ic_menu_gallery" android:text="@string/text_player_name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:id="@+id/imageView1" /> android:id="@+id/textView3" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/tbPlayerName" />
<Button
android:text="@string/button_send_profile"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btSendProfile"
android:enabled="false" />
</LinearLayout> </LinearLayout>
@@ -5,15 +5,19 @@
<string name="button_disconnect">Disconnect</string> <string name="button_disconnect">Disconnect</string>
<string name="button_login">Login</string> <string name="button_login">Login</string>
<string name="button_logout">Logout</string> <string name="button_logout">Logout</string>
<string name="button_up">Up</string>
<string name="button_down">Down</string>
<string name="button_send_avatar">Send Avatar Picture</string> <string name="button_send_avatar">Send Avatar Picture</string>
<string name="button_send_profile">Send Profile</string>
<string name="message_connected">Connected</string> <string name="message_connected">Connected</string>
<string name="message_disconnected">Disconnected</string> <string name="message_disconnected">Disconnected</string>
<string name="message_logged_in">Logged in</string> <string name="message_logged_in">Logged in</string>
<string name="message_logged_out">Logged out</string> <string name="message_logged_out">Logged out</string>
<string name="message_login_failed">Login failed</string>
<string name="message_wrong_password">Wrong Password</string>
<string name="message_ok">Success</string>
<string name="message_nok">Error</string>
<string name="text_ip_address">IP Address of Vocaluxe Server:</string> <string name="text_ip_address">IP Address of Vocaluxe Server:</string>
<string name="text_password">Password:</string> <string name="text_password">Password:</string>
<string name="text_player_name">Player Name:</string>
<string name="ip_address">192.168.178.57</string> <string name="ip_address">192.168.178.57</string>
<string name="password">vocaluxe</string> <string name="password">vocaluxe</string>
</resources> </resources>
+1
View File
@@ -134,6 +134,7 @@ namespace Vocaluxe.Base
change.Profile.ID = _ProfileIDs.Dequeue(); change.Profile.ID = _ProfileIDs.Dequeue();
change.Profile.Avatar = _GetAvatar(change.Profile.AvatarFileName); change.Profile.Avatar = _GetAvatar(change.Profile.AvatarFileName);
change.Profile.SaveProfile();
_Profiles.Add(change.Profile.ID, change.Profile); _Profiles.Add(change.Profile.ID, change.Profile);
_ProfilesChanged = true; _ProfilesChanged = true;
-1
View File
@@ -169,7 +169,6 @@ namespace Vocaluxe.Base.Server
p.Difficulty = (EGameDifficulty)profile.Difficulty; p.Difficulty = (EGameDifficulty)profile.Difficulty;
p.GuestProfile = EOffOn.TR_CONFIG_OFF; p.GuestProfile = EOffOn.TR_CONFIG_OFF;
p.PlayerName = profile.PlayerName; p.PlayerName = profile.PlayerName;
p.SaveProfile();
CProfiles.AddProfile(p); CProfiles.AddProfile(p);
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK); answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK);
} }