public static void SetStatusBarColor(Activity activity)
 {
     if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
     {
         SystemBarTintManager tintManager = new SystemBarTintManager(activity);
         tintManager.StatusBarTintEnabled = true;
         tintManager.SetStatusBarTintResource(Resource.Color.StatusBarBackground);
     }
 }
Beispiel #2
0
        //@Override
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_default);

            SystemBarTintManager tintManager = new SystemBarTintManager(this);

            tintManager.setStatusBarTintEnabled(true);
            tintManager.setNavigationBarTintEnabled(true);
        }
Beispiel #3
0
        //@Override
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_match_actionbar);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
            {
                setTranslucentStatus(true);
            }

            SystemBarTintManager tintManager = new SystemBarTintManager(this);

            tintManager.setStatusBarTintEnabled(true);
            tintManager.setStatusBarTintResource(Resource.Color.statusbar_bg);
        }
        //@Override
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_color);

            mTintManager = new SystemBarTintManager(this);
            mTintManager.setStatusBarTintEnabled(true);
            mTintManager.setNavigationBarTintEnabled(true);

            mColorPicker = (ColorPicker)FindViewById(Resource.Id.color_picker);
            applySelectedColor();

            mButton        = (Button)FindViewById(Resource.Id.button);
            mButton.Click += delegate
            {
                applySelectedColor();
            };
            //mButton.SetOnClickListener(new OnClickListener() {
            //    @Override
            //    public void onClick(View v) {
            //        applySelectedColor();
            //    }
            //});
        }
        //private string _parameterText;
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            _locator = CrossGeolocator.Current;
            // New in iOS 9 allowsBackgroundLocationUpdates must be set if you are running a background agent to track location. I have exposed this on the Geolocator via:
            // disable because it drill down the battery very quickly
            _locator.AllowsBackgroundUpdates = false;
            _locator.DesiredAccuracy = 50;
            _locator.PositionChanged -= Locator_PositionChanged;
            _locator.PositionChanged += Locator_PositionChanged;

            // parse params to show any shared location if it exists
            ParseIntent();

            var tintManager = new SystemBarTintManager(this);
            // set the transparent color of the status bar, 30% darker
            tintManager.SetTintColor(Color.ParseColor("#30000000"));
            tintManager.SetNavigationBarTintEnabled(true);
            tintManager.StatusBarTintEnabled = true;

            // prevent the soft keyboard from pushing the view up
            Window.SetSoftInputMode(SoftInput.AdjustNothing);

            // prepare icons for location / compass button
            var iconGenerator = new IconGenerator(this);
            iconGenerator.SetBackground(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.ic_location, null));
            _iconUserLocation = iconGenerator.MakeIcon();
            iconGenerator.SetBackground(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.ic_compass, null));
            _iconCompass = iconGenerator.MakeIcon();
            //var uiOptions = (int)this.Window.DecorView.SystemUiVisibility;
            //var newUiOptions = (int)uiOptions;
            //newUiOptions &= ~(int)SystemUiFlags.LowProfile;
            //newUiOptions &= ~(int)SystemUiFlags.Fullscreen;
            //newUiOptions &= ~(int)SystemUiFlags.HideNavigation;
            //newUiOptions &= ~(int)SystemUiFlags.Immersive;
            //newUiOptions |= (int)SystemUiFlags.ImmersiveSticky;
            //this.Window.DecorView.SystemUiVisibility = (StatusBarVisibility)newUiOptions;
            //Window.SetFlags(WindowManagerFlags.LayoutNoLimits, WindowManagerFlags.LayoutNoLimits);

            var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            //toolbar.Background.SetAlpha(200);
            ViewCompat.SetElevation(toolbar, 6f);
            SetSupportActionBar(toolbar);

            //Enable support action bar to display hamburger and back arrow
            // http://stackoverflow.com/questions/28071763/toolbar-navigation-hamburger-icon-missing
            _drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
            //_drawerToggle = new CustomActionBarDrawerToggle(this, _drawerLayout, toolbar, Resource.String.ApplicationName, Resource.String.ApplicationName);
            //_drawerToggle.DrawerIndicatorEnabled = true;
            _drawerLayout.SetDrawerListener(new CustomDrawerToggle(this));
            //Enable support action bar to display hamburger


            var burgerImage = FindViewById<ImageButton>(Resource.Id.burgerImage);
            burgerImage.SetOnClickListener(new HomeButtonClickListener(this));

            // SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
            SupportActionBar.SetHomeButtonEnabled(false);
            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetDisplayShowCustomEnabled(false);

            navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
            navigationView.SetNavigationItemSelectedListener(new NavigationItemSelectedListener(this));

            _bikesButton = FindViewById<FloatingActionButton>(Resource.Id.bikesButton);
            _bikesButton.BackgroundTintList = ColorStateList.ValueOf(Resources.GetColor(Resource.Color.primary_light));
            _bikesButton.Click += BikesButton_Click;

            _parkingButton = FindViewById<FloatingActionButton>(Resource.Id.parkingButton);
            _parkingButton.BackgroundTintList = ColorStateList.ValueOf(Resources.GetColor(Resource.Color.primary_light));
            _parkingButton.Click += ParkingButton_Click;

            _locationButton = FindViewById<FloatingActionButton>(Resource.Id.locationButton);
            _locationButton.BackgroundTintList = ColorStateList.ValueOf(Color.White);
            _locationButton.SetColorFilter(Color.Gray);

            _searchProgressBar = FindViewById<ProgressBar>(Resource.Id.searchProgressBar);

            // Doesn't work on Kitkat 4.4, use SetColorFilter instead
            //_locationButton.ImageTintList = ColorStateList.ValueOf(Color.Black);
            _locationButton.Click += LocationButton_Click;

            _tileButton = FindViewById<FloatingActionButton>(Resource.Id.tileButton);
            _tileButton.BackgroundTintList = ColorStateList.ValueOf(Color.White);
            _tileButton.SetColorFilter(Color.DarkGray);
            _tileButton.Click += TileButton_Click;
            var parent = (View)_tileButton.Parent;

            // Gets the parent view and posts a Runnable on the UI thread. 
            // This ensures that the parent lays out its children before calling the getHitRect() method.
            // The getHitRect() method gets the child's hit rectangle (touchable area) in the parent's coordinates.
            parent.Post(() =>
            {
                var touchRect = new Rect();
                _tileButton.GetHitRect(touchRect);
                touchRect.Top -= 200;
                touchRect.Left -= 200;
                touchRect.Bottom += 200;
                touchRect.Right += 200;


                parent.TouchDelegate = new TouchDelegate(touchRect, _tileButton);
            });

            _currentTileName = FindViewById<TextView>(Resource.Id.currentTileName);
            _currentTileNameAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.placeholder);
            _disappearTileNameAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.disappearAnimation);
            _currentTileNameAnimation.AnimationEnd += _currentTileNameAnimation_AnimationEnd;

            UnStickUserLocation();

            AutoCompleteSearchPlaceTextView = FindViewById<AutoCompleteTextView>(Resource.Id.autoCompleteSearchPlaceTextView);
            AutoCompleteSearchPlaceTextView.ItemClick += AutoCompleteSearchPlaceTextView_ItemClick;
            googlePlacesAutocompleteAdapter = new GooglePlacesAutocompleteAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line);
            AutoCompleteSearchPlaceTextView.Adapter = googlePlacesAutocompleteAdapter;


            Observable.FromEventPattern(AutoCompleteSearchPlaceTextView, "TextChanged")
                .Throttle(TimeSpan.FromMilliseconds(300))
                .Where(x => AutoCompleteSearchPlaceTextView.Text.Length >= 2)
                .Subscribe(async x =>
                {
                    try
                    {
                        RunOnUiThread(() =>
                        {
                            _searchProgressBar.Visibility = ViewStates.Visible;
                        });

                        using (var client = new HttpClient(new NativeMessageHandler()))
                        {
                            var response = await client.GetAsync(strAutoCompleteGoogleApi + AutoCompleteSearchPlaceTextView.Text + "&key=" + strGoogleApiKey).ConfigureAwait(false);
                            var responseBodyAsText = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
                            var predictions = JsonConvert.DeserializeObject<PlaceApiModel>(responseBodyAsText).predictions.ToList();
                            googlePlacesAutocompleteAdapter.Results = predictions;
                            if (AutoCompleteSearchPlaceTextView.Text.Length >= 2)
                            {
                                RunOnUiThread(() =>
                                {
                                    googlePlacesAutocompleteAdapter.NotifyDataSetChanged();
                                    EndPlacesSearch();
                                });
                            }
                        }
                    }
                    catch
                    {
                        RunOnUiThread(() =>
                        {
                            EndPlacesSearch();
                        });
                    }
                });


            //navigationView.NavigationItemSelected += (sender, e) =>
            //{
            //    e.MenuItem.SetChecked(true);
            //    //react to click here and swap fragments or navigate
            //    drawerLayout.CloseDrawers();
            //};

            // trigger the creation of the injected dependencies
            _settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
            _favoritesService = SimpleIoc.Default.GetInstance<IFavoritesService>();
        }