예제 #1
0
        public static async Task <ObservableCollection <Contact> > GetContacts(string gesture)
        {
            IListableDataStore <Contact> regContactStore = new ContactStore();
            IListableDataStore <Contact> sosContactStore = new SOSContactStore();
            var contactsStore = gesture == "predeterminedTexts" ? regContactStore : sosContactStore;
            ObservableCollection <Contact> contacts = await contactsStore.ListAsync();

            return(contacts);
        }
예제 #2
0
        public async Task PerformAction(string action, IMusicManager musicManager = null)
        {
            this.musicManager = musicManager ?? this.musicManager;

            if (action.Equals("Emergency Dial"))
            {
                var sosContactStore   = new SOSContactStore();
                var emergencyContacts = await sosContactStore.ListAsync();

                // This version uses the first listed emergency contact as the one to call.
                Contact emergencyContact = null;
                foreach (var contact in emergencyContacts)
                {
                    emergencyContact = contact;
                    break;
                }

                if (emergencyContact != null)
                {
                    this.callManager.Dial(emergencyContact.PhoneNumber);
                }
            }
            else if (action.Equals("Next GPS Direction"))
            {
                gpsManager.ReadNextDirectionAsync();
            }
            else if (action.Equals("Play"))
            {
                bool didItWork = await this.musicManager.Resume();
            }
            else if (action.Equals("Pause"))
            {
                bool didItWork = await this.musicManager.Pause();
            }
            else if (action.Equals("Skip"))
            {
                bool didItWork = await this.musicManager.Skip();
            }
            else if (action.Equals("Send Text"))
            {
                ObservableCollection <Contact> contacts = await TextMessageInfoHandler.GetContacts("predeterminedTexts");

                Text textMessage = await TextMessageInfoHandler.GetText("text");

                foreach (Contact c in contacts)
                {
                    //TODO: find a way to handle bad phone numbers. View can do basic handling. Notification?
                    string number = c.PhoneNumber;
                    number = number.Replace("-", "");
                    try
                    {
                        smsManager.SendTextMessage(number, textMessage.TextMsg);
                    }
                    catch (Exception e)
                    {
                        continue;
                    }
                }
            }
            else if (action.Equals("Emergency Text"))
            {
                ObservableCollection <Contact> contacts = await TextMessageInfoHandler.GetContacts("SOS_predeterminedTexts");

                Text textMessage = await TextMessageInfoHandler.GetText("SOS_text");

                bool sendGPS = await TextMessageInfoHandler.GetSendGPS("Send_GPS");

                foreach (Contact c in contacts)
                {
                    string number = c.PhoneNumber;
                    number = number.Replace("-", "");
                    try
                    {
                        if (sendGPS)
                        {
                            string loc = await gpsManager.GetGPSCoordinates();

                            smsManager.SendTextMessage(number, textMessage.TextMsg + "\nCurrent GPS Location:\n" + loc);
                        }
                        else
                        {
                            smsManager.SendTextMessage(number, textMessage.TextMsg);
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }
            else if (action.Equals("Read Recent Text Aloud"))
            {
                // Takes care of the entire read sms aloud flow
                smsManager.ReadRecentText();
            }
            else if (action.Equals("Turn On/Off Do Not Disturb"))
            {
                notificationManager.ToggleDoNotDisturb();
            }
            else if (action.Equals("Volume Up"))
            {
                audioManager.VolumeUp();
            }
            else if (action.Equals("Volume Down"))
            {
                audioManager.VolumeDown();
            }
        }