private void ShowPassword()
 {
     mCbShowPwd.SetButtonDrawable(ResourcesCompat.GetDrawable(Resources,
                                                              Resource.Drawable.ic_eye_strike,
                                                              Activity.Theme));
     mEtPwd.TransformationMethod = HideReturnsTransformationMethod.Instance;
 }
        public HorizontalDividerItemDecoration(Context context, int orientation, int resourceID) : base(context, orientation)
        {
            _dividerDrawable = ResourcesCompat.GetDrawable(context.Resources, resourceID, null);
            _drawableHeight  = _dividerDrawable.IntrinsicHeight;

            Drawable = _dividerDrawable;
        }
Exemple #3
0
        /*
         *      private void OnButtonClick(object sender, EventArgs e)
         *      {
         *          if (sender is AppCompatImageButton imgButton)
         *              Toast.MakeText(this, (string)imgButton.Tag, ToastLength.Short).Show();
         *
         *      }
         */


        private void SetUpToolbar()
        {
            // Not having raised AppBar area, so don't set SupportActionBar
            //SetSupportActionBar(_toolbar);

            // Set the page Title - Required because of the way that Android sets up app asset names
            _toolbar.Title = null;  // using the custom title so it can be centered
            SetToolbarCustomTitle(ViewModel.Response.Name);
            // Set the subtitle
            //            SetToolbarCustomSubtitle("Subtitle");
            //            _toolbar.Subtitle = "Subtitle";
            var closeIcon = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.lclose, null).Mutate();

            DrawableCompat.SetTint(closeIcon, Color.White);
            _toolbar.NavigationIcon = closeIcon;

            var toolbarColor = Constants.GetIconSettingsFromTitle(this, ViewModel.Response.Name).Item2;

            Window.SetStatusBarColor(toolbarColor);
            _toolbar.SetBackgroundColor(toolbarColor);

            // Set toolbar title colors
            _toolbar.SetTitleTextColor(Color.White);
            _toolbar.SetSubtitleTextColor(Color.White);
            SetToolbarCustomTitleColor(Color.White);
            SetToolbarCustomSubtitleColor(Color.White);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                return;
            }

            if (Element != null)
            {
                _dowButton = (DayOfWeekButton)Element;
            }

            if (Control.Width > Control.Height)
            {
                Control.SetHeight(Control.Width);
            }
            else
            {
                Control.SetWidth(Control.Height);
            }

            _dowButton.Clicked += Element_Clicked;

            Control.StateListAnimator = null;
            Control.SetPaddingRelative(0, 0, 0, 0);
            Control.TextSize   = 20;
            Control.Background = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.circle_background, null);
            SetPadding(0, 0, 0, 0);
            ButtonDeselected();
            Control.Elevation = 0;
        }
        /// <summary>
        ///     Adds all markers of the current ExhibitSet to the specified map.
        /// </summary>
        /// <param name="mapView">MapView where the markers should be displayed.</param>
        private void SetAllMarkers(MapView mapView)
        {
            LocationOverlay   = new MyLocationOverlay(Activity, mapView);
            MyScaleBarOverlay = new ScaleBarOverlay(Activity);

            var markerInfoWindow = new ViaPointInfoWindow(Resource.Layout.navigation_info_window, mapView, Activity);
            var mapMarkerIcon    = ContextCompat.GetDrawable(Activity, Resource.Drawable.marker_blue);
            var setMarker        = new SetMarker(mapView, markerInfoWindow);


            foreach (var e in ExhibitSet.ActiveSet)
            {
                //One Marker Object
                var geoPoint = new GeoPoint(e.Location.Latitude, e.Location.Longitude);
                var marker   = setMarker.AddMarker(null, e.Name, e.Description, geoPoint, mapMarkerIcon, e.Id);
                mapView.OverlayManager.Add(marker);
            }


            userPosition = new Marker(mapView);
            userPosition.SetIcon(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.ic_my_location, null));
            userPosition.Position = new GeoPoint(GeoLocation.Latitude, GeoLocation.Longitude);
            userPosition.SetInfoWindow(null);
            mapView.OverlayManager.Add(userPosition);

            mapView.OverlayManager.Add(MyScaleBarOverlay);
            mapView.OverlayManager.Add(LocationOverlay);
            mapView.Invalidate();
        }
Exemple #6
0
        private void Init(Context context)
        {
            _activity = context as MainActivity;
            // set some styles
            SetHintTextColor(Color.LightGray);
            // The image we defined for the clear button
            imgClearButton = ResourcesCompat.GetDrawable(context.Resources, Resource.Drawable.clear, null);
            SetOnTouchListener(new CustomOnTouchListener());
            FocusChange += (s, e) =>
            {
                if (e.HasFocus)
                {
                    if (CrossCurrentActivity.Current.Activity is MainActivity)
                    {
                        (CrossCurrentActivity.Current.Activity as MainActivity).CloseDrawer();
                    }
                }
            };

            TextChanged += (s, e) =>
            {
                if (Text.Length > 0)
                {
                    ShowClearButton();
                }
                else
                {
                    HideClearButton();
                }
            };
        }
Exemple #7
0
        private void CreateLabels()
        {
            foreach (var child in _originalChildren)
            {
                var layoutParameters = child.LayoutParameters as LayoutParams;

                if (!string.IsNullOrEmpty(layoutParameters.LabelText))
                {
                    var label = new TextView(Context)
                    {
                        Text               = layoutParameters.LabelText,
                        TextSize           = layoutParameters.LabelTextSize,
                        BackgroundTintList = ColorStateList.ValueOf(layoutParameters.LabelBackgroundColor),
                        Background         = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.fab_label_background, null),
                        Visibility         = ViewStates.Gone,
                        Clickable          = true
                    };
                    label.SetTextColor(layoutParameters.LabelTextColor);
                    label.Click += (s, e) => child.CallOnClick();

                    AddView(label);
                    child.SetTag(Resource.Id.fab_label, label);
                }
            }
        }
        public void AddFromBitmap(View view)
        {
            if (hMap == null)
            {
                return;
            }
            if (null != overlay)
            {
                overlay.Remove();
            }
            Log.Debug(TAG, "AddFromBitmap: ");
            Drawable vectorDrawable = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.niuyouguo, null);
            Bitmap   bitmap         = Bitmap.CreateBitmap(vectorDrawable.IntrinsicWidth, vectorDrawable.IntrinsicHeight,
                                                          Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(bitmap);

            vectorDrawable.SetBounds(0, 0, canvas.Width, canvas.Height);
            vectorDrawable.Draw(canvas);
            GroundOverlayOptions options = new GroundOverlayOptions().Position(MapUtils.FRANCE2, 50, 50)
                                           .InvokeImage(BitmapDescriptorFactory.FromBitmap(bitmap));

            overlay = hMap.AddGroundOverlay(options);
            CameraPosition cameraPosition = new
                                            CameraPosition.Builder().Target(MapUtils.FRANCE2).Zoom(18).Bearing(0f).Tilt(0f).Build();
            CameraUpdate cameraUpdate = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            hMap.MoveCamera(cameraUpdate);
        }
Exemple #9
0
 private void UpdateColors()
 {
     if (Build.VERSION.SdkInt <= BuildVersionCodes.LollipopMr1)
     {
         // Android 5.x doesn't support ThumbTintList, and using SwitchCompat on every version after 5.x
         // doesn't apply tinting the way we want. Let 5.x to do its own thing here.
         return;
     }
     if (Control != null)
     {
         var t = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.switch_thumb, null);
         if (t is GradientDrawable thumb)
         {
             Control.ThumbDrawable = thumb;
         }
         var thumbStates = new[]
         {
             new[] { Android.Resource.Attribute.StateChecked },  // checked
             new[] { -Android.Resource.Attribute.StateChecked }, // unchecked
         };
         var thumbColors = new int[]
         {
             ThemeHelpers.SwitchOnColor,
             ThemeHelpers.SwitchThumbColor
         };
         Control.ThumbTintList = new ColorStateList(thumbStates, thumbColors);
     }
 }
Exemple #10
0
        /// <summary>
        /// Everything regarding location changes is handled here
        /// </summary>
        /// <param name="gpsLocation">Location from Gps</param>
        private void NewElementOnGpsLocationChanged(GeoLocation?gpsLocation)
        {
            //Userposition is always updated and shown if position is available
            if (gpsLocation != null)
            {
                var userPosition = new GeoPoint(gpsLocation.Value.Latitude, gpsLocation.Value.Longitude);
                if (userMarkerPosition != null)
                {
                    mapView.OverlayManager.Remove(userMarkerPosition);
                }

                userMarkerPosition = new Marker(mapView);
                userMarkerPosition.SetIcon(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.ic_my_location, null));
                userMarkerPosition.Position = userPosition;
                userMarkerPosition.SetInfoWindow(null);
                mapView.OverlayManager.Add(userMarkerPosition);
                mapView.Invalidate();
            }

            //if navigation is enabled the route will be drawn and updated
            if (osmMap.ShowNavigation)
            {
                CalculateRoute(gpsLocation);
            }
            else if (osmMap.ShowDetailsRoute)
            {
                DrawDetailsRoute(gpsLocation);
            }
        }
Exemple #11
0
        private void InitializeFromAttributes(Context context, IAttributeSet attrs)
        {
            var attr = context.ObtainStyledAttributes(attrs, Resource.Styleable.FloatingActionMenu, 0, 0);

            Icon = attr.GetDrawable(Resource.Styleable.FloatingActionMenu_buttonIcon)
                   ?? ResourcesCompat.GetDrawable(Resources, Resource.Drawable.fab_add, null);
            BackgroundColor = attr.GetColor(Resource.Styleable.FloatingActionMenu_buttonBackgroundColor, unchecked ((int)0xFF263238));
            ButtonElevation = attr.GetFloat(Resource.Styleable.FloatingActionMenu_buttonElevation, 0.0f);
            ButtonSpacing   = attr.GetInteger(Resource.Styleable.FloatingActionMenu_buttonSpacing, BUTTON_SPACING);
            OpenOnHold      = attr.GetBoolean(Resource.Styleable.FloatingActionMenu_openOnHold, false);
            OpenDirection   = attr.GetInteger(Resource.Styleable.FloatingActionMenu_openDirection, OPEN_UP);

            if (bool.TryParse(attrs.GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_alignParentLeft"), out bool alignLeft))
            {
                _alignLeft = alignLeft;
            }

            if (bool.TryParse(attrs.GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_alignParentTop"), out bool alignTop))
            {
                _alignTop = alignTop;
            }

            if (bool.TryParse(attrs.GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_alignParentRight"), out bool alignRight))
            {
                _alignRight = alignRight;
            }

            if (bool.TryParse(attrs.GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_alignParentBottom"), out bool alignBottom))
            {
                _alignBottom = alignBottom;
            }


            CreateMenuButton();
        }
 protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
 {
     base.OnElementChanged(e);
     if (Control != null)
     {
         Control.SetBackground(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.SearchBarStyle, null));
     }
 }
Exemple #13
0
        private GradientDrawable CreateBG(Context context, int id)
        {
            var colorString     = Preferences.Get($"{SettingConstants.WIDGET_BACKGROUND}_{id}", "#FFFFFF");
            var roundedDrawable = ResourcesCompat.GetDrawable(context.Resources, Resource.Drawable.rounded_background, null) as GradientDrawable;

            roundedDrawable.SetColor(Color.ParseColor(colorString));

            return(roundedDrawable);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.SetBackground(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.border_text, null));
            }
        }
Exemple #15
0
        public void SetIconResource(int resId)
        {
            var drw = ResourcesCompat.GetDrawable(Resources, resId, null);

            if (drw != null)
            {
                IconDrawable = drw;
            }
        }
Exemple #16
0
 protected override void OnElementChanged(ElementChangedEventArgs <Slider> e)
 {
     base.OnElementChanged(e);
     if (Control != null)
     {
         var thumb = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.slider_thumb, null);
         Control.SetThumb(thumb);
     }
 }
Exemple #17
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.SetBackgroundColor(Android.Graphics.Color.White);
                Control.SetBackground(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.edit_text_style, null));
            }
        }
        /**
         * Demonstrates converting any Drawable to an Icon, for use as a marker icon.
         */
        public static Icon drawableToIcon(Context context, int id)
        {
            var vectorDrawable = ResourcesCompat.GetDrawable(context.Resources, id, context.Theme);
            var bitmap         = Bitmap.CreateBitmap(vectorDrawable.IntrinsicWidth, vectorDrawable.IntrinsicHeight, Bitmap.Config.Argb8888);
            var canvas         = new Canvas(bitmap);

            vectorDrawable.SetBounds(0, 0, canvas.Width, canvas.Height);
            vectorDrawable.Draw(canvas);
            return(IconFactory.GetInstance(context).FromBitmap(bitmap));
        }
 private void SetControlStyle()
 {
     if (Control != null)
     {
         Drawable imgDropDownArrow = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.arrow1, null);
         //Resources.GetDrawable(Resource.Drawable.arrow);
         imgDropDownArrow.SetBounds(0, 0, 15, 0);
         Control.SetCompoundDrawablesRelativeWithIntrinsicBounds(null, null, imgDropDownArrow, null);
     }
 }
 void SetCircleBackground()
 {
     //Set our control background to round drawable and overlay our background color as long as our background color isn't transparent
     if (Element.BackgroundColor != default(Xamarin.Forms.Color) && Element.BackgroundColor != Xamarin.Forms.Color.Transparent)
     {
         Control.Background = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.circle_background, null);
         Control.Background.SetColorFilter(Element.BackgroundColor.ToAndroid(), PorterDuff.Mode.Src);
         Element.BackgroundColor = XFColor.Transparent;
     }
 }
Exemple #21
0
        protected override IShellToolbarTracker CreateTrackerForToolbar(Toolbar toolbar)
        {
            var d = ResourcesCompat.GetDrawable(context.Resources, Resource.Drawable.toolbar_bg, null);

            toolbar.SetBackground(d);

            var t = base.CreateTrackerForToolbar(toolbar);

            return(t);
        }
 void OnIsValidChanged(object sender, System.EventArgs e)
 {
     if ((Element as CustomEntry).IsValid != true)
     {
         Control.Background = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.control_background_invalid, null);
     }
     else
     {
         Control.Background = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.control_selector, null);
     }
 }
        protected override Android.Widget.ProgressBar CreateNativeControl()
        {
            var progressbar = new Android.Widget.ProgressBar(Context, null, global::Android.Resource.Attribute.ProgressBarStyleHorizontal)
            {
                Indeterminate = false,
                Max           = 10000,
                //Background = ResourcesCompat.GetDrawable(Context.Resources, Resource.Drawable.progressGradient, null)
                ProgressDrawable = ResourcesCompat.GetDrawable(Context.Resources, Resource.Drawable.progressGradient, null)
            };

            return(progressbar);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
            }

            if (e.NewElement != null)
            {
                Control.SetBackground(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.button_style, null));
            }
        }
        public void Update(GeoLocation loc)
        {
            GeoPoint p = new GeoPoint(loc.Latitude, loc.Longitude);

            mapController.SetCenter(p);

            userPosition.SetIcon(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.ic_my_location, null));
            userPosition.Position = new GeoPoint(p.Latitude, p.Longitude);
            userPosition.SetInfoWindow(null);
            mapView.OverlayManager.Add(userPosition);
            mapView.Invalidate();
            GeoLocation = loc;
        }
        private Drawable GetBackgroundDrawable()
        {
            GradientDrawable drawable = (GradientDrawable)ResourcesCompat.GetDrawable(
                res: Resources,
                id: Resource.Drawable.bkg_roundedview,
                theme: null);

            if (Element is PinItemView element)
            {
                drawable.SetStroke(1, element.BorderColor.ToAndroid());
            }
            return(drawable);
        }
Exemple #27
0
        public static LayerDrawable CircularIcon(Context ctx, int iconResId, ColorStateList iconColorList, ColorStateList backgroundColorList, int iconPadding = 10, int intrinsicSize = 100)
        {
            var icon = ResourcesCompat.GetDrawable(ctx.Resources, iconResId, null);

            icon?.SetTintList(iconColorList);
            var backgroundDrawable = Circle();

            backgroundDrawable?.SetTintList(backgroundColorList);
            var drw = new LayerDrawable(new Drawable[] { backgroundDrawable, icon });

            drw.SetLayerSize(0, intrinsicSize, intrinsicSize);
            drw.SetLayerInset(1, iconPadding, iconPadding, iconPadding, iconPadding);
            return(drw);
        }
Exemple #28
0
 protected override void OnElementChanged(ElementChangedEventArgs <Slider> e)
 {
     base.OnElementChanged(e);
     if (Control != null && Element is ExtendedSlider view)
     {
         var t = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.slider_thumb, null);
         if (t is GradientDrawable thumb)
         {
             thumb.SetColor(view.ThumbColor.ToAndroid());
             thumb.SetStroke(3, view.ThumbBorderColor.ToAndroid());
             Control.SetThumb(thumb);
         }
     }
 }
        private Drawable GetDrawable1(string imageEntryImage)
        {
            Drawable imgDropDownArrow = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.dropdown, null);

            //Resources.GetDrawable(Resource.Drawable.arrow);
            imgDropDownArrow.SetBounds(0, 0, 15, 0);
            // Control.SetCompoundDrawablesRelativeWithIntrinsicBounds(null, null, imgDropDownArrow, null);

            //int resID = Resources.GetIdentifier(imageEntryImage, "drawable", this.Context.PackageName);
            //var drawable = ContextCompat.GetDrawable(this.Context, resID);
            //var bitmap = ((BitmapDrawable)drawable).Bitmap;
            return(imgDropDownArrow);
            //return new BitmapDrawable(Resources, Bitmap.CreateScaledBitmap(bitmap, element.ImageWidth1 , element.ImageHeight1 , true));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.WidgetSetting);
            SetSupportActionBar(FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.toolbar));
            Title = AppResources.WidgetConfigure_Title;

            var mExtras = Intent.Extras;

            if (mExtras != null)
            {
                widgetId    = mExtras.GetInt(AppWidgetManager.ExtraAppwidgetId, AppWidgetManager.InvalidAppwidgetId);
                bgSelectKey = $"{SettingConstants.WIDGET_BACKGROUND}_{widgetId}";
            }
            else
            {
                return;
            }

            if (!Preferences.ContainsKey(bgSelectKey))
            {
                Preferences.Set(bgSelectKey, selectedColor);
            }

            widgetManager  = AppWidgetManager.GetInstance(this);
            widgetLayoutId = widgetManager.GetAppWidgetInfo(widgetId).InitialLayout;

            remoteView      = new RemoteViews(PackageName, widgetLayoutId);
            previewView     = LayoutInflater.Inflate(widgetLayoutId, null);
            roundedDrawable = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.rounded_background, null) as GradientDrawable;

            //opacitySeekBar = FindViewById<AndroidX.AppCompat.Widget.AppCompatSeekBar>(Resource.Id.WidgetConfigureOpacitySeekBar);
            //opacitySeekBar.ProgressChanged += (sender, e) =>
            //{
            //    opacity = e.Progress;

            //    UpdatePreviewStyle();
            //};

            FindViewById <RadioButton>(Resource.Id.WidgetConfigureBackgroundColorWhite).CheckedChange += WidgetConfigBackgroundSelector_CheckedChange;
            FindViewById <RadioButton>(Resource.Id.WidgetConfigureBackgroundColorBlack).CheckedChange += WidgetConfigBackgroundSelector_CheckedChange;

            FindViewById <FrameLayout>(Resource.Id.WidgetSettingPreviewLayout).AddView(previewView);

            SetPreviewValue();
            UpdatePreviewStyle();
        }