Esempio n. 1
0
 public CommonDialogFragment (CommonDialogStates cds, Context ctx)
 {
     this.cds = cds;
     this.ctx = ctx;
 }
Esempio n. 2
0
 public GrantDialogFragment(CommonDialogStates cds, Context context)
 {
     this.cds = cds;
     this.ctx = context;
 }
Esempio n. 3
0
        void ShowAlertType1 (CommonDialogStates cds)
        {
            UIAlertView alert = new UIAlertView ();
            alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
            bool isHeartbeatInterval = false;
            string messageBoxTitle = "Set";

            if (cds == CommonDialogStates.Auth) {
                alert.Title = "Auth Key";
                alert.Message = "Enter Auth Key";
            } else if ((cds == CommonDialogStates.AuditSubscribe)
                     || (cds == CommonDialogStates.AuditPresence)
                     || (cds == CommonDialogStates.RevokePresence)
                     || (cds == CommonDialogStates.RevokeSubscribe)) {
                alert.Title = "Auth Key";
                alert.Message = "Enter Auth Key (Optional)";
                messageBoxTitle = cds.ToString ();
            } else if (cds == CommonDialogStates.PresenceHeartbeat) {
                alert.GetTextField (0).KeyboardType = UIKeyboardType.NumberPad;
                alert.Title = "Presence Heartbeat";
                alert.Message = "Enter Presence Heartbeat";
            } else if (cds == CommonDialogStates.PresenceHeartbeatInterval) {
                isHeartbeatInterval = true;
                alert.GetTextField (0).KeyboardType = UIKeyboardType.NumberPad;
                alert.Title = "Presence Heartbeat Interval";
                alert.Message = "Enter Presence Heartbeat Interval";
            } else if (cds == CommonDialogStates.ChangeUuid) {
                alert.Title = "Change UUID";
                alert.Message = "Enter UUID";
            } else if (cds == CommonDialogStates.WhereNow) {
                alert.Title = "Where Now";
                alert.Message = "Enter UUID (optional)";
                messageBoxTitle = "Where Now";
            }

            alert.AddButton (messageBoxTitle);
            alert.AddButton ("Cancel");
            alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
                if (e.ButtonIndex == 0) {
                    if (alert.GetTextField (0) != null) {
                        string input = alert.GetTextField (0).Text;
                        if (cds == CommonDialogStates.Auth) {
                            pubnub.AuthenticationKey = input;
                            Display ("Auth Key Set");
                        } else if (cds == CommonDialogStates.AuditSubscribe) {
                            Display ("Running Subscribe Audit");
                            pubnub.AuditAccess<string> (Channel, input, DisplayReturnMessage, DisplayErrorMessage);
                        } else if (cds == CommonDialogStates.AuditPresence) {
                            Display ("Running Presence Audit");
                            pubnub.AuditPresenceAccess<string> (Channel, input, DisplayReturnMessage, DisplayErrorMessage);
                        } else if (cds == CommonDialogStates.RevokePresence) {
                            Display ("Running Presence Revoke");
                            pubnub.GrantPresenceAccess<string> (Channel, input, false, false, DisplayReturnMessage, DisplayErrorMessage);
                        } else if (cds == CommonDialogStates.RevokeSubscribe) {
                            Display ("Running Subscribe Revoke");
                            pubnub.GrantAccess<string> (Channel, input, false, false, DisplayReturnMessage, DisplayErrorMessage);
                        } else if ((cds == CommonDialogStates.PresenceHeartbeat) || (cds == CommonDialogStates.PresenceHeartbeatInterval)) {
                            int iVal;
                            Int32.TryParse (input, out iVal);
                            if (iVal != 0) {
                                if (isHeartbeatInterval) {
                                    pubnub.PresenceHeartbeatInterval = iVal;
                                    Display (string.Format ("Presence Heartbeat Interval set to {0}", pubnub.PresenceHeartbeatInterval));
                                } else {
                                    pubnub.PresenceHeartbeat = iVal;
                                    Display (string.Format ("Presence Heartbeat set to {0}", pubnub.PresenceHeartbeat));
                                }
                            } else {
                                Display (string.Format ("Value not numeric"));
                            }
                        } else if (cds == CommonDialogStates.ChangeUuid) {
                            pubnub.ChangeUUID (input);
                            Display (string.Format ("UUID set to {0}", pubnub.SessionUUID));
                        } else if (cds == CommonDialogStates.WhereNow) {
                            Display ("Running where now");
                            pubnub.WhereNow<string> (input, DisplayReturnMessage, DisplayErrorMessage);
                        }
                    }
                }           
            };
            alert.Show ();
        }
Esempio n. 4
0
        void ShowAlertType2 (CommonDialogStates cds)
        {
            bool isPresenceGrant = false;
            bool showEntryText = true;
            bool showEntryText2 = false;
            bool boolval1 = false;
            UIKeyboardType keyboardType = UIKeyboardType.Default;

            string strHead = "", elementText1 = "", elementText2 = "", 
            elementText3 = "", elementSubText = "", buttonTitle = "", elementText4 = "", elementSubText2 = "";
            if (cds == CommonDialogStates.PresenceGrant) {
                strHead = "Presence Grant";
                elementText1 = "Read";
                elementText2 = "Write";
                elementText3 = "TTL";
                elementSubText = "Enter TTL (default 1440)";
                elementText4 = "Auth key";
                elementSubText2 = "optional";
                buttonTitle = "Grant";
                keyboardType = UIKeyboardType.NumberPad;
                isPresenceGrant = true;
                showEntryText2 = true;
            } else if (cds == CommonDialogStates.SubscribeGrant) {
                elementText1 = "Read";
                elementText2 = "Write";
                elementText3 = "TTL";
                elementSubText = "Enter TTL (default 1440)";
                elementText4 = "Auth key";
                elementSubText2 = "optional";
                strHead = "Subscribe Grant";
                buttonTitle = "Grant";
                keyboardType = UIKeyboardType.NumberPad;
                showEntryText2 = true;
            } else if (cds == CommonDialogStates.HereNow) {
                elementText1 = "Show UUID";
                elementText2 = "Include User State";
                elementText3 = "Channel";
                elementSubText = "Enter channel name";
                strHead = "Here now";
                buttonTitle = "Here Now";

                boolval1 = true;
            } else if (cds == CommonDialogStates.GlobalHereNow) {
                elementText1 = "Show UUID";
                elementText2 = "Include User State";
                strHead = "Global Here Now";
                buttonTitle = "Global Here Now";
                showEntryText = false;
                boolval1 = true;
            }

            BooleanElement be1 = new BooleanElement (elementText1, boolval1);
            BooleanElement be2 = new BooleanElement (elementText2, false);

            EntryElement entryText = null;
            EntryElement entryText2 = null;

            if (showEntryText) {
                entryText = new EntryElement (elementText3, elementSubText, "");
                entryText.KeyboardType = keyboardType;
                entryText.AutocapitalizationType = UITextAutocapitalizationType.None;
                entryText.AutocorrectionType = UITextAutocorrectionType.No;
            }
            if (showEntryText2) {
                entryText2 = new EntryElement (elementText4, elementSubText2, "");
                entryText2.AutocapitalizationType = UITextAutocapitalizationType.None;
                entryText2.AutocorrectionType = UITextAutocorrectionType.No;
            }

            var newroot = new RootElement (strHead, 0, 0) {
                new Section () {
                    be1,
                    be2,
                    entryText2,
                    entryText
                },
                new Section ("") {
                    new StyledStringElement (buttonTitle, () => {
                        if ((cds == CommonDialogStates.PresenceGrant) || (cds == CommonDialogStates.SubscribeGrant)) {
                            int iTtl;
                            Int32.TryParse (entryText.Value, out iTtl);
                            if (iTtl == 0) {
                                iTtl = 1440;
                                entryText.Value = "1440";
                            }
                            if (isPresenceGrant) {
                                Display ("Running Presence Grant");
                                pubnub.GrantPresenceAccess<string> (Channel, entryText2.Value, be1.Value, be2.Value, iTtl, DisplayReturnMessage, DisplayErrorMessage);
                            } else {
                                Display ("Running Subscribe Grant");
                                pubnub.GrantAccess<string> (Channel, entryText2.Value, be1.Value, be2.Value, iTtl, DisplayReturnMessage, DisplayErrorMessage);
                            }
                        } else if (cds == CommonDialogStates.HereNow) {
                            Display ("Running Here Now");
                            if(entryText.Value.Trim() != ""){
                                string[] channels = entryText.Value.Split (',');//Channel.Split (',');
                                foreach (string channel in channels) {
                                    pubnub.HereNow<string> (channel.Trim (), be1.Value, be2.Value, DisplayReturnMessage, DisplayErrorMessage);
                                }
                            } else {
                                Display ("Channel empty");
                            }
                        } else if (cds == CommonDialogStates.GlobalHereNow) {
                            pubnub.GlobalHereNow<string> (be1.Value, be2.Value, DisplayReturnMessage, DisplayErrorMessage);
                        }

                        AppDelegate.navigation.PopViewControllerAnimated (true);
                    }) {
                        BackgroundColor = UIColor.Blue,
                        TextColor = UIColor.White,
                        Alignment = UITextAlignment.Center
                    },
                },
            };
            dvc = new DialogViewController (newroot, true);
            AppDelegate.navigation.PushViewController (dvc, true);
        }
Esempio n. 5
0
 public CommonDialogFragment(CommonDialogStates cds, Context ctx)
 {
     this.cds = cds;
     this.ctx = ctx;
 }
Esempio n. 6
0
        void ShowAlertType3 (CommonDialogStates cds)
        {
            bool showEntryText3 = true;

            string strHead = "", elementText1 = "", elementText2 = "", elementText3 = "";
            string elementSubText1 = "", elementSubText2 = "", elementSubText3 = "", buttonTitle = "";
            if (cds == CommonDialogStates.SetUserStateKeyPair) {
                strHead = "Add Local User State";
                elementText1 = "Channel";
                elementText2 = "Key";
                elementText3 = "Value";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "Enter Key";
                elementSubText3 = "Enter Value";
                buttonTitle = "Add";
            } else if (cds == CommonDialogStates.DeleteUserState) {
                strHead = "Delete Local User State";
                elementText1 = "Channel";
                elementText2 = "Key";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "Key to delete";
                buttonTitle = "Delete";
                showEntryText3 = false;
            } else if (cds == CommonDialogStates.SetUserStateJson) {
                strHead = "Add User State";
                elementText1 = "Channel";
                elementText2 = "State";
                elementText3 = "UUID";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "enter json format";
                elementSubText3 = "Enter UUID";
                buttonTitle = "Add";
            } else if (cds == CommonDialogStates.GetUserState) {
                strHead = "Get User State";
                elementText1 = "Channel";
                elementText2 = "UUID";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "Enter UUID";
                buttonTitle = "Get";
                showEntryText3 = false;
            }

            EntryElement entryText3 = null;

            if (showEntryText3) {
                entryText3 = new EntryElement (elementText3, elementSubText3, "");
                entryText3.AutocapitalizationType = UITextAutocapitalizationType.None;
                entryText3.AutocorrectionType = UITextAutocorrectionType.No;
            }

            EntryElement entryText1 = new EntryElement (elementText1, elementSubText1, "");
            entryText1.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryText1.AutocorrectionType = UITextAutocorrectionType.No;

            EntryElement entryText2 = new EntryElement (elementText2, elementSubText2, "");
            entryText2.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryText2.AutocorrectionType = UITextAutocorrectionType.No;

            var newroot = new RootElement (strHead, 0, 0) {
                new Section () {
                    entryText1,
                    entryText2,
                    entryText3
                },
                new Section ("") {
                    new StyledStringElement (buttonTitle, () => {
                        if (cds == CommonDialogStates.SetUserStateKeyPair) {
                            Display ("Setting user state");
                            int valueInt;
                            double valueDouble;
                            if (Int32.TryParse (entryText3.Value, out valueInt)) {
                                pubnub.SetUserState<string> (entryText1.Value, new KeyValuePair<string, object> (entryText2.Value, valueInt), DisplayReturnMessage, DisplayErrorMessage);
                            } else if (Double.TryParse (entryText3.Value, out valueDouble)) {
                                pubnub.SetUserState<string> (entryText1.Value, new KeyValuePair<string, object> (entryText2.Value, valueDouble), DisplayReturnMessage, DisplayErrorMessage);
                            } else {
                                pubnub.SetUserState<string> (entryText1.Value, new KeyValuePair<string, object> (entryText2.Value, entryText3.Value), DisplayReturnMessage, DisplayErrorMessage);
                            }
                        } else if (cds == CommonDialogStates.DeleteUserState) {
                            pubnub.SetUserState<string> (entryText1.Value, new KeyValuePair<string, object> (entryText2.Value, null), DisplayReturnMessage, DisplayErrorMessage);
                        } else if (cds == CommonDialogStates.SetUserStateJson) {
                            Display ("Setting user state");
                            string jsonUserState = "";
                            if (string.IsNullOrEmpty (entryText2.Value)) {
                                //jsonUserState = pubnub.GetUserState (entryText1.Value);
                            } else {
                                jsonUserState = entryText2.Value;
                            }
                            pubnub.SetUserState<string> (entryText1.Value, entryText3.Value, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
                        } else if (cds == CommonDialogStates.GetUserState) {
                            Display ("Running get user state");
                            pubnub.GetUserState<string> (entryText1.Value, entryText2.Value, DisplayReturnMessage, DisplayErrorMessage);
                        }

                        AppDelegate.navigation.PopViewControllerAnimated (true);
                    }) {
                        BackgroundColor = UIColor.Blue,
                        TextColor = UIColor.White,
                        Alignment = UITextAlignment.Center
                    },
                },
            };
            dvc = new DialogViewController (newroot, true);
            AppDelegate.navigation.PushViewController (dvc, true);
        }
Esempio n. 7
0
 public GrantDialogFragment(CommonDialogStates cds)
 {
     this.cds = cds;
 }
Esempio n. 8
0
 public AddRemoveFromChannelGroupDialogFragment(CommonDialogStates cds, Context context)
 {
     this.cds = cds;
     this.ctx = context;
 }
 public GrantDialogFragment (CommonDialogStates cds, Context context)
 {
     this.cds = cds;
     this.ctx = context;
 }
 public AddRemoveFromChannelGroupDialogFragment (CommonDialogStates cds, Context context)
 {
     this.cds = cds;
     this.ctx = context;
 }
Esempio n. 11
0
        void ShowAlertType2(CommonDialogStates cds)
        {
            bool           isPresenceGrant = false;
            bool           showEntryText   = true;
            bool           showEntryText2  = false;
            bool           boolval1        = false;
            bool           showBool        = true;
            UIKeyboardType keyboardType    = UIKeyboardType.Default;

            string strHead = "", elementText1 = "", elementText2 = "",
                   elementText3 = "", elementSubText = "", buttonTitle = "", elementText4 = "", elementSubText2 = "";

            if (cds == CommonDialogStates.PresenceGrant)
            {
                strHead         = "Presence Grant";
                elementText1    = "Read";
                elementText2    = "Write";
                elementText3    = "TTL";
                elementSubText  = "Enter TTL (default 1440)";
                elementText4    = "Auth key";
                elementSubText2 = "optional";
                buttonTitle     = "Grant";
                keyboardType    = UIKeyboardType.NumberPad;
                isPresenceGrant = true;
                showEntryText2  = true;
            }
            else if (cds == CommonDialogStates.SubscribeGrant)
            {
                elementText1    = "Read";
                elementText2    = "Write";
                elementText3    = "TTL";
                elementSubText  = "Enter TTL (default 1440)";
                elementText4    = "Auth key";
                elementSubText2 = "optional";
                strHead         = "Subscribe Grant";
                buttonTitle     = "Grant";
                keyboardType    = UIKeyboardType.NumberPad;
                showEntryText2  = true;
            }
            else if (cds == CommonDialogStates.HereNow)
            {
                elementText1   = "Show UUID";
                elementText2   = "Include User State";
                elementText3   = "Channel";
                elementSubText = "Enter channel name";
                strHead        = "Here now";
                buttonTitle    = "Here Now";

                boolval1 = true;
            }
            else if (cds == CommonDialogStates.GlobalHereNow)
            {
                elementText1  = "Show UUID";
                elementText2  = "Include User State";
                strHead       = "Global Here Now";
                buttonTitle   = "Global Here Now";
                showEntryText = false;
                boolval1      = true;
            }
            else if (cds == CommonDialogStates.Publish)
            {
                elementText1    = "Store in history";
                elementText4    = "Channel";
                elementSubText2 = "Enter channel name";
                elementText3    = "Message";
                elementSubText  = "Enter message";
                strHead         = "Publish";
                buttonTitle     = "Publish";
                showEntryText   = true;
                showEntryText2  = true;
                boolval1        = true;
                showBool        = false;
            }

            BooleanElement be1 = new BooleanElement(elementText1, boolval1);
            BooleanElement be2 = null;

            if (showBool)
            {
                be2 = new BooleanElement(elementText2, false);
            }

            EntryElement entryText  = null;
            EntryElement entryText2 = null;

            if (showEntryText)
            {
                entryText = new EntryElement(elementText3, elementSubText, "");
                entryText.KeyboardType           = keyboardType;
                entryText.AutocapitalizationType = UITextAutocapitalizationType.None;
                entryText.AutocorrectionType     = UITextAutocorrectionType.No;
            }
            if (showEntryText2)
            {
                entryText2 = new EntryElement(elementText4, elementSubText2, "");
                entryText2.AutocapitalizationType = UITextAutocapitalizationType.None;
                entryText2.AutocorrectionType     = UITextAutocorrectionType.No;
            }

            var newroot = new RootElement(strHead, 0, 0)
            {
                new Section()
                {
                    be1,
                    be2,
                    entryText2,
                    entryText
                },
                new Section("")
                {
                    new StyledStringElement(buttonTitle, () => {
                        bool be1Val = be1.Value;

                        Channel = newChannels.Text;
                        if ((cds == CommonDialogStates.PresenceGrant) || (cds == CommonDialogStates.SubscribeGrant))
                        {
                            string entryTextVal  = entryText.Value;
                            string entryText2Val = entryText2.Value;
                            bool be2Val          = be2.Value;
                            int iTtl;
                            Int32.TryParse(entryTextVal, out iTtl);
                            if (iTtl < 0)
                            {
                                iTtl         = 1440;
                                entryTextVal = "1440";
                            }
                            if (isPresenceGrant)
                            {
                                Display("Running Presence Grant");
                                InvokeInBackground(() => {
                                    pubnub.GrantPresenceAccess <string> (Channel, entryText2Val, be1Val, be2Val, iTtl, DisplayReturnMessage, DisplayErrorMessage);
                                });
                            }
                            else
                            {
                                Display("Running Subscribe Grant");
                                InvokeInBackground(() => {
                                    pubnub.GrantAccess <string> (Channel, entryText2Val, be1Val, be2Val, iTtl, DisplayReturnMessage, DisplayErrorMessage);
                                });
                            }
                        }
                        else if (cds == CommonDialogStates.HereNow)
                        {
                            Display("Running Here Now");
                            string entryTextVal = entryText.Value;
                            bool be2Val         = be2.Value;
                            if (entryTextVal.Trim() != "")
                            {
                                string[] channels = entryTextVal.Split(','); //Channel.Split (',');
                                foreach (string channel in channels)
                                {
                                    InvokeInBackground(() => {
                                        pubnub.HereNow <string> (channel.Trim(), be1Val, be2Val, DisplayReturnMessage, DisplayErrorMessage);
                                    });
                                }
                            }
                            else
                            {
                                Display("Channel empty");
                            }
                        }
                        else if (cds == CommonDialogStates.GlobalHereNow)
                        {
                            bool be2Val = be2.Value;
                            InvokeInBackground(() => {
                                pubnub.GlobalHereNow <string> (be1Val, be2Val, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if (cds == CommonDialogStates.Publish)
                        {
                            Display("Running Publish");
                            string entryTextVal  = entryText.Value;
                            string entryText2Val = entryText2.Value;

                            string[] channels = entryText2Val.Split(',');

                            foreach (string channel in channels)
                            {
                                InvokeInBackground(() => {
                                    pubnub.Publish <string> (channel.Trim(), entryTextVal, be1Val, DisplayReturnMessage, DisplayErrorMessage);
                                });
                            }
                        }

                        AppDelegate.navigation.PopViewControllerAnimated(true);
                    })
                    {
                        BackgroundColor = UIColor.Blue,
                        TextColor       = UIColor.White,
                        Alignment       = UITextAlignment.Center
                    },
                },
            };

            dvc = new DialogViewController(newroot, true);
            AppDelegate.navigation.PushViewController(dvc, true);
        }
Esempio n. 12
0
        void ShowAlertType1(CommonDialogStates cds)
        {
            UIAlertView alert = new UIAlertView();

            alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
            bool   isHeartbeatInterval = false;
            string messageBoxTitle     = "Set";

            if (cds == CommonDialogStates.Auth)
            {
                alert.Title   = "Auth Key";
                alert.Message = "Enter Auth Key";
            }
            else if ((cds == CommonDialogStates.AuditSubscribe) ||
                     (cds == CommonDialogStates.AuditPresence) ||
                     (cds == CommonDialogStates.RevokePresence) ||
                     (cds == CommonDialogStates.RevokeSubscribe))
            {
                alert.Title     = "Auth Key";
                alert.Message   = "Enter Auth Key (Optional)";
                messageBoxTitle = cds.ToString();
            }
            else if (cds == CommonDialogStates.PresenceHeartbeat)
            {
                alert.GetTextField(0).KeyboardType = UIKeyboardType.NumberPad;
                alert.Title   = "Presence Heartbeat";
                alert.Message = "Enter Presence Heartbeat";
            }
            else if (cds == CommonDialogStates.PresenceHeartbeatInterval)
            {
                isHeartbeatInterval = true;
                alert.GetTextField(0).KeyboardType = UIKeyboardType.NumberPad;
                alert.Title   = "Presence Heartbeat Interval";
                alert.Message = "Enter Presence Heartbeat Interval";
            }
            else if (cds == CommonDialogStates.ChangeUuid)
            {
                alert.Title   = "Change UUID";
                alert.Message = "Enter UUID";
            }
            else if (cds == CommonDialogStates.WhereNow)
            {
                alert.Title     = "Where Now";
                alert.Message   = "Enter UUID (optional)";
                messageBoxTitle = "Where Now";
            }

            alert.AddButton(messageBoxTitle);
            alert.AddButton("Cancel");
            alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
                if (e.ButtonIndex == 0)
                {
                    if (alert.GetTextField(0) != null)
                    {
                        string input = alert.GetTextField(0).Text;
                        Channel = newChannels.Text;
                        if (cds == CommonDialogStates.Auth)
                        {
                            InvokeInBackground(() => {
                                pubnub.AuthenticationKey = input;
                            });
                            Display("Auth Key Set");
                        }
                        else if (cds == CommonDialogStates.AuditSubscribe)
                        {
                            Display("Running Subscribe Audit");
                            InvokeInBackground(() => {
                                pubnub.AuditAccess <string> (Channel, input, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if (cds == CommonDialogStates.AuditPresence)
                        {
                            Display("Running Presence Audit");
                            InvokeInBackground(() => {
                                pubnub.AuditPresenceAccess <string> (Channel, input, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if (cds == CommonDialogStates.RevokePresence)
                        {
                            Display("Running Presence Revoke");
                            InvokeInBackground(() => {
                                pubnub.GrantPresenceAccess <string> (Channel, input, false, false, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if (cds == CommonDialogStates.RevokeSubscribe)
                        {
                            Display("Running Subscribe Revoke");
                            InvokeInBackground(() => {
                                pubnub.GrantAccess <string> (Channel, input, false, false, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if ((cds == CommonDialogStates.PresenceHeartbeat) || (cds == CommonDialogStates.PresenceHeartbeatInterval))
                        {
                            int iVal;
                            Int32.TryParse(input, out iVal);
                            if (iVal != 0)
                            {
                                if (isHeartbeatInterval)
                                {
                                    InvokeInBackground(() => {
                                        pubnub.PresenceHeartbeatInterval = iVal;
                                    });
                                    Display(string.Format("Presence Heartbeat Interval set to {0}", pubnub.PresenceHeartbeatInterval));
                                }
                                else
                                {
                                    InvokeInBackground(() => {
                                        pubnub.PresenceHeartbeat = iVal;
                                    });
                                    Display(string.Format("Presence Heartbeat set to {0}", pubnub.PresenceHeartbeat));
                                }
                            }
                            else
                            {
                                Display(string.Format("Value not numeric"));
                            }
                        }
                        else if (cds == CommonDialogStates.ChangeUuid)
                        {
                            InvokeInBackground(() => {
                                pubnub.ChangeUUID(input);
                            });
                            Display(string.Format("UUID set to {0}", pubnub.SessionUUID));
                        }
                        else if (cds == CommonDialogStates.WhereNow)
                        {
                            Display("Running where now");
                            InvokeInBackground(() => {
                                pubnub.WhereNow <string> (input, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                    }
                }
            };
            alert.Show();
        }
Esempio n. 13
0
        void ShowAlertType3(CommonDialogStates cds)
        {
            bool showEntryText3 = true;

            string strHead = "", elementText1 = "", elementText2 = "", elementText3 = "";
            string elementSubText1 = "", elementSubText2 = "", elementSubText3 = "", buttonTitle = "";

            if (cds == CommonDialogStates.SetUserStateKeyPair)
            {
                strHead         = "Add Local User State";
                elementText1    = "Channel";
                elementText2    = "Key";
                elementText3    = "Value";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "Enter Key";
                elementSubText3 = "Enter Value";
                buttonTitle     = "Add";
            }
            else if (cds == CommonDialogStates.DeleteUserState)
            {
                strHead         = "Delete Local User State";
                elementText1    = "Channel";
                elementText2    = "Key";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "Key to delete";
                buttonTitle     = "Delete";
                showEntryText3  = false;
            }
            else if (cds == CommonDialogStates.SetUserStateJson)
            {
                strHead         = "Add User State";
                elementText1    = "Channel";
                elementText2    = "State";
                elementText3    = "UUID";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "enter json format";
                elementSubText3 = "Enter UUID";
                buttonTitle     = "Add";
            }
            else if (cds == CommonDialogStates.GetUserState)
            {
                strHead         = "Get User State";
                elementText1    = "Channel";
                elementText2    = "UUID";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "Enter UUID";
                buttonTitle     = "Get";
                showEntryText3  = false;
            }

            EntryElement entryText3 = null;

            if (showEntryText3)
            {
                entryText3 = new EntryElement(elementText3, elementSubText3, "");
                entryText3.AutocapitalizationType = UITextAutocapitalizationType.None;
                entryText3.AutocorrectionType     = UITextAutocorrectionType.No;
            }

            EntryElement entryText1 = new EntryElement(elementText1, elementSubText1, "");

            entryText1.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryText1.AutocorrectionType     = UITextAutocorrectionType.No;

            EntryElement entryText2 = new EntryElement(elementText2, elementSubText2, "");

            entryText2.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryText2.AutocorrectionType     = UITextAutocorrectionType.No;

            var newroot = new RootElement(strHead, 0, 0)
            {
                new Section()
                {
                    entryText1,
                    entryText2,
                    entryText3
                },
                new Section("")
                {
                    new StyledStringElement(buttonTitle, () => {
                        string entryText1Val = entryText1.Value;
                        string entryText2Val = entryText2.Value;

                        if (cds == CommonDialogStates.SetUserStateKeyPair)
                        {
                            string entryText3Val = entryText3.Value;
                            Display("Setting user state");
                            int valueInt;
                            double valueDouble;
                            if (Int32.TryParse(entryText3Val, out valueInt))
                            {
                                InvokeInBackground(() => {
                                    pubnub.SetUserState <string> (entryText1Val, new KeyValuePair <string, object> (entryText2Val, valueInt), DisplayReturnMessage, DisplayErrorMessage);
                                });
                            }
                            else if (Double.TryParse(entryText3Val, out valueDouble))
                            {
                                InvokeInBackground(() => {
                                    pubnub.SetUserState <string> (entryText1Val, new KeyValuePair <string, object> (entryText2Val, valueDouble), DisplayReturnMessage, DisplayErrorMessage);
                                });
                            }
                            else
                            {
                                InvokeInBackground(() => {
                                    pubnub.SetUserState <string> (entryText1Val, new KeyValuePair <string, object> (entryText2Val, entryText3Val), DisplayReturnMessage, DisplayErrorMessage);
                                });
                            }
                        }
                        else if (cds == CommonDialogStates.DeleteUserState)
                        {
                            InvokeInBackground(() => {
                                pubnub.SetUserState <string> (entryText1Val, new KeyValuePair <string, object> (entryText2Val, null), DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if (cds == CommonDialogStates.SetUserStateJson)
                        {
                            Display("Setting user state");
                            string entryText3Val = entryText3.Value;
                            string jsonUserState = "";
                            if (string.IsNullOrEmpty(entryText2Val))
                            {
                                //jsonUserState = pubnub.GetUserState (entryText1.Value);
                            }
                            else
                            {
                                jsonUserState = entryText2Val;
                            }
                            InvokeInBackground(() => {
                                pubnub.SetUserState <string> (entryText1Val, entryText3Val, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if (cds == CommonDialogStates.GetUserState)
                        {
                            Display("Running get user state");
                            InvokeInBackground(() => {
                                pubnub.GetUserState <string> (entryText1Val, entryText2Val, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }

                        AppDelegate.navigation.PopViewControllerAnimated(true);
                    })
                    {
                        BackgroundColor = UIColor.Blue,
                        TextColor       = UIColor.White,
                        Alignment       = UITextAlignment.Center
                    },
                },
            };

            dvc = new DialogViewController(newroot, true);
            AppDelegate.navigation.PushViewController(dvc, true);
        }
Esempio n. 14
0
        void ShowAlertType3(CommonDialogStates cds)
        {
            bool showEntryText3 = true;

            string strHead = "", elementText1 = "", elementText2 = "", elementText3 = "";
            string elementSubText1 = "", elementSubText2 = "", elementSubText3 = "", buttonTitle = "";

            if (cds == CommonDialogStates.AddLocalUserState)
            {
                strHead         = "Add Local User State";
                elementText1    = "Channel";
                elementText2    = "Key";
                elementText3    = "Value";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "Enter Key";
                elementSubText3 = "Enter Value";
                buttonTitle     = "Add";
            }
            else if (cds == CommonDialogStates.DeleteLocalUserState)
            {
                strHead         = "Delete Local User State";
                elementText1    = "Channel";
                elementText2    = "Key";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "Key to delete";
                buttonTitle     = "Delete";
                showEntryText3  = false;
            }
            else if (cds == CommonDialogStates.SetUserState)
            {
                strHead         = "Add User State";
                elementText1    = "Channel";
                elementText2    = "State";
                elementText3    = "UUID";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "enter json format or skip to use local";
                elementSubText3 = "Enter UUID";
                buttonTitle     = "Add";
            }
            else if (cds == CommonDialogStates.GetUserState)
            {
                strHead         = "Get User State";
                elementText1    = "Channel";
                elementText2    = "UUID";
                elementSubText1 = "Enter Channel";
                elementSubText2 = "Enter UUID";
                buttonTitle     = "Get";
                showEntryText3  = false;
            }

            EntryElement entryText3 = null;

            if (showEntryText3)
            {
                entryText3 = new EntryElement(elementText3, elementSubText3, "");
                entryText3.AutocapitalizationType = UITextAutocapitalizationType.None;
                entryText3.AutocorrectionType     = UITextAutocorrectionType.No;
            }

            EntryElement entryText1 = new EntryElement(elementText1, elementSubText1, "");

            entryText1.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryText1.AutocorrectionType     = UITextAutocorrectionType.No;

            EntryElement entryText2 = new EntryElement(elementText2, elementSubText2, "");

            entryText2.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryText2.AutocorrectionType     = UITextAutocorrectionType.No;

            var newroot = new RootElement(strHead, 0, 0)
            {
                new Section()
                {
                    entryText1,
                    entryText2,
                    entryText3
                },
                new Section("")
                {
                    new StyledStringElement(buttonTitle, () => {
                        if (cds == CommonDialogStates.AddLocalUserState)
                        {
                            string currentState = pubnub.SetLocalUserState(entryText1.Value, entryText2.Value, entryText3.Value);
                            Display(string.Format("Current user state: {0}", currentState));
                        }
                        else if (cds == CommonDialogStates.DeleteLocalUserState)
                        {
                            string currentUserStateAfterDelete = pubnub.SetLocalUserState(entryText1.Value, entryText2.Value, null);
                            Display(string.Format("Current user state: {0}", currentUserStateAfterDelete));
                        }
                        else if (cds == CommonDialogStates.SetUserState)
                        {
                            string jsonUserState = "";
                            if (string.IsNullOrEmpty(entryText2.Value))
                            {
                                jsonUserState = pubnub.GetLocalUserState(entryText1.Value);
                            }
                            else
                            {
                                jsonUserState = entryText2.Value;
                            }
                            pubnub.SetUserState <string> (entryText1.Value, entryText3.Value, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        else if (cds == CommonDialogStates.GetUserState)
                        {
                            Display("Running get user state");
                            pubnub.GetUserState <string> (entryText1.Value, entryText2.Value, DisplayReturnMessage, DisplayErrorMessage);
                        }

                        AppDelegate.navigation.PopViewControllerAnimated(true);
                    })
                    {
                        BackgroundColor = UIColor.Blue,
                        TextColor       = UIColor.White,
                        Alignment       = UITextAlignment.Center
                    },
                },
            };

            dvc = new DialogViewController(newroot, true);
            AppDelegate.navigation.PushViewController(dvc, true);
        }
 public GrantDialogFragment(CommonDialogStates cds){
     this.cds = cds;
 }