コード例 #1
0
        private void InitToolbar(View view)
        {
            try
            {
                var toolbar = view.FindViewById <Toolbar>(Resource.Id.toolbar);
                GlobalContext.SetToolBar(toolbar, "");

                SearchBox = view.FindViewById <SearchView>(Resource.Id.searchBox);
                SearchBox.SetQuery("", false);
                SearchBox.SetIconifiedByDefault(false);
                SearchBox.OnActionViewExpanded();
                SearchBox.Iconified        = false;
                SearchBox.QueryTextChange += SearchBoxOnQueryTextChange;
                SearchBox.QueryTextSubmit += SearchBoxOnQueryTextSubmit;
                SearchBox.ClearFocus();

                //Change text colors
                var editText = (EditText)SearchBox.FindViewById(Resource.Id.search_src_text);
                editText.SetHintTextColor(Color.Gray);
                editText.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

                //Remove Icon Search
                ImageView searchViewIcon         = (ImageView)SearchBox.FindViewById(Resource.Id.search_mag_icon);
                ViewGroup linearLayoutSearchView = (ViewGroup)searchViewIcon.Parent;
                linearLayoutSearchView.RemoveView(searchViewIcon);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #2
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.SearchGif_Menu, menu);

            try
            {
                var        item       = menu.FindItem(Resource.Id.searchUserBar);
                SearchView searchItem = (SearchView)item.ActionView;

                SearchView = searchItem.JavaCast <SearchView>();
                SearchView.SetQuery("", false);
                SearchView.SetIconifiedByDefault(false);
                SearchView.OnActionViewExpanded();
                SearchView.Iconified        = false;
                SearchView.QueryTextChange += SearchViewOnQueryTextChange;
                SearchView.QueryTextSubmit += SearchViewOnQueryTextSubmit;
                SearchView.ClearFocus();

                //Change text colors
                var editText = (EditText)SearchView.FindViewById(Resource.Id.search_src_text);
                editText.SetHintTextColor(Color.White);
                editText.SetTextColor(Color.White);

                //Remove Icon Search
                ImageView searchViewIcon         = (ImageView)SearchView.FindViewById(Resource.Id.search_mag_icon);
                ViewGroup linearLayoutSearchView = (ViewGroup)searchViewIcon.Parent;
                linearLayoutSearchView.RemoveView(searchViewIcon);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(base.OnCreateOptionsMenu(menu));
        }
コード例 #3
0
        private void InitToolbar(View view)
        {
            try
            {
                var toolbar = view.FindViewById <Toolbar>(Resource.Id.toolbar);
                GlobalContext.SetToolBar(toolbar, "", false);

                SearchBox = view.FindViewById <SearchView>(Resource.Id.browseSearchBox);
                SearchBox.SetIconifiedByDefault(false);

                if ((int)Build.VERSION.SdkInt < 23)
                {
                    SearchBox.SetOnClickListener(this);
                    SearchBox.SetOnSearchClickListener(this);
                    SearchBox.SetOnQueryTextFocusChangeListener(this);
                }

                //Change text colors
                var editText = SearchBox.FindViewById <EditText>(Resource.Id.search_src_text);
                editText.SetHintTextColor(Color.Gray);
                editText.SetTextColor(Color.Black);
                Methods.SetFocusable(editText);
                editText.Touch += EditTextOnClick;

                ImageView searchViewIcon = (ImageView)SearchBox.FindViewById(Resource.Id.search_mag_icon);
                searchViewIcon.SetColorFilter(Color.Gray);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #4
0
        private void InitComponent(View view)
        {
            try
            {
                SearchView = view.FindViewById <SearchView>(Resource.Id.searchviewbox);
                SearchView.SetQuery("", false);
                SearchView.ClearFocus();
                SearchView.OnActionViewExpanded();
                SearchView.SetIconifiedByDefault(true);
                SearchView.OnActionViewExpanded();

                //Change text colors
                var editText = (EditText)SearchView.FindViewById(Resource.Id.search_src_text);
                editText.SetHintTextColor(Color.Gray);
                editText.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

                TabLayout = view.FindViewById <TabLayout>(Resource.Id.Searchtabs);
                ViewPager = view.FindViewById <ViewPager>(Resource.Id.Searchviewpager);

                AppBarLayout = view.FindViewById <AppBarLayout>(Resource.Id.mainAppBarLayout);
                AppBarLayout.SetExpanded(true);

                //Set Tab
                ViewPager.OffscreenPageLimit = 2;
                SetUpViewPager(ViewPager);
                TabLayout.SetupWithViewPager(ViewPager);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            handler = new Handler();

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetNavigationIcon(Resource.Drawable.search_dark_24dp);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            toolbar.SetNavigationOnClickListener(this);

            searchView           = FindViewById <SearchView>(Resource.Id.searchView);
            searchView.Focusable = false;
            searchView.SetIconifiedByDefault(true);
            searchView.OnActionViewExpanded();
            searchView.SetOnQueryTextListener(this);

            var searchAutoComplete = (SearchView.SearchAutoComplete)searchView.FindViewById(Resource.Id.search_src_text);

            searchAutoComplete.SetTextColor(GetColorStateList(Resource.Color.title_color));
            searchAutoComplete.SetTextSize(Android.Util.ComplexUnitType.Sp, 14);
            searchAutoComplete.SetHintTextColor(GetColorStateList(Resource.Color.subtitle_color));
            searchAutoComplete.OnFocusChangeListener = this;

            StatusBarCompat.SetOrdinaryToolBar(this);

            bottomBar = BottomBar.AttachShy(FindViewById <CoordinatorLayout>(Resource.Id.coordinatorLayout), FindViewById(Resource.Id.frameContent), savedInstanceState);

            bottomBar.UseFixedMode();
            bottomBar.SetItems(Resource.Menu.bottombar_menu);
            bottomBar.SetOnTabClickListener(this);
        }
コード例 #6
0
        private void setSearchIcons(SearchView mSearchView)
        {
            try
            {
                Java.Lang.Reflect.Field searchField = mSearchView.Class.GetDeclaredField("mSearchButton");
                searchField.Accessible = true;
                ImageView searchBtn = (ImageView)searchField.Get(mSearchView);
                searchBtn.Background = null;

                searchBtn.SetImageResource(Resource.Drawable.search123);
                searchBtn.SetScaleType(ImageView.ScaleType.FitCenter);
                //searchBtn.LayoutParameters.Width = 80;
                //searchBtn.LayoutParameters.Height = 80;
                searchBtn.RequestLayout();
                searchField            = mSearchView.Class.GetDeclaredField("mSearchPlate");
                searchField.Accessible = true;
                LinearLayout searchPlate = (LinearLayout)searchField.Get(mSearchView);
                ImageView    closeBtn    = ((ImageView)searchPlate.GetChildAt(1));
                closeBtn.SetImageResource(Resource.Drawable.closed);
                closeBtn.SetScaleType(ImageView.ScaleType.FitCenter);
                //closeBtn.LayoutParameters.Width = 80;
                //closeBtn.LayoutParameters.Height = 80;
                closeBtn.RequestLayout();
                //searchPlate.SetBackgroundResource(Resource.Drawable.SearchPlate);
                //searchPlate.LayoutParameters.Height = 1;


                int      searchPlateId = mSearchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);
                EditText plate         = (EditText)mSearchView.FindViewById(searchPlateId);
                //plate.SetBackgroundColor(Color.White);
                plate.SetTextColor(Color.White);
                int voiceSearchPlateId = mSearchView.Context.Resources.GetIdentifier("android:id/submit_area", null, null);
                mSearchView.FindViewById(voiceSearchPlateId).SetBackgroundResource(Resource.Drawable.rounded_textview);

                // change hint color
                int      searchTextViewId = mSearchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
                TextView searchTextView   = (TextView)mSearchView.FindViewById(searchTextViewId);
                searchTextView.SetHintTextColor(Resources.GetColor(Color.LightGray));
            }
            catch (Exception ex)
            {
                string dst = "sdfsfs";
                CustomLogger.CustomLog("From Activity: " + bitopiApplication.CurrentActivity + "\nMessage: " + ex.Message + "\nStack Trace: " + ex.StackTrace + "\n\n", "", bitopiApplication.User != null ?
                                       bitopiApplication.User.UserName : "");
            }
        }
コード例 #7
0
        private void SetupSearchView()
        {
            _searchView = _toolbar.FindViewById <SearchView>(Resource.Id.action_search);

            var searchIcon = (ImageView)_searchView.FindViewById(Resource.Id.search_button);

            searchIcon.SetImageResource(Resource.Mipmap.baseline_search_white_24);

            _searchView.QueryTextChange += (sender, args) => { SearchTextChanged?.Invoke(this, EventArgs.Empty); };
        }
コード例 #8
0
        protected virtual void BuildMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.list_menu, menu);

            var actionSearch = menu.FindItem(Resource.Id.action_search);
            var searchItem   = MenuItemCompat.GetActionView(actionSearch);

            _searchView = searchItem.JavaCast <SearchView>();

            _searchTreeObserver = ViewTreeObserverCompat.From(_searchView.ViewTreeObserver);
            _searchTreeObserver.GlobalLayoutCompat += _searchTreeObserver_GlobalLayoutCompat;
            _searchView.SetIconifiedByDefault(true);


            var id              = Class.ForName("android.support.v7.appcompat.R$id");
            int searchPlateId   = (int)id.GetField("search_plate").Get(id);
            int searchSrcTextId = (int)id.GetField("search_src_text").Get(id);

            LinearLayout searchPlate = _searchView.FindViewById <LinearLayout>(searchPlateId);

            SearchView.SearchAutoComplete textArea =
                _searchView.FindViewById <SearchView.SearchAutoComplete>(searchSrcTextId);
            if (searchPlate != null)
            {
                searchPlate.SetBackgroundColor(Resources.GetColor(Resource.Color.white));
            }
            if (textArea != null)
            {
                textArea.SetTextColor(Resources.GetColor(Resource.Color.black));
            }

            if (bundledSearchInformation != null)
            {
                SearchHelper.SetSearchInfo(bundledSearchInformation);
                bundledSearchInformation = null;
            }

            if (!string.IsNullOrEmpty(SearchHelper.SearchInfo.Query) && SearchView != null)
            {
                actionSearch.ExpandActionView();
                SearchView.SetQuery(SearchHelper.SearchInfo.Query, false);
            }
        }
コード例 #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            Android.Support.V7.Widget.SearchView searchView = FindViewById <Android.Support.V7.Widget.SearchView>(Resource.Id.searchView);
            ImageView mCloseButton = (ImageView)searchView.FindViewById(Resource.Id.search_close_btn);

            mCloseButton.Enabled = false;
            mCloseButton.SetImageDrawable(null);
        }
コード例 #10
0
        protected override void InitBindings()
        {
            Bindings.Add(this.SetBinding(() => ViewModel.Clubs).WhenSourceChanges(() =>
            {
                if (ViewModel.MyClubs == null)
                {
                    List.ClearFlingAdapter();
                    List.Adapter = null;
                }
                else
                {
                    List.ClearFlingAdapter();
                    List.InjectFlingAdapter(ViewModel.Clubs, ViewHolderFactory, DataTemplateFull, DataTemplateFling, DataTemplateBasic, ContainerTemplate);
                }
            }));

            Bindings.Add(
                this.SetBinding(() => ViewModel.EmptyNoticeVisibility,
                                () => EmptyNotice.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));

            Bindings.Add(this.SetBinding(() => ViewModel.SearchQuery).WhenSourceChanges(() =>
            {
                if (!_settingQuery)
                {
                    SearchView.SetQuery(ViewModel.SearchQuery, false);
                }
                if (ViewModel.SearchQuery?.Length > 2)
                {
                    ActionButton.Show();
                }
                else
                {
                    ActionButton.Hide();
                }
            }));

            if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
            {
                List.SetOnScrollChangeListener(new ScrollListener(i =>
                {
                    if (ViewModel.Loading || !ViewModel.MoreButtonVisibility || List.Adapter == null ||
                        ViewModel.QueryType == MalClubQueries.QueryType.My)
                    {
                        return;
                    }
                    if (List.Adapter.Count - List.FirstVisiblePosition <= 2)
                    {
                        ViewModel.MoreCommand.Execute(null);
                    }
                }));
            }


            SearchView.FindViewById(Resource.Id.search_close_btn).Alpha     = 1;
            SearchView.FindViewById(Resource.Id.search_close_btn).Clickable = true;
            SearchView.FindViewById(Resource.Id.search_close_btn).SetOnClickListener(new OnClickListener(view =>
            {
                SearchView.SetQuery("", false);
                ViewModel.SearchCommand.Execute(null);
            }));

            SearchView.QueryTextChange += SearchViewOnQueryTextChange;
            SearchView.QueryTextSubmit += SearchViewOnQueryTextSubmit;

            ActionButton.SetOnClickListener(new OnClickListener(v => OpenFiltersDrawer()));
        }
コード例 #11
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.toolmenu, menu);
            var item       = menu.FindItem(Resource.Id.menu_search);
            var searchItem = MenuItemCompat.GetActionView(item);

            torSearchView = searchItem.JavaCast <Android.Support.V7.Widget.SearchView>();
            torSearchView.SetIconifiedByDefault(false);
            torSearchView.QueryHint = "Torrent Search...";
            //torSearchView.SubmitButtonEnabled = true;
            var simgid         = torSearchView.Context.Resources.GetIdentifier("search_mag_icon", "id", PackageName);
            var id             = torSearchView.Context.Resources.GetIdentifier("search_src_text", "id", PackageName);
            var searchEditText = torSearchView.FindViewById <EditText>(id);
            var searchIcon     = torSearchView.FindViewById <ImageView>(simgid);

            searchIcon.SetColorFilter(Android.Graphics.Color.White);
            searchEditText.SetTextColor(Android.Graphics.Color.White);
            searchEditText.SetHintTextColor(Android.Graphics.Color.White);



            torSearchView.QueryTextSubmit += (s, e) =>
            {
                if (IsConnected == true)
                {
                    string query = e.NewText.ToString();
                    rlStatusLayout.Visibility = ViewStates.Gone;
                    listView.Visibility       = ViewStates.Gone;
                    System.Threading.Thread thread = new System.Threading.Thread(() =>
                    {
                        UserDialogs.Instance.ShowLoading("Searching, Please Wait …", MaskType.Black);
                        torrents = Tpb.Search(new TpbQuery(query, 0, searchOrder, searchCategory));
                        if (torrents.Count == 0)
                        {
                            RunOnUiThread(() => Toast.MakeText(this, "No results found for " + query, ToastLength.Short).Show());
                        }
                        else
                        {
                            //listViewAnimShow.Duration = 200;
                            rlStatusLayout.StartAnimation(statusAnimShow);
                            listView.StartAnimation(listViewAnimShow);
                            RunOnUiThread(() => rlStatusLayout.Visibility = ViewStates.Visible);
                            RunOnUiThread(() => listView.Visibility       = ViewStates.Visible);
                            RunOnUiThread(() => listView.Adapter          = new TorListAdapter(this, torrents));
                        };

                        UserDialogs.Instance.HideLoading();
                    });;
                    thread.Start();
                    torSearchView.ClearFocus();

                    //torSearchView.SetQuery("", false);
                    //MenuItemCompat.CollapseActionView(item);
                    tvStatusText.Text = "Search results for: " + e.NewText.ToString();
                    //tvStatusText.Text = MaterialIcons.md_dis;
                    layoutWelcome.Visibility = ViewStates.Gone;

                    e.Handled = true;
                }
                else
                {
                    torSearchView.ClearFocus();
                    Toast.MakeText(this, "No internet connection detected!", ToastLength.Long).Show();
                };
            };
            //return true;
            return(base.OnCreateOptionsMenu(menu));
        }
コード例 #12
0
ファイル: SearchView.cs プロジェクト: khellang/Solvberget
        public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
        {
            inflater.Inflate(Resource.Menu.search_menu, menu);

            var inflatedSearchView = menu.FindItem(Resource.Id.search);
            var actionSearchView = new Android.Support.V7.Widget.SearchView(Activity);
            inflatedSearchView.SetActionView(actionSearchView);

            var actionView = MenuItemCompat.GetActionView(inflatedSearchView);

            
            _searchView = actionView as Android.Support.V7.Widget.SearchView;
            if (_searchView != null)
            {
                _searchView.QueryTextSubmit += sView_QueryTextSubmit;
                _searchView.QueryTextChange += sView_QueryTextChange;

                // Change the search text color to white.
                // See SearchView Source code @ https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/SearchView.java
                var queryTextView = _searchView.FindViewById(Resource.Id.search_src_text) as EditText;
                if (queryTextView != null)
                {
                    queryTextView.SetTextColor(Color.White);
                }
            }

            base.OnCreateOptionsMenu(menu, inflater);
        }