コード例 #1
0
        private void ChangeCursorColor(Color color)
        {
            if (this.Control == null)
            {
                return;
            }

            try
            {
                if ((int)Build.VERSION.SdkInt >= 29)                // Android.OS.BuildVersionCodes.Q)
                {
                    var qCursorDrawable = this.Control.TextCursorDrawable;

                    qCursorDrawable.SetColorFilter(color, PorterDuff.Mode.SrcIn);

                    this.Control.TextCursorDrawable = qCursorDrawable;

                    return;
                }

                var cursorResource = Java.Lang.Class.FromType(typeof(TextView)).GetDeclaredField(CURSOR_DRAWABLE_RESOURCE);

                cursorResource.Accessible = true;

                int resId = cursorResource.GetInt(this.Control);

                Java.Lang.Reflect.Field editorField = Java.Lang.Class.FromType(typeof(TextView)).GetDeclaredField(EDITOR_FIELD);

                editorField.Accessible = true;

                Drawable cursorDrawable = Context.GetDrawable(resId);

                cursorDrawable.SetColorFilter(color, PorterDuff.Mode.SrcIn);



                Java.Lang.Object editor = editorField.Get(this.Control);

                if ((int)Build.VERSION.SdkInt >= 28)                //Android.OS.BuildVersionCodes.P)
                {
                    Java.Lang.Reflect.Field drawableForCursorField = editor.Class.GetDeclaredField(DRAWABLE_FOR_CURSOR_FIELD);

                    drawableForCursorField.Accessible = true;

                    drawableForCursorField.Set(editor, cursorDrawable);
                }
                else
                {
                    Java.Lang.Reflect.Field cursorDrawableField = editor.Class.GetDeclaredField(CUSROR_DRAWABLE_FIELD);

                    cursorDrawableField.Accessible = true;

                    cursorDrawableField.Set(editor, new[] { cursorDrawable, cursorDrawable });
                }
            }
            catch (Exception ex)
            {
                // Whoops chaning the cursor color is not supported :(
            }
        }
        private bool CheckSmallIconInMIUI(Notification notification)
        {
            try
            {
                Java.Lang.Class         miuiNotificationClass = Java.Lang.Class.ForName("android.app.MiuiNotification");
                Java.Lang.Object        miuiNotification      = miuiNotificationClass.NewInstance();
                Java.Lang.Reflect.Field field = miuiNotification.Class.GetDeclaredField("customizedIcon");
                field.Accessible = true;
                field.Set(miuiNotification, true);
                field            = notification.Class.GetField("extraNotification");
                field.Accessible = true;
                field.Set(notification, miuiNotification);

                return(true);
            }
            catch (Java.Lang.Exception e)
            {
                return(false);
            }
        }
コード例 #3
0
 public static void SetNumberPickerDividerHeight(NumberPicker numberPicker, int height)
 {
     try
     {
         Java.Lang.Reflect.Field field = numberPicker.Class.GetDeclaredField("mSelectionDividerHeight");
         field.Accessible = true;
         field.Set(numberPicker, height);
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine("SetNumberPickerDividerHeight failed.", e);
     }
 }
コード例 #4
0
 public static void SetNumberPickerDividerColor(NumberPicker numberPicker, Xamarin.Forms.Color color)
 {
     try
     {
         Java.Lang.Reflect.Field field = numberPicker.Class.GetDeclaredField("mSelectionDivider");
         field.Accessible = true;
         field.Set(numberPicker, new ColorDrawable(color.ToAndroid()));
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine("SetNumberPickerDividerColor failed.", e);
     }
 }
コード例 #5
0
        public void SetInputTextLayoutColor(TextInputLayout til, Android.Graphics.Color color)
        {
            try
            {
                Java.Lang.Reflect.Field fDefaultTextColor = Java.Lang.Class.FromType(typeof(TextInputLayout)).GetDeclaredField("mDefaultTextColor");
                fDefaultTextColor.Accessible = true;
                fDefaultTextColor.Set(til, new ColorStateList(new int[][] { new int[] { 0 } }, new int[] { entry.PlaceholderColor.ToAndroid() }));

                Java.Lang.Reflect.Field fFocusedTextColor = Java.Lang.Class.FromType(typeof(TextInputLayout)).GetDeclaredField("mFocusedTextColor");
                fFocusedTextColor.Accessible = true;
                fFocusedTextColor.Set(til, new ColorStateList(new int[][] { new int[] { 0 } }, new int[] { entry.TextColor.ToAndroid() }));
            }
            catch
            {
            }
        }
コード例 #6
0
 internal override void SetCount(int badgeCount)
 {
     try
     {
         CurrentCount = badgeCount;
         Java.Lang.Class         miuiNotificationClass = Java.Lang.Class.ForName("android.app.MiuiNotification");
         Java.Lang.Object        miuiNotification      = miuiNotificationClass.NewInstance();
         Java.Lang.Reflect.Field field = miuiNotification.Class.GetDeclaredField("messageCount");
         field.Accessible = true;
         field.Set(miuiNotification, badgeCount == 0 ? "" : badgeCount.ToString());
     }
     catch (Exception e)
     {
         Intent localIntent = new Intent(
             INTENT_ACTION);
         localIntent.PutExtra(EXTRA_UPDATE_APP_COMPONENT_NAME, GetContextPackageName() + "/" + GetEntryActivityName());
         localIntent.PutExtra(EXTRA_UPDATE_APP_MSG_TEXT, badgeCount == 0 ? "" : badgeCount.ToString());
         mContext.SendBroadcast(localIntent);
     }
 }
コード例 #7
0
        private void ChangeCursorColor(Color color)
        {
            if (this.Control == null)
            {
                return;
            }

            try
            {
                var cursorResource = Java.Lang.Class.FromType(typeof(TextView)).GetDeclaredField(CURSOR_DRAWABLE_RESOURCE);

                cursorResource.Accessible = true;

                int resId = cursorResource.GetInt(this.Control);

                Java.Lang.Reflect.Field editorField = Java.Lang.Class.FromType(typeof(TextView)).GetDeclaredField(EDITOR_FIELD);

                editorField.Accessible = true;

                Drawable cursorDrawable = Context.GetDrawable(resId);

                cursorDrawable.SetColorFilter(new BlendModeColorFilter(color, BlendMode.SrcIn));

                Java.Lang.Object editor = editorField.Get(this.Control);

                Java.Lang.Reflect.Field cursorDrawableField = editor.Class.GetDeclaredField(CUSROR_DRAWABLE_FIELD);

                cursorDrawableField.Accessible = true;

                cursorDrawableField.Set(editor, new[] { cursorDrawable, cursorDrawable });
            }
            catch (Exception)
            {
                // Whoops chaning the cursor color is not supported :(
            }
        }
コード例 #8
0
 private void SetHintLabelColor(Java.Lang.Reflect.Field hint, AColor color)
 {
     hint.Accessible = true;
     hint.Set(Control, new ColorStateList(new[] { new[] { 0 } }, new int[] { color }));
 }