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;
}
}
}
+39 -27
View File
@@ -66,20 +66,14 @@ namespace AndroidRemote
// 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: 0x7f060008
public const int btSendAvatar = 2131099656;
// aapt resource value: 0x7f060006
public const int btUp = 2131099654;
public const int btSendAvatar = 2131099654;
// aapt resource value: 0x7f060009
public const int imageView1 = 2131099657;
public const int btSendProfile = 2131099657;
// aapt resource value: 0x7f060001
public const int tbIP = 2131099649;
@@ -87,12 +81,18 @@ namespace AndroidRemote
// aapt resource value: 0x7f060004
public const int tbPassword = 2131099652;
// aapt resource value: 0x7f060008
public const int tbPlayerName = 2131099656;
// aapt resource value: 0x7f060000
public const int textView1 = 2131099648;
// aapt resource value: 0x7f060003
public const int textView2 = 2131099651;
// aapt resource value: 0x7f060007
public const int textView3 = 2131099655;
static Id()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
@@ -134,44 +134,56 @@ namespace AndroidRemote
// 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: 0x7f040007
public const int button_send_avatar = 2130968583;
// aapt resource value: 0x7f040005
public const int button_up = 2130968581;
public const int button_send_avatar = 2130968581;
// aapt resource value: 0x7f04000e
public const int ip_address = 2130968590;
// aapt resource value: 0x7f040006
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
public const int message_connected = 2130968584;
public const int message_disconnected = 2130968584;
// aapt resource value: 0x7f040009
public const int message_disconnected = 2130968585;
public const int message_logged_in = 2130968585;
// aapt resource value: 0x7f04000a
public const int message_logged_in = 2130968586;
public const int message_logged_out = 2130968586;
// aapt resource value: 0x7f04000b
public const int message_logged_out = 2130968587;
public const int message_login_failed = 2130968587;
// aapt resource value: 0x7f04000f
public const int password = 2130968591;
// aapt resource value: 0x7f04000c
public const int text_ip_address = 2130968588;
// aapt resource value: 0x7f04000e
public const int message_nok = 2130968590;
// 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()
{
@@ -37,27 +37,26 @@
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" />
<Button
android:text="@string/button_send_avatar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/btSendAvatar"
android:enabled="true" />
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:enabled="false" />
<TextView
android:text="@string/text_player_name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="@+id/imageView1" />
android:layout_height="wrap_content"
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>
@@ -5,15 +5,19 @@
<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="button_send_avatar">Send Avatar Picture</string>
<string name="button_send_profile">Send Profile</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="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_password">Password:</string>
<string name="text_player_name">Player Name:</string>
<string name="ip_address">192.168.178.57</string>
<string name="password">vocaluxe</string>
</resources>
+1
View File
@@ -134,6 +134,7 @@ namespace Vocaluxe.Base
change.Profile.ID = _ProfileIDs.Dequeue();
change.Profile.Avatar = _GetAvatar(change.Profile.AvatarFileName);
change.Profile.SaveProfile();
_Profiles.Add(change.Profile.ID, change.Profile);
_ProfilesChanged = true;
+1 -2
View File
@@ -168,8 +168,7 @@ namespace Vocaluxe.Base.Server
p.AvatarFileName = AvatarFilename;
p.Difficulty = (EGameDifficulty)profile.Difficulty;
p.GuestProfile = EOffOn.TR_CONFIG_OFF;
p.PlayerName = profile.PlayerName;
p.SaveProfile();
p.PlayerName = profile.PlayerName;
CProfiles.AddProfile(p);
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK);
}