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
+109 -70

No files matched your search

+46 -22
View File
@@ -16,15 +16,14 @@ using Vocaluxe.Base.Server;
namespace AndroidRemote
{
[Activity (Label = "Vocaluxe Remote", MainLauncher = true)]
[Activity (Label = "Vocaluxe Remote", MainLauncher = true, ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation)]
public class Activity1 : Activity
{
CClient client = new CClient();
Button bConnect;
Button bLogin;
Button bUp;
Button bDown;
Button bSendAvatar;
Button bSendProfile;
bool loggedIn;
byte[] fileBytes;
@@ -32,6 +31,8 @@ namespace AndroidRemote
Java.IO.File file;
Java.IO.File dir;
System.IO.FileStream fs;
bool sendProfile;
protected override void OnCreate (Bundle bundle)
{
@@ -47,21 +48,14 @@ namespace AndroidRemote
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);
};
imageView = FindViewById<ImageView>(Resource.Id.imageView1);
bSendAvatar = FindViewById<Button> (Resource.Id.btSendAvatar);
bSendAvatar.Click += SendAvatar;
bSendProfile = FindViewById<Button> (Resource.Id.btSendProfile);
bSendProfile.Click += SendProfile;
sendProfile = false;
}
protected override void OnStop ()
@@ -92,7 +86,19 @@ namespace AndroidRemote
fs.Flush();
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()
@@ -118,6 +124,12 @@ namespace AndroidRemote
intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(file));
StartActivityForResult(intent, 0);
}
private void SendProfile(object sender, EventArgs eventArgs)
{
sendProfile = true;
SendAvatar(sender, eventArgs);
}
private void Connect()
{
@@ -152,16 +164,24 @@ namespace AndroidRemote
switch (command)
{
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;
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;
case CCommands.ResponseLoginOK:
RunOnUiThread (() => UpdateLoginStatus(true));
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:
break;
@@ -182,8 +202,8 @@ namespace AndroidRemote
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;
bSendAvatar.Enabled = false;
bSendProfile.Enabled = false;
Toast.MakeText(this, Resources.GetString(Resource.String.message_disconnected), ToastLength.Short).Show();
}
}
@@ -194,13 +214,17 @@ namespace AndroidRemote
if (LoggedIn)
{
bUp.Enabled = LoggedIn;
bDown.Enabled = LoggedIn;
bLogin.Text = Resources.GetString(Resource.String.button_logout);
Toast.MakeText(this, "Logged In", ToastLength.Short).Show();
bSendAvatar.Enabled = true;
bSendProfile.Enabled = true;
}
else
{
Toast.MakeText(this, "Not Logged In", ToastLength.Short).Show();
bSendAvatar.Enabled = false;
bSendProfile.Enabled = false;
}
}
}