protected ISpanned RemoveLastChar(ISpanned text) { var builder = new SpannableStringBuilder(text); builder.Delete(text.Length() - 1, text.Length()); return(builder); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); AppContextLiveData.Instance.SetLocale(this); SetContentView(Resource.Layout.PrivacyPolicyActivityPortrait); var toolbar = FindViewById <Toolbar>(Resource.Id.privacyPolicyToolbar); SetActionBar(toolbar); ActionBar.SetDisplayShowHomeEnabled(true); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetDisplayShowTitleEnabled(true); ActionBar.SetTitle(Resource.String.PrivacyPolicyStatement); ISpanned sp = Html.FromHtml(GetString(Resource.String.PrivacyPolicy)); FindViewById <TextView>(Resource.Id.textViewPrivacyPolicy).SetText(sp, TextView.BufferType.Spannable); FindViewById <Button>(Resource.Id.buttonPrivacyPolicyAgreement).SetOnClickListener(this); FindViewById <Button>(Resource.Id.buttonPrivacyPolicyRejection).SetOnClickListener(this); FindViewById <Button>(Resource.Id.buttonPrivacyPolicyAgreement).Visibility = AppContextLiveData.Instance.Settings.IsPrivacyPolicyApprovementNeeded() ? ViewStates.Visible : ViewStates.Gone; FindViewById <Button>(Resource.Id.buttonPrivacyPolicyRejection).Visibility = AppContextLiveData.Instance.Settings.IsPrivacyPolicyApprovementNeeded() ? ViewStates.Visible : ViewStates.Gone; }
internal ICharSequence AutoIndent(ICharSequence source, ISpanned dest, int dstart, int dend) { int istart = FindLineBreakPosition(dest, dstart); // append white space of previous line and new indent return(new Java.Lang.String(source + CreateIndentForNextLine(dest, dend, istart))); }
/// <summary> /// Gets the last instance of an Object /// </summary> /// <returns>Java.Lang.Object</returns> /// <param name="text">ISpanned</param> /// <param name="kind">Class</param> static Java.Lang.Object GetLast(ISpanned text, Class kind) { var length = text.Length(); var spans = text.GetSpans(0, length, kind); return(spans.Length > 0 ? spans.Last() : null); }
private void SetText(TextView control, string html) { var htmlLabel = (HtmlLabel)Element; // Set the type of content and the custom tag list handler using var listTagHandler = new ListTagHandler(htmlLabel.AndroidListIndent); // KWI-FIX: added AndroidListIndent parameter var imageGetter = new UrlImageParser(Control); FromHtmlOptions fromHtmlOptions = htmlLabel.AndroidLegacyMode ? FromHtmlOptions.ModeLegacy : FromHtmlOptions.ModeCompact; ISpanned sequence = Build.VERSION.SdkInt >= BuildVersionCodes.N ? Html.FromHtml(html, fromHtmlOptions, imageGetter, listTagHandler) : Html.FromHtml(html, imageGetter, listTagHandler); using var strBuilder = new SpannableStringBuilder(sequence); // Make clickable links if (!Element.GestureRecognizers.Any()) { control.MovementMethod = LinkMovementMethod.Instance; URLSpan[] urls = strBuilder .GetSpans(0, sequence.Length(), Class.FromType(typeof(URLSpan))) .Cast <URLSpan>() .ToArray(); foreach (URLSpan span in urls) { MakeLinkClickable(strBuilder, span); } } // Android adds an unnecessary "\n" that must be removed using ISpanned value = RemoveLastChar(strBuilder); // Finally sets the value of the TextView control.SetText(value, TextView.BufferType.Spannable); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); AppContextLiveData.Instance.SetLocale(this); SetContentView(Resource.Layout.AboutActivity); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetActionBar(toolbar); ActionBar.SetDisplayShowHomeEnabled(true); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetDisplayShowTitleEnabled(true); ActionBar.SetTitle(Resource.String.AboutActivity); var versionTextView = FindViewById <TextView>(Resource.Id.aboutVersion); var versionNumber = DependencyService.Get <IAppVersionService>().GetVersionNumber(); var buildNumber = DependencyService.Get <IAppVersionService>().GetBuildNumber(); var firstInstall = DependencyService.Get <IAppVersionService>().GetInstallDate(); versionTextView.Text = $"Version: {versionNumber} ({buildNumber}) installed on {firstInstall.ToShortDateString()}"; var buttonPrivacyPolicy = FindViewById <TextView>(Resource.Id.textViewPrivacyPolicyLink); ISpanned sp = Html.FromHtml($"<a href=''>{GetString(Resource.String.PrivacyPolicyStatement)}</a>"); buttonPrivacyPolicy.SetText(sp, TextView.BufferType.Spannable); buttonPrivacyPolicy.SetOnClickListener(this); }
private void Init() { _questionnaireViewModel = new QuestionnaireViewModel(); TextView questionnaireTitle = FindViewById <TextView>(Resource.Id.questionnaire_title); questionnaireTitle.Text = REGISTER_QUESTIONAIRE_HEADER; questionnaireTitle.ContentDescription = REGISTER_QUESTIONAIRE_HEADER; questionnaireTitle.SetAccessibilityDelegate(AccessibilityUtils.GetHeadingAccessibilityDelegate()); TextView questionnaireSubtitle = FindViewById <TextView>(Resource.Id.questionnaire_subtitle); ISpanned questionnaireSubtitleTextFormatted = HtmlCompat.FromHtml(REGISTER_QUESTIONAIRE_SYMPTOMONSET_TEXT, HtmlCompat.FromHtmlModeLegacy); questionnaireSubtitle.TextFormatted = questionnaireSubtitleTextFormatted; questionnaireSubtitle.ContentDescriptionFormatted = questionnaireSubtitleTextFormatted; _questionnaireButton = FindViewById <Button>(Resource.Id.questionnaire_button); _questionnaireButton.Text = REGISTER_QUESTIONAIRE_NEXT; _questionnaireButton.ContentDescription = REGISTER_QUESTIONAIRE_NEXT; _questionnaireButton.Click += OnNextButtonClick; _infoButton = FindViewById <ImageButton>(Resource.Id.questionnaire_info_button); _infoButton.ContentDescription = REGISTER_QUESTIONAIRE_ACCESSIBILITY_DATE_INFO_BUTTON; _infoButton.Click += OnInfoButtonPressed; _closeButton = FindViewById <Button>(Resource.Id.close_cross_btn); _closeButton.ContentDescription = SettingsViewModel.SETTINGS_ITEM_ACCESSIBILITY_CLOSE_BUTTON; _closeButton.Click += new SingleClick((o, ev) => ShowAreYouSureToExitDialog()).Run; LogUtils.LogMessage(LogSeverity.INFO, "The user is seeing the Questionnaire page"); PrepareRadioButtons(); }
public static string SpannedToHtml(ISpanned spanned) { string htmlString = Html.ToHtml(spanned, ToHtmlOptions.ParagraphLinesIndividual); string cleanString = CleanHtml(htmlString); return(cleanString); }
public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { try { string val = dest.ToString().Insert(dstart, source.ToString()); int input = int.Parse(val); if (IsInRange(m_Min, m_Max, input)) { return(null); } } catch (Exception ex) { Console.WriteLine("FilterFormatted Error: " + ex.Message); } return(new String(string.Empty)); }
private string CreateIndentForNextLine(ISpanned dest, int dend, int istart) { if (istart > -1) { int iend; for (iend = ++istart; iend < dend; ++iend) { char c = dest.CharAt(iend); if (c != ' ' && c != '\t') { break; } } var subsequence = dest.SubSequence(istart, iend); return(subsequence + AddBulletPointIfNeeded(dest.CharAt(iend))); } else { return(""); } }
private void SetHtmlText() { var element = (this.Element as AppLabel); var text = element.Text; if (!String.IsNullOrEmpty(element.HtmlText)) { text = element.HtmlText; } if (String.IsNullOrEmpty(text)) { text = ""; } ISpanned spanned = null; if ((int)Android.OS.Build.VERSION.SdkInt >= 24) { spanned = Html.FromHtml(text, FromHtmlOptions.ModeLegacy); } else #pragma warning disable CS0618 // Type or member is obsolete { spanned = Html.FromHtml(text); } #pragma warning restore CS0618 // Type or member is obsolete this.Control.TextFormatted = spanned; }
public void SetDirty(bool forceUpdate) { _isDirty = true; _style = null; _attributedValue = null; if (forceUpdate) { UpdateDisplay(); } }
private void SetupSubTextWithLink(TextView textView, string formattedText) { ISpanned formattedDescription = HtmlCompat.FromHtml(formattedText, HtmlCompat.FromHtmlModeLegacy); textView.TextFormatted = formattedDescription; textView.ContentDescriptionFormatted = formattedDescription; textView.MovementMethod = LinkMovementMethod.Instance; Color linkColor = new Color(ContextCompat.GetColor(this, Resource.Color.linkColor)); textView.SetLinkTextColor(linkColor); }
public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { for (int i = start; i < end; ++i) { if (!Character.IsDigit(source.CharAt(i)) && !backgroundHintTextView.IsCharInFilter(source.CharAt(i))) { return new Java.Lang.String(""); } } return null; }
public void UpdateItemDisplay(ISpanned text, int id) { try { this.SetText(text, TextView.BufferType.Normal); this.Id = id; } catch (Exception e) { Console.WriteLine(e.Message); } }
public static CharacterStyle FindSpan(ISpanned text, Java.Lang.Object[] spans, int startIndex) { foreach (var span in spans) { if (startIndex == text.GetSpanStart(span)) { return(span.JavaCast <CharacterStyle>()); } } return(null); }
void Init() { Bundle textFieldsBundle = Intent.Extras; string titleText = textFieldsBundle.GetString("title"); string descriptionText = textFieldsBundle.GetString("description"); string buttonText = textFieldsBundle.GetString("button"); TextView subtitleTextView = FindViewById <TextView>(Resource.Id.error_subtitle); if (textFieldsBundle.ContainsKey("subtitle")) { string subtitleText = textFieldsBundle.GetString("subtitle"); subtitleTextView.Text = subtitleText; subtitleTextView.ContentDescription = subtitleText; subtitleTextView.Visibility = ViewStates.Visible; } else { subtitleTextView.Visibility = ViewStates.Gone; } TextView errorTitle = FindViewById <TextView>(Resource.Id.error_title); errorTitle.Text = titleText; errorTitle.ContentDescription = titleText; errorTitle.SetAccessibilityDelegate(AccessibilityUtils.GetHeadingAccessibilityDelegate()); TextView errorDescription = FindViewById <TextView>(Resource.Id.error_description); ISpanned formattedDescription = HtmlCompat.FromHtml(descriptionText, HtmlCompat.FromHtmlModeLegacy); errorDescription.TextFormatted = formattedDescription; errorDescription.ContentDescriptionFormatted = formattedDescription; errorDescription.MovementMethod = Android.Text.Method.LinkMovementMethod.Instance; ViewGroup close = FindViewById <ViewGroup>(Resource.Id.close_cross_btn); close.Click += new SingleClick((o, ev) => { NavigationHelper.GoToResultPageAndClearTop(this); }).Run; close.ContentDescription = SettingsViewModel.SETTINGS_ITEM_ACCESSIBILITY_CLOSE_BUTTON; Button button = FindViewById <Button>(Resource.Id.error_button); button.Text = buttonText; button.ContentDescription = buttonText; button.Click += new SingleClick((o, ev) => { NavigationHelper.GoToResultPageAndClearTop(this); }).Run; this.Title = textFieldsBundle.GetString("title"); }
private int FindLineBreakPosition(ISpanned dest, int dstart) { int istart = dstart - 1; for (; istart > -1; --istart) { char c = dest.CharAt(istart); if (c == '\n') { break; } } return(istart); }
public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { try { var val = dest.ToString().Insert(dstart, source.ToString()); var input = int.Parse(val); if (IsInRange(_min, _max, input)) return null; } catch (Exception ex) { } return new String(string.Empty); }
/// <summary> /// Gets the last instance of a given Spanned Object /// </summary> /// <returns>The instance of a Spanned Object</returns> /// <param name="text">The text contained within the span</param> /// <param name="kind">Object type</param> static Java.Lang.Object getLast(ISpanned text, Java.Lang.Class kind) { /* * This knows that the last returned object from getSpans() * will be the most recently added. */ Java.Lang.Object [] objs = text.GetSpans(0, text.Length(), kind); if (objs.Length == 0) { return(null); } else { return(objs [objs.Length - 1]); } }
private ShowCaseView(Context mActivity, string mTitle, ISpanned mSpannedTitle, string mId, double mFocusCircleRadiusFactor, View mView, Color mBackgroundColor, Color mFocusBorderColor, int mTitleGravity, int mTitleStyle, int mTitleSize, int mTitleSizeUnit, int mCustomViewRes, int mFocusBorderSize, int mRoundRectRadius, OnViewInflateListener mViewInflateListener, Animation mEnterAnimation, Animation mExitAnimation, AnimationListener mAnimationListener, bool mCloseOnTouch, bool mEnableTouchOnFocusedView, bool mFitSystemWindows, FocusShape mFocusShape, DismissListener mDismissListener, long mDelay, int mFocusAnimationMaxValue, int mFocusAnimationStep, int mFocusPositionX, int mFocusPositionY, int mFocusCircleRadius, int mFocusRectangleWidth, int mFocusRectangleHeight, bool mFocusAnimationEnabled, int mAnimationDuration = 400, int mCenterX = 0, int mCenterY = 0, ViewGroup mRoot = null, ISharedPreferences mSharedPreferences = null, Calculator mCalculator = null, float[] mLastTouchDownXY = null) : base(mActivity) { this.mActivity = (mActivity as Activity); this.mTitle = mTitle; this.mSpannedTitle = mSpannedTitle; this.mId = mId; this.mFocusCircleRadiusFactor = mFocusCircleRadiusFactor; this.mView = mView; this.mBackgroundColor = mBackgroundColor; this.mFocusBorderColor = mFocusBorderColor; this.mTitleGravity = mTitleGravity; this.mTitleStyle = mTitleStyle; this.mTitleSize = mTitleSize; this.mTitleSizeUnit = mTitleSizeUnit; this.mCustomViewRes = mCustomViewRes; this.mFocusBorderSize = mFocusBorderSize; this.mRoundRectRadius = mRoundRectRadius; this.mViewInflateListener = mViewInflateListener; this.mEnterAnimation = mEnterAnimation; this.mExitAnimation = mExitAnimation; this.mAnimationListener = mAnimationListener; this.mCloseOnTouch = mCloseOnTouch; this.mEnableTouchOnFocusedView = mEnableTouchOnFocusedView; this.mFitSystemWindows = mFitSystemWindows; this.mFocusShape = mFocusShape; this.mDismissListener = mDismissListener; this.mDelay = mDelay; this.mAnimationDuration = mAnimationDuration; this.mFocusAnimationMaxValue = mFocusAnimationMaxValue; this.mFocusAnimationStep = mFocusAnimationStep; this.mCenterX = mCenterX; this.mCenterY = mCenterY; this.mRoot = mRoot; this.mSharedPreferences = mSharedPreferences; this.mCalculator = mCalculator; this.mFocusPositionX = mFocusPositionX; this.mFocusPositionY = mFocusPositionY; this.mFocusCircleRadius = mFocusCircleRadius; this.mFocusRectangleWidth = mFocusRectangleWidth; this.mFocusRectangleHeight = mFocusRectangleHeight; this.mLastTouchDownXY = mLastTouchDownXY; this.mFocusAnimationEnabled = mFocusAnimationEnabled; InitializeParameters(); }
/// <summary> /// Returns a SpannableString containing interactive sources for subtitles. /// </summary> /// <param name="action">Action that should be started when the user interacts with the source.</param> /// <param name="textWithSubstitutes">The parsed text with substitutes</param> /// <param name="sources">The parsed sources</param> /// <returns>A SpannableString parsed from the textWithSubstitutes for the subtitles. Returns null, if the provided action is null.</returns> public SpannableString CreateSubtitlesText(IInteractiveSourceAction action, ISpanned textWithSubstitutes, List <Source> sources) { if (action == null) { return(null); } var sourcePositions = new Dictionary <Source, FinalSourcePosition>(); // get the textpositions of each source and mark them foreach (var source in sources) { if (source == null) { continue; } int startIndex = textWithSubstitutes.ToString().IndexOf(source.SubstituteText, StringComparison.Ordinal); sourcePositions.Add(source, new FinalSourcePosition { Start = startIndex, End = startIndex + source.SubstituteText.Length }); } var str = new SpannableString(textWithSubstitutes); foreach (var src in sourcePositions) { if (src.Key == null) { continue; } str.SetSpan( ConvertSrcToClickableSpan(src.Key, action), src.Value.Start, src.Value.End, SpanTypes.ExclusiveExclusive); } return(str); }
public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { if (_editor.Modified && end - start == 1 && start < source.Length() && dstart < dest.Length()) { char c = source.CharAt(start); if (c == '\n') { return(_editor.AutoIndent( source, dest, dstart, dend)); } } return(source); }
private void Init() { // Generate and set correlation id for current authentication flow UpdateCorrelationId(LogUtils.GenerateCorrelationId()); _questionnaireViewModel = new QuestionnaireViewModel(); TextView questionnaireTitle = FindViewById <TextView>(Resource.Id.questionnaire_title); questionnaireTitle.Text = REGISTER_QUESTIONAIRE_HEADER; questionnaireTitle.ContentDescription = REGISTER_QUESTIONAIRE_HEADER; questionnaireTitle.SetAccessibilityDelegate(AccessibilityUtils.GetHeadingAccessibilityDelegate()); TextView questionnaireSubtitle = FindViewById <TextView>(Resource.Id.questionnaire_subtitle); ISpanned questionnaireSubtitleTextFormatted = HtmlCompat.FromHtml(REGISTER_QUESTIONAIRE_SYMPTOMONSET_TEXT, HtmlCompat.FromHtmlModeLegacy); questionnaireSubtitle.TextFormatted = questionnaireSubtitleTextFormatted; questionnaireSubtitle.ContentDescriptionFormatted = questionnaireSubtitleTextFormatted; _questionnaireButton = FindViewById <Button>(Resource.Id.questionnaire_button); _questionnaireButton.Text = REGISTER_QUESTIONAIRE_NEXT; _questionnaireButton.ContentDescription = REGISTER_QUESTIONAIRE_NEXT; _questionnaireButton.Click += OnNextButtonClick; _infoButton = FindViewById <ImageButton>(Resource.Id.questionnaire_info_button); _infoButton.ContentDescription = REGISTER_QUESTIONAIRE_ACCESSIBILITY_DATE_INFO_BUTTON; _infoButton.Click += OnInfoButtonPressed; _closeButton = FindViewById <Button>(Resource.Id.close_cross_btn); _closeButton.ContentDescription = SettingsViewModel.SETTINGS_ITEM_ACCESSIBILITY_CLOSE_BUTTON; _closeButton.Click += new SingleClick((o, ev) => ShowAreYouSureToExitDialog()).Run; PrepareRadioButtons(); View rootView = Window.DecorView.RootView; rootView.LayoutDirection = LayoutUtils.GetLayoutDirection(); }
private List <ISpanned> GetSpannedLog() { List <ISpanned> spannedList = new List <ISpanned>(); ISpanned logSpanned = null; foreach (string item in logEntry) { if (Build.VERSION.SdkInt < BuildVersionCodes.N) { logSpanned = Html.FromHtml(item); } else { logSpanned = Html.FromHtml(item, Android.Text.FromHtmlOptions.ModeLegacy); } spannedList.Add(logSpanned); } return(spannedList); }
public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { var empty = string.Empty.AsJavaString(); var sourceLength = source.Length(); if (sourceLength > 1) { return(source.ToString().AsJavaString()); } if (sourceLength == 0) { onDeletionDetected(); return("0".AsCharSequence()); } var lastChar = source.CharAt(sourceLength - 1); if (char.IsDigit(lastChar)) { int digit = int.Parse(lastChar.ToString()); onDigitEntered(digit); return(empty); } return(empty); }
public override ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { // Borrowed heavily from the Android source ICharSequence filterFormatted = base.FilterFormatted(source, start, end, dest, dstart, dend); if (filterFormatted != null) { source = filterFormatted; start = 0; end = filterFormatted.Length(); } int sign = -1; int dec = -1; int dlen = dest.Length(); // Find out if the existing text has a sign or decimal point characters. for (var i = 0; i < dstart; i++) { char c = dest.CharAt(i); if (IsSignChar(c)) { sign = i; } else if (IsDecimalPointChar(c)) { dec = i; } } for (int i = dend; i < dlen; i++) { char c = dest.CharAt(i); if (IsSignChar(c)) { return(new String("")); // Nothing can be inserted in front of a sign character. } if (IsDecimalPointChar(c)) { dec = i; } } // If it does, we must strip them out from the source. // In addition, a sign character must be the very first character, // and nothing can be inserted before an existing sign character. // Go in reverse order so the offsets are stable. SpannableStringBuilder stripped = null; for (int i = end - 1; i >= start; i--) { char c = source.CharAt(i); var strip = false; if (IsSignChar(c)) { if (i != start || dstart != 0) { strip = true; } else if (sign >= 0) { strip = true; } else { sign = i; } } else if (IsDecimalPointChar(c)) { if (dec >= 0) { strip = true; } else { dec = i; } } if (strip) { if (end == start + 1) { return(new String("")); // Only one character, and it was stripped. } if (stripped == null) { stripped = new SpannableStringBuilder(source, start, end); } stripped.Delete(i - start, i + 1 - start); } } return(stripped ?? filterFormatted); }
/// <summary> /// Converts HTML-formatted data to a string that contains the text content extracted from the HTML. /// </summary> /// <param name="html">A String containing HTML-formatted data.</param> /// <returns>A String of text content.</returns> public static string ConvertToText(string html) { // the platform implementations don't strip out unordered lists so we'll replace with bullet characters int i = 0; int i2; while (i > -1) { i = html.IndexOf("<li"); if (i > -1) { i2 = html.IndexOf(">", i); if (i2 > -1) { html = html.Replace(html.Substring(i, (i2 - i) + 1), "<p>• "); } } } i = 0; while (i > -1) { i = html.IndexOf("<ul"); if (i > -1) { i2 = html.IndexOf(">", i); if (i2 > -1) { html = html.Replace(html.Substring(i, (i2 - i) + 1), ""); } } } i = 0; while (i > -1) { i = html.IndexOf("<img"); if (i > -1) { i2 = html.IndexOf(">", i); if (i2 > -1) { html = html.Replace(html.Substring(i, (i2 - i) + 1), ""); } } } html = html.Replace("</ul>", ""); html = html.Replace("</li>", "<p/>"); #if __ANDROID__ ISpanned sp = Android.Text.Html.FromHtml(html, FromHtmlOptions.ModeLegacy); return(sp.ToString().Trim()); #elif __UNIFIED__ byte[] data = global::System.Text.Encoding.UTF8.GetBytes(html); NSData d = NSData.FromArray(data); NSAttributedStringDocumentAttributes importParams = new NSAttributedStringDocumentAttributes(); importParams.DocumentType = NSDocumentType.HTML; NSError error = new NSError(); error = null; NSDictionary dict = new NSDictionary(); #if __MAC__ var attrString = new NSAttributedString(d, importParams, out dict, out error); #else var attrString = new NSAttributedString(d, importParams, out dict, ref error); #endif return(attrString.Value); #elif WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81 return(Windows.Data.Html.HtmlUtilities.ConvertToText(html)); #elif WINDOWS_PHONE || WIN32 return(global::System.Net.WebUtility.HtmlDecode(Regex.Replace(html, "<(.|\n)*?>", ""))); #else throw new global::System.PlatformNotSupportedException(); #endif }
public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { string s_ = subString(source, start, end); string left_ = subString(dest, 0, dstart); string right_ = subString(dest, dend, dest.Length()); string full_ = left_ + s_ + right_; if (!HelperNumEdit.textValidate(full_, min, max)) { return(new Java.Lang.String(string.Empty)); } return(null); }
public Java.Lang.ICharSequence FilterFormatted(Java.Lang.ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { return(source.SubSequenceFormatted(0, 0)); }
public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { return(new Java.Lang.String($"modified {++_counter:D3} times")); }
public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { string val = dest.ToString().Insert(dstart, source.ToString()); if (!int.TryParse(val, out int input)) { throw new System.Exception("Value is not a valid number"); } if (InRange(input, min, max)) { return(null); } return(new Java.Lang.String(string.Empty)); }
public Java.Lang.ICharSequence FilterFormatted(Java.Lang.ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { /* Console.WriteLine ("current: \"" + GuessText.Text + "\", in: \"" + source + "\""); if (source.Length () > 0) { converted = hiraganaConverter.Convert (GuessText.Text + source); //GuessText.Text = ""; Console.WriteLine ("converted: \"" + converted + "\""); } Console.WriteLine ("returning converted: \"" + converted + "\""); return new Java.Lang.String (converted); Console.WriteLine (start + ", " + end + ", " + dstart + ", " + dend); Console.WriteLine (dest); return source; */ /* if (source.Length () == 0) { Console.WriteLine ("backspace"); } Console.WriteLine ("still works 1"); if (source.Length () > 0) { if(source.CharAt(source.Length() - 1) == 'a') { Console.WriteLine ("source: \"" + source + '"'); Console.WriteLine ("dest: \"" + dest + '"'); //GuessText.DispatchKeyEvent (new KeyEvent(0, Keycode.Del)); } return new Java.Lang.String (source.CharAt (source.Length () - 1).ToString()); } */ return null; }
public Java.Lang.ICharSequence FilterFormatted(Java.Lang.ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend) { var replacement = source.ToString(); var ok = this.MayInsertTextAt(this.currencyEdit.Text, replacement, dstart, this.currencyEdit.DecimalPlaces); if (ok) { return source; } else { return new Java.Lang.String(string.Empty); } }