Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            DatabaseUpdates dataUpdates = GameMaster.DBUpdates;

            dataUpdates.SetContext(this);

            SetContentView(Resource.Layout.Main);

            Button button     = FindViewById <Button>(Resource.Id.MyButton);
            Button playButton = FindViewById <Button>(Resource.Id.PlayButton);

            PopulateTable <Ability>(dataUpdates);
            PopulateTable <Character>(dataUpdates);
            PopulateTable <Division>(dataUpdates);

            button.Click += (sender, e) =>
            {
                dataUpdates.GetAbility("Fireball").ReportAbility(dataUpdates.GetAbility("Fireball"));
                Console.WriteLine();
                Character mary = dataUpdates.GetCharacter("Mary");
                Console.WriteLine();
                Division div = dataUpdates.GetDivision("Mage");
                Console.WriteLine();
            };

            playButton.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(Activities.PlayActivity));
                StartActivity(intent);
            };
        }
Exemplo n.º 2
0
        private void GetConfigList()
        {
            DBManagerHelper dbmgr         = new DBManagerHelper(this);
            DatabaseUpdates tblConfigList = new DatabaseUpdates();
            var             eListAdapt    = new ConfigAdapter(this, tblConfigList.GetConfigList());

            eListAdapt.NotifyDataSetChanged();

            var lvConfigList = FindViewById <ListView>(Resource.Id.lvConfigList);

            lvConfigList.Adapter = eListAdapt;
        }
Exemplo n.º 3
0
        private void MoveMessageReaderByPos(int id)
        {
            if (textToSpeech.IsSpeaking)
            {
                textToSpeech.Stop();
            }

            if (id <= maxPos - 1 && id >= 0)
            {
                if (id == maxPos - 1)
                {
                    var btnNext = FindViewById <Button>(Resource.Id.btnNextEmailReader);
                    btnNext.Enabled = false;
                }
                else
                {
                    var btnNext = FindViewById <Button>(Resource.Id.btnNextEmailReader);
                    btnNext.Enabled = true;
                }

                if (id >= 0)
                {
                    var btnPrev = FindViewById <Button>(Resource.Id.btnPrevEmailReader);
                    btnPrev.Enabled = true;
                }
                else
                {
                    var btnPrev = FindViewById <Button>(Resource.Id.btnPrevEmailReader);
                    btnPrev.Enabled = false;
                }

                //DBManagerHelper dbmgr = new DBManagerHelper(this);
                DatabaseUpdates    tblEmail   = new DatabaseUpdates();
                List <EmailObject> eListAdapt = tblEmail.EmailOBJ();
                EmailObject        emlObj     = eListAdapt[id];
                emlFrom    = emlObj.From;            //Intent.GetStringExtra("emlFrom") ?? "From Data not available";
                emlDate    = emlObj.date.ToString(); //Intent.GetStringExtra("emlDate") ?? "Date Data not available";
                emlCC      = emlObj.CC;              //Intent.GetStringExtra("emlCC") ?? "CC Data not available";
                emlSubject = emlObj.Subject;         //Intent.GetStringExtra("emlSubject") ?? "Subject Data not available";
                emlBody    = emlObj.Body;            //Intent.GetStringExtra("emlBody") ?? "Body Data not available";
                curPos     = id;                     //Intent.GetIntExtra("curPos", 0);

                var tvFrom = FindViewById <TextView>(Resource.Id.tvFromEmailReaer);
                tvFrom.Text = emlFrom;
                var tvCC = FindViewById <TextView>(Resource.Id.tvCCEmailReader);
                tvCC.Text = emlCC;
                var tvSubject = FindViewById <TextView>(Resource.Id.tvSubjectEmailReader);
                tvSubject.Text = emlSubject;
                var tvBody = FindViewById <TextView>(Resource.Id.tvBodyEmailReader);
                tvBody.Text = emlBody;
            }
        }
Exemplo n.º 4
0
        private void RetrieveDBMail()
        {
            EmailsToRead = "";
            DBManagerHelper dbmgr      = new DBManagerHelper(this);
            DatabaseUpdates tblEmail   = new DatabaseUpdates();
            var             eListAdapt = new EmailListAdapter(this, tblEmail.EmailOBJ());

            eListAdapt.NotifyDataSetChanged();

            var emailListView = FindViewById <ListView>(Resource.Id.lvEmailList);

            emailListView.Adapter = eListAdapt;
        }
Exemplo n.º 5
0
        private static void PopulateTable <T>(DatabaseUpdates dataUpdates)
        {
            List <string> allNames = new List <string>();

            if (typeof(T) == typeof(Ability))
            {
                foreach (Ability ability in dataUpdates.GetAllAbilitys())
                {
                    allNames.Add(ability.Name);
                }

                foreach (Ability ability in GameMaster.Abilitys)
                {
                    if (!allNames.Contains(ability.Name))
                    {
                        dataUpdates.AddAbility(ability);
                    }
                }
            }
            if (typeof(T) == typeof(Character))
            {
                foreach (Character character in dataUpdates.GetAllCharacters())
                {
                    allNames.Add(character.Name);
                }

                foreach (Character character in GameMaster.Characters)
                {
                    if (!allNames.Contains(character.Name))
                    {
                        dataUpdates.AddCharacter(character);
                    }
                }
            }
            if (typeof(T) == typeof(Division))
            {
                foreach (Division division in dataUpdates.GetAllDivisions())
                {
                    allNames.Add(division.Name);
                }

                foreach (Division division in GameMaster.Divisions)
                {
                    if (!allNames.Contains(division.Name))
                    {
                        dataUpdates.AddDivision(division);
                    }
                }
            }
        }
Exemplo n.º 6
0
        private static void PopulateTable <T>(DatabaseUpdates mydata)
        {
            List <string> allNames = new List <string>();

            if (typeof(T) == typeof(Collectable))
            {
                foreach (Collectable coll in mydata.GetAllCollectables())
                {
                    allNames.Add(coll.Name);
                }
                foreach (Collectable coll in AppManager.Collectables)
                {
                    if (!allNames.Contains(coll.Name))
                    {
                        mydata.AddCollectable(coll);
                    }
                }
            }
            if (typeof(T) == typeof(Player))
            {
                foreach (Player player in mydata.GetAllPlayers())
                {
                    allNames.Add(player.Name);
                }
                if (!allNames.Contains(AppManager.PlayerName))
                {
                    mydata.AddPlayer(new Player(AppManager.PlayerName));
                }
            }
            if (typeof(T) == typeof(Friend))
            {
                foreach (Friend friend in mydata.GetAllFriends())
                {
                    allNames.Add(friend.Name);
                }
                foreach (Friend friend in AppManager.Friends)
                {
                    if (!allNames.Contains(friend.Name))
                    {
                        mydata.AddFriend(friend);
                    }
                }
            }
        }
Exemplo n.º 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.ConfigEditor);

            ConfigName  = Intent.GetStringExtra("ConfigName") ?? "From Data not available";
            ConfigValue = Intent.GetStringExtra("ConfigValue") ?? "Date Data not available";
            ConfigType  = Intent.GetStringExtra("ConfigType") ?? "CC Data not available";

            var tvNameConfigEdit = FindViewById <TextView>(Resource.Id.tvNameConfigEdit);

            tvNameConfigEdit.Text = ConfigName;

            var etxtValueConfigEdit = FindViewById <EditText>(Resource.Id.etxtValueConfigEdit);

            etxtValueConfigEdit.Text = ConfigValue;

            var btnBackConfigEdit = FindViewById <Button>(Resource.Id.btnBackConfigEdit);

            btnBackConfigEdit.Click += delegate { Finish(); };

            var btnSaveConfigEdit = FindViewById <Button>(Resource.Id.btnSaveConfigEdit);

            btnSaveConfigEdit.Click += delegate {
                //save method here
                DBManagerHelper dbmgr         = new DBManagerHelper(this);
                DatabaseUpdates tblConfigList = new DatabaseUpdates();
                tblConfigList.UpdateConfig(new DataManager.ConfigEntity()
                {
                    Name  = ConfigName,
                    Value = ConfigValue,
                    Type  = ConfigType
                });
                dbmgr.Close();
                Toast.MakeText(this, "Configuration Update Successful", 0);
            };
        }
Exemplo n.º 8
0
        private void RetrievePOP3Mail()
        {
            EmailsToRead = "";
            using (var client = new Pop3Client())
            {
                // accept all SSL certificates (in case the server supports STARTTLS)
                client.ServerCertificateValidationCallback = (s, c, h, e) => true;

                //Console.WriteLine("Connecting to MailServer" + GetString(Resource.String.GDSSEMailServerHost) +" port 995");
                //Toast.MakeText(this, "Email Sync: Authenticating to Server", ToastLength.Long).Show();
                client.Connect(GetString(Resource.String.GDSSEMailServerHost), int.Parse(GetString(Resource.String.GDSSEMailServerPort)), true);

                // Note: since we don't have an OAuth2 token, disable
                // the XOAUTH2 authentication mechanism.
                client.AuthenticationMechanisms.Remove("XOAUTH2");
                client.Authenticate(GetString(Resource.String.GDSSEMailAccount), GetString(Resource.String.GDSSEMailPwd));

                var             emails   = new List <EmailObject>();
                DBManagerHelper dbmgr    = new DBManagerHelper(this);
                DatabaseUpdates tblEmail = new DatabaseUpdates();
                //var tblEmail = new EmailEntity();
                //Toast.MakeText(this, "Email Sync: Downloading Emails", ToastLength.Long).Show();
                //for testing purpose only / clearing of table.
                if (int.Parse(GetString(Resource.String.TestDeleteEmailsOn)) == 1)
                {
                    tblEmail.ClearMail();
                }

                for (int i = client.Count - 1; i >= 0; i--)
                {
                    var message = new MimeMessage();

                    try
                    {
                        message = client.GetMessage(i);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Source + " || " + ex.Message);
                    }

                    if (!tblEmail.IsEmailExist(message.MessageId))
                    {
                        var curemail = new EmailObject(message.MessageId, message.From.ToString(), message.Subject, message.TextBody, message.Cc.ToString(), DateTime.Parse(message.Date.ToString()));

                        try
                        {
                            tblEmail.AddEmail(new EmailEntity
                            {
                                EmailID      = curemail.EmailID ?? "0",
                                EmailFrom    = curemail.From,
                                EmailCC      = curemail.CC,
                                EmailDate    = curemail.date,
                                EmailSubject = curemail.Subject,
                                EmailBody    = curemail.Body
                            });
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Source + "||" + ex.Message);
                        }
                    }
                }
                client.Disconnect(true);
                dbmgr.Close();
            }
        }
Exemplo n.º 9
0
        protected override void OnActivityResult(int req, Result res, Intent data)
        {
            var tvPreviewCommand = FindViewById <TextView>(Resource.Id.tvPreviewCommand);

            //STTtextBox = FindViewById<TextView>(Resource.Id.etxtCommand);
            if (req == NeedLang)
            {
                // we need a new language installed
                var installTTS = new Intent();
                installTTS.SetAction(TextToSpeech.Engine.ActionInstallTtsData);
                StartActivity(installTTS);
            }
            else if (req == VOICE)
            {
                if (res == Result.Ok)
                {
                    var matches = data.GetStringArrayListExtra(RecognizerIntent.ExtraResults);

                    if (matches.Count != 0)
                    {
                        //string textInput = STTtextBox.Text + matches[0];
                        string textInput = matches[0];

                        // limit the output to 500 characters
                        if (textInput.Length > 500)
                        {
                            textInput = textInput.Substring(0, 500);
                        }

                        tvPreviewCommand.Text = textInput;
                        STTtextBox.Text       = textInput;

                        //put logic transfer here. compare keywords then redirect to next activity.
                        if (textInput.ToLower() == "one" || textInput.ToLower() == "1" || textInput.ToLower() == "call" || textInput.ToLower() == "dial")
                        {
                            //start activity here.
                            StartActivity(typeof(Activities.PhoneCallActivity));
                        }
                        else if (textInput.ToLower() == "two" || textInput.ToLower() == "2" || textInput.ToLower() == "message" || textInput.ToLower() == "SMS")
                        {
                            StartActivity(typeof(Activities.MessageActivity));
                        }
                        else if (textInput.ToLower() == "four" || textInput.ToLower() == "4" || textInput.ToLower() == "email" || textInput.ToLower() == "mail")
                        {
                            StartActivity(typeof(Activities.EmailActivity));
                        }
                        else if (textInput.ToLower() == "read email" || textInput.ToLower() == "5" || textInput.ToLower() == "five")
                        {
                            var progressDialog = ProgressDialog.Show(this, "Please wait...", "Connecting to GDSS Mail Server", true);
                            progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
                            new Thread(new ThreadStart(delegate
                            {
                                //LOAD METHOD TO GET ACCOUNT INFO
                                RunOnUiThread(() => {
                                    Toast.MakeText(this, "Email Sync: Connecting to Server", ToastLength.Long).Show();
                                });

                                RunOnUiThread(() => RetrievePOP3Mail());
                                //RetrievePOP3Mail();
                                RunOnUiThread(() => {
                                    Toast.MakeText(this, "Email Sync: Successful", ToastLength.Long).Show();
                                });
                                //RunOnUiThread(() => {
                                DatabaseUpdates tblEmail           = new DatabaseUpdates();
                                List <EmailObject> EmailObjectList = tblEmail.EmailOBJ();
                                int emailListCount = 0;
                                EmailObject item   = EmailObjectList[emailListCount];

                                var actEmailReader = new Intent(this, typeof(EmailReaderActivity));
                                actEmailReader.PutExtra("emlFrom", item.From);
                                actEmailReader.PutExtra("emlCC", item.CC);
                                actEmailReader.PutExtra("emlDate", item.date.ToString());
                                actEmailReader.PutExtra("emlSubject", item.Subject);
                                actEmailReader.PutExtra("emlBody", item.Body);
                                actEmailReader.PutExtra("curPos", emailListCount);
                                actEmailReader.PutExtra("maxPos", EmailObjectList.Count());
                                actEmailReader.PutExtra("autoRead", 1);
                                actEmailReader.SetFlags(ActivityFlags.ReorderToFront);
                                StartActivity(actEmailReader);
                                //});

                                //HIDE PROGRESS DIALOG
                                RunOnUiThread(() => progressDialog.Hide());
                            })).Start();
                        }
                        else if (textInput.ToLower() == "read message" || textInput.ToLower() == "read messages" || textInput.ToLower() == "3" || textInput.ToLower() == "three")
                        {
                            var progressDialog = ProgressDialog.Show(this, "Please wait...", "Fetching Messages", true);
                            progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
                            new Thread(new ThreadStart(delegate
                            {
                                //LOAD METHOD TO GET ACCOUNT INFO
                                RunOnUiThread(() => {
                                    Toast.MakeText(this, "SMS Sync: Fetching Messages", ToastLength.Long).Show();
                                });

                                RunOnUiThread(() => {
                                    Toast.MakeText(this, "SMS Sync: Successful", ToastLength.Long).Show();
                                });

                                //RunOnUiThread(() => {
                                var cursor       = Application.Context.ContentResolver.Query(Telephony.Sms.Inbox.ContentUri, null, null, null, null);
                                var actSMSReader = new Intent(this, typeof(MessageReaderActivity));

                                cursor.MoveToFirst();

                                var ID            = cursor.GetString(cursor.GetColumnIndex(Telephony.Sms.Inbox.InterfaceConsts.Id));
                                string From       = cursor.GetString(cursor.GetColumnIndex(Telephony.Sms.Inbox.InterfaceConsts.Address)).ToString();
                                string messageVal = cursor.GetString(cursor.GetColumnIndex(Telephony.Sms.Inbox.InterfaceConsts.Body)).ToString();

                                var epoch   = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Unspecified);
                                var Dateval = epoch.AddMilliseconds(cursor.GetLong(cursor.GetColumnIndex(Telephony.Sms.Inbox.InterfaceConsts.Date))).AddHours(10);
                                var currSMS = new MessageObject(ID, From, messageVal, Dateval);
                                actSMSReader.PutExtra("SMSFrom", From);
                                actSMSReader.PutExtra("SMSID", ID);
                                actSMSReader.PutExtra("SMSDate", Dateval.ToString());
                                actSMSReader.PutExtra("SMSMessage", messageVal);
                                actSMSReader.PutExtra("curPos", 0);
                                actSMSReader.PutExtra("maxPos", cursor.Count - 1);
                                actSMSReader.PutExtra("autoRead", 1);
                                actSMSReader.SetFlags(ActivityFlags.ReorderToFront);
                                cursor.Close();
                                StartActivity(actSMSReader);
                                //});
                                //HIDE PROGRESS DIALOG
                                RunOnUiThread(() => progressDialog.Hide());
                            })).Start();
                        }
                        else if (textInput.ToLower() == "six" || textInput.ToLower() == "6" || textInput.ToLower() == "assistant" || textInput.ToLower() == "google")
                        {
                            RunOnUiThread(async() =>
                            {
                                //Process.KillProcess(Process.MyPid());
                                var voiceAssistantIntent = new Intent(RecognizerIntent.ActionVoiceSearchHandsFree);
                                voiceAssistantIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);

                                // put a message on the modal dialog
                                voiceAssistantIntent.PutExtra(RecognizerIntent.ExtraPrompt, "Assistant Command");
                                //Application.Context.GetString(Resource.String));

                                // if there is more then 1.5s of silence, consider the speech over
                                voiceAssistantIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 3000);
                                voiceAssistantIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 3000);
                                voiceAssistantIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 3000);
                                voiceAssistantIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);

                                voiceAssistantIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
                                voiceAssistantIntent.SetFlags(ActivityFlags.ReorderToFront);
                                try {
                                    await Task.Delay(4000);
                                    StartActivity(voiceAssistantIntent);
                                } catch (Exception ex) {
                                    //Console.WriteLine(ex.Source + "|" + ex.Message);
                                    Console.WriteLine(ex.Source + "|" + ex.Message);
                                }
                            });
                        }
                        else if (textInput.ToLower() == "quit" || textInput.ToLower() == "exit" || textInput.ToLower() == "close")
                        {
                            Process.KillProcess(Process.MyPid());
                        }
                        else if (textInput.ToLower() == "settings" || textInput.ToLower() == "configuration")
                        {
                            StartActivity(typeof(Activities.ConfigActivity));
                        }
                        else
                        {
                            SetReadMessage("Unrecognized command. You said: " + textInput);

                            var btnAction = FindViewById <ImageButton>(Resource.Id.imgBtnListen);
                            btnAction.SetImageResource(Resource.Drawable.micread);
                            //@android:drawable/presence_audio_online + Android.Resource.Drawable.PresenceAudioOnline + Android.Resource.Drawable.IcDialogInfo
                        }
                    }
                    else
                    {
                        STTtextBox.Text = "No speech was recognised";
                        SetReadMessage(STTtextBox.Text);
                    }
                }
            }

            base.OnActivityResult(req, res, data);
        }
Exemplo n.º 10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            DatabaseUpdates mydata = AppManager.DBUpdates;

            mydata.SetContext(this);

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

            // Get our button from the layout resource,
            // and attach an event to it
            Button playButton       = FindViewById <Button>(Resource.Id.PlayButton);
            Button friendsButton    = FindViewById <Button>(Resource.Id.FriendsButton);
            Button shopButton       = FindViewById <Button>(Resource.Id.ShopButton);
            Button claimCoinsButton = FindViewById <Button>(Resource.Id.ClaimCoinsButton);
            Button resetButton      = FindViewById <Button>(Resource.Id.ResetButton);

            List <string> allCollNames   = new List <string>();
            List <string> allFriendNames = new List <string>();

            PopupateRand();

            //foreach (Collectable coll in mydata.GetAllCollectables())
            //{
            //    allCollNames.Add(coll.Name);
            //}

            //foreach (Collectable coll in AppManager.Collectables)
            //{
            //    if (!allCollNames.Contains(coll.Name))
            //    {
            //        mydata.AddCollectable(coll);
            //    }
            //}

            //foreach (Friend friend in mydata.GetAllFriends())
            //{
            //    allFriendNames.Add(friend.Name);
            //}

            //foreach (Friend friend in AppManager.Friends)
            //{
            //    if (!allFriendNames.Contains(friend.Name))
            //    {
            //        mydata.AddFriend(friend);
            //    }
            //}

            //mydata.AddPlayer(new Player(AppManager.PlayerName));

            PopulateTable <Collectable>(mydata);
            PopulateTable <Player>(mydata);
            PopulateTable <Friend>(mydata);

            playButton.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(Puffin.PlayActivity));
                //intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
                StartActivity(intent);
            };

            friendsButton.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(Puffin.CollectionActivity));
                StartActivity(intent);
            };

            shopButton.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(Puffin.ShopActivity));
                StartActivity(intent);
            };

            claimCoinsButton.Click += (sender, e) =>
            {
                Player player = AppManager.DBUpdates.GetPlayer(AppManager.PlayerName);
                player.Coins += AppManager.ClaimCoin;
                AppManager.DBUpdates.UpdatePlayer(player);
                AppManager.ClaimCoin = 0;

                Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                {
                    FindViewById <TextView>(Resource.Id.ClaimCoinsButton).Text = String.Format("Claim {0} coins", AppManager.ClaimCoin.ToString());
                });
            };

            resetButton.Click += (sender, e) =>
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);

                alert.SetTitle(string.Format("Are you sure you want to reset all data?"));

                alert.SetPositiveButton("Yes", (senderAlert, args) =>
                {
                    //foreach (Collectable coll in AppManager.DBUpdates.GetAllCollectables())
                    //{
                    //    AppManager.DBUpdates.DeleteCollectable(coll);
                    //}
                    //foreach (Player player in AppManager.DBUpdates.GetAllPlayers())
                    //{
                    //    AppManager.DBUpdates.DeletePlayer(player);
                    //}
                    //foreach (Friend friend in AppManager.DBUpdates.GetAllFriends())
                    //{
                    //    AppManager.DBUpdates.DeleteFriend(friend);
                    //}
                    //foreach (Collectable coll in AppManager.Collectables)
                    //{
                    //    mydata.AddCollectable(coll);
                    //}
                    //mydata.AddPlayer(new Player(AppManager.PlayerName));
                    //foreach (Friend friend in AppManager.Friends)
                    //{
                    //    mydata.AddFriend(friend);
                    //}

                    ClearTable <Collectable>();
                    ClearTable <Player>();
                    ClearTable <Friend>();

                    PopulateTable <Collectable>(mydata);
                    PopulateTable <Player>(mydata);
                    PopulateTable <Friend>(mydata);
                });

                alert.SetNegativeButton("No", (senderAlert, args) =>
                {
                });

                Dialog dialog = alert.Create();
                dialog.Show();
            };


            Xamarin.Forms.Forms.Init(this, bundle);
            var timer = new System.Threading.Timer(e => OnTimer(), null, TimeSpan.Zero, TimeSpan.FromSeconds(5));
        }