protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> args)
        {
            base.OnElementChanged(args);
            // Get native control (background set in shared code, but can use SetBackgroundColor here)
            SearchView searchView = (base.Control as SearchView);

            searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal);

            // Access search textview within control
            int      textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
            EditText textView   = (searchView.FindViewById(textViewId) as EditText);

            // Set custom colors
            // textView.SetBackgroundColor(G.Color.Rgb(25, 25, 25));
            textView.SetBackgroundColor(Settings.BlackBg ? G.Color.Rgb(12, 12, 12) : G.Color.Rgb(25, 25, 25));

            textView.SetHintTextColor(G.Color.Rgb(64, 64, 64));
            textView.SetTextColor(G.Color.Rgb(200, 200, 200));

            /*
             * textView.SetTextColor(G.Color.Rgb(32, 32, 32));
             * textView.SetHintTextColor(G.Color.Rgb(128, 128, 128));*/


            // Customize frame color
            int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);

            Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View);
            frameView.SetBackgroundColor(G.Color.ParseColor(CloudStreamForms.Settings.MainBackgroundColor));
            //frameView.SetBackgroundColor(G.Color.Rgb(96, 96, 96));

            /*
             * // Get native control (background set in shared code, but can use SetBackgroundColor here)
             * SearchView searchView = (base.Control as SearchView);
             * //  searchView.SetBackgroundColor(new G.Color() { A = 1, R = 1, B = 255, G = 1 });
             * searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal);
             *
             * // Access search textview within control
             * int textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
             * EditText textView = (searchView.FindViewById(textViewId) as EditText);
             *
             * // Set custom colors
             * //textView.SetBackgroundColor(G.Color.Rgb(225, 225, 225));
             * textView.SetHintTextColor(G.Color.Rgb(64, 64, 64));
             * textView.SetTextColor(G.Color.Rgb(200, 200, 200));
             * textView.SetBackgroundColor(new G.Color() { A = 1, R = 1, B = 255, G = 1 });
             *
             *
             * // Customize frame color
             * int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);
             * Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View);
             * Main.print(CloudStreamForms.Settings.MainBackgroundColor);
             * //  frameView.SetBackgroundColor(G.Color.ParseColor(CloudStreamForms.Settings.MainBackgroundColor));*/
        }
Esempio n. 2
0
        public void SearchType(View view)
        {
            KeyEvent    enter      = new KeyEvent(KeyEventActions.Down, Keycode.Enter);
            SearchView  searchView = FindViewById <SearchView>(Resource.Id.searchView1);
            RadioButton radio      = ((RadioButton)view);
            TextView    text       = FindViewById <TextView>(Resource.Id.searchTVFAB);

            if (radio == FindViewById <RadioButton>(Resource.Id.topicRadio))
            {
                if (radio.Checked)
                {
                    searchView.Enabled = true;

                    searchView.SetImeOptions(Android.Views.InputMethods.ImeAction.Go);
                    searchView.SetInputType(Android.Text.InputTypes.ClassText);
                    searchView.QueryTextSubmit += Search_QueryTextSubmit;
                    searchView.SetQueryHint("Search By topic");
                    text.Text = GetString(Resource.String.Search);
                }
            }
            //Chapter/Question Number Search
            else if (radio == FindViewById <RadioButton>(Resource.Id.chapterRadio))
            {
                if (radio.Checked)
                {
                    searchView.Enabled = true;
                    searchView.SetInputType(Android.Text.InputTypes.ClassNumber);
                    searchView.SetQueryHint("Search By Number...");
                    text.Text = GetString(Resource.String.Search);
                }
            }
            else if (radio == FindViewById <RadioButton>(Resource.Id.viewAllRadio))
            {
                text.Text = GetString(Resource.String.View_Button);
                if (!creedOpen)
                {
                    searchView.SetIconifiedByDefault(true);
                    searchView.Enabled = false;
                }
            }
        }
Esempio n. 3
0
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);

            // Get native control (background set in shared code, but can use SetBackgroundColor here)
            SearchView searchView = (base.Control as SearchView);

            searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal);

            //change icon search
            searchView.SetIconifiedByDefault(false);
            int searchIconId = Context.Resources.GetIdentifier("android:id/search_mag_icon", null, null);
            var icon         = searchView.FindViewById(searchIconId);

            icon.SetBackgroundColor(Android.Graphics.Color.White);
            (icon as ImageView).SetImageResource(Resource.Drawable.ios23);

            //change icon close
            int searchViewCloseButtonId = Control.Resources.GetIdentifier("android:id/search_close_btn", null, null);
            var closeIcon = searchView.FindViewById(searchViewCloseButtonId);

            (closeIcon as ImageView).SetImageResource(Resource.Drawable.close);

            // Access search textview within control
            int      textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
            EditText textView   = (searchView.FindViewById(textViewId) as EditText);

            textView.SetTextColor(Android.Graphics.Color.Black);
            textView.SetHintTextColor(Android.Graphics.Color.Rgb(180, 180, 180));
            textView.TextAlignment = Android.Views.TextAlignment.TextStart;

            //add borders to the search bar
            if (textView != null)
            {
                var shape = new ShapeDrawable(new RectShape());
                shape.Paint.Color       = Android.Graphics.Color.Transparent;
                shape.Paint.StrokeWidth = 0;
                shape.Paint.SetStyle(Paint.Style.Stroke);
                textView.Background = shape;
            }

            var gradient = new GradientDrawable();

            gradient.SetCornerRadius(5.0f);
            gradient.SetStroke((int)this.Context.ToPixels(1.0f), Android.Graphics.Color.Rgb(169, 169, 169));

            this.Control.SetBackground(gradient);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> args)
        {
            base.OnElementChanged(args);

            // Get native control (background set in shared code, but can use SetBackgroundColor here)
            SearchView searchView = (base.Control as SearchView);

            searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal);
            searchView.Iconified = true;
            searchView.SetIconifiedByDefault(false);

            int searchIconId = Context.Resources.GetIdentifier("android:id/search_mag_icon", null, null);
            var icon         = searchView.FindViewById(searchIconId);

            (icon as ImageView).SetImageResource(Resource.Drawable.ic_search_white_24dp);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);

            SearchView searchView = (base.Control as SearchView);

            searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal);

            // Access search textview within control
            int      textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
            EditText textView   = (searchView.FindViewById(textViewId) as EditText);

            // Set custom colors

            textView.SetTextColor(Color.Black);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> args)
        {
            base.OnElementChanged(args);

            // Get native control (background set in shared code, but can use SetBackgroundColor here)
            SearchView searchView = (base.Control as SearchView);

            searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal);

            // Set the magnifying classe's color to white.
            var searchIconId    = searchView.Resources.GetIdentifier("android:id/search_mag_icon", null, null);
            var searchPlateIcon = searchView.FindViewById(searchIconId);

            (searchPlateIcon as ImageView).SetColorFilter(G.Color.White, G.PorterDuff.Mode.SrcIn);

            // Eliminate the grey underline bar for the search bar
            var plateId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);
            var plate   = Control.FindViewById(plateId);

            plate.SetBackgroundColor(Android.Graphics.Color.Transparent);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);
            // Get native control (background set in shared code, but can use SetBackgroundColor here)
            SearchView searchView = (base.Control as SearchView);

            searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal);

            // Access search textview within control
            int      textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
            EditText textView   = (searchView.FindViewById(textViewId) as EditText);

            // Set custom colors
            //textView.SetBackgroundColor(Color.White.ToAndroid());
            textView.SetTextColor(Xamarin.Forms.Color.White.ToAndroid());
            textView.SetHintTextColor(Xamarin.Forms.Color.White.ToAndroid());

            // Customize frame color
            int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);

            DroidView.View frameView = (searchView.FindViewById(frameId) as DroidView.View);
            //frameView.SetBackgroundColor(Color.White.ToAndroid());

            var searchIconId = searchView.Resources.GetIdentifier("android:id/search_mag_icon", null, null);

            if (searchIconId > 0)
            {
                var searchPlateIcon = searchView.FindViewById(searchIconId);
                (searchPlateIcon as ImageView).SetColorFilter(Xamarin.Forms.Color.White.ToAndroid(), PorterDuff.Mode.SrcIn);
            }
            var searchCloseId = searchView.Resources.GetIdentifier("android:id/search_close_btn", null, null);

            if (searchCloseId > 0)
            {
                var searchCloseIcon = searchView.FindViewById(searchCloseId);
                (searchCloseIcon as ImageView).SetColorFilter(Xamarin.Forms.Color.White.ToAndroid(), PorterDuff.Mode.SrcIn);
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);
            var searchBar = (CustomSearchBar)Element;

            // Get native control (background set in shared code, but can use SetBackgroundColor here)
            SearchView searchView = (base.Control as SearchView);

            searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal);

            // Access search textview within control
            int      textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
            EditText textView   = (searchView.FindViewById(textViewId) as EditText);

            textView.SetHintTextColor(G.Color.Rgb(200, 200, 200));
            textView.SetTextColor(global::Android.Graphics.Color.White);

            // Customize frame color
            int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);

            Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View);
            frameView.SetBackgroundColor(G.Color.Rgb(100, 100, 100));
        }
Esempio n. 9
0
        void Background_PropertyChanged(object sender, PropertyChangingEventArgs eventArgs)
        {
            SearchView searchView = (base.Control as SearchView);

            searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal);

            int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);

            if (eventArgs.PropertyName == "IsdarkThemEnabled")
            {
                var isDarkTheme = false; //(App.Current as App).IsDarkThemeEnabled; //Can be set from the app from settings, but just set to false for now

                Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View);

                if (isDarkTheme)
                {
                    frameView.SetBackgroundColor(G.Color.Rgb(51, 48, 46));
                }
                else
                {
                    frameView.SetBackgroundColor(G.Color.Rgb(250, 250, 250));
                }
            }
        }
Esempio n. 10
0
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);

            // Get native control (background set in shared code, but can use SetBackgroundColor here)
            SearchView searchView = (base.Control as SearchView);

            searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal);

            // Access search textview within control
            int      textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
            EditText textView   = (searchView.FindViewById(textViewId) as EditText);

            // Set custom colors
            textView.SetBackgroundColor(G.Color.Rgb(225, 225, 225));
            textView.SetTextColor(G.Color.Rgb(74, 189, 172));
            textView.SetHintTextColor(G.Color.Rgb(211, 211, 211));

            // Customize frame color
            int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);

            Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View);
            //frameView.SetBackgroundColor(G.Color.Rgb(255, 255, 255));
        }
Esempio n. 11
0
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> args)
        {
            base.OnElementChanged(args);
            // Get native control (background set in shared code, but can use SetBackgroundColor here)
            SearchView searchView = (base.Control as SearchView);

            searchView.SetInputType(InputTypes.ClassText | InputTypes.TextVariationNormal);
            if (Settings.TapjackProtectionSearch)
            {
                searchView.FilterTouchesWhenObscured = true;
            }

            // Access search textview within control
            int      textViewId = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
            EditText textView   = (searchView.FindViewById(textViewId) as EditText);

            if (args.NewElement.FontFamily == null)
            {
                args.NewElement.FontFamily = CloudStreamForms.Settings.CurrentFont.FontStyle;
            }
            // Set custom colors
            // textView.SetBackgroundColor(G.Color.Rgb(25, 25, 25));
            int color = Settings.BlackColor - 5;

            if (color < 0)
            {
                color = -color * 2;
            }
            textView.SetBackgroundColor(G.Color.Rgb(color, color, color));            //Settings.BlackBg ? G.Color.Rgb(12, 12, 12) : G.Color.Rgb(25, 25, 25));

            textView.SetHintTextColor(G.Color.Rgb(64, 64, 64));
            textView.SetTextColor(G.Color.Rgb(200, 200, 200));

            /*
             * IntPtr IntPtrtextViewClass = JNIEnv.FindClass(typeof(TextView));
             * IntPtr mCursorDrawableResProperty = JNIEnv.GetFieldID(IntPtrtextViewClass, "mCursorDrawableRes", "I");
             *
             * JNIEnv.SetField(Control.Handle, mCursorDrawableResProperty, Resource.Drawable.my_cursor);*/
            /*
             * textView.SetTextColor(G.Color.Rgb(32, 32, 32));
             * textView.SetHintTextColor(G.Color.Rgb(128, 128, 128));*/


            // Customize frame color
            int frameId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);

            Android.Views.View frameView = (searchView.FindViewById(frameId) as Android.Views.View);
            frameView.SetBackgroundColor(G.Color.Transparent);            //G.Color.ParseColor(CloudStreamForms.Settings.MainBackgroundColor));


            var searchIconId = searchView.Resources.GetIdentifier("android:id/search_mag_icon", null, null);

            if (searchIconId > 0)
            {
                var searchPlateIcon = searchView.FindViewById(searchIconId);
                searchPlateIcon.ScaleX       = 0.75f;
                searchPlateIcon.ScaleY       = 0.75f;
                searchPlateIcon.TranslationX = -5;

                (searchPlateIcon as ImageView).SetImageDrawable(context.GetDrawable(Resource.Drawable.MainSearchIcon));
                (searchPlateIcon as ImageView).SetColorFilter(G.Color.Rgb(190, 190, 190));
            }
        }