protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); SearchView searchView = Control; var isDesigner = Context.IsDesignerContext(); if (searchView == null) { searchView = CreateNativeControl(); searchView.SetIconifiedByDefault(false); // set Iconified calls onSearchClicked // https://github.com/aosp-mirror/platform_frameworks_base/blob/6d891937a38220b0c712a1927f969e74bea3a0f3/core/java/android/widget/SearchView.java#L674-L680 // which causes requestFocus. The designer does not support focuses. if (!isDesigner) { searchView.Iconified = false; } SetNativeControl(searchView); _editText = _editText ?? Control.GetChildrenOfType <EditText>().FirstOrDefault(); if (_editText != null) { var useLegacyColorManagement = e.NewElement.UseLegacyColorManagement(); _textColorSwitcher = new TextColorSwitcher(_editText.TextColors, useLegacyColorManagement); _hintColorSwitcher = new TextColorSwitcher(_editText.HintTextColors, useLegacyColorManagement); } } if (!isDesigner) { ClearFocus(searchView); } UpdateInputType(); UpdatePlaceholder(); UpdateText(); UpdateEnabled(); UpdateCancelButtonColor(); UpdateFont(); UpdateHorizontalTextAlignment(); UpdateVerticalTextAlignment(); UpdateTextColor(); UpdateCharacterSpacing(); UpdatePlaceholderColor(); UpdateMaxLength(); if (e.OldElement == null) { searchView.SetOnQueryTextListener(this); searchView.SetOnQueryTextFocusChangeListener(this); } }
public SearchHandlerAppearanceTracker(IShellSearchView searchView) { _searchHandler = searchView.SearchHandler; _control = searchView.View; _searchHandler.PropertyChanged += SearchHandlerPropertyChanged; _searchHandler.FocusChangeRequested += SearchHandlerFocusChangeRequested; _editText = (_control as ViewGroup).GetChildrenOfType <EditText>().FirstOrDefault(); _textColorSwitcher = new TextColorSwitcher(_editText.TextColors, false); _hintColorSwitcher = new TextColorSwitcher(_editText.HintTextColors, false); UpdateSearchBarColors(); UpdateFont(); UpdateHorizontalTextAlignment(); UpdateVerticalTextAlignment(); UpdateInputType(); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { base.OnElementChanged(e); SearchView searchView = Control; if (searchView == null) { searchView = CreateNativeControl(); searchView.SetIconifiedByDefault(false); searchView.Iconified = false; SetNativeControl(searchView); _editText = _editText ?? Control.GetChildrenOfType <EditText>().FirstOrDefault(); if (_editText != null) { var useLegacyColorManagement = e.NewElement.UseLegacyColorManagement(); _textColorSwitcher = new TextColorSwitcher(_editText.TextColors, useLegacyColorManagement); _hintColorSwitcher = new TextColorSwitcher(_editText.HintTextColors, useLegacyColorManagement); } } ClearFocus(searchView); UpdateInputType(); UpdatePlaceholder(); UpdateText(); UpdateEnabled(); UpdateCancelButtonColor(); UpdateFont(); UpdateHorizontalTextAlignment(); UpdateVerticalTextAlignment(); UpdateTextColor(); UpdateCharacterSpacing(); UpdatePlaceholderColor(); UpdateMaxLength(); if (e.OldElement == null) { searchView.SetOnQueryTextListener(this); searchView.SetOnQueryTextFocusChangeListener(this); } }
protected override void UpdateTextColor() { _textColorSwitcher = _textColorSwitcher ?? new TextColorSwitcher(EditText.TextColors, Element.UseLegacyColorManagement()); _textColorSwitcher.UpdateTextColor(EditText, Element.TextColor); }
protected override void UpdatePlaceholderColor() { _hintColorSwitcher = _hintColorSwitcher ?? new TextColorSwitcher(EditText.HintTextColors, Element.UseLegacyColorManagement()); _hintColorSwitcher.UpdateTextColor(EditText, Element.PlaceholderColor, EditText.SetHintTextColor); }