Ejemplo n.º 1
0
        private void handleAuthorizationError(NSError authorizationError)
        {
            NSDictionary unauthorizedAPIInfo = (NSDictionary)authorizationError.UserInfo.ObjectForKey(WTAuthorizationRequestManager.WTUnauthorizedAppleiOSSDKAPIsKey);

            NSMutableString detailedAuthorizationErrorLogMessage = (NSMutableString) new NSString("The following authorization states do not meet the requirements:").MutableCopy();
            NSMutableString missingAuthorizations = (NSMutableString) new NSString("In order to use the Wikitude SDK, please grant access to the following:").MutableCopy();

            foreach (NSString unauthorizedAPIKey in unauthorizedAPIInfo.Keys)
            {
                NSNumber unauthorizedAPIValue = (NSNumber)unauthorizedAPIInfo.ObjectForKey(unauthorizedAPIKey);
                detailedAuthorizationErrorLogMessage.Append(new NSString("\n"));
                detailedAuthorizationErrorLogMessage.Append(unauthorizedAPIKey);
                detailedAuthorizationErrorLogMessage.Append(new NSString(" = "));
                detailedAuthorizationErrorLogMessage.Append(WTAuthorizationRequestManager.StringFromAuthorizationStatusForUnauthorizedAppleiOSSDKAPI(unauthorizedAPIValue.Int32Value, unauthorizedAPIKey));

                missingAuthorizations.Append(new NSString("\n *"));
                missingAuthorizations.Append(WTAuthorizationRequestManager.HumanReadableDescriptionForUnauthorizedAppleiOSSDKAPI(unauthorizedAPIKey));
            }
            Console.WriteLine(detailedAuthorizationErrorLogMessage);

            UIAlertController settingsAlertController = UIAlertController.Create("Required API authorizations missing", missingAuthorizations, UIAlertControllerStyle.Alert);

            settingsAlertController.AddAction(UIAlertAction.Create("Open Settings", UIAlertActionStyle.Default, (UIAlertAction obj) =>
            {
                UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString));
            }));
            settingsAlertController.AddAction(UIAlertAction.Create("NO", UIAlertActionStyle.Destructive, (UIAlertAction obj) => { }));
            this.PresentViewController(settingsAlertController, true, null);
        }
    public override void Changed(UITextView textView)
    {
        Console.WriteLine("-----" + secureText);
        if (secureTextViewEntry)
        {
            string text = textView.Text;
            if (text.Length > 0)
            {
                if ("" == lastText)
                {
                    secureText.DeleteCharacters(new NSRange(secureText.Length - 1, 1));
                    onlyPassword();
                    timer.Invalidate();
                    //base.Changed(textView);
                    return;
                }
                else
                {
                    NSString one = new NSString(text.Substring(text.Length - 1));
                    secureText.Append(one);
                    NSMutableString temp = new NSMutableString();
                    for (int i = 0; i < secureText.Length - 1; i++)
                    {
                        temp.Append(new NSString("•"));
                    }
                    temp.Append(new NSString(secureText.ToString().Substring(secureText.ToString().Length - 1)));
                    myTextView.Text = temp;

                    //timer.Invalidate();
                    timer = NSTimer.CreateScheduledTimer(2, onlyPassword);
                }
            }
            else
            {
                secureText = new NSMutableString();
            }
            //base.Changed(textView);
        }
        else
        {
            if (textView.Text.Length == 0)
            {
                secureText = new NSMutableString();
            }
            else
            {
                secureText = new NSMutableString();
                secureText.SetString(new NSString(textView.Text));
            }

            timer.Invalidate();
            //base.Changed(textView);
        }
    }
Ejemplo n.º 3
0
 public void setSecureTextViewEntry(bool _secureTextViewEntry)
 {
     secureTextViewEntry = _secureTextViewEntry;
     if (secureText.Length == 0)
     {
         return;
     }
     else
     {
         if (secureTextViewEntry)
         {
             //secret
             NSMutableString aaa = new NSMutableString();
             for (int i = 0; i < secureText.Length; i++)
             {
                 aaa.Append(new NSString("•"));
             }
             myTextView.Text = aaa;
         }
         else
         {
             //real word
             myTextView.Text = secureText;
             if (null != timer)
             {
                 timer.Invalidate();
             }
         }
     }
     Changed(myTextView);
 }
Ejemplo n.º 4
0
        private static NSString OK_QueryStringWithSignature(this NSDictionary self, NSString secretKey, NSString sigName)
        {
            var sigSource   = new NSMutableString();
            var queryString = new NSMutableString();

            var sortedKeys = self.Keys.OrderBy((NSObject arg) => arg);

            foreach (var key in sortedKeys)
            {
                var @value = self[key] as NSString;
                sigSource.Append(NSString.LocalizedFormat(@"%@=%@\", key, value));
                queryString.Append(NSString.LocalizedFormat(@"%@=%@&", key, value.OK_Encode()));
            }

            sigSource.Append(secretKey);
            queryString.Append(NSString.LocalizedFormat(@"%@=%@&", sigName, sigSource.OK_MD5()));

            return(queryString);
        }
Ejemplo n.º 5
0
        private NSMutableString MakeHiddenText()
        //Make string of '●''s for the text and return
        {
            NSMutableString temp = new NSMutableString();

            for (int i = 0; i < this.SecureText.Length; i++)
            {
                temp.Append(new NSString("●"));
            }
            return(temp);
        }
Ejemplo n.º 6
0
    private void onlyPassword()
    {
        //throw new NotImplementedException();
        timer.Invalidate();
        NSMutableString temp = new NSMutableString();

        for (int i = 0; i < secureText.Length; i++)
        {
            temp.Append(new NSString("•"));
        }
        myTextView.Text = temp;
    }
Ejemplo n.º 7
0
        public void Show()
        {
            NSMutableString message = new NSMutableString();

            NSIndexPath[] selected = appearAnimationsList.IndexPathsForSelectedItems();

            if (selected.Length > 0)
            {
                NSIndexPath indexPath = selected [0];
                message.Append(new NSString("Alert did "));
                message.Append(new NSString(showAnimations.GetItem <NSString> ((uint)indexPath.Row)));
                message.Append(new NSString("\n"));
            }

            selected = hideAnimationsList.IndexPathsForSelectedItems();
            if (selected.Length > 0)
            {
                NSIndexPath indexPath = selected [0];
                message.Append(new NSString("It will "));
                message.Append(new NSString(dismissAnimations.GetItem <NSString> ((uint)indexPath.Row)));
                message.Append(new NSString(" when close"));
            }

            alert.Message = message;
            alert.Show(true);
        }
Ejemplo n.º 8
0
        private const string randomAlphabet = "";         // TODO: Add random alphabet chars

        public static NSString GetRandomNSString()
        {
            string          alphabet       = randomAlphabet;
            var             alphabetLength = alphabet.Length;
            nint            stringLength   = 20;
            NSMutableString mstring        = new NSMutableString(stringLength);

            for (var index = 0; index < stringLength; index++)
            {
                int randomIndex = new Random().Next(1, alphabetLength);
                mstring.Append(new NSString(alphabet[randomIndex].ToString()));
            }

            return(mstring);
        }
Ejemplo n.º 9
0
        private const string randomAlphabet = ""; // TODO: Add random alphabet chars

        #endregion Fields

        #region Methods

        public static NSString GetRandomNSString()
        {
            string alphabet = randomAlphabet;
            var alphabetLength = alphabet.Length;
            nint stringLength = 20;
            NSMutableString mstring = new NSMutableString(stringLength);

            for (var index = 0; index < stringLength; index++)
            {
                int randomIndex = new Random().Next(1, alphabetLength);
                mstring.Append(new NSString(alphabet[randomIndex].ToString()));
            }

            return mstring;
        }
        public string ReplaceCharacters(string text, NSRange range, string newText)
        {
            if (text != null)
            {
                var strg   = new NSString(text);
                var result = new NSMutableString();
                result.Append(strg);
                var newContent = new NSString(newText);

                if (range.Length > 0)
                {
                    result.Replace(range, newContent);
                    return(text.Replace(text, newText));
                }
                else
                {
                    result.Insert(newContent, range.Location);
                    return(result);
                }
            }
            return(string.Empty);
        }
Ejemplo n.º 11
0
        public void Show(Object sender, EventArgs e)
        {
            NSMutableString message = new NSMutableString ();
            NSIndexPath[] selected = appearAnimationsList.IndexPathsForSelectedItems();

            if (selected.Length > 0) {
                NSIndexPath indexPath = selected [0];
                message.Append (new NSString("Alert did "));
                message.Append(new NSString(showAnimations.GetItem<NSString> ((uint)indexPath.Row)));
                message.Append (new NSString("\n"));
            }

            selected = hideAnimationsList.IndexPathsForSelectedItems();
            if (selected.Length > 0) {
                NSIndexPath indexPath = selected [0];
                message.Append (new NSString ("It will "));
                message.Append (new NSString(dismissAnimations.GetItem<NSString> ((uint)indexPath.Row)));
                message.Append (new NSString(" when close"));
            }

            alert.Message = message;
            alert.Show (true);
        }
Ejemplo n.º 12
0
        private void HandleTextChange(object sender, EventArgs e)
        {
            UITextView customEditor = (UITextView)sender;

            if (customEditor.SecureTextEntry)
            {
                string text = customEditor.Text;
                if (text.Length > 0)
                {
                    //If LastText is empty, that means deletion occured.
                    if ("" == this.LastText)
                    {       //Delete the last character from the actual text
                        this.SecureText.DeleteCharacters(new NSRange(this.SecureText.Length - 1, 1));
                        if (null != timer)
                        {
                            timer.Invalidate();
                        }
                        return;
                    }
                    // If LastText is not empty, that means (a) new character(s) was/were entered.
                    int lastTextLength = ((this.LastText.ToString()).Length); //Number of characters in LastText.
                    if (lastTextLength > 1)
                    {                                                         // If more than one character was entered (usually by pasting)
                        int    NewTextStartIndex = (text.Length - lastTextLength);
                        string TempNewCharacters = text.Substring(NewTextStartIndex);
                        // Get all the characters except the last character and add them to the secureText
                        NSString NewCharacters = new NSString(TempNewCharacters.Substring(0, TempNewCharacters.Length - 1));
                        SecureText.Append(NewCharacters);
                    }
                    // Get and add the last character
                    NSString LastCharacter = new NSString(text.Substring(text.Length - 1));
                    this.SecureText.Append(LastCharacter);
                    // Change all characters to '●' except the last character
                    NSMutableString temp = new NSMutableString();
                    for (int i = 0; i < this.SecureText.Length - 1; i++)
                    {
                        temp.Append(new NSString("●"));
                    }
                    // Add the last character as a plain text to the temp and set that into the editor.
                    temp.Append(new NSString(this.SecureText.ToString().Substring(this.SecureText.ToString().Length - 1)));
                    customEditor.Text = temp;

                    if (null != this.timer)
                    {
                        this.timer.Invalidate();
                    }
                    // Wait two seconds before changing the last character to '●'.
                    this.timer = NSTimer.CreateScheduledTimer(2, ChangeToHidden);
                }
                else
                {
                    this.SecureText = new NSMutableString();
                }
            }
            else
            {
                // If the password is plain text, then initialize it to the secureText string.
                SecureText = new NSMutableString();
                SecureText.SetString(new NSString(customEditor.Text));
                if (null != timer)
                {
                    this.timer.Invalidate();
                }
            }
        }