public override void OnViewCreated (View view, Bundle savedInstanceState)
		{
			base.OnViewCreated (view, savedInstanceState);
			view.SetBackgroundDrawable (AndroidExtensions.DefaultBackground);
			SetEmptyText ("You have no favorites yet");
			ListView.ItemClick += (sender, e) => stationShower (e.Id);
		}
	public static void setBackground(View view, Drawable background) {
        if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean)
        {
			SDK16.setBackground(view, background);
		} else {
			view.SetBackgroundDrawable(background);
		}
	}
Exemple #3
0
        public static void SetBackground(this AView view, Drawable drawable)
        {
            if (s_apiLevel < 16)
            {
#pragma warning disable 618 // Using older method for compatibility with API 15
                view.SetBackgroundDrawable(drawable);
#pragma warning restore 618
            }
            else
            {
                view.Background = drawable;
            }
        }
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            mView = new View(this.Activity);

            GradientDrawable background = (GradientDrawable) Resources.GetDrawable(Resource.Drawable.rounded_rect);
            background.SetColor(mColour);

            mView.SetBackgroundDrawable(background);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, Xamarin.ActionbarSherlockBinding.App.ActionBar.LayoutParams.FillParent, mWeight);
            lp.SetMargins(marginLeft, marginTop, marginRight, marginBottom);
            mView.LayoutParameters = lp;
        }
Exemple #5
0
        public void ShowToastMessage(string message, NotificationTypeEnum messageType)
        {
            Color backgroundHexColor = Color.ParseColor("#22c064");

            if (messageType == NotificationTypeEnum.Info)
            {
                backgroundHexColor = Color.ParseColor("#1274d1");
            }

            if (messageType == NotificationTypeEnum.Warning)
            {
                backgroundHexColor = Color.IndianRed;
            }

            if (messageType == NotificationTypeEnum.Danger)
            {
                backgroundHexColor = Color.Red;
            }

            var length = messageType == NotificationTypeEnum.Warning || messageType == NotificationTypeEnum.Danger ? ToastLength.Long : ToastLength.Short;

            // To dismiss existing toast, otherwise, the screen will be populated with it if the user do so
            _instance?.Cancel();
            _instance = Toast.MakeText(Android.App.Application.Context, message, length);
            //_instance.SetGravity(GravityFlags.FillHorizontal | GravityFlags.Top, 0, 0);
            _instance.SetGravity(GravityFlags.Top, 0, 0);

            GradientDrawable gradientDrawable = new GradientDrawable();

            gradientDrawable.SetCornerRadius(3f); //set corner radius

            //add icon and change background color/text TODO
            View tView = _instance.View;

            tView.SetMinimumHeight(40);

            tView.SetBackgroundDrawable(gradientDrawable);
            tView.Background.SetColorFilter(backgroundHexColor, PorterDuff.Mode.SrcIn);//Gets the actual oval background of the Toast then sets the color filter
            tView.SetPadding(10, 10, 10, 10);
            TextView text = (TextView)tView.FindViewById(Android.Resource.Id.Message);

            text.SetTextColor(Color.White);
            _instance.Show();
        }
        private void SetPoints()
        {
            var lp = new LinearLayout.LayoutParams(10, 10);

            lp.LeftMargin  = 5;
            lp.RightMargin = 5;

            var shape = new OvalShape();

            shape.Resize(10, 10);
            var dr = new ShapeDrawable(shape);

            dr.Paint.Color = DefaultPointColor.ToAndroid();

            for (var i = 0; i < this.Count; i++)
            {
                var v = new Android.Views.View(this.Context);
                v.SetBackgroundDrawable(dr);

                this.PointsContainer.AddView(v, lp);
            }
        }
Exemple #7
0
    public static void InitializeFrom(this View nativeControl, RoundedBoxView formsControl)
    {
        if (nativeControl == null || formsControl == null)
        {
            return;
        }

        var background = new GradientDrawable();

        background.SetColor(formsControl.BackgroundColor.ToAndroid());

        if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean)
        {
            nativeControl.Background = background;
        }
        else
        {
            nativeControl.SetBackgroundDrawable(background);
        }

        nativeControl.UpdateCornerRadius(formsControl.CornerRadius);
        nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
    }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Create your application here
			SetContentView (Resource.Layout.MapViewLayout);

			assignmentMapViewLayout = FindViewById<LinearLayout> (Resource.Id.mapViewAssignmentLayout);
			assignmentMapViewLayout.Click += (sender, e) => {
				var intent = new Intent (this, typeof(SummaryActivity));
				var tabActivity = (AssignmentTabActivity)Parent;
				tabActivity.MapData = null;
				assignmentViewModel.SelectedAssignment = assignmentViewModel.ActiveAssignment;
				menuViewModel.MenuIndex = Constants.Navigation.IndexOf ("Map");
				StartActivity (intent);
			};
	    
			mapView = FindViewById<MapView> (Resource.Id.googleMapsView);
			mapView.OnCreate (bundle);
			mapView.GetMapAsync (this);

			//View containing the active assignment
			var view = new View (this);
			LayoutInflater inflator = (LayoutInflater)GetSystemService (Context.LayoutInflaterService);
			view = inflator.Inflate (Resource.Layout.AssignmentItemLayout, null);
			assignmentMapViewLayout.AddView (view);
			view.LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
			view.SetBackgroundDrawable (Resources.GetDrawable (Resource.Drawable.active_assignment_selector));
			number = view.FindViewById<TextView> (Resource.Id.assignmentItemNumber);
			job = view.FindViewById<TextView> (Resource.Id.assignmentJob);
			name = view.FindViewById<TextView> (Resource.Id.assignmentName);
			phone = view.FindViewById<TextView> (Resource.Id.assignmentPhone);
			address = view.FindViewById<TextView> (Resource.Id.assignmentAddress);
			buttonLayout = view.FindViewById<LinearLayout> (Resource.Id.assignmentButtonLayout);
			timerLayout = view.FindViewById<LinearLayout> (Resource.Id.assignmentTimerLayout);
			activeSpinner = view.FindViewById<Spinner> (Resource.Id.assignmentStatus);
			spinnerImage = view.FindViewById<ImageView> (Resource.Id.assignmentStatusImage);
			timer = view.FindViewById<ToggleButton> (Resource.Id.assignmentTimer);
			timerText = view.FindViewById<TextView> (Resource.Id.assignmentTimerText);
			phoneButton = view.FindViewById<RelativeLayout> (Resource.Id.assignmentPhoneLayout);
			mapButton = view.FindViewById<RelativeLayout> (Resource.Id.assignmentAddressLayout);

			phoneButton.Click += (sender, e) => {
				Extensions.MakePhoneCall (this, phone.Text);
			};

			mapButton.Click += (sender, e) => {
				var intent = new Intent (this, typeof(SummaryActivity));
				var tabActivity = (AssignmentTabActivity)Parent;
				tabActivity.MapData = null;
				assignmentViewModel.SelectedAssignment = assignmentViewModel.ActiveAssignment;
				menuViewModel.MenuIndex = 0;
				StartActivity (intent);
			};

			assignmentViewModel.LoadTimerEntryAsync ().ContinueWith (_ => {
				RunOnUiThread (() => {
					timer.Checked = assignmentViewModel.Recording;
				});
			});

			timer.CheckedChange += (sender, e) => {
				if (e.IsChecked != assignmentViewModel.Recording) {
					if (assignmentViewModel.Recording)
						assignmentViewModel.PauseAsync ();
					else
						assignmentViewModel.RecordAsync ();
				}
			};

			activeSpinner.ItemSelected += (sender, e) => {

				if (assignment == null)
					return;
				
				var selected = assignmentViewModel.AvailableStatuses.ElementAtOrDefault (e.Position);
				if (selected != assignment.Status) {
					switch (selected) {
					case AssignmentStatus.Hold:
						assignment.Status = selected;
						assignmentViewModel.SaveAssignmentAsync (assignment).ContinueWith (_ => {
							RunOnUiThread (() => {
								SetAssignment (false);
								UpdateLocations ();
							});
						});
						break;
					case AssignmentStatus.Complete:
						var intent = new Intent (this, typeof(SummaryActivity));
						menuViewModel.MenuIndex = Constants.Navigation.IndexOf (Constants.Confirmations);
						StartActivity (intent);
						break;
					default:
						break;
					}
				}
			};
		}
Exemple #9
0
		public override void OnViewCreated (View view, Bundle savedInstanceState)
		{
			base.OnViewCreated (view, savedInstanceState);
			view.SetBackgroundDrawable (AndroidExtensions.DefaultBackground);
		}
		public static void setBackground(View view, Drawable background) {
			view.SetBackgroundDrawable(background);
		}
	    /**
	     * Sets the resource ID of the separator drawable to use between adjacent screens.
	     */
	    public void SetSeparator(int resId) {
	        if (mSeparatorDrawable != null && resId == 0) {
	            // remove existing separators
	            mSeparatorDrawable = null;
	            int num = ChildCount;
	            for (int i = num - 2; i > 0; i -= 2) {
	                RemoveViewAt(i);
	            }
	            RequestLayout();
	        } else if (resId != 0) {
	            // add or update separators
	            if (mSeparatorDrawable == null) {
	                // add
	                int numsep = ChildCount;
	                int insertIndex = 1;
	                mSeparatorDrawable = Resources.GetDrawable(resId);
	                for (int i = 1; i < numsep; i++) {
	                    View v = new View(Context);
	                    v.SetBackgroundDrawable(mSeparatorDrawable);
	                    LayoutParams lp = new LayoutParams(LayoutParams.WrapContent,LayoutParams.FillParent);
	                    v.LayoutParameters = lp;
	                    AddView(v, insertIndex);
	                    insertIndex += 2;
	                }
	                RequestLayout();
	            } else {
	                // update
	                mSeparatorDrawable = Resources.GetDrawable(resId);
	                int num = ChildCount;
	                for (int i = num - 2; i > 0; i -= 2) {
	                    GetChildAt(i).SetBackgroundDrawable(mSeparatorDrawable);
	                }
	                RequestLayout();
	            }
	        }
	    }
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);

            view.SetBackgroundDrawable(AndroidExtensions.DefaultBackground);

            mapFragment?.GetMapAsync(this);



		
            // Setup info pane
            SetSvgImage(pane, Resource.Id.bikeImageView, Resource.Raw.bike);
            SetSvgImage(pane, Resource.Id.lockImageView, Resource.Raw.ic_lock);
            SetSvgImage(pane, Resource.Id.stationLock, Resource.Raw.station_lock);
            SetSvgImage(pane, Resource.Id.bikeNumberImg, Resource.Raw.bike_number);
            SetSvgImage(pane, Resource.Id.clockImg, Resource.Raw.clock);
            SetSvgImage(pane, Resource.Id.stationNotInstalled, Resource.Raw.not_installed);
            starOnDrawable = SvgFactory.GetDrawable(Resources, Resource.Raw.star_on);
            starOffDrawable = SvgFactory.GetDrawable(Resources, Resource.Raw.star_off);
            var starBtn = pane.FindViewById<ImageButton>(Resource.Id.StarButton);
            starBtn.Click += HandleStarButtonChecked;
            streetViewFragment?.GetStreetViewPanoramaAsync(this);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView (Resource.Layout.AssignmentsLayout);

            assignmentsListView = FindViewById<ListView> (Resource.Id.assignmentsListView);
            assignmentActiveLayout = FindViewById<LinearLayout> (Resource.Id.assignmentSelectedItem);
            assignmentActiveLayout.Click += (sender, e) => AssignmentSelected (-1);

            assignmentsListView.ItemClick += (sender, e) => AssignmentSelected (e.Position);

            //View containing the active assignment
            var view = new View (this);
            LayoutInflater inflator = (LayoutInflater)GetSystemService (Context.LayoutInflaterService);
            view = inflator.Inflate (Resource.Layout.AssignmentItemLayout, null);
            assignmentActiveLayout.AddView (view);
            view.LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
            view.SetBackgroundDrawable (Resources.GetDrawable (Resource.Drawable.active_assignment_selector));
            number = view.FindViewById<TextView> (Resource.Id.assignmentItemNumber);
            job = view.FindViewById<TextView> (Resource.Id.assignmentJob);
            name = view.FindViewById<TextView> (Resource.Id.assignmentName);
            phone = view.FindViewById<TextView> (Resource.Id.assignmentPhone);
            address = view.FindViewById<TextView> (Resource.Id.assignmentAddress);
            buttonLayout = view.FindViewById<LinearLayout> (Resource.Id.assignmentButtonLayout);
            timerLayout = view.FindViewById<LinearLayout> (Resource.Id.assignmentTimerLayout);
            activeSpinner = view.FindViewById<Spinner> (Resource.Id.assignmentStatus);
            spinnerImage = view.FindViewById<ImageView> (Resource.Id.assignmentStatusImage);
            timer = view.FindViewById<ToggleButton> (Resource.Id.assignmentTimer);
            timerText = view.FindViewById<TextView> (Resource.Id.assignmentTimerText);
            phoneButton = view.FindViewById<RelativeLayout> (Resource.Id.assignmentPhoneLayout);
            mapButton = view.FindViewById<RelativeLayout> (Resource.Id.assignmentAddressLayout);

            timer.CheckedChange += (sender, e) => {
                if (e.IsChecked != assignmentViewModel.Recording) {
                    if (assignmentViewModel.Recording)
                        assignmentViewModel.PauseAsync ();
                    else
                        assignmentViewModel.RecordAsync ();
                }
            };

            activeSpinner.ItemSelected += (sender, e) => {
                if (assignment != null) {
                    var selected = assignmentViewModel.AvailableStatuses.ElementAtOrDefault (e.Position);
                    if (selected != assignment.Status) {
                        switch (selected) {
                        case AssignmentStatus.Hold:
                            timer.Checked = false;
                            assignment.Status = selected;
                            assignmentViewModel.SaveAssignmentAsync (assignment).ContinueWith (_ => RunOnUiThread (ReloadAssignments));
                            break;
                        case AssignmentStatus.Complete:
                               				//go to confirmations, this is getting called multiple times.
                            var intent = new Intent (this, typeof(SummaryActivity));
                            assignmentViewModel.SelectedAssignment = assignment;
                            menuViewModel.MenuIndex = Constants.Navigation.IndexOf (Constants.Confirmations);
                            StartActivity (intent);
                            break;
                        default:
                            break;
                        }
                    }
                }
            };

            mapButton.Click += (sender, e) => {
                var activity = (AssignmentTabActivity)Parent;
                var intent = new Intent (activity, typeof(SummaryActivity));
                menuViewModel.MenuIndex = Constants.Navigation.IndexOf ("Map");
                assignmentViewModel.SelectedAssignment = assignmentViewModel.ActiveAssignment;
                activity.StartActivity (intent);
            };

            phoneButton.Click += (sender, e) => {
                Extensions.MakePhoneCall (this, phone.Text);
            };
        }
 public static void SetBackgroundCompat(View view, Drawable d)
 {
     if (Build.VERSION.SdkInt < BuildVersionCodes.JellyBean)
     {
         view.SetBackgroundDrawable(d);
     }
     else
     {
         view.Background = d;
     }
 }