/// <summary>
        /// Gets the color from resource.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="packageName">Name of the package.</param>
        /// <param name="resName">Name of the resource.</param>
        /// <returns></returns>
        public static Int32 GetColorFromResource(Context context, String packageName, String resName)
        {
            var resources = context.Resources;
            var resId     = resources.GetIdentifier(resName, "color", packageName);

            if (resId <= 0)
            {
                return(Int32.MaxValue);
            }
            return(ContextCompat.GetColor(context, resId));
        }
Example #2
0
        public LeftOffsetItemDecoration(Context context, int colorResId, int leftOffsetDpi, int heightDpi = 1)
        {
            _leftOffset   = context.ToPixels(leftOffsetDpi);
            _bottomOffset = context.ToPixels(heightDpi);

            _paint = new Paint
            {
                Color       = new Color(ContextCompat.GetColor(context, colorResId)),
                StrokeWidth = _bottomOffset
            };
        }
 private void RefreshStatusBar(Activity ctx)
 {
     if ((int)Build.VERSION.SdkInt >= 21)
     {
         TypedValue typedValue = new TypedValue();
         var        theme      = ctx.Theme;
         theme.ResolveAttribute(Resource.Color.colorPrimaryDark, typedValue, true);
         var color = new Color(ContextCompat.GetColor(ctx, typedValue.ResourceId));
         ctx.Window.SetStatusBarColor(color);
     }
 }
        private Paint GetTextPaint()
        {
            var paint = new Paint();

            paint.TextSize   = (float)(height * textPercentHeight);
            paint.TextScaleX = 1;
            paint.AntiAlias  = true;
            paint.TextAlign  = Align.Right;
            paint.Color      = new Color(ContextCompat.GetColor(Application.Context, Resource.Color.areas_description_tex_color));
            return(paint);
        }
Example #5
0
        private void SetupSubTextWithLink(TextView textView, string formattedText)
        {
            ISpanned formattedDescription = HtmlCompat.FromHtml(formattedText, HtmlCompat.FromHtmlModeLegacy);

            textView.TextFormatted = formattedDescription;
            textView.ContentDescriptionFormatted = formattedDescription;
            textView.MovementMethod = LinkMovementMethod.Instance;
            Color linkColor = new Color(ContextCompat.GetColor(this, Resource.Color.linkColor));

            textView.SetLinkTextColor(linkColor);
        }
Example #6
0
 public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
 {
     base.OnCreate(savedInstanceState, persistentState);
     GlobalConstant.AccessToken = CommonHelper.GetAuthKey();
     SetContentView(Resource.Layout.SplashScreen);
     if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
     {
         Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
         Window.SetStatusBarColor(new Android.Graphics.Color(ContextCompat.GetColor(this, Resource.Color.primary_material_dark)));
     }
 }
        internal static void ShowSnackBar_WithOKButtonToClose(Context context, View view, int iResourceStringID)
        {
            Snackbar bar = Snackbar.Make(view, iResourceStringID, Snackbar.LengthIndefinite);

            bar.View.SetBackgroundColor(new Android.Graphics.Color(ContextCompat.GetColor(context, Resource.Color.primary_dark)));

            bar.SetAction(Resource.String.snackbar_OK, (v) => { });
            bar.SetActionTextColor(new Android.Graphics.Color(ContextCompat.GetColor(context, Resource.Color.primary_light)));

            bar.Show();
        }
Example #8
0
        public void ShowCustomWebView(object sender, EventArgs e)
        {
            int accentColor = ThemeSingleton.Get().WidgetColor;

            if (accentColor == 0)
            {
                accentColor = ContextCompat.GetColor(this, Resource.Color.accent);
            }
            ChangelogDialog.Create(false, accentColor)
            .Show(SupportFragmentManager, "changelog");
        }
        public void OnTabUnselected(TabLayout.Tab tab)
        {
            View view = tab.CustomView;

            if (view != null)
            {
                TextView txt_day = view.FindViewById <TextView>(Resource.Id.txt_tab_reservation);

                txt_day.SetTextColor(new Android.Graphics.Color(ContextCompat.GetColor(Activity, Resource.Color.colorcyan)));
            }
        }
Example #10
0
        protected override void OnCreate(Bundle bundle)
        {
            this.ChangeStatusBarColor(new Color(ContextCompat.GetColor(this, Resource.Color.blueStatusBarBackground)));

            base.OnCreate(bundle);
            SetContentView(Resource.Layout.EditTimeEntryActivity);
            OverridePendingTransition(Resource.Animation.abc_slide_in_bottom, Resource.Animation.abc_fade_out);

            initializeViews();
            setupBindings();
        }
        private void Init()
        {
            int textSize = (35 * parentWidth) / 700;

            SetTextSize(Android.Util.ComplexUnitType.Pt, textSize);
            Color c = new Color(ContextCompat.GetColor(Context, this.textColor));

            SetTextColor(c);
            Gravity = GravityFlags.Center;
            Alpha   = 0.8f;
        }
        /**
         * Set the color resources used in the progress animation from color resources.
         * The first color will also be the color of the bar that grows in response
         * to a user swipe gesture.
         *
         * @param colorResIds
         */
        public void SetColorSchemeResources(int[] colorResIds)
        {
            var colorRes = new int[colorResIds.Length];

            for (var i = 0; i < colorResIds.Length; i++)
            {
                colorRes[i] = ContextCompat.GetColor(Context, colorResIds[i]);
            }

            SetColorSchemeColors(colorRes);
        }
        protected virtual int GetColor(string colorResourceName)
        {
            var colorResourceId = this.core.Android.GetColorByName(colorResourceName);

            if (colorResourceId <= 0)
            {
                throw new ArgumentException($"Color ResourceId for {colorResourceName} not found");
            }

            return(ContextCompat.GetColor(this.core.Android.AppContext, colorResourceId));
        }
Example #14
0
        protected override void OnCreate(Bundle bundle)
        {
            this.ChangeStatusBarColor(new Color(ContextCompat.GetColor(this, Resource.Color.blueStatusBarBackground)));

            base.OnCreate(bundle);
            SetContentView(Resource.Layout.EditActivity);

            OverridePendingTransition(Resource.Animation.abc_fade_in, Resource.Animation.abc_fade_out);

            setupToolbar();
        }
Example #15
0
        private void SetImageColor(ImageView imageView)
        {
            if (imageView != null)
            {
                var drawable = imageView.Drawable;

                var color = new Color(ContextCompat.GetColor(Application.Context, Resource.Color.arrowrightcolor));

                drawable.TintDrawable(color);
            }
        }
Example #16
0
        private static NotificationCompat.Builder SetNotificationColor(Context context, NotificationCompat.Builder builder)
        {
            if (global::Android.OS.Build.VERSION.SdkInt >= global::Android.OS.BuildVersionCodes.Lollipop)
            {
                var blueDocks = ContextCompat.GetColor(context, Resource.Color.blue);

                builder = builder.SetColor(blueDocks);
            }

            return(builder);
        }
        private void Init()
        {
            finalBalance = SumIncomes - SumOutcomes;

            if (finalBalance > 0)
            {
                tvStatus.Text = GetString(Resource.String.we_still_have_money);
                tvFinalBalance.SetTextColor(Context.GetColorStateList(Resource.Color.text_color_blue));
                tvFinalBalance.Text = $"+{finalBalance.ToCurrency()}";
            }
            else
            {
                tvStatus.Text = GetString(Resource.String.We_are_broke_now);
                tvFinalBalance.SetTextColor(Context.GetColorStateList(Resource.Color.text_color_red));
                tvFinalBalance.Text = finalBalance.ToCurrency();
            }

            tvIncome.Text  = $"+{SumIncomes.ToCurrency()}";
            tvOutcome.Text = $"-{SumOutcomes.ToCurrency()}";

            barChart.Description.Enabled  = false;
            barChart.Legend.Enabled       = false;
            barChart.AxisRight.Enabled    = false;
            barChart.AxisLeft.Enabled     = false;
            barChart.AxisLeft.AxisMinimum = 0;
            barChart.XAxis.Position       = XAxis.XAxisPosition.Bottom;
            barChart.XAxis.SetDrawGridLines(false);
            barChart.XAxis.Granularity = 1;
            barChart.SetExtraOffsets(0, 0, 0, 10);
            barChart.SetScaleEnabled(false);

            var labels = new List <string>()
            {
                GetString(Resource.String.income),
                GetString(Resource.String.outcome)
            };

            var barGroup = new List <BarEntry>()
            {
                new BarEntry(0, SumIncomes / 1000f),
                new BarEntry(1, SumOutcomes / 1000f)
            };

            var barDataSet = new BarDataSet(barGroup, null);

            barDataSet.SetColors(new int[] { Resource.Color.income_color, Resource.Color.outcome_color }, Context);
            barDataSet.SetDrawValues(false);

            barChart.XAxis.ValueFormatter = new IndexAxisValueFormatter(labels);
            barChart.XAxis.TextColor      = ContextCompat.GetColor(Context, Resource.Color.text_color_blue);
            barChart.XAxis.TextSize       = Resources.GetDimension(Resource.Dimension.text_size_normal);
            barChart.Data = new BarData(barDataSet);;
            barChart.Invalidate();
        }
        public void OnTabUnselected(TabLayout.Tab tab)
        {
            Activity.RunOnUiThread(() =>
            {
                var textview = tab.CustomView.FindViewById <TextView>(Resource.Id.textView);
                var btmLine  = tab.CustomView.FindViewById <LinearLayout>(Resource.Id.bottom_line);

                textview.SetTextColor(ContextCompat.GetColorStateList(Activity, Resource.Color.areas_description_tex_color));
                btmLine.SetBackgroundColor(new Color(ContextCompat.GetColor(Activity, Resource.Color.areas_description_tex_color)));
                btmLine.Visibility = ViewStates.Invisible;
            });
        }
        private void TabHighlited(TabLayout.Tab tab)
        {
            Activity.RunOnUiThread(() =>
            {
                var textview = tab.CustomView.FindViewById <TextView>(Resource.Id.textView);
                var btmLine  = tab.CustomView.FindViewById <LinearLayout>(Resource.Id.bottom_line);

                textview.SetTextColor(ContextCompat.GetColorStateList(Activity, Resource.Color.tab_selected_color));
                btmLine.SetBackgroundColor(new Color(ContextCompat.GetColor(Activity, Resource.Color.tab_selected_color)));
                btmLine.Visibility = ViewStates.Visible;
            });
        }
Example #20
0
        private void ProgramFab1_Click(object sender, EventArgs e)
        {
            var fab = sender as FloatingActionButton;

            if (fab != null)
            {
                fab.SetLabelColors(ContextCompat.GetColor(this.Activity, Resource.Color.grey),
                                   ContextCompat.GetColor(this.Activity, Resource.Color.light_grey),
                                   ContextCompat.GetColor(this.Activity, Resource.Color.white_transparent));
                fab.SetLabelTextColor(ContextCompat.GetColor(this.Activity, Resource.Color.black));
            }
        }
        void SetDrawableColorPreLollipop(ProgressBar progressBar)
        {
            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                return;
            }

            var mutatedProgressBarDrawable = progressBar.IndeterminateDrawable.Mutate();

            mutatedProgressBarDrawable.SetColorFilter(new Color(ContextCompat.GetColor(this, Resource.Color.uifabric_demo_primary)), PorterDuff.Mode.SrcIn);
            progressBar.IndeterminateDrawable = mutatedProgressBarDrawable;
        }
 public void SetData(string title, UserDTO MeDTO)
 {
     btStatusKind.Text = title;
     if (string.Equals(MeDTO.STATUS_INDICATOR.Trim(), title))
     {
         btStatusKind.SetTextColor(new Android.Graphics.Color(ContextCompat.GetColor(btStatusKind.Context, Resource.Color.colorPrimary)));
     }
     else
     {
         btStatusKind.SetTextColor(new Android.Graphics.Color(ContextCompat.GetColor(btStatusKind.Context, Resource.Color.secondaryTextColor)));
     }
 }
Example #23
0
        private void BackGroundNotification(RemoteMessage message)
        {
            var data  = message.Data;
            var title = data["title"];
            var body  = data["body"];
            var extra = data["Action"];

            Intent intent = new Intent(this, typeof(MainActivity));

            intent.PutExtra("redirect", extra);


            const int     pendingIntentId = 0;
            PendingIntent pendingIntent   =
                PendingIntent.GetActivity(this, pendingIntentId, intent, PendingIntentFlags.OneShot);

            // Instantiate the builder and set notification elements:
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                                                 .SetContentIntent(pendingIntent)
                                                 .SetSmallIcon(Resource.Mipmap.StatusIconTruck)
                                                 .SetContentTitle(title)
                                                 .SetContentText(body)
                                                 .SetBadgeIconType(Resource.Mipmap.StatusIconTruck)
                                                 .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                                                 .SetVibrate(new long[] { 1000, 1000 })
                                                 .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Mipmap.ic_launcher));

            // Build the notification:


            if (Build.VERSION.SdkInt >= Build.VERSION_CODES.Lollipop)
            {
                builder.SetSmallIcon(Resource.Mipmap.StatusIconTruck);
                builder.SetColor(ContextCompat.GetColor(this, Resource.Color.GreenAlert));
            }
            else
            {
                builder.SetSmallIcon(Resource.Mipmap.StatusIconTruck);
            }


            Notification notification = builder.Build();

            //AutoCancel after user touch
            notification.Flags = NotificationFlags.AutoCancel;

            NotificationManager notificationManager =
                GetSystemService(Context.NotificationService) as NotificationManager;

            const int notificationId = 0;

            notificationManager.Notify(notificationId, notification);
        }
Example #24
0
        public ShellPageContainer(Context context, IVisualElementRenderer child, bool inFragment = false) : base(context, child, inFragment)
        {
            if (child.Element.Handler is INativeViewHandler nvh &&
                nvh.VirtualView.Background == null)
            {
                var color = NativeVersion.IsAtLeast(23) ?
                            Context.Resources.GetColor(AColorRes.BackgroundLight, Context.Theme) :
                            new AColor(ContextCompat.GetColor(Context, AColorRes.BackgroundLight));

                nvh.NativeView.SetBackgroundColor(color);
            }
        }
Example #25
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.splash_screen);
     LoadAnimatedGif();
     if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
     {
         Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
         Window.SetStatusBarColor(new Android.Graphics.Color(ContextCompat.GetColor(this, Resource.Color.primaryDark)));
     }
     CrashManager.Register(this, "fc94917a0cd847b59b9df99d55de376a", new crManagerListner());
 }
Example #26
0
            private void UpdateIsSelected()
            {
                if (_mainMenuSelection == _mainScreenView.ViewModel.SelectedItem)
                {
                    View.Background = new ColorDrawable(new Color(ContextCompat.GetColor(View.Context, Resource.Color.primaryLight)));
                }

                else
                {
                    View.Background = null;
                }
            }
Example #27
0
 private async void _checkBtn_Click(object sender, EventArgs e)
 {
     _checkBtn.Enabled = false;
     _checkBtn.HideKeyboard();
     if (string.IsNullOrEmpty(_orderId.Text))
     {
         _orderId.SetHintTextColor(new Color(ContextCompat.GetColor(this, Resource.Color.primary)));
         _checkBtn.Enabled = true;
         return;
     }
     await _presenter.ButtonCheckTapped(_orderId.Text);
 }
Example #28
0
        public void ShowErrorSnack(string message, View v, Action actionCallback = default, string actionName = default)
        {
            var snack = Snackbar.Make(v, message, Snackbar.LengthLong)
                        .SetAction("Dismiss", (s) => { })
                        .SetActionTextColor(ContextCompat.GetColor(v.Context, Resource.Color.colorPrimary));

            if (actionCallback != null && !string.IsNullOrEmpty(actionName))
            {
                snack.SetAction(actionName, (s) => actionCallback.Invoke());
            }
            snack.Show();
        }
Example #29
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var view = base.GetView(position, convertView, parent);
            var icon = view.FindViewById <ImageView>(Resource.Id.challenge_icon);

            if (icon != null)
            {
                icon.SetColorFilter(new Color(ContextCompat.GetColor(Application.Context, Resource.Color.areas_description_tex_color)), PorterDuff.Mode.SrcIn);
            }
            UpdateControls(view);
            return(view);
        }
 public override void convert(EasyLVHolder holder, int position, Java.Lang.String s)
 {
     holder.setText(Resource.Id.tvSelTitleItem, s.ToString());
     if (selPosition == position)
     {
         holder.setTextColor(Resource.Id.tvSelTitleItem, ContextCompat.GetColor(mContext, Resource.Color.light_pink));
     }
     else
     {
         holder.setTextColor(Resource.Id.tvSelTitleItem, ContextCompat.GetColor(mContext, Resource.Color.light_black));
     }
 }