Exemplo n.º 1
0
        /// <summary>
        /// Method runs after the application has been launched
        /// </summary>
        /// <param name="bundle"></param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            ISharedPreferences       preferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
            ISharedPreferencesEditor editor      = preferences.Edit();

            editor.Clear();
            editor.Commit();

            //Get references to user interface controls
            chatHistory    = FindViewById <TextView>(Resource.Id.mainText);
            input          = FindViewById <AutoCompleteTextView>(Resource.Id.messageTextInput);
            sendButton     = FindViewById <Button>(Resource.Id.sendButton);
            settingsButton = FindViewById <Button>(Resource.Id.settingsButton);

            //Append the method 'sendButton_Click' to the button click event
            sendButton.Click += sendButton_Click;

            //Append the settings button event handler
            settingsButton.Click += settingsButton_Click;

            //Initialise the chat application
            chatApplication = new ChatAppAndroid(this, chatHistory, input);

            //Print the usage instructions
            chatApplication.PrintUsageInstructions();

            //Initialise NetworkComms.Net but without a local server
            chatApplication.RefreshNetworkCommsConfiguration();

            //Uncomment this line to enable logging
            //EnableLogging();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method runs after the application has been launched
        /// </summary>
        /// <param name="bundle"></param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
            ISharedPreferencesEditor editor = preferences.Edit();
            editor.Clear();
            editor.Commit();

            //Get references to user interface controls
            chatHistory = FindViewById<TextView>(Resource.Id.mainText);
            input = FindViewById<AutoCompleteTextView>(Resource.Id.messageTextInput);
            sendButton = FindViewById<Button>(Resource.Id.sendButton);
            settingsButton = FindViewById<Button>(Resource.Id.settingsButton);

            //Append the method 'sendButton_Click' to the button click event
            sendButton.Click += sendButton_Click;

            //Append the settings button event handler
            settingsButton.Click += settingsButton_Click;

            //Initialise the chat application
            chatApplication = new ChatAppAndroid(this, chatHistory, input);

            //Print the usage instructions
            chatApplication.PrintUsageInstructions();

            //Initialise NetworkComms.Net but without a local server
            chatApplication.RefreshNetworkCommsConfiguration();

            //Uncomment this line to enable logging
            //EnableLogging();
        }
Exemplo n.º 3
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (requestCode == 0x4655676)
            {
                ISharedPreferences sharedPrefs = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext);
                chatApplication.LocalName       = sharedPrefs.GetString("prefName", "Android");
                chatApplication.ServerIPAddress = sharedPrefs.GetString("prefIPAddress", "");

                string portString = sharedPrefs.GetString("prefPort", "");
                if (portString != String.Empty)
                {
                    chatApplication.ServerPort = int.Parse(portString);
                }

                chatApplication.ConnectionType = (ConnectionType)Enum.Parse(typeof(ConnectionType), sharedPrefs.GetString("prefConnectionType", "TCP"));

                string serializerPref = sharedPrefs.GetString("prefSerializerType", "Protobuf");

                switch (serializerPref)
                {
                case "Protobuf":
                    chatApplication.Serializer = DPSManager.GetDataSerializer <NetworkCommsDotNet.DPSBase.ProtobufSerializer>();
                    break;

                default:
                    break;
                }

                chatApplication.EncryptionEnabled  = sharedPrefs.GetBoolean("prefEncryption", false);
                chatApplication.LocalServerEnabled = sharedPrefs.GetBoolean("prefEnableLocalServer", false);

                chatApplication.RefreshNetworkCommsConfiguration();
            }
        }